FMS  2024.03
Flexible Modeling System
yaml_parser_mod

Routines to use for parsing yaml files. More...

Data Types

interface  get_value_from_key
 Dermine the value of a key from a keyname. More...
 
interface  open_and_parse_file_wrap
 c functions binding More...
 

Functions/Subroutines

subroutine check_error_code (error_code, filename)
 Checks the error code from a open_and_parse_file_wrap function call.
 
subroutine, public get_block_ids (file_id, block_name, block_ids, parent_block_id)
 Gets the the ids of the blocks with block_name in the yaml file If parent_block_id is present, it only gets those that belong to that block. More...
 
subroutine, public get_block_name (file_id, block_id, block_name)
 Gets the block name form the block id. More...
 
subroutine, public get_key_ids (file_id, block_id, key_ids)
 Gets the ids of the key-value pairs in a block. More...
 
subroutine, public get_key_name (file_id, key_id, key_name)
 Gets the key from a file id. More...
 
subroutine, public get_key_value (file_id, key_id, key_value)
 Gets the value from a file id. More...
 
integer function, public get_nkeys (file_id, block_id)
 Gets the number of key-value pairs in a block. More...
 
integer function, public get_num_blocks (file_id, block_name, parent_block_id)
 Determines the number of blocks with block_name in the yaml file If parent_block_id is present, it only counts those that belong to that block. More...
 
integer function, public get_num_unique_blocks (file_id, parent_block_id)
 Gets the number of unique blocks. More...
 
subroutine, public get_unique_block_ids (file_id, block_ids, parent_block_id)
 Gets the ids of the unique block ids. More...
 
subroutine get_value_from_key_0d (file_id, block_id, key_name, key_value, is_optional)
 Used to dermine the value of a key from a keyname. More...
 
subroutine get_value_from_key_1d (file_id, block_id, key_name, key_value, is_optional)
 Used' to dermine the 1D value of a key from a keyname. More...
 
integer function, public open_and_parse_file (filename)
 Opens and parses a yaml file. More...
 

Detailed Description

Routines to use for parsing yaml files.


Data Type Documentation

◆ yaml_parser_mod::get_value_from_key

interface yaml_parser_mod::get_value_from_key

Dermine the value of a key from a keyname.

Definition at line 57 of file yaml_parser.F90.

Private Member Functions

subroutine get_value_from_key_0d (file_id, block_id, key_name, key_value, is_optional)
 Used to dermine the value of a key from a keyname. More...
 
subroutine get_value_from_key_1d (file_id, block_id, key_name, key_value, is_optional)
 Used' to dermine the 1D value of a key from a keyname. More...
 

Member Function/Subroutine Documentation

◆ get_value_from_key_0d()

subroutine get_value_from_key_0d ( integer, intent(in)  file_id,
integer, intent(in)  block_id,
character(len=*), intent(in)  key_name,
class(*), intent(inout)  key_value,
logical, intent(in), optional  is_optional 
)
private

Used to dermine the value of a key from a keyname.

Parameters
[in]file_idFile id of the yaml file to search
[in]block_idID corresponding to the block you want the key for
[in]key_nameName of the key you want the value for
[in,out]key_valueValue of the key
[in]is_optionalFlag indicating if it is okay for the key to not exist. If the key does not exist key_value will not be set, so it is the user's responsibility to initialize it before the call

Definition at line 313 of file yaml_parser.F90.

◆ get_value_from_key_1d()

subroutine get_value_from_key_1d ( integer, intent(in)  file_id,
integer, intent(in)  block_id,
character(len=*), intent(in)  key_name,
class(*), dimension(:), intent(inout)  key_value,
logical, intent(in), optional  is_optional 
)
private

Used' to dermine the 1D value of a key from a keyname.

Parameters
[in]file_idFile id of the yaml file to search
[in]block_idID corresponding to the block you want the key for
[in]key_nameName of the key you want the value for
[in,out]key_valueValue of the key
[in]is_optionalFlag indicating if it is okay for the key' to not exist. If the key does not exist key_value will not be set, so it is the user's responsibility to initialize it before the call

Definition at line 379 of file yaml_parser.F90.

◆ yaml_parser_mod::open_and_parse_file_wrap

interface yaml_parser_mod::open_and_parse_file_wrap

c functions binding

Private c function that opens and parses a yaml file (see yaml_parser_binding.c)

Returns
Flag indicating if the read was successful

Definition at line 74 of file yaml_parser.F90.

Private Member Functions

logical(kind=c_int) function open_and_parse_file_wrap (filename, file_id)
 

Constructor & Destructor Documentation

◆ open_and_parse_file_wrap()

logical(kind=c_int) function open_and_parse_file_wrap ( character(kind=c_char), dimension(*), intent(in)  filename,
integer(kind=c_int), intent(out)  file_id 
)
private
Parameters
[in]filenameFilename of the yaml file
[out]file_idFile id corresponding to the yaml file that was opened
Returns
Flag indicating the error message (1 if sucessful)

Definition at line 74 of file yaml_parser.F90.

Function/Subroutine Documentation

◆ get_block_ids()

subroutine, public yaml_parser_mod::get_block_ids ( integer, intent(in)  file_id,
character(len=*), intent(in)  block_name,
integer, dimension(:), intent(inout)  block_ids,
integer, intent(in), optional  parent_block_id 
)

Gets the the ids of the blocks with block_name in the yaml file If parent_block_id is present, it only gets those that belong to that block.

