21 #include <HdfEosDef.h> 101 if (filename == NULL)
106 if (hdfstatus ==
FAIL)
115 if (hdfstatus ==
FAIL)
134 const char *gridname,
141 int32 num_fields = 0;
145 int32 str_buffer_size = 0;
148 if (fieldlist == NULL)
154 if (gridname == NULL)
161 hdfstatus = Gid =
GDattach(Fid,(
char*)gridname);
162 if (hdfstatus ==
FAIL)
167 if(hdfstatus ==
FAIL)
170 list = (
char*)malloc((str_buffer_size + 1) *
sizeof(char));
175 hdfstatus = num_fields =
GDinqfields(Gid,list,NULL,NULL);
176 if (hdfstatus ==
FAIL)
179 *nfields = num_fields;
180 *fieldlist = (
char**)calloc(num_fields,
sizeof(
char*));
181 if (*fieldlist == NULL)
184 temp = strtok(list,
",");
188 (*fieldlist)[i] = (
char*)malloc((strlen(temp) + 1) *
sizeof(char));
189 if ((*fieldlist)[i] == NULL)
191 strcpy((*fieldlist)[i],temp);
192 temp = strtok(NULL,
",");
199 if (hdfstatus ==
FAIL)
205 if (fieldlist != NULL)
219 const char *gridname,
224 int32 num_fields = 0;
226 int *group_ids = NULL;
229 if (fieldlist == NULL)
235 if (gridname == NULL)
242 int nc_status =
nc_inq_ncid(ncid, gridname, &group_id);
250 group_ids = (
int *)calloc(ngroups,
sizeof(
int));
251 group_ids[0] = group_id;
254 nc_status =
nc_inq_grps(group_id, NULL, group_ids+1);
258 for (
int i = 0 ; i < ngroups ; i++) {
259 int group_id = group_ids[i];
275 varids = (
int *)calloc(nvars,
sizeof(
int));
281 int start = num_fields;
283 *nfields = num_fields;
284 *fieldlist = (
char**)realloc(*fieldlist, num_fields *
sizeof(
char*));
285 if (*fieldlist == NULL) {
289 for (
int i = 0 ; i < nvars ; i++) {
290 int ifield = i +
start;
291 int varid = varids[i];
299 (*fieldlist)[ifield] = (
char*)calloc(strlen(group_name) + strlen(temp) + 2,
sizeof(char));
300 if ((*fieldlist)[ifield] == NULL) {
303 strcpy((*fieldlist)[ifield],group_name);
304 if (strlen(group_name) > 0) {
305 strcat((*fieldlist)[ifield],
"/");
307 strcat((*fieldlist)[ifield],temp);
319 if (fieldlist != NULL)
325 if (varids != NULL) {
329 if (group_ids != NULL) {
MTKt_status MtkStringListFree(int strcnt, char **strlist[])
Free string list.
int32 GDattach(int32, char *)
EXTERNL int nc_inq_varids(int ncid, int *nvars, int *varids)
int32 GDinqfields(int32, char *, int32 [], int32 [])
#define MTK_ERR_CODE_JUMP(code)
MTKt_status MtkFileGridToNativeFieldListHDF(const char *filename, const char *gridname, int *nfields, char **fieldlist[])
EXTERNL int nc_inq_ncid(int ncid, const char *name, int *grp_ncid)
EXTERNL int nc_inq_grps(int ncid, int *numgrps, int *ncids)
int32 GDnentries(int32, int32, int32 *)
EXTERNL int nc_inq_grpname(int ncid, char *name)
HDFFCLIBAPI intf intf start[]
MTKt_status MtkFileGridToNativeFieldListNC(const char *filename, const char *gridname, int *nfields, char **fieldlist[])
MTKt_status MtkFileGridToNativeFieldList(const char *filename, const char *gridname, int *nfields, char **fieldlist[])
Read list of native fields from file (excludes derived fields)
#define MTK_ERR_COND_JUMP(code)
MTKt_status MtkFileGridToNativeFieldListNcid(int ncid, const char *gridname, int *nfields, char **fieldlist[])
int32 GDopen(char *, intn)
EXTERNL int nc_close(int ncid)
EXTERNL int nc_inq_varname(int ncid, int varid, char *name)
EXTERNL int nc_open(const char *path, int mode, int *ncidp)
MTKt_status MtkFileGridToNativeFieldListFid(int32 Fid, const char *gridname, int *nfields, char **fieldlist[])
Version of MtkFileGridToNativeFieldList that takes an HDF-EOS file identifier rather than a filename...