Register to reply

Reading Universal File Type 58b in Fortran

by DaveGil12
Tags: 58b, fortran, unv
Share this thread:
DaveGil12
#1
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.
Thanks.
Phys.Org News Partner Science news on Phys.org
New model helps explain how provisions promote or reduce wildlife disease
Stress can make hard-working mongooses less likely to help in the future
Grammatical habits in written English reveal linguistic features of non-native speakers' languages
jedishrfu
#2
Feb15-13, 07:15 AM
P: 2,769
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.
AlephZero
#3
Feb15-13, 09:14 AM
Engineering
Sci Advisor
HW Helper
Thanks
P: 6,922
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