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

always obtain ndep from datm or cam using cmeps/cdeps #410

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mvertens
Copy link
Contributor

@mvertens mvertens commented Oct 2, 2024

In noresm2_5, ndep is always sent to blom by either cam or datm - so there is no need to read a file.
This PR implements the functionality in blom to use this import data rather than reading a file.

  • a new namelist variable (use_nuopc_ndep) has been added to the namelist group config_bgc
  • by default use_nuopc_ndep will always be true if the coupling framework is using nuopc
  • if use_nuopc_ndep is true, then hamocc will bypass reading in ndep from a file and instead use import values.

Test 1: ERS_Ld3.ne30pg3_tn14.N1850.betzy_intel.allactive-defaultio
The left hand screen is the dev1.6.1.8 output for ndep whereas the right hand screen is the new output for ndep
The two have different behavior. The difference is due to the differerent ndep forcing files:

  • use_nuopc_ndep = .false. blom reads
    /cluster/shared/noresm/inputdata/ocn/blom/bndcon/ndep_1850_CMIP6_tnx1v4_20171106.nc
  • use_nuopc_ndep = .true. blom receives from cam
    /cluster/shared/noresm/inputdata/lnd/clm2/ndepdata/fndep_clm_WACCM6_CMIP6piControl001_y21-50avg_1850monthly_0.95x1.25_c180802.nc
  • note that /cluster/shared/noresm/inputdata/ocn/blom/bndcon/ndep_1850_CMIP6_tnx1v4_20171106.nc
    was obtained from an original fv1.9x2.5 dataset whereas cam is read in an fv09.x1.25 dataset.

Screenshot 2024-10-07 at 4 05 57 PM


Test 2: ERS_Ld3.TL319_tn14.NOIIAJRAOC.betzy_intel.blom-hybrid

  • in the new case - datm is reading the following file and then interpolating it to the model grid (TL319) and then the mediator in turn interpolations this to the blom grid (tnx1v4)
    /cluster/shared/noresm/inputdata/lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc
  • in the original case - blom is reading in the file
    /cluster/shared/noresm/inputdata/ocn/blom/bndcon/ndep_1850_CMIP6_tnx1v4_20171106.nc
    But this is incorrect since the compset is for 2000 (see ndep forcing file is incorrect for most compsets using DATM #411)
  • in the new case, using xmlchange DATM_PRESNDEP=clim_1850 now results in the following two comparisons
Screenshot 2024-10-02 at 10 42 54 PM

!$omp parallel do private(i)
do j=1,kpje
do i=1,kpie
ndep(i,j,idepnoy) = ndep(i,j,idepnoy) + ndep(i,j,idepnhx)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am a bit puzzled in this line: if use_extNcycle=.false., ndep is of size (..,..,1) and not (..,..,2) - see mo_param1_bgc. patmnoydep and patmnhxdep hold the fluxes coming from the nuopc cap, right? - hence I would suggest:

ndep(i,j,idepnoy) = (patmnoydep(i,j)+patmnhxdep(i,j))*fatmndep

Copy link
Collaborator

Choose a reason for hiding this comment

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

I I am not mistaken, this would also affect the former loop above.

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. You are totally right. I agree with your suggested change.

</values>
<desc>if region includes arctic ocean</desc>
</entry>

Copy link
Collaborator

Choose a reason for hiding this comment

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

Question out of curiosity: what is the use_arctic switch for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

use_arctic has a different communication pattern in mod_xc.F90.
In particular - it checks that all arctic patch tiles must be the same size or empty,
and empty tiles must be "twinned" across the top boundary. It ensures that the latitudinal tile dimension is closed/arctic and handles the halo in the arctic differently. @matsbn - do you want to add more?

@jmaerz
Copy link
Collaborator

jmaerz commented Oct 2, 2024

In the figures above (2nd test case): Something seem to be odd - the pattern look quite different and it doesn't seem having to do with the displayed ranges.


! if N-deposition is switched off set ndep to zero and return
if (.not. do_ndep) then
ndep(:,:,:) = 0.0
return
endif

! If use_nuopc_ndep, nitrogen deposition is ALWAYS obtained from the
! nuopc mediator
if (use_extNcycle .and. do_ndep_coupled) then

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 , I am not fully getting your logics here. If I am not mistaken, the source of N-deposition (whether it comes from CAM or from input files) will be decided at the level of the nuopc, right - so the do_ndep_coupled should appear somewhere else? - currently, the extended nitrogen cycle wouldn't be supported by nupc without the coupled fields to CAM, if I am not mistaken. If so, I would rewrite the code as follows (sorry for the formatting - it's a bit hard on github to keep the overview in a small text box):

