input_t Derived Type

type, public, extends(type_node) :: input_t


Inherits

type~~input_t~~InheritsGraph type~input_t input_t type~input_t->type~input_t cmp_arr YamlFile YamlFile type~input_t->YamlFile file type_dictionary type_dictionary type~input_t->type_dictionary cmp_by_type type_node type_node type~input_t->type_node root type~input_t->type_node

Components

Type Visibility Attributes Name Initial
class(type_node), public, pointer :: root => null()

top level (main) access to the tree

type(YamlFile), public :: file

used only for top level config

type(type_dictionary), public :: cmp_by_type

dictionary with arrays of components

type(input_t), public, pointer :: cmp_arr(:) => null()

array of components of the same type


Type-Bound Procedures

procedure, public :: open => input_open_yaml

Open and parse file and return as input dictionary

  • private recursive subroutine input_open_yaml(me, file_name, included)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(inout) :: me
    character(len=*), intent(in) :: file_name
    logical, intent(in), optional :: included

    ignore it - only present for included files

procedure, public :: dict => input_dict

Get input sub-dictionary

  • private function input_dict(me, key, filter_key, filter_value, empty) result(out_dict)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    character(len=*), intent(in), optional :: filter_key
    character(len=*), intent(in), optional :: filter_value
    logical, intent(in), optional :: empty

    Return Value class(input_t), allocatable

procedure, public :: dict1d => input_dict1d

Get allocatable array of input sub-dictionaries

  • private function input_dict1d(me, key, filter_key, filter_value, empty) result(return_array)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    character(len=*), intent(in), optional :: filter_key
    character(len=*), intent(in), optional :: filter_value
    logical, intent(in), optional :: empty

    Return Value class(input_t), allocatable, (:)

procedure, public :: dbl => input_dbl

Get 'real' double precision value

  • private function input_dbl(me, key, default_value) result(val)

    Function returns double value given by the key and stops if key doesn't exist.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key

    key to the value in dictionary

    real(kind=dp), intent(in), optional :: default_value

    default value in case of missing key

    Return Value real(kind=dp)

    returned value

procedure, public :: dbl1d => input_dbl1d

Get 'real' double precision allocatable one dimension array

  • private function input_dbl1d(me, key, default_value, n) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    real(kind=dp), intent(in), optional :: default_value(:)

    default value in case of missing key

    integer, intent(in), optional :: n

    Return Value real(kind=dp), allocatable, (:)

procedure, public :: dbl2d => input_dbl2d

Get 'real' double precision allocatable two dimensional array

  • private function input_dbl2d(me, key, default_value) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    real(kind=dp), intent(in), optional :: default_value(:,:)

    default value in case of missing key

    Return Value real(kind=dp), allocatable, (:,:)

procedure, public :: bin => input_bin

Get 'logical' value like: true/false yes/no etc...

  • private function input_bin(me, key, default_value) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    logical, intent(in), optional :: default_value

    Return Value logical

procedure, public :: bin1d => input_bin1d

Get 'logical' 1d array of values of true/false yes/no etc...

  • private function input_bin1d(me, key, default_value, n) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    logical, intent(in), optional :: default_value(:)

    default value in case of missing key

    integer, intent(in), optional :: n

    Return Value logical, allocatable, (:)

procedure, public :: int => input_int

Get 'integer' value

  • private function input_int(me, key, default_value) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    integer, intent(in), optional :: default_value

    Return Value integer

procedure, public :: int1d => input_int1d

Get 'integer' value

  • private function input_int1d(me, key, default_value, n) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    integer, intent(in), optional :: default_value(:)

    default value in case of missing key

    integer, intent(in), optional :: n

    expected number of elements in the array (can be used broadcast scalar to array)

    Return Value integer, allocatable, (:)

procedure, public :: str => input_str

Get allocatable trimmed 'character(:)' value

  • private function input_str(me, key, default_value) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    character(len=*), intent(in), optional :: default_value

    Return Value character(len=:), allocatable

procedure, public :: str1d => input_str1d

Get allocatable trimmed 'character(:)' value

  • private function input_str1d(me, key, default_value, empty) result(val)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key
    type(str_ptr), intent(in), optional :: default_value
    logical, intent(in), optional :: empty

    Return Value type(str_ptr), allocatable, (:)

procedure, public :: cmp1d => input_cmp1d

Get pointer to array of input components

  • private function input_cmp1d(me, keys) result(return_array)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: keys(:)

    Return Value type(input_t), pointer, (:)

procedure, public :: nb_cmp => input_nb_cmp

Get total number of components

  • private function input_nb_cmp(me) result(nb_cmp)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me

    Return Value integer

procedure, public :: has_key => input_has_key

Return true if dictionary has a key

  • private function input_has_key(me, key)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key

    Return Value logical

procedure, public :: keys1d => input_keys1d

Return 1d array of keys

  • private function input_keys1d(me) result(keys)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me

    Return Value type(str_ptr), allocatable, (:)

procedure, public :: node => input_node

Get "type_node" from yaml lib

  • private function input_node(me, key) result(node)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: me
    character(len=*), intent(in) :: key

    Return Value class(type_node), pointer

procedure, public :: dump => input_dump_dict

  • private recursive subroutine input_dump_dict(self, unit, indent)

    Arguments

    Type IntentOptional Attributes Name
    class(input_t), intent(in) :: self
    integer, intent(in) :: unit
    integer, intent(in) :: indent

Source Code

    type, extends(type_node) :: input_t
        class(type_node), pointer :: root => null()       !! top level (main) access to the tree
        type(YamlFile)            :: file                 !! used only for top level config
        type(type_dictionary)     :: cmp_by_type          !! dictionary with arrays of components
        type(input_t), pointer    :: cmp_arr(:) => null() !! array of components of the same type
    contains
        procedure :: open    => input_open_yaml  !! Open and parse file and return as input dictionary 
        ! Main get access functions
        procedure :: dict    => input_dict   !! Get input sub-dictionary
        procedure :: dict1d  => input_dict1d !! Get allocatable array of input sub-dictionaries 
        procedure :: dbl     => input_dbl    !! Get 'real' double precision value
        procedure :: dbl1d   => input_dbl1d  !! Get 'real' double precision allocatable one dimension array
        procedure :: dbl2d   => input_dbl2d  !! Get 'real' double precision allocatable two dimensional array
        procedure :: bin     => input_bin    !! Get 'logical' value like: true/false yes/no etc... 
        procedure :: bin1d   => input_bin1d  !! Get 'logical' 1d array of values of true/false yes/no etc... 
        procedure :: int     => input_int    !! Get 'integer' value
        procedure :: int1d   => input_int1d  !! Get 'integer' value
        procedure :: str     => input_str    !! Get allocatable trimmed 'character(:)' value
        procedure :: str1d   => input_str1d  !! Get allocatable trimmed 'character(:)' value
        procedure :: cmp1d   => input_cmp1d  !! Get pointer to array of input components
        procedure :: nb_cmp  => input_nb_cmp !! Get total number of components
        procedure :: has_key => input_has_key!! Return true if dictionary has a key
        procedure :: keys1d  => input_keys1d !! Return 1d array of keys
        ! Private only for debugging
        procedure :: node    => input_node   !! Get "type_node" from yaml lib
        procedure :: dump    => input_dump_dict
    end type input_t