problems with opening unformatted direct file.

Ryo Furue furue at HAWAII.EDU
Sun Jun 29 04:49:27 EDT 2008


Hi Arlindo and GrADS users,

|     I write a simple file in FORTRAN by:
|            open (51,file='uwind.dat',form='unformatted, access='direct',recl=
|     2001*2001*4)
|
| Which Fortran compiler are you using? The units for specifying the
| RECL was system dependent before Fortran 90 (could be in bytes or
| words); with f90 the units are words (4 bytes).

This isn't correct.  The units for RECL have been system dependent
and will remain so in the foreseeable future.  Please check some
textbook or the standard itself; for example, here's the final draft
of the Fortran 95 standard:

  http://j3-fortran.org/doc/standing/archive/007/97-007r2/pdf/97-007r2.pdf

I've check the current draft of the next Fortran standard (Fortran
2008?) and this issue hasn't been changed.  (But, in the new draft,
it is "recommended" that the unit be an octet [8 bits].)

There is a portable way of handling this system-dependency:

    real:: arr(2001, 2001)
    integer:: iol

    inquire(iolength=iol) arr
    open(. . . , recl=iol, . . .)
    write(10,rec=1) arr

The iolength specifier of INQUIRE returns the record length
of the item ("arr" in the example above) in whatever units
the particular compiler uses.

Regards,
Ryo



More information about the gradsusr mailing list