Module containing custom input file reading functions and subroutines
This module contains custom input file reading functions and subroutines for reading and assigning values from a file. Code copied from ARTEMIS with permission of the authors Ned Thaddeus Taylor and Francis Huw Davies https://github.com/ExeQuantCode/ARTEMIS
Interface for allocating and assigning a vector to a variable
Allocate and assign an arbitrary length vector of reals to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| real(kind=real32), | intent(out), | dimension(:), allocatable | :: | variable |
Variable to assign data to |
|
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Interface for assigning a value to a variable
Assign an integer to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| integer, | intent(out) | :: | variable |
Variable to assign data to |
||
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign a real to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| real(kind=real32), | intent(out) | :: | variable |
Variable to assign data to |
||
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign a string to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| character(len=*), | intent(out) | :: | variable |
Variable to assign data to |
||
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign a logical to variable (T/t/1 and F/f/0 accepted)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| logical, | intent(out) | :: | variable |
Variable to assign data to |
||
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Interface for assigning a vector to a variable
Assign an arbitrary length vector of integers to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| integer, | intent(out), | dimension(:) | :: | variable |
Variable to assign data to |
|
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign an arbitrary length vector of reals to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| real(kind=real32), | intent(out), | dimension(:) | :: | variable |
Variable to assign data to |
|
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Extract the section of buffer that occurs after the field separator fs
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | buffer |
Input buffer |
||
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Extracted value
Logical check for stop file Check if file exists Read line-by-line
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in), | optional | :: | file |
File to check for |
File found flag and output
Get the line from a grep and assign it to buffer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | unit |
Unit to read from |
||
| character(len=*), | intent(in) | :: | pattern |
Pattern to grep for |
||
| character(len=*), | intent(out) | :: | buffer |
Buffer to assign line to |
Move current position in file based on relative change
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | unit |
Unit to read from |
||
| integer, | intent(in) | :: | change |
Relative change in position |
||
| integer, | intent(out), | optional | :: | iostat |
I/O status |
|
| character(len=*), | intent(out), | optional | :: | err_msg |
Error message |
Remove comment from a string (anything after ! or #)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| integer, | intent(in), | optional | :: | iline |
Line number |
Allocate and assign an arbitrary length vector of reals to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| real(kind=real32), | intent(out), | dimension(:), allocatable | :: | variable |
Variable to assign data to |
|
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign an integer to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| integer, | intent(out) | :: | variable |
Variable to assign data to |
||
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign an arbitrary length vector of integers to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| integer, | intent(out), | dimension(:) | :: | variable |
Variable to assign data to |
|
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign a logical to variable (T/t/1 and F/f/0 accepted)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| logical, | intent(out) | :: | variable |
Variable to assign data to |
||
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign a real to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| real(kind=real32), | intent(out) | :: | variable |
Variable to assign data to |
||
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign an arbitrary length vector of reals to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| real(kind=real32), | intent(out), | dimension(:) | :: | variable |
Variable to assign data to |
|
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
Assign a string to variable
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| character(len=*), | intent(out) | :: | variable |
Variable to assign data to |
||
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |