Commit 5fff637f authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replaced zaxisInqLongname() by cdiZaxisInqKeyStr().

parent 07425b8d
......@@ -771,17 +771,23 @@ void gridDefYvals(int gridID, const double yvals[]);
int gridInqYvals(int gridID, double yvals[]);
/* CDI grid string key values */
#define CDI_KEY_XNAME 901 // X-axis name
#define CDI_KEY_YNAME 902 // Y-axis name
#define CDI_KEY_XDIMNAME 903 // X-axis dimension name
#define CDI_KEY_YDIMNAME 904 // Y-axis dimension name
#define CDI_KEY_VDIMNAME 905 // Vertex dimension name
#define CDI_KEY_XLONGNAME 906 // X-axis longname
#define CDI_KEY_YLONGNAME 907 // Y-axis longname
#define CDI_KEY_XUNITS 908 // X-axis units
#define CDI_KEY_YUNITS 909 // Y-axis units
#define CDI_KEY_MAPNAME 920 // Grid mapping var name
#define CDI_KEY_MAPPING 921 // Grid mapping name
#define CDI_KEY_XNAME 901 // X-axis name
#define CDI_KEY_XDIMNAME 902 // X-axis dimension name
#define CDI_KEY_XLONGNAME 903 // X-axis longname
#define CDI_KEY_XUNITS 904 // X-axis units
#define CDI_KEY_YNAME 911 // Y-axis name
#define CDI_KEY_YDIMNAME 912 // Y-axis dimension name
#define CDI_KEY_YLONGNAME 913 // Y-axis longname
#define CDI_KEY_YUNITS 914 // Y-axis units
#define CDI_KEY_VDIMNAME 920 // Vertex dimension name
#define CDI_KEY_MAPNAME 921 // Grid mapping var name
#define CDI_KEY_MAPPING 922 // Grid mapping name
/* CDI zaxis string key values */
#define CDI_KEY_NAME 941 // Z-axis name
#define CDI_KEY_DIMNAME 942 // Z-axis dimension name
#define CDI_KEY_LONGNAME 943 // Z-axis longname
#define CDI_KEY_UNITS 944 // Z-axis units
// cdiGridDefKeyStr: Define a CDI grid string value from a key
int cdiGridDefKeyStr(int gridID, int key, int size, const char *mesg);
......@@ -979,13 +985,6 @@ void zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE]);
/* zaxisInqUUID: Get the UUID of a generalized Z-axis */
void zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE]);
/* CDI zaxis string key values */
#define CDI_ZAXIS_NAME 801 // Z-axis name
#define CDI_ZAXIS_DIMNAME 802 // Z-axis dimension name
#define CDI_ZAXIS_VDIMNAME 803 // Vertex dimension name
#define CDI_ZAXIS_LONGNAME 804 // Z-axis longname
#define CDI_ZAXIS_UNITS 805 // Z-axis units
// cdiZaxisDefKeyStr: Define a CDI Z-axis string value from a key
int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg);
......
......@@ -883,7 +883,7 @@ void gridInqYname(int gridID, char *yname)
@Function gridInqYlongname
@Title Get the longname of a Y-axis
@Prototype void gridInqXlongname(int gridID, char *longname)
@Prototype void gridInqYlongname(int gridID, char *longname)
@Parameter
@Item gridID Grid ID, from a previous call to @fref{gridCreate} or @fref{vlistInqVarGrid}.
@Item longname Longname of the Y-axis. The caller must allocate space for the
......
......@@ -2890,10 +2890,10 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( is_scalar ) zaxisDefScalar(ncvar->zaxisID);
if ( zdimid != -1 )
cdiZaxisDefKeyStr(ncvar->zaxisID, CDI_ZAXIS_DIMNAME, (int)(strlen(ncdims[zdimid].name)+1), ncdims[zdimid].name);
cdiZaxisDefKeyStr(ncvar->zaxisID, CDI_KEY_DIMNAME, (int)(strlen(ncdims[zdimid].name)+1), ncdims[zdimid].name);
/*
if ( vdimid != -1 )
cdiZaxisDefKeyStr(ncvar->zaxisID, CDI_ZAXIS_VDIMNAME, strlen(ncdims[vdimid].name)+1, ncdims[vdimid].name);
cdiZaxisDefKeyStr(ncvar->zaxisID, CDI_KEY_VDIMNAME, strlen(ncdims[vdimid].name)+1, ncdims[vdimid].name);
*/
Free(zvar);
Free(lbounds);
......
......@@ -461,10 +461,10 @@ void cdfDefFC(stream_t *streamptr, int gridID, int gridindex)
static const struct cdfDefGridAxisInqs {
int (*axisSize)(int gridID);
int (*axisName)(int gridID, int key, int size, char *mesg);
void (*axisStdname)(int gridID, char *dimstdname);
void (*axisLongname)(int gridID, char *dimlongname);
void (*axisUnits)(int gridID, char *dimunits);
int (*axisName)(int cdiID, int key, int size, char *mesg);
void (*axisStdname)(int cdiID, char *dimstdname);
int (*axisLongname)(int cdiID, int key, int size, char *mesg);
void (*axisUnits)(int cdiID, char *dimunits);
double (*axisVal)(int gridID, int index);
const double *(*axisValsPtr)(int gridID);
const double *(*axisBoundsPtr)(int gridID);
......@@ -472,7 +472,7 @@ static const struct cdfDefGridAxisInqs {
.axisSize = gridInqXsize,
.axisName = cdiGridInqKeyStr,
.axisStdname = gridInqXstdname,
.axisLongname = gridInqXlongname,
.axisLongname = cdiGridInqKeyStr,
.axisUnits = gridInqXunits,
.axisVal = gridInqXval,
.axisValsPtr = gridInqXvalsPtr,
......@@ -481,40 +481,37 @@ static const struct cdfDefGridAxisInqs {
.axisSize = gridInqYsize,
.axisName = cdiGridInqKeyStr,
.axisStdname = gridInqYstdname,
.axisLongname = gridInqYlongname,
.axisLongname = cdiGridInqKeyStr,
.axisUnits = gridInqYunits,
.axisVal = gridInqYval,
.axisValsPtr = gridInqYvalsPtr,
.axisBoundsPtr = gridInqYboundsPtr,
}, gridInqsZ = {
.axisStdname = zaxisInqStdname,
.axisLongname = zaxisInqLongname,
.axisLongname = cdiZaxisInqKeyStr,
.axisUnits = zaxisInqUnits,
};
static void
cdfPutGridStdAtts(int fileID, int ncvarid,
int gridID, const struct cdfDefGridAxisInqs *inqs)
static
void cdfPutGridStdAtts(int fileID, int ncvarid, int gridID, int dimtype, const struct cdfDefGridAxisInqs *inqs)
{
size_t len;
{
char stdname[CDI_MAX_NAME];
inqs->axisStdname(gridID, stdname);
if ( (len = strlen(stdname)) )
cdf_put_att_text(fileID, ncvarid, "standard_name", len, stdname);
}
{
char longname[CDI_MAX_NAME];
inqs->axisLongname(gridID, longname);
if ( (len = strlen(longname)) )
cdf_put_att_text(fileID, ncvarid, "long_name", len, longname);
}
{
char units[CDI_MAX_NAME];
inqs->axisUnits(gridID, units);
if ( (len = strlen(units)) )
cdf_put_att_text(fileID, ncvarid, "units", len, units);
}
char stdname[CDI_MAX_NAME];
inqs->axisStdname(gridID, stdname);
if ( (len = strlen(stdname)) )
cdf_put_att_text(fileID, ncvarid, "standard_name", len, stdname);
char longname[CDI_MAX_NAME]; longname[0] = 0;
int keyname = (dimtype == 'Z') ? CDI_KEY_LONGNAME : (dimtype == 'X') ? CDI_KEY_XLONGNAME : CDI_KEY_YLONGNAME;
inqs->axisLongname(gridID, keyname, CDI_MAX_NAME, longname);
if ( (len = strlen(longname)) )
cdf_put_att_text(fileID, ncvarid, "long_name", len, longname);
char units[CDI_MAX_NAME];
inqs->axisUnits(gridID, units);
if ( (len = strlen(units)) )
cdf_put_att_text(fileID, ncvarid, "units", len, units);
}
static void
......@@ -544,7 +541,7 @@ cdfDefTrajLatLon(stream_t *streamptr, int gridID, int gridindex,
int keyname = (dimtype == 'X') ? CDI_KEY_XNAME : CDI_KEY_YNAME;
inqs->axisName(gridID, keyname, CDI_MAX_NAME, axisname);
cdf_def_var(fileID, axisname, xtype, 1, &dimNcID, &ncvarid);
cdfPutGridStdAtts(fileID, ncvarid, gridID, inqs);
cdfPutGridStdAtts(fileID, ncvarid, gridID, dimtype, inqs);
cdf_enddef(fileID);
streamptr->ncmode = 2;
}
......@@ -752,7 +749,7 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
{
cdf_def_var(fileID, extendedAxisname, xtype, ndims, &dimID, &ncvarid);
cdfPutGridStdAtts(fileID, ncvarid, gridID, gridAxisInq);
cdfPutGridStdAtts(fileID, ncvarid, gridID, axisLetter, gridAxisInq);
{
char axisStr[2] = { axisLetter, '\0' };
cdf_put_att_text(fileID, ncvarid, "axis", 1, axisStr);
......@@ -938,7 +935,7 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID, int gridindex)
cdf_def_var(fileID, xaxisname, xtype, 2, dimIDs, &ncxvarid);
cdfGridCompress(fileID, ncxvarid, (int)(xdimlen*ydimlen), streamptr->filetype, streamptr->comptype);
cdfPutGridStdAtts(fileID, ncxvarid, gridID, &gridInqsX);
cdfPutGridStdAtts(fileID, ncxvarid, gridID, 'X', &gridInqsX);
/* attribute for Panoply */
cdf_put_att_text(fileID, ncxvarid, "_CoordinateAxisType", 3, "Lon");
......@@ -964,7 +961,7 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID, int gridindex)
cdf_def_var(fileID, yaxisname, xtype, 2, dimIDs, &ncyvarid);
cdfGridCompress(fileID, ncyvarid, (int)(xdimlen*ydimlen), streamptr->filetype, streamptr->comptype);
cdfPutGridStdAtts(fileID, ncyvarid, gridID, &gridInqsY);
cdfPutGridStdAtts(fileID, ncyvarid, gridID, 'Y', &gridInqsY);
/* attribute for Panoply */
cdf_put_att_text(fileID, ncyvarid, "_CoordinateAxisType", 3, "Lat");
......@@ -1271,7 +1268,7 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID, int gridindex)
cdf_def_var(fileID, xaxisname, xtype, 1, &dimID, &ncxvarid);
cdfGridCompress(fileID, ncxvarid, (int)dimlen, streamptr->filetype, streamptr->comptype);
cdfPutGridStdAtts(fileID, ncxvarid, gridID, &gridInqsX);
cdfPutGridStdAtts(fileID, ncxvarid, gridID, 'X', &gridInqsX);
if ( gridInqXboundsPtr(gridID) && nvdimID != UNDEFID )
{
......@@ -1294,7 +1291,7 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID, int gridindex)
cdf_def_var(fileID, yaxisname, xtype, 1, &dimID, &ncyvarid);
cdfGridCompress(fileID, ncyvarid, (int)dimlen, streamptr->filetype, streamptr->comptype);
cdfPutGridStdAtts(fileID, ncyvarid, gridID, &gridInqsY);
cdfPutGridStdAtts(fileID, ncyvarid, gridID, 'Y', &gridInqsY);
if ( gridInqYboundsPtr(gridID) && nvdimID != UNDEFID )
{
......@@ -1820,7 +1817,7 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
char dimname[CDI_MAX_NAME+3];
dimname[0] = 0;
//cdiZaxisInqKeyStr(zaxisID, CDI_ZAXIS_DIMNAME, CDI_MAX_NAME, dimname);
//cdiZaxisInqKeyStr(zaxisID, CDI_KEY_DIMNAME, CDI_MAX_NAME, dimname);
if ( dimname[0] == 0 ) strcpy(dimname, axisname);
if ( type == ZAXIS_REFERENCE ) cdfDefZaxisUUID(streamptr, zaxisID);
......@@ -1839,7 +1836,7 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
cdf_def_var(fileID, axisname, (nc_type) xtype, ndims, &dimID, &ncvarid);
cdfPutGridStdAtts(fileID, ncvarid, zaxisID, &gridInqsZ);
cdfPutGridStdAtts(fileID, ncvarid, zaxisID, 'Z', &gridInqsZ);
{
int positive = zaxisInqPositive(zaxisID);
......
......@@ -369,14 +369,17 @@ void zaxisGetString(char *name, const char *zaxisstrname, size_t len)
}
static
char *zaxis_key_to_string(zaxis_t *zaxisptr, int key)
void *zaxis_key_to_ptr(zaxis_t *zaxisptr, int key)
{
char *keyptr = NULL;
void *keyptr = NULL;
switch (key)
{
case CDI_ZAXIS_DIMNAME: keyptr = zaxisptr->dimname; break;
case CDI_ZAXIS_VDIMNAME: keyptr = zaxisptr->vdimname; break;
case CDI_KEY_NAME: keyptr = (void*)zaxisptr->name; break;
case CDI_KEY_LONGNAME: keyptr = (void*)zaxisptr->longname; break;
case CDI_KEY_UNITS: keyptr = (void*)zaxisptr->units; break;
case CDI_KEY_DIMNAME: keyptr = (void*)zaxisptr->dimname; break;
case CDI_KEY_VDIMNAME: keyptr = (void*)zaxisptr->vdimname; break;
}
return keyptr;
......@@ -407,7 +410,7 @@ int cdiZaxisDefKeyStr(int zaxisID, int key, int size, const char *mesg)
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
char *keyptr = zaxis_key_to_string(zaxisptr, key);
char *keyptr = (char*)zaxis_key_to_ptr(zaxisptr, key);
if ( keyptr == NULL)
{
Warning("CDI zaxis string key %d not supported!", key);
......@@ -447,7 +450,7 @@ int cdiZaxisInqKeyStr(int zaxisID, int key, int size, char *mesg)
if ( size < 1 || mesg == NULL ) return -1;
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
const char *keyptr = zaxis_key_to_string(zaxisptr, key);
const char *keyptr = (const char*)zaxis_key_to_ptr(zaxisptr, key);
if ( keyptr == NULL)
{
Warning("CDI zaxis string key %d not supported!", key);
......@@ -475,13 +478,7 @@ The function @func{zaxisDefName} defines the name of a Z-axis.
*/
void zaxisDefName(int zaxisID, const char *name)
{
if ( name )
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
strncpy(zaxisptr->name, name, CDI_MAX_NAME - 1);
zaxisptr->name[CDI_MAX_NAME - 1] = '\0';
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
}
(void)cdiZaxisDefKeyStr(zaxisID, CDI_KEY_NAME, CDI_MAX_NAME, name);
}
/*
......@@ -500,13 +497,7 @@ The function @func{zaxisDefLongname} defines the longname of a Z-axis.
*/
void zaxisDefLongname(int zaxisID, const char *longname)
{
if ( longname )
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
strncpy(zaxisptr->longname, longname, CDI_MAX_NAME - 1);
zaxisptr->longname[CDI_MAX_NAME - 1] = '\0';
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
}
(void)cdiZaxisDefKeyStr(zaxisID, CDI_KEY_LONGNAME, CDI_MAX_NAME, longname);
}
/*
......@@ -525,13 +516,7 @@ The function @func{zaxisDefUnits} defines the units of a Z-axis.
*/
void zaxisDefUnits(int zaxisID, const char *units)
{
if ( units )
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
strncpy(zaxisptr->units, units, CDI_MAX_NAME - 1);
zaxisptr->units[CDI_MAX_NAME - 1] = '\0';
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
}
(void)cdiZaxisDefKeyStr(zaxisID, CDI_KEY_UNITS, CDI_MAX_NAME, units);
}
......@@ -567,8 +552,7 @@ The function @func{zaxisInqName} returns the name of a Z-axis.
*/
void zaxisInqName(int zaxisID, char *name)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
strcpy(name, zaxisptr->name);
(void)cdiZaxisInqKeyStr(zaxisID, CDI_KEY_NAME, CDI_MAX_NAME, name);
}
const char *zaxisInqNamePtr(int zaxisID)
......@@ -598,8 +582,7 @@ The function @func{zaxisInqLongname} returns the longname of a Z-axis.
*/
void zaxisInqLongname(int zaxisID, char *longname)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
strcpy(longname, zaxisptr->longname);
(void)cdiZaxisInqKeyStr(zaxisID, CDI_KEY_LONGNAME, CDI_MAX_NAME, longname);
}
/*
......@@ -623,8 +606,7 @@ The function @func{zaxisInqUnits} returns the units of a Z-axis.
*/
void zaxisInqUnits(int zaxisID, char *units)
{
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
strcpy(units, zaxisptr->units);
(void)cdiZaxisInqKeyStr(zaxisID, CDI_KEY_UNITS, CDI_MAX_NAME, units);
}
......
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