best_iolen, next_iolen - TDF dataset best/next I/O length package.

SYNOPSIS


#include "terrno.h"
#include "gp.h"

int best_iolen(var, type, nvars, start, count, data)
VARP var;
int type;
int nvars;
int start[];
int count[];
char **data;

int next_iolen(var, start, count)
VARP var;
int start[];
int count[];

DESCRIPTION

These two functions provide a package for determining optimal I/O lengths for efficiently looping through all elements of a variable. Given a variable var and a type, best_iolen initializes start and count for the most efficient looping of the variable's elements and allocates space for the data that is to be read in. nvars gives the number of like-variables to be maintained in memory. next_iolen increments the start and count arrays for the next I/O call. type will usually be the variable's datatype, i.e. var->type, for the case of using gpgetvar, or will be GP_DOUBLE, for the case of using gpgetscaled.

RETURN VALUES

best_iolen and next_iolen functions return the number of I/O elements to be processed if successful. Otherwise they return -1 and set terrno to the appropriate error code. next_iolen returns 0 when all elements in the dimensions space have been included.

EXAMPLE

For computing the sum of two like-size & like-type variables, var1 and var2.

iolen = best_iolen(var1, var1->type, 2, start, count, data1)

    /* data1 and data2 have type var1->type */
data2 = data1 + iolen;

  while (iolen > 0) {
     :
     (void) gpgetvar(var1, start, count (char *)data1);
     (void) gpgetvar(var2, start, count (char *)data2);

	/* add up values for each variable */
     for (i == 0; i < iolen; i++) {
        sum1 += data1[i];
        sum2 += data2[i];
     }

  iolen = next_iolen(var1, start, count)
  }

free(data1);

FILES

include/gp.h, include/terrno.h, lib/libapp.a

SEE ALSO

gpvar, gpgetvar, gpgetscaled, datasets


Last Update: $Date: 1999/05/10 20:56:51 $