LOGICAL FUNCTION CURRSTEP( JDATE, JTIME, )
& SDATE, STIME, TSTEP,
& CDATE, CTIME )
INTEGER FUNCTION CURREC ( JDATE, JTIME,
& SDATE, STIME, TSTEP,
& CDATE, CTIME )
INTEGER JDATE ! date (encoded DDDYY)
INTEGER JTIME ! time (encoded HHMMSS)
INTEGER SDATE, STIME ! starting d&t for the sequence
INTEGER TSTEP ! time step for the sequence
INTEGER 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:CTIMEto use as the arguments to READ3() for the last time step before or atJDATE:JTIME(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..
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.
#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
...
INTEGER CDATE, CTIME
...
CALL CURRSTEP( 1988101, 123000,
& 1988100, 0, 10000,
& CDATE, CTIME )
C ==> CDATE:CTIME is 1988101:120000 since this is the start
C ==> of the (1-hour) time step which encloses 12:30:00.
...
...
#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