Page 1 of 1

Clarification on using "true" or "True" vs ".TRUE." or "T" in INCAR files.

Posted: Sun Jul 28, 2024 12:25 am
by hszhao.cn@gmail.com
Dear VASP community,

I'm seeking clarification on the proper way to specify boolean values in INCAR files, say for the LHFCALC tag. I've noticed that while .TRUE. and T are commonly used and documented, it seems that "true" or "True" also works, as shown in the following INCAR file generated by pymatgen:

Code: Select all

ALGO = All
EDIFF = 0.0004
ENCUT = 520
HFSCREEN = 0.2
IBRION = 2
ICHARG = 1
ISIF = 3
ISMEAR = 0
ISPIN = 2
IVDW = 11
LASPH = True
LHFCALC = True
LMAXMIX = 4
LORBIT = 11
LREAL = Auto
LWAVE = False
MAGMOM = 2*-0.009 3*0.41 1*0.414 2*0.412
NELM = 100
NSW = 99
PREC = Accurate
PRECFOCK = Fast
SIGMA = 0.05
VDW_S8 = 0.109
VDW_SR = 1.129
My questions are:

1. Is using "true" or "True" instead of ".TRUE." or "T" for boolean values in INCAR files officially supported?

2. Is this behavior consistent across all VASP versions and all boolean tags?

3. Are there any potential issues or inconsistencies that might arise from using "true" or "True" instead of the standard ".TRUE." or "T"?

4. What is the recommended best practice for specifying boolean values in INCAR files?

I've looked through the documentation and searched the forum, but couldn't find a definitive answer on this specific usage. Any insights or official stance on this matter would be greatly appreciated.

Thank you for your time and expertise.

Best regards,
Zhao

Re: Clarification on using "true" or "True" vs ".TRUE." or "T" in INCAR files.

Posted: Mon Jul 29, 2024 8:07 am
by manuel_engel1
Dear Zhao,

Thank you for posting on the VASP forum. The way INCAR tags are parsed has changed over time. Therefore, the behavior will depend on the VASP version you are using. Everything I say here about the "true" values also applies to the "false" values.
1. Is using "true" or "True" instead of ".TRUE." or "T" for boolean values in INCAR files officially supported?
Using true, True, .TRUE. and T are all officially supported on recent VASP versions.
2. Is this behavior consistent across all VASP versions and all boolean tags?
No, the behavior is not consistent across all VASP versions. Lowercase t or true are a feature introduced in VASP 6. They will not work with older versions of VASP.
3. Are there any potential issues or inconsistencies that might arise from using "true" or "True" instead of the standard ".TRUE." or "T"?
Other than true not being supported by older version, no. All variants behave exactly the same.
4. What is the recommended best practice for specifying boolean values in INCAR files?
I would recommend to write True and False which is legible, unambiguous and easy to type. This way of writing also keeps backwards compatibility with older VASP versions, since it uses an uppercase "T" or "F".

Re: Clarification on using "true" or "True" vs ".TRUE." or "T" in INCAR files.

Posted: Mon Jul 29, 2024 12:35 pm
by hszhao.cn@gmail.com
Dear manuel_engel1,

Thank you very much for your systematic and detailed explanation, but I still want to know if there is any specific documentation or how to search the source code to verify these facts.

Regards,
Zhao

Re: Clarification on using "true" or "True" vs ".TRUE." or "T" in INCAR files.

Posted: Mon Jul 29, 2024 1:09 pm
by manuel_engel1
No worries! Reading of the Boolean values into Fortran logical types is done via the standard Fortran read statement. Therefore, the behavior is governed by the Fortran Standard. For example, here is the relevant section from the Fortran 95 standard:
The input field consists of optional blanks, optionally followed by a decimal point, followed by a T
for true or F for false. The T or F may be followed by additional characters in the field, which are
ignored.
If a processor is capable of representing letters in both upper and lower case, a lower-case letter is
equivalent to the corresponding upper-case letter in a logical input field.

The logical constants .TRUE. and .FALSE. are acceptable input forms.
We cannot guarantee that every compiler adheres to the standard.