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

Bugfix DNRA and introduce max_limiter #413

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Conversation

jmaerz
Copy link
Collaborator

@jmaerz jmaerz commented Oct 18, 2024

This PR only affects runs with the extended nitrogen cycle being switched on. It fixes a bug in the sediment DNRA pathway. In addition, I introduce a limiter (max_limiter) to avoid coming too close to available concentrations in one time step (avoiding turning values negative due to precision issues). Further: minor clean-up.

I am currently running a test by applying those changes to a BLOM v1.6.2 setup.

@JorgSchwinger and @TomasTorsvik, if possible and if tests are giving positive results, I would consider to request to also cherry pick this fix to the v.1.6.2 tag - leading to a bugfixed v1.6.3 which I can then use in my setups - I assume that this would be feasible since the N-cycle was anyway optional in v1.6.x

@jmaerz jmaerz self-assigned this Oct 18, 2024
@jmaerz jmaerz added bug Something isn't working iHAMOCC Issue mainly concerns the iHAMOCC code base code release Issues related to upcoming code release or tagging labels Oct 18, 2024
@jmaerz jmaerz added this to the NorESM2.5 - BLOM/iHAMOCC milestone Oct 18, 2024
@jmaerz jmaerz mentioned this pull request Oct 18, 2024
25 tasks
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.

@jmaerz - thanks, a few comments from my side, but nothing major.
I support introducing this bugfix also in the release-1.6 branch and make a new tag.

@@ -152,6 +153,7 @@ module mo_param_bgc
real, parameter :: c14_t_half = 5700.*365. ! Half life of 14C [days]

! Extended nitrogen cycle
real, parameter :: max_limiter = 0.9999 ! maximum in concentrations that can consumed at once
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
real, parameter :: max_limiter = 0.9999 ! maximum in concentrations that can consumed at once
real, parameter :: max_limiter = 0.9999 ! maximum in concentrations that can be consumed at once

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.

@@ -137,6 +137,7 @@ subroutine ocprod(kpie,kpje,kpke,kbnd,pdlxp,pdlyp,pddpo,omask,ptho,pi_ph,psao,pp
real :: wpocd,wcald,wopald,wdustd,dagg
real :: wcal,wdust,wopal,wpoc
real :: o2lim ! O2 limitation of ammonification (POC remin)
real, parameter :: tiny_num = 1e-25
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to define this parameter? If you just need a small number, there is the intrinsic function "tiny" for which tiny(0.0) will return the smallest positive real number.
See e.g. https://fortran-lang.org/en/learn/intrinsics/model/#tiny

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question, thanks - I exchanged the value by the epsilon function now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
real, parameter :: tiny_num = 1e-25
nh4uptfrac = anh4lim/(nlim+epsilon(1.))

Why not replace the tiny_num parameter? Now you have to look in the variable definition list to see that tiny_num = epsilon(1.)

Copy link
Contributor

Choose a reason for hiding this comment

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

That didn't come out as I intended. Point is, I'm not sure you need a tiny_num variable at all.

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'll/should go through the code again exchanging those numbers, which I'll do.

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 now went for your suggestion in mo_ocprod, while I introduced a parameter for the extended nitrogen cycle routines - I feel that this could be done generally throughout the code to define a small number that is generally used, but maybe not for now. Done.

@jmaerz
Copy link
Collaborator Author

jmaerz commented Oct 21, 2024

Hi @TomasTorsvik and @JorgSchwinger , I now checked the results of a 20a run in comparison to the former run and see very minor differences for the water column, while, of course, the sediment bug becomes fixed. Hence, I would suggest to push this fix.
In addition, and as already written, I would like to bring this bugfix into the release version 1.6.x as a new tagged version (since i) it fully supports MCT and ii) still enables CMIP6-compatible circulation). I understand that the default model should still produce the bfb results (which it does), while the N-cycle was thus far seen more as technical and optional. Hence, I am not seeing such fix in the N-cycle as critical for the release policy.

To inform further: I intend to experiment with one more process-implementation for the sediment (small change in how the rates are formulated), which in addition may come in to the sediment N-cycle (but this is beyond the present PR).

@jmaerz jmaerz merged commit 0886dda into NorESMhub:master Oct 23, 2024
5 checks passed
@jmaerz jmaerz deleted the debug_sediment branch October 23, 2024 13:08
TomasTorsvik pushed a commit to TomasTorsvik/BLOM-TTfork that referenced this pull request Oct 23, 2024
* Bugfix DNRA and introduce max_limiter
TomasTorsvik added a commit that referenced this pull request Oct 23, 2024
* Bugfix DNRA and introduce max_limiter
* Equivalent to PR #413, applied to the `release-1.6` branch

Co-authored-by: jmaerz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code release Issues related to upcoming code release or tagging iHAMOCC Issue mainly concerns the iHAMOCC code base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants