[vtkusers] reading from FORTRAN files
David D. Marshall
gte552m at prism.gatech.edu
Sun Mar 18 01:14:03 EST 2001
FORTRAN unformatted file format works by putting a 4 byte (possibly
integer) header in front of every data block. For instance the
following code:
INTEGER*4 I1, I2, I3
REAL*4 F
WRITE(11) I1, I2, I3
WRITE(11) (F(N),N=1,3)
Will result in the following data layout on 32-bit arch:
byte:1---5----0----5----0----5----0--
data:HDR1[I1][I2][I3]HDR2[F1][F2][F3]
I'm sure that the header information has some signifigance, but I never
saw a pattern the few times I cared to look. As for the data types, the
data should be written as a direct memcpy way, so a REAL*4 => float and
REAL*8 => double. The last twist is the byte order of the machine
running the FORTRAN code. You may need to do byte swapping (see VTK
code for how to do the swapping). This is all the info that you should
need, as this has been what has gotten me to read FORTRAN files from all
kinds of hardware/OS combinations without problems.
Gavin Tabor wrote:
>
> Hi.
>
> I'm trying to read in data from a FE file written by a FORTRAN code,
> in order to visualise the data in VTK. The file contains integers
> and floating point numbers in binary format. I've managed to read
> in the integers OK, giving me an outline of the file (I can for
> example read how many points there are in the mesh), but I cannot
> work out how to read a binary FLOAT into an appropriate C variable.
> If anyone can give me some clues on this I would be very appreciative.
>
> Gavin
>
> --
>
> Dr. Gavin Tabor
> School of Engineering and Computer Science
> Department of Engineering
> University of Exeter
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
--
David D. Marshall
ARTLab System Administrator/GRA
Georgia Institute of Technology, Atlanta Georgia, 30332
http://www.ae.gatech.edu/research/artlab/artl/artlab.html
mailto:gte552m at prism.gatech.edu
think: Why anonymity is good,
http://www.cato.org/pubs/briefs/bp-054es.html
More information about the vtkusers
mailing list