diff --git a/bld/build-namelist b/bld/build-namelist index 66c3574a62..6dd96595d9 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -509,14 +509,6 @@ if ($phys_mode_flags > 1) { my $simple_phys = 0; if ($adia_mode or $ideal_mode) { $simple_phys = 1; } -# If running either a simple physics or an aquaplanet configuration, the nitrogen -# deposition data is not used. These files are set in buildnml and can't be overridden -# via user_nl_cam. So provide an override here. -if ($simple_phys or $aqua_mode) { - $nl->set_variable_value('ndep_stream_nl', 'stream_ndep_data_filename', '" "'); - $nl->set_variable_value('ndep_stream_nl', 'stream_ndep_mesh_filename', '" "'); -} - # Single column mode my $scam = $cfg->get('scam'); my $scam_iop = $cfg->get('scam_iop'); diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index 462570da4a..ab2707290c 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2060,6 +2060,13 @@ atm/cam/dst/dst_source2x2tuned-cam4-06132012.nc atm/cam/dst/dst_source1x1tuned-cam4-06202012.nc + +lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc +share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc +2000 +2000 +1 + .false. .true. diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index bd003c779a..4aaa038224 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -7609,40 +7609,29 @@ Bubble-mediated sea-air transfer. See ocean_emis.F90 for details. Default: FALSE - -List of nitrogen deposition fluxes to be sent from CAM to surface models. -Default: set by build-namelist. - - -Year first to use in nitrogen deposition stream data. Set by case xml variable -CAM_STREAM_NDEP_YEAR_FIRST +Year first to use in nitrogen deposition stream data. Year last to use in nitrogen deposition stream data. -Set by case xml variable CAM_STREAM_NDEP_YEAR_LAST -Model year to align with CAM_STREAM_NDEP_YEAR_FIRST. -Set by case xml variable CAM_STREAM_NDEP_YEAR_ALIGN +Model year to align with stream_ndep_year_first. -NDEP stream data filename. -Set by case xml variable CAM_STREAM_NDEP_DATA_FILENAME. +Nitrogen deposition stream data filename. -NDEP mesh file corresponding to sream_ndep_data_filename. -Set by case xml variable CAM_STREAM_NDEP_MESH_FILENAME. +Grid mesh file corresponding to stream_ndep_data_filename. CYCLICAL 1850 + +lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc +share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc +1850 +1850 +1 + diff --git a/bld/namelist_files/use_cases/1850_cam_mt.xml b/bld/namelist_files/use_cases/1850_cam_mt.xml index 5a535f27be..df05241070 100644 --- a/bld/namelist_files/use_cases/1850_cam_mt.xml +++ b/bld/namelist_files/use_cases/1850_cam_mt.xml @@ -56,4 +56,11 @@ CYCLICAL 1850 + +lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc +share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc +1850 +1850 +1 + diff --git a/bld/namelist_files/use_cases/hist_cam_lt.xml b/bld/namelist_files/use_cases/hist_cam_lt.xml index c436b97c1f..a7cd6c0e9c 100644 --- a/bld/namelist_files/use_cases/hist_cam_lt.xml +++ b/bld/namelist_files/use_cases/hist_cam_lt.xml @@ -42,4 +42,11 @@ INTERP_MISSING_MONTHS SERIAL + +lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc +share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc +1850 +2015 +1850 + diff --git a/bld/namelist_files/use_cases/hist_cam_mt.xml b/bld/namelist_files/use_cases/hist_cam_mt.xml index c100cc6e85..63b6691929 100644 --- a/bld/namelist_files/use_cases/hist_cam_mt.xml +++ b/bld/namelist_files/use_cases/hist_cam_mt.xml @@ -37,4 +37,11 @@ INTERP_MISSING_MONTHS SERIAL + +lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc +share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc +1850 +2015 +1850 + diff --git a/cime_config/buildnml b/cime_config/buildnml index 9c156b66d5..674d1a29ea 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -48,12 +48,6 @@ def buildnml(case, caseroot, compname): RUN_REFTOD = case.get_value("RUN_REFTOD") COMP_INTERFACE = case.get_value("COMP_INTERFACE") - stream_ndep_year_first = case.get_value("CAM_STREAM_NDEP_YEAR_FIRST") - stream_ndep_year_last = case.get_value("CAM_STREAM_NDEP_YEAR_LAST") - stream_ndep_year_align = case.get_value("CAM_STREAM_NDEP_YEAR_ALIGN") - stream_ndep_data_filename = case.get_value("CAM_STREAM_NDEP_DATA_FILENAME") - stream_ndep_mesh_filename = case.get_value("CAM_STREAM_NDEP_MESH_FILENAME") - testsrc = os.path.join(srcroot, "components", "cam") if os.path.exists(testsrc): srcroot = testsrc @@ -173,12 +167,6 @@ def buildnml(case, caseroot, compname): buildnl_opts += ["-inputdata", input_data_list] - CAM_NAMELIST_OPTS += " stream_ndep_year_first=" + stream_ndep_year_first - CAM_NAMELIST_OPTS += " stream_ndep_year_last=" + stream_ndep_year_last - CAM_NAMELIST_OPTS += " stream_ndep_year_align=" + stream_ndep_year_align - CAM_NAMELIST_OPTS += " stream_ndep_data_filename='" + stream_ndep_data_filename.strip() + "'" - CAM_NAMELIST_OPTS += " stream_ndep_mesh_filename='" + stream_ndep_mesh_filename.strip() + "'" - buildnl_opts += ["-namelist", '" &atmexp ' + CAM_NAMELIST_OPTS + '/" '] diff --git a/cime_config/config_component.xml b/cime_config/config_component.xml index 2ab0a50558..ef718404f5 100644 --- a/cime_config/config_component.xml +++ b/cime_config/config_component.xml @@ -383,79 +383,6 @@ User mods to apply to specific compset matches. - - - - char - 2000 - - 1850 - 2010 - 1850 - 2015 - - run_component_cam - env_run.xml - Nitrogen deposition data year first - - - - char - 2000 - - 2010 - 1850 - 2015 - 2101 - - run_component_cam - env_run.xml - Nitrogen deposition data year last - - - - char - 1 - - 1850 - 2015 - - run_component_cam - env_run.xml - Nitrogen deposition align CAM_STREAM_NDEP_YEAR_FIRST with this model year - - - - - char - UNSET - - $DIN_LOC_ROOT/lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP5-8.5-WACCM_1849-2101_monthly_c191007.nc - $DIN_LOC_ROOT/lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP1-2.6-WACCM_1849-2101_monthly_c191007.nc - $DIN_LOC_ROOT/lnd/clm2/ndepdata/fndep_clm_f09_g17.CMIP6-SSP2-4.5-WACCM_1849-2101_monthly_c191007.nc - $DIN_LOC_ROOT/lnd/clm2/ndepdata/fndep_clm_SSP370_b.e21.BWSSP370cmip6.f09_g17.CMIP6-SSP3-7.0-WACCM.002_1849-2101_monthly_0.9x1.25_c211216.nc - $DIN_LOC_ROOT/lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc - $DIN_LOC_ROOT/lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc - $DIN_LOC_ROOT/lnd/clm2/ndepdata/fndep_clm_hist_b.e21.BWHIST.f09_g17.CMIP6-historical-WACCM.ensmean_1849-2015_monthly_0.9x1.25_c180926.nc - $DIN_LOC_ROOT/lnd/clm2/ndepdata/fndep_clm_WACCM6_CMIP6piControl001_y21-50avg_1850monthly_0.95x1.25_c180802.nc - - run_component_cam - env_run.xml - Nitrogen deposition data filename - - - - char - $DIN_LOC_ROOT/share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc - run_component_cam - env_run.xml - Nitrogen deposition mesh filename (corresponding to the CAM_STREAM_NDEP_DATA_FILENAME) - - ========================================= CAM naming conventions diff --git a/src/chemistry/mozart/chemistry.F90 b/src/chemistry/mozart/chemistry.F90 index 085bd2237b..6527b0ccc1 100644 --- a/src/chemistry/mozart/chemistry.F90 +++ b/src/chemistry/mozart/chemistry.F90 @@ -24,6 +24,7 @@ module chemistry use ref_pres, only : ptop_ref use phys_control, only : waccmx_is ! WACCM-X switch query function use phys_control, only : use_hemco ! HEMCO switch logical + use mo_chm_diags, only : chem_has_ndep_flx => chm_prod_ndep_flx implicit none private @@ -46,6 +47,7 @@ module chemistry public :: chem_read_restart public :: chem_init_restart public :: chem_emissions + public :: chem_has_ndep_flx integer, public :: imozart = -1 ! index of 1st constituent @@ -1147,6 +1149,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dt, pbuf, fh2o) use mo_neu_wetdep, only : neu_wetdep_tend use aerodep_flx, only : aerodep_flx_prescribed use short_lived_species, only : short_lived_species_writeic + use atm_stream_ndep, only : ndep_stream_active implicit none @@ -1265,11 +1268,13 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dt, pbuf, fh2o) cam_out%precc, cam_out%precl, cam_in%snowhland, ghg_chem, state%latmapback, & drydepflx, wetdepflx, cam_in%cflx, cam_in%fireflx, cam_in%fireztop, & nhx_nitrogen_flx, noy_nitrogen_flx, use_hemco, ptend%q, pbuf ) - if (associated(cam_out%nhx_nitrogen_flx)) then - cam_out%nhx_nitrogen_flx(:ncol) = nhx_nitrogen_flx(:ncol) - endif - if (associated(cam_out%noy_nitrogen_flx)) then - cam_out%noy_nitrogen_flx(:ncol) = noy_nitrogen_flx(:ncol) + if (.not.ndep_stream_active) then + if (associated(cam_out%nhx_nitrogen_flx)) then + cam_out%nhx_nitrogen_flx(:ncol) = nhx_nitrogen_flx(:ncol) + endif + if (associated(cam_out%noy_nitrogen_flx)) then + cam_out%noy_nitrogen_flx(:ncol) = noy_nitrogen_flx(:ncol) + endif endif call t_stopf( 'chemdr' ) diff --git a/src/chemistry/mozart/mo_chm_diags.F90 b/src/chemistry/mozart/mo_chm_diags.F90 index 5650403fee..1a11b2b39d 100644 --- a/src/chemistry/mozart/mo_chm_diags.F90 +++ b/src/chemistry/mozart/mo_chm_diags.F90 @@ -18,6 +18,7 @@ module mo_chm_diags public :: chm_diags_inti public :: chm_diags public :: het_diags + public :: chm_prod_ndep_flx integer :: id_n,id_no,id_no2,id_no3,id_n2o5,id_hno3,id_ho2no2,id_clono2,id_brono2 integer :: id_isopfdn, id_isopfdnc, id_terpfdn !these are dinitrates @@ -55,6 +56,8 @@ module mo_chm_diags real(r8), parameter :: N_molwgt = 14.00674_r8 real(r8), parameter :: S_molwgt = 32.066_r8 + logical, protected :: chm_prod_ndep_flx =.false. + contains subroutine chm_diags_inti @@ -330,6 +333,8 @@ subroutine chm_diags_inti toth_species = (/ id_ch4, id_h2o, id_h2 /) + chm_prod_ndep_flx = any(noy_species>0) .or. any(nhx_species>0) + call addfld( 'NOX', (/ 'lev' /), 'A', 'mol/mol', 'nox (N+NO+NO2)' ) call addfld( 'NOY', (/ 'lev' /), 'A', 'mol/mol', & 'noy = total nitrogen (N+NO+NO2+NO3+2N2O5+HNO3+HO2NO2+ORGNOY+NH4NO3)' ) diff --git a/src/chemistry/pp_none/chemistry.F90 b/src/chemistry/pp_none/chemistry.F90 index 7e67fadb6e..9da9aa0852 100644 --- a/src/chemistry/pp_none/chemistry.F90 +++ b/src/chemistry/pp_none/chemistry.F90 @@ -7,7 +7,7 @@ module chemistry use shr_kind_mod, only: r8 => shr_kind_r8 use physics_types, only: physics_state, physics_ptend use ppgrid, only: begchunk, endchunk, pcols - + implicit none private @@ -27,9 +27,10 @@ module chemistry public :: chem_write_restart public :: chem_read_restart public :: chem_init_restart - public :: chem_readnl ! read chem namelist + public :: chem_readnl ! read chem namelist public :: chem_reset_fluxes public :: chem_emissions + public :: chem_has_ndep_flx interface chem_write_restart module procedure chem_write_restart_bin @@ -40,6 +41,8 @@ module chemistry module procedure chem_read_restart_pio end interface + logical, parameter :: chem_has_ndep_flx = .false. + ! Private data !================================================================================================ @@ -61,10 +64,10 @@ end function chem_is subroutine chem_register use aero_model, only : aero_model_register - !----------------------------------------------------------------------- - ! + !----------------------------------------------------------------------- + ! ! Purpose: register advected constituents for parameterized greenhouse gas chemistry - ! + ! !----------------------------------------------------------------------- ! for prescribed aerosols @@ -95,12 +98,12 @@ end function chem_is_active !================================================================================================ function chem_implements_cnst(name) - !----------------------------------------------------------------------- - ! + !----------------------------------------------------------------------- + ! ! Purpose: return true if specified constituent is implemented by this package - ! + ! ! Author: B. Eaton - ! + ! !----------------------------------------------------------------------- implicit none !-----------------------------Arguments--------------------------------- @@ -115,11 +118,11 @@ end function chem_implements_cnst !=============================================================================== subroutine chem_init(phys_state, pbuf2d) - !----------------------------------------------------------------------- - ! + !----------------------------------------------------------------------- + ! ! Purpose: initialize parameterized greenhouse gas chemistry ! (declare history variables) - ! + ! !----------------------------------------------------------------------- use physics_buffer, only : physics_buffer_desc use aero_model, only : aero_model_init @@ -138,7 +141,7 @@ subroutine chem_timestep_init(phys_state, pbuf2d) use physics_buffer, only : physics_buffer_desc use time_manager, only: get_curr_date, get_perp_date, get_curr_calday, & is_perpetual - type(physics_state), intent(in):: phys_state(begchunk:endchunk) + type(physics_state), intent(in):: phys_state(begchunk:endchunk) type(physics_buffer_desc), pointer :: pbuf2d(:,:) @@ -162,7 +165,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dt, pbuf, fh2o) type(cam_out_t), intent(in) :: cam_out type(physics_buffer_desc), pointer :: pbuf(:) real(r8), optional, intent(out) :: fh2o(pcols) ! h2o flux to balance source from chemistry - + return end subroutine chem_timestep_tend @@ -215,7 +218,7 @@ subroutine chem_init_restart(File) end subroutine chem_init_restart !================================================================================ subroutine chem_reset_fluxes( fptr, cam_in ) - use camsrfexch, only : cam_in_t + use camsrfexch, only : cam_in_t real(r8), pointer :: fptr(:,:) ! pointer into array data type(cam_in_t), intent(inout) :: cam_in(begchunk:endchunk) @@ -223,7 +226,7 @@ subroutine chem_reset_fluxes( fptr, cam_in ) end subroutine chem_reset_fluxes !================================================================================ subroutine chem_emissions( state, cam_in, pbuf ) - use camsrfexch, only: cam_in_t + use camsrfexch, only: cam_in_t use physics_buffer, only: physics_buffer_desc ! Arguments: diff --git a/src/control/camsrfexch.F90 b/src/control/camsrfexch.F90 index 0357ba3128..8111785cd1 100644 --- a/src/control/camsrfexch.F90 +++ b/src/control/camsrfexch.F90 @@ -9,14 +9,12 @@ module camsrfexch use constituents, only: pcnst use ppgrid, only: pcols, begchunk, endchunk use phys_grid, only: get_ncols_p, phys_grid_initialized - use infnan, only: posinf, assignment(=) + use infnan, only: nan, posinf, assignment(=) use cam_abortutils, only: endrun use cam_logfile, only: iulog use srf_field_check, only: active_Sl_ram1, active_Sl_fv, active_Sl_soilw, & - active_Fall_flxdst1, active_Fall_flxvoc, active_Fall_flxfire, & - active_Faxa_nhx, active_Faxa_noy - - + active_Fall_flxdst1, active_Fall_flxvoc, active_Fall_flxfire + use cam_control_mod, only: aqua_planet, simple_phys implicit none private @@ -100,7 +98,7 @@ module camsrfexch real(r8) :: tref(pcols) ! ref height surface air temp real(r8) :: qref(pcols) ! ref height specific humidity real(r8) :: u10(pcols) ! 10m wind speed - real(r8) :: ugustOut(pcols) ! gustiness added + real(r8) :: ugustOut(pcols) ! gustiness added real(r8) :: u10withGusts(pcols) ! 10m wind speed with gusts added real(r8) :: ts(pcols) ! merged surface temp real(r8) :: sst(pcols) ! sea surface temp @@ -325,14 +323,20 @@ subroutine atm2hub_alloc( cam_out ) cam_out(c)%dstwet4(:) = 0._r8 nullify(cam_out(c)%nhx_nitrogen_flx) - allocate (cam_out(c)%nhx_nitrogen_flx(pcols), stat=ierror) - if ( ierror /= 0 ) call endrun(sub//': allocation error nhx_nitrogen_flx') - cam_out(c)%nhx_nitrogen_flx(:) = 0._r8 - nullify(cam_out(c)%noy_nitrogen_flx) - allocate (cam_out(c)%noy_nitrogen_flx(pcols), stat=ierror) - if ( ierror /= 0 ) call endrun(sub//': allocation error noy_nitrogen_flx') - cam_out(c)%noy_nitrogen_flx(:) = 0._r8 + + if (.not.(simple_phys .or. aqua_planet)) then + + allocate (cam_out(c)%nhx_nitrogen_flx(pcols), stat=ierror) + if ( ierror /= 0 ) call endrun(sub//': allocation error nhx_nitrogen_flx') + cam_out(c)%nhx_nitrogen_flx(:) = nan + + allocate (cam_out(c)%noy_nitrogen_flx(pcols), stat=ierror) + if ( ierror /= 0 ) call endrun(sub//': allocation error noy_nitrogen_flx') + cam_out(c)%noy_nitrogen_flx(:) = nan + + endif + end do end subroutine atm2hub_alloc diff --git a/src/control/runtime_opts.F90 b/src/control/runtime_opts.F90 index 915664cdb9..f7bc2a40ff 100644 --- a/src/control/runtime_opts.F90 +++ b/src/control/runtime_opts.F90 @@ -102,6 +102,7 @@ subroutine read_namelist(nlfilename, single_column, scmlat, scmlon) use cam_budget, only: cam_budget_readnl use phys_grid_ctem, only: phys_grid_ctem_readnl use mo_lightning, only: lightning_readnl + use atm_stream_ndep, only: stream_ndep_readnl !---------------------------Arguments----------------------------------- @@ -205,6 +206,7 @@ subroutine read_namelist(nlfilename, single_column, scmlat, scmlon) call hemco_readnl(nlfilename) call cam_budget_readnl(nlfilename) call phys_grid_ctem_readnl(nlfilename) + call stream_ndep_readnl(nlfilename) end subroutine read_namelist diff --git a/src/cpl/nuopc/atm_import_export.F90 b/src/cpl/nuopc/atm_import_export.F90 index b3e16bee8c..b5b56b8112 100644 --- a/src/cpl/nuopc/atm_import_export.F90 +++ b/src/cpl/nuopc/atm_import_export.F90 @@ -22,10 +22,10 @@ module atm_import_export use srf_field_check , only : set_active_Fall_flxfire use srf_field_check , only : set_active_Fall_fco2_lnd use srf_field_check , only : set_active_Faoo_fco2_ocn - use srf_field_check , only : set_active_Faxa_nhx - use srf_field_check , only : set_active_Faxa_noy - use srf_field_check , only : active_Faxa_nhx, active_Faxa_noy - use atm_stream_ndep , only : stream_ndep_init, stream_ndep_interp, stream_ndep_is_initialized, use_ndep_stream + use atm_stream_ndep , only : stream_ndep_init, stream_ndep_interp, stream_ndep_is_initialized + use atm_stream_ndep , only : ndep_stream_active + use chemistry , only : chem_has_ndep_flx + use cam_control_mod , only : aqua_planet, simple_phys implicit none private ! except @@ -60,7 +60,6 @@ module atm_import_export integer :: drydep_nflds = -huge(1) ! number of dry deposition velocity fields lnd-> atm integer :: megan_nflds = -huge(1) ! number of MEGAN voc fields from lnd-> atm integer :: emis_nflds = -huge(1) ! number of fire emission fields from lnd-> atm - integer, public :: ndep_nflds = -huge(1) ! number of nitrogen deposition fields from atm->lnd/ocn logical :: atm_provides_lightning = .false. ! cld to grnd lightning flash freq (min-1) character(*),parameter :: F01 = "('(cam_import_export) ',a,i8,2x,i8,2x,d21.14)" character(*),parameter :: F02 = "('(cam_import_export) ',a,i8,2x,i8,2x,i8,2x,d21.14)" @@ -79,13 +78,11 @@ subroutine read_surface_fields_namelists() use shr_megan_mod , only : shr_megan_readnl use shr_fire_emis_mod , only : shr_fire_emis_readnl use shr_carma_mod , only : shr_carma_readnl - use shr_ndep_mod , only : shr_ndep_readnl use shr_lightning_coupling_mod, only : shr_lightning_coupling_readnl character(len=*), parameter :: nl_file_name = 'drv_flds_in' ! read mediator fields options - call shr_ndep_readnl(nl_file_name, ndep_nflds) call shr_drydep_readnl(nl_file_name, drydep_nflds) call shr_megan_readnl(nl_file_name, megan_nflds) call shr_fire_emis_readnl(nl_file_name, emis_nflds) @@ -194,16 +191,7 @@ subroutine advertise_fields(gcomp, flds_scalar_name, rc) call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Sa_co2diag' ) end if - if (ndep_nflds > 0) then - ! The following is when CAM/WACCM computes ndep - call set_active_Faxa_nhx(.true.) - call set_active_Faxa_noy(.true.) - else - ! The following is used for reading in stream data, or for aquaplanet or simple model - ! cases where the ndep fluxes are not used. - call set_active_Faxa_nhx(.false.) - call set_active_Faxa_noy(.false.) - end if + ! Nitrogen deposition fluxes ! Assume that 2 fields are always sent as part of Faxa_ndep call fldlist_add(fldsFrAtm_num, fldsFrAtm, 'Faxa_ndep', ungridded_lbound=1, ungridded_ubound=2) @@ -1121,10 +1109,8 @@ subroutine export_fields( gcomp, model_mesh, model_clock, cam_out, rc) call state_getfldptr(exportState, 'Faxa_ndep', fldptr2d=fldptr_ndep, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (.not. active_Faxa_nhx .and. .not. active_Faxa_noy) then - ! ndep fields not active (i.e., not computed by WACCM). Either they are not needed, - ! or they are obtained from the ndep input stream. + if (.not. (simple_phys .or. aqua_planet)) then ! The ndep_stream_nl namelist group is read in stream_ndep_init. This sets whether ! or not the stream will be used. @@ -1134,45 +1120,43 @@ subroutine export_fields( gcomp, model_mesh, model_clock, cam_out, rc) stream_ndep_is_initialized = .true. end if - if (use_ndep_stream) then + if (ndep_stream_active.or.chem_has_ndep_flx) then + ! Nitrogen dep fluxes are obtained from the ndep input stream if input data is available + ! otherwise computed by chemistry + if (ndep_stream_active) then + + ! get ndep fluxes from the stream + call stream_ndep_interp(cam_out, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! NDEP read from forcing is expected to be in units of gN/m2/sec - but the mediator + ! expects units of kgN/m2/sec + scale_ndep = .001_r8 + + else if (chem_has_ndep_flx) then - ! get ndep fluxes from the stream - call stream_ndep_interp(cam_out, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! NDEP read from forcing is expected to be in units of gN/m2/sec - but the mediator - ! expects units of kgN/m2/sec - scale_ndep = .001_r8 + ! Assume chemistry computes ndep fluxes, then its in units of kgN/m2/s - and the mediator expects + ! units of kgN/m2/sec, so the following conversion needs to happen + scale_ndep = 1._r8 - else + end if - ! ndep fluxes not used. Set to zero. + g = 1 do c = begchunk,endchunk do i = 1,get_ncols_p(c) - cam_out(c)%nhx_nitrogen_flx(i) = 0._r8 - cam_out(c)%noy_nitrogen_flx(i) = 0._r8 + fldptr_ndep(1,g) = cam_out(c)%nhx_nitrogen_flx(i) * scale_ndep * mod2med_areacor(g) + fldptr_ndep(2,g) = cam_out(c)%noy_nitrogen_flx(i) * scale_ndep * mod2med_areacor(g) + g = g + 1 end do end do - scale_ndep = 1._r8 - end if + else - else + fldptr_ndep(:,:) = 0._r8 - ! If waccm computes ndep, then its in units of kgN/m2/s - and the mediator expects - ! units of kgN/m2/sec, so the following conversion needs to happen - scale_ndep = 1._r8 + end if end if - g = 1 - do c = begchunk,endchunk - do i = 1,get_ncols_p(c) - fldptr_ndep(1,g) = cam_out(c)%nhx_nitrogen_flx(i) * scale_ndep * mod2med_areacor(g) - fldptr_ndep(2,g) = cam_out(c)%noy_nitrogen_flx(i) * scale_ndep * mod2med_areacor(g) - g = g + 1 - end do - end do - end subroutine export_fields !=============================================================================== diff --git a/src/cpl/nuopc/atm_stream_ndep.F90 b/src/cpl/nuopc/atm_stream_ndep.F90 index a393b27f05..eed6ac619e 100644 --- a/src/cpl/nuopc/atm_stream_ndep.F90 +++ b/src/cpl/nuopc/atm_stream_ndep.F90 @@ -21,52 +21,46 @@ module atm_stream_ndep implicit none private + public :: stream_ndep_readnl ! read runtime options public :: stream_ndep_init ! position datasets for dynamic ndep public :: stream_ndep_interp ! interpolates between two years of ndep file data private :: stream_ndep_check_units ! Check the units and make sure they can be used ! The ndep stream is not needed for aquaplanet or simple model configurations. It - ! is disabled by setting the namelist variable stream_ndep_data_filename to blank. - logical, public, protected :: use_ndep_stream = .true. + ! is disabled by setting the namelist variable stream_ndep_data_filename to 'UNSET' or empty string. + logical, public, protected :: ndep_stream_active = .false. type(shr_strdata_type) :: sdat_ndep ! input data stream logical, public :: stream_ndep_is_initialized = .false. character(len=CS) :: stream_varlist_ndep(2) type(ESMF_Clock) :: model_clock - character(len=*), parameter :: sourcefile = & - __FILE__ + character(len=*), parameter :: sourcefile = __FILE__ + + character(len=CL) :: stream_ndep_data_filename + character(len=CL) :: stream_ndep_mesh_filename + integer :: stream_ndep_year_first ! first year in stream to use + integer :: stream_ndep_year_last ! last year in stream to use + integer :: stream_ndep_year_align ! align stream_year_firstndep with !============================================================================== contains !============================================================================== - subroutine stream_ndep_init(model_mesh, model_clock, rc) - ! - ! Initialize data stream information. + subroutine stream_ndep_readnl(nlfile) ! Uses: - use cam_instance , only: inst_suffix - use shr_nl_mod , only: shr_nl_find_group_name - use dshr_strdata_mod , only: shr_strdata_init_from_inline + use shr_nl_mod, only: shr_nl_find_group_name ! input/output variables - type(ESMF_CLock), intent(in) :: model_clock - type(ESMF_Mesh) , intent(in) :: model_mesh - integer , intent(out) :: rc + character(len=*), intent(in) :: nlfile ! local variables integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - character(len=CL) :: stream_ndep_data_filename - character(len=CL) :: stream_ndep_mesh_filename - character(len=CL) :: filein ! atm namelist file - integer :: stream_ndep_year_first ! first year in stream to use - integer :: stream_ndep_year_last ! last year in stream to use - integer :: stream_ndep_year_align ! align stream_year_firstndep with integer :: ierr - character(*), parameter :: subName = "('stream_ndep_init')" + character(*), parameter :: subName = "('stream_ndep_readnl')" !----------------------------------------------------------------------- namelist /ndep_stream_nl/ & @@ -76,8 +70,6 @@ subroutine stream_ndep_init(model_mesh, model_clock, rc) stream_ndep_year_last, & stream_ndep_year_align - rc = ESMF_SUCCESS - ! Default values for namelist stream_ndep_data_filename = ' ' stream_ndep_mesh_filename = ' ' @@ -90,10 +82,9 @@ subroutine stream_ndep_init(model_mesh, model_clock, rc) ! Read ndep_stream namelist if (masterproc) then - filein = "atm_in" // trim(inst_suffix) - open( newunit=nu_nml, file=trim(filein), status='old', iostat=nml_error ) + open( newunit=nu_nml, file=trim(nlfile), status='old', iostat=nml_error ) if (nml_error /= 0) then - call endrun(subName//': ERROR opening '//trim(filein)//errMsg(sourcefile, __LINE__)) + call endrun(subName//': ERROR opening '//trim(nlfile)//errMsg(sourcefile, __LINE__)) end if call shr_nl_find_group_name(nu_nml, 'ndep_stream_nl', status=nml_error) if (nml_error == 0) then @@ -101,8 +92,6 @@ subroutine stream_ndep_init(model_mesh, model_clock, rc) if (nml_error /= 0) then call endrun(' ERROR reading ndep_stream_nl namelist'//errMsg(sourcefile, __LINE__)) end if - else - call endrun(' ERROR finding ndep_stream_nl namelist'//errMsg(sourcefile, __LINE__)) end if close(nu_nml) endif @@ -117,9 +106,10 @@ subroutine stream_ndep_init(model_mesh, model_clock, rc) call mpi_bcast(stream_ndep_year_align, 1, mpi_integer, 0, mpicom, ierr) if (ierr /= 0) call endrun(trim(subname)//": FATAL: mpi_bcast: stream_ndep_year_align") + ndep_stream_active = len_trim(stream_ndep_data_filename)>0 .and. stream_ndep_data_filename/='UNSET' + ! Check whether the stream is being used. - if (stream_ndep_data_filename == ' '.or.stream_ndep_data_filename == 'UNSET') then - use_ndep_stream = .false. + if (.not.ndep_stream_active) then if (masterproc) then write(iulog,'(a)') ' ' write(iulog,'(a)') 'NDEP STREAM IS NOT USED.' @@ -140,6 +130,25 @@ subroutine stream_ndep_init(model_mesh, model_clock, rc) write(iulog,'(a)' ) ' ' endif + end subroutine stream_ndep_readnl + + subroutine stream_ndep_init(model_mesh, model_clock, rc) + use dshr_strdata_mod, only: shr_strdata_init_from_inline + + ! input/output variables + type(ESMF_CLock), intent(in) :: model_clock + type(ESMF_Mesh) , intent(in) :: model_mesh + integer , intent(out) :: rc + + ! local variables + character(*), parameter :: subName = "('stream_ndep_init')" + + rc = ESMF_SUCCESS + if (.not.ndep_stream_active) then + return + end if + ! + ! Initialize data stream information. ! Read in units call stream_ndep_check_units(stream_ndep_data_filename) diff --git a/src/physics/cam/cam_diagnostics.F90 b/src/physics/cam/cam_diagnostics.F90 index 97dad2ba01..3a01d9536e 100644 --- a/src/physics/cam/cam_diagnostics.F90 +++ b/src/physics/cam/cam_diagnostics.F90 @@ -568,6 +568,9 @@ subroutine diag_init_moist(pbuf2d) call addfld('a2x_DSTWET4', horiz_only, 'A', 'kg/m2/s', 'wetdep of dust (bin4)') call addfld('a2x_DSTDRY4', horiz_only, 'A', 'kg/m2/s', 'drydep of dust (bin4)') + call addfld('a2x_NOYDEP', horiz_only, 'A', 'kg/m2/s', 'NOy Deposition Flux') + call addfld('a2x_NHXDEP', horiz_only, 'A', 'kg/m2/s', 'NHx Deposition Flux') + ! defaults if (history_amwg) then call add_default (cnst_name(1), 1, ' ') @@ -1903,6 +1906,13 @@ subroutine diag_export(cam_out) call outfld('a2x_DSTDRY4', cam_out%dstdry4, pcols, lchnk) end if + if (associated(cam_out%nhx_nitrogen_flx)) then + call outfld('a2x_NHXDEP', cam_out%nhx_nitrogen_flx, pcols, lchnk) + end if + if (associated(cam_out%noy_nitrogen_flx)) then + call outfld('a2x_NOYDEP', cam_out%noy_nitrogen_flx, pcols, lchnk) + end if + end subroutine diag_export !####################################################################### diff --git a/src/utils/srf_field_check.F90 b/src/utils/srf_field_check.F90 index d1c0adfbca..a0aa0cb0f5 100644 --- a/src/utils/srf_field_check.F90 +++ b/src/utils/srf_field_check.F90 @@ -29,8 +29,6 @@ module srf_field_check public :: set_active_Fall_flxfire public :: set_active_Fall_fco2_lnd public :: set_active_Faoo_fco2_ocn - public :: set_active_Faxa_nhx - public :: set_active_Faxa_noy !=============================================================================== contains @@ -76,14 +74,4 @@ subroutine set_active_Faoo_fco2_ocn(is_active) active_Faoo_fco2_ocn = is_active end subroutine set_active_Faoo_fco2_ocn - subroutine set_active_Faxa_nhx(is_active) - logical, intent(in) :: is_active - active_Faxa_nhx = is_active - end subroutine set_active_Faxa_nhx - - subroutine set_active_Faxa_noy(is_active) - logical, intent(in) :: is_active - active_Faxa_noy = is_active - end subroutine set_active_Faxa_noy - end module srf_field_check