toolFortran

toolFortran — Introduces routines to read the binary Fortran data format.

Functions

Types and Values

Description

In Fortran binary data are written inside tags. These tags give the size to the data that are between. The routines in this module can read these tags and the data inside. One must know the endianness of the file and the kind of data to be read (integer, float, double...). If the first tag is known, one can test the endianness of the file calling tool_fortran_testEndianness().

The size of the tag (32 bits or 64 bits) is not modifiable for the moment and is fixed at 32 bits. This may be changed in the futur with the same kind of things that for endianness.

Functions

tool_fortran_readCharacter ()

gboolean
tool_fortran_readCharacter (char *var,
                            guint nb,
                            FILE *flux,
                            GError **error,
                            ToolFortranEndianId endianness,
                            gboolean testFlag,
                            gboolean store);

Read an array of characters from a fortran record. The endianness is required to read the Fortran flag. If argument store is FALSE, then the file is read and consistency checked but no data is stored. In that case, var can be not allocated.

Parameters

var

an allocated array of char ;

 

nb

the size of the array var ;

 

flux

a pointer on an opened file ;

 

error

a pointer to an error location ;

 

endianness

reverse or not the order of multi-bytes ;

 

testFlag

if TRUE, read start and stop flags and test their values ;

 

store

a boolean.

 

Returns

TRUE if everything went right.


tool_fortran_readInteger ()

gboolean
tool_fortran_readInteger (guint *var,
                          guint nb,
                          FILE *flux,
                          GError **error,
                          ToolFortranEndianId endianness,
                          gboolean testFlag,
                          gboolean store);

Read an array of integers from a fortran record. If argument store is FALSE, then the file is read and consistency checked but no data is stored. In that case, var can be not allocated.

Parameters

var

an allocated array of int ;

 

nb

the size of the array var ;

 

flux

a pointer on an opened file ;

 

error

a pointer to an error location ;

 

endianness

reverse or not the order of multi-bytes ;

 

testFlag

if TRUE, read start and stop flags and test their values ;

 

store

a boolean.

 

Returns

TRUE if everything went right.


tool_fortran_readReal ()

gboolean
tool_fortran_readReal (float *var,
                       guint nb,
                       FILE *flux,
                       GError **error,
                       ToolFortranEndianId endianness,
                       gboolean testFlag,
                       gboolean store);

Read an array of reals from a fortran record. If argument store is FALSE, then the file is read and consistency checked but no data is stored. In that case, var can be not allocated.

Parameters

var

an allocated array of float ;

 

nb

the size of the array var ;

 

flux

a pointer on an opened file ;

 

error

a pointer to an error location ;

 

endianness

reverse or not the order of multi-bytes ;

 

testFlag

if TRUE, read start and stop flags and test their values ;

 

store

a boolean.

 

Returns

TRUE if everything went right.


tool_fortran_readDouble ()

gboolean
tool_fortran_readDouble (double *var,
                         guint nb,
                         FILE *flux,
                         GError **error,
                         ToolFortranEndianId endianness,
                         gboolean testFlag,
                         gboolean store);

Read an array of doubles from a fortran record. If argument store is FALSE, then the file is read and consistency checked but no data is stored. In that case, var can be not allocated.

Parameters

var

an allocated array of double ;

 

nb

the size of the array var ;

 

flux

a pointer on an opened file ;

 

error

a pointer to an error location ;

 

endianness

reverse or not the order of multi-bytes ;

 

testFlag

if TRUE, read start and stop flags and test their values ;

 

store

a boolean.

 

Returns

TRUE if everything went right.


tool_fortran_readFlag ()

gboolean
tool_fortran_readFlag (guint *nb,
                       FILE *flux,
                       GError **error,
                       ToolFortranEndianId endianness);

Read the flag of a record (a 32bits integer).

Parameters

nb

a location t store the value of the flag ;

 

flux

a pointer on an opened file ;

 

error

a pointer to an error location ;

 

endianness

reverse or not the order of multi-bytes.

 

Returns

TRUE if everything went right.


tool_fortran_testEndianness ()

gboolean
tool_fortran_testEndianness (guint nb,
                             FILE *flux,
                             GError **error,
                             ToolFortranEndianId *endianness);

Read a flag and compare the value with nb for little and big endian. It return the value of endianness to be used after. The file is rewind after the call.

Parameters

nb

the value of the flag to read ;

 

flux

a pointer on an opened file ;

 

error

a pointer to an error location ;

 

endianness

a location to store the endianness.

 

Returns

TRUE if everything went right.

Types and Values

enum ToolFortranEndianId

Thiese ids are used when reading a multi-bytes information from a binary file.

Members

TOOL_FORTRAN_ENDIAN_KEEP

read a file without inverting records.

 

TOOL_FORTRAN_ENDIAN_CHANGE

read a file inverting records.