Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Reading Universal File Type 58b in Fortran

  1. Feb 15, 2013 #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.
  2. jcsd
  3. Feb 15, 2013 #2


    Staff: Mentor

    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.
  4. Feb 15, 2013 #3


    User Avatar
    Science Advisor
    Homework Helper

    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: Feb 15, 2013
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook