TUV-x
Loading...
Searching...
No Matches
musica_config::config_t Type Reference

Model configuration data. More...

Public Member Functions

procedure empty (this)
 Empties the configuration.
 
procedure from_file (this, file_name)
 Loads a configuration with data from a file.
 
procedure to_file (this, file_name)
 Writes a configuration to a file.
 
procedure number_of_children (this)
 Returns the number of child objects.
 
procedure get_iterator (this)
 Gets an iterator for the configuration data.
 
procedure key (this, iterator)
 Gets the key name for a key-value pair.
 
procedure merge_in (this, other, caller)
 Merges another config_t object into the config_t object.
 
procedure validate (this, required_keys, optional_keys)
 Validates the format of the configuration file.
 
procedure print (this)
 Print the raw contents of the configuration.
 
procedure pack_size (this, comm)
 Returns the number of bytes required to pack the object onto a buffer.
 
procedure mpi_pack (this, buffer, position, comm)
 Packs the object onto a character buffer.
 
procedure mpi_unpack (this, buffer, position, comm)
 Unpacks an object from a character buffer.
 
final finalize (this)
 Cleans up memory.
 
 finalize_1d_array (this)
 Cleans up memory.
 

Private Member Functions

procedure, private find_by_prefix (this, prefix, full_key, found)
 Find a JSON key by prefix.
 

Private Attributes

type(c_ptr) node_ = c_null_ptr
 Pointer to YAML node.
 

Gets some configuration data

Each function includes optional found and default arguments. If neither is included and the data are not found, execution is stopped with an error message.

If a default value is included and the data are not found, the returned argument is set to this default value, otherwise it is set to a standard default value.

If the found argument is included and the data are found, found is set to true, otherwise it is set to false.

generic get (this, key, value, caller, default, found)
 Gets a subset of the configuration data.
 
generic get (this, key, value, caller, default, found)
 Gets a string from the configuration data.
 
generic get (this, key, value, caller, default, found)
 Gets a string from the configuration data.
 
generic get (this, key, value, caller, default, found)
 Gets an integer from the configuration data.
 
generic get (this, key, value, caller, default, found)
 Gets a single-precision real number from the configuration data.
 
generic get (this, key, value, caller, default, found)
 Gets a double-precision real number from the configuration data.
 
generic get (this, key, value, caller, default, found)
 Gets a boolean value from the configuration data.
 
generic get (this, key, value, caller, default, found)
 Gets an array of strings from the configuration data.
 
generic get (this, key, value, caller, default, found)
 Gets an array of doubles from the configuration data.
 
generic get (this, key, value, caller, default, found)
 Gets an array of config_t objects.
 
generic get (this, iterator, value, caller)
 Gets a value using an iterator.
 
generic get (this, iterator, value, caller)
 Gets an array value using an iterator.
 
procedure, private get_config (this, key, value, caller, default, found)
 Gets a subset of the configuration data.
 
procedure, private get_string_string_default (this, key, value, caller, default, found)
 Gets a string from the configuration data.
 
procedure, private get_string (this, key, value, caller, default, found)
 Gets a string from the configuration data.
 
procedure, private get_int (this, key, value, caller, default, found)
 Gets an integer from the configuration data.
 
procedure, private get_float (this, key, value, caller, default, found)
 Gets a single-precision real number from the configuration data.
 
procedure, private get_double (this, key, value, caller, default, found)
 Gets a double-precision real number from the configuration data.
 
procedure, private get_logical (this, key, value, caller, default, found)
 Gets a boolean value from the configuration data.
 
procedure, private get_string_array (this, key, value, caller, default, found)
 Gets an array of strings from the configuration data.
 
procedure, private get_double_array (this, key, value, caller, default, found)
 Gets an array of doubles from the configuration data.
 
procedure, private get_config_array (this, key, value, caller, default, found)
 Gets an array of config_t objects.
 
procedure, private get_from_iterator (this, iterator, value, caller)
 Gets a value using an iterator.
 
procedure, private get_array_from_iterator (this, iterator, value, caller)
 Gets an array value using an iterator.
 

Adds a named piece of configuration data

generic add (this, key, value, caller)
 Adds a subset of configuration data.
 
generic add (this, key, value, caller)
 Adds a string to the configuration data.
 
