Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | String | |||
logical, | intent(out) | :: | ErrorFlag |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
FUNCTION ProcessNumber(String,ErrorFlag) RESULT(rProcessNumber)
! FUNCTION INFORMATION:
! AUTHOR Linda K. Lawrie
! DATE WRITTEN September 1997
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This function processes a string that should be numeric and
! returns the real value of the string.
! METHODOLOGY EMPLOYED:
! FUNCTION ProcessNumber translates the argument (a string)
! into a real number. The string should consist of all
! numeric characters (except a decimal point). Numerics
! with exponentiation (i.e. 1.2345E+03) are allowed but if
! it is not a valid number an error message along with the
! string causing the error is printed out and 0.0 is returned
! as the value.
! The Fortran input processor is used to make the conversion.
! REFERENCES:
! List directed Fortran input/output.
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
CHARACTER(len=*), INTENT(IN) :: String
LOGICAL, INTENT(OUT) :: ErrorFlag
REAL(r64) :: rProcessNumber
! SUBROUTINE PARAMETER DEFINITIONS:
CHARACTER(len=*), PARAMETER :: ValidNumerics='0123456789.+-EeDd'//CHAR(9)
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
REAL(r64) Temp
INTEGER IoStatus
INTEGER VerNumber
INTEGER StringLen
CHARACTER(len=MaxNameLength) :: PString
rProcessNumber=0.0d0
! Make sure the string has all what we think numerics should have
PString=ADJUSTL(String)
StringLen=LEN_TRIM(PString)
ErrorFlag=.false.
IoStatus=0
IF (StringLen == 0) RETURN
VerNumber=VERIFY(PString(1:StringLen),ValidNumerics)
IF (VerNumber == 0) THEN
Read(PString,*,IOSTAT=IoStatus) Temp
rProcessNumber=Temp
ErrorFlag=.false.
ELSE
rProcessNumber=0.0d0
ErrorFlag=.true.
ENDIF
IF (IoStatus /= 0) THEN
rProcessNumber=0.0d0
ErrorFlag=.true.
ENDIF
RETURN
END FUNCTION ProcessNumber