Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!udel!nigel.ee.udel.edu!mccalpin From: mccalpin@perelandra.cms.udel.edu (John D. McCalpin) Newsgroups: comp.unix.aix Subject: Re: pure binary files in fortran on RS6000 (xlf) Message-ID: Date: 22 May 91 19:54:27 GMT References: <9105221902.AA08859@ucbvax.Berkeley.EDU> Sender: usenet@ee.udel.edu Organization: College of Marine Studies, U. Del. Lines: 55 Nntp-Posting-Host: perelandra.cms.udel.edu In-reply-to: freese@dalvm41b.vnet.ibm.com's message of 22 May 91 19:04:38 GMT >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