Routine that obtains the value of a string variable from the input file author: P J Knight, CCFE, Culham Science Centre varnam : input string : name of the variable varval : input/output string : value of the variable description : input string : brief description of the variable This routine parses a line containing a 'name = value' pair for a string variable, extracting the value from the line. None
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | varnam | |||
character(len=*), | intent(inout) | :: | varval | |||
character(len=*), | intent(in) | :: | description |
subroutine parse_string_variable(varnam,varval,description)
!! Routine that obtains the value of a string variable from the
!! input file
!! author: P J Knight, CCFE, Culham Science Centre
!! varnam : input string : name of the variable
!! varval : input/output string : value of the variable
!! description : input string : brief description of the variable
!! This routine parses a line containing a 'name = value' pair
!! for a string variable, extracting the value from the line.
!! None
!
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
implicit none
! Arguments
character(len=*), intent(in) :: varnam, description
character(len=*), intent(inout) :: varval
! Local variables
character(len=maxlen) :: 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.
!stop 1
end if
! Obtain the new value for the variable
oldval = varval
call get_substring(varval,icode)
if (icode /= 0) then
write(*,*) 'Error in IN.DAT found at line ',lineno
write(*,*) 'Variable name, description:'
write(*,*) varnam, ', ', description
error = .True.
end if
if ((report_changes == 1).and.(trim(varval) /= trim(oldval))) then
write(outfile,*) trim(description),', ',trim(varnam),' = ',varval
end if
end subroutine parse_string_variable