athena__tools_infile Module

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


Uses

    • coreutils

Interfaces

public interface allocate_and_assign_vec

Interface for allocating and assigning a vector to a variable

  • private subroutine allocate_and_assignRvec(buffer, variable, keyword, fs)

    Allocate and assign an arbitrary length vector of reals to variable

    Arguments

    Type IntentOptional 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

public interface assign_val

Interface for assigning a value to a variable

  • private subroutine assignI(buffer, variable, found, keyword, fs)

    Assign an integer to variable

    Arguments

    Type IntentOptional 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

  • private subroutine assignR(buffer, variable, found, keyword, fs)

    Assign a real to variable

    Arguments

    Type IntentOptional 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

  • private subroutine assignS(buffer, variable, found, keyword, fs)

    Assign a string to variable

    Arguments

    Type IntentOptional 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

  • private subroutine assignL(buffer, variable, found, keyword, fs)

    Assign a logical to variable (T/t/1 and F/f/0 accepted)

    Arguments

    Type IntentOptional 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

public interface assign_vec

Interface for assigning a vector to a variable

  • private subroutine assignIvec(buffer, variable, found, keyword, fs)

    Assign an arbitrary length vector of integers to variable

    Arguments

    Type IntentOptional 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

  • private subroutine assignRvec(buffer, variable, found, keyword, fs)

    Assign an arbitrary length vector of reals to variable

    Arguments

    Type IntentOptional 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


Functions

public function get_val(buffer, fs) result(output)

Extract the section of buffer that occurs after the field separator fs

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: buffer

Input buffer

character(len=1), intent(in), optional :: fs

Field separator

Return Value character(len=:), allocatable

Extracted value

public function stop_check(file) result(output)

Logical check for stop file Check if file exists Read line-by-line

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in), optional :: file

File to check for

Return Value logical

File found flag and output


Subroutines

public subroutine getline(unit, pattern, buffer)

Get the line from a grep and assign it to buffer

Arguments

Type IntentOptional 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

public subroutine move(unit, change, iostat, err_msg)

Move current position in file based on relative change

Arguments

Type IntentOptional 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

public subroutine rm_comments(buffer, iline)

Remove comment from a string (anything after ! or #)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(inout) :: buffer

Input buffer

integer, intent(in), optional :: iline

Line number

private subroutine allocate_and_assignRvec(buffer, variable, keyword, fs)

Allocate and assign an arbitrary length vector of reals to variable

Arguments

Type IntentOptional 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

private subroutine assignI(buffer, variable, found, keyword, fs)

Assign an integer to variable

Arguments

Type IntentOptional 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

private subroutine assignIvec(buffer, variable, found, keyword, fs)

Assign an arbitrary length vector of integers to variable

Arguments

Type IntentOptional 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

private subroutine assignL(buffer, variable, found, keyword, fs)

Assign a logical to variable (T/t/1 and F/f/0 accepted)

Arguments

Type IntentOptional 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

private subroutine assignR(buffer, variable, found, keyword, fs)

Assign a real to variable

Arguments

Type IntentOptional 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

private subroutine assignRvec(buffer, variable, found, keyword, fs)

Assign an arbitrary length vector of reals to variable

Arguments

Type IntentOptional 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

private subroutine assignS(buffer, variable, found, keyword, fs)

Assign a string to variable

Arguments

Type IntentOptional 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