Skip to content

Methods summary ​

Every type-bound procedure of file_ini, with its arguments. Optional arguments are in square brackets; pass them by keyword, as the examples do. The pages of the reference explain each group, and the API pages are generated from the sources.

The type ​

fortran
type :: file_ini
  character(len=:), allocatable, public :: filename   ! set by load(filename=), save(filename=), initialize(filename=)
  ! every other component is private
contains
  ...
endtype file_ini

b = a copies a file_ini (file name, separator, sections and options). file_ini_autotest(), a public subroutine of finer, runs a self test that prints its results.

Loading, saving, printing ​

MethodArguments
load[filename], [source], [separator], [error]read a file or a string; details
save[filename], [retain_comments], [iostat], [iomsg]write the file; details
printunit, [pref], [retain_comments], [iostat], [iomsg]write to a unit; details
initialize[filename]empty the file_ini, set its file name; details
freedelete everything

Reading ​

MethodArguments
get (scalar)section_name, option_name, val, [error], [default]convert a value into val; details
get (array)section_name, option_name, val(:), [delimiter], [error], [default(:)]convert a list into val
get_stringsection_name, option_name, val, [error], [default]a value into an allocatable string; details
count_valuessection_name, option_name, [delimiter]function: the number of items of a value

Writing ​

MethodArguments
add (section)section_name, [error]create a section if missing; details
add (scalar, array)section_name, option_name, val or val(:), [error]create or update an option
delsection_name, [option_name]delete a section, or one of its options; details
free_options[section_name], [option_name]delete every option, those of a section, or one

Exploring ​

MethodArguments
sections_numberfunction: the number of sections; details
sectionsection_indexfunction: the name of a section
get_sections_listlistsubroutine: every section name
has_sectionsection_namefunction: is the section there
has_optionoption_name, [section_name]function: is the option in some section, and in which; details
indexsection_name, [option_name], [back]function: the position of a section, or of an option in its section
get_itemsitemssubroutine: every name and value
unused_optionsitemssubroutine: the section and the name of every option never read; details
loop[section_name], option_pairsfunction: the next name and value, .false. at the end; details

Argument types ​

ArgumentType and intent
section_name, option_namecharacter(*), in (inout for the section_name of has_option)
valclass(*): inout for get, in for add; character(len=:), allocatable, inout for get_string
defaultclass(*), in (character(*) for get_string)
delimiter, pref, filename, sourcecharacter(*), in
separatorcharacter(1), in
unit, section_indexinteger(I4P), in
error, iostatinteger(I4P), out
iomsgcharacter(*), out
retain_comments, backlogical, in
list, option_pairscharacter(len=:), allocatable, rank 1, out
itemscharacter(len=:), allocatable, rank 2 (items(n, 2)), out

Error codes ​

ERR_OPTION_NAME (1), ERR_OPTION_VALS (2), ERR_OPTION (3), ERR_SECTION_NAME (4), ERR_SECTION_OPTIONS (5), ERR_SECTION (6), ERR_SOURCE_MISSING (7): see Errors for which method returns which.