Commit 18cf6df1 authored by Fabian Wachsmann's avatar Fabian Wachsmann
Browse files

Allow fourth dimension registration as substitute for z_axis

parent 0fe1e94f
......@@ -2930,7 +2930,7 @@ register_fourth_axis(list_t *kvl, int vlistID, int varID, char *varname, int *ax
static void
register_z_axis(list_t *kvl, int vlistID, int varID, int zaxisID, char *varname, int *axis_ids, int *zfactor_id,
char *project_id, int miptab_freq)
char *project_id, int miptab_freq, int *mergeIDs)
{
char zaxisunits[CDI_MAX_NAME];
zaxisInqUnits(zaxisID, zaxisunits);
......@@ -3139,44 +3139,8 @@ register_z_axis(list_t *kvl, int vlistID, int varID, int zaxisID, char *varname,
}
else if (zaxisInqType(zaxisID) == ZAXIS_GENERIC && strcmp(chardim, "notSet") != 0 )
{
if (Options::cdoVerbose)
cdoPrint("In Z-axis registration:\n The '%d' levels are interpreted as "
"the character coordinates for '%s' in the order they are given for '%s'.",
zsize, varname, chardim);
int numchar = 0;
char *charvalstring = (char *) Malloc(CMOR_MAX_STRING * sizeof(char));
sprintf(charvalstring, "char_axis_%s", chardim);
char **charvals = kv_get_vals(kvl, charvalstring, &numchar);
Free(charvalstring);
if (charvals)
{
size_t maxlen = get_strmaxlen(charvals, numchar);
void *charcmor = (void *) Malloc((numchar * maxlen + 1) * sizeof(char));
sprintf((char *) charcmor, "%s", charvals[0]);
std::vector<char> blanks(maxlen);
for (size_t i = 0; i < maxlen; i++) blanks[i] = ' ';
sprintf((char *) charcmor, "%s%.*s", (char *) charcmor, (int) (maxlen - strlen(charvals[0])), blanks.data());
for (int i = 1; i < numchar; i++)
{
sprintf((char *) charcmor, "%s%s", (char *) charcmor, charvals[i]);
sprintf((char *) charcmor, "%s%.*s", (char *) charcmor, (int) (maxlen - strlen(charvals[i])), blanks.data());
}
if (numchar == zsize)
cmf = cmor_axis(new_axis_id(axis_ids), chardim, (char *) "", numchar, (void *) charcmor, 'c', NULL, maxlen,
NULL);
else
cdoAbort("ERROR (infile: '%s')! In registration of a character coordinate as a substitution for a vertical coordinate:\n "
" The number of registered character coordinates '%d' differ from the number of axis "
"levels '%d'.",
cdoGetStreamName(0), numchar, zsize);
if (cmf != 0) cdoAbort("ERROR (infile: '%s')! Function cmor_axis failed!", cdoGetStreamName(0));
Free(charcmor);
}
else
cdoAbort("ERROR (infile: '%s')! In registration of a character coordinate as a substitution for a vertical coordinate:\n "
" You configured a character coordinate '%s' but no values are found! Configure values via "
"attribute 'char_dim_vals'.",
cdoGetStreamName(0), chardim);
register_fourth_axis(kvl, vlistID, varID, varname, axis_ids, project_id, miptab_freq, mergeIDs);
kv_insert_a_val(kvl, "capr", (char *)"y", 1);
}
else if (zaxisInqType(zaxisID) == ZAXIS_GENERIC || zaxisInqType(zaxisID) == ZAXIS_HEIGHT)
{
......@@ -4066,6 +4030,7 @@ register_grid(list_t *kvl, int vlistID, int varID, int *axis_ids, int *grid_ids,
ycell_bounds = (double *) Malloc(4 * totalsize * sizeof(double));
inquire_vals_and_bounds(gridID, &xnbounds, &ynbounds, xcoord_vals, ycoord_vals, xcell_bounds, ycell_bounds);
/* In a projection, this is done by setting mapping parameter */
move_lons(xcoord_vals, xcell_bounds, totalsize, 4 * totalsize, xnbounds);
get_cmor_table(kvl, project_id);
int grid_axis[2];
check_and_gen_bounds_curv(gridID, totalsize, xnbounds, xlength, xcoord_vals, xcell_bounds, ynbounds, ylength,
......@@ -4316,10 +4281,10 @@ register_variable(list_t *kvl, int vlistID, int varID, int *axis_ids, struct map
#if (CMOR_VERSION_MAJOR == 3 && CMOR_VERSION_MINOR >= 3)
char *deflates = NULL;
long int deflate = 0;
if ( deflates = kv_get_a_val(kvl, "dl", NULL) )
if ( ( deflates = kv_get_a_val(kvl, "dl", NULL) ) )
{
if (Options::cdoVerbose) cdoPrint("8.5.3. Start to set deflate for variable '%s'.", name);
if ( deflate = atol((const char *)deflates) )
if ( ( deflate = atol((const char *)deflates) ) )
{
if ( deflate == -1 )
cmf = cmor_set_deflate(var->cmor_varID, 0, 0, 0);
......@@ -4430,7 +4395,7 @@ register_all_dimensions(list_t *kvl, int streamID, struct mapping vars[], int ta
if (Options::cdoVerbose) cdoPrint("8.2. Successfully handled grid registration.");
/* Z-Axis */
if (Options::cdoVerbose) cdoPrint("8.3. Start to register zaxis of '%s'", name);
register_z_axis(kvl, vlistID, varID, zaxisID, name, axis_ids, &var->zfactor_id, project_id, miptab_freq);
register_z_axis(kvl, vlistID, varID, zaxisID, name, axis_ids, &var->zfactor_id, project_id, miptab_freq, mergeIDs);
if (Options::cdoVerbose) cdoPrint("8.3. Successfully handled zaxis registration.");
/* Possible 4th spatial dimension */
/* Z-Axis */
......
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