INQUIRE statement does not find an existing filefile

Hi,

I am having problems with the INQUIRE statement. I have a file CO2TAB which is accessed by the fortran program (f77). The file does exist and is located in the same directory as the compiled program:

magrathea:tr_eco2n maurice$ ls -al CO2TAB
-rwxr-xr-x 1 maurice staff 260200 Oct 27 2005 CO2TAB

The program has the following statements in it:


LOGICAL EX

INQUIRE(FILE=‘CO2TAB’,EXIST=EX)
IF(EX) GOTO 162
PRINT 163
163 FORMAT(’ FILE CO2TAB DOES NOT EXIST — STOP EXECUTION’)
stop
C
162 PRINT 164

When the program executes the INQUIRE statement, the value for EX comes back as .FALSE. and the program stops, as it is instructed to in the above code.

Any suggestions as to why INQUIRE is not seeing the file CO2TAB?

Many thanks,

Maurice

Hi Maurice,

I’m not sure what wrong here. INQUIRE simply calls the OS ‘stat’ function. What happens if you call stat directly from the shell’s command line: ‘stat CO2TAB’? Also, what OS and compiler version are you using?

What happens if you put the fully qualified path for the filename instead of just CO2TAB?

  • Mat
% cat inq.f
        LOGICAL EX
        INQUIRE(FILE='CO2TAB',EXIST=EX)
        IF(EX) GOTO 162
        PRINT 163
 163    FORMAT(' FILE *CO2TAB* DOES NOT EXIST --- STOP EXECUTION')
        stop
C
 162    PRINT 164
 164    FORMAT(' FILE *CO2TAB* EXIST --- STOP EXECUTION')
        stop
        end
% pgf77 inq.f -o inq.out
% inq.out
 FILE *CO2TAB* DOES NOT EXIST --- STOP EXECUTION
FORTRAN STOP
% touch CO2TAB
% inq.out
 FILE *CO2TAB* EXIST --- STOP EXECUTION
FORTRAN STOP
%

Hi Mat,

I am using Mac OS 10.5.7 (Mac Pro, 16 GB RAM 4 TB disk) with PGI workstation-complete, V8.0-6.

When I run the stat command I get the following:

magrathea:tr_eco2n maurice$ stat CO2TAB
234881038 4778046 -rwxr-xr-x 1 maurice staff 0 260200 “May 27 13:05:38 2009” “Oct 27 01:12:36 2005” “May 27 12:55:41 2009” “Oct 27 01:12:36 2005” 4096 512 0 CO2TAB

SO, the file is definatly there.

When a fully qualified path is included, same error message.

Maurice

Hi Maurice,

Can you please send a report to PGI customer service (trs@pgroup.com) and include code that reproduces the problem? My little test program works fine on Mac as well so there must be something else besides the INQUIRE that’s causing the problem.

  • Mat