TUV-x
Loading...
Searching...
No Matches
Data Types | Functions/Subroutines
musica_config Module Reference

The config_t type and related functions. More...

Data Types

type  config_iterator_t
 Configuration data iterator. More...
 
type  config_t
 Model configuration data. More...
 

Functions/Subroutines

subroutine empty (this)
 Empties the configuration. More...
 
subroutine construct_from_file (this, file_name)
 Constructs a configuration from a file. More...
 
subroutine to_file (this, file_name)
 Writes a configuration to a file. More...
 
integer(kind=musica_ik) function number_of_children (this)
 Returns the number of child objects. More...
 
class(iterator_t) function, pointer get_iterator (this)
 Gets an interator for the configuration data. More...
 
type(string_t) function key (this, iterator)
 Gets the key name using an iterator. More...
 
subroutine get_config (this, key, value, caller, default, found)
 Gets a subset of the configuration data. More...
 
subroutine get_string_string_default (this, key, value, caller, default, found)
 Gets a string from the configuration data. More...
 
subroutine get_string (this, key, value, caller, default, found)
 Gets a string from the configuration data. More...
 
subroutine get_int (this, key, value, caller, default, found)
 Gets an integer from the configuration data. More...
 
subroutine get_float (this, key, value, caller, default, found)
 Gets a single-precision real number from the configuration data. More...
 
subroutine get_double (this, key, value, caller, default, found)
 Gets a double-precision real number from the configuration data. More...
 
subroutine get_logical (this, key, value, caller, default, found)
 Gets a boolean value from the configuration data. More...
 
subroutine get_string_array (this, key, value, caller, default, found)
 Gets an array of strings from the configuration data. More...
 
subroutine get_double_array (this, key, value, caller, default, found)
 Gets an array of doubles from the configuration data. More...
 
subroutine get_config_array (this, key, value, caller, default, found)
 Gets an array of config_t objects. More...
 
subroutine get_from_iterator (this, iterator, value, caller)
 Gets a value using an iterator. More...
 
subroutine get_array_from_iterator (this, iterator, value, caller)
 Gets an array value using an iterator. More...
 
subroutine add_config (this, key, value, caller)
 Adds a subset of configuration data. More...
 
subroutine add_char_array (this, key, value, caller)
 Adds a string to the configuration data. More...
 
subroutine add_string (this, key, value, caller)
 Adds a string to the configuration data. More...
 
subroutine add_int (this, key, value, caller)
 Adds an integer to the configuration data. More...
 
subroutine add_float (this, key, value, caller)
 Adds a single-precision real number to the configuration data. More...
 
subroutine add_double (this, key, value, caller)
 Adds a double-precision real number to the configuration data. More...
 
subroutine add_logical (this, key, value, caller)
 Adds a boolean to the configuration data. More...
 
subroutine add_string_array (this, key, value, caller)
 Adds a string array to the configuration data. More...
 
subroutine add_double_array (this, key, value, caller)
 Adds a double array to the configuration data. More...
 
subroutine add_config_array (this, key, value, caller)
 Adds a config_t array to the configuration data. More...
 
subroutine config_assign_config (a, b)
 Assigns a config_t from a config_t. More...
 
subroutine config_assign_string (config, string)
 Assigns a config_t from a string. More...
 
subroutine config_assign_char (config, string)
 Assigns a config_t from a character array. More...
 
subroutine string_assign_config (string, config)
 Assigns a string from a configuration. More...
 
subroutine finalize (this)
 Cleans up memory. More...
 
subroutine finalize_1d_array (this)
 Cleans up memory. More...
 
subroutine find_by_prefix (this, prefix, full_key, found)
 Finds a full key name by a prefix. More...
 
recursive subroutine merge_in (this, other, caller)
 Merges another config_t object into the config_t object. More...
 
logical function find_key_in_list (key_to_find, list)
 Returns true if the given key is in the given list of keys.
 
logical function validate (this, required_keys, optional_keys)
 Validates the format of the configuration data. More...
 
subroutine do_print (this)
 Print out the raw contents of the configuration. More...
 
integer function pack_size (this, comm)
 Returns the size of a binary buffer required to pack the object.
 
subroutine mpi_pack (this, buffer, position, comm)
 Packs the configuration onto a character buffer. More...
 
subroutine mpi_unpack (this, buffer, position, comm)
 Unpacks the configuration from a character buffer. More...
 
logical function iterator_next (this)
 Advances the iterator. More...
 
subroutine iterator_reset (this, parent)
 Resets the iterator. More...
 
subroutine iterator_finalize (this)
 Cleans up memory assoicated with an iterator. More...
 
subroutine initialize_config_t (config, string)
 Initialize a config_t object. More...
 
