Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature iHAMOCC nml #261

Merged
merged 23 commits into from
Aug 9, 2023
Merged

Feature iHAMOCC nml #261

merged 23 commits into from
Aug 9, 2023

Conversation

jmaerz
Copy link
Collaborator

@jmaerz jmaerz commented Jul 4, 2023

Hi @TomasTorsvik and @JorgSchwinger , I create this draft pull request to follow up on and move the discussion #195 based on the current changes I did for the BGC parameter nml. I restructured the parameter initialization a bit related to the different topics of the parameters.

I currently see a few related questions:

  1. How shall we deal with parameters calculated from other (tunable) parameters? - shall we introduce functions or shall we ONLY calculate them after having read the namelist?
  2. Shall we continue putting atmospheric concentrations (as external controlling parameters) into the former BGC namelist, where atm_co2 is still located? - this would enable to recombine the further calculation of dependent concentrations (isotopes) and initializing the atmosphere fields.
  3. I thus far only introduced TYPICAL tuning parameters in the new nml. I personally would keep it like this or do you have a different opinion?
  4. I would like to delete the line breaks in the write parameter routine - any objections?
  5. I still need to delete the old subroutine that is still present (but not used anymore).

Thus far, I didn't move any of the parameter declarations to get the parameter values under the protect statement. I can do this, if you want me to do it. Just let me know.

@jmaerz jmaerz added enhancement New feature or request iHAMOCC Issue mainly concerns the iHAMOCC code base labels Jul 4, 2023
@jmaerz jmaerz self-assigned this Jul 4, 2023
#endif

