MPAS-Dev / MPAS-Model

Repository for MPAS models and shared framework releases.
238 stars 317 forks source link

Eliminate the need to specify config_len_disp through the introduction of a new variable, nominalMinDc #1079

Closed mgduda closed 1 year ago

mgduda commented 1 year ago

This PR eliminates the need for users to specify config_len_disp in their namelist.atmosphere files by introducing a new scalar variable, nominalMinDc, which specifies the nominal minimum grid distance where meshDensity == 1.0. The nominalMinDc variable is read from the "input" stream by the init_atmosphere core and scaled along with other mesh fields like dcEdge and dvEdge; the nominalMinDc variable is then written to the "output" stream by the init_atmosphere core, making it available to the atmoshere core.

At start-up, the atmosphere core attempts to read both the config_len_disp namelist variable and the nominalMinDc variable, both of which default to 0.0.

1) If both config_len_disp and nominalMinDc are provided (in the namelist and input file, respectively) as positive values, the config_len_disp value is used as the horizontal length scale for horizontal diffusion and 3-d divergence damping; nominalMinDc is set to this value as well. Additionally, if config_len_disp and nominalMinDc differ (by more than ~1.0e-6 relative difference), a warning is printed to the log file; e.g.:

WARNING: nominalMinDc was read from input file as a positive value (120000.) that differs
WARNING: from the specified config_len_disp value (125000.)

2) If only one of config_len_disp and nominalMinDc is provided as a positive value, that positive value is used in the model (and in any case, nominalMinDc takes that value when written to model restart files).

3) If neither config_len_disp nor nominalMinDc are provided, the atmosphere core stops with an error:

      ERROR: Both config_len_disp and nominalMinDc are <= 0.0.
      ERROR: Please either specify config_len_disp in the &nhyd_model namelist group,
      ERROR: or use an input file that provides a valid value for the nominalMinDc variable.

The changes in this PR are backwards-compatible, in the sense that old mesh files that lack the nominalMinDc variable can still be used, in which case the user must supply the config_len_disp option in their namelist.atmosphere file.

mgduda commented 1 year ago

Code looks good and (correctly setup) tests did what I expected.

My only note is that in the PR description the following line isn't clear to me:

Additionally, if config_len_disp and nominalMinDc differ by more than 1 part in 10e6, a warning is printed ...

It might be clearer to say:

Additionally, if the difference between config_len_disp and nominalMinDc is greater than 1E-6, a warning is printed ...

Thanks for the suggestion. I've updated the PR description. The tolerance is actually 1e-6 scaled by config_len_disp, which I've tried to convey in the updated text.