Commit 2f84ae5f authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge declaration and definition.

parent 6c641d6b
...@@ -2895,17 +2895,17 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int ...@@ -2895,17 +2895,17 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
} }
struct varinfo struct cdf_varinfo
{ {
int ncvarid; int varid;
const char *name; const char *name;
}; };
static static
int cmpvarname(const void *s1, const void *s2) int cdf_cmp_varname(const void *s1, const void *s2)
{ {
const struct varinfo *x = (const struct varinfo *)s1, const struct cdf_varinfo *x = (const struct cdf_varinfo *)s1,
*y = (const struct varinfo *)s2; *y = (const struct cdf_varinfo *)s2;
return strcmp(x->name, y->name); return strcmp(x->name, y->name);
} }
...@@ -2918,19 +2918,19 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model ...@@ -2918,19 +2918,19 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
if ( streamptr->sortname ) if ( streamptr->sortname )
{ {
struct varinfo *varInfo struct cdf_varinfo *varInfo
= (struct varinfo *) Malloc((size_t)nvars * sizeof (struct varinfo)); = (struct cdf_varinfo *) Malloc((size_t)nvars * sizeof(struct cdf_varinfo));
for ( int varID = 0; varID < nvars; varID++ ) for ( int varID = 0; varID < nvars; varID++ )
{ {
int ncvarid = varids[varID]; int ncvarid = varids[varID];
varInfo[varID].ncvarid = ncvarid; varInfo[varID].varid = ncvarid;
varInfo[varID].name = ncvars[ncvarid].name; varInfo[varID].name = ncvars[ncvarid].name;
} }
qsort(varInfo, (size_t)nvars, sizeof(varInfo[0]), cmpvarname); qsort(varInfo, (size_t)nvars, sizeof(varInfo[0]), cdf_cmp_varname);
for ( int varID = 0; varID < nvars; varID++ ) for ( int varID = 0; varID < nvars; varID++ )
{ {
varids[varID] = varInfo[varID].ncvarid; varids[varID] = varInfo[varID].varid;
} }
Free(varInfo); Free(varInfo);
if ( CDI_Debug ) if ( CDI_Debug )
......
...@@ -424,10 +424,9 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d ...@@ -424,10 +424,9 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d
if ( varInqInst(varID) == CDI_UNDEFID ) if ( varInqInst(varID) == CDI_UNDEFID )
{ {
int center, subcenter, instID; int center = ISEC1_CenterID;
center = ISEC1_CenterID; int subcenter = ISEC1_SubCenterID;
subcenter = ISEC1_SubCenterID; int instID = institutInq(center, subcenter, NULL, NULL);
instID = institutInq(center, subcenter, NULL, NULL);
if ( instID == CDI_UNDEFID ) if ( instID == CDI_UNDEFID )
instID = institutDef(center, subcenter, NULL, NULL); instID = institutDef(center, subcenter, NULL, NULL);
varDefInst(varID, instID); varDefInst(varID, instID);
...@@ -435,8 +434,7 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d ...@@ -435,8 +434,7 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d
if ( varInqModel(varID) == CDI_UNDEFID ) if ( varInqModel(varID) == CDI_UNDEFID )
{ {
int modelID; int modelID = modelInq(varInqInst(varID), ISEC1_ModelID, NULL);
modelID = modelInq(varInqInst(varID), ISEC1_ModelID, NULL);
if ( modelID == CDI_UNDEFID ) if ( modelID == CDI_UNDEFID )
modelID = modelDef(varInqInst(varID), ISEC1_ModelID, NULL); modelID = modelDef(varInqInst(varID), ISEC1_ModelID, NULL);
varDefModel(varID, modelID); varDefModel(varID, modelID);
...@@ -444,10 +442,7 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d ...@@ -444,10 +442,7 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d
if ( varInqTable(varID) == CDI_UNDEFID ) if ( varInqTable(varID) == CDI_UNDEFID )
{ {
int tableID; int tableID = tableInq(varInqModel(varID), ISEC1_CodeTable, NULL);
tableID = tableInq(varInqModel(varID), ISEC1_CodeTable, NULL);
if ( tableID == CDI_UNDEFID ) if ( tableID == CDI_UNDEFID )
tableID = tableDef(varInqModel(varID), ISEC1_CodeTable, NULL); tableID = tableDef(varInqModel(varID), ISEC1_CodeTable, NULL);
varDefTable(varID, tableID); varDefTable(varID, tableID);
......
...@@ -430,11 +430,11 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -430,11 +430,11 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
int vlistID = streamptr->vlistID; int vlistID = streamptr->vlistID;
int tsID = streamptr->curTsID; int tsID = streamptr->curTsID;
int recID = recordNewEntry(streamptr, tsID); int recID = recordNewEntry(streamptr, tsID);
record_t *record = &streamptr->tsteps[tsID].records[recID]; record_t *record = &streamptr->tsteps[tsID].records[recID];
int tsteptype = gribapiGetTsteptype(gh); int tsteptype = gribapiGetTsteptype(gh);
// numavg = ISEC1_AvgNum; // numavg = ISEC1_AvgNum;
int numavg = 0; int numavg = 0;
// fprintf(stderr, "param %d %d %d %d\n", param, level1, level2, leveltype1); // fprintf(stderr, "param %d %d %d %d\n", param, level1, level2, leveltype1);
...@@ -504,10 +504,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -504,10 +504,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
unsigned char uuid[CDI_UUID_SIZE]; unsigned char uuid[CDI_UUID_SIZE];
long lpar; long lpar;
GRIB_CHECK(grib_get_long(gh, "NV", &lpar), 0); GRIB_CHECK(grib_get_long(gh, "NV", &lpar), 0);
if ( lpar != 6 ) if ( lpar != 6 ) fprintf(stderr, "Warning ...\n");
{
fprintf(stderr, "Warning ...\n");
}
GRIB_CHECK(grib_get_long(gh, "nlev", &lpar), 0); GRIB_CHECK(grib_get_long(gh, "nlev", &lpar), 0);
int nhlev = (int)lpar; int nhlev = (int)lpar;
GRIB_CHECK(grib_get_long(gh, "numberOfVGridUsed", &lpar), 0); GRIB_CHECK(grib_get_long(gh, "numberOfVGridUsed", &lpar), 0);
...@@ -572,12 +569,11 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -572,12 +569,11 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
if ( grib_get_long(gh, "productDefinitionTemplateNumber", &productDefinitionTemplate) == 0 ) if ( grib_get_long(gh, "productDefinitionTemplateNumber", &productDefinitionTemplate) == 0 )
varDefProductDefinitionTemplate(varID, (int) productDefinitionTemplate); varDefProductDefinitionTemplate(varID, (int) productDefinitionTemplate);
int i;
long lval; long lval;
double dval; double dval;
if (lread_additional_keys) if (lread_additional_keys)
for ( i = 0; i < cdiNAdditionalGRIBKeys; i++ ) for ( int i = 0; i < cdiNAdditionalGRIBKeys; i++ )
{ {
/* note: if the key is not defined, we do not throw an error! */ /* note: if the key is not defined, we do not throw an error! */
if ( grib_get_long(gh, cdiAdditionalGRIBKeys[i], &lval) == 0 ) if ( grib_get_long(gh, cdiAdditionalGRIBKeys[i], &lval) == 0 )
...@@ -589,10 +585,9 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -589,10 +585,9 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
if ( varInqInst(varID) == CDI_UNDEFID ) if ( varInqInst(varID) == CDI_UNDEFID )
{ {
long center, subcenter; long center, subcenter;
int instID;
GRIB_CHECK(grib_get_long(gh, "centre", &center), 0); GRIB_CHECK(grib_get_long(gh, "centre", &center), 0);
GRIB_CHECK(grib_get_long(gh, "subCentre", &subcenter), 0); GRIB_CHECK(grib_get_long(gh, "subCentre", &subcenter), 0);
instID = institutInq((int)center, (int)subcenter, NULL, NULL); int instID = institutInq((int)center, (int)subcenter, NULL, NULL);
if ( instID == CDI_UNDEFID ) if ( instID == CDI_UNDEFID )
instID = institutDef((int)center, (int)subcenter, NULL, NULL); instID = institutDef((int)center, (int)subcenter, NULL, NULL);
varDefInst(varID, instID); varDefInst(varID, instID);
...@@ -600,12 +595,11 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -600,12 +595,11 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
if ( varInqModel(varID) == CDI_UNDEFID ) if ( varInqModel(varID) == CDI_UNDEFID )
{ {
int modelID;
long processID; long processID;
if ( grib_get_long(gh, "generatingProcessIdentifier", &processID) == 0 ) if ( grib_get_long(gh, "generatingProcessIdentifier", &processID) == 0 )
{ {
/* FIXME: assert(processID >= INT_MIN && processID <= INT_MAX) */ /* FIXME: assert(processID >= INT_MIN && processID <= INT_MAX) */
modelID = modelInq(varInqInst(varID), (int)processID, NULL); int modelID = modelInq(varInqInst(varID), (int)processID, NULL);
if ( modelID == CDI_UNDEFID ) if ( modelID == CDI_UNDEFID )
modelID = modelDef(varInqInst(varID), (int)processID, NULL); modelID = modelDef(varInqInst(varID), (int)processID, NULL);
varDefModel(varID, modelID); varDefModel(varID, modelID);
...@@ -615,16 +609,12 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -615,16 +609,12 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
if ( varInqTable(varID) == CDI_UNDEFID ) if ( varInqTable(varID) == CDI_UNDEFID )
{ {
int pdis, pcat, pnum; int pdis, pcat, pnum;
cdiDecodeParam(param, &pnum, &pcat, &pdis); cdiDecodeParam(param, &pnum, &pcat, &pdis);
if ( pdis == 255 ) if ( pdis == 255 )
{ {
int tableID;
int tabnum = pcat; int tabnum = pcat;
int tableID = tableInq(varInqModel(varID), tabnum, NULL);
tableID = tableInq(varInqModel(varID), tabnum, NULL);
if ( tableID == CDI_UNDEFID ) if ( tableID == CDI_UNDEFID )
tableID = tableDef(varInqModel(varID), tabnum, NULL); tableID = tableDef(varInqModel(varID), tabnum, NULL);
varDefTable(varID, tableID); varDefTable(varID, tableID);
...@@ -639,7 +629,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -639,7 +629,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
varID, param, zaxistype, gridID, levelID); varID, param, zaxistype, gridID, levelID);
} }
static compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype, static compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype,
int tsteptype, char *name, var_tile_t tiles_data) int tsteptype, char *name, var_tile_t tiles_data)
{ {
compvar2_t compVar; compvar2_t compVar;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment