Hi,
I am migrating a legacy fortran program from HP UX f90 to Redhat Linux using the ifort compiler. The program is throwing an error on the first attempt to write to a direct access file on the linux version. iostat is 31. The output file is opened without error. The program runs correctly on UNIX. I’ve managed to isolate the code into a small test program provided below. What is causing this error? Please help, I've been struggling with this for a couple of days now.
program wtf
c test program to isolate iostat=31 error when writing to idu on Linux using ifort
integer idu,ierr,ipos
integer buffsizebytes
parameter (buffsizebytes=8)
real rnum
idu=37
c open the output file
open (idu,file='P5904.ft37',access='direct',recl=buffsizebytes,
+form='unformatted',iostat=ierr)
if (ierr.ne.0) then
write (6,*)'Error ',ierr,' opening P5904.ft37'
stop
endif
inquire(unit=idu,nextrec=ipos)
rnum = 1.0
write(unit=idu,err=999,iostat=ierr) rnum
if(iostat == 0) then
write(6,*) 'write to ',idu,' at position ',ipos,' successful!'
endif
goto 1000
999 write(6,*) 'Error writing to ',idu,'. iostat=',ierr
1000 end