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

migrate HAMOCC config settings to run time namelist settings #281

Merged
merged 17 commits into from
Oct 24, 2023

Conversation

mvertens
Copy link
Contributor

@mvertens mvertens commented Oct 15, 2023

This PR builds on top of #280. Instead of using build time configuration settings for new HAMOCC use_XXX variables, namelist variables have been introduced instead. This allows HAMOCC to be configured at run time rather than at compile time. This PR was brought in as a separate pull request - but if desired be merged into #280.

The only files that are different with respect to #280 are

cime_config/buildcpp
cime_config/buildnml
cime_config/config_component.xml
cime_config/namelist_definition_blom.xml
drivers/mct/import_mct.F
drivers/nuopc/mod_nuopc_methods.F90
hamocc/hamocc4bcm.F90
hamocc/hamocc_init.F90
hamocc/mo_control_bgc.F90
hamocc/mo_param1_bgc.F90

@JorgSchwinger
Copy link
Contributor

I think we should merge #280 first - it gets very confusing, because I see all changes at the same time (maybe that's just because I don't know how to switch this of?).

Anyway - this PR seems also to bring in the changes with the fluxes calculated in the mediator, and there are some changes related to mct, too. Is this intended?

@mvertens
Copy link
Contributor Author

@JorgSchwinger - I agree. We need to bring in #280 first. The changes for fluxes in the mediator should not be there.
I'll fix this once we bring #280 in. But I thought it would be good to have a run-time configurable for hamocc - since we removed the #ifdefs. That will make it much easier to use I think.

atmco2_da(i,j,l2ci) =
. x2o_o%rAttr(index_x2o_Sa_co2prog,n)
endif
if (ocn_co2_type == 'prognostic') then
Copy link
Contributor

Choose a reason for hiding this comment

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

This would now need a #ifdef HAMOCC, too since ocn_co2_type will be undefined otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I will be testing this PR with mct as well.

if pg_blom.get_value('use_cisonew') == ".true.":
if pg_blom.bet_value("use_SEDBYPASS") == ".false.":
expect(False,
"HAMOCC C-isotopes currently not supported in the sediment module. Set use_SEDBYPASS to .true.")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be removed now, since C-isotopes with sediment is technically supported now.

@mvertens
Copy link
Contributor Author

@JorgSchwinger @TomasTorsvik @jmaerz - I'd really like some feedback as to what new tests I should add. I would propose at least the following:

  1. Add turning on the namelist flags to .true. for all of the following:
    USE_CFC = .true.
    USE_WLIN = .true.
    USE_CISONEW = .true.
    USE_NATDIC = .true.

  2. Do the above but turn on use_secbypass
    USE_CFC = .true.
    USE_WLIN = .true.
    USE_CISONEW = .true.
    USE_NATDIC = .true.
    USE_SEDBYPASS = .true.

I would do these as 5 day ERS tests at tn14

I also need to introduce tn21 for the development code - but I'll do that in a separate PR - since it will also need cice6 namelist changes.

@JorgSchwinger
Copy link
Contributor

Looks good to me. But note that switching the CFCs and natDIC options on will mostly only test that it compiles correctly - if no transient compset is used then natDIC=DIC and CDFs=0 all the time. For a transient compset (e.g., NOIIAOC20TR) one would need to restart from e.g. 1948. That would be the most meaningful test, but this might get too complicated.

@mvertens
Copy link
Contributor Author

@JorgSchwinger - thanks! I'm confused by the meaning of restart here.
Can we do an initial run for NOIIAOC20TR - and point to 1948 files? Or do we need to start it up as a branch run and use the restart files? I think its worthwhile to continue testing this the right way.

@JorgSchwinger
Copy link
Contributor

If we want to test natDIC and CFCs with "real" values we need to restart from 1948 files (or any other year over the period where atmospheric CFCs were > 0 and and atmospheric CO2 > 284)

@JorgSchwinger
Copy link
Contributor

