Commit 824aa80f authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Removed function tableInqParUnitsPtr().

parent f3f429bd
......@@ -319,7 +319,6 @@ int cdfDefVar(stream_t *streamptr, int varID)
int ncvarid = -1;
int xid = CDI_UNDEFID, yid = CDI_UNDEFID;
size_t xsize = 0, ysize = 0;
char varname[CDI_MAX_NAME];
int dims[4];
size_t chunks[4] = {0,0,0,0};
int ndims = 0;
......@@ -428,16 +427,21 @@ int cdfDefVar(stream_t *streamptr, int varID)
if ( CDI_Debug )
fprintf(stderr, "chunktype %d chunks %d %d %d %d\n", chunktype, (int)chunks[0], (int)chunks[1], (int)chunks[2], (int)chunks[3]);
const char *name = vlistInqVarNamePtr(vlistID, varID);
const char *longname = vlistInqVarLongnamePtr(vlistID, varID);
const char *stdname = vlistInqVarStdnamePtr(vlistID, varID);
const char *units = vlistInqVarUnitsPtr(vlistID, varID);
char varname[CDI_MAX_NAME];
char name[CDI_MAX_NAME]; name[0] = 0;
char longname[CDI_MAX_NAME]; longname[0] = 0;
char stdname[CDI_MAX_NAME]; stdname[0] = 0;
char units[CDI_MAX_NAME]; units[0] = 0;
if ( vlistInqVarNamePtr(vlistID, varID) ) vlistInqVarName(vlistID, varID, name);
vlistInqVarLongname(vlistID, varID, longname);
vlistInqVarStdname(vlistID, varID, stdname);
vlistInqVarUnits(vlistID, varID, units);
int tableID = vlistInqVarTable(vlistID, varID);
if ( name == NULL ) name = tableInqParNamePtr(tableID, code);
if ( longname == NULL ) longname = tableInqParLongnamePtr(tableID, code);
if ( units == NULL ) units = tableInqParUnitsPtr(tableID, code);
if ( name )
if ( !name[0] ) tableInqParName(tableID, code, name);
if ( !longname[0] ) tableInqParLongname(tableID, code, longname);
if ( !units[0] ) tableInqParUnits(tableID, code, units);
if ( name[0] )
{
sprintf(varname, "%s", name);
......@@ -464,7 +468,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
Warning("Changed multiple entry of variable name '%s' to '%s'!", name, varname);
}
name = varname;
strcpy(name, varname);
}
else
{
......@@ -493,7 +497,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
if ( iz >= CDI_MAX_NAME ) break;
}
name = varname;
strcpy(name, varname);
code = 0;
pdis = 255;
}
......@@ -530,14 +534,9 @@ int cdfDefVar(stream_t *streamptr, int varID)
}
}
if ( stdname && *stdname )
cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(stdname), stdname);
if ( longname && *longname )
cdf_put_att_text(fileID, ncvarid, "long_name", strlen(longname), longname);
if ( units && *units )
cdf_put_att_text(fileID, ncvarid, "units", strlen(units), units);
if ( *stdname ) cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(stdname), stdname);
if ( *longname ) cdf_put_att_text(fileID, ncvarid, "long_name", strlen(longname), longname);
if ( *units ) cdf_put_att_text(fileID, ncvarid, "units", strlen(units), units);
if ( code > 0 && pdis == 255 )
cdf_put_att_int(fileID, ncvarid, "code", NC_INT, 1, &code);
......
......@@ -1223,11 +1223,6 @@ int tableInqParName(int tableID, int code, char *name);
int tableInqParLongname(int tableID, int code, char *longname);
int tableInqParUnits(int tableID, int code, char *units);
/* needed only for CDO operator after */
const char *tableInqParNamePtr(int tableID, int parID);
const char *tableInqParLongnamePtr(int tableID, int parID);
const char *tableInqParUnitsPtr(int tableID, int parID);
/* History routines */
void streamDefHistory(int streamID, int size, const char *history);
......
......@@ -3223,13 +3223,11 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
if ( varids ) Free(varids);
char name[CDI_MAX_NAME];
for ( int varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarCode(vlistID, varID) == -varID-1 )
{
name[0] = 0;
char name[CDI_MAX_NAME]; name[0] = 0;
vlistInqVarName(vlistID, varID, name);
size_t len = strlen(name);
if ( len > 3 && isdigit((int) name[3]) )
......@@ -3269,7 +3267,9 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
int code = vlistInqVarCode(vlistID, varID);
if ( cdiDefaultTableID != CDI_UNDEFID )
{
if ( tableInqParNamePtr(cdiDefaultTableID, code) )
char buf[CDI_MAX_NAME]; buf[0] = 0;
tableInqParName(cdiDefaultTableID, code, buf);
if ( buf[0] )
{
vlistDestroyVarName(vlistID, varID);
vlistDestroyVarLongname(vlistID, varID);
......@@ -3277,11 +3277,13 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
if ( varTableID != CDI_UNDEFID )
{
vlistDefVarName(vlistID, varID, tableInqParNamePtr(cdiDefaultTableID, code));
if ( tableInqParLongnamePtr(cdiDefaultTableID, code) )
vlistDefVarLongname(vlistID, varID, tableInqParLongnamePtr(cdiDefaultTableID, code));
if ( tableInqParUnitsPtr(cdiDefaultTableID, code) )
vlistDefVarUnits(vlistID, varID, tableInqParUnitsPtr(cdiDefaultTableID, code));
vlistDefVarName(vlistID, varID, buf);
buf[0] = 0;
tableInqParLongname(cdiDefaultTableID, code, buf);
if ( buf[0] ) vlistDefVarLongname(vlistID, varID, buf);
buf[0] = 0;
tableInqParUnits(cdiDefaultTableID, code, buf);
if ( buf[0] ) vlistDefVarUnits(vlistID, varID, buf);
}
else
{
......
......@@ -868,27 +868,6 @@ const char *tableInqParLongnamePtr(int tableID, int code)
}
const char *tableInqParUnitsPtr(int tableID, int code)
{
const char *units = NULL;
if ( tableID != CDI_UNDEFID )
{
int npars = parTable[tableID].npars;
for ( int item = 0; item < npars; item++ )
{
if ( parTable[tableID].pars[item].id == code )
{
units = parTable[tableID].pars[item].units;
break;
}
}
}
return units;
}
int tableInqParLongname(int tableID, int code, char *longname)
{
if ( ((tableID >= 0) & (tableID < MAX_TABLE)) | (tableID == CDI_UNDEFID) ) { } else
......
......@@ -22,6 +22,9 @@ param_type;
static void tableLink(int tableID, const param_type *pars, int npars);
int tableDef(int modelID, int tablegribID, const char *tablename);
const char *tableInqParNamePtr(int tableID, int parID);
const char *tableInqParLongnamePtr(int tableID, int parID);
#endif
/*
* Local Variables:
......
......@@ -578,7 +578,6 @@ int cmp_varname(const void *s1, const void *s2)
void cdi_generate_vars(stream_t *streamptr)
{
char name[CDI_MAX_NAME], longname[CDI_MAX_NAME], units[CDI_MAX_NAME];
int vlistID = streamptr->vlistID;
int *varids = (int *) Malloc(varTableUsed*sizeof(int));
......@@ -802,23 +801,24 @@ void cdi_generate_vars(stream_t *streamptr)
{
int pdis, pcat, pnum;
cdiDecodeParam(param, &pnum, &pcat, &pdis);
if ( tableInqParNamePtr(cdiDefaultTableID, pnum) )
char name[CDI_MAX_NAME]; name[0] = 0;
tableInqParName(cdiDefaultTableID, pnum, name);
if ( name[0] )
{
if ( tableID != CDI_UNDEFID )
{
strcpy(name, tableInqParNamePtr(cdiDefaultTableID, pnum));
vlistDefVarName(vlistID, varID, name);
if ( tableInqParLongnamePtr(cdiDefaultTableID, pnum) )
{
strcpy(longname, tableInqParLongnamePtr(cdiDefaultTableID, pnum));
vlistDefVarLongname(vlistID, varID, longname);
}
if ( tableInqParUnitsPtr(cdiDefaultTableID, pnum) )
{
strcpy(units, tableInqParUnitsPtr(cdiDefaultTableID, pnum));
vlistDefVarUnits(vlistID, varID, units);
}
}
{
char longname[CDI_MAX_NAME]; longname[0] = 0;
tableInqParLongname(cdiDefaultTableID, pnum, longname);
if ( longname[0] ) vlistDefVarLongname(vlistID, varID, longname);
}
{
char units[CDI_MAX_NAME]; units[0] = 0;
tableInqParUnits(cdiDefaultTableID, pnum, units);
if ( units[0] ) vlistDefVarUnits(vlistID, varID, units);
}
}
else
tableID = cdiDefaultTableID;
}
......
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