Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(in) | :: | RealValue | |||
integer, | intent(in) | :: | SigDigits |
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 rTrimSigDigits(RealValue,SigDigits) RESULT(OutputString)
! FUNCTION INFORMATION:
! AUTHOR Linda K. Lawrie
! DATE WRITTEN March 2002
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This function accepts a number as parameter as well as the number of
! significant digits after the decimal point to report and returns a string
! that is appropriate.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
! na
!USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY : IEEE_IS_NAN ! Use IEEE_IS_NAN when GFortran supports it
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
REAL(r64), INTENT(IN) :: RealValue
INTEGER, INTENT(IN) :: SigDigits
CHARACTER(len=32) OutputString
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
INTEGER DotPos ! Position of decimal point in original string
INTEGER EPos ! Position of E in original string format xxEyy
INTEGER SLen ! Length of String (w/o E part)
CHARACTER(len=32) String ! Working string
CHARACTER(len=10) EString ! E string retained from original string
LOGICAL IncludeDot ! True when decimal point output
IF (RealValue /= 0.0d0) THEN
WRITE(String,*) RealValue
ELSE
String='0.000000000000000000000000000'
ENDIF
EPos=INDEX(String,'E')
IF (EPos > 0) THEN
EString=String(EPos:)
String(EPos:)=' '
ELSE
EString=' '
ENDIF
DotPos=INDEX(String,'.')
SLen=LEN_TRIM(String)
IF (SigDigits > 0 .or. EString /= ' ') THEN
IncludeDot=.true.
ELSE
IncludeDot=.false.
ENDIF
IF (IncludeDot) THEN
String=String(1:MIN(DotPos+SigDigits,SLen))//EString
ELSE
String=String(1:DotPos-1)
ENDIF
IF (RealValue /= RealValue) THEN ! Use IEEE_IS_NAN when GFortran supports it
String='NAN'
ENDIF
OutputString=ADJUSTL(String)
RETURN
END FUNCTION rTrimSigDigits