named global parameters
When trying to achieve #28 (closed), we sometimes run in the case, that global_parameters occur in more than one transfer function (e.g. frac_sealed_city_area is applied on land_cover_fraction_sealed and land_cover_fraction_pervious. It is error prone to have them as different values in the global_parameter namelist. Thus, we must somehow link them.
One concept could be, that we support named global parameters. When defining transfer functions in a dynamic way, one could directly type the name of a parameter or constant that is required. When defining transfer functions in a static way (by name), the user must supply the names of the parameters in a similar way as the names of the data arrays. The parameters are first checked with a new namelist "constants", which resides in mpr.nml. If not found, they are checked for in "global_parameters", which resides in mpr_global_parameter.nml. If not found, they are parsed (assuming a real number).
This has the following advantages:
- it is much neater than #23 (closed)
- it allows for real numbers to be put in dynamically parsed transfer functions (a number cannot be at the beginning of a function name in Fortran though, a workaround would be to enclose it in brackets, e.g. type
(5.0 * bar)
instead of5.0 * bar
leading to the function namebs_5_0_x1_be
) - it keeps the namelist mpr_global_parameters.nml clean, so that it only contains parameters that are true parameters (e.g. created by an optimizer)
- it solves our issue... :)
To sum up, I propose an API change on the read_config, transfer_func initialization and the namelists:
In mpr.nml
&data_arrays
names(1) = "foo"
! the transfer function is dynamically parsed and pointed to
transfer_funcs(1) = "myconstant1 + myparam1 * bar"
from_data_arrays(1,1) = "bar"
names(2) = "foo2"
! the transfer function is static and pointed to
transfer_funcs(2) = "linear_1arg_intercept"
from_data_arrays(1,2) = "bar"
from_parameters(1:2,2) = "myconstant1", "myparam1"
! or also possible
! from_parameters(1:2,2) = "1.0", "-1.0"
/
&constants
! *this is new*
myconstant1 = -273.15
/
In mpr_global_parameter.nml
&global_parameters
! *new structure*
myparam1 = -1.0
/