Fortran Reading Universal File Type 58b in Fortran

Click For Summary
To read a universal file (*.unv) of type 58b in Fortran, it is essential to open the file in binary mode to prevent IO functions from altering non-ascii characters. While the ASCII portion can be read without issue, the binary section requires careful handling due to its machine-dependent nature. The file's header contains flags indicating the binary format, which is crucial for proper interpretation. If there are compatibility issues between different machines (e.g., big endian vs. little endian), additional conversion may be necessary. As a workaround, converting the type 58b data to type 58 using a C program is suggested, as this format retains the same logical structure without binary formatting complications.
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:
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

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