From 24dcb11958fafe6d4cffba4347ccf9f02f114043 Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Tue, 3 Dec 2024 17:40:44 +0100 Subject: [PATCH 1/9] Add default for fates since BGC one can change. --- bld/namelist_files/namelist_defaults_drydep.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/bld/namelist_files/namelist_defaults_drydep.xml b/bld/namelist_files/namelist_defaults_drydep.xml index fb73ab6646..d288439ecf 100644 --- a/bld/namelist_files/namelist_defaults_drydep.xml +++ b/bld/namelist_files/namelist_defaults_drydep.xml @@ -25,6 +25,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). 'ISOP = isoprene', 'C10H16 = pinene_a + carene_3 + thujene_a', 'CH3OH = methanol', 'C2H5OH = ethanol', 'CH2O = formaldehyde', 'CH3CHO = acetaldehyde', 'CH3COOH = acetic_acid', 'CH3COCH3 = acetone' +atm/cam/chem/trop_mozart/emis/megan21_emis_factors_78pft_c20161108.nc atm/cam/chem/trop_mozart/emis/megan21_emis_factors_78pft_c20161108.nc atm/cam/chem/trop_mozart/emis/megan21_emis_factors_78pft_c20161108.nc atm/cam/chem/trop_mozart/emis/megan21_emis_factors_78pft_c20161108.nc From 618b838e055237b0c63cade2282139ff3567d684 Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Tue, 3 Dec 2024 17:40:44 +0100 Subject: [PATCH 2/9] refactor how pft indeces and intercellular CO2 is passed to VOCemissions --- src/biogeochem/VOCEmissionMod.F90 | 43 +++++++++++++++++------------ src/biogeophys/CanopyStateType.F90 | 2 -- src/utils/clmfates_interfaceMod.F90 | 8 ++++-- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/biogeochem/VOCEmissionMod.F90 b/src/biogeochem/VOCEmissionMod.F90 index 74afda8980..89c1ce49b0 100644 --- a/src/biogeochem/VOCEmissionMod.F90 +++ b/src/biogeochem/VOCEmissionMod.F90 @@ -452,7 +452,9 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & real(r8) :: par240_sha ! temporary integer :: class_num, n_meg_comps, imech, imeg, ii - integer :: patchpft ! to transfer FATES PFT space into CLM PFT space. + integer :: l_pft_itype(bounds%begp:bounds%endp) ! local index of pft type + ! that corresponds to pfts on megan factors + ! for BGC it will be 1 to 1 with pftcon%itype(p) character(len=16) :: mech_name type(shr_megan_megcomp_t), pointer :: meg_cmp real(r8) :: cp, alpha, Eopt, topt ! for history output @@ -499,7 +501,6 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & fsun240 => canopystate_inst%fsun240_patch , & ! Input: [real(r8) (:) ] sunlit fraction of canopy last 240 hrs elai => canopystate_inst%elai_patch , & ! Input: [real(r8) (:) ] one-sided leaf area index with burying by snow elai240 => canopystate_inst%elai240_patch , & ! Input: [real(r8) (:) ] one-sided leaf area index with burying by snow last 240 hrs - ci_fates => canopystate_inst%ci_patch , & !Input: [real(r8) (:) ] FATES-calculated internalleaf ci cisun_z => photosyns_inst%cisun_z_patch , & ! Input: [real(r8) (:,:) ] sunlit intracellular CO2 (Pa) cisha_z => photosyns_inst%cisha_z_patch , & ! Input: [real(r8) (:,:) ] shaded intracellular CO2 (Pa) @@ -531,11 +532,27 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! initialize variables which get passed to the atmosphere vocflx(bounds%begp:bounds%endp,:) = 0._r8 vocflx_tot(bounds%begp:bounds%endp) = 0._r8 - + do imeg=1,shr_megan_megcomps_n meg_out(imeg)%flux_out(bounds%begp:bounds%endp) = 0._r8 enddo - + + ! Get local pft types: + ! this has to be done earlier, so if use_fates, we locally know what is not bare ground + ! voc_pft_index comes from fates-internal mapping between pft's in megan_factors_file and fates pfts + l_pft_itype(bounds%begp:bounds%endp) = 0 + if (use_fates) then + do fp = 1,num_soilp + p = filter_soilp(fp) + l_pft_itype(p) = canopystate_inst%voc_pftindex_patch(p) + end do + else + do fp = 1,num_soilp + p = filter_soilp(fp) + l_pft_itype(p) = patch%itype(p) + end do + end if + ! Begin loop over points !_______________________________________________________________________________ do fp = 1,num_soilp @@ -551,7 +568,7 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & vocflx_meg(:) = 0._r8 ! calculate VOC emissions for non-bare ground Patches - if (patch%itype(p) > 0) then + if (l_pft_itype(p) > 0) then gamma=0._r8 ! Calculate PAR: multiply w/m2 by 4.6 to get umol/m2/s for par (added 8/14/02) @@ -583,16 +600,10 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! set emis factor ! if specified, set EF for isoprene with mapped values - if(use_fates)then - patchpft = canopystate_inst%voc_pftindex_patch(p) - else - patchpft = patch%itype(p) - endif - if ( trim(meg_cmp%name) == 'isoprene' .and. shr_megan_mapped_emisfctrs) then - epsilon = get_map_EF(patchpft,g, vocemis_inst) + epsilon = get_map_EF(l_pft_itype(p),g, vocemis_inst) else - epsilon = meg_cmp%emis_factors(patchpft) + epsilon = meg_cmp%emis_factors(l_pft_itype(p)) end if @@ -612,11 +623,7 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! Activity factor for CO2 (only for isoprene) if (trim(meg_cmp%name) == 'isoprene') then co2_ppmv = 1.e6_r8*forc_pco2(g)/forc_pbot(c) - if(use_fates)then - gamma_c = get_gamma_C(ci_fates(p),ci_fates(p),forc_pbot(c),fsun(p), co2_ppmv) - else - gamma_c = get_gamma_C(cisun_z(p,1),cisha_z(p,1),forc_pbot(c),fsun(p), co2_ppmv) - endif + gamma_c = get_gamma_C(cisun_z(p),cisha_z(p),forc_pbot(c),fsun(p), co2_ppmv) else gamma_c = 1._r8 diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index f4cf3f17d2..3bcd6b3a6e 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -46,7 +46,6 @@ module CanopyStateType real(r8) , pointer :: hbot_patch (:) ! patch canopy bottom (m) real(r8) , pointer :: z0m_patch (:) ! patch momentum roughness length (m) real(r8) , pointer :: displa_patch (:) ! patch displacement height (m) - real(r8) , pointer :: ci_patch (:) ! Internal leaf CO2 concentration for MEGAN real(r8) , pointer :: fsun_patch (:) ! patch sunlit fraction of canopy real(r8) , pointer :: fsun24_patch (:) ! patch 24hr average of sunlit fraction of canopy real(r8) , pointer :: fsun240_patch (:) ! patch 240hr average of sunlit fraction of canopy @@ -141,7 +140,6 @@ subroutine InitAllocate(this, bounds) allocate(this%hbot_patch (begp:endp)) ; this%hbot_patch (:) = nan allocate(this%z0m_patch (begp:endp)) ; this%z0m_patch (:) = nan allocate(this%displa_patch (begp:endp)) ; this%displa_patch (:) = nan - allocate(this%ci_patch (begp:endp)) ; this%ci_patch (:) = nan allocate(this%fsun_patch (begp:endp)) ; this%fsun_patch (:) = nan allocate(this%fsun24_patch (begp:endp)) ; this%fsun24_patch (:) = nan allocate(this%fsun240_patch (begp:endp)) ; this%fsun240_patch (:) = nan diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 1f83d29603..21d3813a38 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2578,7 +2578,9 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, & rssha => photosyns_inst%rssha_patch, & psnsun => photosyns_inst%psnsun_patch, & psnsha => photosyns_inst%psnsha_patch, & - ci => canopystate_inst%ci_patch) + cisun_z => photosyns_inst%cisun_z_patch, & + cisha_z => photosyns_inst%cisha_z_patch, & + ) do s = 1, this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) @@ -2645,7 +2647,9 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, & this%fates(nc)%bc_in(s)%filter_photo_pa(ifp) = 3 rssun(p) = this%fates(nc)%bc_out(s)%rssun_pa(ifp) rssha(p) = this%fates(nc)%bc_out(s)%rssha_pa(ifp) - ci(p) = this%fates(nc)%bc_out(s)%ci_pa(ifp) + ! this is needed for MEGAN to work with FATES + cisun_z = this%fates(nc)%bc_out(s)%ci_pa(ifp) + cisha_z = this%fates(nc)%bc_out(s)%ci_pa(ifp) ! These fields are marked with a bad-value flag photosyns_inst%psnsun_patch(p) = spval photosyns_inst%psnsha_patch(p) = spval From c34ed10feacb8a8914610eb3da9113881be1a258 Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Tue, 3 Dec 2024 17:40:44 +0100 Subject: [PATCH 3/9] fix ci passing --- src/biogeophys/CanopyFluxesMod.F90 | 4 +++- src/utils/clmfates_interfaceMod.F90 | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/biogeophys/CanopyFluxesMod.F90 b/src/biogeophys/CanopyFluxesMod.F90 index 0c5431728d..6c6aac43c3 100644 --- a/src/biogeophys/CanopyFluxesMod.F90 +++ b/src/biogeophys/CanopyFluxesMod.F90 @@ -1113,7 +1113,9 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, end do if ( use_fates ) then - + ! zeroed out here for megan isoprene calculations, in case patches are not transfered properly. + photosyns_inst%cisha_z_patch(begp:endp,:) = -999._r8 + photosyns_inst$cisun_z_patch(begp:endp,:) = -999._r8 call clm_fates%wrap_photosynthesis(nc, bounds, fn, filterp(1:fn), & svpts(begp:endp), eah(begp:endp), o2(begp:endp), & co2(begp:endp), rb(begp:endp), dayl_factor(begp:endp), & diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 21d3813a38..020f644a16 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2648,8 +2648,8 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, & rssun(p) = this%fates(nc)%bc_out(s)%rssun_pa(ifp) rssha(p) = this%fates(nc)%bc_out(s)%rssha_pa(ifp) ! this is needed for MEGAN to work with FATES - cisun_z = this%fates(nc)%bc_out(s)%ci_pa(ifp) - cisha_z = this%fates(nc)%bc_out(s)%ci_pa(ifp) + cisun_z(p,:) = this%fates(nc)%bc_out(s)%ci_pa(ifp) + cisha_z(p,:) = this%fates(nc)%bc_out(s)%ci_pa(ifp) ! These fields are marked with a bad-value flag photosyns_inst%psnsun_patch(p) = spval photosyns_inst%psnsha_patch(p) = spval From f4af14e0e5258f3b702252365442f0bd46c92a2a Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Tue, 3 Dec 2024 17:40:44 +0100 Subject: [PATCH 4/9] fix isoprene --- src/biogeochem/VOCEmissionMod.F90 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/biogeochem/VOCEmissionMod.F90 b/src/biogeochem/VOCEmissionMod.F90 index 89c1ce49b0..affb3d5073 100644 --- a/src/biogeochem/VOCEmissionMod.F90 +++ b/src/biogeochem/VOCEmissionMod.F90 @@ -85,14 +85,14 @@ module VOCEmissionMod !------------------------------------------------------------------------ subroutine Init(this, bounds) - use clm_varctl, only : use_fates, use_fates_nocomp + use clm_varctl, only : use_fates, use_fates_nocomp, use_fates_sp class(vocemis_type) :: this type(bounds_type), intent(in) :: bounds if ( shr_megan_mechcomps_n > 0) then if (use_fates) then - if (.not. use_fates_nocomp) then + if (.not. (use_fates_nocomp .or. use_fates_sp)) then call endrun( msg='ERROR: MEGAN currently only works with when FATES is in SP and/or NOCOMP mode '//& errMsg(sourcefile, __LINE__)) end if @@ -417,6 +417,8 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! !USES: use subgridAveMod , only : p2g use clm_varctl , only : use_fates + use clm_varcon , only : smallValue + use decompMod , only : subgrid_level_patch ! ! !ARGUMENTS: type(bounds_type) , intent(in) :: bounds @@ -615,15 +617,20 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! Activity factor for T gamma_t = get_gamma_T(t_veg240(p), t_veg24(p),t_veg(p), ct1(class_num), ct2(class_num),& - betaT(class_num),LDF(class_num), Ceo(class_num), Eopt, topt, patchpft) + betaT(class_num),LDF(class_num), Ceo(class_num), Eopt, topt, l_pft_itype(p)) ! Activity factor for Leaf Age - gamma_a = get_gamma_A(patchpft, elai240(p),elai(p),class_num) + gamma_a = get_gamma_A(l_pft_itype(p), elai240(p),elai(p),class_num) ! Activity factor for CO2 (only for isoprene) if (trim(meg_cmp%name) == 'isoprene') then + ! Check of valid intercellular co2 pressure values. + if (cisha_z(p,nlevcan) < smallValue .or. cisun_z(p,nlevcan) < smallValue) then + write(iulog,*) 'Invalid intercellular co2 pressure (sunlit, shaded): ',cisun_z(p,nlevcan),cisha_z(p,nlevcan) + call endrun(subgrid_index=p, subgrid_level=subgrid_level_patch, msg=errMsg(sourcefile, __LINE__)) + endif co2_ppmv = 1.e6_r8*forc_pco2(g)/forc_pbot(c) - gamma_c = get_gamma_C(cisun_z(p),cisha_z(p),forc_pbot(c),fsun(p), co2_ppmv) + gamma_c = get_gamma_C(cisun_z(p,nlevcan),cisha_z(p,nlevcan),forc_pbot(c),fsun(p), co2_ppmv) else gamma_c = 1._r8 From 56cceedfccbb4752629ccae641412fde7558243f Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Tue, 3 Dec 2024 17:40:44 +0100 Subject: [PATCH 5/9] Fix typos. --- src/biogeophys/CanopyFluxesMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/biogeophys/CanopyFluxesMod.F90 b/src/biogeophys/CanopyFluxesMod.F90 index 6c6aac43c3..925640523f 100644 --- a/src/biogeophys/CanopyFluxesMod.F90 +++ b/src/biogeophys/CanopyFluxesMod.F90 @@ -1115,7 +1115,7 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, if ( use_fates ) then ! zeroed out here for megan isoprene calculations, in case patches are not transfered properly. photosyns_inst%cisha_z_patch(begp:endp,:) = -999._r8 - photosyns_inst$cisun_z_patch(begp:endp,:) = -999._r8 + photosyns_inst%cisun_z_patch(begp:endp,:) = -999._r8 call clm_fates%wrap_photosynthesis(nc, bounds, fn, filterp(1:fn), & svpts(begp:endp), eah(begp:endp), o2(begp:endp), & co2(begp:endp), rb(begp:endp), dayl_factor(begp:endp), & diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 020f644a16..30b8b8d84a 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2579,7 +2579,7 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, & psnsun => photosyns_inst%psnsun_patch, & psnsha => photosyns_inst%psnsha_patch, & cisun_z => photosyns_inst%cisun_z_patch, & - cisha_z => photosyns_inst%cisha_z_patch, & + cisha_z => photosyns_inst%cisha_z_patch & ) do s = 1, this%fates(nc)%nsites From 7f42386071e778df21a753d158f46319ce51d8d1 Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Tue, 3 Dec 2024 17:40:44 +0100 Subject: [PATCH 6/9] revert check for sp, add patch type in the endrun. --- src/biogeochem/VOCEmissionMod.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/biogeochem/VOCEmissionMod.F90 b/src/biogeochem/VOCEmissionMod.F90 index affb3d5073..6310cc3088 100644 --- a/src/biogeochem/VOCEmissionMod.F90 +++ b/src/biogeochem/VOCEmissionMod.F90 @@ -85,14 +85,14 @@ module VOCEmissionMod !------------------------------------------------------------------------ subroutine Init(this, bounds) - use clm_varctl, only : use_fates, use_fates_nocomp, use_fates_sp + use clm_varctl, only : use_fates, use_fates_nocomp class(vocemis_type) :: this type(bounds_type), intent(in) :: bounds if ( shr_megan_mechcomps_n > 0) then if (use_fates) then - if (.not. (use_fates_nocomp .or. use_fates_sp)) then + if (.not. use_fates_nocomp) then ! SP implies NOCOMP is on. call endrun( msg='ERROR: MEGAN currently only works with when FATES is in SP and/or NOCOMP mode '//& errMsg(sourcefile, __LINE__)) end if @@ -626,7 +626,7 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & if (trim(meg_cmp%name) == 'isoprene') then ! Check of valid intercellular co2 pressure values. if (cisha_z(p,nlevcan) < smallValue .or. cisun_z(p,nlevcan) < smallValue) then - write(iulog,*) 'Invalid intercellular co2 pressure (sunlit, shaded): ',cisun_z(p,nlevcan),cisha_z(p,nlevcan) + write(iulog,*) 'Invalid intercellular co2 pressure (patch itype, sunlit, shaded): ', l_pft_itype(p),cisun_z(p,nlevcan),cisha_z(p,nlevcan) call endrun(subgrid_index=p, subgrid_level=subgrid_level_patch, msg=errMsg(sourcefile, __LINE__)) endif co2_ppmv = 1.e6_r8*forc_pco2(g)/forc_pbot(c) From b9e4b4f2e32d410a5e668f0a52b47e5d6b69dbd8 Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Fri, 6 Dec 2024 18:50:24 +0100 Subject: [PATCH 7/9] add checks for bareground and fix canopy fluxes --- src/biogeochem/VOCEmissionMod.F90 | 10 ++++++---- src/biogeophys/CanopyFluxesMod.F90 | 4 +--- src/utils/clmfates_interfaceMod.F90 | 9 +++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/biogeochem/VOCEmissionMod.F90 b/src/biogeochem/VOCEmissionMod.F90 index 6310cc3088..364779a17c 100644 --- a/src/biogeochem/VOCEmissionMod.F90 +++ b/src/biogeochem/VOCEmissionMod.F90 @@ -546,7 +546,9 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & if (use_fates) then do fp = 1,num_soilp p = filter_soilp(fp) - l_pft_itype(p) = canopystate_inst%voc_pftindex_patch(p) + if (patch%is_fates(p)) then + l_pft_itype(p) = canopystate_inst%voc_pftindex_patch(p) + endif end do else do fp = 1,num_soilp @@ -625,12 +627,12 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! Activity factor for CO2 (only for isoprene) if (trim(meg_cmp%name) == 'isoprene') then ! Check of valid intercellular co2 pressure values. - if (cisha_z(p,nlevcan) < smallValue .or. cisun_z(p,nlevcan) < smallValue) then - write(iulog,*) 'Invalid intercellular co2 pressure (patch itype, sunlit, shaded): ', l_pft_itype(p),cisun_z(p,nlevcan),cisha_z(p,nlevcan) + if (cisha_z(p,1) < 0.0_r8 .or. cisun_z(p,1) < 0.0_r8) then + write(iulog,*) 'Invalid intercellular co2 pressure (patch itype, sunlit, shaded): ', l_pft_itype(p),cisun_z(p,1),cisha_z(p,1) call endrun(subgrid_index=p, subgrid_level=subgrid_level_patch, msg=errMsg(sourcefile, __LINE__)) endif co2_ppmv = 1.e6_r8*forc_pco2(g)/forc_pbot(c) - gamma_c = get_gamma_C(cisun_z(p,nlevcan),cisha_z(p,nlevcan),forc_pbot(c),fsun(p), co2_ppmv) + gamma_c = get_gamma_C(cisun_z(p,1),cisha_z(p,1),forc_pbot(c),fsun(p), co2_ppmv) else gamma_c = 1._r8 diff --git a/src/biogeophys/CanopyFluxesMod.F90 b/src/biogeophys/CanopyFluxesMod.F90 index 925640523f..196e72894c 100644 --- a/src/biogeophys/CanopyFluxesMod.F90 +++ b/src/biogeophys/CanopyFluxesMod.F90 @@ -1111,11 +1111,9 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, vpd(p) = max((svpts(p) - eah(p)), 50._r8) * 0.001_r8 end do - if ( use_fates ) then ! zeroed out here for megan isoprene calculations, in case patches are not transfered properly. - photosyns_inst%cisha_z_patch(begp:endp,:) = -999._r8 - photosyns_inst%cisun_z_patch(begp:endp,:) = -999._r8 + call clm_fates%wrap_photosynthesis(nc, bounds, fn, filterp(1:fn), & svpts(begp:endp), eah(begp:endp), o2(begp:endp), & co2(begp:endp), rb(begp:endp), dayl_factor(begp:endp), & diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 30b8b8d84a..8fce6e2c1c 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1616,6 +1616,10 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & patch%is_bareground(col%patchi(c)) = .true. npatch = this%fates(nc)%sites(s)%youngest_patch%patchno + ! set voc_pft_index of bareground to 0 explicitly, so the bare ground is properly ignored in VOCEmissionMod + if (patch%is_bareground(col%patchi(c))) then + voc_pftindex(col%patchi(c)) = 0 + endif ! Precision errors on the canopy_fraction_pa sum, even small (e-12) ! do exist, and can create potentially negetive bare-soil fractions ! (ie -1e-12 or smaller). Even though this is effectively zero, @@ -2650,6 +2654,11 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, & ! this is needed for MEGAN to work with FATES cisun_z(p,:) = this%fates(nc)%bc_out(s)%ci_pa(ifp) cisha_z(p,:) = this%fates(nc)%bc_out(s)%ci_pa(ifp) + if (this%fates(nc)%bc_out(s)%ci_pa(ifp) <0.0_r8) then + write(iulog,*) 'ci_pa is less than 0: ', this%fates(nc)%bc_out(s)%ci_pa(ifp) + write(iulog,*) 'filter ran photosynthesis s p icp ifp ilter',s,p,icp,ifp + call endrun(msg=errMsg(sourcefile, __LINE__)) + endif ! These fields are marked with a bad-value flag photosyns_inst%psnsun_patch(p) = spval photosyns_inst%psnsha_patch(p) = spval From 4ec97f2c568610b5a4530193284029a503dc02dd Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Fri, 6 Dec 2024 19:32:24 +0100 Subject: [PATCH 8/9] Add cisun and cisha to history --- src/biogeophys/PhotosynthesisMod.F90 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/biogeophys/PhotosynthesisMod.F90 b/src/biogeophys/PhotosynthesisMod.F90 index 6176668f19..029fea7d89 100644 --- a/src/biogeophys/PhotosynthesisMod.F90 +++ b/src/biogeophys/PhotosynthesisMod.F90 @@ -709,6 +709,30 @@ subroutine InitHistory(this, bounds) endif + ! megan variables + this%cisun_z_patch(begp:endp,:) = spval + this%cisha_z_patch(begp:endp,:) = spval + if (nlevcan>1) then + call hist_addfld2d (fname='CISUN', units='(Pa)', type2d='nlevcan', & + avgflag='A', long_name='sunlit leaf intracellular CO2 pressure', & + ptr_patch=this%cisun_z_patch, set_lake=spval, set_urb=spval, default='inactive') + + call hist_addfld2d (fname='CISHA', units='(Pa)', type2d='nlevcan', & + avgflag='A', long_name='shaded leaf intracellular CO2 pressure', & + ptr_patch=this%cisha_z_patch, set_lake=spval, set_urb=spval, default='inactive') + else + ptr_1d => this%cisun_z_patch(begp:endp,1) + call hist_addfld1d (fname='CISUN', units='(Pa)', & + avgflag='A', long_name='sunlit leaf intracellular CO2 pressure', & + ptr_patch=ptr_1d, default='inactive') + + ptr_1d => this%cisha_z_patch(begp:endp,1) + call hist_addfld1d (fname='CISHA', units='(Pa)', & + avgflag='A', long_name='shaded leaf intracellular CO2 pressure', & + ptr_patch=ptr_1d, default='inactive') + + endif + end subroutine InitHistory !----------------------------------------------------------------------- From 6b7fdc9b7a7e0980a18bfe664142c1e1a1bf0361 Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Fri, 6 Dec 2024 19:32:58 +0100 Subject: [PATCH 9/9] add extra fields to FatesColdMeganSatPhen test --- .../testdefs/testmods_dirs/clm/FatesColdMeganSatPhen/user_nl_clm | 1 + 1 file changed, 1 insertion(+) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdMeganSatPhen/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdMeganSatPhen/user_nl_clm index 3749fd1d61..e95192bd18 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdMeganSatPhen/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdMeganSatPhen/user_nl_clm @@ -2,3 +2,4 @@ hist_mfilt = 365 hist_nhtfrq = -24 +hist_fincl1 += 'GAMMA' 'GAMMAC' 'GAMMAA' 'GAMMAL' 'GAMMAT' 'GAMMAP' 'GAMMAS' 'CISHA' 'CISUN' 'FSUN24' 'FSUN' 'FSUN240' 'PCO2' \ No newline at end of file