0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
mo_io Module Reference

File reading routines. More...

Data Types

interface  loadtxt
 Read a file into a 2D array containing reals. More...
 

Functions/Subroutines

subroutine loadtxt_dp (filename, d, skiprows, max_rows)
 Read a file into a 2D array containing reals.
 
subroutine loadtxt_sp (filename, d, skiprows, max_rows)
 Read a file into a 2D array containing reals.
 
integer function, public number_of_columns (u)
 Determine number of columns in a file. The columns are assumed to be separated by spaces or tabs.
 
integer function, public number_of_rows (u)
 Determine number of rows in a file.
 

Detailed Description

File reading routines.

This module provides routines to load a file into an array. This is mainly taken from the Fortran stdlib: https://github.com/fortran-lang/stdlib

Version
0.1
Authors
Sebastian Mueller
Date
Apr 2022

Function/Subroutine Documentation

◆ loadtxt_dp()

subroutine mo_io::loadtxt_dp ( character(len=*), intent(in)  filename,
real(dp), dimension(:,:), intent(out), allocatable  d,
integer(i4), intent(in), optional  skiprows,
integer(i4), intent(in), optional  max_rows 
)
private

Read a file into a 2D array containing reals.

Parameters
[in]filenameFilename to load the array from
[out]dThe array 'd' will be automatically allocated with the correct dimensions
[in]skiprowslines to skip at the begining
[in]max_rowsRead max_rows lines of content after skiprows lines. The default is to read all the lines (negative values).

Definition at line 33 of file mo_io.f90.

◆ loadtxt_sp()

subroutine mo_io::loadtxt_sp ( character(len=*), intent(in)  filename,
real(sp), dimension(:,:), intent(out), allocatable  d,
integer(i4), intent(in), optional  skiprows,
integer(i4), intent(in), optional  max_rows 
)
private

Read a file into a 2D array containing reals.

Parameters
[in]filenameFilename to load the array from
[out]dThe array 'd' will be automatically allocated with the correct dimensions
[in]skiprowslines to skip at the begining
[in]max_rowsRead max_rows lines of content after skiprows lines. The default is to read all the lines (negative values).

Definition at line 75 of file mo_io.f90.

◆ number_of_columns()

integer function, public mo_io::number_of_columns ( integer(i4), intent(in)  u)

Determine number of columns in a file. The columns are assumed to be separated by spaces or tabs.

Returns
Number of columns.
Parameters
[in]uunit of the open file

Definition at line 118 of file mo_io.f90.

References mo_string_utils::is_blank(), and number_of_columns().

Referenced by mo_io::loadtxt::loadtxt_dp(), mo_io::loadtxt::loadtxt_sp(), and number_of_columns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ number_of_rows()

integer function, public mo_io::number_of_rows ( integer(i4), intent(in)  u)

Determine number of rows in a file.

Returns
Number of rows.
Parameters
[in]uunit of the open file

Definition at line 140 of file mo_io.f90.

References number_of_rows().

Referenced by mo_io::loadtxt::loadtxt_dp(), mo_io::loadtxt::loadtxt_sp(), and number_of_rows().

Here is the call graph for this function:
Here is the caller graph for this function: