Newsgroups: comp.lang.fortran
Path: utzoo!utgpu!radio.astro!brian
From: brian@radio.astro.utoronto.ca (Brian Glendenning)
Subject: Direct Unformatted I/O
Message-ID: <BRIAN.89May31001207@radio.utoronto.ca>
Organization: Radio Astronomy, Univeristy of Toronto
Distribution: 
Date: Wed, 31-May-89 00:12:14 EDT


I have a problem where I want to do direct unformatted i/o to a file,
where the record length isn't known until run-time, but a maximum
length is known. So I do something like:

      PARAMETER (BIG=1024)
      REAL LINE(BIG)
      READ (5,*) NSIZE
      OPEN ( [...] ACCESS='DIRECT', FORM='UNFORMATTED', RECL=NSIZE*4, [...])
      (4 is a constant that varies with hardware)

Now obviously I want to put NSIZE reals into LINE and write them out
later. My question is: what is the proper way to do  this. On our Sun
3 it looks like you fill up the last NSIZE elements of LINE and use a
write statement of the form:

            WRITE( [...] REC=[...]) LINE(BIG-NSIZE+1)

Is this the right thing to do in general? My recollection was that you
filled up the first  NSIZE elements of LINE, and used a line like:

            WRITE( [...] REC=[...]) LINE

and the fortran io would automatically take the appropriate number of
units of storage (RECL) from the beginning of line.

However, on our Sun 3 under 4.0 this isn't what happens, so probably
my recollection is faulty. So my question is: what is the standard
(portable) way to do this? Am I doing it right? Thanks.
--
--
	  Brian Glendenning - Radio astronomy, University of Toronto
brian@radio.astro.utoronto.ca uunet!utai!radio!brian  glendenn@utorphys.bitnet