generic add (this, key, value, caller)
 Adds a string to the configuration data.
 
generic add (this, key, value, caller)
 Adds an integer to the configuration data.
 
generic add (this, key, value, caller)
 Adds a single-precision real number to the configuration data.
 
generic add (this, key, value, caller)
 Adds a double-precision real number to the configuration data.
 
generic add (this, key, value, caller)
 Adds a boolean to the configuration data.
 
generic add (this, key, value, caller)
 Adds a string array to the configuration data.
 
generic add (this, key, value, caller)
 Adds a double array to the configuration data.
 
generic add (this, key, value, caller)
 Adds a config_t array to the configuration data.
 
procedure, private add_config (this, key, value, caller)
 Adds a subset of configuration data.
 
procedure, private add_char_array (this, key, value, caller)
 Adds a string to the configuration data.
 
procedure, private add_string (this, key, value, caller)
 Adds a string to the configuration data.
 
procedure, private add_int (this, key, value, caller)
 Adds an integer to the configuration data.
 
procedure, private add_float (this, key, value, caller)
 Adds a single-precision real number to the configuration data.
 
procedure, private add_double (this, key, value, caller)
 Adds a double-precision real number to the configuration data.
 
procedure, private add_logical (this, key, value, caller)
 Adds a boolean to the configuration data.
 
procedure, private add_string_array (this, key, value, caller)
 Adds a string array to the configuration data.
 
procedure, private add_double_array (this, key, value, caller)
 Adds a double array to the configuration data.
 
procedure, private add_config_array (this, key, value, caller)
 Adds a config_t array to the configuration data.
 

Assignment

generic assignment (a, b)
 Assigns a config_t from a config_t.
 
generic assignment (config, string)
 Assigns a config_t from a string.
 
generic assignment (config, string)
 Assigns a config_t from a character array.
 
generic assignment (string, config)
 Assigns a string from a configuration.
 
procedure, private config_assign_config (a, b)
 Assigns a config_t from a config_t.
 
procedure, private config_assign_string (config, string)
 Assigns a config_t from a string.
 
procedure, private config_assign_char (config, string)
 Assigns a config_t from a character array.
 
procedure, pass(config), private string_assign_config (string, config)
 Assigns a string from a configuration.
 

Detailed Description

Model configuration data.

Instances of type config_t can be used to access model configuration data in json format. If there is a need to use model configuration in another format (e.g., XML) in the future, an abstract config_t type could be set up, that this type and an XML-based type could extend. The rest of the model code would be unaffected.

It is assumed that most configuration datasets will be small enough that returned subsets of configuration data can just be a copy of the original data (instead of using a pointer to the start of the subset in the original dataset, or something like this). This avoids ownership problems with cleaning up the memory after a config_t object goes out of scope.

Only use config_t objects during initialization. They are not designed for efficiency.

IMPORTANT: The order of elements is arbitrary. No user of a config_t object can assume anything by the order of key-value pairs in the data. This dataset:

foo: 1
bar: 2
foobar: 3

... is the same as:

bar: 2
foobar: 3
foo: 1

There is no guarantee that an iterator over the elements of a config_t object will return them in the same order they exist in the original file or string.

Example of a config_t object generated from a file:

use musica_constants, only : musica_dk, musica_ik
character(len=*), parameter :: my_name =
type(config_t) :: main_config, sub_config, sub_real_config
real(musica_dk) :: my_real
integer(musica_ik) :: my_int
type(string_t) :: my_string
class(iterator_t), pointer :: iter
logical :: found
call main_config%from_file( 'data/config_example.yaml' )
! this would fail with an error if 'a string' is not found
call main_config%get( , my_string, my_name )
write(*,*) , my_string
! add the found argument to avoid failure if the pair is not found
call main_config%get( , my_int, my_name, found = found )
if( found ) then
write(*,*) , my_int
else
write(*,*)
end if
! when you get a subset of the properties, a new config_t object is
! created containing the subset data. The two config_t objects are
! independent of one another after this point.
call main_config%get( , sub_config, my_name )
call sub_config%get( , my_int, my_name )
write(*,*) , my_int
! you can iterate over a set of key-value pairs. but remember that
! the order is always arbitrary. you also must provide the right type
! of variable for the values.
call main_config%get( , sub_real_config, my_name )
iter => sub_real_config%get_iterator( )
do while( iter%next( ) )
my_string = sub_real_config%key( iter )
call sub_real_config%get( iter, my_real, my_name )
write(*,*) my_string, , my_real
end do
! you can also get the number of child objects before iterating over
! them, if you want to allocate an array or something first
write(*,*) , sub_real_config%number_of_children( )
! you can add key-value pairs with the add function
call main_config%add( , 43, my_name )
call main_config%get( , my_int, my_name )
write(*,*) , my_int
! clean up memory
deallocate( iter )
The config_t type and related functions.
Definition config.F90:8
Common physical constants.
Definition constants.F90:8
integer, parameter musica_dk
Kind of a double-precision real number.
Definition constants.F90:20
The abstract iterator_t type and related functions.
Definition iterator.F90:8
The string_t type and related functions.
Definition string.F90:8
Model configuration data.
Definition config.F90:144
An abstract iterator.
Definition iterator.F90:40
Generic string type.
Definition string.F90:21

