dceresoli / qe-gipaw

QE-GIPAW for Quantum-Espresso (official repository)
GNU General Public License v2.0
30 stars 11 forks source link

Preprocessor failure with gfortran in xml_routines.f90 in 7.0 #9

Open zao opened 2 years ago

zao commented 2 years ago

The macros in xml_routines.f90 use the stringification feature #x of the preprocessor which is not available in the "traditional" cpp mode that the GNU toolchain uses to preprocess code.

This leads to several compilation failures like the following as the # is emitted verbatim into the resulting source file:

xml_routines.f90:96:31:

   96 |     _NE(general_info)
      |                               1
Error: Syntax error in argument list at (1)

Manual expansion of the macros that use # (splitting the longer ones into multiple lines due to line lengths) compiles properly.

This is building via EasyBuild and its foss/2021b and intel/2021b toolchains, Intel seems unaffected.

dceresoli commented 2 years ago

Can you try now? I fixed and uploaded new tar.gz files to the release.

zao commented 2 years ago

Please note that the preprocessing unconditionally removed these conditional statements:

#if defined(__OMP) 
    integer, external :: omp_get_max
    nthreads = omp_get_max()
#endif    

I'll give it a try, I just have to unbreak my build recipes first as modifying the release tarballs in-place caused the checksum protection to (rightfully) alert.

zao commented 2 years ago

The generated source file does not compile here as several lines are too long, assuming this is some 135 character Fortran limit that the/our QE build process doesn't specify a flag for?

xml_routines.f90:167:127:

  167 |       call XML_NewElement(xmlf, "q_gipaw")
      |                                                                                                                               1
Error: Unterminated character constant beginning at (1)
xml_routines.f90:168:129:

  168 |         call XML_AddCharacters(xmlf, (q_gipaw*tpiba))
      |                                                                                                                                 1
Error: Unterminated character constant beginning at (1)
xml_routines.f90:172:132:

  172 |       call XML_NewElement(xmlf, "filfield"); call XML_AddCharacters(xmlf, trim((filfield))); call XML_EndElement(xmlf, "filfield");
      |                                                                                                                                    1
Error: Syntax error in argument list at (1)
xml_routines.f90:184:132:

  184 |         call XML_AddAttribute(xmlf, "size", (nat))
      |                                                                                                                                    1
Error: Syntax error in argument list at (1)
xml_routines.f90:189:132:

  189 |       call XML_NewElement(xmlf, "hfi_output_unit"); call XML_AddCharacters(xmlf, trim((hfi_output_unit))); call XML_EndElement(xmlf, "hfi_output_unit");
      |                                                                                                                                    1
Error: Syntax error in argument list at (1)
xml_routines.f90:191:132:

  191 |         call XML_AddAttribute(xmlf, "size", (nat))
      |                                                                                                                                    1
Error: Syntax error in argument list at (1)
xml_routines.f90:196:132:

  196 |     call XML_EndElement(xmlf, "input")
      |                                                                                                                                    1
Error: Unterminated character constant beginning at (1)

In my manual preprocessing, I had to manually line-wrap the output of _OUTS and _OUTV to make it short enough for the compiler to accept it.

dceresoli commented 2 years ago

Dear Lars, tomorrow I'll try to fix both issues. Thank you for pointing out!