implicit none

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A thought from my side: Having the variables that qualify as "parameters" defined in the module header of this module would simplify things a lot. Those variables that are truly "parameters" could be defined as such and assigned a value (that isn't changed), e.g.

integer, parameter :: rcar =122

Parameters that can be modified via namelist could be assigned a default value, e.g.

real, save :: atm_co2 = 284.32

Then the problem of having to recalculate things after reading of the namelist would be obsolete, and the module would be much simpler (plus it would be much more transparent to the user - the fact that all parameter definition are scattered between different modules now isn't very nice in my opinion.

Of course this is more invasive and much more work (a lot of use statements would need to be changed).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JorgSchwinger , seeing the upcoming pull request in #264 (and potentially my nitrogen cycle), I currently would opt for a step-wise approach, so first introducing this less invasive step, and after pulling in Marianas changes doing a second step and following your suggestion, potentially even go the step with the protect statement, what @TomasTorsvik suggested. Let's discuss this in person.

ENDDO
ENDDO
end subroutine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 subroutines above could be simplified and combined into one routine if we would follow the idea of defining all parameters inside this module (as opposed to importing them)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JorgSchwinger , I -partially- agree - the calculation and field initialization need to be carried out after reading the namelist, while the initial default initialization could be done before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave it for now and re-think about it, once introducing the protect statements after #264 was coming in.

integer :: iounit

namelist /bgcparams/ bkphy,dyphy,bluefix,bkzoo,grazra,spemor,gammap,gammaz,ecan,zinges,epsher,bkopal,rcalc,ropal, &
& remido,drempoc,dremopal,dremn2o,dremsul,fetune,relaxfe,wpoc,wcal,wopal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wpoc would only be used directly if the old HAMOCC sinking (constant wpoc) is used. Shouldn't we rather include wmin/wmax/wlin of the WLIN scheme as tuning parameters? (I would even be tempted to remove the constant sinking completely from HAMOCC, since this produces crap results)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am totally happy to extend the parameter list of the namelist. So far, I saw the new namelist as extendable and only for relevant parameters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I left the constant sinking, though - can be discussed afterward in an extra PR.

!
perc_diron = fetune * 0.035 * 0.01 / 55.85

end subroutine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this remains the only parameter to adjust, I think it is better to just have this line in the main routine instead of making a separate subroutine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, if I understand, what you consider the main routine here. I guess, my intention was to provide a structure , which one can follow.

Copy link
Contributor

@TomasTorsvik TomasTorsvik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine for me

hamocc/beleg_vars.F90 Outdated Show resolved Hide resolved
@jmaerz
Copy link
Collaborator Author

jmaerz commented Aug 2, 2023

To briefly summarize the conversation on this PR: To avoid too many merging conflicts, the potential restructuring wrt protect statements and pulling all parameters into one module is envisaged in an extra PR, once #264 is merged into master.

@jmaerz
Copy link
Collaborator Author

jmaerz commented Aug 2, 2023

Hi @TomasTorsvik and @JorgSchwinger , I tested the branch against the current master using the NOINYOC T62_tn21 setup and ran the model for 1 year and checked successfully for binary identical results.

How to use the new feature (thus far, tested):
After model setup (./case.setup), copy the ./components/blom/cime_config/buildnml to the ./SourceMods/src.blom/ folder (no further subfolders needed). In this copy of buildnml, enter the parameters that you wish to change in the BGCPARAMS namelist (for available parameters, see code, potentially add it, if needed - careful with rates and parameters that are required for further calculation of other parameters - make sure that they are converted and applied after reading the namelist - currently, this should be ensured, but with new developments, this needs care-taking). Parameters available through the user_nl_blom are still possible to change via an additionally provided user namelist for BLOM (so nothing changed in this regards).

I will perform the pull once the boxatm change #265 has been merged into master. Afterward, I will also merge these changes into the feature-HAMOCC_beyond-CMIP6 branch. Once the ifdefs refactoring #264 are merged into master, we can proceed with restructuring the parameter declaration and initialization.

@jmaerz jmaerz marked this pull request as ready for review August 2, 2023 16:41
@jmaerz jmaerz requested a review from JorgSchwinger August 7, 2023 10:16
! NAMELIST BGCPARAMS FOR iHAMOCC-BGC PARAMETERS (DEVELOPERS ONLY)
!
! CONTENTS: EMPTY BY DEFAULT
! FOR ADJUSTABLE PARAMETERS, SEE CODE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we have settled on a set of parameters, it would be good to list those here

@@ -48,6 +48,7 @@ subroutine hamocc_init(read_rest,rstfnm_hamocc)
& dtb,dtbgc,io_stdo_bgc,ldtbgc, &
& ldtrunbgc,ndtdaybgc,with_dmsph,l_3Dvarsedpor
use mo_param1_bgc, only: ks,init_por2octra_mapping
use mo_parambgc_ini,only: ini_parambgc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we plan to have all parameters defined within the module (in the longer run), the name mo_parambgc_ini is not really the best, in my opinion. mo_param_bgc would be better (but that is too close to mo_param1_bgc?). Not sure what to do about it.

! factor for normalizing 14C tracers (~1e-12)
c14fac = atm_c14/atm_co2
#endif
end subroutine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A matter of personal taste, but I would prefer to have not too many small subroutines. I would place the calculations done here in other routines: The 3 first lines could go into ini_param_atm and the rest into ini_fields_atm (d13C_atm is only used to print out the value, so it could go into write_parambgc)

call readjust_param() ! potentially readjust namlist parameter-dependent parameters
call rates_2_timestep() ! Converting rates from /d... to /dtb

call write_parambgc() ! write out used parameters and calculate back rates from /dtb to /d..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to write out the parameter BEFORE multiplying by dtb? If I want to check the settings of parameters in the log file, I relate much more to the value that I have set via namelist than the value multiplied by dtb.

@jmaerz
Copy link
Collaborator Author

jmaerz commented Aug 9, 2023

To briefly summarize (incl. the short-conversation today), before merging:

  • After merging, and once remove most hamocc #ifdefs in favorite of new logicals #264 has been merged in, we can i) implement the protect statements and ii) potentially slightly restructure mo_param_bgc wrt to the number of subroutines. This includes potentially shifting the initialization of the atmosphere field into beleg_vars. Further mo_param1_bgc could be renamed to mo_param_tracer in that process.
  • In write_parambgc, rates are multiplied with an inverse of dtbgc so that the namelist parameter is comparable - not refinding the nml-provided parameter give rise to an intended double-check.
  • Wrt to explicitly mentioning the BGC nml parameters: we can discuss this again. I would tend to not state them explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request iHAMOCC Issue mainly concerns the iHAMOCC code base
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants