gpgetvar, gpputvar, gpgetscaled, gpputscaled - TDF variable I/O functions

SYNOPSIS

#include <gp.h>

int gpgetvar(var, start, count, value)
VARP var;
int start[], count[];
char *value;

int gpputvar(var, start, count, value)
VARP var;
int start[], count[];
char *value;

int gpgetscaled(var, start, count, value)
VARP var;
int start[], count[];
double *value;

int gpputscaled(var, start, count, value)
VARP var;
int start[], count[];
double *value;

DESCRIPTION

The functions described here read and write hypercubes of TDF variable data. The hypercube is defined by a 0-relative starting coordinate,

( start[0], start[1], ..., start[n-1] )

and a size

( count[0], count[1], ..., count[n-1] )

where n is the number of variable dimensions. As a convenience, the following are defined in include/gp.h:

Specifies starting coordinate (0,0,...,0)

Specifies hypercube extending from the starting coordinate to end of data for the variable

Specifies a 1-element hypercube

gpgetvar reads data for variable var into value.

gpputvar writes data for variable var from value.

gpgetscaled reads data for variable var and scales it before storing it in value. The scaling is performed as follows:


value[i] = (raw[i] == var->badval) ? GP_BAD_DOUBLE :
           (raw[i] <  var->usemin) ? GP_BAD_DOUBLE :
           (raw[i] >  var->usemax) ? GP_BAD_DOUBLE :

           var->scale * raw[i] + var->offset;

gpputscaled scales the data stored in value prior to writing it to disk. The data in value is replaced by the scaled data.


scaled[i] = (value[i] == GP_BAD_DOUBLE) ? var->badval :
            (value[i] <  datatypemin) ? var->badval :
            (value[i] >  datatypemax) ? var->badval :

            (value[i] - var->offset) / var->scale;

where datatypemin and datatypemax are selected based on var->type.

RETURN VALUES

All functions return 0 if successful. Otherwise they call *gperr() with the appropriate error code and return -1.

ERRORS

Variable is stored in file opened as read-only.

Hypercube lies beyond variable dimension bounds.

Ran out of space on disk during write

End of file encountered before reading hypercube

Invalid variable pointer passed by application.

Scaled I/O not supported for string-value data.

FILES

include/gp.h, /usr/include/errno.h, lib/libcdf.a

SEE ALSO

gpatt, gpdim, gperr, gplink, gpname, gprel, gpset, gptype, gpvar, datasets

NOTES

None.


Last Update: $Date: 2001/12/14 21:22:09 $