diff --git a/src/gray_params.f90 b/src/gray_params.f90 index 0cdf4c3..6c06a84 100644 --- a/src/gray_params.f90 +++ b/src/gray_params.f90 @@ -203,6 +203,25 @@ module gray_params type(misc_parameters) :: misc end type + ! List of mandatory GRAY parameters + integer, parameter :: max_name_size = 40 + character(len=*), parameter :: mandatory(*) = [ & + character(len=max_name_size) :: & + "antenna.alpha", & + "antenna.beta", & + "antenna.iox", & + "antenna.ibeam", & + "antenna.filenm", & + "equilibrium.filenm", & + "profiles.irho", & + "profiles.iprof", & + "profiles.filenm", & + "raytracing.dst", & + "raytracing.nrayr", & + "raytracing.nrayth", & + "misc.rwall" & + ] + ! All GRAY input data type gray_data type(equilibrium_data) :: equilibrium @@ -355,15 +374,31 @@ contains subroutine read_gray_config(filename, params, err) ! Reads the GRAY parameters from the gray.ini configuration file - use ini_parser, only : parse_ini, property_handler, ini_error - + use ini_parser, only : parse_ini, property_handler, ini_error, ERR_SUCCESS + use logger, only : log_error ! subroutine arguments character(len=*), intent(in) :: filename type(gray_parameters), intent(out) :: params integer(kind(ini_error)), intent(out) :: err + integer, parameter :: max_lines = 100 + integer :: count, i + character(len=max_name_size) :: provided(max_lines), name + + ! parse the configuration + count = 1 call parse_ini(filename, ini_handler, err) + if (err /= ERR_SUCCESS) return + + ! check if all mandatory parameters were given + do i = 1, size(mandatory) + name = mandatory(i) + if (findloc(provided, trim(name), count) /= 0) cycle + call log_error('mandatory parameter `'//trim(name)//'` is missing!', & + mod='gray_params', proc='read_gray_config') + err = 1 + end do contains @@ -376,6 +411,10 @@ contains integer(kind(ini_error)) :: err err = update_parameter(params, section // "." // name, value) + + ! store the parameter name + provided(count) = section // "." // name + count = count + 1 end function ini_handler end subroutine read_gray_config diff --git a/src/ini_parser.f90 b/src/ini_parser.f90 index 886c3e4..7461a6f 100644 --- a/src/ini_parser.f90 +++ b/src/ini_parser.f90 @@ -137,7 +137,7 @@ contains cycle case (ERR_VALUE) - write (msg, '("invalid value for property ",a,": ", a)') name, value + write (msg, '("invalid value for property `",a,"`: ", a)') name, value call log_error(msg, proc='parse_ini', mod='ini_parser') deallocate(line) error = ERR_VALUE