From ca2ca2055d1c4c7e86b39e5c60437b209c19df77 Mon Sep 17 00:00:00 2001 From: mvdebolskiy <80036033+mvdebolskiy@users.noreply.github.com> Date: Fri, 16 Feb 2024 10:10:18 +0100 Subject: [PATCH 01/12] Point to noresm fates branch with fire emissions --- Externals_CLM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index a6fae66356..7f846b0bd7 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -1,8 +1,8 @@ [fates] local_path = src/fates protocol = git -repo_url = https://github.com/NGEET/fates -tag = sci.1.71.0_api.33.0.0 +repo_url = https://github.com/NorESMhub/fates +branch = feature/fates-fire-emission required = True [externals_description] From be3edce56d7f7f1a4b53601744238aa7a1e1b325 Mon Sep 17 00:00:00 2001 From: mvdebolskiy <80036033+mvdebolskiy@users.noreply.github.com> Date: Fri, 16 Feb 2024 10:14:45 +0100 Subject: [PATCH 02/12] fix typo --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 7f846b0bd7..b7e9d2017d 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -1,7 +1,7 @@ [fates] local_path = src/fates protocol = git -repo_url = https://github.com/NorESMhub/fates +repo_url = https://github.com/NorESMhub/fates.git branch = feature/fates-fire-emission required = True From 50d67847757098c88800e90a41a301287b92496f Mon Sep 17 00:00:00 2001 From: mvdebolskiy Date: Fri, 15 Mar 2024 16:02:45 +0100 Subject: [PATCH 03/12] make fates compatable with -fire_emis --- bld/CLMBuildNamelist.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index dae7b5f7f0..b4550f99c4 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -3918,11 +3918,11 @@ sub setup_logic_fire_emis { if ($opts->{'fire_emis'} ) { if ( &value_is_true( $nl_flags->{'use_fates'} ) ) { - $log->warning("Fire emission can NOT be on when FATES is also on.\n" . - " DON'T use the '-fire_emis' option when '-bgc fates' is activated"); - } - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_emis_factors_file'); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_emis_specifier'); + $log->warning( "Fire emission factor file will NOT be used when FATES is on.\n" ); + } else { + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_emis_factors_file'); + } + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_emis_specifier'); } else { if ( defined($nl->get_value('fire_emis_elevated')) || defined($nl->get_value('fire_emis_factors_file')) || From bb37cab5373f9f150673e7de3bfdd0512b51097c Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Fri, 15 Mar 2024 16:04:02 +0100 Subject: [PATCH 04/12] updates for error check --- bld/CLMBuildNamelist.pm | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b4550f99c4..01e9395529 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -97,7 +97,7 @@ OPTIONS CENTURY or MIMICS decomposition This toggles on the namelist variables: use_fates. use_lch4 and use_nitrif_denitrif are optional - + (Only for CLM4.5/CLM5.0) -[no-]chk_res Also check [do NOT check] to make sure the resolution and land-mask is valid. @@ -984,6 +984,13 @@ sub setup_cmdl_fire_light_res { if ( defined($stream_fldfilename_lightng) && $val ne "none" ) { $log->fatal_error("-$var option used while also explicitly setting stream_fldfilename_lightng filename which is a contradiction. Use one or the other not both."); } + if ( &value_is_true($nl_flags->{'use_fates'}) ) { + if ( $nl->get_value('fates_spitfire_mode') == 0) { + if (! $opts->{'fire_emis'} ) { + $log->fatal_error("cannot have fire_emis and use_fates set if fates does not have spitfire mode") + } + } + } if ( ! &value_is_true($nl->get_value('use_cn')) ) { if ( &value_is_true($nl_flags->{'use_fates'}) ) { if ( $nl->get_value('fates_spitfire_mode') < 2) { @@ -1010,7 +1017,7 @@ sub setup_cmdl_fire_light_res { if ( ! &value_is_true($nl_flags->{'neon'}) ) { if ( defined($opts->{'clm_usr_name'}) ) { $log->warning("The NEON lightning dataset does NOT cover the entire globe, make sure it covers the region for your grid"); - } else { + } else { $log->fatal_error("The NEON lightning dataset can NOT be used for global grids or regions or points outside of its area as it does NOT cover the entire globe."); } } @@ -2260,7 +2267,7 @@ sub setup_logic_crop_inparm { } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, "initial_seed_at_planting", 'use_crop'=>$nl->get_value('use_crop') ); - + my $crop_residue_removal_frac = $nl->get_value('crop_residue_removal_frac'); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'crop_residue_removal_frac' ); if ( $crop_residue_removal_frac < 0.0 or $crop_residue_removal_frac > 1.0 ) { @@ -2454,7 +2461,7 @@ sub setup_logic_surface_dataset { } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'hgrid'=>$nl_flags->{'res'}, 'ssp_rcp'=>$nl_flags->{'ssp_rcp'}, 'use_vichydro'=>$nl_flags->{'use_vichydro'}, - 'sim_year'=>$nl_flags->{'sim_year'}, 'irrigate'=>".true.", 'use_fates'=>$nl_flags->{'use_fates'}, + 'sim_year'=>$nl_flags->{'sim_year'}, 'irrigate'=>".true.", 'use_fates'=>$nl_flags->{'use_fates'}, 'neon'=>$nl_flags->{'neon'}, 'neonsite'=>$nl_flags->{'neonsite'}, 'use_crop'=>$nl_flags->{'use_crop'}, 'glc_nec'=>$nl_flags->{'glc_nec'} ); } @@ -3119,7 +3126,7 @@ sub setup_logic_supplemental_nitrogen { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'suplnitro', 'use_fates'=>$nl_flags->{'use_fates'}); } - + # # Error checking for suplnitro # @@ -3629,10 +3636,10 @@ sub setup_logic_nitrogen_deposition { 'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'}, 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'ndep_taxmode', 'phys'=>$nl_flags->{'phys'}, - 'use_cn'=>$nl_flags->{'use_cn'}, + 'use_cn'=>$nl_flags->{'use_cn'}, 'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'} ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'ndep_varlist', 'phys'=>$nl_flags->{'phys'}, - 'use_cn'=>$nl_flags->{'use_cn'}, + 'use_cn'=>$nl_flags->{'use_cn'}, 'lnd_tuning_mode'=>$nl_flags->{'lnd_tuning_mode'} ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_ndep', 'phys'=>$nl_flags->{'phys'}, 'use_cn'=>$nl_flags->{'use_cn'}, 'sim_year'=>$nl_flags->{'sim_year'}, @@ -4423,8 +4430,8 @@ sub setup_logic_fates { my $suplnitro = $nl->get_value('suplnitro'); my $parteh_mode = $nl->get_value('fates_parteh_mode'); if ( ($parteh_mode == 1) && ($suplnitro !~ /ALL/) && not &value_is_true( $nl_flags->{'use_fates_sp'}) ) { - $log->fatal_error("supplemental Nitrogen (suplnitro) is NOT set to ALL, FATES is on, " . - "but and FATES-SP is not active, but fates_parteh_mode is 1, so Nitrogen is not active" . + $log->fatal_error("supplemental Nitrogen (suplnitro) is NOT set to ALL, FATES is on, " . + "but and FATES-SP is not active, but fates_parteh_mode is 1, so Nitrogen is not active" . "Change suplnitro back to ALL"); } # From c6405cd8fdabd172d77b6b2e0d67090a853b5ae2 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Fri, 15 Mar 2024 16:13:59 +0100 Subject: [PATCH 05/12] error check for spitfire mode and fire_emis --- bld/CLMBuildNamelist.pm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 01e9395529..fde53a8f8e 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -984,13 +984,6 @@ sub setup_cmdl_fire_light_res { if ( defined($stream_fldfilename_lightng) && $val ne "none" ) { $log->fatal_error("-$var option used while also explicitly setting stream_fldfilename_lightng filename which is a contradiction. Use one or the other not both."); } - if ( &value_is_true($nl_flags->{'use_fates'}) ) { - if ( $nl->get_value('fates_spitfire_mode') == 0) { - if (! $opts->{'fire_emis'} ) { - $log->fatal_error("cannot have fire_emis and use_fates set if fates does not have spitfire mode") - } - } - } if ( ! &value_is_true($nl->get_value('use_cn')) ) { if ( &value_is_true($nl_flags->{'use_fates'}) ) { if ( $nl->get_value('fates_spitfire_mode') < 2) { @@ -3925,7 +3918,10 @@ sub setup_logic_fire_emis { if ($opts->{'fire_emis'} ) { if ( &value_is_true( $nl_flags->{'use_fates'} ) ) { - $log->warning( "Fire emission factor file will NOT be used when FATES is on.\n" ); + $log->message( "Fire emission factor file will NOT be used when FATES is on.\n" ); + if ( $nl->get_value('fates_spitfire_mode') == 0) { + $log->fatal_error("cannot have fire_emis and use_fates set if fates does not have spitfire mode on") + } } else { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fire_emis_factors_file'); } From 1c65fee16253174c6561c998e5dec6a89bfeebbc Mon Sep 17 00:00:00 2001 From: rosiealice Date: Tue, 2 Apr 2024 02:44:55 -0600 Subject: [PATCH 06/12] added CTSM side variables for MEGAN_pft_index --- src/biogeophys/CanopyStateType.F90 | 4 +++- src/utils/clmfates_interfaceMod.F90 | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index 313f7a83f3..1d6b1638d2 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -51,7 +51,8 @@ module CanopyStateType real(r8) , pointer :: fsun240_patch (:) ! patch 240hr average of sunlit fraction of canopy real(r8) , pointer :: dleaf_patch (:) ! patch characteristic leaf width (diameter) [m] - ! for non-ED/FATES this is the same as pftcon%dleaf() + ! for non-ED/FATES this is the same as pftcon%dleaf() + integer , pointer :: voc_pftindex_patch (:) ! FATES specific MEGAN pft index. real(r8) , pointer :: rscanopy_patch (:) ! patch canopy stomatal resistance (s/m) (ED specific) real(r8) , pointer :: vegwp_patch (:,:) ! patch vegetation water matric potential (mm) @@ -142,6 +143,7 @@ subroutine InitAllocate(this, bounds) allocate(this%fsun240_patch (begp:endp)) ; this%fsun240_patch (:) = nan allocate(this%dleaf_patch (begp:endp)) ; this%dleaf_patch (:) = nan + allocate(this%voc_pftindex_patch (begp:endp)) ; this%voc_pftindex_patch (:) = nan allocate(this%rscanopy_patch (begp:endp)) ; this%rscanopy_patch (:) = nan ! allocate(this%gccanopy_patch (begp:endp)) ; this%gccanopy_patch (:) = 0.0_r8 allocate(this%vegwp_patch (begp:endp,1:nvegwcs)) ; this%vegwp_patch (:,:) = nan diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 7039884847..bd9610998e 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1355,6 +1355,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & z0m => canopystate_inst%z0m_patch , & ! Output: [real(r8) (:) ] momentum roughness length (m) displa => canopystate_inst%displa_patch, & dleaf_patch => canopystate_inst%dleaf_patch, & + voc_pftindex => canopystate_inst%voc_pftindex_patch, & snow_depth => waterdiagnosticbulk_inst%snow_depth_col, & frac_sno_eff => waterdiagnosticbulk_inst%frac_sno_eff_col, & frac_veg_nosno_alb => canopystate_inst%frac_veg_nosno_alb_patch) @@ -1478,7 +1479,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & z0m(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 displa(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 dleaf_patch(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 - + voc_pftindex(col%patchi(c)+1:col%patchf(c)) = 0 frac_veg_nosno_alb(col%patchi(c):col%patchf(c)) = 0.0_r8 ! Set the bareground patch indicator @@ -1540,6 +1541,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & z0m(p) = this%fates(nc)%bc_out(s)%z0m_pa(ifp) displa(p) = this%fates(nc)%bc_out(s)%displa_pa(ifp) dleaf_patch(p) = this%fates(nc)%bc_out(s)%dleaf_pa(ifp) + voc_pftindex(p) = this%fates(nc)%bc_out(s)%nocomp_MEGAN_pft_label_pa(ifp) end do ! veg pach if(abs(areacheck - 1.0_r8).gt.1.e-9_r8)then From e355bf2674ee672e18f0c0236766ae1ec2846dc2 Mon Sep 17 00:00:00 2001 From: rosiealice Date: Mon, 8 Apr 2024 03:27:28 -0600 Subject: [PATCH 07/12] spelling corrections --- src/biogeochem/MEGANFactorsMod.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/biogeochem/MEGANFactorsMod.F90 b/src/biogeochem/MEGANFactorsMod.F90 index 661bfbdde2..1f5caedbe6 100644 --- a/src/biogeochem/MEGANFactorsMod.F90 +++ b/src/biogeochem/MEGANFactorsMod.F90 @@ -58,9 +58,9 @@ subroutine megan_factors_get( comp_name, factors, class_n, molecwght ) ! ! !ARGUMENTS: character(len=*),intent(in) :: comp_name ! MEGAN compound name - real(r8), intent(out) :: factors(npfts) ! vegitation type factors for the compound of intrest - integer, intent(out) :: class_n ! MEGAN class number for the compound of intrest - real(r8), intent(out) :: molecwght ! molecular weight of the compound of intrest + real(r8), intent(out) :: factors(npfts) ! vegetation type factors for the compound of interest + integer, intent(out) :: class_n ! MEGAN class number for the compound of interest + real(r8), intent(out) :: molecwght ! molecular weight of the compound of interest ! ! LOCAL VARS: integer :: hashkey, ndx From 8451bd01f89fd9ab2b413962543e210f92882cf0 Mon Sep 17 00:00:00 2001 From: rosiealice Date: Mon, 8 Apr 2024 03:30:33 -0600 Subject: [PATCH 08/12] use FATES voc index in MEGAN calculations (implied mapping between FATES PFTs and HLM PFTs --- src/biogeochem/VOCEmissionMod.F90 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/biogeochem/VOCEmissionMod.F90 b/src/biogeochem/VOCEmissionMod.F90 index a1722a08b9..91b6269634 100644 --- a/src/biogeochem/VOCEmissionMod.F90 +++ b/src/biogeochem/VOCEmissionMod.F90 @@ -588,12 +588,18 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! set emis factor ! if specified, set EF for isoprene with mapped values + if(use_fates)then + patchtype = canopystate_inst%voc_pftindex_patch + else + patchtype = patch%itype(p) + endif if ( trim(meg_cmp%name) == 'isoprene' .and. shr_megan_mapped_emisfctrs) then - epsilon = get_map_EF(patch%itype(p),g, vocemis_inst) + epsilon = get_map_EF(patchtype,g, vocemis_inst) else - epsilon = meg_cmp%emis_factors(patch%itype(p)) + epsilon = meg_cmp%emis_factors(patchtype) end if + class_num = meg_cmp%class_number ! Activity factor for PPFD @@ -699,7 +705,6 @@ function get_map_EF(ivt_in, g_in, vocemis_inst) ! vocemis_inst%efisop_patch ! Output: [real(r8) (:,:)] emission factors for isoprene for each patch [ug m-2 h-1] get_map_EF = 0._r8 - if ( ivt_in == ndllf_evr_tmp_tree & .or. ivt_in == ndllf_evr_brl_tree) then !fineleaf evergreen get_map_EF = vocemis_inst%efisop_grc(2,g_in) @@ -717,7 +722,7 @@ function get_map_EF(ivt_in, g_in, vocemis_inst) else if (ivt_in >= nc3crop) then !crops get_map_EF = vocemis_inst%efisop_grc(6,g_in) end if - + end function get_map_EF !----------------------------------------------------------------------- From 0928770623ba3278ddce99e95263d669f8b50164 Mon Sep 17 00:00:00 2001 From: rosiealice Date: Mon, 8 Apr 2024 04:04:16 -0600 Subject: [PATCH 09/12] remove error check that stops FATES and MEGAN working together --- bld/CLMBuildNamelist.pm | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index fde53a8f8e..9b40ba3fb1 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -3952,10 +3952,6 @@ sub setup_logic_megan { } if ($nl_flags->{'megan'} ) { - if ( &value_is_true( $nl_flags->{'use_fates'} ) ) { - $log->warning("MEGAN can NOT be on when FATES is also on.\n" . - " Use the '-no-megan' option when '-bgc fates' is activated"); - } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'megan_specifier'); check_megan_spec( $opts, $nl, $definition ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'megan_factors_file'); From 06d783d21d6fb73b281ad4e246d466673962994d Mon Sep 17 00:00:00 2001 From: rosiealice Date: Mon, 8 Apr 2024 05:23:12 -0600 Subject: [PATCH 10/12] debugging --- src/biogeochem/VOCEmissionMod.F90 | 10 ++++++---- src/biogeophys/CanopyStateType.F90 | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/biogeochem/VOCEmissionMod.F90 b/src/biogeochem/VOCEmissionMod.F90 index 91b6269634..b52b793f52 100644 --- a/src/biogeochem/VOCEmissionMod.F90 +++ b/src/biogeochem/VOCEmissionMod.F90 @@ -415,6 +415,7 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! ! !USES: use subgridAveMod , only : p2g + use clm_varctl , only : use_fates ! ! !ARGUMENTS: type(bounds_type) , intent(in) :: bounds @@ -449,6 +450,7 @@ 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. character(len=16) :: mech_name type(shr_megan_megcomp_t), pointer :: meg_cmp real(r8) :: cp, alpha, Eopt, topt ! for history output @@ -589,14 +591,14 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! set emis factor ! if specified, set EF for isoprene with mapped values if(use_fates)then - patchtype = canopystate_inst%voc_pftindex_patch + patchpft = canopystate_inst%voc_pftindex_patch(p) else - patchtype = patch%itype(p) + patchpft = patch%itype(p) endif if ( trim(meg_cmp%name) == 'isoprene' .and. shr_megan_mapped_emisfctrs) then - epsilon = get_map_EF(patchtype,g, vocemis_inst) + epsilon = get_map_EF(patchpft,g, vocemis_inst) else - epsilon = meg_cmp%emis_factors(patchtype) + epsilon = meg_cmp%emis_factors(patchpft) end if diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index 1d6b1638d2..df14a925ac 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -143,7 +143,7 @@ subroutine InitAllocate(this, bounds) allocate(this%fsun240_patch (begp:endp)) ; this%fsun240_patch (:) = nan allocate(this%dleaf_patch (begp:endp)) ; this%dleaf_patch (:) = nan - allocate(this%voc_pftindex_patch (begp:endp)) ; this%voc_pftindex_patch (:) = nan + allocate(this%voc_pftindex_patch (begp:endp)) ; this%voc_pftindex_patch (:) = 0 allocate(this%rscanopy_patch (begp:endp)) ; this%rscanopy_patch (:) = nan ! allocate(this%gccanopy_patch (begp:endp)) ; this%gccanopy_patch (:) = 0.0_r8 allocate(this%vegwp_patch (begp:endp,1:nvegwcs)) ; this%vegwp_patch (:,:) = nan From b53ee9836d2efae2ff43d06a79cd62a627003974 Mon Sep 17 00:00:00 2001 From: rosiealice Date: Mon, 28 Oct 2024 02:35:32 -0600 Subject: [PATCH 11/12] turn off the -megan cant run with FATES- statement in bldnamelist --- bld/CLMBuildNamelist.pm | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 5ecff9c967..741fcfae10 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4156,10 +4156,6 @@ sub setup_logic_megan { if ( defined($nl->get_value('megan_specifier')) || defined($nl->get_value('megan_factors_file')) ) { check_megan_spec( $opts, $nl, $definition ); - if ( &value_is_true( $nl_flags->{'use_fates'} ) ) { - $log->warning("MEGAN can NOT be on when FATES is also on.\n" . - " Use the '-no-megan' option when '-bgc fates' is activated"); - } } } From 0f84a5a96a768ca592df65540f168dfee8fc9a57 Mon Sep 17 00:00:00 2001 From: rosiealice Date: Mon, 28 Oct 2024 08:28:16 -0600 Subject: [PATCH 12/12] passing ci from FATES into MEGAN --- src/biogeochem/VOCEmissionMod.F90 | 21 +++++++++++++-------- src/biogeophys/CanopyStateType.F90 | 2 ++ src/utils/clmfates_interfaceMod.F90 | 6 +++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/biogeochem/VOCEmissionMod.F90 b/src/biogeochem/VOCEmissionMod.F90 index 81089c5dac..74afda8980 100644 --- a/src/biogeochem/VOCEmissionMod.F90 +++ b/src/biogeochem/VOCEmissionMod.F90 @@ -499,7 +499,7 @@ 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) @@ -587,7 +587,8 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & patchpft = canopystate_inst%voc_pftindex_patch(p) else patchpft = patch%itype(p) - endif + endif + if ( trim(meg_cmp%name) == 'isoprene' .and. shr_megan_mapped_emisfctrs) then epsilon = get_map_EF(patchpft,g, vocemis_inst) else @@ -600,22 +601,27 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! Activity factor for PPFD gamma_p = get_gamma_P(par_sun, par24_sun, par240_sun, par_sha, par24_sha, par240_sha, & fsun(p), fsun240(p), forc_solad240(p),forc_solai240(p), LDF(class_num), cp, alpha) - + ! 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, patch%itype(p)) + betaT(class_num),LDF(class_num), Ceo(class_num), Eopt, topt, patchpft) ! Activity factor for Leaf Age - gamma_a = get_gamma_A(patch%itype(p), elai240(p),elai(p),class_num) + gamma_a = get_gamma_A(patchpft, elai240(p),elai(p),class_num) ! 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) - gamma_c = get_gamma_C(cisun_z(p,1),cisha_z(p,1),forc_pbot(c),fsun(p), co2_ppmv) + 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 + else gamma_c = 1._r8 end if - + ! Calculate total scaling factor gamma = gamma_l * gamma_sm * gamma_a * gamma_p * gamma_T * gamma_c @@ -626,7 +632,6 @@ subroutine VOCEmission (bounds, num_soilp, filter_soilp, & ! assign to arrays for history file output (not weighted by landfrac) meg_out(imeg)%flux_out(p) = meg_out(imeg)%flux_out(p) & + epsilon * gamma * megemis_units_factor*1.e-3_r8 ! Kg/m2/sec - if (imeg==1) then ! gamma_out(p)=gamma diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index 3bcd6b3a6e..f4cf3f17d2 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -46,6 +46,7 @@ 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 @@ -140,6 +141,7 @@ 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 86a203a881..1f83d29603 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2577,8 +2577,8 @@ subroutine wrap_photosynthesis(this, nc, bounds, fn, filterp, & rssun => photosyns_inst%rssun_patch , & rssha => photosyns_inst%rssha_patch, & psnsun => photosyns_inst%psnsun_patch, & - psnsha => photosyns_inst%psnsha_patch) - + psnsha => photosyns_inst%psnsha_patch, & + ci => canopystate_inst%ci_patch) do s = 1, this%fates(nc)%nsites c = this%f2hmap(nc)%fcolumn(s) @@ -2645,7 +2645,7 @@ 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) ! These fields are marked with a bad-value flag photosyns_inst%psnsun_patch(p) = spval photosyns_inst%psnsha_patch(p) = spval