character(len=1, kind=c_char) function, dimension(:), allocatable to_c_string (f_string)
 Convert a fortran character array to a c string. More...
 
character(len=:) function, allocatable to_f_string (c_string)
 Convert a c string to a fortran character array. More...
 

Detailed Description

The config_t type and related functions.

Function/Subroutine Documentation

◆ add_char_array()

subroutine musica_config::add_char_array ( 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_config()

subroutine musica_config::add_config ( 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_config_array()

subroutine musica_config::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()

subroutine musica_config::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()

subroutine musica_config::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 
)

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()

subroutine musica_config::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()

subroutine musica_config::add_int ( 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_logical()

subroutine musica_config::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()

subroutine musica_config::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()

subroutine musica_config::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)

◆ config_assign_char()

subroutine musica_config::config_assign_char ( 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

◆ config_assign_config()

subroutine musica_config::config_assign_config ( 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

◆ config_assign_string()

subroutine musica_config::config_assign_string ( 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

◆ construct_from_file()

subroutine musica_config::construct_from_file ( class(config_t), intent(out)  this,
character(len=*), intent(in)  file_name 
)
private

Constructs a configuration from a file.

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

◆ do_print()

subroutine musica_config::do_print ( class(config_t), intent(inout)  this)

Print out the raw contents of the configuration.

Parameters
[in,out]thisConfiguration

◆ empty()

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

Empties the configuration.

Parameters
[out]thisConfiguration

◆ finalize()

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

Cleans up memory.

Parameters
[in,out]thisConfiguration

◆ finalize_1d_array()

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

Cleans up memory.

Parameters
[in,out]thisConfiguration

◆ find_by_prefix()

subroutine musica_config::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

Finds a full key name by a 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

◆ get_array_from_iterator()

subroutine musica_config::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 
)

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()

subroutine musica_config::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 
)

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()

subroutine musica_config::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 
)

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()

subroutine musica_config::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 
)

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()

subroutine musica_config::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 
)

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()

subroutine musica_config::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 
)

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()

subroutine musica_config::get_from_iterator ( 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_int()

subroutine musica_config::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 
)

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()

class(iterator_t) function, pointer musica_config::get_iterator ( class(config_t), intent(in), target  this)

Gets an interator for the configuration data.

Returns
Pointer to the iterator
Parameters
[in]thisConfiguration

◆ get_logical()

subroutine musica_config::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 
)

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()

subroutine musica_config::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 
)

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()

subroutine musica_config::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 
)

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()

subroutine musica_config::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 
)

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

◆ initialize_config_t()

subroutine musica_config::initialize_config_t ( class(config_t), intent(inout)  config,
character(len=*), intent(in), optional  string 
)
private

Initialize a config_t object.

Parameters
[in,out]configConfiguration
[in]stringYAML string

◆ iterator_finalize()

subroutine musica_config::iterator_finalize ( type(config_iterator_t), intent(inout)  this)

Cleans up memory assoicated with an iterator.

Parameters
[in,out]thisIterator

◆ iterator_next()

logical function musica_config::iterator_next ( class(config_iterator_t), intent(inout)  this)

Advances the iterator.

Returns false if the end of the collection has been reached

Parameters
[in,out]thisIterator

◆ iterator_reset()

subroutine musica_config::iterator_reset ( class(config_iterator_t), intent(inout)  this,
class(iterator_t), intent(in), optional  parent 
)

Resets the iterator.

Parameters
[in,out]thisIterator
[in]parentIterator for parent model element

◆ key()

type(string_t) function musica_config::key ( class(config_t), intent(inout)  this,
class(iterator_t), intent(in)  iterator 
)

Gets the key name using an iterator.

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

◆ merge_in()

recursive subroutine musica_config::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()

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

Packs the configuration onto a character buffer.

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

◆ mpi_unpack()

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

Unpacks the configuration from a character buffer.

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

◆ number_of_children()

integer(kind=musica_ik) function musica_config::number_of_children ( class(config_t), intent(inout)  this)
private

Returns the number of child objects.

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

◆ string_assign_config()

subroutine musica_config::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_c_string()

character(len=1, kind=c_char) function, dimension(:), allocatable musica_config::to_c_string ( character(len=*), intent(in)  f_string)

Convert a fortran character array to a c string.

Returns
String as const char*
Parameters
[in]f_stringFortran string to convert

◆ to_f_string()

character(len=:) function, allocatable musica_config::to_f_string ( type(string_t_c), intent(in)  c_string)
private

Convert a c string to a fortran character array.

Returns
Converted string for fortran
Parameters
[in]c_stringC pointer to const char*

◆ to_file()

subroutine musica_config::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()

logical function musica_config::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 data.

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