Commit f3f429bd authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Moved declarition of vlistInqVarNamePtr() to vlist_var.h.

parent 80aa8556
......@@ -14,6 +14,7 @@
#include "cdf.h"
#include "cdf_int.h"
#include "vlist.h"
#include "vlist_var.h"
static
......
......@@ -11,6 +11,7 @@
#include "cdf.h"
#include "cdf_int.h"
#include "vlist.h"
#include "vlist_var.h"
void cdfDefVarDeflate(int ncid, int ncvarid, int deflate_level)
......@@ -427,13 +428,12 @@ 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]);
int tableID = vlistInqVarTable(vlistID, varID);
const char *name = vlistInqVarNamePtr(vlistID, varID);
const char *longname = vlistInqVarLongnamePtr(vlistID, varID);
const char *stdname = vlistInqVarStdnamePtr(vlistID, varID);
const char *units = vlistInqVarUnitsPtr(vlistID, varID);
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);
......
......@@ -699,11 +699,6 @@ double vlistInqVarDblKey(int vlistID, int varID, const char *name);
/* vlistInqVarIntKey: raw access to GRIB meta-data */
int vlistInqVarIntKey(int vlistID, int varID, const char *name);
/* needed only for CDO operator after */
const char *vlistInqVarNamePtr(int vlistID, int varID);
const char *vlistInqVarLongnamePtr(int vlistID, int varID);
const char *vlistInqVarUnitsPtr(int vlistID, int varID);
/* CDI attributes */
/* cdiInqNatts: Get number of attributes assigned to this variable */
......
......@@ -3223,34 +3223,37 @@ 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 )
{
const char *pname = vlistInqVarNamePtr(vlistID, varID);
size_t len = strlen(pname);
if ( len > 3 && isdigit((int) pname[3]) )
name[0] = 0;
vlistInqVarName(vlistID, varID, name);
size_t len = strlen(name);
if ( len > 3 && isdigit((int) name[3]) )
{
if ( str_is_equal(pname, "var") )
if ( str_is_equal(name, "var") )
{
vlistDefVarCode(vlistID, varID, atoi(pname+3));
vlistDefVarCode(vlistID, varID, atoi(name+3));
// vlistDestroyVarName(vlistID, varID);
}
}
else if ( len > 4 && isdigit((int) pname[4]) )
else if ( len > 4 && isdigit((int) name[4]) )
{
if ( str_is_equal(pname, "code") )
if ( str_is_equal(name, "code") )
{
vlistDefVarCode(vlistID, varID, atoi(pname+4));
vlistDefVarCode(vlistID, varID, atoi(name+4));
// vlistDestroyVarName(vlistID, varID);
}
}
else if ( len > 5 && isdigit((int) pname[5]) )
else if ( len > 5 && isdigit((int) name[5]) )
{
if ( str_is_equal(pname, "param") )
if ( str_is_equal(name, "param") )
{
int pnum = -1, pcat = 255, pdis = 255;
sscanf(pname+5, "%d.%d.%d", &pnum, &pcat, &pdis);
sscanf(name+5, "%d.%d.%d", &pnum, &pcat, &pdis);
vlistDefVarParam(vlistID, varID, cdiEncodeParam(pnum, pcat, pdis));
// vlistDestroyVarName(vlistID, varID);
}
......
......@@ -917,7 +917,6 @@ int tableInqParLongname(int tableID, int code, char *longname)
int tableInqParUnits(int tableID, int code, char *units)
{
if ( ((tableID >= 0) & (tableID < MAX_TABLE)) | (tableID == CDI_UNDEFID) ) { } else
Error("Invalid table ID %d", tableID);
......
......@@ -20,6 +20,10 @@ int vlistInqVarIOrank ( int, int );
void cdiVlistCreateVarLevInfo(vlist_t *vlistptr, int varID);
const char *vlistInqVarNamePtr(int vlistID, int varID);
const char *vlistInqVarLongnamePtr(int vlistID, int varID);
const char *vlistInqVarUnitsPtr(int vlistID, int varID);
#endif
/*
* Local Variables:
......
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