data/config_example.json:

my int: 12
other props:
some time [min]: 12
a pressure [bar]: 103.4
an int: 45
real props:
foo: 14.2
bar: 64.2
foobar: 920.4
a string: foo

Output:

a string value: foo
my int value: 12
other props->an int value: 45
other props->some time value: 720.00000000000000 s
other props->a pressure value: 10340000.000000000 Pa
foo value: 14.199999999999999
bar value: 64.200000000000003
foobar value: 920.39999999999998
number of children: 3
my new int value: 43

Constructor & Destructor Documentation

◆ finalize()

final musica_config::config_t::finalize ( type(config_t), intent(inout) this)
final

Cleans up memory.

Parameters
[in,out]thisConfiguration

Member Function/Subroutine Documentation

◆ add() [1/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(config_t), intent(in) value,
character(len=*), intent(in) caller )

Adds a subset of configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add() [2/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
character(len=*), intent(in) value,
character(len=*), intent(in) caller )

Adds a string to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add() [3/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(string_t), intent(in) value,
character(len=*), intent(in) caller )

Adds a string to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add() [4/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
integer, intent(in) value,
character(len=*), intent(in) caller )

Adds an integer to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add() [5/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_rk), intent(in) value,
character(len=*), intent(in) caller )

Adds a single-precision real number to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add() [6/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_dk), intent(in) value,
character(len=*), intent(in) caller )

Adds a double-precision real number to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add() [7/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
logical, intent(in) value,
character(len=*), intent(in) caller )

Adds a boolean to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add() [8/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(string_t), dimension(:), intent(in) value,
character(len=*), intent(in) caller )

Adds a string array to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add() [9/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_dk), dimension(:), intent(in) value,
character(len=*), intent(in) caller )

Adds a double array to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey to insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add() [10/10]

generic musica_config::config_t::add ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(config_t), dimension(:), intent(in) value,
character(len=*), intent(in) caller )

Adds a config_t array to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_char_array()

procedure, private musica_config::config_t::add_char_array ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
character(len=*), intent(in) value,
character(len=*), intent(in) caller )
private

Adds a string to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_config()

procedure, private musica_config::config_t::add_config ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(config_t), intent(in) value,
character(len=*), intent(in) caller )
private

Adds a subset of configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_config_array()

procedure, private musica_config::config_t::add_config_array ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(config_t), dimension(:), intent(in) value,
character(len=*), intent(in) caller )
private

Adds a config_t array to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_double()

procedure, private musica_config::config_t::add_double ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_dk), intent(in) value,
character(len=*), intent(in) caller )
private

Adds a double-precision real number to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_double_array()

procedure, private musica_config::config_t::add_double_array ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_dk), dimension(:), intent(in) value,
character(len=*), intent(in) caller )
private

Adds a double array to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey to insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_float()

procedure, private musica_config::config_t::add_float ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_rk), intent(in) value,
character(len=*), intent(in) caller )
private

Adds a single-precision real number to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_int()

procedure, private musica_config::config_t::add_int ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
integer, intent(in) value,
character(len=*), intent(in) caller )
private

Adds an integer to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_logical()

procedure, private musica_config::config_t::add_logical ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
logical, intent(in) value,
character(len=*), intent(in) caller )
private

