LOGICAL FUNCTION KFREAD( FNAME, VNAME, EVENT,
& COL, ROW, SDATE, STIME, KFLEN, VBLE )
CHARACTER*(*), INTENT(IN ) :: FNAME ! logical file name
CHARACTER*(*), INTENT(IN ) :: VNAME ! variable name, or 'ALL'
INTEGER , INTENT(IN ) :: EVENT ! KF-cloud event number
INTEGER , INTENT(IN ) :: COL ! column number for this event
INTEGER , INTENT(IN ) :: ROW ! row number for this event
INTEGER , INTENT(IN ) :: SDATE ! starting date, formatted YYYYDDD
INTEGER , INTENT(IN ) :: STIME ! starting time, formatted HHMMSS
INTEGER , INTENT( OUT) :: KFLEN ! event duration, formatted HHMMSS
REAL , INTENT( OUT) :: VBLE(*) ! array of returned values for VNAME
FNAME,
along with the event's description:
COL is the grid-column for this event.
ROW is the grid-row.
SDATE is the
event starting date, formatted YYYYDDD
STIME is the
event starting time, formatted HHMMSS
KFLEN is the
event event duration, formatted HHMMSS
VBLE(NLAYS3D) is the array of
values for variable VNAME at this event
(or VBLE(NLAYS3D,NVARS3D)
for the ALLVARS3 case).
ALLVARS3
(= 'ALL', defined in
PARMS3.EXT), reads all
variables for this event.
Returns .TRUE. (or 1) if the operation succeeds, .FALSE. (or 0) if it fails. For failure, writes a log message indicating the nature of the failure.
KFREAD() is OpenMP thread-safe.
INCLUDE 'IODECL3.EXT'
and
INCLUDE 'FDESC3.EXT' for Fortran.
I/O API must already be initialized by a call to INIT3() .
FNAME must have length at most 16.
FNAME must already have been opened by OPEN3() or KFOPEN().
Dimensionality of the VBLE
argument should be at least the NLAYS3D for the
file FNAME for the single-variable case), or
NLAYS3D*NVARS3D for the ALLVARS3 case.
...
INCLUDE 'IODECL3.EXT'
INCLUDE 'PARMS3.EXT'
...
INTEGER NCOLS, NROWS, NLAYS, NTHIK
PARAMETER ( NCOLS = ??, NROWS = ??, NLAYS = ??, NTHIK = ?? )
...
INTEGER ECOUNT ! # of events for this col-row
INTEGER SDATES(NTHIK) ! starting date, formatted YYYYDDD
INTEGER STIMES(NTHIK) ! starting time, formatted HHMMSS
INTEGER KFLENS(NTHIK) ! event duration, formatted HHMMSS
INTEGER EVENTS(NTHIK) ! event numbers
REAL TA(NLAYS) ! buffer for variable 'TA'
INTEGER C, R, I, IEVENT, ISECS, IDIFF
INTEGER COL, ROW, SDATE, STIME, KFLEN
INTEGER JDATE, JTIME
...
DO R = 1, NROWS
DO C = 1, NCOLS
IF ( KFINDX( 'MYFILE', C, R,
& ECOUNT, SDATES, STIMES, KFLENS, EVENTS ) THEN
!! For I=1 to ECOUNT, there are KF-events at (C,R),
!! with time periods starting at SDATES(I),STIMES(I),
!! durations KFLENS(I) and event numbers EVENTS(I)
!! (for use with KFREAD(), below)
...
ELSE
!! Error: see program log for further info.
...
GO TO 999
END IF
!! Check and see if any event returned by KFINDX() is
!! active at JDATE:JTIME. If so, read and process it:
DO I = 1, ECOUNT
ISECS = TIME2SEC( KFLENS(I) )
IDIFF = SECSDIFF( SDATES(I), STIMES(I), JDATE, JTIME )
IEVENT= EVENTS(I)
IF ( IDIFF .GE. 0 .AND. IDIFF .LT. ISECS ) THEN
IF ( KFREAD( 'MYFILE', 'TA', IEVENT,
& COL, ROW, SDATE, STIME, KFLEN, TA ) ) THEN
!! process this event.
!! note that the returned COL, ROW, SDATE, STIME, KFLEN
!! are redundant for this particular algorithm
....
ELSE
!! Error: see program log for further info.
...
GO TO 999
END IF ! if kfread() succeeded
END IF ! if event active for count I
GO TO 999 ! done processing this loop
END DO ! end loop on events I at this cell
999 CONTINUE ! exit from search loop on I (etc.)
END DO
END DO
...
To: Models-3/EDSS I/O API: The Help Pages