Reading Universal File Type 58b in Fortran

Click For Summary
SUMMARY

This discussion focuses on reading Universal File Type 58b (*.unv) in Fortran, specifically addressing challenges with the binary portion of the file. Users must open the file in binary mode to prevent IO functions from altering non-ASCII characters. The 58B format is machine-dependent, requiring attention to header flags for binary format identification. For those unable to read the binary data correctly, converting the data to Type 58 using a C program is suggested as a viable alternative.

PREREQUISITES
  • Understanding of Fortran file I/O operations
  • Familiarity with binary and ASCII data formats
  • Knowledge of machine-dependent data representation
  • Basic programming skills in C for data conversion
NEXT STEPS
  • Research Fortran binary file handling techniques
  • Learn about the Universal File Type 58b specifications
  • Explore endianess and its implications in data formats
  • Study C programming for file data conversion
USEFUL FOR

This discussion is beneficial for Fortran developers, data scientists working with mixed-format files, and programmers involved in data conversion tasks.

DaveGil12
Messages
1
Reaction score
0
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.
 
Technology news on Phys.org
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.
 
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).
 
Last edited:

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 57 ·
2
Replies
57
Views
6K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K