21 #include <HdfEosDef.h> 45 const char *fieldname,
61 const char *fieldname,
99 const char *fieldname,
109 if (filename == NULL)
114 if (hdfstatus ==
FAIL)
119 dimcnt, dimlist, dimsize);
141 const char *gridname,
142 const char *fieldname,
157 char *basefield = NULL;
159 int *extradims = NULL;
172 if (gridname == NULL || fieldname == NULL ||
177 hdfstatus = Gid =
GDattach(Fid,(
char*)gridname);
178 if (hdfstatus ==
FAIL)
181 list = (
char*)malloc(5000 *
sizeof(
char));
189 hdfstatus =
GDfieldinfo(Gid, basefield, &rank, dims, &numbertype, list);
190 if (hdfstatus ==
FAIL)
193 *dimlist = (
char**)calloc(rank,
sizeof(
char*));
194 if (*dimlist == NULL)
196 *dimsize = (
int*)calloc(rank,
sizeof(
int));
197 if (*dimsize == NULL)
200 temp = strtok(list,
",");
204 if ((strncmp(temp,
"SOMBlockDim",
sizeof(*temp))) != 0 &&
205 (strncmp(temp,
"XDim",
sizeof(*temp))) != 0 &&
206 (strncmp(temp,
"YDim",
sizeof(*temp))) != 0) {
207 (*dimlist)[i] = (
char*)malloc((strlen(temp) + 1) *
sizeof(char));
208 if ((*dimlist)[i] == NULL)
210 strcpy((*dimlist)[i],temp);
213 temp = strtok(NULL,
",");
222 for (i = 0; i < *dimcnt; ++i) {
223 (*dimsize)[i] =
GDdiminfo(Gid, (*dimlist)[i]);
227 *dimlist = (
char **)realloc((
void *)*dimlist, *dimcnt *
sizeof(
char*));
228 if (*dimlist == NULL)
230 *dimsize = (
int *)realloc((
void *)*
dimsize, *dimcnt *
sizeof(int));
231 if (*dimsize == NULL)
247 if (dimlist != NULL && *dimlist != NULL)
259 if (basefield != NULL) free(basefield);
260 if (extradims != NULL) free(extradims);
270 const char *gridname,
271 const char *fieldname,
278 char *basefield = NULL;
280 int *extradims = NULL;
295 if (gridname == NULL || fieldname == NULL ||
309 status =
MtkNCVarId(group_id, basefield, &var);
318 dimids = calloc(ndims,
sizeof(
int));
324 *dimlist = calloc(ndims,
sizeof(
char *));
325 *dimsize = calloc(ndims,
sizeof(
int));
328 for (
size_t i = 0 ; i < ndims ; i++) {
330 int this_dimid = dimids[i];
332 int nc_status =
nc_inq_dim(group_id, this_dimid, name, &size);
335 if (0 == strcmp(name,
"X_Dim"))
continue;
336 if (0 == strcmp(name,
"Y_Dim"))
continue;
338 char *this_name = calloc(
sizeof(name),
sizeof(
char));
339 strcpy(this_name, name);
340 (*dimlist)[(*dimcnt)] = this_name;
341 (*dimsize)[(*dimcnt)] =
size;
358 if (dimids != NULL) free(dimids);
359 if (dimlist != NULL && *dimlist != NULL)
371 if (basefield != NULL) free(basefield);
372 if (extradims != NULL) free(extradims);
MTKt_status MtkStringListFree(int strcnt, char **strlist[])
Free string list.
int32 GDattach(int32, char *)
MTKt_status MtkFileGridFieldToDimListHDF(const char *filename, const char *gridname, const char *fieldname, int *dimcnt, char **dimlist[], int **dimsize)
MTKt_status MtkFileGridFieldToDimListNcid(int ncid, const char *gridname, const char *fieldname, int *dimcnt, char **dimlist[], int **dimsize)
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)
HDFFCLIBAPI intf * dimsize
#define MTK_ERR_CODE_JUMP(code)
MTKt_status MtkFileGridFieldToDimListNC(const char *filename, const char *gridname, const char *fieldname, int *dimcnt, char **dimlist[], int **dimsize)
intn GDfieldinfo(int32, char *, int32 *, int32 [], int32 *, char *)
MTKt_status MtkFileGridFieldToDimList(const char *filename, const char *gridname, const char *fieldname, int *dimcnt, char **dimlist[], int **dimsize)
Read dimension list of a particular field.
MTKt_status MtkFileGridFieldToDimListFid(int32 Fid, const char *gridname, const char *fieldname, int *dimcnt, char **dimlist[], int **dimsize)
Version of MtkFileGridFieldToDimList that takes an HDF-EOS file ID rather than a filename.
#define MTK_ERR_COND_JUMP(code)
int32 GDdiminfo(int32, char *)
EXTERNL int nc_inq_varndims(int ncid, int varid, int *ndimsp)
int32 GDopen(char *, intn)
EXTERNL int nc_close(int ncid)
MTKt_status MtkNCVarId(int Ncid, const char *Name, MTKt_ncvarid *Var)
EXTERNL int nc_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
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)