Reading Universal File Type 58b in Fortran

In summary, The conversation discusses the issue of reading a universal file with type 58b in Fortran. The user is able to read the ascii part but is having trouble with the binary part. They ask for help in finding source code to correctly read the binary part, suspecting an issue with their open and read statements. Another user suggests opening the file as a binary file and mentions that in the past, reading binary data with A format worked fine. The discussion also touches on the machine dependency and potential conversion issues with the 58b data format. Finally, the option of writing a program in C to convert the data is mentioned as a last resort.
  • #1
DaveGil12
1
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
  • #2
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.
 
  • #3
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:

1. What is a Universal File Type 58b, and why is it important to read it in Fortran?

A Universal File Type (UFT) 58b is a type of file format used to store data in a standardized and universal way. It is important to read this file type in Fortran because Fortran is a programming language commonly used for scientific and engineering applications, and it is able to efficiently handle large amounts of data.

2. How do I read a Universal File Type 58b in Fortran?

To read a UFT 58b file in Fortran, you will need to use the appropriate input/output (I/O) functions that are specific to this file type. These functions will allow you to open, read, and manipulate the data contained within the file. It is important to carefully follow the syntax and guidelines for using these I/O functions.

3. Are there any specific libraries or modules that I need to use to read a Universal File Type 58b in Fortran?

Yes, there are specific libraries and modules that are designed to handle UFT 58b files in Fortran. These include the ISO_FORTRAN_ENV and ISO_C_BINDING modules, which provide the necessary functions and data types for reading and manipulating the data in the file. It is important to include these modules in your Fortran program before attempting to read a UFT 58b file.

4. Can I write to a Universal File Type 58b in Fortran?

Yes, you can also write data to a UFT 58b file using Fortran. This can be done using the appropriate output functions, which allow you to specify the data to be written and the format in which it should be written. However, it is important to note that not all data types are supported for writing to a UFT 58b file, so it is important to consult the documentation for the file type to ensure compatibility.

5. Are there any limitations to reading a Universal File Type 58b in Fortran?

One limitation to consider when reading a UFT 58b file in Fortran is that it may not be compatible with certain compilers or operating systems. It is important to ensure that your Fortran compiler and operating system support the UFT 58b file type before attempting to read it. Additionally, as mentioned earlier, not all data types may be supported for reading from a UFT 58b file, so it is important to carefully check the documentation and format of the file before attempting to read it in Fortran.

Similar threads

  • Programming and Computer Science
Replies
2
Views
907
  • Programming and Computer Science
2
Replies
57
Views
3K
  • Programming and Computer Science
Replies
12
Views
2K
  • Programming and Computer Science
Replies
29
Views
2K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
7
Views
2K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
2
Replies
65
Views
2K
Back
Top