Page 1 of 1

Looks like a bug in "fileio.F": Failing in reading CHGCAR

Posted: Tue Feb 04, 2025 5:20 pm
by zhiyong_zhu

With VASP version 6.4.2, I got the following warning and failed in reading CHGCAR file, but no such issue observed with VASP vesion 5.4.4.
'WARNING: number of atoms are different on CHGCAR file'.
ERROR: charge density could not be read from file CHGCAR for ICHARG>10

Checked the sources code, and it seems to be a bug in "fileio.F":
As I understand, the format of CHGCAR file has changed. As a result, in some situations, the 7th line of this file (the number of atoms of each type of atoms) could be quite long and exceeds 80 characters. But in the "fileio.F" file, it reads the first 80 characters of this line only (for example Line 1358 of this file in version 6.4.2), which fails the calculation when reading CHGCAR file.

Please advise if this is a genuine bug or not, or anything could be wrong with compilation.


Re: Looks like a bug in "fileio.F": Failing in reading CHGCAR

Posted: Tue Feb 04, 2025 5:28 pm
by alexey.tal

Dear zhiyong_zhu,

Thank you for your question.

Could you please provide the files so that I can try to reproduce this issue?
Is it really necessary to use more than 80 characters to describe the types in your structure?

Best wishes,
Alexey


Re: Looks like a bug in "fileio.F": Failing in reading CHGCAR

Posted: Tue Feb 04, 2025 6:15 pm
by zhiyong_zhu

Dear Alexey,

Thank you for looking into this.

Actually I don't need 80 characters when preparing the POSCAR file. But when VASP (at least for version 6.4.2) write the CHGCAR file, each atom type will take 16 characters in CHGCAR, and it exceeds 80 characters when the number of atom types is 6 or more. There is no problem when running normal SCF calculations. But when running band structure calculations (set ICHARG=11), we need to read CHGCAR file, especially need to parse that line, and then we hit this error.

I have prepared a simple example to reproduce this issue. Please find below the INCAR, POSCAR, KPOINTS files:

INCAR:
ISTART = 0
ICHARG = 11
PREC = Accurate
ENCUT = 400
ISPIN = 1
ISMEAR = 0
SIGMA = 0.05
EDIFF = 1E-6
ALGO = Normal

POSCAR:
Si
1.00000000000000
5.4300000000000000 0.0000000000000000 0.0000000000000000
0.0000000000000000 5.4300000000000000 0.0000000000000000
0.0000000000000000 0.0000000000000000 5.4300000000000000
Si Si Si Si Si Si Si Si
1 1 1 1 1 1 1 1
Direct
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.5000000000000000 0.5000000000000000 0.0000000000000000
0.0000000000000000 0.5000000000000000 0.5000000000000000
0.5000000000000000 0.0000000000000000 0.5000000000000000
0.2500000000000000 0.2500000000000000 0.2500000000000000
0.7500000000000000 0.7500000000000000 0.2500000000000000
0.2500000000000000 0.7500000000000000 0.7500000000000000
0.7500000000000000 0.2500000000000000 0.7500000000000000

KPOINTS:
K-Spacing Value to Generate K-Mesh: 0.040
0
Monkhorst-Pack
2 2 2
0.0 0.0 0.0

First we run the normal SCF calculation, and it finished successfully with the first several lines of CHGCAR like this (note that there are 128 characters in Line 7):
CHGCAR:
unknown system
1.00000000000000
5.430000 0.000000 0.000000
0.000000 5.430000 0.000000
0.000000 0.000000 5.430000
Si/79d9987ad87 Si/79d9987ad87 Si/79d9987ad87 Si/79d9987ad87 Si/79d9987ad87 Si/79d9987ad87 Si/79d9987ad87 Si/79d9987ad87
1 1 1 1 1 1 1 1
Direct
0.000000 0.000000 0.000000
0.500000 0.500000 0.000000
...
...

Then if we set ICHARG=11 in INCAR and run it again, we got the following errors:
WARNING: number of atoms are different on CHGCAR file
-----------------------------------------------------------------------------
| |
| EEEEEEE RRRRRR RRRRRR OOOOOOO RRRRRR ### ### ### |
| E R R R R O O R R ### ### ### |
| E R R R R O O R R ### ### ### |
| EEEEE RRRRRR RRRRRR O O RRRRRR # # # |
| E R R R R O O R R |
| E R R R R O O R R ### ### ### |
| EEEEEEE R R R R OOOOOOO R R ### ### ### |
| |
| ERROR: charge density could not be read from file CHGCAR for |
| ICHARG>10 |
| |
| ----> I REFUSE TO CONTINUE WITH THIS SICK JOB ... BYE!!! <---- |
| |
-----------------------------------------------------------------------------

Regards,
Zhiyong


Re: Looks like a bug in "fileio.F": Failing in reading CHGCAR

Posted: Wed Feb 05, 2025 7:17 am
by alexey.tal

Ok, I see what the problem is. In VASP 6.4.2 we merged the code that would add hashes to the types to identify the potential, but this change turned out to cause too much trouble, so we had to revert the changes. You can also see our discussion in this thread. In your case the problem is that when the hashes are written with types the line becomes too long.
This issue was resolved in VASP 6.4.3 so you should update if you have access to a newer version of VASP. Otherwise, you can apply the patch from this thread.

Also, thank you for bringing this issue to our attention. We weren't aware of this problem.


Re: Looks like a bug in "fileio.F": Failing in reading CHGCAR

Posted: Wed Feb 05, 2025 1:36 pm
by zhiyong_zhu

Thank you Alexey,

I did a test and confirm that the issue has been fixed in VASP 6.4.3.

Regards,
Zhiyong