YAML handling

Automatic definition of arguments yaml_parse

This module deals with the parsing of yaml streams and their conversion into FUTILE dictionaries.

Anyone which uses python knows how practical it the usage of the argparse module. This FORTRAN module is an attempt to combine the ideas of the argparse approach with the yaml syntax.

Quick access

Routines:

yaml_argparse(), yaml_cl_errors(), yaml_cl_parse_cmd_line(), yaml_cl_parse_free(), yaml_cl_parse_null(), yaml_cl_parse_option(), yaml_parse_from_file()

Needed modules

  • dictionaries (dictionary, max_field_length()): High-level dictionary API used throughout Futile and BigDFT. A dictionary is a pointer-based tree that can represent scalars, ordered mappings, and lists. It maps directly to YAML data and is manipulated with constructors

  • yaml_parse_base (yaml_load(), yaml_parse_database(), yaml_parse_from_string())

Subroutines and functions

interface  yaml_parse/yaml_cl_parse_option(parser, name, default_bn, help_string[, shortname, help_dict, first_option, conflicts])
Parameters:
  • parser [yaml_cl_parse, inout]

  • name [character(len=*), in]

  • default_bn [character(len=*), in]

  • help_string [character(len=*), in]

Options:
  • shortname [character(len=1), in,]

  • help_dict [dictionary, pointer]

  • first_option [logical, in,]

  • conflicts [character(len=*), in,]

function  yaml_parse/yaml_cl_parse_null()
Return:

parser [yaml_cl_parse]

Called from:

yaml_cl_parse_free(), yaml_argparse()

subroutine  yaml_parse/yaml_cl_parse_free(parser)
Parameters:

parser [yaml_cl_parse, inout]

Use :

dictionaries_base (dict_free())

Called from:

yaml_argparse(), yaml_cl_parse_cmd_line()

Call to:

dict_free(), yaml_cl_parse_null()

subroutine  yaml_parse/yaml_cl_errors()
Use :

dictionaries

Called from:

initialize_flib_errors()

Call to:

f_err_define()

subroutine  yaml_parse/yaml_cl_parse_option(parser, name, default_bn, help_string[, shortname, help_dict, first_option, conflicts])
Parameters:
  • parser [yaml_cl_parse, inout]

  • name [character(len=*), in]

  • default_bn [character(len=*), in]

  • help_string [character(len=*), in]

Options:
  • shortname [character(len=1), in,]

  • help_dict [dictionary, pointer]

  • first_option [logical, in,]

  • conflicts [character(len=*), in,]

Use :

dictionaries, yaml_strings, yaml_parse_base

Called from:

yaml_argparse()

Call to:

f_err_throw(), dict_new(), dict_iter(), dict_key(), dict_next(), set(), yaml_load(), dict_update(), dict_free(), dict_init(), f_strcpy()

subroutine  yaml_parse/yaml_argparse(options, string_bn)
Parameters:
  • options [dictionary, pointer]

  • string_bn [character(len=*), in]

Use :

dictionaries, f_utils (f_zero())

Call to:

yaml_cl_parse_null(), yaml_cl_parse_option(), yaml_cl_parse_cmd_line(), yaml_cl_parse_free()

subroutine  yaml_parse/yaml_cl_parse_cmd_line(parser[, args])
Parameters:

parser [yaml_cl_parse, inout]

Options:

args [dictionary, out,pointer]

Use :

dictionaries, yaml_strings (f_strcpy()), yaml_output

Called from:

yaml_argparse()

Call to:

f_err_check(), dict_update(), dict_free(), dict_iter(), dict_key(), dict_value(), f_err_throw(), dict_next(), dict_copy(), yaml_cl_parse_free(), f_lib_finalize_noreport(), f_strcpy(), yaml_load()

subroutine  yaml_parse/yaml_parse_from_file(dict, fname[, tags, mpi_env])
Parameters:
  • dict [dictionary, pointer]

  • fname [character(len=*), in]

Options:
  • tags [dictionary, pointer]

  • mpi_env [mpi_environment]

Use :

dictionaries, wrapper_mpi, f_utils, dynamic_memory, yaml_parse_base (yaml_parse_from_file => parse_from_file())

Called from:

get_proc_status_dict()

Call to:

f_file_exists(), yaml_parse_from_char_array(), f_free_str()

YAML emitter in Fortran: the yaml_output module

Quick access

Routines:

dump_progress_bar(), yaml_bib_dump(), yaml_cite(), yaml_close_all_streams(), yaml_close_stream(), yaml_comment(), yaml_dict_dump(), yaml_dict_dump_all(), yaml_dict_inspect(), yaml_flush_document(), yaml_get_default_stream(), yaml_map(), yaml_mapping_close(), yaml_mapping_open(), yaml_new_document(), yaml_newline(), yaml_output_errors(), yaml_release_document(), yaml_scalar(), yaml_sequence(), yaml_sequence_close(), yaml_sequence_open(), yaml_set_default_stream(), yaml_set_stream(), yaml_stream_attributes(), yaml_stream_connected(), yaml_swap_stream(), yaml_warning()

Needed modules

  • yaml_strings

  • dictionaries: High-level dictionary API used throughout Futile and BigDFT. A dictionary is a pointer-based tree that can represent scalars, ordered mappings, and lists. It maps directly to YAML data and is manipulated with constructors

  • f_precisions: Defines the portable Futile kind policy, undefined sentinels, precision conversion helpers, and low-level address inquiry helpers. Host codes should use these names instead of compiler-specific kind

Subroutines and functions

interface  yaml_output/yaml_map()

general scalar

Called from:

f_routine(), f_release_routine(), f_malloc_finalize(), f_malloc_dump_status(), dump_f_matrix_ptr(), memstate_report(), f_profile(), yaml_stream_attributes(), yaml_dict_inspect(), yaml_bib_dump(), f_dump_all_errors(), f_lib_finalize()

interface  yaml_output/yaml_warning()
Called from:

f_malloc_finalize(), f_malloc_dump_status(), yaml_new_document(), yaml_cite()

interface  yaml_output/yaml_comment()
Called from:

f_release_routine(), f_malloc_set_status(), input_file_dump(), dump_progress_bar(), yaml_dict_dump_all(), yaml_release_document(), f_lib_finalize()

subroutine  yaml_output/yaml_swap_stream(new_unit, old_unit, ierr)
Parameters:
  • new_unit [integer, in] :: < new unit

  • old_unit [integer, out] :: < old unit

  • ierr [integer, out] :: < error code

Call to:

yaml_get_default_stream(), yaml_set_default_stream()

subroutine  yaml_output/yaml_output_errors()
Use :

exception_callbacks (f_err_set_last_error_callback(), f_err_set_all_errors_callback())

Called from:

initialize_flib_errors()

Call to:

f_err_define(), dict_init(), f_err_set_last_error_callback(), f_err_set_all_errors_callback()

subroutine  yaml_output/yaml_set_default_stream(unit, ierr)
Parameters:
  • unit [integer, in] :: < stream unit

  • ierr [integer, out] :: < error code

Called from:

yaml_swap_stream()

subroutine  yaml_output/yaml_get_default_stream(unit)
Parameters:

unit [integer, out]

Called from:

f_malloc_dump_status(), yaml_swap_stream(), f_dump_all_errors()

subroutine  yaml_output/yaml_stream_connected(filename, unit[, istat])
Parameters:
  • filename [character(len=*), in] :: < Filename of the stream to inquire

  • unit [integer, out] :: < File unit specified by the user.(by default 6) Returns a error code if the unit

Options:

istat [integer, out,] :: so far

Call to:

has_key()

subroutine  yaml_output/yaml_set_stream([unit, filename, istat, tabbing, record_length, position, setdefault])
Options:
  • unit [integer, in,] :: < File unit specified by the user.(by default 6) Returns a error code if the unit

  • filename [character(len=*), in,] :: < Filename of the stream

  • istat [integer, out,] :: so far

  • tabbing [integer, in,] :: < Indicate a tabbing for the stream (0 no tabbing, default)

  • record_length [integer, in,] :: int(record_length,kind=8)

  • position [character(len=*), in,]

  • setdefault [logical, in,] :: < decide if the new stream will be set as default stream. True if absent

Use :

f_utils (f_utils_recl(), f_get_free_unit(), f_open_file())

Called from:

f_malloc_set_status(), f_malloc_dump_status()

Call to:

has_key(), f_get_free_unit(), f_err_raise(), f_err_throw(), f_err_open_try(), f_open_file(), f_get_last_error(), f_err_close_try(), f_utils_recl(), set()

