Module fortran

Module fortran 

Source
Expand description

Fortran unformatted file format module

Provides functionality for reading and writing Fortran unformatted files:

  • Sequential, direct, and stream access modes
  • Support for different endianness and record marker sizes
  • Automatic format detection
  • Arrays stored in column-major order (Fortran convention)
  • Support for all common Fortran data types Fortran unformatted file handling module

This module provides functionality for reading and writing Fortran unformatted files, which are commonly used in scientific computing, particularly in computational physics, weather modeling, and engineering applications.

§Fortran Unformatted File Format

Fortran unformatted files use a record-based structure where each record is delimited by a record marker that contains the byte count of the record. The format varies between compilers and platforms:

  • Sequential access: Each record has a 4-byte (or 8-byte) marker before and after
  • Direct access: Fixed-length records without markers
  • Stream access: Continuous byte stream (Fortran 2003+)

§Examples

use scirs2_io::fortran::{FortranFile, RecordType, EndianMode};
use scirs2_core::ndarray::Array2;

// Read a Fortran unformatted file
let mut file = FortranFile::open("data.unf")?;

// Read a 2D array of doubles
let array: Array2<f64> = file.read_array_2d(100, 50)?;

// Write to a new file
let mut out_file = FortranFile::create("output.unf")?;
out_file.write_array(&array)?;

Structs§

FortranConfig
Configuration for reading/writing Fortran unformatted files
FortranFile
Fortran unformatted file reader/writer

Enums§

AccessMode
Fortran file access mode
EndianMode
Endianness mode for Fortran files
FortranType
Fortran data types
RecordMarkerSize
Record marker size for Fortran unformatted files
RecordType
Type of record in a Fortran file

Functions§

detect_fortran_format
Detect the endianness and record marker size of a Fortran file
read_fortran_file
Read a complete Fortran unformatted file into memory