Preface: I needed to figure out the structure of a binary grid_data_file. From the Fortran routines I figured that the first record consists of 57 bytes and has information in the following order.
No. of the file :: integer*4 File name :: char*16 file status :: char*3 (i.e. new, old, tmp) .... so forth (rest is clear from write statement in the program) Now for the testing I wrote a simple program as follows: (I haven't included all the parameters)
Program testIO implicit none integer :: x, nclat, nclon character :: y, z real :: lat_gap, lon_gap, north_lat, west_lat integer :: gridtype open(11, file='filename', access='direct', form='unformatted', recl='200') read(11, rec=1) x,y,z,lat_gap,lon_gap, north_lat,west_lat, nclat, nclon, gridtyp write(*,*) x,y,z,lat_gap,lon_gap, north_lat,west_lat, nclat, nclon, gridtyp close(11) END To my surprise, when I change the declaration part to
integer*4 :: x, nclat, nclon character*16 :: y character*3 :: z real*4 :: lat_gap, lon_gap, north_lat, west_lat integer*2 :: gridtype It gives me SOME correct information, albeit not all! I can't understand this. It would help me to improve my Fortran knowledge if someone explains this phenomenon.
Moreover, I can't use ACCESS=stream due to machine being old and not supported, so I conclude that above is the only possibility to figure out the file structure.
200. The processor doesn't have to use bytes as the unit of length, theinquirestatement should be used to get it. Also, why do you use200when you stated before it is57bytes?INQUIRE(file=filename, recl=irec)before open statement, but it gave me an error. RECL specifier is zero or negativeINQUIRE(iolength=irec) x,y,z,lat_gap,lon_gap, north_lat,west_lat, nclat, nclon, gridtyp