Your advice on the following question will be greatly appreciated.
Suppose one has a derived type:
TYPE FooType
REAL :: component1
CHARACTER (LEN = 10) :: component2
END TYPE FooType
Let x be a variable of this type:
TYPE(FooType) :: x
One can write x to an unformatted sequential file open on unit fout as follows:
WRITE(fout) x
This variable can be retrieved from this file at a later date using a read of
the following form:
READ(fin) x
(where fin is the unit on which the file is open for input)
My question is, having written x as above, is it standard conforming to read x
in component order as follows:
READ(fin) x%component1,x%component2
Thank you,
David Vowles.
(PS: The reason behind the question is that if one were to change the type
components e.g. increase LEN to 20 in FooType then the component ordered read
would provide a mechanisim for correctly retrieving data saved before the
change in the derived type. Otherwise one must both write and read components
individually to facilitate backward compatibility of file formats)
----------------------------------------------------------
David Vowles
Research Officer
Department of Electrical and Electronic Engineering
The University of Adelaide
Australia 5005
Voice: +61 8 8303 5416
Fax: +61 8 8303 4360
Email: [log in to unmask]
Home Page: http://www.eleceng.adelaide.edu.au/Personal/dvowles/home.html
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|