fn@fractal.math.yale.edu (Francois Normant) (04/04/91)
I'm trying to write pure binary files in fortran in order to read them in C. On CRAY 2, I usually open an unformatted file open(unit=70,status='new',form='unformatted',file='foo.out') and call the setpure function to avoid any control characters call setpure(70) The question is: Is there a function equivalent to setpure in xlf (RS6000 fortran) ? Thanks -- Francois Normant - fn@math.yale.edu Yale University - Mathematics Department Box 2155 - Yale Station New Haven CT 06520
pack@acd.uucp (Daniel Packman) (05/23/91)
In article <9105221902.AA08859@ucbvax.Berkeley.EDU> freese@dalvm41b.vnet.ibm.com ("Bradley T. Freese") writes: >fn@fractal.math.yale.edu (Francois Normant) writes: > >> I'm trying to write pure binary files in fortran in order to read them in C. >> ... >> The question is: > >> Is there a function equivalent to setpure in xlf (RS6000 fortran) ? > >No, xlf does not have such a function. However, xlf does not add any >extraneous characters to an unformatted file (other than an EOF >record). It only writes the data you write to the file. Depends on what you mean "extraneous". In order to support standard unformatted reads, a byte count at least must be accessable before the data. In order to support backspace and detection of "eof", byte counts of some sort must be added after the data. Counts of some sort somewhere must be added to the data stream for fortran unformatted io. AIX/RS6000 and *many* other unix fortran implementations on 32 bit machines prepend and postpend a 4 byte byte count of the intervening data. You are, of course, never guaranteed what the local fortran implementation of binary data is. We solve the problem of multi-architecture binary data by using the netCDF (common data format) routines. The package is free from unidata.ucar.edu and runs on VMS and DOS as well as unix machines. Its underlying assumption is the XDR (external data represention) which is used by NFS and other animals. Dan Packman NCAR INTERNET: pack@ncar.UCAR.EDU (303) 497-1427 P.O. Box 3000 CSNET: pack@ncar.CSNET Boulder, CO 80307-3000 DECNET SPAN: 9583::PACK
mccalpin@perelandra.cms.udel.edu (John D. McCalpin) (05/23/91)
>On 22 May 91 19:04:38 GMT,freese@dalvm41b.vnet.ibm.com (Bradley Freese) said: Bradley> fn@fractal.math.yale.edu (Francois Normant) writes: > I'm trying to write pure binary files in fortran in order to read them in C. > On CRAY 2, I usually open an unformatted file > open(unit=70,status='new',form='unformatted',file='foo.out') > and call the setpure function to avoid any control characters > call setpure(70) > The question is: > Is there a function equivalent to setpure in xlf (RS6000 fortran) ? Bradley> No, xlf does not have such a function. However, xlf does not Bradley> add any extraneous characters to an unformatted file (other Bradley> than an EOF record). It only writes the data you write to Bradley> the file. ------------------ This is *wrong*! When a file is opened with open(unit=70,form='unformatted'), the Fortran run-time system places control words in the output file before and after each record. The control word is a 32-bit integer which is set to the number of *bytes* in the record. This behavior is compatible with Sun and Silicon Graphics systems. ----------------- If you want a *pure binary* file from xlf, you have to open the file with open(unit=70,form='unformatted',access='direct',recl=NNN) where NNN is the number of *bytes* that you are going to write in each *fixed-length* record. This behavior is compatible with Sun systems. It is almost compatible with Silicon Graphics systems, which by default specify the record length in *words* instead of bytes. I use a library routine on each machine to allow portable source: integer sizeof external sizeof open(unit=70,form='unformatted',access='direct', $ recl=sizeof('REAL')*NNN) where NNN is the number of REAL variables per record. On my IBM and Sun machines I have written a sizeof routine that returns the number 4 for an argument of 'REAL', while on the SGI machines it returns 1. I have placed the sizeof() function in a local library /usr/lib/libocal.a which is accessed by the '-local' flag on the xlf command line.... -- John D. McCalpin mccalpin@perelandra.cms.udel.edu Assistant Professor mccalpin@brahms.udel.edu College of Marine Studies, U. Del. J.MCCALPIN/OMNET
freese@dalvm41b.vnet.ibm.com ("Bradley T. Freese") (05/25/91)
fn@fractal.math.yale.edu (Francois Normant) writes: > I'm trying to write pure binary files in fortran in order to read them in C. > On CRAY 2, I usually open an unformatted file > open(unit=70,status='new',form='unformatted',file='foo.out') > and call the setpure function to avoid any control characters > call setpure(70) > The question is: > Is there a function equivalent to setpure in xlf (RS6000 fortran) ? No, xlf does not have such a function. However, xlf does not add any extraneous characters to an unformatted file (other than an EOF record). It only writes the data you write to the file.