Provides a support for file handling (Specification)
version: experimental
Reads a whole ASCII file and loads its contents into a string variable. (Specification)
Subroutine interface for reading the content of a file into a string.
This subroutine reads the entirety of a specified ASCII file and returns it as a string. The optional
err
argument allows for handling errors through the library's state_type
class.
An optional logical
flag can be passed to delete the file after reading.
Note
Handles errors using the library's state_type
error-handling class. If not provided,
exceptions will trigger an error stop
.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=*), | public, | parameter | :: | FMT_COMPLEX_DP | = | '(es24.16e3,1x,es24.16e3)' |
Format strings with edit descriptors for each type and kind (Specification) Format string for integers Format string for single precision real numbers Format string for souble precision real numbers Format string for extended double precision real numbers Format string for quadruple precision real numbers Format string for single precision complex numbers Format string for double precision complex numbers Format string for extended double precision complex numbers Format string for quadruple precision complex numbers |
character(len=*), | public, | parameter | :: | FMT_COMPLEX_QP | = | '(es44.35e4,1x,es44.35e4)' |
Format strings with edit descriptors for each type and kind (Specification) Format string for integers Format string for single precision real numbers Format string for souble precision real numbers Format string for extended double precision real numbers Format string for quadruple precision real numbers Format string for single precision complex numbers Format string for double precision complex numbers Format string for extended double precision complex numbers Format string for quadruple precision complex numbers |
character(len=*), | public, | parameter | :: | FMT_COMPLEX_SP | = | '(es15.8e2,1x,es15.8e2)' |
Format strings with edit descriptors for each type and kind (Specification) Format string for integers Format string for single precision real numbers Format string for souble precision real numbers Format string for extended double precision real numbers Format string for quadruple precision real numbers Format string for single precision complex numbers Format string for double precision complex numbers Format string for extended double precision complex numbers Format string for quadruple precision complex numbers |
character(len=*), | public, | parameter | :: | FMT_COMPLEX_XDP | = | '(es26.18e3,1x,es26.18e3)' |
Format strings with edit descriptors for each type and kind (Specification) Format string for integers Format string for single precision real numbers Format string for souble precision real numbers Format string for extended double precision real numbers Format string for quadruple precision real numbers Format string for single precision complex numbers Format string for double precision complex numbers Format string for extended double precision complex numbers Format string for quadruple precision complex numbers |
character(len=*), | public, | parameter | :: | FMT_INT | = | '(i0)' |
Format strings with edit descriptors for each type and kind (Specification) Format string for integers Format string for single precision real numbers Format string for souble precision real numbers Format string for extended double precision real numbers Format string for quadruple precision real numbers Format string for single precision complex numbers Format string for double precision complex numbers Format string for extended double precision complex numbers Format string for quadruple precision complex numbers |
character(len=*), | public, | parameter | :: | FMT_REAL_DP | = | '(es24.16e3)' |
Format strings with edit descriptors for each type and kind (Specification) Format string for integers Format string for single precision real numbers Format string for souble precision real numbers Format string for extended double precision real numbers Format string for quadruple precision real numbers Format string for single precision complex numbers Format string for double precision complex numbers Format string for extended double precision complex numbers Format string for quadruple precision complex numbers |
character(len=*), | public, | parameter | :: | FMT_REAL_QP | = | '(es44.35e4)' |
Format strings with edit descriptors for each type and kind (Specification) Format string for integers Format string for single precision real numbers Format string for souble precision real numbers Format string for extended double precision real numbers Format string for quadruple precision real numbers Format string for single precision complex numbers Format string for double precision complex numbers Format string for extended double precision complex numbers Format string for quadruple precision complex numbers |
character(len=*), | public, | parameter | :: | FMT_REAL_SP | = | '(es15.8e2)' |
Format strings with edit descriptors for each type and kind (Specification) Format string for integers Format string for single precision real numbers Format string for souble precision real numbers Format string for extended double precision real numbers Format string for quadruple precision real numbers Format string for single precision complex numbers Format string for double precision complex numbers Format string for extended double precision complex numbers Format string for quadruple precision complex numbers |
character(len=*), | public, | parameter | :: | FMT_REAL_XDP | = | '(es26.18e3)' |
Format strings with edit descriptors for each type and kind (Specification) Format string for integers Format string for single precision real numbers Format string for souble precision real numbers Format string for extended double precision real numbers Format string for quadruple precision real numbers Format string for single precision complex numbers Format string for double precision complex numbers Format string for extended double precision complex numbers Format string for quadruple precision complex numbers |
Reads a whole ASCII file and loads its contents into an allocatable character
variable.
The function handles error states and optionally deletes the file after reading.
Check if the file should be deleted after reading
Check file existing
Retrieve file size
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Input file name |
||
character(len=:), | intent(out), | allocatable | :: | file |
Output string variable |
|
type(state_type), | intent(out), | optional | :: | err |
[optional] State return flag. On error, if not requested, the code will stop. |
|
logical, | intent(in), | optional | :: | delete |
[optional] Delete file after reading? Default: do not delete |
Reads a whole ASCII file and loads its contents into a string variable. The function handles error states and optionally deletes the file after reading.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
Input file name |
||
type(string_type), | intent(out) | :: | file |
Output string variable |
||
type(state_type), | intent(out), | optional | :: | err |
[optional] State return flag. On error, if not requested, the code will stop. |
|
logical, | intent(in), | optional | :: | delete |
[optional] Delete file after reading? Default: do not delete |
Read a whole line from a formatted unit into a string variable
Read a whole line from a formatted unit into a deferred length character variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | unit |
Formatted IO unit |
||
character(len=:), | intent(out), | allocatable | :: | line |
Line to read |
|
integer, | intent(out), | optional | :: | iostat |
Status of operation |
|
character(len=:), | optional, | allocatable | :: | iomsg |
Error message |
Read a whole line from a formatted unit into a string variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | unit |
Formatted IO unit |
||
type(string_type), | intent(out) | :: | line |
Line to read |
||
integer, | intent(out), | optional | :: | iostat |
Status of operation |
|
character(len=:), | optional, | allocatable | :: | iomsg |
Error message |
Read a whole line from the standard input into a deferred length character variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=:), | intent(out), | allocatable | :: | line |
Line to read |
|
integer, | intent(out), | optional | :: | iostat |
Status of operation |
|
character(len=:), | optional, | allocatable | :: | iomsg |
Error message |
Read a whole line from the standard input into a string variable
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(string_type), | intent(out) | :: | line |
Line to read |
||
integer, | intent(out), | optional | :: | iostat |
Status of operation |
|
character(len=:), | optional, | allocatable | :: | iomsg |
Error message |
Loads a 2D array from a text file (Specification)
Loads a 2D array from a text file.
Filename to load the array from
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
The array 'd' will be automatically allocated with the correct dimensions |
||
real(kind=sp), | intent(out), | allocatable | :: | d(:,:) |
Skip the first |
|
integer, | intent(in), | optional | :: | skiprows |
Read |
|
integer, | intent(in), | optional | :: | max_rows | ||
character(len=*), | intent(in), | optional | :: | fmt |
Loads a 2D array from a text file.
Filename to load the array from
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
The array 'd' will be automatically allocated with the correct dimensions |
||
real(kind=dp), | intent(out), | allocatable | :: | d(:,:) |
Skip the first |
|
integer, | intent(in), | optional | :: | skiprows |
Read |
|
integer, | intent(in), | optional | :: | max_rows | ||
character(len=*), | intent(in), | optional | :: | fmt |
Loads a 2D array from a text file.
Filename to load the array from
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
The array 'd' will be automatically allocated with the correct dimensions |
||
integer(kind=int8), | intent(out), | allocatable | :: | d(:,:) |
Skip the first |
|
integer, | intent(in), | optional | :: | skiprows |
Read |
|
integer, | intent(in), | optional | :: | max_rows | ||
character(len=*), | intent(in), | optional | :: | fmt |
Loads a 2D array from a text file.
Filename to load the array from
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
The array 'd' will be automatically allocated with the correct dimensions |
||
integer(kind=int16), | intent(out), | allocatable | :: | d(:,:) |
Skip the first |
|
integer, | intent(in), | optional | :: | skiprows |
Read |
|
integer, | intent(in), | optional | :: | max_rows | ||
character(len=*), | intent(in), | optional | :: | fmt |
Loads a 2D array from a text file.
Filename to load the array from
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
The array 'd' will be automatically allocated with the correct dimensions |
||
integer(kind=int32), | intent(out), | allocatable | :: | d(:,:) |
Skip the first |
|
integer, | intent(in), | optional | :: | skiprows |
Read |
|
integer, | intent(in), | optional | :: | max_rows | ||
character(len=*), | intent(in), | optional | :: | fmt |
Loads a 2D array from a text file.
Filename to load the array from
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
The array 'd' will be automatically allocated with the correct dimensions |
||
integer(kind=int64), | intent(out), | allocatable | :: | d(:,:) |
Skip the first |
|
integer, | intent(in), | optional | :: | skiprows |
Read |
|
integer, | intent(in), | optional | :: | max_rows | ||
character(len=*), | intent(in), | optional | :: | fmt |
Loads a 2D array from a text file.
Filename to load the array from
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
The array 'd' will be automatically allocated with the correct dimensions |
||
complex(kind=sp), | intent(out), | allocatable | :: | d(:,:) |
Skip the first |
|
integer, | intent(in), | optional | :: | skiprows |
Read |
|
integer, | intent(in), | optional | :: | max_rows | ||
character(len=*), | intent(in), | optional | :: | fmt |
Loads a 2D array from a text file.
Filename to load the array from
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
The array 'd' will be automatically allocated with the correct dimensions |
||
complex(kind=dp), | intent(out), | allocatable | :: | d(:,:) |
Skip the first |
|
integer, | intent(in), | optional | :: | skiprows |
Read |
|
integer, | intent(in), | optional | :: | max_rows | ||
character(len=*), | intent(in), | optional | :: | fmt |
Saves a 2D array into a text file (Specification)
Saves a 2D array into a text file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
real(kind=sp), | intent(in) | :: | d(:,:) |
Example
|
Saves a 2D array into a text file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
real(kind=dp), | intent(in) | :: | d(:,:) |
Example
|
Saves a 2D array into a text file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
integer(kind=int8), | intent(in) | :: | d(:,:) |
Example
|
Saves a 2D array into a text file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
integer(kind=int16), | intent(in) | :: | d(:,:) |
Example
|
Saves a 2D array into a text file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
integer(kind=int32), | intent(in) | :: | d(:,:) |
Example
|
Saves a 2D array into a text file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
integer(kind=int64), | intent(in) | :: | d(:,:) |
Example
|
Saves a 2D array into a text file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
complex(kind=sp), | intent(in) | :: | d(:,:) |
Example
|
Saves a 2D array into a text file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
complex(kind=dp), | intent(in) | :: | d(:,:) |
Example
|
Opens a file (Specification)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
character(len=*), | intent(in), | optional | :: | mode | ||
integer, | intent(out), | optional | :: | iostat |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | mode |