parse_real_array Subroutine

private subroutine parse_real_array(varnam, varval, isub1, n, description, icode)

Routine that obtains the values of a real array from the input file author: P J Knight, CCFE, Culham Science Centre varnam : input string : name of the variable varval(n) : input/output real array : value of the variable isub1 : input integer : array element pointer n : input integer : size of varval array icode : output integer : diagnostic flag description : input string : brief description of the variable This routine parses a line in one of the two following forms:

 name = v1[, v2, ...]
 name(element) = v
 

to read in and extract one or more values for a real 1-D array.

N.B. No array bounds or value range checking is performed. None

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: varnam
real(kind=dp), intent(inout), dimension(n):: varval
integer, intent(inout) :: isub1
integer, intent(in) :: n
character(len=*), intent(in) :: description
integer, intent(out) :: icode

Contents

Source Code


Source Code

  subroutine parse_real_array(varnam,varval,isub1,n,description,icode)

    !! Routine that obtains the values of a real array from the input file
    !! author: P J Knight, CCFE, Culham Science Centre
    !! varnam : input string : name of the variable
    !! varval(n) : input/output real array : value of the variable
    !! isub1 : input integer : array element pointer
    !! n : input integer : size of varval array
    !! icode : output integer : diagnostic flag
    !! description : input string : brief description of the variable
    !! This routine parses a line in one of the two following forms:
    !! <PRE>
    !! name = v1[, v2, ...]
    !! name(element) = v
    !! </PRE>
    !! to read in and extract one or more values for a real 1-D array.
    !! <P>N.B. No array bounds or value range checking is performed.
    !! None
    !
    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    implicit none

    !  Arguments

    character(len=*), intent(in) :: varnam, description
    integer, intent(inout) :: isub1
    integer, intent(in) :: n
    integer, intent(out) :: icode
    real(dp), dimension(n), intent(inout) :: varval

    !  Local variables

    real(dp) :: oldval, val

    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    !  Check whether a subscript was found by the preceding call to GET_VARIABLE_NAME

    if (subscript_present) then

       oldval = varval(isub1)
       call get_value_real(val,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

       varval(isub1) = val
       if ((report_changes == 1).and.(varval(isub1) /= oldval)) then
          write(outfile,10) trim(description),', ', &
               trim(varnam),'(',isub1,') = ',varval(isub1)
       end if

    else

       isub1 = 1
       do
          call get_value_real(val,icode)
          !  icode == 1 denotes an error
          !  icode == -1 denotes end of line, so the next line needs to be read in
          !  (hence the 'goto 20' in the calling routine)
          if (icode /= 0) return

          oldval = varval(isub1)
          varval(isub1) = val
          if ((report_changes == 1).and.(varval(isub1) /= oldval)) then
             write(outfile,10) trim(description),', ', &
                  trim(varnam),'(',isub1,') = ',varval(isub1)
          end if
          isub1 = isub1 + 1
       end do
    end if

10  format(a,a,a,a1,i3,a,e14.6e2)

  end subroutine parse_real_array