Re: Portable record length




Asbjørn L. Johansen wrote:
Is there a portable way of saying "I want to store a 240 byte header +
some data per record" in Fortran 90? The data is in an array of known
length and type.
--
You insist on access by direct unformatted, but the reading program
will not know what record data length to use to read these records.

So you HAVE to have a record end marker that you can look for.
Since the data following your header is floating point data, there are
two situations:
1) your floatng point data in is binary words
2) your floating point data is in ascii F or G format

In case 1) your record marker has to be the FIRST character or
characters in your header, because a floating point number as as binary
words can have ANY bit configuration, which will include all possible
end revord markers. So you have to use part of your fixed header as an
identifier.

In case 2) you can write a normal carriage return-linefeed pair afeter
the end of the record (as a word #0D0A, inverted), thus producing an
even number of bytes in the record length. Better if the total length
is a multiple of four.

In both cases the reading porgram opens the file as unformatted binary
(stream, transparent) and looks for the record end maker, and checks
over at a few more records, to find the actual record length, then
closes the file and now opens it in unformatted direct mode to be able
to access any records and even update them.

Terence Wright

Asbjørn L. Johansen
asbjorjo@xxxxxxxxxxxx

.



Relevant Pages

  • techniques for handling large text files
    ... header line ... file and decides which output file to write it to. ... # open output file for line type 1 ...
    (perl.beginners)
  • techniques for handling large text files
    ... header line ... file and decides which output file to write it to. ... # open output file for line type 1 ...
    (perl.beginners)
  • Re: techniques for handling large text files
    ... > header line ... > marker 1 ... Another warning sign, I think. ... After that I built some code to split it, ...
    (perl.beginners)
  • Re: __atoi64 not working correctly
    ... are missing from header files. ... programmers have to work to is the C89/90 standard, ... of the C compilers available are C99 compliant ... I want to determine the 'best' floating point type for my ...
    (comp.lang.c)
  • Re: Portable record length
    ... The header contains 16 and 32 bit integer and 32 bit floating ... Direct access has fixed length records, ... This is not an issue as I have to conform to a format specification. ...
    (comp.lang.fortran)