Topic: Error in OPEN FILE Statement - Bug or user error
Hi All,
I am trying to pass filename as string variable in OPEN FILE statement as follows:
Program TestFileIOPgm
IMPLICIT NONE
CHARACTER*12 :: DATE, TIME
CHARACTER*10 :: OMSDATE, OMSTIME
CHARACTER (LEN=256) :: FILENAMEPATH
INTEGER :: DBGLUN,TESTDATA, IDFILE
CHARACTER(LEN=60) :: FILEPATH
CHARACTER*20 :: TESTDATANAME
CHARACTER(LEN=20) :: FLNAME
TESTDATA=15
DBGLUN=25
C
FILEPATH='G:\oms-Development\Version-VB6\Interfaces\omsLPIntf\'
FILEPATH=TRIM(FILEPATH)
FILENAMEPATH=REPEAT(' ',256)
OPEN (UNIT=TESTDATA,
1FILE='G:\oms-Development\Version-VB6\Interfaces\omsLPIntf\'
2// 'Input\' // 'TESTCASES.DAT', STATUS='OLD',ACCESS='SEQUENTIAL',
3 FORM='FORMATTED')
C OPEN (UNIT=TESTDATA,
C 1FILE=FILEPATH// 'Input\TESTCASES.DAT', STATUS='OLD',
C 2 ACCESS='SEQUENTIAL', FORM='FORMATTED')
OPEN (UNIT=DBGLUN,
1FILE='G:\oms-Development\Version-VB6\Interfaces\omsLPIntf\'
2// 'Debug\' // 'DEBUG-TEST.DAT' , STATUS='REPLACE')
DO 8000 IDFILE = 1, 100
READ (TESTDATA,8001) TESTDATANAME
WRITE(*,*) TESTDATANAME
8001 FORMAT(A20)
FLNAME=TRIM(TESTDATANAME)
FILENAMEPATH='G:\oms-Development\Version-VB6\Interfaces\'
1 // 'omsLPIntf\' // 'Input\' // FLNAME
IF (FLNAME .EQ. '') GO TO 8002
CALL DATE_AND_TIME(DATE,TIME)
OMSDATE = DATE(1:4) // "/" // DATE(5:6) // "/" // DATE(7:8)
OMSTIME = TIME(1:2) // ":" // TIME(3:4) // ":" // TIME(5:6)
WRITE (DBGLUN,50) FILEPATH,FLNAME,DATE(1:8),TIME(1:6)
8002 CONTINUE
8000 CONTINUE
CLOSE(TESTDATA)
CLOSE(DBGLUN)
*
*---- FORMAT STATTEMENTS
*
50 FORMAT(2x,'Input Data File Opened Successfully ', A60,2X, A20,2X,
1 " AT DATE/TIME ", A8,2X,A6)
END PROGRAM TestFileIOPgm
The above code when the filepath is hradcoded but if pass the variable as
OPEN (UNIT=TESTDATA,
1FILE=FILEPATH// 'Input\TESTCASES.DAT', STATUS='OLD',
2 ACCESS='SEQUENTIAL', FORM='FORMATTED')
I get this error
At line 32 of file .\TestFileIOPgm.FOR (unit = 15, file = '° ')
Fortran runtime error: File 'G:\oms-Development\Version-VB6\Interfaces\omsLPIntf\ Input\TESTCASES.DAT' does not exist
It does not pickup the FullFileName in the file=?
What am I missing here. New user at learning f90 and had worked with Visual fortran with no problem. Please guide me. Would appreciate it.
s.agrawal@earthlink.net