#ifndef _HDFPODAAC_H #define _HDFPODAAC_H #include /* int32, ...; includes */ typedef struct { void *actualData; int actualDataSize; /* needed? */ int userMemory; /* 1 if user supplied actualData (so don't free()) */ char *objectName; /* needed? */ int32 sds_id; int32 rank; /* 3 */ int32 *dims; /* 720,1440,2 */ int32 *start; /* 0, 0,0 if reading all */ int32 *edges; /* 720,1440,2 if reading all */ int32 data_type; int32 nattrs; float64 scale; float64 offset; int32 vdata_id; /* either this or sds_id is set; other is 0 */ } DTYPE; /* check if an HDF function returned a non-FAIL value; if not, exit */ extern int32 checkHDF(int32 retVal, char *funcName, char *param); /* Regardless of storage type, read all Level 3 variables with this. * INPUTS: * sd_id: value returned from SDstart() * sdsName: name of HDF object * start: location in HDF object to begin reading from. If NULL, use 0,0,... * edges: length of each dimension to read. If NULL, read to end. * actualData: if not NULL, this gest the HDF data; gives user direct access * actualDataSize: number of bytes. If insufficient, exit */ extern DTYPE *openSDS(int32 sd_id, char *sdsname, int32 *start, int32 *edges, void *actualData, int actualDataSize); extern DTYPE *openVdata(int32 v_id, char *name, int32 start, int32 edge, void *actualData, int actualDataSize); extern void closeDTYPE(DTYPE *datatypePtr); /* Before opening the SDS or Vdata, you may want to check if they exist */ extern int existsSDS(int32 sd_id, char *sdsName); extern int existsVdata(int32 sd_id, char *name); /* Access an object via its Conceptual Type, e.g. getReal(). For an * n-dimensional object, set numIndices to n, then provide n indices. * These functions automatically handle the offset (0 for SeaWinds) and scale. */ extern double getReal(DTYPE *data, int numIndices, ... /*array indices*/); #define getInteger (int)getReal #define getUInteger (unsigned int)getReal /* alloc & return 1D array starting at indices (assume 0s if numIndicessds_id #define getDTYPE_VDID(x) x->vdata_id /* probably used to check if vdata */ #define getDTYPE_NAME(x) x->objectName #define getDTYPE_RANK(x) x->rank #define getDTYPE_ATTR(x) x->nattrs #define getDTYPE_DIM(x,d) x->dims[d] #define getDTYPE_DT(x) x->data_type #define getDTYPE_DATA(x) x->actualData /* probably shouldn't do this */ /* metadata/attribute functions */ extern int getAttrInt( DTYPE *data, char *attrName); extern char *getAttrString(DTYPE *data, char *attrName); extern double getAttrDouble(DTYPE *data, char *attrName); extern int getMetaInt( int32 sd_id, char *attrName); extern char *getMetaString(int32 sd_id, char *attrName); extern float getMetaFloat( int32 sd_id, char *attrName); #endif /* _HDFPODAAC_H */