Routine that obtains the value of a real variable from the input file and checks that it lies within the expected range author: P J Knight, CCFE, Culham Science Centre varnam : input string : name of the variable varval : input/output real : value of the variable vmin : input real : minimum allowed value for the variable vmax : input real : maximum allowed value for the variable description : input string : brief description of the variable This routine parses a line containing a 'name = value' pair for a real variable, extracting the value from the line and checking whether it lies between user-defined lower and upper limits. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | varnam | |||
real(kind=dp), | intent(inout) | :: | varval | |||
real(kind=dp), | intent(in) | :: | vmin | |||
real(kind=dp), | intent(in) | :: | vmax | |||
character(len=*), | intent(in) | :: | description |
subroutine parse_real_variable(varnam,varval,vmin,vmax,description)
!! Routine that obtains the value of a real variable from the input
!! file and checks that it lies within the expected range
!! author: P J Knight, CCFE, Culham Science Centre
!! varnam : input string : name of the variable
!! varval : input/output real : value of the variable
!! vmin : input real : minimum allowed value for the variable
!! vmax : input real : maximum allowed value for the variable
!! description : input string : brief description of the variable
!! This routine parses a line containing a 'name = value' pair
!! for a real variable, extracting the value from the line
!! and checking whether it lies between user-defined lower and
!! upper limits.
!! None
!
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
implicit none
! Arguments
character(len=*), intent(in) :: varnam, description
real(dp), intent(inout) :: varval
real(dp), intent(in) :: vmin, vmax
! Local variables
real(dp) :: oldval
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Check whether a subscript was found by the preceding call to GET_VARIABLE_NAME
! and stop if this is the case
if (subscript_present) then
write(*,*) 'Unexpected subscript found at line ', lineno
write(*,*) 'Variable name and description:'
write(*,*) varnam, ', ', description
error = .True.
end if
! Obtain the new value for the variable
oldval = varval
call get_value_real(varval,icode)
if (icode /= 0) then
write(*,*) 'Error whilst reading input file. Variable name and description:'
write(*,*) varnam, ', ', description
write(*,*) 'Comments should be indicated by an asterisk'
error = .True.
end if
! Check variable lies within range
call check_range_real(varnam,varval,vmin,vmax)
if ((report_changes == 1).and.(varval /= oldval)) then
write(outfile,*) trim(description),', ',trim(varnam),' = ',varval
end if
end subroutine parse_real_variable