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§
- Fortran
Config - Configuration for reading/writing Fortran unformatted files
- Fortran
File - Fortran unformatted file reader/writer
Enums§
- Access
Mode - Fortran file access mode
- Endian
Mode - Endianness mode for Fortran files
- Fortran
Type - Fortran data types
- Record
Marker Size - Record marker size for Fortran unformatted files
- Record
Type - 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