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

INQUIRE STATEMENT

steve_konarski
Beginner
834 Views
I am uing theINQUIRE statement in a code. if the file exists the EXISTS is returned as .TRUE., however, I have extremely long file names ( including directories) and the combined length is 290 characters. Is this too long ?because say for instance the end of the file name is ..... ABCDEFG_001
then an INQUIRE on ..... ABCDEFG_002 also gives EXISTS as being .TRUE. giving the impression that INQUIRE only works on a set number of characters from the beginning of the filename
The form of the INQUIRE statement is :
INQUIRE (FILE = FNAME, EXIST = EXISTS)
0 Kudos
3 Replies
Steven_L_Intel1
Employee
834 Views
The maximum path length on Windows is 260 characters. I haven't tested to see what happens with longer paths, but I'd expect INQUIRE to complain. Please file a support request with Intel Premier Support.
0 Kudos
Paul_Curtis
Valued Contributor I
834 Views

Here is a Win32 alternative:

FUNCTION file_exists (fname) RESULT (size)

IMPLICIT NONE

TYPE(T_WIN32_FIND_DATA) :: fdata

! fname is full pathname, null-terminated

CHARACTER(LEN=*),INTENT(IN) :: fnameINTEGER :: size, handle, rval

size = -1

handle = FindFirstFile (fname, fdata)

IF (handle /= INVALID_HANDLE_VALUE) THEN

size = fdata%nFileSizeLow

rval = FindClose (handle)

END IF

END FUNCTION file_exists

0 Kudos
jimdempseyatthecove
Honored Contributor III
834 Views

One of the techniques I have used in the past is to make use of the current working directory. Write a subroutine that:

a) gets and saves the current working on the drive of the pathfilename you are querying on (GETDRIVEQQ)

b) Attempt to set current working directory to a directory in the who's path in the pathfilename you are examining is the longest pathless than 260 characters long.

c) Use INQUIRE on current directory of drive for remainder of pathfilename

d) Restore the current working on the drive

This will get you up to 500 or so characters (assuming Windows doesn't choke).

You can modify this routine to nest deeper if need be.

Jim Dempsey

0 Kudos
Reply