Automatic definition of the input dictionary the f_input_file module

In a Fortran program it is often useful to have a high-level handling of the input variables. The Fortran specification provides the namelist approach, which is relatively easy to use. However such an approach presents few drawbacks of portability and code-intrusivity, which limit its usage in a multi-language context. With this module we provide a set of rules to automatically parse, inspect, verify and convert a input file from the yaml format into a futile dictionary. With the usage of the f_input_file module developers might easily write _specifications_ for their program input file.

Such module is in tight connection with its python counterpart, futile.Inputvars, which employs the same conventions and make possible a full interplay between a yaml input file and a python dictionary.

Quick access

Routines:warn_illegal(), list_scalar(), input_file_errors(), abort_excl(), input_value_is_default(), input_keys_get_profile(), input_file_dump(), input_keys_control(), input_keys_fill(), input_file_complete(), input_file_minimal(), input_keys_set(), input_variable_dump()

Needed modules

  • dictionaries
  • yaml_strings (f_strcpy(), operator(.eqv.)())
  • f_utils (f_zero())

Subroutines and functions

subroutine f_input_file/abort_excl()
Use :dictionaries, yaml_output
Call to:f_err_severe()
subroutine f_input_file/warn_illegal()
subroutine f_input_file/input_file_errors()
Use :dictionaries (f_err_define())
Call to:f_err_define()
subroutine f_input_file/input_file_complete(inputdef, dict[, imports[, nocheck[, verbose]]])
Parameters:
Options:
  • imports [dictionary,optional/pointer]
  • nocheck [dictionary,optional/pointer]
  • verbose [logical,in,optional]
Use :

dynamic_memory, yaml_output

Call to:

dict_len(), dict_iter(), dict_update(), dict_value(), dict_next(), dict_size(), dict_copy(), dict_free(), dict_key(), input_keys_fill()

subroutine f_input_file/input_keys_set(inputdef, userdef, dict, file, key)
Parameters:
  • inputdef [dictionary,pointer]
  • userdef [logical,out]
  • dict [dictionary,pointer] :: (has_key(dict, key))
  • file [character,in]
  • key [character,in] :: this retrieve the value of the driver key
Use :

yaml_output, dictionaries, dynamic_memory

Called from:

input_keys_fill()

Call to:

has_key(), dict_copy(), dict_value(), dict_key(), dict_len(), dict_size(), dict_keys()

subroutine f_input_file/input_keys_fill(inputdef, dict, file, check, verbose)
Parameters:
  • inputdef [dictionary,pointer]
  • dict [dictionary,pointer]
  • file [character,in]
  • check [logical,in]
  • verbose [logical,in]
Use :

dynamic_memory, yaml_output

Called from:

input_file_complete()

Call to:

input_keys_control(), dict_iter(), dict_key(), input_keys_set(), dict_free(), dict_next()

subroutine f_input_file/input_keys_control(inputdef, dict, file)
Parameters:
Use :

yaml_output (yaml_warning(), yaml_map()), dictionaries, yaml_strings (yaml_toa())

Called from:

input_keys_fill()

Call to:

dict_iter(), dict_key(), dict_init(), dict_next(), dict_free()

function f_input_file/input_keys_get_profile(dict, key, user_defined)
Parameters:
  • dict [dictionary,pointer]
  • key [character,in]
  • user_defined [logical,out]
Return:

input_keys_get_profile [character]

Use :

dictionaries

Called from:

input_value_is_default()

function f_input_file/input_value_is_default(dict, key)
Parameters:
Return:

yes [logical]

Call to:

input_keys_get_profile()

subroutine f_input_file/input_variable_dump(dict, useronly)
Parameters:
Use :

dictionaries, yaml_output, f_utils (f_zero())

Called from:

input_file_dump()

subroutine f_input_file/input_file_minimal(inputdef, dict, minimal, nested, as_is)
Parameters:
  • inputdef [dictionary,pointer] :: < Dictionary of the input definitions
  • dict [dictionary,in,pointer] :: < User input file
  • minimal [dictionary,out,pointer] :: < List of keys in dict that remain which require special treatments
  • nested [dictionary,in,pointer] :: < Add other keys (extracted by subcategories of nested elements)
  • as_is [dictionary,in,pointer] :: < Add keys in as_is and not in inputdef
Use :

dynamic_memory, dictionaries, yaml_output

Call to:

dict_iter(), dict_key(), has_key(), dict_init(), dict_next(), dict_value(), dict_copy(), list_scalar()

subroutine f_input_file/list_scalar(list, scalar)
Parameters:
  • list [dictionary,pointer]
  • scalar [character,out] :: <empty if failed
Called from:

input_file_minimal()

Call to:

dict_len(), dict_iter(), dict_size(), dict_next()

subroutine f_input_file/input_file_dump(dict[, useronly[, nodump_list[, msg]]])
Parameters:

dict [dictionary,pointer] :: < Dictionary to dump

Options:
  • useronly [logical,in,optional]
  • nodump_list [dictionary,optional/pointer] :: <list containing keys not to dump
  • msg [character,in,optional]
Use :

yaml_output

Call to:

dict_key(), input_variable_dump()