Process the configuration file to a TOML data structure
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(toml_table), | intent(out), | allocatable | :: | table | TOML data structure |
|
character(len=*), | intent(in) | :: | file | Name of the configuration file |
||
type(error_type), | intent(out), | allocatable | :: | error | Error status of the operation |
subroutine read_config_file(table, file, error)
!> TOML data structure
type(toml_table), allocatable, intent(out) :: table
!> Name of the configuration file
character(len=*), intent(in) :: file
!> Error status of the operation
type(error_type), allocatable, intent(out) :: error
type(toml_error), allocatable :: parse_error
integer :: unit
logical :: exist
inquire(file=file, exist=exist)
if (.not.exist) then
call fatal_error(error, "'"//file//"' not found")
return
end if
open(file=file, newunit=unit)
call toml_parse(table, unit, parse_error)
close(unit)
if (allocated(parse_error)) then
allocate(error)
call move_alloc(parse_error%message, error%message)
return
end if
end subroutine read_config_file