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

INQUIRE no longer works for directories?

pedro_gonnet
Beginner
512 Views
Hello,

I have a small question regarding the INQUIRE statement in ifort v.8.0.034. The following code:

PROGRAM TestInquire

! we need this var for the call to INQUIRE
LOGICAL :: bool

! call INQUIRE
INQUIRE(FILE='TestInquire.f',EXIST=bool)

! print the result
IF (bool) THEN
WRITE(*,*) 'The file TestInquire.f seems to exist...'
ELSE
WRITE(*,*) 'The file TestInquire.f doesn''t seem to exist...'
ENDIF

! call INQUIRE
INQUIRE(FILE='.',EXIST=bool)

! print the result
IF (bool) THEN
WRITE(*,*) 'The file ''.'' seems to exist...'
ELSE
WRITE(*,*) 'The file ''.'' doesn''t seem to exist...'
ENDIF

END PROGRAM TestInquire

Produces different results for ifc-7.1:

$ ./a.out
The file TestInquire.f seems to exist...
The file '.' seems to exist...

and ifort-8.0:

$ ./a.out
The file TestInquire.f seems to exist...
The file '.' doesn't seem to exist...

I don't know if this is a bug in INQUIRE, since according to all specifications I've seen it applies to files, but under all other fortrans I know of, this works... Is this a feature that got lost in the re-implementation of the IO-routines? If so, how can I work around it?

Cheers and many thanks in advance,
Pedro
0 Kudos
1 Reply
Steven_L_Intel1
Employee
512 Views
It's not a bug, and support of this concept is not as unversal as you think. It comes up for discussion occasionally in comp.lang.fortran. The general thinking is that if you can't OPEN it, you can't INQUIRE about it either, so directories ought not to be supported as subjects in INQUIRE. Some compilers support it, many do not.
I suggest you use some OS-appropriate method to look up directories.
0 Kudos
Reply