Adds a boolean to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_string()

procedure, private musica_config::config_t::add_string ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(string_t), intent(in) value,
character(len=*), intent(in) caller )
private

Adds a string to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ add_string_array()

procedure, private musica_config::config_t::add_string_array ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(string_t), dimension(:), intent(in) value,
character(len=*), intent(in) caller )
private

Adds a string array to the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey in insert
[in]valueValue to set
[in]callerName of the calling function (only for use in error messages)

◆ assignment() [1/4]

generic musica_config::config_t::assignment ( class(config_t), intent(out) a,
class(config_t), intent(in) b )

Assigns a config_t from a config_t.

Parameters
[out]aConfiguration to assign to
[in]bConfiguration to assign from

◆ assignment() [2/4]

generic musica_config::config_t::assignment ( class(config_t), intent(out) config,
class(string_t), intent(in) string )

Assigns a config_t from a string.

Parameters
[out]configConfiguration to assign to
[in]stringString to assign from

◆ assignment() [3/4]

generic musica_config::config_t::assignment ( class(config_t), intent(out) config,
character(len=*), intent(in) string )

Assigns a config_t from a character array.

Parameters
[out]configConfiguration to assign to
[in]stringString to assign from

◆ assignment() [4/4]

generic musica_config::config_t::assignment ( type(string_t), intent(out) string,
class(config_t), intent(in) config )

Assigns a string from a configuration.

Parameters
[out]stringString to assign to
[in]configConfiguration to assign from

◆ config_assign_char()

procedure, private musica_config::config_t::config_assign_char ( class(config_t), intent(out) config,
character(len=*), intent(in) string )
private

Assigns a config_t from a character array.

Parameters
[out]configConfiguration to assign to
[in]stringString to assign from

◆ config_assign_config()

procedure, private musica_config::config_t::config_assign_config ( class(config_t), intent(out) a,
class(config_t), intent(in) b )
private

Assigns a config_t from a config_t.

Parameters
[out]aConfiguration to assign to
[in]bConfiguration to assign from

◆ config_assign_string()

procedure, private musica_config::config_t::config_assign_string ( class(config_t), intent(out) config,
class(string_t), intent(in) string )
private

Assigns a config_t from a string.

Parameters
[out]configConfiguration to assign to
[in]stringString to assign from

◆ empty()

procedure musica_config::config_t::empty ( class(config_t), intent(out) this)

Empties the configuration.

Parameters
[out]thisConfiguration

◆ finalize_1d_array()

musica_config::config_t::finalize_1d_array ( type(config_t), dimension(:), intent(inout) this)

Cleans up memory.

Parameters
[in,out]thisConfiguration

◆ find_by_prefix()

procedure, private musica_config::config_t::find_by_prefix ( class(config_t), intent(inout) this,
character(len=*), intent(in) prefix,
type(string_t), intent(out) full_key,
logical, intent(out) found )
private

Find a JSON key by prefix.

Returns the first instance of the prefix if found

Parameters
[in,out]thisConfiguration
[in]prefixPrefix to search for (first instance is returned)
[out]full_keyFull key found
[out]foundFlag indicating whether the key was found

◆ from_file()

procedure musica_config::config_t::from_file ( class(config_t), intent(out) this,
character(len=*), intent(in) file_name )

Loads a configuration with data from a file.

Parameters
[out]thisNew configuration
[in]file_nameFile name containing configuration data

◆ get() [1/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
class(iterator_t), intent(in) iterator,
class(*), intent(out) value,
character(len=*), intent(in) caller )

Gets a value using an iterator.

Parameters
[in,out]thisConfiguration
[in]iteratorIterator to use to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)

◆ get() [2/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
class(iterator_t), intent(in) iterator,
type(string_t), dimension(:), intent(out), allocatable value,
character(len=*), intent(in) caller )

Gets an array value using an iterator.

Parameters
[in,out]thisConfiguration
[in]iteratorIterator to use to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)

◆ get() [3/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
class(config_t), intent(out) value,
character(len=*), intent(in) caller,
class(config_t), intent(in), optional default,
logical, intent(out), optional found )

Gets a subset of the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get() [4/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
class(string_t), intent(out) value,
character(len=*), intent(in) caller,
character(len=*), intent(in), optional default,
logical, intent(out), optional found )

