markonvert

A little Fortran unformatted record marker converter



Fortran unformatted data interoperability issues?

Do you use any programs written in the Fortran programming language? Do they save and load data to/from unformatted files? This is quite common in the scientific/engineering calculation field.

Have you ever experienced interoperability issues when trying to exchange unformatted data files between programs compiled with different Fortran compilers? Depending on the pair of compilers, it may happen that one program is not able to properly read unformatted data files written by the other program.

Unfortunately the Fortran77 ANSI standard does not mandate any low level form for unformatted files. As a consequence, each Fortran implementation uses an arbitrary, and possibly different, format.
Usually an unformatted record is stored as a record start marker, followed by the record payload (the actual data the Fortran code explicitly reads or writes), followed by a record end marker. Both record markers (start and end) typically represent the length of the record payload, in bytes.

GNU G77 version 3.3.x and earlier uses 32 bit record markers, which represent the payload byte count as a signed 32 bit integer. This format limits the payload length to 231 - 1 byte (about 2.15 ⋅ 109 byte). Other compilers adopt the same format for records shorter than 231 byte, while they exploit special (not necessarily interoperable) formats for longer records.

GNU G77 version 3.4.x and GNU Fortran 4.0.x use 64 bit record markers, representing the payload byte count as a signed 64 bit integer. This format allows for payload lengths up to 263 - 1 byte (about 9.22 ⋅ 1018 byte), but is not interoperable with the previously adopted one.

GNU Fortran 4.1.x and later can use both 32 bit and 64 bit record markers: programs compiled with the -frecord-marker=4 compile option will use 32 bit markers, while -frecord-marker=8 will force 64 bit markers.
Please note that GNU Fortran 4.1.x uses 64 bit markers by default on most systems; GNU Fortran 4.2.x and later uses 32 bit markers by default, instead.

All this means that you cannot count on reading previously written unformatted data, if different Fortran compilers were used to compile the involved programs!

See also Debian bug #369547 and GCC Bugzilla bug #19303 for further details.

markonvert aims to alleviate the above described interoperability issues.

markonvert: what does it do?

markonvert is a little program (written in C++) that can convert between different Fortran unformatted data file formats. It can convert Fortran unformatted data files from the 32 bit marker low level form to the 64 bit form and vice-versa, provided that all record payloads are shorter than 231 byte.

It is distributed under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. You need a C++ compiler and a C++ standard library implementation (surprised?) in order to build it.

markonvert is not difficult to use: run it from the command line, without any arguments, in order to get a brief usage help.

Latest release

Warning: The development of markonvert ceased in 2007, when the interoperability issues it tries to address were already fading away. There are currently no plans to further develop or maintain it, but it is still available for download, in case someone finds it useful for any purpose.

N.B.: markonvert currently works only on little endian architectures, and converts only little endian unformatted data files. Support for big endian architectures and data is not (yet) implemented.

version 0.5, codename "Does not" (source code)
This is the first public version: it does not (yet) support big endian architectures or big endian data, does not use the GNU autotools for configuration and building, does not even have a simple Makefile, does not live in any VCS (e.g.: Git) repository, does not have a man page, OK you got it... it does not...
But anyway, it seems to work.

This work is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2. It comes with absolutely no warranty. See the license text for details.