subroutine  yaml_output/yaml_stream_attributes([unit, stream_unit, icursor, flowrite, itab_active, iflowlevel, ilevel, ilast, indent, indent_previous, record_length])
Options:
  • unit [integer, in,] :: < File unit to display

  • stream_unit [integer, in,] :: < Stream Id

  • icursor [integer, out,] :: < @copydoc yaml_stream::icursor

  • flowrite [logical, out,] :: < @copydoc yaml_stream::flowrite

  • itab_active [integer, out,] :: < @copydoc yaml_stream::itab_active

  • iflowlevel [integer, out,] :: < @copydoc yaml_stream::iflowlevel

  • ilevel [integer, out,] :: < @copydoc yaml_stream::ilevel

  • ilast [integer, out,] :: < @copydoc yaml_stream::ilast

  • indent [integer, out,] :: < @copydoc yaml_stream::indent

  • indent_previous [integer, out,] :: < @copydoc yaml_stream::indent_previous

  • record_length [integer, out,] :: < Maximum number of columns of the stream (default @link yaml_output::yaml_stream::tot_max_record_length @endlink)

Call to:

yaml_newline(), yaml_mapping_open(), yaml_map(), yaml_mapping_close()

subroutine  yaml_output/yaml_new_document([unit])
Options:

unit [integer, in,] :: < @copydoc doc::unit

Called from:

f_timing_reset(), yaml_dict_dump_all()

Call to:

yaml_warning()

subroutine  yaml_output/yaml_flush_document([unit])
Options:

unit [integer, in,] :: < @copydoc doc::unit

Called from:

f_routine(), f_release_routine(), f_update_database(), f_purge_database(), yaml_release_document()

Call to:

f_utils_flush()

subroutine  yaml_output/yaml_close_stream([unit, istat])
Options:
  • unit [integer, in,] :: < @copydoc doc::unit

  • istat [integer, out,] :: <error code, zero if suceeded

Called from:

f_malloc_set_status(), f_malloc_finalize(), f_malloc_dump_status(), yaml_close_all_streams()

Call to:

f_err_raise(), yaml_release_document(), dict_iter(), dict_size(), dict_remove(), dict_key(), dict_init(), dict_next()

subroutine  yaml_output/yaml_close_all_streams()
Called from:

f_lib_finalize(), f_lib_finalize_noreport()

Call to:

yaml_close_stream(), yaml_release_document(), dict_free()

subroutine  yaml_output/yaml_dict_inspect(dict)
Parameters:

dict [dictionary, pointer]

Call to:

yaml_map(), yaml_mapping_open(), yaml_mapping_close()

subroutine  yaml_output/dump_progress_bar(bar[, step, unit])
Parameters:

bar [f_progress_bar, inout]

Options:
  • step [integer, in,]

  • unit [integer, in,]

Use :

f_precisions, f_utils

Call to:

yaml_newline(), update_progress_bar(), f_tty(), yaml_comment(), f_utils_flush()

subroutine  yaml_output/yaml_cite(paper[, unit])
Parameters:

paper [character(len=*), in] :: <the item to be cited in the bibliography

Options:

unit [integer, in,]

Use :

f_bibliography, f_utils

Call to:

f_bib_item_exists(), dict_init(), get_bib_filename(), f_open_file(), f_close(), add(), f_bib_get_item(), dict_value(), yaml_warning()

subroutine  yaml_output/yaml_bib_dump(citations[, unit])
Parameters:

citations [dictionary, pointer]

Options:

unit [integer, in,] :: < yaml stream associated

Use :

f_bibliography, f_utils

Call to:

yaml_mapping_open(), f_bib_get_item(), dict_value(), yaml_map(), dict_key(), yaml_mapping_close()

subroutine  yaml_output/yaml_scalar(message[, advance, unit, hfill])
Parameters:

message [character(len=*), in] :: < the message to be printed

Options:
  • advance [character(len=*), in,] :: < @copydoc doc::advance

  • unit [integer, in,] :: < @copydoc doc::unit

  • hfill [character(len=*), in,] :: < If present fill the line with the given character

subroutine  yaml_output/yaml_mapping_open([mapname, label, tag, flow, tabbing, advance, unit])
Options:
  • mapname [character(len=*), in,] :: < Key of the sequence. @copydoc doc::mapname

  • label [character(len=*), in,] :: < @copydoc doc::label

  • tag [character(len=*), in,] :: < @copydoc doc::tag

  • flow [logical, in,] :: < @copydoc doc::flow

  • tabbing [integer, in,] :: < @copydoc doc::tabbing

  • advance [character(len=*), in,] :: < @copydoc doc::advance

  • unit [integer, in,] :: < @copydoc doc::unit

