From b70cfeaf6a2e6aa3511cc469a53d8de080b112c3 Mon Sep 17 00:00:00 2001 From: Francis Vitt Date: Thu, 19 Dec 2024 13:24:28 -0700 Subject: [PATCH] fix some issues in derecho regression tests modified: bld/build-namelist modified: bld/namelist_files/namelist_defaults_cam.xml modified: bld/namelist_files/namelist_definition.xml modified: bld/namelist_files/use_cases/2010_cam6.xml modified: bld/namelist_files/use_cases/sd_cam6.xml modified: bld/namelist_files/use_cases/waccm_sc_1850_cam6.xml modified: src/chemistry/geoschem/chemistry.F90 modified: src/chemistry/pp_terminator/chemistry.F90 modified: src/control/camsrfexch.F90 --- bld/build-namelist | 13 +++++ bld/namelist_files/namelist_defaults_cam.xml | 3 ++ bld/namelist_files/namelist_definition.xml | 6 +++ bld/namelist_files/use_cases/2010_cam6.xml | 4 ++ bld/namelist_files/use_cases/sd_cam6.xml | 6 ++- .../use_cases/waccm_sc_1850_cam6.xml | 7 +++ src/chemistry/geoschem/chemistry.F90 | 31 ++++++------ src/chemistry/pp_terminator/chemistry.F90 | 49 ++++++++++--------- src/control/camsrfexch.F90 | 6 +-- 9 files changed, 84 insertions(+), 41 deletions(-) diff --git a/bld/build-namelist b/bld/build-namelist index 6dd96595d9..22be75b310 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -509,6 +509,19 @@ if ($phys_mode_flags > 1) { my $simple_phys = 0; if ($adia_mode or $ideal_mode) { $simple_phys = 1; } +# Setup default ndep streams only if not simple_phys or aqua_mode and +# the chemistry cannot produce the nitrogen depostion fluxes +if (!($simple_phys or $aqua_mode)) { + my $chem_nitrodep = chem_has_species($cfg, 'NO') and chem_has_species($cfg, 'NH3'); + if (!$chem_nitrodep) { + add_default($nl, 'stream_ndep_data_filename'); + add_default($nl, 'stream_ndep_mesh_filename'); + add_default($nl, 'stream_ndep_year_first'); + add_default($nl, 'stream_ndep_year_last'); + add_default($nl, 'stream_ndep_year_align'); + } +} + # 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 ab2707290c..501047a1bc 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2063,6 +2063,9 @@ 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 2000 2000 1 diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 4aaa038224..185edfa81e 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -7609,6 +7609,12 @@ 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. diff --git a/bld/namelist_files/use_cases/2010_cam6.xml b/bld/namelist_files/use_cases/2010_cam6.xml index 239f5436f6..d392d2b76e 100644 --- a/bld/namelist_files/use_cases/2010_cam6.xml +++ b/bld/namelist_files/use_cases/2010_cam6.xml @@ -83,4 +83,8 @@ 'CYCLICAL' 2010 +2010 +2010 +1 + diff --git a/bld/namelist_files/use_cases/sd_cam6.xml b/bld/namelist_files/use_cases/sd_cam6.xml index 146268c62b..9a89255e88 100644 --- a/bld/namelist_files/use_cases/sd_cam6.xml +++ b/bld/namelist_files/use_cases/sd_cam6.xml @@ -28,7 +28,7 @@ 'SERIAL' 'atm/cam/ozone_strataero' - 'ozone_strataero_WACCM_L70_zm5day_18500101-20150103_CMIP6ensAvg_c180923.nc' + 'ozone_strataero_WACCM_L70_zm5day_18500101-20150103_CMIP6ensAvg_c180923.nc' .true. 'CHEM_LBC_FILE' @@ -36,4 +36,8 @@ 'SERIAL' 'CO2','CH4','N2O','CFC11eq','CFC12' + 1850 + 2015 + 1850 + diff --git a/bld/namelist_files/use_cases/waccm_sc_1850_cam6.xml b/bld/namelist_files/use_cases/waccm_sc_1850_cam6.xml index dbc6b0921b..691150a417 100644 --- a/bld/namelist_files/use_cases/waccm_sc_1850_cam6.xml +++ b/bld/namelist_files/use_cases/waccm_sc_1850_cam6.xml @@ -88,4 +88,11 @@ 'UTEND4', 'UTEND5', 'FRONTGF', 'FRONTGFA', 'EKGW', 'QNO', 'QRLNLTE', 'QRL_TOT', 'DUV', 'DVV', 'TTPXMLC' + +lnd/clm2/ndepdata/fndep_clm_WACCM6_CMIP6piControl001_y21-50avg_1850monthly_0.95x1.25_c180802.nc +share/meshes/fv0.9x1.25_141008_polemod_ESMFmesh.nc +1850 +1850 +1 + diff --git a/src/chemistry/geoschem/chemistry.F90 b/src/chemistry/geoschem/chemistry.F90 index fbb99e4b8f..e46bda2c4e 100644 --- a/src/chemistry/geoschem/chemistry.F90 +++ b/src/chemistry/geoschem/chemistry.F90 @@ -22,7 +22,7 @@ module chemistry #if defined( MODAL_AERO ) use modal_aero_data, only : ntot_amode #endif - + ! GEOS-Chem derived types USE DiagList_Mod, ONLY : DgnList ! Diagnostics list object use GeosChem_History_Mod, ONLY : HistoryConfigObj ! History diagnostic object @@ -59,6 +59,7 @@ module chemistry public :: chem_readnl ! read chem namelist public :: chem_emissions public :: chem_timestep_init + public :: chem_has_ndep_flx ! ! Private routines: @@ -166,6 +167,8 @@ module chemistry ! For dry deposition character(len=shr_kind_cl) :: depvel_lnd_file = 'depvel_lnd_file' + ! for nitrogen deposition fluxes to surface models + logical, parameter :: chem_has_ndep_flx = .false. contains @@ -515,11 +518,11 @@ subroutine chem_register CALL cnst_get_ind('Q', cQ, abort=.True.) CALL cnst_get_ind('H2O', cH2O, abort=.True.) CALL cnst_get_ind('H2SO4', cH2SO4, abort=.True.) - + !------------------------------------------------------------ ! Get mapping between dry deposition species and species set !------------------------------------------------------------ - + nIgnored = 0 if (debug .and. masterproc) write(iulog,'(a,i4,a)') 'chem_register: looping over gas dry deposition list with ', nddvels, ' species' @@ -831,7 +834,7 @@ subroutine chem_readnl(nlfile) ! Now go through the KPP mechanism and add any species not ! implemented by the tracer list in geoschem_config.yml !---------------------------------------------------------- - + IF ( nSpec > nSlsMax ) THEN CALL ENDRUN('chem_readnl: too many species - increase nSlsmax') ENDIF @@ -1022,7 +1025,7 @@ subroutine chem_init(phys_state, pbuf2d) use Time_Mod, only : Accept_External_Date_Time use Ucx_Mod, only : Init_Ucx use Unitconv_Mod, only : MOLES_SPECIES_PER_MOLES_DRY_AIR - use Vdiff_Mod, only : Max_PblHt_For_Vdiff + use Vdiff_Mod, only : Max_PblHt_For_Vdiff TYPE(physics_state), INTENT(IN ) :: phys_state(BEGCHUNK:ENDCHUNK) TYPE(physics_buffer_desc), POINTER, INTENT(INOUT) :: pbuf2d(:,:) @@ -1143,7 +1146,7 @@ subroutine chem_init(phys_state, pbuf2d) ! on State_Grid(BEGCHUNK). ! To go around this, we define all of GEOS-Chem arrays with ! size PCOLS x PVER, which is the largest possible number of - ! grid cells. + ! grid cells. CALL Init_State_Grid( Input_Opt = Input_Opt, & State_Grid = maxGrid, & RC = RC ) @@ -1484,7 +1487,7 @@ subroutine chem_init(phys_state, pbuf2d) ! Init_Drydep ! Thibaud M. Fritz - 04 Mar 2020 !---------------------------------------------------------- - + ALLOCATE(map2GC_dryDep(nddvels), STAT=IERR) IF ( IERR .NE. 0 ) CALL ENDRUN('Failed to allocate map2GC_dryDep') @@ -1754,7 +1757,7 @@ subroutine chem_timestep_init(phys_state, pbuf2d) use mo_flbc, only : flbc_chk use mo_ghg_chem, only : ghg_chem_timestep_init use physics_buffer, only : physics_buffer_desc - + TYPE(physics_state), INTENT(IN):: phys_state(begchunk:endchunk) TYPE(physics_buffer_desc), POINTER :: pbuf2d(:,:) @@ -2019,7 +2022,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o ) REAL(r8) :: mmr_tend(state%NCOL,PVER,gas_pcnst) REAL(r8) :: wk_out(state%NCOL) LOGICAL :: Found - + CHARACTER(LEN=shr_kind_cl) :: tagName REAL(r8), PARAMETER :: zlnd = 0.01_r8 ! Roughness length for soil [m] @@ -2364,7 +2367,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o ) ENDDO ! Deal with secondary organic aerosols (SOAs). This mapping is using the - ! complex SOA option in GEOS-Chem. + ! complex SOA option in GEOS-Chem. ! MAM uses five volatility bins spanning saturation concentrations from 0.01 ! to 100 ug/m3 (logarithmically). The complex SOA option has four volatility ! bins that 0.1 to 100 ug/m3. We lump the lowest two bins in CESM2 to the @@ -3692,7 +3695,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o ) ! Compute the surface flux for the non-local mixing, ! (which means getting emissions & drydep from HEMCO) ! and store it in State_Chm%Surface_Flux - ! + ! ! For CESM-GC, Surface_Flux will be equal to the opposite of the ! dry deposition flux since emissions are loaded externally ! ( SurfaceFlux = eflx - dflx = - dflx ) @@ -3739,10 +3742,10 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o ) ! Get the species ID from the drydep ID N = State_Chm(BEGCHUNK)%Map_DryDep(ND) IF ( N <= 0 ) CYCLE - + M = map2GCinv(N) IF ( M <= 0 ) CYCLE - + cam_in%cflx(1:nY,M) = cam_in%cflx(1:nY,M) & + State_Chm(LCHNK)%SurfaceFlux(1,1:nY,N) ENDDO @@ -3763,7 +3766,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o ) new_units = KG_SPECIES_PER_M2, & previous_units = previous_units, & RC = RC ) - + IF ( RC /= GC_SUCCESS ) THEN ErrMsg = 'Error encountered in "Convert_Spc_Units"!' diff --git a/src/chemistry/pp_terminator/chemistry.F90 b/src/chemistry/pp_terminator/chemistry.F90 index 11fbf5e0c9..b1e82d8d65 100644 --- a/src/chemistry/pp_terminator/chemistry.F90 +++ b/src/chemistry/pp_terminator/chemistry.F90 @@ -32,9 +32,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 @@ -45,9 +46,11 @@ module chemistry module procedure chem_read_restart_pio end interface + logical, parameter :: chem_has_ndep_flx = .false. + ! Private data integer, parameter :: nspecies = 3 - + integer :: idx_cl =-1 integer :: idx_cl2=-1 @@ -75,10 +78,10 @@ end function chem_is !================================================================================================ subroutine chem_register - !----------------------------------------------------------------------- - ! + !----------------------------------------------------------------------- + ! ! Purpose: register advected constituents for parameterized greenhouse gas chemistry - ! + ! !----------------------------------------------------------------------- real(r8), parameter :: cptmp = 666._r8 @@ -86,10 +89,10 @@ subroutine chem_register logical :: camout integer :: i, n - + do i = 1, nspecies camout = trim(species(i)) .eq. 'RHO' - call cnst_add( species(i), adv_mass(i), cptmp, qmin, n, & + call cnst_add( species(i), adv_mass(i), cptmp, qmin, n, & readiv=.true.,mixtype='dry',cam_outfld=camout) indices(i) = n map2chm(n) = i @@ -123,12 +126,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--------------------------------- @@ -137,7 +140,7 @@ function chem_implements_cnst(name) logical :: chem_implements_cnst ! return value integer :: i - + chem_implements_cnst = .false. do i = 1, nspecies @@ -150,13 +153,13 @@ function chem_implements_cnst(name) 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 cam_history, only: addfld, add_default, horiz_only @@ -196,7 +199,7 @@ end subroutine chem_init subroutine chem_timestep_init(phys_state, pbuf2d) use physics_buffer, only: physics_buffer_desc - type(physics_state), intent(in):: phys_state(begchunk:endchunk) + type(physics_state), intent(in):: phys_state(begchunk:endchunk) type(physics_buffer_desc), pointer :: pbuf2d(:,:) end subroutine chem_timestep_init @@ -222,7 +225,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dt, pbuf, fh2o ) real(r8), optional, intent(out) :: fh2o(pcols) ! h2o flux to balance source from chemistry real(r8) :: a(pver),b(pver),c(pver),d(pver) - + real(r8) :: k1(pcols) real(r8) :: k2(pcols) @@ -278,7 +281,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dt, pbuf, fh2o ) l(i,:) = (1._r8 - e(i,:))/det(i,:)/dt elsewhere l(i,:) = 4._r8*k2(i) - endwhere + endwhere cl_f(i,:) = -l(i,:)*(cl(i,:) - det(i,:) + r(i) )*(cl(i,:) + det(i,:) + r(i)) / ( 1._r8 +e(i,:) + dt*l(i,:)*(cl(i,:) + r(i))) cl2_f(i,:) = -cl_f(i,:) / 2._r8 @@ -325,7 +328,7 @@ subroutine chem_init_cnst(name, latvals, lonvals, mask, q) real(r8) :: q_vmr(size(q, 1)) ! volume mixing ratio (ncol) real(r8) :: det(size(q, 1)) real(r8) :: krat(size(q, 1)) - + real(r8) :: k1(size(q, 1)) real(r8) :: k2(size(q, 1)) @@ -347,7 +350,7 @@ subroutine chem_init_cnst(name, latvals, lonvals, mask, q) krat(:) = k1(:) / (4._r8 * k2(:)) h = init_vmr_cl + 2._r8 * init_vmr_cl2 - + det(:) = sqrt(krat(:) * krat(:) + 2._r8 * h * krat(:)) if (trim(name) == trim(species(1)) ) then @@ -412,7 +415,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) @@ -420,7 +423,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 8111785cd1..1470c46198 100644 --- a/src/control/camsrfexch.F90 +++ b/src/control/camsrfexch.F90 @@ -9,7 +9,7 @@ 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: nan, posinf, assignment(=) + use infnan, only: 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, & @@ -329,11 +329,11 @@ subroutine atm2hub_alloc( cam_out ) 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 + cam_out(c)%nhx_nitrogen_flx(:) = 0._r8 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 + cam_out(c)%noy_nitrogen_flx(:) = 0._r8 endif