21 #include <HdfEosDef.h> 100 if (filename == NULL)
142 if (gridlist == NULL)
158 list = (
char*)malloc((strbufsize + 1) *
sizeof(char));
163 status = num_grids =
GDinqgridfid(fid, list, &strbufsize);
168 *gridlist = (
char**)calloc(num_grids,
sizeof(
char*));
169 if (*gridlist == NULL)
172 temp = strtok(list,
",");
176 (*gridlist)[i] = (
char*)malloc((strlen(temp) + 1) *
sizeof(char));
177 if ((*gridlist)[i] == NULL)
179 strcpy((*gridlist)[i],temp);
180 temp = strtok(NULL,
",");
189 if (gridlist != NULL)
207 int *group_ids = NULL;
210 if (gridlist == NULL)
221 int nc_status =
nc_inq_grps(ncid, &num_groups, NULL);
224 group_ids = (
int *)calloc(num_groups,
sizeof(
int));
228 *gridlist = (
char**)calloc(num_groups,
sizeof(
char*));
229 if (*gridlist == NULL)
232 for (
int i = 0 ; i < num_groups ; i++) {
233 int group_id = group_ids[i];
240 if (nc_status !=
NC_NOERR)
continue;
242 (*gridlist)[num_grids] = (
char*)malloc((strlen(temp) + 1) *
sizeof(char));
243 if ((*gridlist)[num_grids] == NULL)
245 strcpy((*gridlist)[num_grids],temp);
257 if (gridlist != NULL)
263 if (group_ids != NULL) {
290 intn hdf_status_code;
294 hdf_status_code =
EHidinfo(fid, &HDFfid, &sid);
295 if (hdf_status_code ==
FAIL)
305 if (strbufsize != NULL)
319 vgRef =
Vgetid(HDFfid, vgRef);
329 vGrpID =
Vattach(HDFfid, vgRef,
"r");
336 if (strcmp(
class,
"GRID") == 0)
346 if (objectlist != NULL)
350 strcpy(objectlist, name);
353 strcat(objectlist,
",");
354 strcat(objectlist, name);
359 slen = (nobj == 1) ? strlen(name) : strlen(name) + 1;
364 if (strbufsize != NULL)
MTKt_status MtkStringListFree(int strcnt, char **strlist[])
Free string list.
MTKt_status MtkFileToGridList(const char *filename, int *ngrids, char **gridlist[])
Read list of grids from a file.
#define MTK_ERR_CODE_JUMP(code)
HDFLIBAPI int32 Vgetid(HFILEID f, int32 vgid)
MTKt_status MtkFileToGridListHDF(const char *filename, int *ngrids, char **gridlist[])
HDFLIBAPI int32 Vdetach(int32 vkey)
EXTERNL int nc_inq_att(int ncid, int varid, const char *name, nc_type *xtypep, size_t *lenp)
HDFLIBAPI int32 Vgetclass(int32 vkey, char *vgclass)
HDFLIBAPI int32 Vattach(HFILEID f, int32 vgid, const char *accesstype)
MTKt_status MtkFileToGridListFid(int32 fid, int *ngrids, char **gridlist[])
Version of MtkFileToGridList that takes an HDF-EOS file identifier rather than a filename.
EXTERNL int nc_inq_grps(int ncid, int *numgrps, int *ncids)
EXTERNL int nc_inq_grpname(int ncid, char *name)
intn EHidinfo(int32, int32 *, int32 *)
HDFLIBAPI int32 Vgetname(int32 vkey, char *vgname)
MTKt_status MtkFileToGridListNC(const char *filename, int *ngrids, char **gridlist[])
MTKt_status MtkFileToGridListNcid(int ncid, int *ngrids, char **gridlist[])
#define MTK_ERR_COND_JUMP(code)
int32 GDopen(char *, intn)
EXTERNL int nc_close(int ncid)
EXTERNL int nc_open(const char *path, int mode, int *ncidp)
int32 GDinqgridfid(int32 fid, char *objectlist, int32 *strbufsize)
Replacement for HDF-EOS GDinqgrid that takes an HDF-EOS file id rather than a filename.