Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!chx400!bernina!igc.ethz.ch!torda From: torda@igc.ethz.ch (Andrew Torda ) Newsgroups: comp.lang.fortran Subject: Re: pure binary files in fortran on RS6000 (xlf) Message-ID: <1991Apr5.083950@igc.ethz.ch> Date: 5 Apr 91 06:39:50 GMT References: <29850@cs.yale.edu> Sender: news@bernina.ethz.ch (USENET News System) Reply-To: torda@igc.ethz.ch (Andrew Torda ) Organization: InformatikgestutzteChemie, ETH, Zurich Lines: 31 Nntp-Posting-Host: hermitage In article , mccalpin@perelandra.cms.udel.edu (John D. McCalpin) writes: > > On 4 Apr 91 16:12:31 GMT, fn@fractal.math.yale.edu (Francois Normant) said: > > Francois> I'm trying to write pure binary files in fortran in order to > Francois> read them in C. > > On most UNIX workstations, the only way to do this is to open the file > as unformatted and direct access. This is true of the IBM RS/6000, > Sun, and SGI machines. > > The obvious disadvantage is that the record lengths must be fixed. No. On sun, convex and sgi, each fortran record starts with four bytes which tell you the length of the record that is coming. Each record ends with the same four bytes. On sun and convex, the four bytes tell you how many bytes are coming, on the irises, it is how many words are coming unless you have compiled with an option for backwards compatibility. You can even write fortran binary records on a convex and read them in C on your sun or iris if you are prepared to divide or multiply by 4 (I have forgotten which way it goes). -- Andrew Torda, ETH, Zurich