Register to reply

Reading Universal File Type 58b in Fortran

by DaveGil12
Tags: 58b, fortran, unv
Share this thread:
Feb15-13, 06:40 AM
P: 1
Hi there,

I am trying to read a universal file (*.unv) in fortran. The file is type 58b (mixed ascii and binary format). I can read the ascii part fine but am having trouble reading the binary part. Does anyone know of anywhere I can access some source code to read this correctly. I suspect its something to do with my open and read statements not being set up correctly but am unsure.
Phys.Org News Partner Science news on
Final pieces to the circadian clock puzzle found
A spray-on light show on four wheels: Darkside Scientific
How an ancient vertebrate uses familiar tools to build a strange-looking head
Feb15-13, 07:15 AM
P: 3,091
I think you need to open the file as a binary file otherwise the IO functions will edit the input stream removing non-ascii characters.
Feb15-13, 09:14 AM
Sci Advisor
HW Helper
P: 7,279
Back in the days of Fortran IV when this file format was invented, you could just read the binary data into real or integer variables with A format, and everything worked fine.

The "quiche-eating police" have probably made that illegal in Fortram 90/95 though.

The 58B data format is hightly machine dependent, but at least it includes some flags in the header to tell you which binary format the data is in. If you need to convert from one machine to another (e.g. big endian to little endian, or IBM System/360 floating point to IEEE) that's a different question!

It all else fails, you could write a program in C to convert the type 58b data to type 58 (exactly the same logical data structure, but everything is formatted not binary).

Register to reply

Related Discussions
[Fortran] problem on reading the csv file Programming & Computer Science 6
Reading a file in FORTRAN 90 or 95 Programming & Computer Science 2
Fortran 90, problem with reading a file Programming & Computer Science 9
Help with reading file into FORTRAN Programming & Computer Science 0
Fortran 90 help reading from file Programming & Computer Science 2