Skip to content

INQUIRE statement before create_directory

Mitsuaki KAWAMURA requested to merge mitsuaki1987/q-e:inquire_dir into develop

In PHonon/PH directory, there are codes like

IF (ionode) INQUIRE(file=TRIM(elph_dir), EXIST=exst)
CALL mp_bcast(exst, ionode_id, intra_image_comm)
IF (.NOT.exst) CALL create_directory( elph_dir )

that uses INQUIRE statement to check the existence of a directory before creating it. However this INQUIRE statement is not necessary since create_directory also check that existence. Moreover, the behavior of inquire(dir, exist) is undefined, and it causes error for Fujitsu compiler.

As a reference, when a directory "test/" exists, the behavior of the code

program main
  implicit none
  logical :: ii
  inquire(file="test/", exist=ii)
  write(*,*) ii
end program main

with each compiler becomes as follows:

  • GNU gfortran (8.4.1) : True
  • Intel ifort (2021.8.0) : False
  • Intel ifx (2023.0.0) : False
  • NVIDIA nvfortran (23.3-0) : True
  • Fujitsu frt (4.9.0) : Error jwe0103i-e line 4 The value of the FILE specifier in an INQUIRE statement is invalid.

Merge request reports