if (use_nupc_ndep) then
         ! get N-deposition from atmosphere (either CAM or data)
        ndep(:,:,:) = 0.
        fatmndep = 365.*86400./mw_nitrogen
       
   if (use_extNcycle) then
      !$omp parallel do private(i)
        do j=1,kpje
          do i=1,kpie
            ! convert from kgN/m2/s to climatological input file units: kmolN/m2/yr
            if (patmnoydep(i,j) > 0.) then
              ndep(i,j,idepnoy) = patmnoydep(i,j)*fatmndep
            endif
            if (patmnhxdep(i,j) > 0.) then
              ndep(i,j,idepnhx) = patmnhxdep(i,j)*fatmndep
            endif
          enddo
        enddo
        !$omp end parallel do
        if (mnproc == 1 .and. first_call) then
          write (io_stdo_bgc,*) 'iHAMOCC: getting NOy and NHx deposition from atm'
        endif
   else ! standard N-cycle version
      !$omp parallel do private(i)
        do j=1,kpje
          do i=1,kpie
            ! convert from kgN/m2/s to climatological input file units: kmolN/m2/yr
            ! reduced and oxidized forms will all enter the NO3 pool
            ndep(i,j,idepnoy) = (patmnoydep(i,j)+patmnhxdep(i,j))*fatmndep
          enddo
        enddo
        !$omp end parallel do
   end if
else ! MCT coupler part - don't using nuopc
 ! read ndep data from file
      if (kplmon /= oldmonth) then
        month_in_file=(max(startyear,min(endyear,kplyear))-startyear)*12+kplmon
        if (mnproc == 1) then
          write(io_stdo_bgc,*) 'Read N deposition month ',month_in_file,' from file ',trim(ndepfile)
        endif
        ncstat=nf90_open(trim(ndepfile),nf90_nowrite,ncid)
        if (use_extNcycle) then
          call read_netcdf_var(ncid,'nhxdep',nhxdepread,1,month_in_file,0)
          call read_netcdf_var(ncid,'noydep',noydepread,1,month_in_file,0)
        else
          call read_netcdf_var(ncid,'ndep',ndepread,1,month_in_file,0)
        endif
        ncstat=nf90_close(ncid)
        oldmonth=kplmon
      endif
      !$omp parallel do private(i)
      do j=1,kpje
        do i=1,kpie
             if (use_extNcycle) then
            ndep(i,j,idepnoy) = noydepread(i,j)
            ndep(i,j,idepnhx) = nhxdepread(i,j)
           else
            ndep(i,j,idepnoy) = ndepread(i,j)
          endif
        enddo
      enddo
      !$omp end parallel do

    endif
endif

@mvertens
Copy link
Contributor Author

mvertens commented Oct 3, 2024

@jmaerz - I think a chat at this point would be helpful. My logic was the following:

  • You are correct that for nuopc - when regardless of if you are using the extended nitrogen cycle or not - you always get the ndep fields from cam. So you logic is correct.
  • In terms of do_ndep_coupled - that is not needed for nuopc but is needed for MCT if you are using the extended nitrogen cycle. The previous logic was if (use_extNcycle .and. do_ndep_coupled) then. I don't see that case in your block. Do we no longer need that?
  • I supposed that we could introduce another flag - get_ndep_from_atm which would contain the following logic:
    get_ndep_from_atm = ( use_nuopc_ndep .or. (use_extNcycle .and. do_ndep_coupled))
    and use this instead of if (use_nuopc_ndep). Does that make sense?
  • I mentioned to @matsbn this morning that supporting both nuopc and mct in blom at this point is getting quite complicated and that it would be good to separate out the branches. This would provide a lot of simplification to the blom code.

@jmaerz
Copy link
Collaborator

jmaerz commented Oct 3, 2024

Hi @mvertens , as a follow up on our call:
Here is the path to the nitrogen input data downloaded from esgf:
/cluster/projects/nn2980k/jma105/input_restart/bnd/Ndeposition and then there should be a folder with preparation under which the original files from the esgf node are located (sorry, just having issues logging in to betzy...). Ideally, these should be the input files for any component, as far as I can see/understand it.

@jmaerz
Copy link
Collaborator

jmaerz commented Oct 3, 2024

@Mats and @JorgSchwinger , just to inform you, I just discussed with @mvertens that for the optional extended nitrogen cycle, I don't see a need in master to support the online-coupling to CAM through the MCT coupler for nitrogen deposition (while deposition via input files is supported through both, nuopc and MCT - for a number of cases, the input files are currently not yet there for the extended nitrogen cycle, though). For the current default iHAMOCC, nothing changes (while there might be small changes in the input files, which we currently try to sort out). In ESM2025, I will likely rely on NorESM2.3, where the MCT online-coupling was/is supported. Any run for CMIP7 will anyway rely on nuopc, where both, the current default and the extended nitrogen cycle are supported with both options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants