Routine that obtains the value of an integer 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 integer : value of the variable vmin : input integer : minimum allowed value for the variable vmax : input integer : 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 an integer 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 | |||
integer, | intent(inout) | :: | varval | |||
integer, | intent(in) | :: | vmin | |||
integer, | intent(in) | :: | vmax | |||
character(len=*), | intent(in) | :: | description |
subroutine parse_int_variable(varnam,varval,vmin,vmax,description)
!! Routine that obtains the value of an integer 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 integer : value of the variable
!! vmin : input integer : minimum allowed value for the variable
!! vmax : input integer : 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 an integer variable, extracting the value from the line
!! and checking whether it lies between user-defined lower and
!! upper limits.
!! None
!
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use constants, only: nout
implicit none
! Arguments
character(len=*), intent(in) :: varnam, description
integer, intent(inout) :: varval
integer, intent(in) :: vmin, vmax
! Local variables
integer :: 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 in IN.DAT at line number: ', lineno
write(*,*) 'Name and description of variable: '
write(*,*) varnam, description
error = .True.
end if
! Obtain the new value for the variable
oldval = varval
call get_value_int(varval,icode)
if (icode /= 0) then
write(*,*) 'Error found in input file, check line ',lineno
write(*,*) 'Variable name, description:'
write(*,*) varnam, ', ', description
error = .True.
end if
! Check variable lies within range
call check_range_int(varnam,varval,vmin,vmax)
if ((report_changes == 1).and.(varval /= oldval)) then
write(outfile,*) trim(description),', ',trim(varnam),' = ',varval
end if
end subroutine parse_int_variable