Gets a string from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get() [5/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
class(string_t), intent(out) value,
character(len=*), intent(in) caller,
class(string_t), intent(in) default,
logical, intent(out), optional found )

Gets a string from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get() [6/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
integer(kind=musica_ik), intent(out) value,
character(len=*), intent(in) caller,
integer(kind=musica_ik), intent(in), optional default,
logical, intent(out), optional found )

Gets an integer from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get() [7/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_rk), intent(out) value,
character(len=*), intent(in) caller,
real(kind=musica_rk), intent(in), optional default,
logical, intent(out), optional found )

Gets a single-precision real number from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get() [8/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_dk), intent(out) value,
character(len=*), intent(in) caller,
real(kind=musica_dk), intent(in), optional default,
logical, intent(out), optional found )

Gets a double-precision real number from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get() [9/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
logical, intent(out) value,
character(len=*), intent(in) caller,
logical, intent(in), optional default,
logical, intent(out), optional found )

Gets a boolean value from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get() [10/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(string_t), dimension(:), intent(out), allocatable value,
character(len=*), intent(in) caller,
type(string_t), dimension(:), intent(in), optional default,
logical, intent(out), optional found )

Gets an array of strings from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get() [11/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(musica_dk), dimension(:), intent(out), allocatable value,
character(len=*), intent(in) caller,
real(musica_dk), dimension(:), intent(in), optional default,
logical, intent(out), optional found )

Gets an array of doubles from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get() [12/12]

generic musica_config::config_t::get ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(config_t), dimension(:), intent(out), allocatable value,
character(len=*), intent(in) caller,
type(config_t), dimension(:), intent(in), optional default,
logical, intent(out), optional found )

Gets an array of config_t objects.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_array_from_iterator()

procedure, private musica_config::config_t::get_array_from_iterator ( class(config_t), intent(inout) this,
class(iterator_t), intent(in) iterator,
type(string_t), dimension(:), intent(out), allocatable value,
character(len=*), intent(in) caller )
private

Gets an array value using an iterator.

Parameters
[in,out]thisConfiguration
[in]iteratorIterator to use to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)

◆ get_config()

procedure, private musica_config::config_t::get_config ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
class(config_t), intent(out) value,
character(len=*), intent(in) caller,
class(config_t), intent(in), optional default,
logical, intent(out), optional found )
private

Gets a subset of the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_config_array()

procedure, private musica_config::config_t::get_config_array ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(config_t), dimension(:), intent(out), allocatable value,
character(len=*), intent(in) caller,
type(config_t), dimension(:), intent(in), optional default,
logical, intent(out), optional found )
private

Gets an array of config_t objects.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_double()

procedure, private musica_config::config_t::get_double ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_dk), intent(out) value,
character(len=*), intent(in) caller,
real(kind=musica_dk), intent(in), optional default,
logical, intent(out), optional found )
private

Gets a double-precision real number from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_double_array()

procedure, private musica_config::config_t::get_double_array ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(musica_dk), dimension(:), intent(out), allocatable value,
character(len=*), intent(in) caller,
real(musica_dk), dimension(:), intent(in), optional default,
logical, intent(out), optional found )
private

Gets an array of doubles from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_float()

procedure, private musica_config::config_t::get_float ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
real(kind=musica_rk), intent(out) value,
character(len=*), intent(in) caller,
real(kind=musica_rk), intent(in), optional default,
logical, intent(out), optional found )
private

Gets a single-precision real number from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_from_iterator()

procedure, private musica_config::config_t::get_from_iterator ( class(config_t), intent(inout) this,
class(iterator_t), intent(in) iterator,
class(*), intent(out) value,
character(len=*), intent(in) caller )
private

Gets a value using an iterator.

Parameters
[in,out]thisConfiguration
[in]iteratorIterator to use to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)

◆ get_int()

procedure, private musica_config::config_t::get_int ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
integer(kind=musica_ik), intent(out) value,
character(len=*), intent(in) caller,
integer(kind=musica_ik), intent(in), optional default,
logical, intent(out), optional found )
private

Gets an integer from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_iterator()

procedure musica_config::config_t::get_iterator ( class(config_t), intent(in), target this)

Gets an iterator for the configuration data.

