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);
......
......@@ -437,151 +437,6 @@ valid_min: -700
valid_max: 1.00E+04
!----------------------------------
!
!
!============
variable_entry: p0
!============
!------------
!
! Variable attributes:
!----------------------------------
long_name: vertical coordinate formula term: reference pressure
units: Pa
!----------------------------------
!
!
!============
variable_entry: ptop
!============
!
!------------
!
! Variable attributes:
!----------------------------------
long_name: pressure at top of model
units: Pa
!----------------------------------
!
!
!
!============
variable_entry: a
!============
!------------
!
! Variable attributes:
!----------------------------------
long_name: vertical coordinate formula term: a(k)
!----------------------------------
!
! Additional variable information:
!----------------------------------
dimensions: alevel
type: double
!----------------------------------
!
!
!============
variable_entry: b
!============
!------------
!
! Variable attributes:
!----------------------------------
long_name: vertical coordinate formula term: b(k)
!----------------------------------
!
! Additional variable information:
!----------------------------------
dimensions: alevel
type: double
!----------------------------------
!
!
!============
variable_entry: a_bnds
!============
!
!------------
!
! Variable attributes:
!----------------------------------
long_name: vertical coordinate formula term: a(k+1/2)
!----------------------------------
!
! Additional variable information:
!----------------------------------
dimensions: alevel
type: double
!----------------------------------
!
!
!============
variable_entry: b_bnds
!============
!
!------------
!
! Variable attributes:
!----------------------------------
long_name: vertical coordinate formula term: b(k+1/2)
!----------------------------------
!
! Additional variable information:
!----------------------------------
dimensions: alevel
type: double
!----------------------------------
!
!
!============
variable_entry: ap
!============
!
! Variable attributes:
!----------------------------------
long_name: vertical coordinate formula term: ap(k)
units: Pa
!----------------------------------
!
! Additional variable information:
!----------------------------------
dimensions: alevel
type: double
!----------------------------------
!
!
!============
variable_entry: ap_bnds
!============
!
! Variable attributes:
!----------------------------------
long_name: vertical coordinate formula term: ap(k+1/2)
units: Pa
!----------------------------------
!
! Additional variable information:
!----------------------------------
dimensions: alevel
type: double
!----------------------------------
!
!
!============
variable_entry: ztop
!============
!
!------------
!
! Variable attributes:
!----------------------------------
long_name: height of top of model
units: m
!----------------------------------
!
!
!
!============
variable_entry: tas
......@@ -635,34 +490,9 @@ ok_max_mean_abs: 281.8
!----------------------------------
!
!============
variable_entry: tasmin
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: air_temperature
units: K
cell_methods: time: minimum within days time: mean over days
cell_measures: area: areacella
long_name: Daily Minimum Near-Surface Air Temperature
comment: monthly mean of the daily-minimum near-surface (usually, 2 meter) air temperature.
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time height2m
out_name: tasmin
type: real
valid_min: 183.6
valid_max: 309.8
ok_min_mean_abs: 271.8
ok_max_mean_abs: 279.6
!----------------------------------
!
!============
variable_entry: tasmax
variable_entry: ta
!============
modeling_realm: atmos
!----------------------------------
......@@ -670,77 +500,24 @@ modeling_realm: atmos
!----------------------------------
standard_name: air_temperature
units: K
cell_methods: time: maximum within days time: mean over days
cell_measures: area: areacella
long_name: Daily Maximum Near-Surface Air Temperature
comment: monthly mean of the daily-maximum near-surface (usually, 2 meter) air temperature.
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time height2m
out_name: tasmax
type: real
valid_min: 181.9
valid_max: 330.6
ok_min_mean_abs: 277.3
ok_max_mean_abs: 281.4
!----------------------------------
!
!============
variable_entry: psl
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: air_pressure_at_sea_level
units: Pa
cell_methods: time: mean
cell_measures: area: areacella
long_name: Sea Level Pressure
comment: not, in general, the same as surface pressure
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: psl
type: real
valid_min: 9.477e+04
valid_max: 1.124e+05
ok_min_mean_abs: 1.003e+05
ok_max_mean_abs: 1.017e+05
!----------------------------------
!
!============
variable_entry: ps
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: surface_air_pressure
units: Pa
cell_methods: time: mean
cell_measures: area: areacella
long_name: Surface Air Pressure
comment: not, in general, the same as mean sea-level pressure
long_name: Air Temperature
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: ps
dimensions: longitude latitude plevs time
out_name: ta
type: real
valid_min: 4.792e+04
valid_max: 1.093e+05
ok_min_mean_abs: 9.606e+04
ok_max_mean_abs: 9.743e+04
valid_min: 157.1
valid_max: 326.4
ok_min_mean_abs: 200.2
ok_max_mean_abs: 289.9
!----------------------------------
!
!============
variable_entry: uas
variable_entry: ua
!============
modeling_realm: atmos
!----------------------------------
......@@ -749,23 +526,22 @@ modeling_realm: atmos
standard_name: eastward_wind
units: m s-1
cell_methods: time: mean
long_name: Eastward Near-Surface Wind
comment: near-surface (usually, 10 meters) eastward component of wind.
long_name: Eastward Wind
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time height10m
out_name: uas
dimensions: longitude latitude plevs time
out_name: ua
type: real
valid_min: -19.01
valid_max: 18.68
ok_min_mean_abs: 1.668
ok_max_mean_abs: 4.106
valid_min: -68.65
valid_max: 136.6
ok_min_mean_abs: 1.101
ok_max_mean_abs: 22.42
!----------------------------------
!
!============
variable_entry: vas
variable_entry: va
!============
modeling_realm: atmos
!----------------------------------
......@@ -774,1614 +550,16 @@ modeling_realm: atmos
standard_name: northward_wind
units: m s-1
cell_methods: time: mean
long_name: Northward Near-Surface Wind
comment: near-surface (usually, 10 meters) northward component of wind.
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time height10m
out_name: vas
type: real
valid_min: -18.04
valid_max: 22.84
ok_min_mean_abs: 1.065
ok_max_mean_abs: 2.678
!----------------------------------
!
!============
variable_entry: sfcWind
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: wind_speed
units: m s-1
cell_methods: time: mean
long_name: Near-Surface Wind Speed
comment: near-surface (usually, 10 meters) wind speed. This is the mean of the speed, not the speed computed from the mean u and v components of wind
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time height10m
out_name: sfcWind
type: real
!----------------------------------
!
!============
variable_entry: hurs
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: relative_humidity
units: %
cell_methods: time: mean
cell_measures: area: areacella
long_name: Near-Surface Relative Humidity
comment: near-surface (usually, 2meters) relative humidity expressed as a percentage. This is the relative humidity with respect to liquid water for T> 0 C, and with respect to ice for T<0 C.
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time height2m
out_name: hurs
type: real
!----------------------------------
!
!============
variable_entry: huss
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: specific_humidity
units: 1
cell_methods: time: mean
cell_measures: area: areacella
long_name: Near-Surface Specific Humidity
comment: near-surface (usually, 2 meters) specific humidity.
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time height2m
out_name: huss
type: real
valid_min: -7.21e-06
valid_max: 0.02992
ok_min_mean_abs: 0.006391
ok_max_mean_abs: 0.008749
!----------------------------------
!
!============
variable_entry: pr
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: precipitation_flux
units: kg m-2 s-1
cell_methods: time: mean
cell_measures: area: areacella
long_name: Precipitation
comment: at surface; includes both liquid and solid phases from all types of clouds (both large-scale and convective)
long_name: Northward Wind
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: pr
dimensions: longitude latitude plevs time
out_name: va
type: real
valid_min: 0
valid_max: 0.001254
ok_min_mean_abs: 2.156e-05
ok_max_mean_abs: 3.215e-05
valid_min: -71.1
valid_max: 69.93
ok_min_mean_abs: 0.9886
ok_max_mean_abs: 4.679
!----------------------------------
!
!============
variable_entry: prsn
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: snowfall_flux
units: kg m-2 s-1
cell_methods: time: mean
cell_measures: area: areacella
long_name: Snowfall Flux
comment: at surface; includes precipitation of all forms of water in the solid phase
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: prsn
type: real
valid_min: 0
valid_max: 0.0002987
ok_min_mean_abs: 1.449e-06
ok_max_mean_abs: 6.11e-06
!----------------------------------
!
!============
variable_entry: prc
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: convective_precipitation_flux
units: kg m-2 s-1
cell_methods: time: mean
cell_measures: area: areacella
long_name: Convective Precipitation
comment: at surface; includes both liquid and solid phases.
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: prc
type: real
valid_min: 0
valid_max: 0.0006323
ok_min_mean_abs: -2.528e-06
ok_max_mean_abs: 3.209e-05
!----------------------------------
!
!============
variable_entry: evspsbl
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: water_evaporation_flux
units: kg m-2 s-1
cell_methods: time: mean
cell_measures: area: areacella
long_name: Evaporation
comment: at surface; flux of water into the atmosphere due to conversion of both liquid and solid phases to vapor (from underlying surface and vegetation)
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: evspsbl
type: real
!----------------------------------
!
!============
variable_entry: sbl
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: water_sublimation_flux
units: kg m-2 s-1
cell_methods: time: mean
cell_measures: area: areacella
long_name: Surface Snow and Ice Sublimation Flux
comment: The snow and ice sublimation flux is the loss of snow and ice mass from the surface resulting from their conversion to water vapor that enters the atmosphere. This differs from sbl appearing in table Limon in that the flux is averaged over the entire grid cell, not just the land portion.
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: sbl
type: real
valid_min: -0.004959
valid_max: 0.0009936
ok_min_mean_abs: -5.521e-05
ok_max_mean_abs: 9.61e-05
!----------------------------------
!
!============
variable_entry: tauu
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: surface_downward_eastward_stress
units: Pa
cell_methods: time: mean
long_name: Surface Downward Eastward Wind Stress
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: tauu
type: real
positive: down
valid_min: -2.729
valid_max: 2.934
ok_min_mean_abs: 0.03979
ok_max_mean_abs: 0.1065
!----------------------------------
!
!============
variable_entry: tauv
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: surface_downward_northward_stress
units: Pa
cell_methods: time: mean
long_name: Surface Downward Northward Wind Stress
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: tauv
type: real
positive: down
valid_min: -2.472
valid_max: 2.527
ok_min_mean_abs: 0.01447
ok_max_mean_abs: 0.08134
!----------------------------------
!
!============
variable_entry: hfls
!============
modeling_realm: atmos
!----------------------------------
! Variable attributes:
!----------------------------------
standard_name: surface_upward_latent_heat_flux
units: W m-2
cell_methods: time: mean
cell_measures: area: areacella
long_name: Surface Upward Latent Heat Flux
comment: includes both evaporation and sublimation
!----------------------------------
! Additional variable information:
!----------------------------------
dimensions: longitude latitude time
out_name: hfls
type: real
positive: up
valid_min: -76.77
valid_max: 790.7
ok_min_mean_abs: 50.39
ok_max_mean_abs: 73.2
!----------------------------------
!
!============