Commit 4666ec68 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Vertint.test: check ml2plx with code156 and code157.

parents 88827d17 bb240cab
Pipeline #3290 passed with stages
in 14 minutes and 12 seconds
......@@ -550,6 +550,7 @@ check_for_charvars(KVList *cmorVarLine, const char */*cn*/, char */*miptabfreq*/
/* If it is given as a string and the string contains a ',', */
/* it must be divided into several values and is a variable with character coordinate */
/***/
if (Options::cdoVerbose) cdoPrint("Start to check for variables to merge as a character coordinate.");
const KeyValues *kvn = nullptr;
bool isCode = false;
if (key)
......@@ -568,14 +569,18 @@ check_for_charvars(KVList *cmorVarLine, const char */*cn*/, char */*miptabfreq*/
if (kvn && strstr(kvn->values[0].c_str(), ",") && kvn->nvalues == 1)
{
if (Options::cdoVerbose) cdoPrint("Start to replace identifier string with its values.");
char *unfilteredComma = strdup(kvn->values[0].c_str());
if ( isCode )
kv_insert_vals(cmorVarLine, "code", unfilteredComma, true, true);
else
kv_insert_vals(cmorVarLine, "name", unfilteredComma, true, true);
Free(unfilteredComma);
if (Options::cdoVerbose) cdoPrint("Successfully replaced identifier string with its values.");
return cmorVarLine;
}
if (Options::cdoVerbose) cdoPrint("Successfully checked for variables to merge as a character coordinate.");
return nullptr;
}
......@@ -1993,7 +1998,7 @@ setup_dataset(KVList *kvl, CdoStreamID streamID, int *calendar, char *project_id
"institution_id", "license", "mip_era", "nominal_resolution", "physics_index", "product", "realization_index",
"source", "source_id", "source_type", "sub_experiment", "sub_experiment_id", "table_id", "variant_label",
"parent_experiment_id", "parent_activity_id", "parent_mip_era", "parent_source_id", "parent_variant_label",
"parent_time_units", nullptr
"parent_time_units", "variant_info", nullptr
};
while (allneeded[i])
{
......@@ -2318,6 +2323,10 @@ register_fourth_axis(KVList *kvl, int vlistID, int varID, char *varname, int *ax
{
if (Options::cdoVerbose) cdoPrint("Try to replace the vertical axis with a character_axis.");
}
else if ( nofvals == 1 )
{
if (Options::cdoVerbose) cdoPrint("Try to register a forth axis with one value.");
}
else
{
cdoAbort("ERROR (infile: '%s')! No data to substitute found in infile for specified number of values '%d' for axis '%s'.", cdoGetStreamName(0), nofvals, chardim);
......@@ -2552,7 +2561,7 @@ register_z_axis(KVList *kvl, int vlistID, int varID, int zaxisID, char *varname,
PMList pml = cdo_parse_cmor_file(mtproof, true);
std::vector<std::string> tempo = { "ps" };
maptab_via_cn(mtproof, pml, tempo, vlistID, 1,
kv_get_a_val(kvl, "miptab_freq", nullptr), CDI_FILETYPE_NC, nullptr, false);
kv_get_a_val(kvl, "miptab_freq", nullptr), filetype, nullptr, false);
}
int psindex = getVarIDToMap(vlistID, vlistNvars(vlistID), "name", "ps");
if (psindex == CDI_UNDEFID)
......
......@@ -165,10 +165,10 @@ count(Field &field1, const Field &field2, double mode)
if (!DBL_IS_EQUAL(array1[i], missval1))
{
if (IS_EQUAL(mode, 0.0) || IS_EQUAL(mode, 1.0) || array2[i] > mode)
if (IS_EQUAL(mode, 0.0) || IS_EQUAL(mode, 1.0) )
array1[i] += 1.0;
else if (DBL_IS_EQUAL(array2[i], mode))
array1[i] += mode;
else if (DBL_IS_EQUAL(array2[i], mode) || array2[i] > mode)
array1[i] += array2[i];
}
else
{
......@@ -193,10 +193,10 @@ count(Field &field1, const Field &field2, double mode)
continue;
}
if (IS_EQUAL(mode, 0.0) || IS_EQUAL(mode, 1.0) || array2[i] > mode)
if (IS_EQUAL(mode, 0.0) || IS_EQUAL(mode, 1.0))
array1[i] += 1.0;
else if (DBL_IS_EQUAL(array2[i], mode))
array1[i] += mode;
else if (DBL_IS_EQUAL(array2[i], mode) || array2[i] > mode)
array1[i] += array2[i];
}
}
}
......
......@@ -143,6 +143,9 @@ MergeVarsOnAxis::define_var_structure(int vlistID, int ntsteps, std::vector<int>
{
this->output.vlistID = vlistID;
this->output.varID = vlistDefVar(this->output.vlistID, this->output.gridID, this->output.zaxisID, TIME_VARYING);
int oldcode = vlistInqVarCode(this->output.vlistID, this->inputKeys[0].varID);
vlistDefVarCode(this->output.vlistID, this->inputKeys[0].varID, 1);
vlistDefVarCode(this->output.vlistID, this->output.varID, oldcode);
cdiDefKeyString(this->output.vlistID, this->inputKeys[0].varID, CDI_KEY_NAME, "ChangedForMap");
cdiDefKeyString(this->output.vlistID, this->output.varID, CDI_KEY_NAME, this->inputNames.values[0].c_str());
auto datatype = vlistInqVarDatatype(this->output.vlistID, this->inputKeys[0].varID);
......
......@@ -177,7 +177,7 @@ KVListAppendNamelist(KVList &kvlist, const char *key, const char *buffer, Nameli
pval = vbuf;
}
if (cdocmor && strcmp(key, "code") == 0)
if (cdocmor && strcmp(key, "code") == 0 && !strstr(pval, ",") )
{
const auto code = atoi(pval);
if (code > 0 && code < 1000)
......
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