Called from:

f_routine(), f_malloc_finalize(), f_malloc_dump_status(), f_tree_dump(), memstate_report(), f_profile(), yaml_stream_attributes(), yaml_dict_inspect(), yaml_bib_dump()

subroutine  yaml_output/yaml_mapping_close([advance, unit])
Options:
  • advance [character(len=*), in,] :: <@copydoc doc::advance

  • unit [integer, in,] :: < @copydoc doc::unit

Called from:

f_release_routine(), f_malloc_finalize(), f_malloc_dump_status(), f_tree_dump(), memstate_report(), f_profile(), yaml_stream_attributes(), yaml_dict_inspect(), yaml_bib_dump()

subroutine  yaml_output/yaml_sequence_open([mapname, label, tag, flow, tabbing, advance, unit])
Options:
  • mapname [character(len=*), in,] :: < Key of the sequence. @copydoc doc::mapname

  • label [character(len=*), in,] :: < @copydoc doc::label

  • tag [character(len=*), in,] :: < @copydoc doc::tag

  • flow [logical, in,] :: < @copydoc doc::flow

  • tabbing [integer, in,] :: < @copydoc doc::tabbing

  • advance [character(len=*), in,] :: < @copydoc doc::advance

  • unit [integer, in,] :: < @copydoc doc::unit

Called from:

f_malloc_set_status(), dump_status_line()

subroutine  yaml_output/yaml_sequence_close([advance, unit])
Options:
  • advance [character(len=*), in,]

  • unit [integer, in,]

Called from:

f_malloc_finalize(), dump_status_line()

subroutine  yaml_output/yaml_newline([unit])
Options:

unit [integer, in,] :: < @copydoc doc::unit

Called from:

f_malloc_dump_status(), yaml_stream_attributes(), dump_progress_bar(), yaml_release_document()

subroutine  yaml_output/yaml_sequence([seqvalue, label, advance, unit, padding])
Options:
  • seqvalue [character(len=*), in,] :: < value of the sequence

  • label [character(len=*), in,] :: < @copydoc doc::label

  • advance [character(len=*), in,] :: < @copydoc doc::advance

  • unit [integer, in,] :: < @copydoc doc::unit

  • padding [integer, in,] :: < pad the seqvalue with blanks to have more readable output

Called from:

dump_status_line()

Call to:

buffer_string()

subroutine  yaml_output/yaml_dict_dump(dict[, unit, flow, verbatim])
Parameters:

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

Options:
  • unit [integer, in,] :: < unit in which the dump has to be

  • flow [logical, in,] :: < @copydoc doc::flow

  • verbatim [logical, in,] :: < if .true. print as comments the calls performed

Called from:

f_release_routine(), f_tree_dump(), yaml_dict_dump_all(), yaml_release_document(), f_dump_all_errors()

Call to:

dict_value(), dict_len(), dict_next(), dict_size(), dict_item(), dict_key()

subroutine  yaml_output/yaml_dict_dump_all(dict[, unit, flow, verbatim])
Parameters:

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

Options:
  • unit [integer, in,] :: < unit in which the dump has to be

  • flow [logical, in,] :: < if .true. inline

  • verbatim [logical, in,] :: < if .true. print as comments the calls performed

Call to:

f_err_raise(), dict_len(), yaml_comment(), yaml_new_document(), yaml_dict_dump(), yaml_release_document()

subroutine  yaml_output/yaml_release_document([unit])
Options:

unit [integer, in,] :: < @copydoc doc::unit

Called from:

yaml_close_stream(), yaml_close_all_streams(), yaml_dict_dump_all()

Call to:

yaml_newline(), yaml_comment(), yaml_dict_dump(), dict_free(), yaml_flush_document()

Convenient string functions: the yaml_strings module

Quick access

Types:

f_string

Routines:

align_message(), buffer_string(), convert_f_char_ptr(), f_char_ptr(), f_strcpy(), is_atof(), is_atoi(), is_atol(), is_atoli(), operator(**)(), operator(.eqv.)(), operator(.neqv.)(), read_fraction_string(), rstrip(), shiftstr(), yaml_blink(), yaml_bold(), yaml_date_and_time_toa(), yaml_date_toa(), yaml_time_toa(), yaml_toa()

Needed modules

  • f_precisions: Defines the portable Futile kind policy, undefined sentinels, precision conversion helpers, and low-level address inquiry helpers. Host codes should use these names instead of compiler-specific kind

