config_file_module Module

For handling JSON config files


Uses

  • module~~config_file_module~~UsesGraph module~config_file_module config_file_module json_module json_module module~config_file_module->json_module module~parameters_module parameters_module module~config_file_module->module~parameters_module fortran_astrodynamics_toolkit fortran_astrodynamics_toolkit module~parameters_module->fortran_astrodynamics_toolkit module~halo_kinds_module halo_kinds_module module~parameters_module->module~halo_kinds_module iso_fortran_env iso_fortran_env module~halo_kinds_module->iso_fortran_env

Used by

  • module~~config_file_module~~UsedByGraph module~config_file_module config_file_module module~halo_module halo_module module~halo_module->module~config_file_module

Derived Types

type, public ::  config_file

a class for handling JSON config files.

Components

Type Visibility Attributes Name Initial
character(len=:), private, allocatable :: name

the file name

type(json_file), public :: json

made it public so we can use the methods

Type-Bound Procedures

procedure, public :: open => open_config_file
procedure, public :: close => close_config_file
generic, public :: get => get_int, get_real, get_logical, get_char, get_real_vec
procedure, private :: get_real_vec
procedure, private :: get_char
procedure, private :: get_logical
procedure, private :: get_real
procedure, private :: get_int

Subroutines

private subroutine open_config_file(me, filename)

Open the file.

Arguments

Type IntentOptional Attributes Name
class(config_file), intent(inout) :: me
character(len=*), intent(in) :: filename

the name of the JSON file

private subroutine close_config_file(me)

Open the file.

Arguments

Type IntentOptional Attributes Name
class(config_file), intent(inout) :: me

private subroutine get_int(me, name, variable, found)

Get an integer variable from the config file.

Arguments

Type IntentOptional Attributes Name
class(config_file), intent(inout) :: me
character(len=*), intent(in) :: name

name of the variable

integer, intent(inout) :: variable

the variable to populate with the value

logical, intent(out), optional :: found

if the variable was in the file

private subroutine get_real(me, name, variable, found)

Get a real variable from the config file.

Arguments

Type IntentOptional Attributes Name
class(config_file), intent(inout) :: me
character(len=*), intent(in) :: name

name of the variable

real(kind=wp), intent(inout) :: variable

the variable to populate with the value

logical, intent(out), optional :: found

if the variable was in the file

private subroutine get_logical(me, name, variable, found)

Get a logical variable from the config file.

Arguments

Type IntentOptional Attributes Name
class(config_file), intent(inout) :: me
character(len=*), intent(in) :: name

name of the variable

logical, intent(inout) :: variable

the variable to populate with the value

logical, intent(out), optional :: found

if the variable was in the file

private subroutine get_char(me, name, variable, found)

Get a character variable from the config file.

Arguments

Type IntentOptional Attributes Name
class(config_file), intent(inout) :: me
character(len=*), intent(in) :: name

name of the variable

character(len=:), intent(inout), allocatable :: variable

the variable to populate with the value

logical, intent(out), optional :: found

if the variable was in the file

private subroutine get_real_vec(me, name, variable, found)

Get a real vector from the config file.

Arguments

Type IntentOptional Attributes Name
class(config_file), intent(inout) :: me
character(len=*), intent(in) :: name

name of the variable

real(kind=wp), intent(inout), dimension(:), allocatable :: variable

the variable to populate with the value

logical, intent(out), optional :: found

if the variable was in the file