Fortran Reading Universal File Type 58b in Fortran

AI Thread 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:
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
2
Views
1K
Replies
8
Views
1K
Replies
12
Views
3K
Replies
57
Views
5K
Replies
5
Views
5K
Replies
5
Views
2K
Replies
1
Views
3K
Back
Top