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

Added createZaxisFromZaxis().

parent 576d2b3e
Pipeline #4334 passed with stages
in 14 minutes and 59 seconds
......@@ -281,6 +281,31 @@ createZaxisFromZvar(const Varray<double> &levels, int vlistID, int varID)
return zaxisID;
}
static int
createZaxisFromZaxis(const Varray<double> &levels, int zaxisID1)
{
int nlevels = levels.size();
int zaxisID2 = zaxisCreate(zaxisInqType(zaxisID1), nlevels);
char str[CDI_MAX_NAME];
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID1, CDI_GLOBAL, CDI_KEY_NAME, str, &length);
cdiDefKeyString(zaxisID2, CDI_GLOBAL, CDI_KEY_NAME, str);
str[0] = 0;
length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID1, CDI_GLOBAL, CDI_KEY_LONGNAME, str, &length);
if (str[0]) cdiDefKeyString(zaxisID2, CDI_GLOBAL, CDI_KEY_LONGNAME, str);
str[0] = 0;
length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID1, CDI_GLOBAL, CDI_KEY_UNITS, str, &length);
if (str[0]) cdiDefKeyString(zaxisID2, CDI_GLOBAL, CDI_KEY_UNITS, str);
zaxisDefDatatype(zaxisID2, zaxisInqDatatype(zaxisID1));
zaxisDefLevels(zaxisID2, levels.data());
return zaxisID2;
}
static void
intlevelGetParameter(Varray<double> &lev2, std::string &zdescription, std::string &zvarname)
......@@ -425,7 +450,7 @@ Intlevel(void *process)
zvarGridsize = varList1[zvarID].gridsize;
nlev1 = varList1[zvarID].nlevels;
if (zaxisID2 == CDI_UNDEFID) zaxisID = createZaxisFromZvar(lev2, vlistID1, zvarID);
if (zaxisID2 == CDI_UNDEFID) zaxisID2 = createZaxisFromZvar(lev2, vlistID1, zvarID);
wisize = zvarGridsize * nlev2;
......@@ -460,27 +485,7 @@ Intlevel(void *process)
}
if (i == nzaxis) cdoAbort("No processable variable found!");
if (zaxisID2 == CDI_UNDEFID)
{
zaxisID2 = zaxisCreate(zaxisInqType(zaxisID1), nlev2);
char str[CDI_MAX_NAME];
int length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID1, CDI_GLOBAL, CDI_KEY_NAME, str, &length);
cdiDefKeyString(zaxisID2, CDI_GLOBAL, CDI_KEY_NAME, str);
str[0] = 0;
length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID1, CDI_GLOBAL, CDI_KEY_LONGNAME, str, &length);
if (str[0]) cdiDefKeyString(zaxisID2, CDI_GLOBAL, CDI_KEY_LONGNAME, str);
str[0] = 0;
length = CDI_MAX_NAME;
cdiInqKeyString(zaxisID1, CDI_GLOBAL, CDI_KEY_UNITS, str, &length);
if (str[0]) cdiDefKeyString(zaxisID2, CDI_GLOBAL, CDI_KEY_UNITS, str);
zaxisDefDatatype(zaxisID2, zaxisInqDatatype(zaxisID1));
zaxisDefLevels(zaxisID2, lev2.data());
}
if (zaxisID2 == CDI_UNDEFID) zaxisID2 = createZaxisFromZaxis(lev2, zaxisID1);
nlev1 = nlevel;
lev1.resize(nlev1 + 2);
......
Supports Markdown
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