Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28629 Discussions

Inquire statement result for directory

twlaub
Beginner
773 Views

I'm using fortran version 8 for linux and have a question about the results from the inquire statement. I'm porting code and the code does an inquire with file = to a directory name. The result for exist is false even though the directory exists. I wrote a small test program and confirmed the behavior. Is there a way to get inquire to recognize a directory as a file for the purpose of testing existence?

Tom

0 Kudos
4 Replies
Steven_L_Intel1
Employee
773 Views
No - we feel that doing so would be disallowed by the standard. In version 9 we added features to INQUIRE to allow you to ask about directory existence. See the release notes.
0 Kudos
paffe
Beginner
773 Views

Existing directories are not recognized by the FORTRAN-INQUIRE-Statement using the so called file inquiry. The returned value of the EXIST specifier is always ".false.", even if the directory exists. According to the description the output value should be ".true.".

Other Compilers and History:

All other F77/F90 compilers in use - and all Fortran Compilers before - on the other platforms return the value ".true." - according to the f95 standard. Besides:pgf90 Portland Compiler on Linux returns also ".true.". Andalso the father of the Intel ifort compiler on WindowsXP (Digital- COMPAQ) returns the value ".true.".

That is the truth. The standard document for INQUIRE EXIST specifier tells about files in total nothing about limitation to regular files.

The hint of Steve to ifort 9 release notes: we think that it is no solution to fuse some new incompatible specifiers (DIRECTORY and DIRSPEC) to the INQUIRE statement. We ask you and intel to satisfy the meaning of the standard for in this point and to make a cahnge according to the remark oftwlaub from 2006-01-11

0 Kudos
Steven_L_Intel1
Employee
773 Views
See my reply to your other post. We feel that the current behavior meets the standard whereas the old behavior did not.
0 Kudos
joe_krahn
Beginner
773 Views
I think Intel is generally correct here. The Fortran95 standard only refers to files, not directories. Many compilers allow INQUIRE for directories, because no standrad method exists. Directory inquiries can only be implemented as an extension (at least up to F95). However, claiming that a file exists when given a directory name is an invalid result, because a directory is not a file.

Unfortunately, it looks like the new standards still avoid dealing with directories due to OS-dependence. Maybe one could convince other compiler vendors to implement Intel's INQUIRE extensions.
0 Kudos
Reply