22 #include <HdfEosDef.h> 54 const char *fieldname,
70 const char *fieldname,
89 startblock, endblock, databuf);
108 const char *gridname,
109 const char *fieldname,
127 startblock, endblock, databuf);
148 const char *gridname,
149 const char *fieldname,
164 char *basefield = NULL;
166 int *extradims = NULL;
179 nblocks = endblock - startblock + 1;
181 gid =
GDattach(fid, (
char*)gridname);
187 hdfstatus =
GDfieldinfo(gid, basefield, &rank, dims, &hdf_datatype, dimlist);
199 start[0] = startblock-1;
207 for (i = 3; i <
rank; i++) {
208 start[i] = extradims[i-3];
212 hdfstatus =
GDreadfield(gid, basefield, start, NULL, edge,
219 *databuf = databuf_tmp;
226 if (basefield != NULL) free(basefield);
227 if (extradims != NULL) free(extradims);
234 const char *gridname,
235 const char *fieldname,
242 char *basefield = NULL;
244 int *extradims = NULL;
256 nblocks = endblock - startblock + 1;
266 int block_start_x[180];
267 int block_start_y[180];
277 nc_status =
nc_inq_varid(group_id,
"Block_Number", &bvarid);
281 nc_status =
nc_inq_var(group_id, bvarid, NULL, NULL, NULL, dimid, NULL);
284 size_t file_number_block;
285 nc_status =
nc_inq_dimlen(group_id, dimid[0], &file_number_block);
288 if (file_number_block > 180) {
292 int file_block_numbers[180];
297 nc_status =
nc_inq_varid(group_id,
"Block_Start_X_Index", &xvarid);
305 nc_status =
nc_inq_varid(group_id,
"Block_Start_Y_Index", &yvarid);
313 int start_block_index;
314 for (
size_t i = 0 ; i < file_number_block ; i++) {
315 if (file_block_numbers[i] == startblock) {
317 start_block_index = i;
323 for (
size_t i = 0 ; i < file_number_block ; i++) {
324 if (file_block_numbers[i] == endblock) {
330 for (
int i = 0 ; i < nblocks ; i++) {
331 block_start_x[i] = start_x[start_block_index + i];
332 block_start_y[i] = start_y[start_block_index + i];
346 status =
MtkNCVarId(group_id, basefield, &var);
366 size_t unit_size_bytes = block_size_x * block_size_y * databuf_tmp.
datasize;
367 count[0] = block_size_x;
368 count[1] = block_size_y;
370 for (
int i = 2; i <
rank; i++) {
371 start[i] = extradims[i-2];
375 for (
int i = 0 ; i < nblocks ; i++) {
376 start[0] = block_start_x[i];
377 start[1] = block_start_y[i];
382 *databuf = databuf_tmp;
388 if (basefield != NULL) free(basefield);
389 if (extradims != NULL) free(extradims);
HDFFCLIBAPI intf intf intf * count
MTKt_status MtkNcToMtkDataTypeConvert(nc_type nc_datatype, MTKt_DataType *datatype)
MTKt_status MtkDataBufferAllocate3D(int nblock, int nline, int nsample, MTKt_DataType datatype, MTKt_DataBuffer3D *databuf)
Allocate 3-dimensional Data Buffer (a buffer stack)
HDFFCLIBAPI _fcd _fcd intf intf * datatype
int32 GDattach(int32, char *)
MTKt_status MtkReadBlockRangeNcid(int ncid, const char *gridname, const char *fieldname, int startblock, int endblock, MTKt_DataBuffer3D *databuf)
EXTERNL int nc_get_att(int ncid, int varid, const char *name, void *ip)
HDFFCLIBAPI void intf dims[]
MTKt_status MtkParseFieldname(const char *fieldname, char **basefieldname, int *ndim, int **dimlist)
Parses extra dimensions from fieldnames.
EXTERNL int nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp)
#define MTK_ERR_CODE_JUMP(code)
MTKt_status MtkHdfToMtkDataTypeConvert(int32 hdf_datatype, MTKt_DataType *datatype)
Convert HDF data type to MISR Toolkit data type.
3-dimensional Data Buffer
MTKt_status MtkReadBlockRange(const char *filename, const char *gridname, const char *fieldname, int startblock, int endblock, MTKt_DataBuffer3D *databuf)
Read range of blocks of data into a 3-dimensional array.
EXTERNL int nc_inq_vartype(int ncid, int varid, nc_type *xtypep)
MTKt_status MtkReadBlockRangeNC(const char *filename, const char *gridname, const char *fieldname, int startblock, int endblock, MTKt_DataBuffer3D *databuf)
EXTERNL int nc_get_var_int(int ncid, int varid, int *ip)
intn GDfieldinfo(int32, char *, int32 *, int32 [], int32 *, char *)
EXTERNL int nc_inq_dimlen(int ncid, int dimid, size_t *lenp)
MTKt_status MtkReadBlockRangeHDF(const char *filename, const char *gridname, const char *fieldname, int startblock, int endblock, MTKt_DataBuffer3D *databuf)
HDFFCLIBAPI intf intf start[]
#define MTKT_DATABUFFER3D_INIT
EXTERNL int nc_get_vara(int ncid, int varid, const size_t *startp, const size_t *countp, void *ip)
EXTERNL int nc_inq_varid(int ncid, const char *name, int *varidp)
intn GDreadfield(int32, char *, int32 [], int32 [], int32 [], VOIDP)
#define MTK_ERR_COND_JUMP(code)
EXTERNL int nc_inq_varndims(int ncid, int varid, int *ndimsp)
MTKt_status MtkDataBufferFree3D(MTKt_DataBuffer3D *databuf)
Free 3-dimensional data buffer (a buffer stack)
int32 GDopen(char *, intn)
EXTERNL int nc_close(int ncid)
MTKt_status MtkNCVarId(int Ncid, const char *Name, MTKt_ncvarid *Var)
MTKt_status MtkReadBlockRangeFid(int32 fid, const char *gridname, const char *fieldname, int startblock, int endblock, MTKt_DataBuffer3D *databuf)
Version of MtkReadBlockRange that takes an HDF-EOS file identifier rather than a filename.
EXTERNL int nc_inq_grp_ncid(int ncid, const char *grp_name, int *grp_ncid)
EXTERNL int nc_open(const char *path, int mode, int *ncidp)