grimme-lab / xtb

Semiempirical Extended Tight-Binding Program Package
https://xtb-docs.readthedocs.io/
GNU Lesser General Public License v3.0
568 stars 144 forks source link

File reads fail with ifx compilation #1059

Closed TyBalduf closed 3 months ago

TyBalduf commented 3 months ago

Describe the bug There is another issue saying that ifx compilation doesn't succeed. But, on Linux (Centos7), I am able to compile xTB-v6.7.0 with ifx 2024.0.2 using meson. However, once it is built, it fails immediately for any job while trying to read the input file:

>>> xtb h2o.xyz
forrtl: severe (268): end of record during read, unit -129, file /home/balduf/repos/testing/h2o.xyz
Image              PC                Routine            Line        Source
libifcore.so.5     00007FB451CE6CC8  for__io_return        Unknown  Unknown
libifcore.so.5     00007FB451D26A2A  for_read_seq_fmt_     Unknown  Unknown
libifcore.so.5     00007FB451D24710  for_read_seq_fmt      Unknown  Unknown
xtb                00000000005A4671  getline                    50  systools.F90
xtb                000000000078A593  mirror_line               118  readin.f90
xtb                00000000007EBB71  rdcontrol                 771  set_module.f90
xtb                000000000042AEA7  xtbmain                   288  main.F90
xtb                000000000043D8AC  xtb_prog_primary           57  primary.f90
xtb                00000000004066ED  Unknown               Unknown  Unknown
libc-2.17.so       00007FB450C31555  __libc_start_main     Unknown  Unknown
xtb                0000000000406616  Unknown               Unknown  Unknown

It seems that getline isn't properly returning iostat and is just failing outright.

If I add eor to the read in getline to force, it gets stuck in an infinite loop because the "end of file" error code returned is 24, which is not recognized by is_iostat_end.

If I add a check for 24, it correctly finishes trying to read the input file, but then fails again with the "severe (268): end of record" during readmolecule.

To Reproduce meson setup xtb build --buildtype=release with Fortran compiler set to ifx. xtb -h should work fine, but xtb any_input.xyz should fail immediately with an end of record error.

Additional context Compiling v6.7.0 with ifort-2022.0.2 runs just fine with all the same settings.

I also made a small test program that just opens a file and applies getline to it repeatedly. Compiling with ifx, this seems to correctly handle iostat. So it seems like there is an issue with ifx misinterpreting something about how xTB opens files.

awvwgk commented 3 months ago

This behavior is quite surprising, it seems that ifx is deviating in behavior from most of the common Fortran compilers, not sure whether this behavior is still compliant with the Fortran standard and could be considered a bug in ifx. One option would be to check the getline implementation in stdlib whether there is any update we can port back to xtb.

TyBalduf commented 3 months ago

I believe his was a false alarm. I was somehow compiling with ifx 2024, but also linking against parts of ifort 2022. I have to imagine this could cause all sorts of strange behavior, including this iostat issue.