marbl-ecosys / MARBL

Marine Biogeochemistry Library
https://marbl-ecosys.github.io
Other
13 stars 23 forks source link

Access MARBL constants without use statements? #259

Open mnlevy1981 opened 6 years ago

mnlevy1981 commented 6 years ago

The following parameters are defined in marbl_constants_mod.F90, but used in POP:

      molw_Fe   =  55.845_r8,          & ! molecular weight of iron (gFe / mol Fe)
      R13C_std  =   1.0_r8,            & ! actual 13C/12C PDB standard ratio (Craig, 1957) = 1123.72e-5_r8
      R14C_std =    1.0_r8               ! actual 14C/12C NOSAMS standard ratio = 11.76e-13_r8

If there was a data type similar to marbl_settings_type that allowed users to run get(), then we could eliminate the use marbl_constants_mod statements. In talking about this, though, @klindsay28 and I realized that there are a number of "constants" that are currently defined with Fortran's parameter attribute that we may want to allow the GCM to override:

      pi     =    3.14159265358979323846_r8
      vonkar    =   0.4_r8,            & ! von Karman constant
      T0_Kelvin = 273.15_r8,           & ! freezing T of fresh water (deg K)
      rho_sw    =   1.026_r8,          & ! density of salt water (g/cm^3)
      molw_Fe   =  55.845_r8,          & ! molecular weight of iron (gFe / mol Fe)
      R13C_std  =   1.0_r8,            & ! actual 13C/12C PDB standard ratio (Craig, 1957) = 1123.72e-5_r8
      R14C_std =    1.0_r8               ! actual 14C/12C NOSAMS standard ratio = 11.76e-13_r8

One possibility would be to move these variables to marbl_settings_mod, but this would require a change in default_settings.yaml (and the associated Python code) to avoid putting the default value in marbl_in: I envision the GCM calling put_setting() with its desired value, and then only over-writing that with a second put_setting() call if the user explicitly specified a different value in the MARBL input file. Having a value in the input file by default would mean the GCM's preference would always be ignored.

Note it might also be useful to include c14_halflife_years from marbl_ciso_mod.F90.

mnlevy1981 commented 5 years ago

From #334 --

Many GCMs will define T0_Kelvin and K_Boltz for non-MARBL computations. For consistency, we should provide a way for the GCM to tell MARBL what these values are. Options:

  1. Add additional [optional] arguments to marbl_instance%init()
  2. Add new subroutine marbl_instance%set_global_constants() (or set_physical_constants()?) that can be called before init()
  3. Move variables to marbl_settings_mod.F90 and use marbl_instance%put_setting()

I don't really like this last option because I don't know that we want users to be able to override the GCM value without editing the Fortran. I'm leaning towards the second option, where set_global_constants() is treated like put_setting() but without a file like user_nl_marbl to allow run-time configuration.

Note: POP could then populate these fields with values from share code (note that #328 wants K_Boltz in eV/K rather than J/K so POP would need to do the unit conversion)