mctc_io_utils Module



Interfaces

public interface read_next_token

  • private subroutine read_next_token_int(line, pos, token, val, iostat, iomsg)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: line
    integer, intent(inout) :: pos
    type(token_type), intent(inout) :: token
    integer, intent(out) :: val
    integer, intent(out) :: iostat
    character(len=:), intent(out), optional, allocatable :: iomsg
  • private subroutine read_next_token_real(line, pos, token, val, iostat, iomsg)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: line
    integer, intent(inout) :: pos
    type(token_type), intent(inout) :: token
    real(kind=wp), intent(out) :: val
    integer, intent(out) :: iostat
    character(len=:), intent(out), optional, allocatable :: iomsg

public interface read_token

  • private subroutine read_token_int(line, token, val, iostat, iomsg)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: line
    type(token_type), intent(in) :: token
    integer, intent(out) :: val
    integer, intent(out) :: iostat
    character(len=:), intent(out), optional, allocatable :: iomsg
  • private subroutine read_token_real(line, token, val, iostat, iomsg)

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: line
    type(token_type), intent(in) :: token
    real(kind=wp), intent(out) :: val
    integer, intent(out) :: iostat
    character(len=:), intent(out), optional, allocatable :: iomsg

Derived Types

type, public ::  token_type

Text token

Components

Type Visibility Attributes Name Initial
integer, public :: first

Begin of sequence

integer, public :: last

End of sequence


Functions

public function filename(unit)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

Return Value character(len=:), allocatable

public pure function to_string(val, width) result(string)

Represent an integer as character sequence.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: val
integer, intent(in), optional :: width

Return Value character(len=:), allocatable


Subroutines

public subroutine getline(unit, line, iostat, iomsg)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

Formatted IO unit

character(len=:), intent(out), allocatable :: line

Line to read

integer, intent(out) :: iostat

Status of operation

character(len=:), optional, allocatable :: iomsg

Error message

public subroutine io2_error(error, message, source1, source2, token1, token2, filename, line1, line2, label1, label2)

Create new IO error

Arguments

Type IntentOptional Attributes Name
type(error_type), intent(out), allocatable :: error

Error handler

character(len=*), intent(in) :: message

Main error message

character(len=*), intent(in) :: source1

String representing the offending input

character(len=*), intent(in) :: source2

String representing the offending input

type(token_type), intent(in) :: token1

Last processed token

type(token_type), intent(in) :: token2

Last processed token

character(len=*), intent(in), optional :: filename

Name of the input file

integer, intent(in), optional :: line1

Line number

integer, intent(in), optional :: line2

Line number

character(len=*), intent(in), optional :: label1

Label of the offending statement

character(len=*), intent(in), optional :: label2

Label of the offending statement

public subroutine io_error(error, message, source, token, filename, line, label)

Create new IO error

Arguments

Type IntentOptional Attributes Name
type(error_type), intent(out), allocatable :: error

Error handler

character(len=*), intent(in) :: message

Main error message

character(len=*), intent(in) :: source

String representing the offending input

type(token_type), intent(in) :: token

Last processed token

character(len=*), intent(in), optional :: filename

Name of the input file

integer, intent(in), optional :: line

Line number

character(len=*), intent(in), optional :: label

Label of the offending statement

public subroutine next_line(unit, line, pos, lnum, iostat, iomsg)

Convenience function to read a line and update associated descriptors

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: unit

Formatted IO unit

character(len=:), intent(out), allocatable :: line

Line to read

integer, intent(out) :: pos

Current position in line

integer, intent(inout) :: lnum

Current line number

integer, intent(out) :: iostat

Status of operation

character(len=:), optional, allocatable :: iomsg

Error message

public subroutine next_token(string, pos, token)

Advance pointer to next text token

Arguments

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

String to check

integer, intent(inout) :: pos

Current position in string

type(token_type), intent(out) :: token

Token found