Search code examples
fortranfortran77

Having error on the READ statement: Error 90 File access and properties are incompatible


I am getting the error message:

Error 90 File access and properties are incompatible

The piece of code that gives me the error is the following:

  PARAMETER (NPT=250, NPR=9)
  IMPLICIT  REAL*8 (A-H,O-Z)
  CHARACTER*255 ARQDAT
  DIMENSION Z(NPT,NPT,NPR) 
  COMMON/CPROP/ TMIN,TMAX,DT,PMIN,PMAX,DP,VMIN,VMAX,DX,DX2,DY,DY2,Z
  REAL*4 RGAS        
!*     Read matrix
  OPEN(UNIT=10,FILE=ARQDAT,FORM='UNFORMATTED', ACCESS='DIRECT',RECL=1)
  READ(10) Z !this is the statement giving error ARQDAT is a binary file
  CLOSE(UNIT=10)

Why or what should I do?


Solution

  • You opened the file ACCESS='DIRECT' but are doing a sequential READ on it - this is not allowed. Often when people do ACCESS='DIRECT',RECL='1' they want to read a byte at a time, but you have to combine this with a REC= value in the READ statement. In modern Fortran there are other, better ways to do this (such as ACCESS='STREAM').

    What compiler are you using and on what operating system?