Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64), | intent(in) | :: | Time | |||
integer, | intent(out) | :: | Hours | |||
integer, | intent(out) | :: | Minutes | |||
real(kind=r64), | intent(out) | :: | Seconds |
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.
SUBROUTINE ParseTime( Time, Hours, Minutes, Seconds )
! FUNCTION INFORMATION:
! AUTHOR Dimitri Curtil
! DATE WRITTEN January 2005
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This subroutine decomposes a time value specified in seconds
! into a triplet { hours : minutes : seconds } such that
! - minutes < 60
! - seconds < 60
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
REAL(r64), INTENT(IN) :: Time ! Time value in seconds
INTEGER, INTENT(OUT) :: Hours ! Number of hours
INTEGER, INTENT(OUT) :: Minutes ! Number of minutes < 60
REAL(r64), INTENT(OUT) :: Seconds ! Number of seconds < 60
! SUBROUTINE PARAMETER DEFINITIONS:
REAL(r64), PARAMETER :: MinToSec = 60.0d0
REAL(r64), PARAMETER :: HourToSec = MinToSec * 60.0d0
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: Remainder = 0.0d0
! Get number of hours
! This might undershoot the actual number of hours. See DO WHILE loop.
Hours = INT( Time/HourToSec )
! Compute remainder in seconds
Remainder = (Time - Hours*3600.0d0)
! Correct number of hours whenever Remainder >= 60 to fix round-off errors
! E.g., Time = 2.0 would return Hours=1 and Minutes=60 instead of Hours=2!
DO WHILE ( ANINT(Remainder/MinToSec,r64) .GE. 60.0d0 )
Hours = Hours + 1
Remainder = (Time - Hours*3600.0d0)
END DO
! Compute minutes
Minutes = INT(Remainder/MinToSec)
! Compute remainder in seconds
Remainder = (Time - Hours*3600.0d0 - Minutes*60.0d0)
! Correct number of minutes whenever Remainder >= 60 to fix round-off errors
DO WHILE ( ANINT(Remainder,r64) .GE. 60.0d0 )
Minutes = Minutes + 1
Remainder = (Time - Hours*3600.0d0 - Minutes*60.0d0)
END DO
! Compute seconds
Seconds = Remainder
RETURN
END SUBROUTINE ParseTime