Re: The concept of a record



On 2008-01-30 15:37:16 -0400, qsc <qingshan.chen@xxxxxxxxx> said:

After reading Gordon and Klaus's replies, I came to the conclusion
that
write(12) U(:) will write all the values in U(:) as one record. But
the concept
of "line" doesn't apply here.

If I am correct in the statement above, then what will be the
structure of
the data file? Or put in another way, after writing the array into an
external data file, I load the data file using fread of matlab. The
function
fread will produce a data matrix. What will be the shape of the
matrix?
Is it (1,N), or is it (N, 1), or something else?

I will soon find it out by experiments. But if someone can shed light
on
it beforehand, it is greatly appreciated.

Thank you!

The values that are in the record come one after the other.

The structure of (1,n) or (n,1) is an artifact of your program.
There will usually be some documentation on how the sequence
of values corresponds to your structure. RTFM (Read The Fine
(or F***ing accoding to some folks) Manual)!

In Fortran you will find a correspondence that says the first subscript
varies most rapidly. It only matters if there are several (like 2) subscripts.
Other languages might choose to vary the last subscript most rapidly.
Fortran is the oldest commonly used language so it should be treated
deferentially with its choice preferred notwithstanding the opinions
of some upstart newcomers.

In your example both structures lead to the same sequence of values.
So the answer it is both! If you had some other value than 1 the answer
would be something else. But you may find that MatLab does not understand
Fortran records.

A common Fortran implementation of its record structure is to include
record lengths at the begining of the record, to allow forward skipping,
and the end, to allow backspacing. Without this implementation overhead
the useful operations of skipping and backspacing become much more difficult.
If you have never thought of these features your could end up expressing
wonderment, and your own lack of breadth of knowledge, at the need for this
overhead. If you know of these feature you are left wondering why other
systems are so primitive and devoid of capability.



.



Relevant Pages

  • Re: Attempt to read past end of file
    ... the data file 'press' has the same values as the previously generated ... add: Command not found. ... Write a main program in Fortran, plain Fortran, no macros, no ...
    (comp.lang.fortran)
  • Re: Is FORTRAN a dying language? (not a troll)
    ... which stores arrays in row-major order. ... Fortran and C store two dimensional arrays in the *same* way. ... and the "most significant" subscript on the right. ...
    (comp.lang.fortran)
  • Re: Optimal programming advice
    ... >> If you stick to Fortran, no problem, but C is the other way around. ... which subscript to call "row" and which to call "column" ... puts the row number as the second subscript and the ... Index order, that is, ...
    (comp.lang.fortran)
  • Re: Assistance Reading Binary Data
    ... I used to be a Fortran buff 30 years ago, ... The following program reads the data file described above and displays ... implicit none - disallows implicit typing ... an initialization expression sets i2 ...
    (comp.lang.fortran)
  • Re: The concept of a record
    ... In Fortran you will find a correspondence that says the first subscript ... Other languages might choose to vary the last subscript most rapidly. ... In your example both structures lead to the same sequence of values. ... But you may find that MatLab does not understand ...
    (comp.lang.fortran)