SUBROUTINE LASTTIME( SDATE, STIME, TSTEP, NSTEPS, EDATE, ETIME ) INTEGER, INTENT(IN ) :: SDATE ! date, YYYDDD = 1000*year + day(1...365,6) INTEGER, INTENT(IN ) :: STIME ! time (encoded HHMMSS) INTEGER, INTENT(IN ) :: TSTEP ! timestep (encoded HHMMSS) INTEGER, INTENT(IN ) :: NSTEPS ! number of timesteps INTEGER, INTENT( OUT) :: EDATE ! date, YYYDDD = 1000*year + day(1...365,6) INTEGER, INTENT( OUT) :: ETIME ! time (encoded HHMMSS)
Find the last date & timeEDATE:ETIME
in the time step sequence starting atSDATE:STIME
, with time stepTSTEP
andNSTEPS
time steps. Uses high precision arithemetic internally, so that it is safe for very long (even multi-century) applications.See also subroutines CURRSTEP() and NEXTIME().
USE M3UTILIO
To find the last date&time in a time stepped I/O API file:
... USE M3UTILIO ... INTEGER EDATE, ETIME CHARACTER*256 MESG ... IF ( .NOT.OPEN3( 'MYFILE', FSUNKN3, 'MyProgram' ) ) THEN CALL M3EX(T( 'MyProgram', 0, 0. 'Could not open "MYFILE"', 2 ) ELSE IF ( .NOT.DESC3( 'MYFILE' ) ) THEN CALL M3EX(T( 'MyProgram', 0, 0. 'Could not DESC3 "MYFILE"', 2 ) ELSE ... CALL LASTTIME( SDATE3D,STIME3D,TSTEP3D, MXREC3D, EDATE, ETIME ) WRITE( MESG, '( A, I9.7, A, I6.6 )' ) & '"MYFILE" ending date&time', EDATE, ':', ETIME CALL M3MESG( MESG ) ... END IF ...
Up: Date-Time Manipulation Routines
To: Models-3/EDSS I/O API: The Help Pages