Types

  • type  yaml_strings/f_string
    Type fields:
    • % msg [character(len=4*max_value_length)]

Subroutines and functions

interface  yaml_strings/yaml_toa()

Convert a supported Futile intrinsic value to its YAML string representation.

interface  yaml_strings/f_strcpy(dest, src)
Parameters:
  • dest [character(len=*), out]

  • src [character(len=*), in]

interface  yaml_strings/operator(.eqv.)()
interface  yaml_strings/operator(.neqv.)()
interface  yaml_strings/operator(//)()
interface  yaml_strings/operator(+)()
interface  yaml_strings/assignment(=)()
interface  yaml_strings/operator(**)()
subroutine  yaml_strings/f_strcpy(dest, src)
Parameters:
  • dest [character(len=*), out]

  • src [character(len=*), in]

Called from:

set_elem(), storage_data(), stored_key(), stored_value(), f_purge_database(), f_malloc_set_status(), nullify_f_enum(), input_keys_get_profile(), f_humantime(), update_progress_bar(), f_open_file(), memstate_report(), dump_status_line(), get_proc_status_dict(), yaml_cl_parse_option(), yaml_cl_parse_cmd_line()

function  yaml_strings/yaml_bold(str)
Parameters:

str [character(len=*), in]

Return:

bstr [character(len=max_value_length)]

Parameters:

str [character(len=*), in]

Return:

bstr [character(len=max_value_length)]

subroutine  yaml_strings/buffer_string(string_bn, string_lgt, buffer, string_pos[, back, istat])
Parameters:
  • string_bn [character(len=string_lgt), inout]

  • string_lgt [integer, in] :: < Length of the string towrite

  • buffer [character(len=*), in] :: < Buffer to add

  • string_pos [integer, inout] :: < Position to add buffer into string and for the next.

Options:
  • back [logical, in,] :: < Add string from the end

  • istat [integer, out,] :: no errors

Called from:

yaml_sequence()

Call to:

shiftstr()

subroutine  yaml_strings/align_message(rigid, maxlen, tabval, anchor, message)
Parameters:
  • rigid [logical, in]

  • maxlen [integer, in]

  • tabval [integer, in]

  • anchor [character(len=*), in]

  • message [character(len=maxlen), inout]

Call to:

shiftstr()

function  yaml_strings/yaml_date_and_time_toa([values, zone])
Options:
  • values (8) [integer, in,]

  • zone [logical, in,]

Return:

yaml_date_and_time_toa [character(len=max_value_length)]

Called from:

f_malloc_initialize()

function  yaml_strings/yaml_date_toa([values])

Yaml Spaced format for Date

Options:

values (8) [integer, in,]

Return:

yaml_date_toa [character(len=max_value_length)]

function  yaml_strings/yaml_time_toa([values])
Options:

values (8) [integer, in,]

Return:

yaml_time_toa [character(len=max_value_length)]

Called from:

f_routine(), f_release_routine(), update_progress_bar()

function  yaml_strings/is_atoi(str)
Parameters:

str [character(len=*), in]

Return:

yes [logical]

function  yaml_strings/is_atoli(str)
Parameters:

str [character(len=*), in]

Return:

yes [logical]

function  yaml_strings/is_atof(str)
Parameters:

str [character(len=*), in]

Return:

yes [logical]

function  yaml_strings/is_atol(str)
Parameters:

str [character(len=*), in]

Return:

yes [logical]

subroutine  yaml_strings/read_fraction_string(string_bn, var, ierror)
Parameters:
  • string_bn [character(len=*), in]

  • var [real, out]

  • ierror [integer, out]

subroutine  yaml_strings/rstrip(string_bn, substring)
Parameters:
  • string_bn [character(len=*), inout]

  • substring [character(len=*), in]

Called from:

get_bib_filename()

subroutine  yaml_strings/shiftstr(str, n)
Parameters:
  • str [character(len=*), inout]

  • n [integer, in]

Called from:

buffer_string(), align_message()

function  yaml_strings/f_char_ptr(str)
Parameters:

str [character(len=*), in]

Return:

f_char_ptr (1 + len_trim(str) [character]

Called from:

f_err_throw_c(), f_char_ptr()

Call to:

f_char_ptr()

subroutine  yaml_strings/convert_f_char_ptr(src, dest)
Parameters:
  • src (*) [character, in]

  • dest [character(len=*), out]

Called from:

bind_dict_set_string(), bind_dict_add_char()