Returns
Pointer to the iterator
Parameters
[in]thisConfiguration

◆ get_logical()

procedure, private musica_config::config_t::get_logical ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
logical, intent(out) value,
character(len=*), intent(in) caller,
logical, intent(in), optional default,
logical, intent(out), optional found )
private

Gets a boolean value from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_string()

procedure, private musica_config::config_t::get_string ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
class(string_t), intent(out) value,
character(len=*), intent(in) caller,
character(len=*), intent(in), optional default,
logical, intent(out), optional found )
private

Gets a string from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_string_array()

procedure, private musica_config::config_t::get_string_array ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
type(string_t), dimension(:), intent(out), allocatable value,
character(len=*), intent(in) caller,
type(string_t), dimension(:), intent(in), optional default,
logical, intent(out), optional found )
private

Gets an array of strings from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ get_string_string_default()

procedure, private musica_config::config_t::get_string_string_default ( class(config_t), intent(inout) this,
character(len=*), intent(in) key,
class(string_t), intent(out) value,
character(len=*), intent(in) caller,
class(string_t), intent(in) default,
logical, intent(out), optional found )
private

Gets a string from the configuration data.

Parameters
[in,out]thisConfiguration
[in]keyKey used to find value
[out]valueReturned value
[in]callerName of the calling function (only for use in error messages)
[in]defaultDefault value if not found
[out]foundFlag indicating whether key was found

◆ key()

procedure musica_config::config_t::key ( class(config_t), intent(inout) this,
class(iterator_t), intent(in) iterator )

Gets the key name for a key-value pair.

Returns
Key name
Parameters
[in,out]thisConfiguration
[in]iteratorConfiguration iterator

◆ merge_in()

procedure musica_config::config_t::merge_in ( class(config_t), intent(inout) this,
class(config_t), intent(inout) other,
character(len=*), intent(in) caller )

Merges another config_t object into the config_t object.

Parameters
[in,out]thisConfiguration
[in,out]otherConfiguration to merge in
[in]callerName of the calling function (only for use in error messages)

◆ mpi_pack()

procedure musica_config::config_t::mpi_pack ( class(config_t), intent(inout) this,
character, dimension(:), intent(inout) buffer,
integer, intent(inout) position,
integer, intent(in), optional comm )

Packs the object onto a character buffer.

Parameters
[in,out]thisConfiguration to pack
[in,out]bufferMemory buffer
[in,out]positionCurrent buffer position
[in]commMPI communicator

◆ mpi_unpack()

procedure musica_config::config_t::mpi_unpack ( class(config_t), intent(out) this,
character, dimension(:), intent(inout) buffer,
integer, intent(inout) position,
integer, intent(in), optional comm )

Unpacks an object from a character buffer.

Parameters
[out]thisConfiguration to unpack
[in,out]bufferMemory buffer
[in,out]positionCurrent buffer position
[in]commMPI communicator

◆ number_of_children()

procedure musica_config::config_t::number_of_children ( class(config_t), intent(inout) this)

Returns the number of child objects.

Returns
Number of child objects
Parameters
[in,out]thisConfiguration

◆ print()

procedure musica_config::config_t::print ( class(config_t), intent(inout) this)

Print the raw contents of the configuration.

Parameters
[in,out]thisConfiguration

◆ string_assign_config()

procedure, pass(config), private musica_config::config_t::string_assign_config ( type(string_t), intent(out) string,
class(config_t), intent(in) config )
private

Assigns a string from a configuration.

Parameters
[out]stringString to assign to
[in]configConfiguration to assign from

◆ to_file()

procedure musica_config::config_t::to_file ( class(config_t), intent(inout) this,
character(len=*), intent(in) file_name )

Writes a configuration to a file.

Parameters
[in,out]thisConfiguration
[in]file_nameFile name to save configuration with

◆ validate()

procedure musica_config::config_t::validate ( class(config_t), intent(inout) this,
type(string_t), dimension(:), intent(in) required_keys,
type(string_t), dimension(:), intent(in) optional_keys )

Validates the format of the configuration file.

Ensures that the required keys are present, and that user-defined keys start with a "`__`" prefix.

Parameters
[in,out]thisConfiguration
[in]required_keysRequired keys
[in]optional_keysOptional keys

The documentation for this type was generated from the following file: