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

cmortable_parser: added support for namelist formatted tables.

parent 59675e38
......@@ -174,7 +174,7 @@ static
void apply_cmorlist(list_t *pmlist, int nvars, int vlistID2, var_t *vars)
{
const char *hentry[] = {"Header"};
const char *ventry[] = {"variable_entry"};
const char *ventry[] = {"variable_entry", "parameter"};
int nventry = (int) sizeof(ventry)/sizeof(ventry[0]);
int nhentry = (int) sizeof(hentry)/sizeof(hentry[0]);
char varname[CDI_MAX_NAME];
......@@ -261,7 +261,7 @@ void apply_cmorlist(list_t *pmlist, int nvars, int vlistID2, var_t *vars)
var->factor = parameter2double(value);
if ( cdoVerbose ) cdoPrint("%s - scale factor %g", varname, var->factor);
}
else if ( STR_IS_EQ(key, "missval") )
else if ( STR_IS_EQ(key, "missval") || STR_IS_EQ(key, "missing_value") )
{
double missval = parameter2double(value);
double missval_old = vlistInqVarMissval(vlistID2, varID);
......@@ -308,7 +308,7 @@ void apply_cmorlist(list_t *pmlist, int nvars, int vlistID2, var_t *vars)
}
else
{
cdoPrint("Variable %s not found in cmor table!", varname);
cdoPrint("Variable %s not found in CMOR table!", varname);
}
}
}
......
......@@ -296,12 +296,22 @@ list_t *cmortable_to_pmlist(FILE *fp, const char *name)
listbuf_t *listbuf = listbuf_new();
if ( listbuf_read(listbuf, fp, name) ) cdoAbort("Read error on CMOR table %s!", name);
list_t *pmlist = list_new(sizeof(list_t *), free_kvlist, name);
list_t *pmlist = NULL;
if ( listbuf->buffer[0] == '{' )
cmortablebuf_to_pmlist_json(pmlist, listbuf->size, listbuf->buffer, name);
{
pmlist = list_new(sizeof(list_t *), free_kvlist, name);
cmortablebuf_to_pmlist_json(pmlist, listbuf->size, listbuf->buffer, name);
}
else if ( strncmp(listbuf->buffer, "table_id:", 9) == 0 )
cmortablebuf_to_pmlist(pmlist, listbuf->size, listbuf->buffer);
{
pmlist = list_new(sizeof(list_t *), free_kvlist, name);
cmortablebuf_to_pmlist(pmlist, listbuf->size, listbuf->buffer);
}
else if ( listbuf->buffer[0] == '&' || listbuf->buffer[0] == '#' )
{
pmlist = namelistbuf_to_pmlist(listbuf);
}
else
cdoAbort("Invalid CMOR table (file: %s)!", name);
......
This diff is collapsed.
This diff is collapsed.
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