Commit 60fa3d17 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Used zaxis dim name if var name is missing.

parent 6d05a80c
......@@ -2720,7 +2720,7 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( CDI_Debug ) Message("nlevs = %d", zsize);
double *zvar = (double *) Malloc((size_t)zsize * sizeof (double));
double *zvar = NULL;
int zaxisType = UNDEFID;
if ( zvarid != UNDEFID ) zaxisType = ncvars[zvarid].zaxistype;
......@@ -2749,6 +2749,7 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( ncvars[zvarid].psvarid != -1 ) psvarid = ncvars[zvarid].psvarid;
}
zvar = (double*) Malloc((size_t)zsize*sizeof(double));
cdf_get_var_double(ncvars[zvarid].ncid, zvarid, zvar);
if ( ncvars[zvarid].bounds != UNDEFID )
......@@ -2776,19 +2777,16 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
}
else
{
pname = NULL;
pname = (zdimid != UNDEFID) ? ncdims[zdimid].name : NULL;
plongname = NULL;
punits = NULL;
if ( zsize == 1 && zdimid == UNDEFID )
{
zaxisType = (ncvar->zaxistype != UNDEFID) ? ncvar->zaxistype : ZAXIS_SURFACE;
zvar = (double*) Malloc(sizeof(double));
zvar[0] = 0;
}
else
{
for ( int ilev = 0; ilev < zsize; ilev++ ) zvar[ilev] = ilev + 1;
}
}
ncvar->zaxisID = varDefZaxis(vlistID, zaxisType, (int) zsize, zvar, with_bounds, lbounds, ubounds,
......@@ -2799,10 +2797,7 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( CDI_cmor_mode && zsize == 1 && zaxisType != ZAXIS_HYBRID ) zaxisDefScalar(zaxisID);
if ( uuidOfVGrid[0] != 0 )
{
// printf("uuidOfVGrid: defined\n");
zaxisDefUUID(zaxisID, uuidOfVGrid);
}
zaxisDefUUID(zaxisID, uuidOfVGrid);
if ( zaxisType == ZAXIS_HYBRID && psvarid != -1 )
cdiZaxisDefKeyStr(zaxisID, CDI_KEY_PSNAME, strlen(ncvars[psvarid].name)+1, ncvars[psvarid].name);
......@@ -2810,15 +2805,15 @@ void cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( positive > 0 ) zaxisDefPositive(zaxisID, positive);
if ( is_scalar ) zaxisDefScalar(zaxisID);
if ( zdimid != -1 )
if ( zdimid != UNDEFID )
cdiZaxisDefKeyStr(zaxisID, CDI_KEY_DIMNAME, (int)(strlen(ncdims[zdimid].name)+1), ncdims[zdimid].name);
/*
if ( vdimid != -1 )
cdiZaxisDefKeyStr(zaxisID, CDI_KEY_VDIMNAME, strlen(ncdims[vdimid].name)+1, ncdims[vdimid].name);
*/
Free(zvar);
Free(lbounds);
Free(ubounds);
if ( zvar ) Free(zvar);
if ( lbounds ) Free(lbounds);
if ( ubounds ) Free(ubounds);
if ( zvarid != UNDEFID )
{
......
......@@ -994,7 +994,7 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, const double *levels, b
if ( ! zaxisglobdefined )
{
zaxisID = zaxisCreate(zaxistype, nlevels);
zaxisDefLevels(zaxisID, levels);
if ( levels ) zaxisDefLevels(zaxisID, levels);
if ( lbounds )
{
zaxisDefLbounds(zaxisID, levels1);
......@@ -1004,9 +1004,9 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, const double *levels, b
if ( (zaxistype == ZAXIS_HYBRID || zaxistype == ZAXIS_HYBRID_HALF) && vctsize > 0 )
zaxisDefVct(zaxisID, vctsize, vct);
zaxisDefName(zaxisID, name);
zaxisDefLongname(zaxisID, longname);
zaxisDefUnits(zaxisID, units);
if ( name && name[0] ) zaxisDefName(zaxisID, name);
if ( longname && longname[0] ) zaxisDefLongname(zaxisID, longname);
if ( units && units[0] ) zaxisDefUnits(zaxisID, units);
zaxisDefPrec(zaxisID, prec);
zaxisDefLtype(zaxisID, ltype1);
}
......
......@@ -32,7 +32,7 @@ static const struct {
}
ZaxistypeEntry[] = {
{ /* 0 */ 0, "sfc", "surface", "", ""},
{ /* 1 */ 0, "lev", "generic", "", "level"},
{ /* 1 */ 0, "lev", "generic", "", ""},
{ /* 2 */ 2, "lev", "hybrid", "", "level"},
{ /* 3 */ 2, "lev", "hybrid_half", "", "level"},
{ /* 4 */ 2, "lev", "pressure", "air_pressure", "Pa"},
......@@ -684,15 +684,18 @@ void zaxisDefLevels(int zaxisID, const double *levels)
zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
size_t size = (size_t)zaxisptr->size;
if ( zaxisptr->vals == NULL )
zaxisptr->vals = (double*) Malloc(size*sizeof(double));
if ( levels )
{
if ( zaxisptr->vals == NULL )
zaxisptr->vals = (double*) Malloc(size*sizeof(double));
double *vals = zaxisptr->vals;
double *vals = zaxisptr->vals;
for ( size_t ilev = 0; ilev < size; ++ilev )
vals[ilev] = levels[ilev];
for ( size_t ilev = 0; ilev < size; ++ilev )
vals[ilev] = levels[ilev];
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
}
}
/*
......
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