Parameters
[in]file_idFile id of the yaml file to search
[in]block_nameThe name of the block you are looking for
[in,out]block_idsId of blocks with block_name
[in]parent_block_idId of the parent_block

Definition at line 460 of file yaml_parser.F90.

◆ get_block_name()

subroutine, public yaml_parser_mod::get_block_name ( integer, intent(in)  file_id,
integer, intent(in)  block_id,
character(len=*), intent(out)  block_name 
)

Gets the block name form the block id.

Parameters
[in]file_idFile id corresponding to the yaml file that was opened
[in]block_idId of the block to get the name from
[out]block_nameName of the block

Definition at line 562 of file yaml_parser.F90.

◆ get_key_ids()

subroutine, public yaml_parser_mod::get_key_ids ( integer, intent(in)  file_id,
integer, intent(in)  block_id,
integer, dimension(:), intent(inout)  key_ids 
)

Gets the ids of the key-value pairs in a block.

Parameters
[in]file_idFile id corresponding to the yaml file that was opened
[in]block_idId of the parent_block
[in,out]key_idsIds of the key-value pairs

Definition at line 502 of file yaml_parser.F90.

◆ get_key_name()

subroutine, public yaml_parser_mod::get_key_name ( integer, intent(in)  file_id,
integer, intent(in)  key_id,
character(len=*), intent(out)  key_name 
)

Gets the key from a file id.

Parameters
[in]key_idId of the key-value pair of interest
[in]file_idFile id of the yaml file to search

Definition at line 283 of file yaml_parser.F90.

◆ get_key_value()

subroutine, public yaml_parser_mod::get_key_value ( integer, intent(in)  file_id,
integer, intent(in)  key_id,
character(len=*), intent(out)  key_value 
)

Gets the value from a file id.

Parameters
[in]key_idId of the key-value pair of interest
[in]file_idFile id of the yaml file to search

Definition at line 298 of file yaml_parser.F90.

◆ get_nkeys()

integer function, public yaml_parser_mod::get_nkeys ( integer, intent(in)  file_id,
integer, intent(in)  block_id 
)

Gets the number of key-value pairs in a block.

Returns
Number of key-value pairs in this block
Parameters
[in]file_idFile id corresponding to the yaml file that was opened
[in]block_idId of the parent_block

Definition at line 487 of file yaml_parser.F90.

◆ get_num_blocks()

integer function, public yaml_parser_mod::get_num_blocks ( integer, intent(in)  file_id,
character(len=*), intent(in)  block_name,
integer, intent(in), optional  parent_block_id 
)

Determines the number of blocks with block_name in the yaml file If parent_block_id is present, it only counts those that belong to that block.

Returns
Number of blocks with block_name
Parameters
[in]file_idFile id of the yaml file to search
[in]block_nameThe name of the block you are looking for
[in]parent_block_idId of the parent block

Definition at line 438 of file yaml_parser.F90.

◆ get_num_unique_blocks()

integer function, public yaml_parser_mod::get_num_unique_blocks ( integer, intent(in)  file_id,
integer, intent(in), optional  parent_block_id 
)

Gets the number of unique blocks.

Returns
The number of unique blocks
Parameters
[in]file_idFile id corresponding to the yaml file that was opened
[in]parent_block_idId of the parent_block

Definition at line 525 of file yaml_parser.F90.

◆ get_unique_block_ids()

subroutine, public yaml_parser_mod::get_unique_block_ids ( integer, intent(in)  file_id,
integer, dimension(:), intent(inout)  block_ids,
integer, intent(in), optional  parent_block_id 
)

Gets the ids of the unique block ids.

Parameters
[in]file_idFile id corresponding to the yaml file that was opened
[in,out]block_idsIds of each unique block
[in]parent_block_idId of the parent_block

Definition at line 544 of file yaml_parser.F90.

◆ get_value_from_key_0d()

subroutine yaml_parser_mod::get_value_from_key_0d ( integer, intent(in)  file_id,
integer, intent(in)  block_id,
character(len=*), intent(in)  key_name,
class(*), intent(inout)  key_value,
logical, intent(in), optional  is_optional 
)
private

Used to dermine the value of a key from a keyname.

Parameters
[in]file_idFile id of the yaml file to search
[in]block_idID corresponding to the block you want the key for
[in]key_nameName of the key you want the value for
[in,out]key_valueValue of the key
[in]is_optionalFlag indicating if it is okay for the key to not exist. If the key does not exist key_value will not be set, so it is the user's responsibility to initialize it before the call

Definition at line 313 of file yaml_parser.F90.

◆ get_value_from_key_1d()

subroutine yaml_parser_mod::get_value_from_key_1d ( integer, intent(in)  file_id,
integer, intent(in)  block_id,
character(len=*), intent(in)  key_name,
class(*), dimension(:), intent(inout)  key_value,
logical, intent(in), optional  is_optional 
)
private

Used' to dermine the 1D value of a key from a keyname.

Parameters
[in]file_idFile id of the yaml file to search
[in]block_idID corresponding to the block you want the key for
[in]key_nameName of the key you want the value for
[in,out]key_valueValue of the key
[in]is_optionalFlag indicating if it is okay for the key' to not exist. If the key does not exist key_value will not be set, so it is the user's responsibility to initialize it before the call

Definition at line 379 of file yaml_parser.F90.

◆ open_and_parse_file()

integer function, public yaml_parser_mod::open_and_parse_file ( character(len=*), intent(in)  filename)

Opens and parses a yaml file.

Returns
A file id corresponding to the file that was opened
Parameters
[in]filenameFilename of the yaml file

Definition at line 245 of file yaml_parser.F90.