Read the config file and populate the global variables.
subroutine read_config_file()
use argv_module, only: argv
use json_module, only: json_file
implicit none
character(len=:),allocatable :: filename
type(json_file) :: json
logical :: status_ok, found
character(len=:),allocatable :: error_msg
filename = argv(1) ! get the first argument
if (filename == '') then
error stop 'The first command line arg should be the config file name'
else
write(*,'(A)') 'Reading config file: '//trim(filename)
call json%initialize() ! no optional args for now
call json%load(filename)
if (json%failed()) then
call json%check_for_errors(error_msg=error_msg)
error stop error_msg
else
! populate the run variables:
call json%get('dt_max', dt_max, found); if (.not. found) error stop 'dt_max not found in config file.'
call json%get('et0', et0, found); if (.not. found) error stop 'et0 not found in config file.'
call json%get('tru0', tru0, found); if (.not. found) error stop 'tru0 not found in config file.'
call json%get('alt0', alt0, found); if (.not. found) error stop 'alt0 not found in config file.'
call json%get('deadband_alt', deadband_alt, found); if (.not. found) error stop 'deadband_alt not found in config file.'
call json%get('inc_start', inc_start, found); if (.not. found) error stop 'inc_start not found in config file.'
call json%get('inc_stop', inc_stop, found); if (.not. found) error stop 'inc_stop not found in config file.'
call json%get('inc_step', inc_step, found); if (.not. found) error stop 'inc_step not found in config file.'
call json%get('lan_start', lan_start, found); if (.not. found) error stop 'lan_start not found in config file.'
call json%get('lan_stop', lan_stop, found); if (.not. found) error stop 'lan_stop not found in config file.'
call json%get('lan_step', lan_step, found); if (.not. found) error stop 'lan_step not found in config file.'
call json%get('grav_n', grav_n, found); if (.not. found) error stop 'grav_n not found in config file.'
call json%get('grav_m', grav_m, found); if (.not. found) error stop 'grav_m not found in config file.'
call json%get('ephemeris_file', ephemeris_file, found)
if (.not. found) error stop 'ephemeris_file not found in config file.'
call json%get('gravfile', gravfile, found)
if (.not. found) error stop 'gravfile not found in config file.'
end if
call json%destroy()
end if
end subroutine read_config_file