LOGICAL FUNCTION CURRSTEP( JDATE, JTIME,
& SDATE, STIME, TSTEP,
& CDATE, CTIME )
INTEGER FUNCTION CURREC ( JDATE, JTIME,
& SDATE, STIME, TSTEP,
& CDATE, CTIME )
INTEGER, INTENT(IN ) :: JDATE ! date (encoded DDDYY)
INTEGER, INTENT(IN ) :: JTIME ! time (encoded HHMMSS)
INTEGER, INTENT(IN ) :: SDATE, STIME ! starting d&t for the sequence
INTEGER, INTENT(IN ) :: TSTEP ! time step for the sequence
INTEGER, INTENT( OUT) :: CDATE, CTIME ! d&t for timestep of
int currstepc( int jdate , int jtime ,
int sdate , int stime , int tstep,
int *cdate , int *ctime )
Useful with READ3() and XTRACT3() -- if a file has time step sequence withSDATE, STIME, TSTEPand you want to read the data relevant toJDATE:JTIME, then you want to use CURRSTEP() to find theCDATE:CTIME, which will be the last time step at or beforeJDATE:JTIME, to use as the arguments to READ3() (and possibly read the next time step from that file as well, if you're doing interpolation). Returns TRUE if and only if this is possible (and it succeeded in computingCDATE:CTIME.
For Fortran-90 declarations and interface checking:USE M3UTILIO
CURRSTEPcomputes the date&timeCDATE:CTIMEandCURRECcomputes the record-number 1, 2, 3, ... for the time step enclosingJDATE:JTIMEin the time step sequence starting atSDATE:STIMEand having time step| TSTEP |(absolute values, in order to deal with restart files easily). In particular,CDATE:CTIMEis date&time of the largest timestep in the sequence having the property:CDATE:CTIME <= JDATE:JTIMECURRSTEPreturns.TRUE.,CURRRECreturns positive result, andcurrstepcreturns 1 iffJDATE:JTIMEis within a time step starting atSDATE:STIME(i.e., ifTSTEPis nonzero this means thatJDATE:JTIMEis later thanSDATE:STIME.) Otherwise, these return.FALSE., -1, or0respectively.See also subroutine JSTEP3() that computes (Fortran style 1,2,...) record numbers for
JDATE:JTIMEwithin the time step sequenceSDATE:STIME:TSTEP.These routines are carefully coded to avoid
INTEGERoverflow in the intermediate calculations, and can be used for runs having durations even measured in millenia.
#include "iodecl3.h"if called from C.dates and times represented according to Models-3 conventions:
DATEs are YYYYDDD = YEAR*1000 + DAY
TIMEs are HHMMSS = HOUR*10000 + MINS*100 + SECS
...
USE M3UTILIO
...
INTEGER CDATE, CTIME, IREC
...
IREC = CURRSTEP( 1988101, 123000,
& 1988100, 0, 10000,
& CDATE, CTIME )
!! ==> CDATE:CTIME is 1988101:120000 since this is the start
!! ==> of the (1-hour) time step which encloses 12:30:00.
...
IF ( IREC .LT. 0 ) THEN
!! ...error: request before start of time step sequence
END IF
...
#include "iodecl3.h"
...
int jdate, jtime, sdate, stime, tstep, cdate, ctime ;
...
/* get jdate, jtime;
get sdate, stime, tstep relevant to file "foo" */
if ( currstepc( jdate, jtime,
sdate, stime, tstep,
&cdate, &ctime ) )
{
/* CAN read3c() the data for cdate:ctime from "foo" */
if read3c( "foo", "bar", ALLAYS3, cdate, ctime, buffer ) ) { ... }
else{ ... }
}
else
{
/* CANNOT read3c( "foo", ... ) --
there is no legal date&time for "foo" just before jdate:jtime */
}
...
Up: Date-Time Manipulation Routines
To: Models-3/EDSS I/O API: The Help Pages