FUNCTION RemoveTrailingZeros(InputString) RESULT(ResultString)
! FUNCTION INFORMATION:
! AUTHOR Linda Lawrie
! DATE WRITTEN September 2005
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! Remove trailing zeroes from output strings.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
CHARACTER(len=*), INTENT(IN) :: InputString
CHARACTER(len=LEN(InputString)) :: ResultString
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
INTEGER Pos
Pos=SCAN(InputString,'ED')
IF (Pos == 0) THEN
Pos=SCAN(InputString,'.')
IF (Pos /= 0) THEN
Pos=SCAN(InputString,'123456789.',.true.)
IF (Pos > 0) THEN
ResultString=InputString(1:Pos)
ELSE
ResultString='0.'
ENDIF
ELSE ! no decimal, an integer. leave as is
ResultString=InputString
ENDIF
ELSE ! for now, ignore x.xExx
ResultString=InputString
ENDIF
RETURN
END FUNCTION RemoveTrailingZeros