READ4D() and read4dc()

Fortran version:

    LOGICAL FUNCTION READ4D( FNAME, VNAME, LAYER, 
   &            JDATE, JTIME, TSTEP, NRECS, BUFFER)
        CHARACTER*(*), INTENT(IN   ) :: FNAME     !  file name for query
        CHARACTER*(*), INTENT(IN   ) :: VNAME     !  vble  name   (or ALLVAR3 (='ALL'))
        INTEGER      , INTENT(IN   ) :: LAYER     !  layer number (or ALLAYS3 (=-1))
        INTEGER      , INTENT(IN   ) :: JDATE     !  starting date, formatted YYYYDDD
        INTEGER      , INTENT(IN   ) :: JTIME     !  starting time, formatted HHMMSS
        INTEGER      , INTENT(IN   ) :: TSTEP     !  time step,     formatted HHMMSS
        INTEGER      , INTENT(IN   ) :: NRECS     !  number of time step records to read
        <type>       , INTENT(  OUT) :: BUFFER(*) !  array to hold input

C version:

read4dc() is a C wrapper calling the Fortran READ4D()
    int read4dc( const char * fname ,
                 const char * vname ,
                 int          layer ,
                 int          jdate ,
                 int          jtime ,
                 int          tstep ,
                 int          nrecs ,
                 void       * buffer )

Summary:

Reads data for the specified LAYER of the variable with name VNAME, for the time step sequence with NRECS time steps of data starting at JDATE (coded YYYYDDD), JTIME (HHMMSS), with time step TSTEP, to Models-3 data file with logical name FNAME. Supported only for single-variable reads from disk-resident time-stepped files of types CUSTOM , GRIDDED , or BOUNDARY . If LAYER is the "magic number " ALLAYS3 (= -1, defined in PARMS3.EXT), reads all layers.

Returns .TRUE. (or 1) if the entire operation succeeds, .FALSE. (or 0) if it fails. For failure, writes a log message indicating the nature of the failure.

Preconditions:

INCLUDE 'IODECL3.EXT' and INCLUDE 'FDESC3.EXT' for Fortran, or #include "iodecl3.h" and #include "fdesc3.h" for C.

FNAME must be a time-stepped disk-resident file already have been opened by OPEN3() or open3c(), that contains the entire requested time step sequence of the requested variable.

FNAME must have one of the file types CUSTOM , GRIDDED , or BOUNDARY .

I/O API must already be initialized by a call to INIT3() .

FNAME and VNAME must have length at most 16. VNAME must be the name of a variable in FNAME, and LAYER must be either a layer within the range of dimensions for FNAME, or must be ALLAYS3.

FNAME must already have been opened by OPEN3() or open3c() .

JDATE, JTIME, and TSTEP must be expressed in terms of Models-3 date and time conventions. JDATE:JTIME must be an exact positive integer multiple of the file's time step from the file's starting date and time. TSTEP must be an exact positive integer multiple of the file's time step. Data for the entire specified time step sequence of VNAME must already be stored in FNAME.

Dimensionality of the BUFFER argument should agree with I/O API conventions for the dimensionality of the data being written. In particular,he time step record subscript is the "slowest" subscript in the buffer. (I.e., Fortran subscripting for BUFFER should be BUFFER( ..., [LAYER,], TIMESTEP-RECORD ).)

See Also:

Fortran Usage:

    ...
    USE M3UTILIO
    ...
    INTEGER NCOLS, NROWS, NLAYS, NRECS
    PARAMETER ( NCOLS = ??, NROWS = ??, NLAYS = ??, NRECS = 10 )
    ...
    REAL  HNO3( NCOLS, NROWS, NRECS )
    REAL  SO4( NCOLS, NROWS, NLAYS, NRECS )
    ...
    IF ( READ4D( 'MYFILE', 'HNO3', 3, 1988021, 123000, 3000, NRECS,
 &              HNO3 ) THEN
C            Layer 3 time-step sequence of variable 'HNO3' starting
C            at 12:30:00 Jan 21, 1988 and having NRECS=10 30-minute 
C            time steps read from MYFILE into array HNO3.
        ...
    ELSE
C           Error:  see program log for further info.
        ...
    END IF
    ...
    IF ( READ4D( 'AFILE', 'SO4', ALLAYS3, 1988021, 123000, 10000, NRECS, 
 &              SO4 ) ) THEN
C            Time-step sequence for all layers of SO4 for starting at
C            12:30:00 Jan 21, 1988 and having NRECS=10 hourly 
C            time steps read from AFILE and placed into array SO4
        ...
    ELSE
C           Error:  see program log for further info.
        ...
    END IF
    ...
    IF ( READ4D( 'BFILE', ALLVAR3, ALLAYS3, 1988021, 123000, METS ) ) THEN
C            All BFILE-variables (all layers) for 12:30:00 Jan 21, 1988 
C            read into array METS.
        ...
    ELSE
C           Error:  see program log for further info.
        ...
    END IF
    ...

C Usage:

    ...
    #include "iodecl3.h"
    ...
    float  so4[ NRECS ][ NLAYS ][ NROWS ][ NCOLS ] ;
    ...
    if ( read4dc( "BFILE", "SO4", ALLAYS3, 
                  1988021, 123000, 10000, NRECS, so4 ) )
        {
            /*  Time-step sequence for all layers of SO4 for starting
C               at 12:30:00 Jan 21, 1988 and having NRECS=10 hourly 
C               time steps read from AFILE and placed into array SO4    */
        ...
        }
    else
        {
            /*  Error:  see program log for further info.  */
        ...
        }
    ...


Previous: IOPARMS3

Next: WRITE4D

Up: I/O API: Public Routines

To: Models-3/EDSS I/O API: The Help Pages