Caveat: for CO2 this requires that transient CO2 is available through the data atmosphere

@mvertens mvertens requested review from jmaerz and removed request for matsbn October 18, 2023 10:45
Comment on lines -145 to -146
# HAMOCC bromoform scheme currently only supported on the tnx1v4 grid
# (no swa-climatology has been created for other grid configurations)"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is perhaps an important comment to preserve, i.e. why only tnx1v4 gid is supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TomasTorsvik - use_BROMO is now a namelist variable - not a CPP variable -
this is why I removed it from buildcpp. I have now added the comment to namelist_definition_blom.xml.

<desc>HAMOCC debug mode flag</desc>
</entry>

<entry id="use_BROMO">
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
<entry id="use_BROMO">
<!-- HAMOCC bromoform scheme currently only supported on the tnx1v4 grid -->
<!-- (no swa-climatology has been created for other grid configurations) -->
<entry id="use_BROMO">

Maybe something like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. Thanks!

@JorgSchwinger
Copy link
Contributor

Can we proceed with this PR? I would have two or three small PR that should go into release 1.4.0, but I think it would be better to merge this in first.

@mvertens
Copy link
Contributor Author

I have not had a chance to add the new test yet. Could you please give me this afternoon to add the test and create the baselines - then I'm fine with proceeding. Sorry for the delay.

@JorgSchwinger
Copy link
Contributor

Of course that's fine. Meanwhile I'll add some of the stuff already that will not interfere with this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mvertens, @TomasTorsvik, @jmaerz there are some things I came across during my own testing yesterday:

  1. for some HAMOCC entries a is_input_data="yes" flag is missing (inidic, inialk,inipo3,inioxy,inino3,ndepfile,fedepfile,rivinfile,swaclimfile).

  2. the value for ndepfile isn't generated correctly if blom_ndep_scenario=ssp* i.e. any of the SSPs (I guess $BLOM_NDEP_SCENARIO doesn't exist any longer?)

  3. do_sedspinup and sedspin_ncyc should have a modify_via_xml flag

  4. I think the C-iso option should stay as an option in env_run, and get the modify_via_xml flag, too

Maybe this could also be quickly fixed with this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JorgSchwinger - thanks for catching these! I will fix them in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for finding these. I've put in the fixes and am regenerating tests and baselines now.

@jmaerz
Copy link
Collaborator

jmaerz commented Oct 20, 2023

Dear @mvertens , many thanks for making the code more flexible to use! - could you also adjust the meson.build and meson_options.txt to reflect your code changes there as well - to further support the single column setup?

@mvertens
Copy link
Contributor Author

@jmaerz - I am happy to work on the meson build. However, could we please chat today so that I can understand how to test this - both in the new and old system. Also - should that fix be added to this PR?

@jmaerz
Copy link
Collaborator

jmaerz commented Oct 20, 2023

Hi @mvertens , sure, we can have a short conversation (while admittedly, I am also more a user of the meson.build system than developer). From what I know about it, it's just about cleaning out the previously used preprocessor flags for iHAMOCC (which are now configured via the config namelist). Wrt testing, I personally used to use it for the single column setup, which can be tested locally or on betzy and requires a limits file (generated from the namelist file), which I can provide (maybe need to update it to the latest developments). I am not sure, if there are other tests to perform than just check that such setup is still running. @TomasTorsvik: anything else to add on this?

@mvertens
Copy link
Contributor Author

@jmaerz - how do I run a single column test? Is this documented?

@jmaerz
Copy link
Collaborator

jmaerz commented Oct 20, 2023

Hi Mariana, it's described on the main page: https://github.com/NorESMhub/BLOM/ - maybe we chat quickly and then I'll provide the limits file, etc. afterward. If it is easier, I can also do the editing of the meson.build after the PR.

@jmaerz
Copy link
Collaborator

jmaerz commented Oct 20, 2023

Hi Mariana, I just realize that some files experienced too long lines and compilation failed in master when testing with meson.... - so some hotfix is needed before the single column testing could work. I could do that also in preparation for #292 .

@mvertens
Copy link
Contributor Author

A quick update:

  • I have incorporated fixes for the problems that were outlined by @JorgSchwinger.
  • I have generated a new baseline in /cluster/shared/noresm/noresm_baselines/aux_blom_noresm_20102023/.
  • I verified that answers do not change for those cases where we expect bfb.
  • I have two new tests that use the namelists settings for hamocc.
  • I will wait to work on the meson.build once fixes from @jmaerz are in.

@jmaerz
Copy link
Collaborator

jmaerz commented Oct 20, 2023

@mvertens: with #293 meson compiles again as expected.

@mvertens
Copy link
Contributor Author

I think at this point we should defer changes to the meson build until the next PR and try to get this one merged in if everyone is in agreement.

</entry>

<!-- hamocc configuration -->

Copy link
Collaborator

Choose a reason for hiding this comment

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

Dear @mvertens , if I understand the approach correct, the entry ids for use_Agg and use_BOXATM are missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmaerz - thanks for catching this. I think we need to add two more tests for use_BOXATM and use_AGG.
I'll do that today.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So in looking at the original buildcpp - BOXATM and AGG were never defined - and I only introduced namelists that corresponded to those variables. That was clearly an oversight on my part. Do we want to test turning these on with hamocc given that they were not defined as part of NorESM configurations before?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi Mariana, my suspicion is that both cases are not well supported, but I would hope that particularly AGG isn't broken (it was used the last time in a study by @JorgSchwinger). AGG should work within a coupled NorESM setup, while I have limited idea about BOXATM - I would need to look into it - I would suggest to skip the testing for BOXATM now, but I feel it would be good to enable switching it on via the xml. I hope to get through your changes by the end of the day.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmaerz - use_BOXATM and use_AGG are only turned on via user_nl_blom right now - no longer throught the xml since they are no longer CPP variables. I will test that use_AGG works and add a test today.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @mvertens , I just realize that use_FB_BGC_OCE might also be missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

BOXATM, AGG, FB_BGC_OCN all are options that have not been used quite some time. So currently, these are only for expert users who can activate these options via namelist switches if they know what they are doing.

How much it makes sense to include tests for these options I don't know, I wouldn't see this as a priority.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JorgSchwinger @jmaerz - I have added missing namelists use_boxatm, use_agg and use_fb_bgc_oce to the new namelist group config_bgc. Given the last statement by @JorgSchwinger - can we test these options after this PR and add appropriate tests if everyone agrees? Otherwise - I'm happy to test it in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @mvertens , from my side, I am totally fine to proceed as you suggested. The testing feature is different from the nml configuration.

Copy link
Collaborator

@jmaerz jmaerz left a comment

Choose a reason for hiding this comment

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

Dear @mvertens , apart from the comments that I had, it looks good to me.

@TomasTorsvik
Copy link
Contributor

@mvertens , @JorgSchwinger , @jmaerz
This PR has been approved by all reviewers. Is it OK to merge, or are there any more checks that should pass first?

@TomasTorsvik TomasTorsvik self-assigned this Oct 24, 2023
@TomasTorsvik TomasTorsvik added the iHAMOCC Issue mainly concerns the iHAMOCC code base label Oct 24, 2023
@TomasTorsvik TomasTorsvik added this to the preparing for noresm2.1 milestone Oct 24, 2023
@mvertens
Copy link
Contributor Author

@TomasTorsvik - I have verified that adding the new namelists to ocn_in does not change answers.
From my point of view - this PR is ready to be merged.

@jmaerz
Copy link
Collaborator

jmaerz commented Oct 24, 2023

Then go ahead @mvertens 👍

@TomasTorsvik TomasTorsvik merged commit 1d71682 into NorESMhub:master Oct 24, 2023
12 checks passed
@mvertens mvertens deleted the feature/refactor_ifdefs3 branch May 15, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iHAMOCC Issue mainly concerns the iHAMOCC code base
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants