From 2785caf1882324ffaeced04f6ec2aede2b57cda6 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 27 May 2022 09:25:13 -0600 Subject: [PATCH 001/194] Seperate out nrepr loops into ones for matrixcn off and on --- src/biogeochem/CNCStateUpdate1Mod.F90 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/biogeochem/CNCStateUpdate1Mod.F90 b/src/biogeochem/CNCStateUpdate1Mod.F90 index 717b524383..8c6fc11602 100644 --- a/src/biogeochem/CNCStateUpdate1Mod.F90 +++ b/src/biogeochem/CNCStateUpdate1Mod.F90 @@ -430,18 +430,18 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & end if cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_livestemc_patch(p)*dt cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_livestemc_storage_patch(p)*dt - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_reproductivec_patch(p,1)*dt - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_reproductivec_storage_patch(p,1)*dt + do k = 1, nrepr + cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_reproductivec_patch(p,k)*dt + cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_reproductivec_storage_patch(p,k)*dt + end do if(.not. use_matrixcn)then cs_veg%livestemc_patch(p) = cs_veg%livestemc_patch(p) + cf_veg%cpool_to_livestemc_patch(p)*dt cs_veg%livestemc_storage_patch(p) = cs_veg%livestemc_storage_patch(p) + cf_veg%cpool_to_livestemc_storage_patch(p)*dt do k = 1, nrepr - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_reproductivec_patch(p,k)*dt - cs_veg%reproductivec_patch(p,k) = cs_veg%reproductivec_patch(p,k) & - + cf_veg%cpool_to_reproductivec_patch(p,k)*dt - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_reproductivec_storage_patch(p,k)*dt + cs_veg%reproductivec_patch(p,k) = cs_veg%reproductivec_patch(p,k) & + + cf_veg%cpool_to_reproductivec_patch(p,k)*dt cs_veg%reproductivec_storage_patch(p,k) = cs_veg%reproductivec_storage_patch(p,k) & - + cf_veg%cpool_to_reproductivec_storage_patch(p,k)*dt + + cf_veg%cpool_to_reproductivec_storage_patch(p,k)*dt end do else ! NOTE: The equivalent changes for matrix code are in CNPhenology EBK (11/26/2019) From effacf2b1db196c7bf4c4fa87d45628fd25e9e00 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 28 Nov 2023 14:27:07 -0700 Subject: [PATCH 002/194] Corrections for cheyenne test-suite to pass --- src/biogeochem/CNCStateUpdate1Mod.F90 | 6 ------ src/biogeochem/CNNStateUpdate1Mod.F90 | 14 ++++++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/biogeochem/CNCStateUpdate1Mod.F90 b/src/biogeochem/CNCStateUpdate1Mod.F90 index 8c6fc11602..76b14585b4 100644 --- a/src/biogeochem/CNCStateUpdate1Mod.F90 +++ b/src/biogeochem/CNCStateUpdate1Mod.F90 @@ -325,15 +325,9 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%cropseedc_deficit_patch(p) = cs_veg%cropseedc_deficit_patch(p) & - cf_veg%crop_seedc_to_leaf_patch(p) * dt do k = repr_grain_min, repr_grain_max - cs_veg%reproductivec_patch(p,k) = cs_veg%reproductivec_patch(p,k) & - - (cf_veg%repr_grainc_to_food_patch(p,k) + cf_veg%repr_grainc_to_seed_patch(p,k))*dt cs_veg%cropseedc_deficit_patch(p) = cs_veg%cropseedc_deficit_patch(p) & + cf_veg%repr_grainc_to_seed_patch(p,k) * dt end do - do k = repr_structure_min, repr_structure_max - cs_veg%reproductivec_patch(p,k) = cs_veg%reproductivec_patch(p,k) & - - (cf_veg%repr_structurec_to_cropprod_patch(p,k) + cf_veg%repr_structurec_to_litter_patch(p,k))*dt - end do end if end if !not use_matrixcn diff --git a/src/biogeochem/CNNStateUpdate1Mod.F90 b/src/biogeochem/CNNStateUpdate1Mod.F90 index 8aa24e3aa3..4a9e081583 100644 --- a/src/biogeochem/CNNStateUpdate1Mod.F90 +++ b/src/biogeochem/CNNStateUpdate1Mod.F90 @@ -226,21 +226,23 @@ subroutine NStateUpdate1(num_soilc, filter_soilc, num_soilp, filter_soilp, & ns_veg%leafn_patch(p) = ns_veg%leafn_patch(p) - nf_veg%leafn_to_biofueln_patch(p)*dt ns_veg%livestemn_patch(p) = ns_veg%livestemn_patch(p) - nf_veg%livestemn_to_retransn_patch(p)*dt ns_veg%retransn_patch(p) = ns_veg%retransn_patch(p) + nf_veg%livestemn_to_retransn_patch(p)*dt + do k = repr_grain_min, repr_grain_max + ns_veg%reproductiven_patch(p,k) = ns_veg%reproductiven_patch(p,k) & + - (nf_veg%repr_grainn_to_food_patch(p,k) + nf_veg%repr_grainn_to_seed_patch(p,k))*dt + end do + do k = repr_structure_min, repr_structure_max + ns_veg%reproductiven_patch(p,k) = ns_veg%reproductiven_patch(p,k) & + - (nf_veg%repr_structuren_to_cropprod_patch(p,k) + nf_veg%repr_structuren_to_litter_patch(p,k))*dt + end do else ! NOTE: The equivalent changes for matrix code are in CNPhenology EBK (11/26/2019) end if !not use_matrixcn ns_veg%cropseedn_deficit_patch(p) = ns_veg%cropseedn_deficit_patch(p) & - nf_veg%crop_seedn_to_leaf_patch(p) * dt do k = repr_grain_min, repr_grain_max - ns_veg%reproductiven_patch(p,k) = ns_veg%reproductiven_patch(p,k) & - - (nf_veg%repr_grainn_to_food_patch(p,k) + nf_veg%repr_grainn_to_seed_patch(p,k))*dt ns_veg%cropseedn_deficit_patch(p) = ns_veg%cropseedn_deficit_patch(p) & + nf_veg%repr_grainn_to_seed_patch(p,k) * dt end do - do k = repr_structure_min, repr_structure_max - ns_veg%reproductiven_patch(p,k) = ns_veg%reproductiven_patch(p,k) & - - (nf_veg%repr_structuren_to_cropprod_patch(p,k) + nf_veg%repr_structuren_to_litter_patch(p,k))*dt - end do end if ! uptake from soil mineral N pool From ffc6acc0184df317314d5d2cdd36076627d854a1 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 29 Nov 2023 17:47:40 -0700 Subject: [PATCH 003/194] Upd. expected fails, test list, and relevant error checks --- bld/CLMBuildNamelist.pm | 7 ++++ cime_config/testdefs/ExpectedTestFails.xml | 28 +++++++++++++++ cime_config/testdefs/testlist_clm.xml | 40 ++++++++++++++++++++++ src/biogeochem/CropReprPoolsMod.F90 | 11 ++++++ 4 files changed, 86 insertions(+) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b0d533ebde..b92acc34c7 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4222,6 +4222,13 @@ sub setup_logic_cnmatrix { } # Otherwise for CN or BGC mode } else { + # If matrixcn is on, for_testing_use_second_grain_pool and for_testing_use_repr_structure_pool must be off + if ( &value_is_true($nl->get_value("use_matrixcn")) && &value_is_true($nl_flags->{"for_testing_use_second_grain_pool"}) ) { + $log->fatal_error("for_testing_use_second_grain_pool can NOT be on when use_matrixcn is on" ); + } + if ( &value_is_true($nl->get_value("use_matrixcn")) && &value_is_true($nl_flags->{"for_testing_use_repr_structure_pool"}) ) { + $log->fatal_error("for_testing_use_repr_structure_pool can NOT be on when use_matrixcn is on" ); + } # If both matrixcn and soil_matrix are off outmatrix can't be on if ( ! &value_is_true($nl->get_value("use_matrixcn")) && ! &value_is_true($nl_flags->{"use_soil_matrixcn"}) ) { my $var = "is_outmatrix"; diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 2656079bf7..a55ce73634 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -44,6 +44,34 @@ + + + FAIL + #640, same test with clm-ciso_soil_matrixcn_only works + + + + + + FAIL + #640, same test with clm-ciso_soil_matrixcn_only works + + + + + + FAIL + #640, same test with clm-ciso_soil_matrixcn_only works + + + + + + FAIL + #640, same test with clm-ciso_soil_matrixcn_only works + + + diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index e570603ff7..100067f90d 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2599,6 +2599,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/biogeochem/CropReprPoolsMod.F90 b/src/biogeochem/CropReprPoolsMod.F90 index 780b9f2d52..82469b074f 100644 --- a/src/biogeochem/CropReprPoolsMod.F90 +++ b/src/biogeochem/CropReprPoolsMod.F90 @@ -57,6 +57,11 @@ subroutine crop_repr_pools_init() ! !DESCRIPTION: ! Initialize module-level data ! + ! !USES: + use clm_varctl, only: use_matrixcn + use abortutils, only: endrun + use shr_log_mod, only: errmsg => shr_log_errMsg + ! ! !ARGUMENTS: ! ! !LOCAL VARIABLES: @@ -77,11 +82,17 @@ subroutine crop_repr_pools_init() ! repr_hist_fnames(1) = 'GRAIN_MEAL', grain_hist_fnames(2) = 'GRAIN_OIL', etc. if (for_testing_use_second_grain_pool) then nrepr_grain = 2 + if (use_matrixcn) then + call endrun(msg="ERROR: for_testing_use_second_grain_pool should be .false. when use_matrixcn = .true."//errmsg(sourcefile, __LINE__)) + end if else nrepr_grain = 1 end if if (for_testing_use_repr_structure_pool) then nrepr_structure = 2 + if (use_matrixcn) then + call endrun(msg="ERROR: for_testing_use_repr_structure_pool should be .false. when use_matrixcn = .true."//errMsg(sourcefile, __LINE__)) + end if else nrepr_structure = 0 end if From 040111314eb439f6815b4519174d179882650c42 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 1 Dec 2023 15:50:14 -0700 Subject: [PATCH 004/194] Update expected fails and testlist files --- bld/CLMBuildNamelist.pm | 5 +++++ cime_config/testdefs/ExpectedTestFails.xml | 13 +++---------- cime_config/testdefs/testlist_clm.xml | 12 ------------ 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b92acc34c7..f02be0c91a 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4222,6 +4222,11 @@ sub setup_logic_cnmatrix { } # Otherwise for CN or BGC mode } else { + # TODO (slevis 2023/12/1) The next two if statements do nothing. Erik K and Sam L found that + # for_testing_use_second_grain_pool and for_testing_use_repr_structure_pool + # are empty rather than .true. or .false., but we did not get to the bottom + # of why, yet. The same error-check in the code does get triggered at run-time, + # so we will not pursue fixing this right now. # If matrixcn is on, for_testing_use_second_grain_pool and for_testing_use_repr_structure_pool must be off if ( &value_is_true($nl->get_value("use_matrixcn")) && &value_is_true($nl_flags->{"for_testing_use_second_grain_pool"}) ) { $log->fatal_error("for_testing_use_second_grain_pool can NOT be on when use_matrixcn is on" ); diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index a55ce73634..18619818fa 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -30,17 +30,10 @@ - - + + FAIL - PGI problems with the nuopc driver - - - - - - FAIL - PGI problems with the nuopc driver + Accessing incorrect url for neon data; will resolve itself when we update cnmatrix to some newer tag diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 100067f90d..ede4f6d278 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1177,7 +1177,6 @@ - @@ -1431,7 +1430,6 @@ - @@ -1446,15 +1444,6 @@ - - - - - - - - - @@ -1548,7 +1537,6 @@ - From def2f7506284508182898bc0d1edeb2c12812572 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 12 Dec 2023 12:16:39 -0700 Subject: [PATCH 005/194] Change failing SMS_Ln9_P72x2 test to passing SMS_Ln9_P360x2 --- cime_config/testdefs/testlist_clm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 81ad8bced4..52ccfbf2db 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -322,7 +322,7 @@ - + From 08768f9b877caed6efd3c8fbb38f1ac3bbf29991 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 18 Dec 2023 15:25:38 -0700 Subject: [PATCH 006/194] To pass test, add use_matrixcn=.false. to luna testmod --- cime_config/testdefs/testmods_dirs/clm/luna/user_nl_clm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/luna/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/luna/user_nl_clm index cbfbb9f525..fb796ebfaf 100644 --- a/cime_config/testdefs/testmods_dirs/clm/luna/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/luna/user_nl_clm @@ -1,3 +1,3 @@ use_luna = .true. use_flexibleCN = .false. - + use_matrixcn = .false. From 8b2cb728ac99a2e6c8a7be5738f8b709b5e336b5 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 19 Dec 2023 12:46:43 -0700 Subject: [PATCH 007/194] Remove two clm45 tests from ExpectedTestFails --- cime_config/testdefs/ExpectedTestFails.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 18619818fa..8a43eb0acc 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -44,13 +44,6 @@ - - - FAIL - #640, same test with clm-ciso_soil_matrixcn_only works - - - FAIL @@ -58,13 +51,6 @@ - - - FAIL - #640, same test with clm-ciso_soil_matrixcn_only works - - - From ddfac7b299d8143fdf2c2d7438cf2729fe1a047d Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 22 Dec 2023 15:35:13 -0700 Subject: [PATCH 008/194] Backed dev100 mods out of 3 more files for 1x1_brazil test to pass --- src/biogeochem/CNCStateUpdate1Mod.F90 | 232 ++---- src/biogeochem/CNPhenologyMod.F90 | 680 +++++++++--------- .../SoilBiogeochemNStateUpdate1Mod.F90 | 70 +- 3 files changed, 429 insertions(+), 553 deletions(-) diff --git a/src/biogeochem/CNCStateUpdate1Mod.F90 b/src/biogeochem/CNCStateUpdate1Mod.F90 index 8cac85824e..f73453476e 100644 --- a/src/biogeochem/CNCStateUpdate1Mod.F90 +++ b/src/biogeochem/CNCStateUpdate1Mod.F90 @@ -2,9 +2,6 @@ module CNCStateUpdate1Mod !----------------------------------------------------------------------- ! Module for carbon state variable update, non-mortality fluxes. - ! When the matrix solution is being used (use_matrixcn and use_soil_matrixcn) - ! only some state updates are done here, the other state updates happen - ! after the matrix is solved in VegMatrix and SoilMatrix. ! ! !USES: use shr_kind_mod , only : r8 => shr_kind_r8 @@ -19,7 +16,8 @@ module CNCStateUpdate1Mod use CNVegCarbonFluxType , only : cnveg_carbonflux_type use CropType , only : crop_type use CropReprPoolsMod , only : nrepr, repr_grain_min, repr_grain_max, repr_structure_min, repr_structure_max - use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con, use_soil_matrixcn + use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con + use SoilBiogeochemDecompCascadeConType , only : use_soil_matrixcn use SoilBiogeochemCarbonFluxType , only : soilbiogeochem_carbonflux_type use SoilBiogeochemCarbonStateType , only : soilbiogeochem_carbonstate_type use PatchType , only : patch @@ -193,9 +191,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & do j = 1,nlevdecomp do fc = 1,num_soilc c = filter_soilc(fc) - ! - ! State update without the matrix solution - ! if (.not. use_soil_matrixcn) then ! phenology and dynamic land cover fluxes do i = i_litr_min, i_litr_max @@ -207,12 +202,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & ! terms have been moved to CStateUpdateDynPatch. I think this is zeroed every ! time step, but to be safe, I'm explicitly setting it to zero here. cf_soil%decomp_cpools_sourcesink_col(c,j,i_cwd) = 0._r8 - ! - ! For the matrix solution the actual state update comes after the matrix - ! multiply in SoilMatrix, but the matrix needs to be setup with - ! the equivalent of above. Those changes can be here or in the - ! native subroutines dealing with that field - ! else ! phenology and dynamic land cover fluxes do i = i_litr_min, i_litr_max @@ -243,15 +232,11 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & do j = 1,nlevdecomp do fc = 1,num_soilc c = filter_soilc(fc) - ! - ! State update without the matrix solution - ! if (.not. use_soil_matrixcn) then cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) = & - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) & - - ( cf_soil%decomp_cascade_hr_vr_col(c,j,k) + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)) *dt - ! else ! not needed here? - end if !not use_soil_matrixcn + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) & + - ( cf_soil%decomp_cascade_hr_vr_col(c,j,k) + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)) *dt + end if !not use_soil_matrixcn end do end do end do @@ -260,14 +245,10 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & do j = 1,nlevdecomp do fc = 1,num_soilc c = filter_soilc(fc) - ! - ! State update without the matrix solution - ! if (.not. use_soil_matrixcn) then cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) = & - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) & - + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)*dt - ! else ! not needed here? + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) & + + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)*dt end if !not use_soil_matrixcn end do end do @@ -275,17 +256,13 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & end do end if - if (.not. use_fates) then + if (.not. use_fates) then ptch: do fp = 1,num_soilp p = filter_soilp(fp) c = patch%column(p) ! phenology: transfer growth fluxes - - ! - ! State update without the matrix solution - ! - if(.not. use_matrixcn)then + if(.not. use_matrixcn)then ! NOTE: Any changes that go here MUST be applied to the matrix ! version as well cs_veg%leafc_patch(p) = cs_veg%leafc_patch(p) + cf_veg%leafc_xfer_to_leafc_patch(p)*dt @@ -314,11 +291,11 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & end do end if - ! phenology: litterfall fluxes + ! phenology: litterfall fluxes cs_veg%leafc_patch(p) = cs_veg%leafc_patch(p) - cf_veg%leafc_to_litter_patch(p)*dt cs_veg%frootc_patch(p) = cs_veg%frootc_patch(p) - cf_veg%frootc_to_litter_patch(p)*dt - - ! livewood turnover fluxes + + ! livewood turnover fluxes if (woody(ivt(p)) == 1._r8) then cs_veg%livestemc_patch(p) = cs_veg%livestemc_patch(p) - cf_veg%livestemc_to_deadstemc_patch(p)*dt cs_veg%deadstemc_patch(p) = cs_veg%deadstemc_patch(p) + cf_veg%livestemc_to_deadstemc_patch(p)*dt @@ -342,81 +319,57 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & - (cf_veg%repr_structurec_to_cropprod_patch(p,k) + cf_veg%repr_structurec_to_litter_patch(p,k))*dt end do end if - ! - ! For the matrix solution the actual state update comes after the matrix - ! multiply in VegMatrix, but the matrix needs to be setup with - ! the equivalent of above. Those changes can be here or in the - ! native subroutines dealing with that field - ! - else - ! NOTE: Changes for above that apply for matrix code are in CNPhenology EBK (11/26/2019) - - ! This part below MUST match exactly the code for the non-matrix part - ! above! - if (ivt(p) >= npcropmin) then - cs_veg%cropseedc_deficit_patch(p) = cs_veg%cropseedc_deficit_patch(p) & - - cf_veg%crop_seedc_to_leaf_patch(p) * dt - do k = repr_grain_min, repr_grain_max - cs_veg%cropseedc_deficit_patch(p) = cs_veg%cropseedc_deficit_patch(p) & - + cf_veg%repr_grainc_to_seed_patch(p,k) * dt - end do -! else ! slevis: I think I rejected this alternative due to a balance error -! ! NOTE: Changes for above that apply for matrix code are in CNPhenology EBK (11/26/2019) - -! ! This part below MUST match exactly the code for the non-matrix part -! ! above! -! if (ivt(p) >= npcropmin) then -! cs_veg%cropseedc_deficit_patch(p) = cs_veg%cropseedc_deficit_patch(p) & -! - cf_veg%crop_seedc_to_leaf_patch(p) * dt -! do k = repr_grain_min, repr_grain_max -! cs_veg%reproductivec_patch(p,k) = cs_veg%reproductivec_patch(p,k) & -! - (cf_veg%repr_grainc_to_food_patch(p,k) + cf_veg%repr_grainc_to_seed_patch(p,k))*dt -! cs_veg%cropseedc_deficit_patch(p) = cs_veg%cropseedc_deficit_patch(p) & -! + cf_veg%repr_grainc_to_seed_patch(p,k) * dt -! end do -! do k = repr_structure_min, repr_structure_max -! cs_veg%reproductivec_patch(p,k) = cs_veg%reproductivec_patch(p,k) & -! - (cf_veg%repr_structurec_to_cropprod_patch(p,k) + cf_veg%repr_structurec_to_litter_patch(p,k))*dt -! end do - end if - end if !not use_matrixcn + else + ! NOTE: Changes for above that apply for matrix code are in CNPhenology EBK (11/26/2019) + + ! This part below MUST match exactly the code for the non-matrix part + ! above! + if (ivt(p) >= npcropmin) then + cs_veg%cropseedc_deficit_patch(p) = cs_veg%cropseedc_deficit_patch(p) & + - cf_veg%crop_seedc_to_leaf_patch(p) * dt + do k = repr_grain_min, repr_grain_max + cs_veg%cropseedc_deficit_patch(p) = cs_veg%cropseedc_deficit_patch(p) & + + cf_veg%repr_grainc_to_seed_patch(p,k) * dt + end do + end if + end if !not use_matrixcn - check_cpool = cs_veg%cpool_patch(p)- cf_veg%psnsun_to_cpool_patch(p)*dt-cf_veg%psnshade_to_cpool_patch(p)*dt - cpool_delta = cs_veg%cpool_patch(p) + check_cpool = cs_veg%cpool_patch(p)- cf_veg%psnsun_to_cpool_patch(p)*dt-cf_veg%psnshade_to_cpool_patch(p)*dt + cpool_delta = cs_veg%cpool_patch(p) - ! maintenance respiration fluxes from cpool + ! maintenance respiration fluxes from cpool - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_xsmrpool_patch(p)*dt - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%leaf_curmr_patch(p)*dt - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%froot_curmr_patch(p)*dt - If (woody(ivt(p)) == 1._r8) then + cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_xsmrpool_patch(p)*dt + cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%leaf_curmr_patch(p)*dt + cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%froot_curmr_patch(p)*dt + If (woody(ivt(p)) == 1._r8) then cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%livestem_curmr_patch(p)*dt cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%livecroot_curmr_patch(p)*dt - end if - if (ivt(p) >= npcropmin) then ! skip 2 generic crops + end if + if (ivt(p) >= npcropmin) then ! skip 2 generic crops cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%livestem_curmr_patch(p)*dt do k = 1, nrepr cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%reproductive_curmr_patch(p,k)*dt end do - end if + end if - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_resp_patch(p)*dt + cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_resp_patch(p)*dt - !RF Add in the carbon spent on uptake respiration - cs_veg%cpool_patch(p)= cs_veg%cpool_patch(p) - cf_veg%soilc_change_patch(p)*dt + !RF Add in the carbon spent on uptake respiration. + cs_veg%cpool_patch(p)= cs_veg%cpool_patch(p) - cf_veg%soilc_change_patch(p)*dt - ! maintenance respiration fluxes from xsmrpool - cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) + cf_veg%cpool_to_xsmrpool_patch(p)*dt - cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) - cf_veg%leaf_xsmr_patch(p)*dt - cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) - cf_veg%froot_xsmr_patch(p)*dt - if (woody(ivt(p)) == 1._r8) then + ! maintenance respiration fluxes from xsmrpool + cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) + cf_veg%cpool_to_xsmrpool_patch(p)*dt + cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) - cf_veg%leaf_xsmr_patch(p)*dt + cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) - cf_veg%froot_xsmr_patch(p)*dt + if (woody(ivt(p)) == 1._r8) then cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) - cf_veg%livestem_xsmr_patch(p)*dt cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) - cf_veg%livecroot_xsmr_patch(p)*dt - end if + end if - ! allocation fluxes - if (carbon_resp_opt == 1) then + ! allocation fluxes + if (carbon_resp_opt == 1) then cf_veg%cpool_to_leafc_patch(p) = cf_veg%cpool_to_leafc_patch(p) - cf_veg%cpool_to_leafc_resp_patch(p) cf_veg%cpool_to_leafc_storage_patch(p) = cf_veg%cpool_to_leafc_storage_patch(p) - & cf_veg%cpool_to_leafc_storage_resp_patch(p) @@ -427,21 +380,12 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_leafc_patch(p)*dt cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_leafc_storage_patch(p)*dt cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_frootc_patch(p)*dt - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_frootc_storage_patch(p)*dt - ! - ! State update without the matrix solution - ! - if(.not. use_matrixcn) then + cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_frootc_storage_patch(p)*dt + if(.not. use_matrixcn) then cs_veg%leafc_patch(p) = cs_veg%leafc_patch(p) + cf_veg%cpool_to_leafc_patch(p)*dt cs_veg%leafc_storage_patch(p) = cs_veg%leafc_storage_patch(p) + cf_veg%cpool_to_leafc_storage_patch(p)*dt cs_veg%frootc_patch(p) = cs_veg%frootc_patch(p) + cf_veg%cpool_to_frootc_patch(p)*dt cs_veg%frootc_storage_patch(p) = cs_veg%frootc_storage_patch(p) + cf_veg%cpool_to_frootc_storage_patch(p)*dt - ! - ! For the matrix solution the actual state update comes after the matrix - ! multiply in VegMatrix, but the matrix needs to be setup with - ! the equivalent of above. Those changes can be here or in the - ! native subroutines dealing with that field - ! else ! NOTE: The equivalent changes for matrix code are in CNPhenology EBK (11/26/2019) end if !not use_matrixcn @@ -461,10 +405,7 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_livecrootc_patch(p)*dt cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_livecrootc_storage_patch(p)*dt cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_deadcrootc_patch(p)*dt - cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_deadcrootc_storage_patch(p)*dt - ! - ! State update without the matrix solution - ! + cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_deadcrootc_storage_patch(p)*dt if(.not. use_matrixcn)then cs_veg%livestemc_patch(p) = cs_veg%livestemc_patch(p) + cf_veg%cpool_to_livestemc_patch(p)*dt cs_veg%livestemc_storage_patch(p) = cs_veg%livestemc_storage_patch(p) + cf_veg%cpool_to_livestemc_storage_patch(p)*dt @@ -474,12 +415,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%livecrootc_storage_patch(p) = cs_veg%livecrootc_storage_patch(p) + cf_veg%cpool_to_livecrootc_storage_patch(p)*dt cs_veg%deadcrootc_patch(p) = cs_veg%deadcrootc_patch(p) + cf_veg%cpool_to_deadcrootc_patch(p)*dt cs_veg%deadcrootc_storage_patch(p) = cs_veg%deadcrootc_storage_patch(p) + cf_veg%cpool_to_deadcrootc_storage_patch(p)*dt - ! - ! For the matrix solution the actual state update comes after the matrix - ! multiply in VegMatrix, but the matrix needs to be setup with - ! the equivalent of above. Those changes can be here or in the - ! native subroutines dealing with that field - ! else ! NOTE: The equivalent changes for matrix code are in CNPhenology EBK (11/26/2019) end if !not use_matrixcn @@ -496,9 +431,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_reproductivec_patch(p,k)*dt cs_veg%cpool_patch(p) = cs_veg%cpool_patch(p) - cf_veg%cpool_to_reproductivec_storage_patch(p,k)*dt end do - ! - ! State update without the matrix solution - ! if(.not. use_matrixcn)then cs_veg%livestemc_patch(p) = cs_veg%livestemc_patch(p) + cf_veg%cpool_to_livestemc_patch(p)*dt cs_veg%livestemc_storage_patch(p) = cs_veg%livestemc_storage_patch(p) + cf_veg%cpool_to_livestemc_storage_patch(p)*dt @@ -508,12 +440,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%reproductivec_storage_patch(p,k) = cs_veg%reproductivec_storage_patch(p,k) & + cf_veg%cpool_to_reproductivec_storage_patch(p,k)*dt end do - ! - ! For the matrix solution the actual state update comes after the matrix - ! multiply in VegMatrix, but the matrix needs to be setup with - ! the equivalent of above. Those changes can be here or in the - ! native subroutines dealing with that field - ! else ! NOTE: The equivalent changes for matrix code are in CNPhenology EBK (11/26/2019) end if !not use_matrixcn @@ -576,30 +502,17 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%gresp_storage_patch(p) = cs_veg%gresp_storage_patch(p) + cf_veg%cpool_to_gresp_storage_patch(p)*dt ! move storage pools into transfer pools - - ! - ! State update without the matrix solution - ! - if(.not. use_matrixcn)then - cs_veg%leafc_storage_patch(p) = cs_veg%leafc_storage_patch(p) - cf_veg%leafc_storage_to_xfer_patch(p)*dt - cs_veg%leafc_xfer_patch(p) = cs_veg%leafc_xfer_patch(p) + cf_veg%leafc_storage_to_xfer_patch(p)*dt - cs_veg%frootc_storage_patch(p) = cs_veg%frootc_storage_patch(p) - cf_veg%frootc_storage_to_xfer_patch(p)*dt - cs_veg%frootc_xfer_patch(p) = cs_veg%frootc_xfer_patch(p) + cf_veg%frootc_storage_to_xfer_patch(p)*dt - ! - ! For the matrix solution the actual state update comes after the matrix - ! multiply in VegMatrix, but the matrix needs to be setup with - ! the equivalent of above. Those changes can be here or in the - ! native subroutines dealing with that field - ! + if(.not. use_matrixcn)then + cs_veg%leafc_storage_patch(p) = cs_veg%leafc_storage_patch(p) - cf_veg%leafc_storage_to_xfer_patch(p)*dt + cs_veg%leafc_xfer_patch(p) = cs_veg%leafc_xfer_patch(p) + cf_veg%leafc_storage_to_xfer_patch(p)*dt + cs_veg%frootc_storage_patch(p) = cs_veg%frootc_storage_patch(p) - cf_veg%frootc_storage_to_xfer_patch(p)*dt + cs_veg%frootc_xfer_patch(p) = cs_veg%frootc_xfer_patch(p) + cf_veg%frootc_storage_to_xfer_patch(p)*dt else - ! NOTE: The equivalent changes for matrix code are in CNPhenology EBK (11/26/2019) + ! NOTE: The equivalent changes for matrix code are in CNPhenology EBK (11/26/2019) end if !not use_matrixcn if (woody(ivt(p)) == 1._r8) then cs_veg%gresp_storage_patch(p) = cs_veg%gresp_storage_patch(p) - cf_veg%gresp_storage_to_xfer_patch(p)*dt cs_veg%gresp_xfer_patch(p) = cs_veg%gresp_xfer_patch(p) + cf_veg%gresp_storage_to_xfer_patch(p)*dt - ! - ! State update without the matrix solution - ! if(.not. use_matrixcn)then cs_veg%livestemc_storage_patch(p) = cs_veg%livestemc_storage_patch(p) - cf_veg%livestemc_storage_to_xfer_patch(p)*dt cs_veg%livestemc_xfer_patch(p) = cs_veg%livestemc_xfer_patch(p) + cf_veg%livestemc_storage_to_xfer_patch(p)*dt @@ -609,21 +522,12 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%livecrootc_xfer_patch(p) = cs_veg%livecrootc_xfer_patch(p) + cf_veg%livecrootc_storage_to_xfer_patch(p)*dt cs_veg%deadcrootc_storage_patch(p) = cs_veg%deadcrootc_storage_patch(p)- cf_veg%deadcrootc_storage_to_xfer_patch(p)*dt cs_veg%deadcrootc_xfer_patch(p) = cs_veg%deadcrootc_xfer_patch(p) + cf_veg%deadcrootc_storage_to_xfer_patch(p)*dt - ! - ! For the matrix solution the actual state update comes after the matrix - ! multiply in VegMatrix, but the matrix needs to be setup with - ! the equivalent of above. Those changes can be here or in the - ! native subroutines dealing with that field - ! else ! NOTE: The equivalent changes for matrix code are in CNPhenology EBK (11/26/2019) end if !not use_matrixcn end if if (ivt(p) >= npcropmin) then ! skip 2 generic crops ! lines here for consistency; the transfer terms are zero - ! - ! State update without the matrix solution - ! if(.not. use_matrixcn)then ! lines here for consistency; the transfer terms are zero cs_veg%livestemc_storage_patch(p) = cs_veg%livestemc_storage_patch(p) - cf_veg%livestemc_storage_to_xfer_patch(p)*dt @@ -634,12 +538,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%reproductivec_xfer_patch(p,k) = cs_veg%reproductivec_xfer_patch(p,k) & + cf_veg%reproductivec_storage_to_xfer_patch(p,k)*dt end do - ! - ! For the matrix solution the actual state update comes after the matrix - ! multiply in VegMatrix, but the matrix needs to be setup with - ! the equivalent of above. Those changes can be here or in the - ! native subroutines dealing with that field - ! else ! NOTE: The equivalent changes for matrix code are in CNPhenology EBK (11/26/2019) end if !not use_matrixcn @@ -655,20 +553,16 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & ! an intent(inout) ! fluxes should not be updated in this module - not sure where ! this belongs - ! DML (06-20-2017) While debugging crop isotope code, found that cpool_patch and frootc_patch - ! could occasionally be very small but nonzero numbers after crop harvest, which persists + ! DML (06-20-2017) While debugging crop isotope code, found that cpool_patch and frootc_patch + ! could occasionally be very small but nonzero numbers after crop harvest, which persists ! through to next planting and for reasons that could not 100% ! isolate, caused C12/C13 ratios to occasionally go out of ! bounds. Zeroing out these small pools and putting them into the flux to the ! atmosphere solved many of the crop isotope problems - ! Instantly release XSMRPOOL to atmosphere if ( .not. dribble_crophrv_xsmrpool_2atm ) then cf_veg%xsmrpool_to_atm_patch(p) = cf_veg%xsmrpool_to_atm_patch(p) + cs_veg%xsmrpool_patch(p)/dt cf_veg%xsmrpool_to_atm_patch(p) = cf_veg%xsmrpool_to_atm_patch(p) + cs_veg%cpool_patch(p)/dt - ! - ! State update without the matrix solution - ! if(.not. use_matrixcn)then cf_veg%xsmrpool_to_atm_patch(p) = cf_veg%xsmrpool_to_atm_patch(p) + cs_veg%frootc_patch(p)/dt else @@ -684,9 +578,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%xsmrpool_loss_patch(p) = cs_veg%xsmrpool_loss_patch(p) + & cs_veg%xsmrpool_patch(p) + & cs_veg%cpool_patch(p) - ! - ! State update without the matrix solution - ! if(.not. use_matrixcn)then cs_veg%xsmrpool_loss_patch(p) = cs_veg%xsmrpool_loss_patch(p) + cs_veg%frootc_patch(p) else @@ -694,9 +585,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & + cs_veg%frootc_patch(p) * matrix_update_phc(p,cf_veg%ifroot_to_iout_ph,1._r8/dt,dt,cnveg_carbonflux_inst,.true.,.true.) end if end if - ! - ! State update without the matrix solution - ! if (.not. use_matrixcn) then cs_veg%frootc_patch(p) = 0._r8 end if @@ -713,8 +601,8 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & end if end if - end do ptch ! end of patch loop - end if ! end of NOT fates + end do ptch ! end of patch loop + end if ! end of NOT fates end associate diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 5d666c0ffb..e804c0658b 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -136,10 +136,8 @@ module CNPhenologyMod integer, allocatable :: maxplantjday(:,:) ! maximum planting julian day integer :: jdayyrstart(inSH) ! julian day of start of year - ! Two matrix check parameters that will be invoked when the matrix solution - ! comes in (use_matrixcn) - logical,parameter :: matrixcheck_ph = .True. ! Matrix solution check - logical,parameter :: acc_ph = .False. ! Another matrix solution check + logical,parameter :: matrixcheck_ph = .True. ! Matrix check + logical,parameter :: acc_ph = .False. ! Another matrix check real(r8), private :: initial_seed_at_planting = 3._r8 ! Initial seed at planting @@ -641,114 +639,115 @@ subroutine CNEvergreenPhenology (num_soilp, filter_soilp , & integer :: p ! indices integer :: fp ! lake filter patch index - real(r8):: tranr + real(r8):: tranr real(r8):: t1 ! temporary variable !----------------------------------------------------------------------- associate( & - ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type + ivt => patch%itype , & ! Input: [integer (:) ] patch vegetation type - evergreen => pftcon%evergreen , & ! Input: binary flag for evergreen leaf habit (0 or 1) - leaf_long => pftcon%leaf_long , & ! Input: leaf longevity (yrs) + evergreen => pftcon%evergreen , & ! Input: binary flag for evergreen leaf habit (0 or 1) + leaf_long => pftcon%leaf_long , & ! Input: leaf longevity (yrs) - woody => pftcon%woody , & ! Input: binary flag for woody lifeform (1=woody, 0=not woody) + woody => pftcon%woody , & ! Input: binary flag for woody lifeform (1=woody, 0=not woody) - leafc_storage => cnveg_carbonstate_inst%leafc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) leaf C storage - frootc_storage => cnveg_carbonstate_inst%frootc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) fine root C storage - livestemc_storage => cnveg_carbonstate_inst%livestemc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) live stem C storage - deadstemc_storage => cnveg_carbonstate_inst%deadstemc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) dead stem C storage - livecrootc_storage => cnveg_carbonstate_inst%livecrootc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) live coarse root C storage - deadcrootc_storage => cnveg_carbonstate_inst%deadcrootc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) dead coarse root C storage - gresp_storage => cnveg_carbonstate_inst%gresp_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) growth respiration storage - leafc_xfer => cnveg_carbonstate_inst%leafc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) leaf C transfer - frootc_xfer => cnveg_carbonstate_inst%frootc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) fine root C transfer - livestemc_xfer => cnveg_carbonstate_inst%livestemc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) live stem C transfer - deadstemc_xfer => cnveg_carbonstate_inst%deadstemc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) dead stem C transfer - livecrootc_xfer => cnveg_carbonstate_inst%livecrootc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) live coarse root C transfer - deadcrootc_xfer => cnveg_carbonstate_inst%deadcrootc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) dead coarse root C transfer - - leafn_storage => cnveg_nitrogenstate_inst%leafn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) leaf N storage - frootn_storage => cnveg_nitrogenstate_inst%frootn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) fine root N storage - livestemn_storage => cnveg_nitrogenstate_inst%livestemn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) live stem N storage - deadstemn_storage => cnveg_nitrogenstate_inst%deadstemn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) dead stem N storage - livecrootn_storage => cnveg_nitrogenstate_inst%livecrootn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) live coarse root N storage - deadcrootn_storage => cnveg_nitrogenstate_inst%deadcrootn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) dead coarse root N storage - leafn_xfer => cnveg_nitrogenstate_inst%leafn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) leaf N transfer - frootn_xfer => cnveg_nitrogenstate_inst%frootn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) fine root N transfer - livestemn_xfer => cnveg_nitrogenstate_inst%livestemn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) live stem N transfer - deadstemn_xfer => cnveg_nitrogenstate_inst%deadstemn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) dead stem N transfer - livecrootn_xfer => cnveg_nitrogenstate_inst%livecrootn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) live coarse root N transfer - deadcrootn_xfer => cnveg_nitrogenstate_inst%deadcrootn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) dead coarse root N transfer - - leafc_storage_to_xfer => cnveg_carbonflux_inst%leafc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - frootc_storage_to_xfer => cnveg_carbonflux_inst%frootc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - livestemc_storage_to_xfer => cnveg_carbonflux_inst%livestemc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - deadstemc_storage_to_xfer => cnveg_carbonflux_inst%deadstemc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - livecrootc_storage_to_xfer => cnveg_carbonflux_inst%livecrootc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - deadcrootc_storage_to_xfer => cnveg_carbonflux_inst%deadcrootc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - gresp_storage_to_xfer => cnveg_carbonflux_inst%gresp_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - leafc_xfer_to_leafc => cnveg_carbonflux_inst%leafc_xfer_to_leafc_patch , & ! InOut: [real(r8) (:)] - frootc_xfer_to_frootc => cnveg_carbonflux_inst%frootc_xfer_to_frootc_patch , & ! InOut: [real(r8) (:)] - livestemc_xfer_to_livestemc => cnveg_carbonflux_inst%livestemc_xfer_to_livestemc_patch , & ! InOut: [real(r8) (:)] - deadstemc_xfer_to_deadstemc => cnveg_carbonflux_inst%deadstemc_xfer_to_deadstemc_patch , & ! InOut: [real(r8) (:)] - livecrootc_xfer_to_livecrootc => cnveg_carbonflux_inst%livecrootc_xfer_to_livecrootc_patch , & ! InOut: [real(r8) (:)] - deadcrootc_xfer_to_deadcrootc => cnveg_carbonflux_inst%deadcrootc_xfer_to_deadcrootc_patch , & ! InOut: [real(r8) (:)] - - leafn_storage_to_xfer => cnveg_nitrogenflux_inst%leafn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - frootn_storage_to_xfer => cnveg_nitrogenflux_inst%frootn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - livestemn_storage_to_xfer => cnveg_nitrogenflux_inst%livestemn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - deadstemn_storage_to_xfer => cnveg_nitrogenflux_inst%deadstemn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - livecrootn_storage_to_xfer => cnveg_nitrogenflux_inst%livecrootn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - deadcrootn_storage_to_xfer => cnveg_nitrogenflux_inst%deadcrootn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] - leafn_xfer_to_leafn => cnveg_nitrogenflux_inst%leafn_xfer_to_leafn_patch , & ! InOut: [real(r8) (:)] - frootn_xfer_to_frootn => cnveg_nitrogenflux_inst%frootn_xfer_to_frootn_patch , & ! InOut: [real(r8) (:)] - livestemn_xfer_to_livestemn => cnveg_nitrogenflux_inst%livestemn_xfer_to_livestemn_patch , & ! InOut: [real(r8) (:)] - deadstemn_xfer_to_deadstemn => cnveg_nitrogenflux_inst%deadstemn_xfer_to_deadstemn_patch , & ! InOut: [real(r8) (:)] - livecrootn_xfer_to_livecrootn => cnveg_nitrogenflux_inst%livecrootn_xfer_to_livecrootn_patch , & ! InOut: [real(r8) (:)] - deadcrootn_xfer_to_deadcrootn => cnveg_nitrogenflux_inst%deadcrootn_xfer_to_deadcrootn_patch , & ! InOut: [real(r8) (:)] - - bglfr => cnveg_state_inst%bglfr_patch , & ! Output: [real(r8) (:) ] background litterfall rate (1/s) - bgtr => cnveg_state_inst%bgtr_patch , & ! Output: [real(r8) (:) ] background transfer growth rate (1/s) - lgsf => cnveg_state_inst%lgsf_patch , & ! Output: [real(r8) (:) ] long growing season factor [0-1] - ileafst_to_ileafxf_phc => cnveg_carbonflux_inst%ileafst_to_ileafxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf storage pool to leaf transfer pool - ileafxf_to_ileaf_phc => cnveg_carbonflux_inst%ileafxf_to_ileaf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf transfer pool to leaf pool - ifrootst_to_ifrootxf_phc => cnveg_carbonflux_inst%ifrootst_to_ifrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root storage pool to fine root transfer pool - ifrootxf_to_ifroot_phc => cnveg_carbonflux_inst%ifrootxf_to_ifroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root transfer pool to fine root pool - ilivestemst_to_ilivestemxf_phc => cnveg_carbonflux_inst%ilivestemst_to_ilivestemxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem storage pool to live stem transfer pool - ilivestemxf_to_ilivestem_phc => cnveg_carbonflux_inst%ilivestemxf_to_ilivestem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem transfer pool to live stem pool - ideadstemst_to_ideadstemxf_phc => cnveg_carbonflux_inst%ideadstemst_to_ideadstemxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead stem storage pool to dead stem transfer pool - ideadstemxf_to_ideadstem_phc => cnveg_carbonflux_inst%ideadstemxf_to_ideadstem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead stem transfer pool to dead stem pool - ilivecrootst_to_ilivecrootxf_phc => cnveg_carbonflux_inst%ilivecrootst_to_ilivecrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root storage pool to live coarse root transfer pool - ilivecrootxf_to_ilivecroot_phc => cnveg_carbonflux_inst%ilivecrootxf_to_ilivecroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root transfer pool to live coarse root pool - ideadcrootst_to_ideadcrootxf_phc => cnveg_carbonflux_inst%ideadcrootst_to_ideadcrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead coarse root storage pool to dead coarse root transfer pool - ideadcrootxf_to_ideadcroot_phc => cnveg_carbonflux_inst%ideadcrootxf_to_ideadcroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead coarse root transfer pool to dead coarse root pool - ilivestem_to_ideadstem_phc => cnveg_carbonflux_inst%ilivestem_to_ideadstem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to dead stem pool - ilivecroot_to_ideadcroot_phc => cnveg_carbonflux_inst%ilivecroot_to_ideadcroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root to dead coarse root pool - ileaf_to_iout_phc => cnveg_carbonflux_inst%ileaf_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf pool to outside of vegetation pools - ifroot_to_iout_phc => cnveg_carbonflux_inst%ifroot_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root pool to outside of vegetation pools - ilivestem_to_iout_phc => cnveg_carbonflux_inst%ilivestem_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to outside of vegetation pools - igrain_to_iout_phc => cnveg_carbonflux_inst%igrain_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from grain pool to outside of vegetation pools - ileafst_to_ileafxf_phn => cnveg_nitrogenflux_inst%ileafst_to_ileafxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf storage pool to leaf transfer pool - ileafxf_to_ileaf_phn => cnveg_nitrogenflux_inst%ileafxf_to_ileaf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf transfer pool to leaf pool - ifrootst_to_ifrootxf_phn => cnveg_nitrogenflux_inst%ifrootst_to_ifrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root storage pool to fine root transfer pool - ifrootxf_to_ifroot_phn => cnveg_nitrogenflux_inst%ifrootxf_to_ifroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root transfer pool to fine root pool - ilivestemst_to_ilivestemxf_phn => cnveg_nitrogenflux_inst%ilivestemst_to_ilivestemxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem storage pool to live stem transfer pool - ilivestemxf_to_ilivestem_phn => cnveg_nitrogenflux_inst%ilivestemxf_to_ilivestem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem transfer pool to live stem pool - ideadstemst_to_ideadstemxf_phn => cnveg_nitrogenflux_inst%ideadstemst_to_ideadstemxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead stem storage pool to dead stem transfer pool - ideadstemxf_to_ideadstem_phn => cnveg_nitrogenflux_inst%ideadstemxf_to_ideadstem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead stem transfer pool to dead stem pool - ilivecrootst_to_ilivecrootxf_phn => cnveg_nitrogenflux_inst%ilivecrootst_to_ilivecrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root storage pool to live coarse root transfer pool - ilivecrootxf_to_ilivecroot_phn => cnveg_nitrogenflux_inst%ilivecrootxf_to_ilivecroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root transfer pool to live coarse root pool - ideadcrootst_to_ideadcrootxf_phn => cnveg_nitrogenflux_inst%ideadcrootst_to_ideadcrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead coarse root storage pool to dead coarse root transfer pool - ideadcrootxf_to_ideadcroot_phn => cnveg_nitrogenflux_inst%ideadcrootxf_to_ideadcroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead coarse root transfer pool to dead coarse root pool - ilivestem_to_ideadstem_phn => cnveg_nitrogenflux_inst%ilivestem_to_ideadstem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to dead stem pool - ilivecroot_to_ideadcroot_phn => cnveg_nitrogenflux_inst%ilivecroot_to_ideadcroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root to dead coarse root pool - ileaf_to_iout_phn => cnveg_nitrogenflux_inst%ileaf_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf pool to outside of vegetation pools - ifroot_to_iout_phn => cnveg_nitrogenflux_inst%ifroot_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root pool to outside of vegetation pools - ilivestem_to_iout_phn => cnveg_nitrogenflux_inst%ilivestem_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to outside of vegetation pools - ileaf_to_iretransn_phn => cnveg_nitrogenflux_inst%ileaf_to_iretransn_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf pool to retranslocation pool - ilivestem_to_iretransn_phn => cnveg_nitrogenflux_inst%ilivestem_to_iretransn_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to retranslocation pool - ilivecroot_to_iretransn_phn => cnveg_nitrogenflux_inst%ilivecroot_to_iretransn_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root pool to retranslocation pool - igrain_to_iout_phn => cnveg_nitrogenflux_inst%igrain_to_iout_ph & ! Input: [integer (:)] Index of phenology related C transfer from grain pool to outside of vegetation pools + leafc_storage => cnveg_carbonstate_inst%leafc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) leaf C storage + frootc_storage => cnveg_carbonstate_inst%frootc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) fine root C storage + livestemc_storage => cnveg_carbonstate_inst%livestemc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) live stem C storage + deadstemc_storage => cnveg_carbonstate_inst%deadstemc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) dead stem C storage + livecrootc_storage => cnveg_carbonstate_inst%livecrootc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) live coarse root C storage + deadcrootc_storage => cnveg_carbonstate_inst%deadcrootc_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) dead coarse root C storage + gresp_storage => cnveg_carbonstate_inst%gresp_storage_patch , & ! Input: [real(r8) (:)] (gC/m2) growth respiration storage + leafc_xfer => cnveg_carbonstate_inst%leafc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) leaf C transfer + frootc_xfer => cnveg_carbonstate_inst%frootc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) fine root C transfer + livestemc_xfer => cnveg_carbonstate_inst%livestemc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) live stem C transfer + deadstemc_xfer => cnveg_carbonstate_inst%deadstemc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) dead stem C transfer + livecrootc_xfer => cnveg_carbonstate_inst%livecrootc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) live coarse root C transfer + deadcrootc_xfer => cnveg_carbonstate_inst%deadcrootc_xfer_patch , & ! InOut: [real(r8) (:)] (gC/m2) dead coarse root C transfer + + leafn_storage => cnveg_nitrogenstate_inst%leafn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) leaf N storage + frootn_storage => cnveg_nitrogenstate_inst%frootn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) fine root N storage + livestemn_storage => cnveg_nitrogenstate_inst%livestemn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) live stem N storage + deadstemn_storage => cnveg_nitrogenstate_inst%deadstemn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) dead stem N storage + livecrootn_storage => cnveg_nitrogenstate_inst%livecrootn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) live coarse root N storage + deadcrootn_storage => cnveg_nitrogenstate_inst%deadcrootn_storage_patch , & ! Input: [real(r8) (:)] (gN/m2) dead coarse root N storage + leafn_xfer => cnveg_nitrogenstate_inst%leafn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) leaf N transfer + frootn_xfer => cnveg_nitrogenstate_inst%frootn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) fine root N transfer + livestemn_xfer => cnveg_nitrogenstate_inst%livestemn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) live stem N transfer + deadstemn_xfer => cnveg_nitrogenstate_inst%deadstemn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) dead stem N transfer + livecrootn_xfer => cnveg_nitrogenstate_inst%livecrootn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) live coarse root N transfer + deadcrootn_xfer => cnveg_nitrogenstate_inst%deadcrootn_xfer_patch , & ! InOut: [real(r8) (:)] (gN/m2) dead coarse root N transfer + + leafc_storage_to_xfer => cnveg_carbonflux_inst%leafc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + frootc_storage_to_xfer => cnveg_carbonflux_inst%frootc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + livestemc_storage_to_xfer => cnveg_carbonflux_inst%livestemc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + deadstemc_storage_to_xfer => cnveg_carbonflux_inst%deadstemc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + livecrootc_storage_to_xfer => cnveg_carbonflux_inst%livecrootc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + deadcrootc_storage_to_xfer => cnveg_carbonflux_inst%deadcrootc_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + gresp_storage_to_xfer => cnveg_carbonflux_inst%gresp_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + leafc_xfer_to_leafc => cnveg_carbonflux_inst%leafc_xfer_to_leafc_patch , & ! InOut: [real(r8) (:)] + frootc_xfer_to_frootc => cnveg_carbonflux_inst%frootc_xfer_to_frootc_patch , & ! InOut: [real(r8) (:)] + livestemc_xfer_to_livestemc => cnveg_carbonflux_inst%livestemc_xfer_to_livestemc_patch , & ! InOut: [real(r8) (:)] + deadstemc_xfer_to_deadstemc => cnveg_carbonflux_inst%deadstemc_xfer_to_deadstemc_patch , & ! InOut: [real(r8) (:)] + livecrootc_xfer_to_livecrootc => cnveg_carbonflux_inst%livecrootc_xfer_to_livecrootc_patch , & ! InOut: [real(r8) (:)] + deadcrootc_xfer_to_deadcrootc => cnveg_carbonflux_inst%deadcrootc_xfer_to_deadcrootc_patch , & ! InOut: [real(r8) (:)] + + leafn_storage_to_xfer => cnveg_nitrogenflux_inst%leafn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + frootn_storage_to_xfer => cnveg_nitrogenflux_inst%frootn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + livestemn_storage_to_xfer => cnveg_nitrogenflux_inst%livestemn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + deadstemn_storage_to_xfer => cnveg_nitrogenflux_inst%deadstemn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + livecrootn_storage_to_xfer => cnveg_nitrogenflux_inst%livecrootn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + deadcrootn_storage_to_xfer => cnveg_nitrogenflux_inst%deadcrootn_storage_to_xfer_patch , & ! InOut: [real(r8) (:)] + leafn_xfer_to_leafn => cnveg_nitrogenflux_inst%leafn_xfer_to_leafn_patch , & ! InOut: [real(r8) (:)] + frootn_xfer_to_frootn => cnveg_nitrogenflux_inst%frootn_xfer_to_frootn_patch , & ! InOut: [real(r8) (:)] + livestemn_xfer_to_livestemn => cnveg_nitrogenflux_inst%livestemn_xfer_to_livestemn_patch , & ! InOut: [real(r8) (:)] + deadstemn_xfer_to_deadstemn => cnveg_nitrogenflux_inst%deadstemn_xfer_to_deadstemn_patch , & ! InOut: [real(r8) (:)] + livecrootn_xfer_to_livecrootn => cnveg_nitrogenflux_inst%livecrootn_xfer_to_livecrootn_patch , & ! InOut: [real(r8) (:)] + deadcrootn_xfer_to_deadcrootn => cnveg_nitrogenflux_inst%deadcrootn_xfer_to_deadcrootn_patch , & ! InOut: [real(r8) (:)] + + bglfr => cnveg_state_inst%bglfr_patch , & ! Output: [real(r8) (:) ] background litterfall rate (1/s) + bgtr => cnveg_state_inst%bgtr_patch , & ! Output: [real(r8) (:) ] background transfer growth rate (1/s) + lgsf => cnveg_state_inst%lgsf_patch , & ! Output: [real(r8) (:) ] long growing season factor [0-1] + + ileafst_to_ileafxf_phc => cnveg_carbonflux_inst%ileafst_to_ileafxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf storage pool to leaf transfer pool + ileafxf_to_ileaf_phc => cnveg_carbonflux_inst%ileafxf_to_ileaf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf transfer pool to leaf pool + ifrootst_to_ifrootxf_phc => cnveg_carbonflux_inst%ifrootst_to_ifrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root storage pool to fine root transfer pool + ifrootxf_to_ifroot_phc => cnveg_carbonflux_inst%ifrootxf_to_ifroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root transfer pool to fine root pool + ilivestemst_to_ilivestemxf_phc => cnveg_carbonflux_inst%ilivestemst_to_ilivestemxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem storage pool to live stem transfer pool + ilivestemxf_to_ilivestem_phc => cnveg_carbonflux_inst%ilivestemxf_to_ilivestem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem transfer pool to live stem pool + ideadstemst_to_ideadstemxf_phc => cnveg_carbonflux_inst%ideadstemst_to_ideadstemxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead stem storage pool to dead stem transfer pool + ideadstemxf_to_ideadstem_phc => cnveg_carbonflux_inst%ideadstemxf_to_ideadstem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead stem transfer pool to dead stem pool + ilivecrootst_to_ilivecrootxf_phc => cnveg_carbonflux_inst%ilivecrootst_to_ilivecrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root storage pool to live coarse root transfer pool + ilivecrootxf_to_ilivecroot_phc => cnveg_carbonflux_inst%ilivecrootxf_to_ilivecroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root transfer pool to live coarse root pool + ideadcrootst_to_ideadcrootxf_phc => cnveg_carbonflux_inst%ideadcrootst_to_ideadcrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead coarse root storage pool to dead coarse root transfer pool + ideadcrootxf_to_ideadcroot_phc => cnveg_carbonflux_inst%ideadcrootxf_to_ideadcroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead coarse root transfer pool to dead coarse root pool + ilivestem_to_ideadstem_phc => cnveg_carbonflux_inst%ilivestem_to_ideadstem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to dead stem pool + ilivecroot_to_ideadcroot_phc => cnveg_carbonflux_inst%ilivecroot_to_ideadcroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root to dead coarse root pool + ileaf_to_iout_phc => cnveg_carbonflux_inst%ileaf_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf pool to outside of vegetation pools + ifroot_to_iout_phc => cnveg_carbonflux_inst%ifroot_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root pool to outside of vegetation pools + ilivestem_to_iout_phc => cnveg_carbonflux_inst%ilivestem_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to outside of vegetation pools + igrain_to_iout_phc => cnveg_carbonflux_inst%igrain_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from grain pool to outside of vegetation pools + ileafst_to_ileafxf_phn => cnveg_nitrogenflux_inst%ileafst_to_ileafxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf storage pool to leaf transfer pool + ileafxf_to_ileaf_phn => cnveg_nitrogenflux_inst%ileafxf_to_ileaf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf transfer pool to leaf pool + ifrootst_to_ifrootxf_phn => cnveg_nitrogenflux_inst%ifrootst_to_ifrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root storage pool to fine root transfer pool + ifrootxf_to_ifroot_phn => cnveg_nitrogenflux_inst%ifrootxf_to_ifroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root transfer pool to fine root pool + ilivestemst_to_ilivestemxf_phn => cnveg_nitrogenflux_inst%ilivestemst_to_ilivestemxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem storage pool to live stem transfer pool + ilivestemxf_to_ilivestem_phn => cnveg_nitrogenflux_inst%ilivestemxf_to_ilivestem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem transfer pool to live stem pool + ideadstemst_to_ideadstemxf_phn => cnveg_nitrogenflux_inst%ideadstemst_to_ideadstemxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead stem storage pool to dead stem transfer pool + ideadstemxf_to_ideadstem_phn => cnveg_nitrogenflux_inst%ideadstemxf_to_ideadstem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead stem transfer pool to dead stem pool + ilivecrootst_to_ilivecrootxf_phn => cnveg_nitrogenflux_inst%ilivecrootst_to_ilivecrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root storage pool to live coarse root transfer pool + ilivecrootxf_to_ilivecroot_phn => cnveg_nitrogenflux_inst%ilivecrootxf_to_ilivecroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root transfer pool to live coarse root pool + ideadcrootst_to_ideadcrootxf_phn => cnveg_nitrogenflux_inst%ideadcrootst_to_ideadcrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead coarse root storage pool to dead coarse root transfer pool + ideadcrootxf_to_ideadcroot_phn => cnveg_nitrogenflux_inst%ideadcrootxf_to_ideadcroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from dead coarse root transfer pool to dead coarse root pool + ilivestem_to_ideadstem_phn => cnveg_nitrogenflux_inst%ilivestem_to_ideadstem_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to dead stem pool + ilivecroot_to_ideadcroot_phn => cnveg_nitrogenflux_inst%ilivecroot_to_ideadcroot_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root to dead coarse root pool + ileaf_to_iout_phn => cnveg_nitrogenflux_inst%ileaf_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf pool to outside of vegetation pools + ifroot_to_iout_phn => cnveg_nitrogenflux_inst%ifroot_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root pool to outside of vegetation pools + ilivestem_to_iout_phn => cnveg_nitrogenflux_inst%ilivestem_to_iout_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to outside of vegetation pools + ileaf_to_iretransn_phn => cnveg_nitrogenflux_inst%ileaf_to_iretransn_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf pool to retranslocation pool + ilivestem_to_iretransn_phn => cnveg_nitrogenflux_inst%ilivestem_to_iretransn_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live stem pool to retranslocation pool + ilivecroot_to_iretransn_phn => cnveg_nitrogenflux_inst%ilivecroot_to_iretransn_ph , & ! Input: [integer (:)] Index of phenology related C transfer from live coarse root pool to retranslocation pool + igrain_to_iout_phn => cnveg_nitrogenflux_inst%igrain_to_iout_ph & ! Input: [integer (:)] Index of phenology related C transfer from grain pool to outside of vegetation pools ) avg_dayspyr = get_average_days_per_year() @@ -770,17 +769,7 @@ subroutine CNEvergreenPhenology (num_soilp, filter_soilp , & tranr=0.0002_r8 ! set carbon fluxes for shifting storage pools to transfer pools - if (.not. use_matrixcn) then - leafc_storage_to_xfer(p) = tranr * leafc_storage(p)/dt - frootc_storage_to_xfer(p) = tranr * frootc_storage(p)/dt - if (woody(ivt(p)) == 1.0_r8) then - livestemc_storage_to_xfer(p) = tranr * livestemc_storage(p)/dt - deadstemc_storage_to_xfer(p) = tranr * deadstemc_storage(p)/dt - livecrootc_storage_to_xfer(p) = tranr * livecrootc_storage(p)/dt - deadcrootc_storage_to_xfer(p) = tranr * deadcrootc_storage(p)/dt - gresp_storage_to_xfer(p) = tranr * gresp_storage(p)/dt - end if - else + if (use_matrixcn) then leafc_storage_to_xfer(p) = leafc_storage(p) * matrix_update_phc(p,ileafst_to_ileafxf_phc,tranr/dt,dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) frootc_storage_to_xfer(p) = frootc_storage(p) * matrix_update_phc(p,ifrootst_to_ifrootxf_phc,tranr/dt,dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) if (woody(ivt(p)) == 1.0_r8) then @@ -789,7 +778,18 @@ subroutine CNEvergreenPhenology (num_soilp, filter_soilp , & livecrootc_storage_to_xfer(p) = livecrootc_storage(p) * matrix_update_phc(p,ilivecrootst_to_ilivecrootxf_phc,tranr/dt,dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) deadcrootc_storage_to_xfer(p) = deadcrootc_storage(p) * matrix_update_phc(p,ideadcrootst_to_ideadcrootxf_phc,tranr/dt,dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) end if - end if !not use_matrixcn + else + ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) + leafc_storage_to_xfer(p) = tranr * leafc_storage(p)/dt + frootc_storage_to_xfer(p) = tranr * frootc_storage(p)/dt + if (woody(ivt(p)) == 1.0_r8) then + livestemc_storage_to_xfer(p) = tranr * livestemc_storage(p)/dt + deadstemc_storage_to_xfer(p) = tranr * deadstemc_storage(p)/dt + livecrootc_storage_to_xfer(p) = tranr * livecrootc_storage(p)/dt + deadcrootc_storage_to_xfer(p) = tranr * deadcrootc_storage(p)/dt + gresp_storage_to_xfer(p) = tranr * gresp_storage(p)/dt + end if + end if !use_matrixcn ! set nitrogen fluxes for shifting storage pools to transfer pools if (use_matrixcn) then @@ -1849,37 +1849,36 @@ subroutine CNStressDecidPhenology (num_soilp, filter_soilp , & ! between leafc and leafc_store in the flux. RosieF, Nov5 2015. leafc_storage_to_xfer(p) = max(0.0_r8,(leafc_storage(p)-leafc(p))) * bgtr(p) frootc_storage_to_xfer(p) = max(0.0_r8,(frootc_storage(p)-frootc(p))) * bgtr(p) - if (use_matrixcn) then - if(leafc_storage(p) > 0._r8)then + if(leafc_storage(p) .gt. 0)then leafc_storage_to_xfer(p) = leafc_storage(p) * matrix_update_phc(p,ileafst_to_ileafxf_phc,& leafc_storage_to_xfer(p) / leafc_storage(p), dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - leafc_storage_to_xfer(p) = 0._r8 + leafc_storage_to_xfer(p) = 0 end if - if(frootc_storage(p) > 0._r8)then + if(frootc_storage(p) .gt. 0)then frootc_storage_to_xfer(p) = frootc_storage(p) * matrix_update_phc(p,ifrootst_to_ifrootxf_phc,& frootc_storage_to_xfer(p) / frootc_storage(p), dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - frootc_storage_to_xfer(p) = 0._r8 + frootc_storage_to_xfer(p) = 0 end if - if (woody(ivt(p)) == 1.0_r8) then + if (woody(ivt(p)) == 1.0_r8) then livestemc_storage_to_xfer(p) = livestemc_storage(p) * matrix_update_phc(p,ilivestemst_to_ilivestemxf_phc ,bgtr(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) deadstemc_storage_to_xfer(p) = deadstemc_storage(p) * matrix_update_phc(p,ideadstemst_to_ideadstemxf_phc ,bgtr(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) livecrootc_storage_to_xfer(p) = livecrootc_storage(p) * matrix_update_phc(p,ilivecrootst_to_ilivecrootxf_phc,bgtr(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) deadcrootc_storage_to_xfer(p) = deadcrootc_storage(p) * matrix_update_phc(p,ideadcrootst_to_ideadcrootxf_phc,bgtr(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) - end if - else - ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) - ! and CNNStateUpdate1::NStateUpdate1 - if (woody(ivt(p)) == 1.0_r8) then - livestemc_storage_to_xfer(p) = livestemc_storage(p) * bgtr(p) - deadstemc_storage_to_xfer(p) = deadstemc_storage(p) * bgtr(p) - livecrootc_storage_to_xfer(p) = livecrootc_storage(p) * bgtr(p) - deadcrootc_storage_to_xfer(p) = deadcrootc_storage(p) * bgtr(p) - gresp_storage_to_xfer(p) = gresp_storage(p) * bgtr(p) - end if - end if !use_matrixcn + end if + else + ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) + ! and CNNStateUpdate1::NStateUpdate1 + if (woody(ivt(p)) == 1.0_r8) then + livestemc_storage_to_xfer(p) = livestemc_storage(p) * bgtr(p) + deadstemc_storage_to_xfer(p) = deadstemc_storage(p) * bgtr(p) + livecrootc_storage_to_xfer(p) = livecrootc_storage(p) * bgtr(p) + deadcrootc_storage_to_xfer(p) = deadcrootc_storage(p) * bgtr(p) + gresp_storage_to_xfer(p) = gresp_storage(p) * bgtr(p) + end if + end if !use_matrixcn ! set nitrogen fluxes for shifting storage pools to transfer pools if (use_matrixcn) then @@ -2920,22 +2919,7 @@ subroutine CNOnsetGrowth (num_soilp, filter_soilp, & ! pools should be moved to displayed growth in each timestep. if (bgtr(p) > 0._r8) then - if(.not. use_matrixcn)then - leafc_xfer_to_leafc(p) = leafc_xfer(p) / dt - frootc_xfer_to_frootc(p) = frootc_xfer(p) / dt - leafn_xfer_to_leafn(p) = leafn_xfer(p) / dt - frootn_xfer_to_frootn(p) = frootn_xfer(p) / dt - if (woody(ivt(p)) == 1.0_r8) then - livestemc_xfer_to_livestemc(p) = livestemc_xfer(p) / dt - deadstemc_xfer_to_deadstemc(p) = deadstemc_xfer(p) / dt - livecrootc_xfer_to_livecrootc(p) = livecrootc_xfer(p) / dt - deadcrootc_xfer_to_deadcrootc(p) = deadcrootc_xfer(p) / dt - livestemn_xfer_to_livestemn(p) = livestemn_xfer(p) / dt - deadstemn_xfer_to_deadstemn(p) = deadstemn_xfer(p) / dt - livecrootn_xfer_to_livecrootn(p) = livecrootn_xfer(p) / dt - deadcrootn_xfer_to_deadcrootn(p) = deadcrootn_xfer(p) / dt - end if - else + if(use_matrixcn)then leafc_xfer_to_leafc(p) = leafc_xfer(p) * matrix_update_phc(p,ileafxf_to_ileaf_phc,1._r8 / dt,dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) frootc_xfer_to_frootc(p) = frootc_xfer(p) * matrix_update_phc(p,ifrootxf_to_ifroot_phc,1._r8 / dt,dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) leafn_xfer_to_leafn(p) = leafn_xfer(p) * matrix_update_phn(p,ileafxf_to_ileaf_phn,1._r8 / dt,dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) @@ -2952,7 +2936,24 @@ subroutine CNOnsetGrowth (num_soilp, filter_soilp, & livecrootn_xfer_to_livecrootn(p) = livecrootn_xfer(p) * matrix_update_phn(p,ilivecrootxf_to_ilivecroot_phn,1._r8 / dt,dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) deadcrootn_xfer_to_deadcrootn(p) = deadcrootn_xfer(p) * matrix_update_phn(p,ideadcrootxf_to_ideadcroot_phn,1._r8 / dt,dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) end if - end if !not use_matrixcn + else + ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) + ! and CNNStateUpdate1::NStateUpdate1 + leafc_xfer_to_leafc(p) = leafc_xfer(p) / dt + frootc_xfer_to_frootc(p) = frootc_xfer(p) / dt + leafn_xfer_to_leafn(p) = leafn_xfer(p) / dt + frootn_xfer_to_frootn(p) = frootn_xfer(p) / dt + if (woody(ivt(p)) == 1.0_r8) then + livestemc_xfer_to_livestemc(p) = livestemc_xfer(p) / dt + deadstemc_xfer_to_deadstemc(p) = deadstemc_xfer(p) / dt + livecrootc_xfer_to_livecrootc(p) = livecrootc_xfer(p) / dt + deadcrootc_xfer_to_deadcrootc(p) = deadcrootc_xfer(p) / dt + livestemn_xfer_to_livestemn(p) = livestemn_xfer(p) / dt + deadstemn_xfer_to_deadstemn(p) = deadstemn_xfer(p) / dt + livecrootn_xfer_to_livecrootn(p) = livecrootn_xfer(p) / dt + deadcrootn_xfer_to_deadcrootn(p) = deadcrootn_xfer(p) / dt + end if + end if !use_matrixcn end if ! end if bgtr end do ! end patch loop @@ -3113,26 +3114,26 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & if (abs(offset_counter(p) - dt) <= dt/2._r8) then t1 = 1.0_r8 / dt + frootc_to_litter(p) = t1 * frootc(p) + cpool_to_frootc(p) + + ! biofuel_harvfrac is only non-zero for prognostic crops. + leafc_to_litter(p) = t1 * leafc(p)*(1._r8-biofuel_harvfrac(ivt(p))) + cpool_to_leafc(p) - ! leafc_litter and frootc_to_litter for matrix if (use_matrixcn) then - if(leafc(p) > 0._r8)then + if(leafc(p) .gt. 0)then leafc_to_litter(p) = leafc(p) * matrix_update_phc(p,ileaf_to_iout_phc,leafc_to_litter(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - leafc_to_litter(p) = 0._r8 + leafc_to_litter(p) = 0 end if - if(frootc(p) > 0._r8)then + if(frootc(p) .gt. 0)then frootc_to_litter(p) = frootc(p) * matrix_update_phc(p,ifroot_to_iout_phc,frootc_to_litter(p) / frootc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - frootc_to_litter(p) = 0._r8 + frootc_to_litter(p) = 0 end if else - frootc_to_litter(p) = t1 * frootc(p) + cpool_to_frootc(p) - - ! biofuel_harvfrac is only non-zero for prognostic crops. - leafc_to_litter(p) = t1 * leafc(p)*(1._r8-biofuel_harvfrac(ivt(p))) + cpool_to_leafc(p) + ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) + ! and CNNStateUpdate1::NStateUpdate1 end if ! use_matrixcn - ! this assumes that offset_counter == dt for crops ! if this were ever changed, we'd need to add code to the "else" if (ivt(p) >= npcropmin) then @@ -3176,101 +3177,105 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & * (1._r8 - repr_structure_harvfrac(ivt(p), k)) end do - ! Matrix for grain, livestem to litter and biofuel + ! Cut a certain fraction (i.e., biofuel_harvfrac(ivt(p))) (e.g., biofuel_harvfrac(ivt(p)=70% for bioenergy crops) of leaf C + ! and move this fration of leaf C to biofuel C, rather than move it to litter + leafc_to_biofuelc(p) = t1 * leafc(p) * biofuel_harvfrac(ivt(p)) + leafn_to_biofueln(p) = t1 * leafn(p) * biofuel_harvfrac(ivt(p)) + + ! Cut a certain fraction (i.e., biofuel_harvfrac(ivt(p))) (e.g., biofuel_harvfrac(ivt(p)=70% for bioenergy crops) of livestem C + ! and move this fration of leaf C to biofuel C, rather than move it to litter + livestemc_to_litter(p) = t1 * livestemc(p)*(1._r8-biofuel_harvfrac(ivt(p))) + cpool_to_livestemc(p) + livestemc_to_biofuelc(p) = t1 * livestemc(p) * biofuel_harvfrac(ivt(p)) + livestemn_to_biofueln(p) = t1 * livestemn(p) * biofuel_harvfrac(ivt(p)) + if(use_matrixcn)then - if(reproductivec(p,1) > 0._r8)then + if(reproductivec(p,1) .gt. 0)then grainc_to_out = reproductivec(p,1) * matrix_update_phc(p,igrain_to_iout_phc,(repr_grainc_to_seed(p,1) + repr_grainc_to_food(p,1)) / reproductivec(p,1),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - repr_grainc_to_seed(p,1) = 0._r8 - repr_grainc_to_food(p,1) = 0._r8 + repr_grainc_to_seed(p,1) = 0 + repr_grainc_to_food(p,1) = 0 end if - if(reproductiven(p,1) > 0._r8)then + if(reproductiven(p,1) .gt. 0)then grainn_to_out = reproductiven(p,1) * matrix_update_phn(p,igrain_to_iout_phn,(repr_grainn_to_seed(p,1) + repr_grainn_to_food(p,1)) / reproductiven(p,1),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - repr_grainn_to_seed(p,1) = 0._r8 - repr_grainn_to_food(p,1) = 0._r8 + repr_grainn_to_seed(p,1) = 0 + repr_grainn_to_food(p,1) = 0 end if - if(livestemc(p) > 0._r8)then + if(livestemc(p) .gt. 0)then livestemc_to_litter(p) = livestemc(p) * matrix_update_phc(p,ilivestem_to_iout_phc,livestemc_to_litter(p) / livestemc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - livestemc_to_litter(p) = 0._r8 + livestemc_to_litter(p) = 0 end if - if(livestemn(p) > 0._r8)then + if(livestemn(p) .gt. 0)then livestemn_to_biofueln(p) = livestemn(p) * matrix_update_gmn(p,ilivestem_to_iout_gmn,livestemn_to_biofueln(p) / livestemn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) else - livestemn_to_biofueln(p) = 0._r8 + livestemn_to_biofueln(p) = 0 end if - if(leafn(p) > 0._r8)then + if(leafn(p) > 0)then leafn_to_biofueln(p) = leafn(p) * matrix_update_gmn(p,ileaf_to_iout_gmn,leafn_to_biofueln(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) else - leafn_to_biofueln(p) = 0._r8 + leafn_to_biofueln(p) = 0 end if - if (leafc(p) > 0._r8)then + if (leafc(p) > 0)then leafc_to_biofuelc(p) = leafc(p) * matrix_update_gmc(p,ileaf_to_iout_gmc,leafc_to_biofuelc(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) else - leafc_to_biofuelc(p) = 0._r8 + leafc_to_biofuelc(p) = 0 end if - if(livestemc(p) > 0._r8)then + if(livestemc(p) .gt. 0)then livestemc_to_biofuelc(p) = livestemc(p) * matrix_update_gmc(p,ilivestem_to_iout_gmc,livestemc_to_biofuelc(p) / livestemc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) else - livestemc_to_biofuelc(p) = 0._r8 + livestemc_to_biofuelc(p) = 0 end if else - ! Cut a certain fraction (i.e., biofuel_harvfrac(ivt(p))) (e.g., biofuel_harvfrac(ivt(p)=70% for bioenergy crops) of leaf C - ! and move this fration of leaf C to biofuel C, rather than move it to litter - leafc_to_biofuelc(p) = t1 * leafc(p) * biofuel_harvfrac(ivt(p)) - leafn_to_biofueln(p) = t1 * leafn(p) * biofuel_harvfrac(ivt(p)) - - ! Cut a certain fraction (i.e., biofuel_harvfrac(ivt(p))) (e.g., biofuel_harvfrac(ivt(p)=70% for bioenergy crops) of livestem C - ! and move this fration of leaf C to biofuel C, rather than move it to litter - livestemc_to_litter(p) = t1 * livestemc(p)*(1._r8-biofuel_harvfrac(ivt(p))) + cpool_to_livestemc(p) - livestemc_to_biofuelc(p) = t1 * livestemc(p) * biofuel_harvfrac(ivt(p)) - livestemn_to_biofueln(p) = t1 * livestemn(p) * biofuel_harvfrac(ivt(p)) + ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) + ! and CNNStateUpdate1::NStateUpdate1 end if ! use_matrixcn end if else - ! Matrix for leafc and frootc to litter + t1 = dt * 2.0_r8 / (offset_counter(p) * offset_counter(p)) + leafc_to_litter(p) = prev_leafc_to_litter(p) + t1*(leafc(p) - prev_leafc_to_litter(p)*offset_counter(p)) + frootc_to_litter(p) = prev_frootc_to_litter(p) + t1*(frootc(p) - prev_frootc_to_litter(p)*offset_counter(p)) + if (use_matrixcn) then - if(leafc(p) > 0._r8)then + if(leafc(p) .gt. 0)then leafc_to_litter(p) = leafc(p) * matrix_update_phc(p,ileaf_to_iout_phc,leafc_to_litter(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - leafc_to_litter(p) = 0._r8 + leafc_to_litter(p) = 0 end if - if(frootc(p) > 0._r8)then + if(frootc(p) .gt. 0)then frootc_to_litter(p) = frootc(p) * matrix_update_phc(p,ifroot_to_iout_phc,frootc_to_litter(p) / frootc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - frootc_to_litter(p) = 0._r8 + frootc_to_litter(p) = 0 end if else - t1 = dt * 2.0_r8 / (offset_counter(p) * offset_counter(p)) - leafc_to_litter(p) = prev_leafc_to_litter(p) + t1*(leafc(p) - prev_leafc_to_litter(p)*offset_counter(p)) - frootc_to_litter(p) = prev_frootc_to_litter(p) + t1*(frootc(p) - prev_frootc_to_litter(p)*offset_counter(p)) + ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) + ! and CNNStateUpdate1::NStateUpdate1 end if !use_matrixcn end if if ( use_fun ) then if(leafc_to_litter(p)*dt.gt.leafc(p))then - ! Matrix for leafc to litter - if (use_matrixcn) then - if(leafc(p) > 0._r8)then + leafc_to_litter(p) = leafc(p)/dt + cpool_to_leafc(p) + if (use_matrixcn) then + if(leafc(p) .gt. 0)then leafc_to_litter(p) = leafc(p) * matrix_update_phc(p,ileaf_to_iout_phc,leafc_to_litter(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - leafc_to_litter(p) = 0._r8 + leafc_to_litter(p) = 0 end if - else - leafc_to_litter(p) = leafc(p)/dt + cpool_to_leafc(p) - end if !use_matrixcn + else + ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) + end if !use_matrixcn endif if(frootc_to_litter(p)*dt.gt.frootc(p))then - ! Matrix update for frootc to litter + frootc_to_litter(p) = frootc(p)/dt + cpool_to_frootc(p) if (use_matrixcn) then - if(frootc(p) > 0._r8)then + if(frootc(p) .gt. 0)then frootc_to_litter(p) = frootc(p) * matrix_update_phc(p,ifroot_to_iout_phc,frootc_to_litter(p) / frootc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - frootc_to_litter(p) = 0._r8 + frootc_to_litter(p) = 0 end if else - frootc_to_litter(p) = frootc(p)/dt + cpool_to_frootc(p) + ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) end if !use_matrixcn endif end if @@ -3279,8 +3284,8 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & if ( use_fun ) then leafc_to_litter_fun(p) = leafc_to_litter(p) leafn_to_retransn(p) = paid_retransn_to_npool(p) + free_retransn_to_npool(p) - if (leafn(p) > 0._r8) then - if (leafn(p)-leafn_to_retransn(p)*dt > 0._r8) then + if (leafn(p).gt.0._r8) then + if (leafn(p)-leafn_to_retransn(p)*dt.gt.0._r8) then leafcn_offset(p) = leafc(p)/(leafn(p)-leafn_to_retransn(p)*dt) else leafcn_offset(p) = leafc(p)/leafn(p) @@ -3290,15 +3295,13 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & end if leafn_to_litter(p) = leafc_to_litter(p)/leafcn_offset(p) - leafn_to_retransn(p) leafn_to_litter(p) = max(leafn_to_litter(p),0._r8) - - ! Matrix update for leafn to litter and retrans if (use_matrixcn) then - if(leafn(p) > 0._r8)then + if(leafn(p) .gt. 0)then leafn_to_litter(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iout_phn,leafn_to_litter(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) leafn_to_retransn(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iretransn_phn,leafn_to_retransn(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - leafn_to_litter(p) = 0._r8 - leafn_to_retransn(p) = 0._r8 + leafn_to_litter(p) = 0 + leafn_to_retransn(p) = 0 end if else ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) @@ -3315,21 +3318,20 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & end if else - if (CNratio_floating) then + if (CNratio_floating .eqv. .true.) then fr_leafn_to_litter = 0.5_r8 ! assuming 50% of nitrogen turnover goes to litter end if ! calculate the leaf N litterfall and retranslocation leafn_to_litter(p) = leafc_to_litter(p) / lflitcn(ivt(p)) leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn(ivt(p))) - leafn_to_litter(p) - ! Matrix update for leafn to litter and retrans if (use_matrixcn) then - if(leafn(p) > 0._r8)then + if(leafn(p) .gt. 0)then leafn_to_litter(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iout_phn,leafn_to_litter(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) leafn_to_retransn(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iretransn_phn,leafn_to_retransn(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - leafn_to_litter(p) = 0._r8 - leafn_to_retransn(p) = 0._r8 + leafn_to_litter(p) = 0 + leafn_to_retransn(p) = 0 end if else ! NOTE: The non matrix version of this is in CNNStateUpdate1::NStateUpdate1 EBK (11/26/2019) @@ -3338,49 +3340,44 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & ! calculate fine root N litterfall (no retranslocation of fine root N) frootn_to_litter(p) = frootc_to_litter(p) / frootcn(ivt(p)) - - ! Matrix update for frootn to litter if (use_matrixcn) then - if(frootn(p) > 0._r8)then + if(frootn(p) .gt. 0)then frootn_to_litter(p) = frootn(p) * matrix_update_phn(p,ifroot_to_iout_phn,frootn_to_litter(p) / frootn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - frootn_to_litter(p) = 0._r8 + frootn_to_litter(p) = 0 end if else ! NOTE: The non matrix version of this is in CNNStateUpdate1::NStateUpdate1 EBK (11/26/2019) end if !use_matrixcn - if (CNratio_floating) then - if (.not. use_matrixcn) then - if (leafc(p) == 0.0_r8) then - ntovr_leaf = 0.0_r8 - else - ntovr_leaf = leafc_to_litter(p) * (leafn(p) / leafc(p)) - end if + if (CNratio_floating .eqv. .true.) then + if (leafc(p) == 0.0_r8) then + ntovr_leaf = 0.0_r8 + else + ntovr_leaf = leafc_to_litter(p) * (leafn(p) / leafc(p)) + end if - leafn_to_litter(p) = fr_leafn_to_litter * ntovr_leaf - leafn_to_retransn(p) = ntovr_leaf - leafn_to_litter(p) - else ! Matrix update for leafn to litter and retrans - if(leafn(p) > 0._r8)then + leafn_to_litter(p) = fr_leafn_to_litter * ntovr_leaf + leafn_to_retransn(p) = ntovr_leaf - leafn_to_litter(p) + if (use_matrixcn) then + if(leafn(p) .gt. 0)then leafn_to_litter(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iout_phn,leafn_to_litter(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) leafn_to_retransn(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iretransn_phn,leafn_to_retransn(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - leafn_to_litter(p) = 0._r8 - leafn_to_retransn(p) = 0._r8 + leafn_to_litter(p) = 0 + leafn_to_retransn(p) = 0 end if - end if ! .not. use_matrixcn + end if !use_matrixcn if (frootc(p) == 0.0_r8) then frootn_to_litter(p) = 0.0_r8 - else + else frootn_to_litter(p) = frootc_to_litter(p) * (frootn(p) / frootc(p)) - end if - - ! Matrix update for frootn to litter + end if if (use_matrixcn) then - if(frootn(p) > 0._r8)then + if(frootn(p) .gt. 0)then frootn_to_litter(p) = frootn(p) * matrix_update_phn(p,ifroot_to_iout_phn,frootn_to_litter(p) / frootn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - frootn_to_litter(p) = 0._r8 + frootn_to_litter(p) = 0 end if else ! NOTE: The non matrix version of this is in CNNStateUpdate1::NStateUpdate1 EBK (11/26/2019) @@ -3389,26 +3386,21 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & if ( use_fun ) then if(frootn_to_litter(p)*dt.gt.frootn(p))then - - ! Send all frootn to litter if (.not. use_matrixcn) then frootn_to_litter(p) = frootn(p)/dt else - ! Matrix update for frootn to litter frootn_to_litter(p) = frootn(p) * matrix_update_phn(p,ifroot_to_iout_phn,1._r8/dt,dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) end if endif end if if (ivt(p) >= npcropmin) then - ! Matrix update for livestemn to litter + ! NOTE(slevis, 2014-12) results in -ve livestemn and -ve totpftn + !X! livestemn_to_litter(p) = livestemc_to_litter(p) / livewdcn(ivt(p)) + ! NOTE(slevis, 2014-12) Beth Drewniak suggested this instead + livestemn_to_litter(p) = livestemn(p) / dt * (1._r8 - biofuel_harvfrac(ivt(p))) if(use_matrixcn)then livestemn_to_litter(p) = livestemn(p) * matrix_update_phn(p,ilivestem_to_iout_phn, (1._r8- biofuel_harvfrac(ivt(p)))/dt, dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) - else - ! NOTE(slevis, 2014-12) results in -ve livestemn and -ve totpftn - !X! livestemn_to_litter(p) = livestemc_to_litter(p) / livewdcn(ivt(p)) - ! NOTE(slevis, 2014-12) Beth Drewniak suggested this instead - livestemn_to_litter(p) = livestemn(p) / dt * (1._r8 - biofuel_harvfrac(ivt(p))) end if end if @@ -3477,7 +3469,7 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & leafc_to_litter_fun => cnveg_carbonflux_inst%leafc_to_litter_fun_patch, & ! Output: [real(r8) (:) ] leaf C litterfall used by FUN (gC/m2/s) leafcn_offset => cnveg_state_inst%leafcn_offset_patch , & ! Output: [real(r8) (:) ] Leaf C:N used by FUN free_retransn_to_npool=> cnveg_nitrogenflux_inst%free_retransn_to_npool_patch , & ! Input: [real(r8) (:) ] free leaf N to retranslocated N pool (gN/m2/s) - paid_retransn_to_npool=> cnveg_nitrogenflux_inst%retransn_to_npool_patch , & ! Input: [real(r8) (:) ] free leaf N to retranslocated N pool (gN/m2/s) + paid_retransn_to_npool=> cnveg_nitrogenflux_inst%retransn_to_npool_patch , & ! Input: [real(r8) (:) ] free leaf N to retranslocated N pool (gN/m2/s) ileafst_to_ileafxf_phc => cnveg_carbonflux_inst%ileafst_to_ileafxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf storage pool to leaf transfer pool ileafxf_to_ileaf_phc => cnveg_carbonflux_inst%ileafxf_to_ileaf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf transfer pool to leaf pool @@ -3526,36 +3518,35 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & ! only calculate these fluxes if the background litterfall rate is non-zero if (bglfr(p) > 0._r8) then - ! Matrix update for leafc and frootc to litter + ! units for bglfr are already 1/s + leafc_to_litter(p) = bglfr(p) * leafc(p) + frootc_to_litter(p) = bglfr(p) * frootc(p) if (use_matrixcn) then leafc_to_litter(p) = leafc(p) * matrix_update_phc(p,ileaf_to_iout_phc,bglfr(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) frootc_to_litter(p) = frootc(p) * matrix_update_phc(p,ifroot_to_iout_phc,bglfr(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) - else - ! units for bglfr are already 1/s - leafc_to_litter(p) = bglfr(p) * leafc(p) - frootc_to_litter(p) = bglfr(p) * frootc(p) end if if ( use_fun ) then - if(.not. use_matrixcn)then - leafc_to_litter_fun(p) = leafc_to_litter(p) - leafn_to_retransn(p) = paid_retransn_to_npool(p) + free_retransn_to_npool(p) - if (leafn(p).gt.0._r8) then - if (leafn(p)-leafn_to_retransn(p)*dt.gt.0._r8) then - leafcn_offset(p) = leafc(p)/(leafn(p)-leafn_to_retransn(p)*dt) - else - leafcn_offset(p) = leafc(p)/leafn(p) - end if + leafc_to_litter_fun(p) = leafc_to_litter(p) + leafn_to_retransn(p) = paid_retransn_to_npool(p) + free_retransn_to_npool(p) + if (leafn(p).gt.0._r8) then + if (leafn(p)-leafn_to_retransn(p)*dt.gt.0._r8) then + leafcn_offset(p) = leafc(p)/(leafn(p)-leafn_to_retransn(p)*dt) else - leafcn_offset(p) = leafcn(ivt(p)) + leafcn_offset(p) = leafc(p)/leafn(p) end if - leafn_to_litter(p) = leafc_to_litter(p)/leafcn_offset(p) - leafn_to_retransn(p) - leafn_to_litter(p) = max(leafn_to_litter(p),0._r8) - else ! Matrix update for leafn to litter and retrans + else + leafcn_offset(p) = leafcn(ivt(p)) + end if + leafn_to_litter(p) = leafc_to_litter(p)/leafcn_offset(p) - leafn_to_retransn(p) + leafn_to_litter(p) = max(leafn_to_litter(p),0._r8) + if(use_matrixcn)then if(leafn(p) .ne. 0._r8)then leafn_to_litter(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iout_phn,leafn_to_litter(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) leafn_to_retransn(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iretransn_phn,leafn_to_retransn(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) end if - end if ! .not. use_matrixcn + else + ! NOTE: The non matrix version of this is in CNNStateUpdate1::NStateUpdate1 EBK (11/26/2019) + end if !use_matrixcn denom = ( leafn_to_retransn(p) + leafn_to_litter(p) ) if ( denom /= 0.0_r8 ) then @@ -3568,45 +3559,46 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & else - if (CNratio_floating) then + if (CNratio_floating .eqv. .true.) then fr_leafn_to_litter = 0.5_r8 ! assuming 50% of nitrogen turnover goes to litter end if - ! Matrix update for leafn to litter and retrans + ! calculate the leaf N litterfall and retranslocation + leafn_to_litter(p) = leafc_to_litter(p) / lflitcn(ivt(p)) + leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn(ivt(p))) - leafn_to_litter(p) + if (use_matrixcn) then - if(leafn(p) .ne. 0._r8)then + if(leafn(p) .ne. 0)then leafn_to_litter(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iout_phn,leafn_to_litter(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) leafn_to_retransn(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iretransn_phn,leafn_to_retransn(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) end if else ! NOTE: The non matrix version of this is in CNNStateUpdate1::NStateUpdate1 EBK (11/26/2019) - ! calculate the leaf N litterfall and retranslocation - leafn_to_litter(p) = leafc_to_litter(p) / lflitcn(ivt(p)) - leafn_to_retransn(p) = (leafc_to_litter(p) / leafcn(ivt(p))) - leafn_to_litter(p) end if !use_matrixcn end if ! calculate fine root N litterfall (no retranslocation of fine root N) frootn_to_litter(p) = frootc_to_litter(p) / frootcn(ivt(p)) - if (CNratio_floating) then - if (.not. use_matrixcn) then - if (leafc(p) == 0.0_r8) then - ntovr_leaf = 0.0_r8 - else - ntovr_leaf = leafc_to_litter(p) * (leafn(p) / leafc(p)) - end if + if (CNratio_floating .eqv. .true.) then + if (leafc(p) == 0.0_r8) then + ntovr_leaf = 0.0_r8 + else + ntovr_leaf = leafc_to_litter(p) * (leafn(p) / leafc(p)) + end if - leafn_to_litter(p) = fr_leafn_to_litter * ntovr_leaf - leafn_to_retransn(p) = ntovr_leaf - leafn_to_litter(p) - else ! Matrix update for leafn to litter and retrans - if(leafn(p) > 0._r8)then + leafn_to_litter(p) = fr_leafn_to_litter * ntovr_leaf + leafn_to_retransn(p) = ntovr_leaf - leafn_to_litter(p) + if (use_matrixcn) then + if(leafn(p) .gt. 0)then leafn_to_litter(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iout_phn,leafn_to_litter(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) leafn_to_retransn(p) = leafn(p) * matrix_update_phn(p,ileaf_to_iretransn_phn,leafn_to_retransn(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - leafn_to_litter(p) = 0._r8 - leafn_to_retransn(p) = 0._r8 + leafn_to_litter(p) = 0 + leafn_to_retransn(p) = 0 end if - end if ! .not. use_matrixcn + else + ! NOTE: The non matrix version of this is in CNNStateUpdate1::NStateUpdate1 EBK (11/26/2019) + end if !use_matrixcn if (frootc(p) == 0.0_r8) then frootn_to_litter(p) = 0.0_r8 else @@ -3620,9 +3612,8 @@ subroutine CNBackgroundLitterfall (num_soilp, filter_soilp, & endif end if - ! Matrix update for frootn to litter if (use_matrixcn) then - if(frootn(p) /= 0._r8)then + if(frootn(p) .ne. 0)then frootn_to_litter(p) = frootn(p) * matrix_update_phn(p,ifroot_to_iout_phn,frootn_to_litter(p) / frootn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) end if else @@ -3682,7 +3673,7 @@ subroutine CNLivewoodTurnover (num_soilp, filter_soilp, & livestemn_to_retransn => cnveg_nitrogenflux_inst%livestemn_to_retransn_patch , & ! Output: [real(r8) (:) ] livecrootn_to_deadcrootn => cnveg_nitrogenflux_inst%livecrootn_to_deadcrootn_patch , & ! Output: [real(r8) (:) ] livecrootn_to_retransn => cnveg_nitrogenflux_inst%livecrootn_to_retransn_patch , & ! Output: [real(r8) (:) ] - free_retransn_to_npool => cnveg_nitrogenflux_inst%free_retransn_to_npool_patch , & ! Input: [real(r8) (:) ] free leaf N to retranslocated N pool (gN/m2/s) + free_retransn_to_npool => cnveg_nitrogenflux_inst%free_retransn_to_npool_patch , & ! Input: [real(r8) (:) ] free leaf N to retranslocated N pool (gN/m2/s) ileafst_to_ileafxf_phc => cnveg_carbonflux_inst%ileafst_to_ileafxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf storage pool to leaf transfer pool ileafxf_to_ileaf_phc => cnveg_carbonflux_inst%ileafxf_to_ileaf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from leaf transfer pool to leaf pool ifrootst_to_ifrootxf_phc => cnveg_carbonflux_inst%ifrootst_to_ifrootxf_ph , & ! Input: [integer (:)] Index of phenology related C transfer from fine root storage pool to fine root transfer pool @@ -3736,38 +3727,40 @@ subroutine CNLivewoodTurnover (num_soilp, filter_soilp, & ! live stem to dead stem turnover - ! Matrix update for livestemc to deadstem + ctovr = livestemc(p) * lwtop + ntovr = ctovr / livewdcn(ivt(p)) + livestemc_to_deadstemc(p) = ctovr + livestemn_to_deadstemn(p) = ctovr / deadwdcn(ivt(p)) if( use_matrixcn)then livestemc_to_deadstemc(p) = livestemc(p) * matrix_update_phc(p,ilivestem_to_ideadstem_phc,lwtop,dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) if (livestemn(p) .gt. 0.0_r8) then livestemn_to_deadstemn(p) = livestemn(p) * matrix_update_phn(p,ilivestem_to_ideadstem_phn,livestemn_to_deadstemn(p)/livestemn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - livestemn_to_deadstemn(p) = 0._r8 + livestemn_to_deadstemn(p) = 0 end if else ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) ! and CNNStateUpdate1::NStateUpdate1 - ctovr = livestemc(p) * lwtop - ntovr = ctovr / livewdcn(ivt(p)) - livestemc_to_deadstemc(p) = ctovr - livestemn_to_deadstemn(p) = ctovr / deadwdcn(ivt(p)) end if - if (CNratio_floating) then + if (CNratio_floating .eqv. .true.) then if (livestemc(p) == 0.0_r8) then ntovr = 0.0_r8 livestemn_to_deadstemn(p) = 0.0_r8 - else + else ntovr = ctovr * (livestemn(p) / livestemc(p)) livestemn_to_deadstemn(p) = ctovr / deadwdcn(ivt(p)) - end if - if (use_matrixcn)then ! Matrix update for livestemn to deadstem + end if + + if (use_matrixcn)then if (livestemn(p) .gt. 0.0_r8) then livestemn_to_deadstemn(p) = livestemn(p) * matrix_update_phn(p,ilivestem_to_ideadstem_phn,& livestemn_to_deadstemn(p) / livestemn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else livestemn_to_deadstemn(p) = 0 end if - end if ! use_matrixcn + else + ! NOTE: The non matrix version of this is in CNNStateUpdate1::NStateUpdate1 EBK (11/26/2019) + end if end if livestemn_to_retransn(p) = ntovr - livestemn_to_deadstemn(p) @@ -3777,19 +3770,17 @@ subroutine CNLivewoodTurnover (num_soilp, filter_soilp, & ctovr = livecrootc(p) * lwtop ntovr = ctovr / livewdcn(ivt(p)) - if(.not. use_matrixcn)then ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) ! and CNNStateUpdate1::NStateUpdate1 livecrootc_to_deadcrootc(p) = ctovr livecrootn_to_deadcrootn(p) = ctovr / deadwdcn(ivt(p)) else - ! Matrix update for livecroot to deadcroot livecrootc_to_deadcrootc(p) = livecrootc(p) * matrix_update_phc(p,ilivecroot_to_ideadcroot_phc,lwtop,dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) livecrootn_to_deadcrootn(p) = livecrootn(p) * matrix_update_phn(p,ilivecroot_to_ideadcroot_phn,lwtop/deadwdcn(ivt(p)),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) end if !use_matrixcn - if (CNratio_floating) then + if (CNratio_floating .eqv. .true.) then if (livecrootc(p) == 0.0_r8) then ntovr = 0.0_r8 livecrootn_to_deadcrootn(p) = 0.0_r8 @@ -3797,50 +3788,49 @@ subroutine CNLivewoodTurnover (num_soilp, filter_soilp, & ntovr = ctovr * (livecrootn(p) / livecrootc(p)) livecrootn_to_deadcrootn(p) = ctovr / deadwdcn(ivt(p)) end if - if (use_matrixcn)then ! Matrix update for livecroot to deadcroot + + if (use_matrixcn)then if (livecrootn(p) .ne.0.0_r8 )then livecrootn_to_deadcrootn(p) = matrix_update_phn(p,ilivecroot_to_ideadcroot_phn,& livecrootn_to_deadcrootn(p) / livecrootn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) * livecrootn(p) end if - end if ! use_matrixcn + else + ! NOTE: The non matrix version of this is in CNNStateUpdate1::NStateUpdate1 EBK (11/26/2019) + end if !use_matrixcn end if livecrootn_to_retransn(p) = ntovr - livecrootn_to_deadcrootn(p) - - ! Matrix update for livecrootn and livestemn to retrans as well as free retransn to npool with FUN - if(use_matrixcn)then - if(livecrootn(p) .gt. 0.0_r8) then - livecrootn_to_retransn(p) = matrix_update_phn(p,ilivecroot_to_iretransn_phn,& - livecrootn_to_retransn(p) / livecrootn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) * livecrootn(p) - else - livecrootn_to_retransn(p) = 0 - end if - if(livestemn(p) .gt. 0.0_r8) then - livestemn_to_retransn(p) = matrix_update_phn(p,ilivestem_to_iretransn_phn,& - livestemn_to_retransn(p) / livestemn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) * livestemn(p) - else - livestemn_to_retransn(p) = 0 - end if - ! WW change logic so livestem_retrans goes to npool (via - ! free_retrans flux) - ! this should likely be done more cleanly if it works, i.e. not - ! update fluxes w/ states - ! additional considerations for crop? - ! The non-matrix version of this is in NStateUpdate1 - if (use_fun) then - if (retransn(p) .gt. 0._r8) then - ! The acc matrix check MUST be turned on, or this will - ! fail with Nitrogen balance error EBK 03/11/2021 - free_retransn_to_npool(p) = free_retransn_to_npool(p) + retransn(p) * matrix_update_phn(p,iretransn_to_iout, & - (livestemn_to_retransn(p) + livecrootn_to_retransn(p)) / retransn(p),dt, & - cnveg_nitrogenflux_inst, matrixcheck_ph, acc=.true.) + if(use_matrixcn)then + if(livecrootn(p) .gt. 0.0_r8) then + livecrootn_to_retransn(p) = matrix_update_phn(p,ilivecroot_to_iretransn_phn,& + livecrootn_to_retransn(p) / livecrootn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) * livecrootn(p) else - free_retransn_to_npool(p) = 0._r8 + livecrootn_to_retransn(p) = 0 end if - end if - else - ! The non-matrix version of this is in NStateUpdate1 - end if !use_matrixcn + if(livestemn(p) .gt. 0.0_r8) then + livestemn_to_retransn(p) = matrix_update_phn(p,ilivestem_to_iretransn_phn,& + livestemn_to_retransn(p) / livestemn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) * livestemn(p) + else + livestemn_to_retransn(p) = 0 + end if + ! WW change logic so livestem_retrans goes to npool (via + ! free_retrans flux) + ! this should likely be done more cleanly if it works, i.e. not + ! update fluxes w/ states + ! additional considerations for crop? + ! The non-matrix version of this is in NStateUpdate1 + if (use_fun) then + if (retransn(p) .gt. 0._r8) then + ! The acc matrix check MUST be turned on, or this will + ! fail with Nitrogen balance error EBK 03/11/2021 + free_retransn_to_npool(p) = free_retransn_to_npool(p) + retransn(p) * matrix_update_phn(p,iretransn_to_iout, & + (livestemn_to_retransn(p) + livecrootn_to_retransn(p)) / retransn(p),dt, & + cnveg_nitrogenflux_inst, matrixcheck_ph, acc=.true.) + else + free_retransn_to_npool(p) = 0._r8 + end if + end if + end if !use_matrixcn end if diff --git a/src/soilbiogeochem/SoilBiogeochemNStateUpdate1Mod.F90 b/src/soilbiogeochem/SoilBiogeochemNStateUpdate1Mod.F90 index d7b3c01fc1..4f221c6910 100644 --- a/src/soilbiogeochem/SoilBiogeochemNStateUpdate1Mod.F90 +++ b/src/soilbiogeochem/SoilBiogeochemNStateUpdate1Mod.F90 @@ -9,11 +9,12 @@ module SoilBiogeochemNStateUpdate1Mod use clm_time_manager , only : get_step_size_real use clm_varpar , only : nlevdecomp, ndecomp_cascade_transitions use clm_varctl , only : iulog, use_nitrif_denitrif, use_crop + use SoilBiogeochemDecompCascadeConType , only : use_soil_matrixcn use clm_varcon , only : nitrif_n2o_loss_frac use SoilBiogeochemStateType , only : soilbiogeochem_state_type use SoilBiogeochemNitrogenStateType , only : soilbiogeochem_nitrogenstate_type use SoilBiogeochemNitrogenfluxType , only : soilbiogeochem_nitrogenflux_type - use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con, use_soil_matrixcn + use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con use CNSharedParamsMod , only : use_fun use ColumnType , only : col ! @@ -118,50 +119,47 @@ subroutine SoilBiogeochemNStateUpdate1(num_soilc, filter_soilc, & end if ! decomposition fluxes - if (.not. use_soil_matrixcn) then - do k = 1, ndecomp_cascade_transitions + if (.not. use_soil_matrixcn) then + do k = 1, ndecomp_cascade_transitions + do j = 1, nlevdecomp + ! column loop + do fc = 1,num_soilc + c = filter_soilc(fc) + + nf%decomp_npools_sourcesink_col(c,j,cascade_donor_pool(k)) = & + nf%decomp_npools_sourcesink_col(c,j,cascade_donor_pool(k)) - & + nf%decomp_cascade_ntransfer_vr_col(c,j,k) * dt + end do + end do + end do + + + do k = 1, ndecomp_cascade_transitions + if ( cascade_receiver_pool(k) /= 0 ) then ! skip terminal transitions do j = 1, nlevdecomp ! column loop do fc = 1,num_soilc c = filter_soilc(fc) + nf%decomp_npools_sourcesink_col(c,j,cascade_receiver_pool(k)) = & + nf%decomp_npools_sourcesink_col(c,j,cascade_receiver_pool(k)) + & + (nf%decomp_cascade_ntransfer_vr_col(c,j,k) + & + nf%decomp_cascade_sminn_flux_vr_col(c,j,k)) * dt + end do + end do + else ! terminal transitions + do j = 1, nlevdecomp + ! column loop + do fc = 1,num_soilc + c = filter_soilc(fc) nf%decomp_npools_sourcesink_col(c,j,cascade_donor_pool(k)) = & nf%decomp_npools_sourcesink_col(c,j,cascade_donor_pool(k)) - & - nf%decomp_cascade_ntransfer_vr_col(c,j,k) * dt + nf%decomp_cascade_sminn_flux_vr_col(c,j,k) * dt end do end do - end do - - - do k = 1, ndecomp_cascade_transitions - if ( cascade_receiver_pool(k) /= 0 ) then ! skip terminal transitions - do j = 1, nlevdecomp - ! column loop - do fc = 1,num_soilc - c = filter_soilc(fc) - - nf%decomp_npools_sourcesink_col(c,j,cascade_receiver_pool(k)) = & - nf%decomp_npools_sourcesink_col(c,j,cascade_receiver_pool(k)) + & - (nf%decomp_cascade_ntransfer_vr_col(c,j,k) + & - nf%decomp_cascade_sminn_flux_vr_col(c,j,k)) * dt - end do - end do - else ! terminal transitions - do j = 1, nlevdecomp - ! column loop - do fc = 1,num_soilc - c = filter_soilc(fc) - nf%decomp_npools_sourcesink_col(c,j,cascade_donor_pool(k)) = & - nf%decomp_npools_sourcesink_col(c,j,cascade_donor_pool(k)) - & - nf%decomp_cascade_sminn_flux_vr_col(c,j,k) * dt - end do - end do - end if - end do - else - ! Matrix solution equvalent to above is in CNSoilMatrixMod.F90? - ! TODO check on this - end if ! + end if + end do + end if ! if (.not. use_nitrif_denitrif) then From 42af57b7f6584610e5127874f55044fe16da2ccb Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 28 Dec 2023 13:18:15 -0700 Subject: [PATCH 009/194] Matrixcn updates pertaining to GULU (gross unrep. landuse chg) --- src/biogeochem/CNBalanceCheckMod.F90 | 1 - src/biogeochem/CNCStateUpdate2Mod.F90 | 132 ++++++++++------- src/biogeochem/CNNStateUpdate2Mod.F90 | 129 +++++++++------- src/biogeochem/dynGrossUnrepMod.F90 | 205 +++++++++++++++++++------- src/dyn_subgrid/dynHarvestMod.F90 | 19 +-- 5 files changed, 313 insertions(+), 173 deletions(-) diff --git a/src/biogeochem/CNBalanceCheckMod.F90 b/src/biogeochem/CNBalanceCheckMod.F90 index fbf30e9549..5b253fdd00 100644 --- a/src/biogeochem/CNBalanceCheckMod.F90 +++ b/src/biogeochem/CNBalanceCheckMod.F90 @@ -60,7 +60,6 @@ module CNBalanceCheckMod !----------------------------------------------------------------------- subroutine Init(this, bounds) - use CNSharedParamsMod, only : use_matrixcn class(cn_balance_type) :: this type(bounds_type) , intent(in) :: bounds diff --git a/src/biogeochem/CNCStateUpdate2Mod.F90 b/src/biogeochem/CNCStateUpdate2Mod.F90 index 76fcc340b6..2890c7d1fd 100644 --- a/src/biogeochem/CNCStateUpdate2Mod.F90 +++ b/src/biogeochem/CNCStateUpdate2Mod.F90 @@ -370,15 +370,27 @@ subroutine CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & do fc = 1,num_soilc c = filter_soilc(fc) - ! column gross unrepresented landcover change fluxes - do i = i_litr_min, i_litr_max - cs_soil%decomp_cpools_vr_col(c,j,i) = & - cs_soil%decomp_cpools_vr_col(c,j,i) + cf_veg%gru_c_to_litr_c_col(c,j,i) * dt - end do - cs_soil%decomp_cpools_vr_col(c,j,i_cwd) = & - cs_soil%decomp_cpools_vr_col(c,j,i_cwd) + cf_veg%gru_c_to_cwdc_col(c,j) * dt + if (.not. use_soil_matrixcn)then + ! column gross unrepresented landcover change fluxes + do i = i_litr_min, i_litr_max + cs_soil%decomp_cpools_vr_col(c,j,i) = & + cs_soil%decomp_cpools_vr_col(c,j,i) + cf_veg%gru_c_to_litr_c_col(c,j,i) * dt + end do + cs_soil%decomp_cpools_vr_col(c,j,i_cwd) = & + cs_soil%decomp_cpools_vr_col(c,j,i_cwd) + cf_veg%gru_c_to_cwdc_col(c,j) * dt - ! wood to product pools - states updated in CNProducts + ! wood to product pools - states updated in CNProducts + else + ! Match above for soil-matrix + do i = i_litr_min, i_litr_max + cf_soil%matrix_Cinput%V(c,j+(i-1)*nlevdecomp) = & + cf_soil%matrix_Cinput%V(c,j+(i-1)*nlevdecomp) + cf_veg%gru_c_to_litr_c_col(c,j,i) * dt + end do + ! Currently i_cwd .ne. i_litr_max + 1 if .not. fates and + ! i_cwd = 0 if fates, so not including in the i-loop + cf_soil%matrix_Cinput%V(c,j+(i_cwd-1)*nlevdecomp) = & + cf_soil%matrix_Cinput%V(c,j+(i_cwd-1)*nlevdecomp) + cf_veg%gru_c_to_cwdc_col(c,j) * dt + end if !soil_matrix end do end do @@ -387,58 +399,66 @@ subroutine CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & p = filter_soilp(fp) ! patch-level carbon fluxes from gross unrepresented landcover change mortality - ! displayed pools - cs_veg%leafc_patch(p) = cs_veg%leafc_patch(p) & - - cf_veg%gru_leafc_to_litter_patch(p) * dt - cs_veg%frootc_patch(p) = cs_veg%frootc_patch(p) & - - cf_veg%gru_frootc_to_litter_patch(p) * dt - cs_veg%livestemc_patch(p) = cs_veg%livestemc_patch(p) & - - cf_veg%gru_livestemc_to_atm_patch(p) * dt - cs_veg%deadstemc_patch(p) = cs_veg%deadstemc_patch(p) & - - cf_veg%gru_deadstemc_to_atm_patch(p) * dt - cs_veg%deadstemc_patch(p) = cs_veg%deadstemc_patch(p) & - - cf_veg%gru_wood_productc_gain_patch(p) * dt - cs_veg%livecrootc_patch(p) = cs_veg%livecrootc_patch(p) & - - cf_veg%gru_livecrootc_to_litter_patch(p) * dt - cs_veg%deadcrootc_patch(p) = cs_veg%deadcrootc_patch(p) & - - cf_veg%gru_deadcrootc_to_litter_patch(p) * dt + ! + ! State update without the matrix solution + ! + if(.not. use_matrixcn)then + ! displayed pools + cs_veg%leafc_patch(p) = cs_veg%leafc_patch(p) & + - cf_veg%gru_leafc_to_litter_patch(p) * dt + cs_veg%frootc_patch(p) = cs_veg%frootc_patch(p) & + - cf_veg%gru_frootc_to_litter_patch(p) * dt + cs_veg%livestemc_patch(p) = cs_veg%livestemc_patch(p) & + - cf_veg%gru_livestemc_to_atm_patch(p) * dt + cs_veg%deadstemc_patch(p) = cs_veg%deadstemc_patch(p) & + - cf_veg%gru_deadstemc_to_atm_patch(p) * dt + cs_veg%deadstemc_patch(p) = cs_veg%deadstemc_patch(p) & + - cf_veg%gru_wood_productc_gain_patch(p) * dt + cs_veg%livecrootc_patch(p) = cs_veg%livecrootc_patch(p) & + - cf_veg%gru_livecrootc_to_litter_patch(p) * dt + cs_veg%deadcrootc_patch(p) = cs_veg%deadcrootc_patch(p) & + - cf_veg%gru_deadcrootc_to_litter_patch(p) * dt - ! xsmrpool - cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) & - - cf_veg%gru_xsmrpool_to_atm_patch(p) * dt + ! xsmrpool + cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) & + - cf_veg%gru_xsmrpool_to_atm_patch(p) * dt - ! storage pools - cs_veg%leafc_storage_patch(p) = cs_veg%leafc_storage_patch(p) & - - cf_veg%gru_leafc_storage_to_atm_patch(p) * dt - cs_veg%frootc_storage_patch(p) = cs_veg%frootc_storage_patch(p) & - - cf_veg%gru_frootc_storage_to_atm_patch(p) * dt - cs_veg%livestemc_storage_patch(p) = cs_veg%livestemc_storage_patch(p) & - - cf_veg%gru_livestemc_storage_to_atm_patch(p) * dt - cs_veg%deadstemc_storage_patch(p) = cs_veg%deadstemc_storage_patch(p) & - - cf_veg%gru_deadstemc_storage_to_atm_patch(p) * dt - cs_veg%livecrootc_storage_patch(p) = cs_veg%livecrootc_storage_patch(p) & - - cf_veg%gru_livecrootc_storage_to_atm_patch(p) * dt - cs_veg%deadcrootc_storage_patch(p) = cs_veg%deadcrootc_storage_patch(p) & - - cf_veg%gru_deadcrootc_storage_to_atm_patch(p) * dt - cs_veg%gresp_storage_patch(p) = cs_veg%gresp_storage_patch(p) & - - cf_veg%gru_gresp_storage_to_atm_patch(p) * dt + ! storage pools + cs_veg%leafc_storage_patch(p) = cs_veg%leafc_storage_patch(p) & + - cf_veg%gru_leafc_storage_to_atm_patch(p) * dt + cs_veg%frootc_storage_patch(p) = cs_veg%frootc_storage_patch(p) & + - cf_veg%gru_frootc_storage_to_atm_patch(p) * dt + cs_veg%livestemc_storage_patch(p) = cs_veg%livestemc_storage_patch(p) & + - cf_veg%gru_livestemc_storage_to_atm_patch(p) * dt + cs_veg%deadstemc_storage_patch(p) = cs_veg%deadstemc_storage_patch(p) & + - cf_veg%gru_deadstemc_storage_to_atm_patch(p) * dt + cs_veg%livecrootc_storage_patch(p) = cs_veg%livecrootc_storage_patch(p) & + - cf_veg%gru_livecrootc_storage_to_atm_patch(p) * dt + cs_veg%deadcrootc_storage_patch(p) = cs_veg%deadcrootc_storage_patch(p) & + - cf_veg%gru_deadcrootc_storage_to_atm_patch(p) * dt + cs_veg%gresp_storage_patch(p) = cs_veg%gresp_storage_patch(p) & + - cf_veg%gru_gresp_storage_to_atm_patch(p) * dt - ! transfer pools - cs_veg%leafc_xfer_patch(p) = cs_veg%leafc_xfer_patch(p) & - - cf_veg%gru_leafc_xfer_to_atm_patch(p) * dt - cs_veg%frootc_xfer_patch(p) = cs_veg%frootc_xfer_patch(p) & - - cf_veg%gru_frootc_xfer_to_atm_patch(p) * dt - cs_veg%livestemc_xfer_patch(p) = cs_veg%livestemc_xfer_patch(p) & - - cf_veg%gru_livestemc_xfer_to_atm_patch(p) * dt - cs_veg%deadstemc_xfer_patch(p) = cs_veg%deadstemc_xfer_patch(p) & - - cf_veg%gru_deadstemc_xfer_to_atm_patch(p) * dt - cs_veg%livecrootc_xfer_patch(p) = cs_veg%livecrootc_xfer_patch(p) & - - cf_veg%gru_livecrootc_xfer_to_atm_patch(p) * dt - cs_veg%deadcrootc_xfer_patch(p) = cs_veg%deadcrootc_xfer_patch(p) & - - cf_veg%gru_deadcrootc_xfer_to_atm_patch(p) * dt - cs_veg%gresp_xfer_patch(p) = cs_veg%gresp_xfer_patch(p) & - - cf_veg%gru_gresp_xfer_to_atm_patch(p) * dt + ! transfer pools + cs_veg%leafc_xfer_patch(p) = cs_veg%leafc_xfer_patch(p) & + - cf_veg%gru_leafc_xfer_to_atm_patch(p) * dt + cs_veg%frootc_xfer_patch(p) = cs_veg%frootc_xfer_patch(p) & + - cf_veg%gru_frootc_xfer_to_atm_patch(p) * dt + cs_veg%livestemc_xfer_patch(p) = cs_veg%livestemc_xfer_patch(p) & + - cf_veg%gru_livestemc_xfer_to_atm_patch(p) * dt + cs_veg%deadstemc_xfer_patch(p) = cs_veg%deadstemc_xfer_patch(p) & + - cf_veg%gru_deadstemc_xfer_to_atm_patch(p) * dt + cs_veg%livecrootc_xfer_patch(p) = cs_veg%livecrootc_xfer_patch(p) & + - cf_veg%gru_livecrootc_xfer_to_atm_patch(p) * dt + cs_veg%deadcrootc_xfer_patch(p) = cs_veg%deadcrootc_xfer_patch(p) & + - cf_veg%gru_deadcrootc_xfer_to_atm_patch(p) * dt + cs_veg%gresp_xfer_patch(p) = cs_veg%gresp_xfer_patch(p) & + - cf_veg%gru_gresp_xfer_to_atm_patch(p) * dt + else + ! NB (slevis) The matrix equivalent of the above is in + ! dynGrossUnrepMod::CNGrossUnrep* + end if end do ! end of patch loop end associate diff --git a/src/biogeochem/CNNStateUpdate2Mod.F90 b/src/biogeochem/CNNStateUpdate2Mod.F90 index 2702b80de5..2dbba68b82 100644 --- a/src/biogeochem/CNNStateUpdate2Mod.F90 +++ b/src/biogeochem/CNNStateUpdate2Mod.F90 @@ -358,14 +358,29 @@ subroutine NStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & do j = 1,nlevdecomp do fc = 1,num_soilc c = filter_soilc(fc) - do i = i_litr_min, i_litr_max - ns_soil%decomp_npools_vr_col(c,j,i) = & - ns_soil%decomp_npools_vr_col(c,j,i) + nf_veg%gru_n_to_litr_n_col(c,j,i) * dt - end do - ! Currently i_cwd .ne. i_litr_max + 1 if .not. fates and - ! i_cwd = 0 if fates, so not including in the i-loop - ns_soil%decomp_npools_vr_col(c,j,i_cwd) = & - ns_soil%decomp_npools_vr_col(c,j,i_cwd) + nf_veg%gru_n_to_cwdn_col(c,j) * dt + ! + ! State update without the matrix solution + ! + if (.not. use_soil_matrixcn)then + do i = i_litr_min, i_litr_max + ns_soil%decomp_npools_vr_col(c,j,i) = & + ns_soil%decomp_npools_vr_col(c,j,i) + nf_veg%gru_n_to_litr_n_col(c,j,i) * dt + end do + ! Currently i_cwd .ne. i_litr_max + 1 if .not. fates and + ! i_cwd = 0 if fates, so not including in the i-loop + ns_soil%decomp_npools_vr_col(c,j,i_cwd) = & + ns_soil%decomp_npools_vr_col(c,j,i_cwd) + nf_veg%gru_n_to_cwdn_col(c,j) * dt + else + ! Do above for the matrix solution + do i = i_litr_min, i_litr_max + nf_soil%matrix_Ninput%V(c,j+(i-1)*nlevdecomp) = & + nf_soil%matrix_Ninput%V(c,j+(i-1)*nlevdecomp) + nf_veg%gru_n_to_litr_n_col(c,j,i) * dt + end do + ! Currently i_cwd .ne. i_litr_max + 1 if .not. fates and + ! i_cwd = 0 if fates, so not including in the i-loop + nf_soil%matrix_Ninput%V(c,j+(i_cwd-1)*nlevdecomp) = & + nf_soil%matrix_Ninput%V(c,j+(i_cwd-1)*nlevdecomp) + nf_veg%gru_n_to_cwdn_col(c,j) * dt + end if !not use_soil_matrixcn end do end do @@ -374,51 +389,59 @@ subroutine NStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & do fp = 1,num_soilp p = filter_soilp(fp) - ! displayed pools - ns_veg%leafn_patch(p) = ns_veg%leafn_patch(p) & - - nf_veg%gru_leafn_to_litter_patch(p) * dt - ns_veg%frootn_patch(p) = ns_veg%frootn_patch(p) & - - nf_veg%gru_frootn_to_litter_patch(p) * dt - ns_veg%livestemn_patch(p) = ns_veg%livestemn_patch(p) & - - nf_veg%gru_livestemn_to_atm_patch(p) * dt - ns_veg%deadstemn_patch(p) = ns_veg%deadstemn_patch(p) & - - nf_veg%gru_deadstemn_to_atm_patch(p) * dt - ns_veg%deadstemn_patch(p) = ns_veg%deadstemn_patch(p) & - - nf_veg%gru_wood_productn_gain_patch(p) * dt - ns_veg%livecrootn_patch(p) = ns_veg%livecrootn_patch(p) & - - nf_veg%gru_livecrootn_to_litter_patch(p) * dt - ns_veg%deadcrootn_patch(p) = ns_veg%deadcrootn_patch(p) & - - nf_veg%gru_deadcrootn_to_litter_patch(p) * dt - ns_veg%retransn_patch(p) = ns_veg%retransn_patch(p) & - - nf_veg%gru_retransn_to_litter_patch(p) * dt - - ! storage pools - ns_veg%leafn_storage_patch(p) = ns_veg%leafn_storage_patch(p) & - - nf_veg%gru_leafn_storage_to_atm_patch(p) * dt - ns_veg%frootn_storage_patch(p) = ns_veg%frootn_storage_patch(p) & - - nf_veg%gru_frootn_storage_to_atm_patch(p) * dt - ns_veg%livestemn_storage_patch(p) = ns_veg%livestemn_storage_patch(p) & - - nf_veg%gru_livestemn_storage_to_atm_patch(p) * dt - ns_veg%deadstemn_storage_patch(p) = ns_veg%deadstemn_storage_patch(p) & - - nf_veg%gru_deadstemn_storage_to_atm_patch(p) * dt - ns_veg%livecrootn_storage_patch(p) = ns_veg%livecrootn_storage_patch(p) & - - nf_veg%gru_livecrootn_storage_to_atm_patch(p) * dt - ns_veg%deadcrootn_storage_patch(p) = ns_veg%deadcrootn_storage_patch(p) & - - nf_veg%gru_deadcrootn_storage_to_atm_patch(p) * dt - - ! transfer pools - ns_veg%leafn_xfer_patch(p) = ns_veg%leafn_xfer_patch(p) & - - nf_veg%gru_leafn_xfer_to_atm_patch(p) *dt - ns_veg%frootn_xfer_patch(p) = ns_veg%frootn_xfer_patch(p) & - - nf_veg%gru_frootn_xfer_to_atm_patch(p) *dt - ns_veg%livestemn_xfer_patch(p) = ns_veg%livestemn_xfer_patch(p) & - - nf_veg%gru_livestemn_xfer_to_atm_patch(p) *dt - ns_veg%deadstemn_xfer_patch(p) = ns_veg%deadstemn_xfer_patch(p) & - - nf_veg%gru_deadstemn_xfer_to_atm_patch(p) *dt - ns_veg%livecrootn_xfer_patch(p) = ns_veg%livecrootn_xfer_patch(p) & - - nf_veg%gru_livecrootn_xfer_to_atm_patch(p) *dt - ns_veg%deadcrootn_xfer_patch(p) = ns_veg%deadcrootn_xfer_patch(p) & - - nf_veg%gru_deadcrootn_xfer_to_atm_patch(p) *dt + ! + ! State update without the matrix solution + ! + if(.not. use_matrixcn)then + ! displayed pools + ns_veg%leafn_patch(p) = ns_veg%leafn_patch(p) & + - nf_veg%gru_leafn_to_litter_patch(p) * dt + ns_veg%frootn_patch(p) = ns_veg%frootn_patch(p) & + - nf_veg%gru_frootn_to_litter_patch(p) * dt + ns_veg%livestemn_patch(p) = ns_veg%livestemn_patch(p) & + - nf_veg%gru_livestemn_to_atm_patch(p) * dt + ns_veg%deadstemn_patch(p) = ns_veg%deadstemn_patch(p) & + - nf_veg%gru_deadstemn_to_atm_patch(p) * dt + ns_veg%deadstemn_patch(p) = ns_veg%deadstemn_patch(p) & + - nf_veg%gru_wood_productn_gain_patch(p) * dt + ns_veg%livecrootn_patch(p) = ns_veg%livecrootn_patch(p) & + - nf_veg%gru_livecrootn_to_litter_patch(p) * dt + ns_veg%deadcrootn_patch(p) = ns_veg%deadcrootn_patch(p) & + - nf_veg%gru_deadcrootn_to_litter_patch(p) * dt + ns_veg%retransn_patch(p) = ns_veg%retransn_patch(p) & + - nf_veg%gru_retransn_to_litter_patch(p) * dt + + ! storage pools + ns_veg%leafn_storage_patch(p) = ns_veg%leafn_storage_patch(p) & + - nf_veg%gru_leafn_storage_to_atm_patch(p) * dt + ns_veg%frootn_storage_patch(p) = ns_veg%frootn_storage_patch(p) & + - nf_veg%gru_frootn_storage_to_atm_patch(p) * dt + ns_veg%livestemn_storage_patch(p) = ns_veg%livestemn_storage_patch(p) & + - nf_veg%gru_livestemn_storage_to_atm_patch(p) * dt + ns_veg%deadstemn_storage_patch(p) = ns_veg%deadstemn_storage_patch(p) & + - nf_veg%gru_deadstemn_storage_to_atm_patch(p) * dt + ns_veg%livecrootn_storage_patch(p) = ns_veg%livecrootn_storage_patch(p) & + - nf_veg%gru_livecrootn_storage_to_atm_patch(p) * dt + ns_veg%deadcrootn_storage_patch(p) = ns_veg%deadcrootn_storage_patch(p) & + - nf_veg%gru_deadcrootn_storage_to_atm_patch(p) * dt + + ! transfer pools + ns_veg%leafn_xfer_patch(p) = ns_veg%leafn_xfer_patch(p) & + - nf_veg%gru_leafn_xfer_to_atm_patch(p) *dt + ns_veg%frootn_xfer_patch(p) = ns_veg%frootn_xfer_patch(p) & + - nf_veg%gru_frootn_xfer_to_atm_patch(p) *dt + ns_veg%livestemn_xfer_patch(p) = ns_veg%livestemn_xfer_patch(p) & + - nf_veg%gru_livestemn_xfer_to_atm_patch(p) *dt + ns_veg%deadstemn_xfer_patch(p) = ns_veg%deadstemn_xfer_patch(p) & + - nf_veg%gru_deadstemn_xfer_to_atm_patch(p) *dt + ns_veg%livecrootn_xfer_patch(p) = ns_veg%livecrootn_xfer_patch(p) & + - nf_veg%gru_livecrootn_xfer_to_atm_patch(p) *dt + ns_veg%deadcrootn_xfer_patch(p) = ns_veg%deadcrootn_xfer_patch(p) & + - nf_veg%gru_deadcrootn_xfer_to_atm_patch(p) *dt + else + ! NB (slevis) The equivalent changes for matrix code are in + ! dynGrossUnrepMod::CNGrossUnrep* + end if !not use_matrixcn end do diff --git a/src/biogeochem/dynGrossUnrepMod.F90 b/src/biogeochem/dynGrossUnrepMod.F90 index bc49e72f4c..b354744b61 100644 --- a/src/biogeochem/dynGrossUnrepMod.F90 +++ b/src/biogeochem/dynGrossUnrepMod.F90 @@ -24,6 +24,7 @@ module dynGrossUnrepMod use clm_varpar , only : natpft_size, i_litr_min, i_litr_max, i_met_lit use ColumnType , only : col use PatchType , only : patch + use CNSharedParamsMod , only : use_matrixcn ! ! !PUBLIC MEMBER FUNCTIONS: implicit none @@ -296,61 +297,157 @@ subroutine CNGrossUnrep (num_soilc, filter_soilc, num_soilp, filter_soilp, & m = 0._r8 end if - ! patch-level gross unrepresented landcover change carbon fluxes - ! displayed pools - gru_leafc_to_litter(p) = leafc(p) * m - gru_frootc_to_litter(p) = frootc(p) * m - gru_livestemc_to_atm(p) = livestemc(p) * m - gru_deadstemc_to_atm(p) = deadstemc(p) * m * convfrac(ivt(p)) - gru_wood_productc_gain(p) = deadstemc(p) * m * (1._r8 - convfrac(ivt(p))) - gru_livecrootc_to_litter(p) = livecrootc(p) * m - gru_deadcrootc_to_litter(p) = deadcrootc(p) * m - gru_xsmrpool_to_atm(p) = xsmrpool(p) * m - - ! storage pools - gru_leafc_storage_to_atm(p) = leafc_storage(p) * m - gru_frootc_storage_to_atm(p) = frootc_storage(p) * m - gru_livestemc_storage_to_atm(p) = livestemc_storage(p) * m - gru_deadstemc_storage_to_atm(p) = deadstemc_storage(p) * m - gru_livecrootc_storage_to_atm(p) = livecrootc_storage(p) * m - gru_deadcrootc_storage_to_atm(p) = deadcrootc_storage(p) * m - gru_gresp_storage_to_atm(p) = gresp_storage(p) * m - - ! transfer pools - gru_leafc_xfer_to_atm(p) = leafc_xfer(p) * m - gru_frootc_xfer_to_atm(p) = frootc_xfer(p) * m - gru_livestemc_xfer_to_atm(p) = livestemc_xfer(p) * m - gru_deadstemc_xfer_to_atm(p) = deadstemc_xfer(p) * m - gru_livecrootc_xfer_to_atm(p) = livecrootc_xfer(p) * m - gru_deadcrootc_xfer_to_atm(p) = deadcrootc_xfer(p) * m - gru_gresp_xfer_to_atm(p) = gresp_xfer(p) * m + if(.not. use_matrixcn)then + ! patch-level gross unrepresented landcover change carbon fluxes + ! displayed pools + gru_leafc_to_litter(p) = leafc(p) * m + gru_frootc_to_litter(p) = frootc(p) * m + gru_livestemc_to_atm(p) = livestemc(p) * m + gru_deadstemc_to_atm(p) = deadstemc(p) * m * convfrac(ivt(p)) + gru_wood_productc_gain(p) = deadstemc(p) * m * (1._r8 - convfrac(ivt(p))) + gru_livecrootc_to_litter(p) = livecrootc(p) * m + gru_deadcrootc_to_litter(p) = deadcrootc(p) * m + gru_xsmrpool_to_atm(p) = xsmrpool(p) * m + + ! storage pools + gru_leafc_storage_to_atm(p) = leafc_storage(p) * m + gru_frootc_storage_to_atm(p) = frootc_storage(p) * m + gru_livestemc_storage_to_atm(p) = livestemc_storage(p) * m + gru_deadstemc_storage_to_atm(p) = deadstemc_storage(p) * m + gru_livecrootc_storage_to_atm(p) = livecrootc_storage(p) * m + gru_deadcrootc_storage_to_atm(p) = deadcrootc_storage(p) * m + gru_gresp_storage_to_atm(p) = gresp_storage(p) * m + + ! transfer pools + gru_leafc_xfer_to_atm(p) = leafc_xfer(p) * m + gru_frootc_xfer_to_atm(p) = frootc_xfer(p) * m + gru_livestemc_xfer_to_atm(p) = livestemc_xfer(p) * m + gru_deadstemc_xfer_to_atm(p) = deadstemc_xfer(p) * m + gru_livecrootc_xfer_to_atm(p) = livecrootc_xfer(p) * m + gru_deadcrootc_xfer_to_atm(p) = deadcrootc_xfer(p) * m + gru_gresp_xfer_to_atm(p) = gresp_xfer(p) * m - ! patch-level gross unrepresented landcover change mortality nitrogen fluxes - ! displayed pools - gru_leafn_to_litter(p) = leafn(p) * m - gru_frootn_to_litter(p) = frootn(p) * m - gru_livestemn_to_atm(p) = livestemn(p) * m - gru_deadstemn_to_atm(p) = deadstemn(p) * m * convfrac(ivt(p)) - gru_wood_productn_gain(p) = deadstemn(p) * m * (1._r8 - convfrac(ivt(p))) - gru_livecrootn_to_litter(p) = livecrootn(p) * m - gru_deadcrootn_to_litter(p) = deadcrootn(p) * m - gru_retransn_to_litter(p) = retransn(p) * m - - ! storage pools - gru_leafn_storage_to_atm(p) = leafn_storage(p) * m - gru_frootn_storage_to_atm(p) = frootn_storage(p) * m - gru_livestemn_storage_to_atm(p) = livestemn_storage(p) * m - gru_deadstemn_storage_to_atm(p) = deadstemn_storage(p) * m - gru_livecrootn_storage_to_atm(p) = livecrootn_storage(p) * m - gru_deadcrootn_storage_to_atm(p) = deadcrootn_storage(p) * m - - ! transfer pools - gru_leafn_xfer_to_atm(p) = leafn_xfer(p) * m - gru_frootn_xfer_to_atm(p) = frootn_xfer(p) * m - gru_livestemn_xfer_to_atm(p) = livestemn_xfer(p) * m - gru_deadstemn_xfer_to_atm(p) = deadstemn_xfer(p) * m - gru_livecrootn_xfer_to_atm(p) = livecrootn_xfer(p) * m - gru_deadcrootn_xfer_to_atm(p) = deadcrootn_xfer(p) * m + ! patch-level gross unrepresented landcover change mortality nitrogen fluxes + ! displayed pools + gru_leafn_to_litter(p) = leafn(p) * m + gru_frootn_to_litter(p) = frootn(p) * m + gru_livestemn_to_atm(p) = livestemn(p) * m + gru_deadstemn_to_atm(p) = deadstemn(p) * m * convfrac(ivt(p)) + gru_wood_productn_gain(p) = deadstemn(p) * m * (1._r8 - convfrac(ivt(p))) + gru_livecrootn_to_litter(p) = livecrootn(p) * m + gru_deadcrootn_to_litter(p) = deadcrootn(p) * m + gru_retransn_to_litter(p) = retransn(p) * m + + ! storage pools + gru_leafn_storage_to_atm(p) = leafn_storage(p) * m + gru_frootn_storage_to_atm(p) = frootn_storage(p) * m + gru_livestemn_storage_to_atm(p) = livestemn_storage(p) * m + gru_deadstemn_storage_to_atm(p) = deadstemn_storage(p) * m + gru_livecrootn_storage_to_atm(p) = livecrootn_storage(p) * m + gru_deadcrootn_storage_to_atm(p) = deadcrootn_storage(p) * m + + ! transfer pools + gru_leafn_xfer_to_atm(p) = leafn_xfer(p) * m + gru_frootn_xfer_to_atm(p) = frootn_xfer(p) * m + gru_livestemn_xfer_to_atm(p) = livestemn_xfer(p) * m + gru_deadstemn_xfer_to_atm(p) = deadstemn_xfer(p) * m + gru_livecrootn_xfer_to_atm(p) = livecrootn_xfer(p) * m + gru_deadcrootn_xfer_to_atm(p) = deadcrootn_xfer(p) * m + else ! matrixcn solution + ! patch-level gross unrepresented landcover change carbon fluxes + ! displayed pools + gru_leafc_to_litter(p) = matrix_update_gmc(p,ileaf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + leafc(p) + gru_frootc_to_litter(p) = matrix_update_gmc(p,ifroot_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + frootc(p) + gru_livestemc_to_atm(p) = matrix_update_gmc(p,ilivestem_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + livestemc(p) + gru_deadstemc_to_atm(p) = matrix_update_gmc(p,ideadstem_to_iout_gmc,m * convfrac(ivt(p)),dtime,cnveg_carbonflux_inst,.True.,.True.) * & + deadstemc(p) + gru_wood_productc_gain(p) = matrix_update_gmc(p,ideadstem_to_iout_gmc,m * (1._r8 - convfrac(ivt(p))),dtime,cnveg_carbonflux_inst,.True.,.True.) * & + deadstemc(p) + gru_livecrootc_to_litter(p) = matrix_update_gmc(p,ilivecroot_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + livecrootc(p) + gru_deadcrootc_to_litter(p) = matrix_update_gmc(p,ideadcroot_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + deadcrootc(p) + gru_xsmrpool_to_atm(p) = xsmrpool(p) * m + + ! storage pools + gru_leafc_storage_to_atm(p) = matrix_update_gmc(p,ileafst_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + leafc_storage(p) + gru_frootc_storage_to_atm(p) = matrix_update_gmc(p,ifrootst_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + frootc_storage(p) + gru_livestemc_storage_to_atm(p) = matrix_update_gmc(p,ilivestemst_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + livestemc_storage(p) + gru_deadstemc_storage_to_atm(p) = matrix_update_gmc(p,ideadstemst_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + deadstemc_storage(p) + gru_livecrootc_storage_to_atm(p) = matrix_update_gmc(p,ilivecrootst_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + livecrootc_storage(p) + gru_deadcrootc_storage_to_atm(p) = matrix_update_gmc(p,ideadcrootst_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + deadcrootc_storage(p) + gru_gresp_storage_to_atm(p) = gresp_storage(p) * m + + ! transfer pools + gru_leafc_xfer_to_atm(p) = matrix_update_gmc(p,ileafxf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + leafc_xfer(p) + gru_frootc_xfer_to_atm(p) = matrix_update_gmc(p,ifrootxf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + frootc_xfer(p) + gru_livestemc_xfer_to_atm(p) = matrix_update_gmc(p,ilivestemxf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + livestemc_xfer(p) + gru_deadstemc_xfer_to_atm(p) = matrix_update_gmc(p,ideadstemxf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + deadstemc_xfer(p) + gru_livecrootc_xfer_to_atm(p) = matrix_update_gmc(p,ilivecrootxf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + livecrootc_xfer(p) + gru_deadcrootc_xfer_to_atm(p) = matrix_update_gmc(p,ideadcrootxf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & + deadcrootc_xfer(p) + gru_gresp_xfer_to_atm(p) = gresp_xfer(p) * m + + ! patch-level gross unrepresented landcover change mortality nitrogen fluxes + ! displayed pools + gru_leafn_to_litter(p) = matrix_update_gmn(p,ileaf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + leafn(p) + gru_frootn_to_litter(p) = matrix_update_gmn(p,ifroot_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + frootn(p) + gru_livestemn_to_atm(p) = matrix_update_gmn(p,ilivestem_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + livestemn(p) + gru_deadstemn_to_atm(p) = matrix_update_gmn(p,ideadstem_to_iout_gmn,m * convfrac(ivt(p)),dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + deadstemn(p) + gru_wood_productn_gain(p) = matrix_update_gmn(p,ideadstem_to_iout_gmn,m * (1._r8 - convfrac(ivt(p))),dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + deadstemn(p) + gru_livecrootn_to_litter(p) = matrix_update_gmn(p,ilivecroot_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + livecrootn(p) + gru_deadcrootn_to_litter(p) = matrix_update_gmn(p,ideadcroot_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + deadcrootn(p) + gru_retransn_to_litter(p) = matrix_update_gmn(p,iretransn_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + retransn(p) + + ! storage pools + gru_leafn_storage_to_atm(p) = matrix_update_gmn(p,ileafst_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + leafn_storage(p) + gru_frootn_storage_to_atm(p) = matrix_update_gmn(p,ifrootst_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + frootn_storage(p) + gru_livestemn_storage_to_atm(p) = matrix_update_gmn(p,ilivestemst_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + livestemn_storage(p) + gru_deadstemn_storage_to_atm(p) = matrix_update_gmn(p,ideadstemst_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + deadstemn_storage(p) + gru_livecrootn_storage_to_atm(p) = matrix_update_gmn(p,ilivecrootst_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.)* & + livecrootn_storage(p) + gru_deadcrootn_storage_to_atm(p) = matrix_update_gmn(p,ideadcrootst_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.)* & + deadcrootn_storage(p) + ! transfer pools + gru_leafn_xfer_to_atm(p) = matrix_update_gmn(p,ileafxf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + leafn_xfer(p) + gru_frootn_xfer_to_atm(p) = matrix_update_gmn(p,ifrootxf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + frootn_xfer(p) + gru_livestemn_xfer_to_atm(p) = matrix_update_gmn(p,ilivestemxf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + livestemn_xfer(p) + gru_deadstemn_xfer_to_atm(p) = matrix_update_gmn(p,ideadstemxf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + deadstemn_xfer(p) + gru_livecrootn_xfer_to_atm(p) = matrix_update_gmn(p,ilivecrootxf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + livecrootn_xfer(p) + gru_deadcrootn_xfer_to_atm(p) = matrix_update_gmn(p,ideadcrootxf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & + deadcrootn_xfer(p) + end if end if ! end tree block diff --git a/src/dyn_subgrid/dynHarvestMod.F90 b/src/dyn_subgrid/dynHarvestMod.F90 index b662d67d73..609ba6679b 100644 --- a/src/dyn_subgrid/dynHarvestMod.F90 +++ b/src/dyn_subgrid/dynHarvestMod.F90 @@ -434,9 +434,9 @@ subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & m = 0._r8 end if - ! patch-level harvest carbon fluxes - ! displayed pools if(.not. use_matrixcn)then + ! patch-level harvest carbon fluxes + ! displayed pools hrv_leafc_to_litter(p) = leafc(p) * m hrv_frootc_to_litter(p) = frootc(p) * m hrv_livestemc_to_litter(p) = livestemc(p) * m @@ -492,6 +492,8 @@ subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & ! NOTE: The non-matrix part of this update is in CNCStatUpdate2 CStateUpdate2h (EBK 11/25/2019) ! and for Nitrogen The non-matrix part of this update is in CNNStatUpdate2 NStateUpdate2h (EBK 11/25/2019) else + ! patch-level harvest carbon fluxes + ! displayed pools hrv_leafc_to_litter(p) = matrix_update_gmc(p,ileaf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & leafc(p) hrv_frootc_to_litter(p) = matrix_update_gmc(p,ifroot_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & @@ -506,7 +508,7 @@ subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & deadcrootc(p) hrv_xsmrpool_to_atm(p) = xsmrpool(p) * m - ! storage pools + ! storage pools hrv_leafc_storage_to_litter(p) = matrix_update_gmc(p,ileafst_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & leafc_storage(p) hrv_frootc_storage_to_litter(p) = matrix_update_gmc(p,ifrootst_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & @@ -521,8 +523,7 @@ subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & deadcrootc_storage(p) hrv_gresp_storage_to_litter(p) = gresp_storage(p) * m - - ! transfer pools + ! transfer pools hrv_leafc_xfer_to_litter(p) = matrix_update_gmc(p,ileafxf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & leafc_xfer(p) hrv_frootc_xfer_to_litter(p) = matrix_update_gmc(p,ifrootxf_to_iout_gmc,m,dtime,cnveg_carbonflux_inst,.True.,.True.) * & @@ -537,6 +538,8 @@ subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & deadcrootc_xfer(p) hrv_gresp_xfer_to_litter(p) = gresp_xfer(p) * m + ! patch-level harvest mortality nitrogen fluxes + ! displayed pools hrv_leafn_to_litter(p) = matrix_update_gmn(p,ileaf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & leafn(p) hrv_frootn_to_litter(p) = matrix_update_gmn(p,ifroot_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & @@ -552,7 +555,7 @@ subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & hrv_retransn_to_litter(p) = matrix_update_gmn(p,iretransn_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & retransn(p) - ! storage pools + ! storage pools hrv_leafn_storage_to_litter(p) = matrix_update_gmn(p,ileafst_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) *& leafn_storage(p) hrv_frootn_storage_to_litter(p) = matrix_update_gmn(p,ifrootst_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) *& @@ -565,7 +568,7 @@ subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & livecrootn_storage(p) hrv_deadcrootn_storage_to_litter(p) = matrix_update_gmn(p,ideadcrootst_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.)*& deadcrootn_storage(p) - ! transfer pools + ! transfer pools hrv_leafn_xfer_to_litter(p) = matrix_update_gmn(p,ileafxf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & leafn_xfer(p) hrv_frootn_xfer_to_litter(p) = matrix_update_gmn(p,ifrootxf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & @@ -578,9 +581,7 @@ subroutine CNHarvest (num_soilc, filter_soilc, num_soilp, filter_soilp, & livecrootn_xfer(p) hrv_deadcrootn_xfer_to_litter(p) = matrix_update_gmn(p,ideadcrootxf_to_iout_gmn,m,dtime,cnveg_nitrogenflux_inst,.True.,.True.) * & deadcrootn_xfer(p) - end if - end if ! end tree block end do ! end of pft loop From 57aa176ae3f28dbea9a9a20c3953fe4c6c1bae12 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 28 Dec 2023 15:55:12 -0700 Subject: [PATCH 010/194] Additional updates for matrixcn to work with GULU --- src/biogeochem/CNCStateUpdate2Mod.F90 | 5 +++- src/biogeochem/CNDriverMod.F90 | 12 +++++--- src/biogeochem/CNNStateUpdate2Mod.F90 | 5 +++- src/biogeochem/dynGrossUnrepMod.F90 | 40 ++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/biogeochem/CNCStateUpdate2Mod.F90 b/src/biogeochem/CNCStateUpdate2Mod.F90 index 2890c7d1fd..c59d7d47f1 100644 --- a/src/biogeochem/CNCStateUpdate2Mod.F90 +++ b/src/biogeochem/CNCStateUpdate2Mod.F90 @@ -335,7 +335,8 @@ end subroutine CStateUpdate2h !----------------------------------------------------------------------- subroutine CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & - cnveg_carbonflux_inst, cnveg_carbonstate_inst, soilbiogeochem_carbonstate_inst) + cnveg_carbonflux_inst, cnveg_carbonstate_inst, & + soilbiogeochem_carbonstate_inst, soilbiogeochem_carbonflux_inst) ! ! !DESCRIPTION: ! Update all the prognostic carbon state @@ -348,6 +349,7 @@ subroutine CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & integer , intent(in) :: filter_soilp(:) ! filter for soil patches type(cnveg_carbonflux_type) , intent(in) :: cnveg_carbonflux_inst type(cnveg_carbonstate_type) , intent(inout) :: cnveg_carbonstate_inst + type(soilbiogeochem_carbonflux_type) , intent(inout) :: soilbiogeochem_carbonflux_inst type(soilbiogeochem_carbonstate_type) , intent(inout) :: soilbiogeochem_carbonstate_inst ! ! !LOCAL VARIABLES: @@ -359,6 +361,7 @@ subroutine CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & associate( & cf_veg => cnveg_carbonflux_inst , & cs_veg => cnveg_carbonstate_inst , & + cf_soil => soilbiogeochem_carbonflux_inst, & cs_soil => soilbiogeochem_carbonstate_inst & ) diff --git a/src/biogeochem/CNDriverMod.F90 b/src/biogeochem/CNDriverMod.F90 index 3d75ee51f0..d7eb964f1d 100644 --- a/src/biogeochem/CNDriverMod.F90 +++ b/src/biogeochem/CNDriverMod.F90 @@ -799,18 +799,22 @@ subroutine CNDriverNoLeaching(bounds, end if call CStateUpdate2g( num_soilc, filter_soilc, num_soilp, filter_soilp, & - cnveg_carbonflux_inst, cnveg_carbonstate_inst, soilbiogeochem_carbonstate_inst) + cnveg_carbonflux_inst, cnveg_carbonstate_inst, & + soilbiogeochem_carbonstate_inst, soilbiogeochem_carbonflux_inst) if ( use_c13 ) then call CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & - c13_cnveg_carbonflux_inst, c13_cnveg_carbonstate_inst, c13_soilbiogeochem_carbonstate_inst) + c13_cnveg_carbonflux_inst, c13_cnveg_carbonstate_inst, & + c13_soilbiogeochem_carbonstate_inst, c13_soilbiogeochem_carbonflux_inst) end if if ( use_c14 ) then call CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & - c14_cnveg_carbonflux_inst, c14_cnveg_carbonstate_inst, c14_soilbiogeochem_carbonstate_inst) + c14_cnveg_carbonflux_inst, c14_cnveg_carbonstate_inst, & + c14_soilbiogeochem_carbonstate_inst, c14_soilbiogeochem_carbonflux_inst) end if call NStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & - cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, soilbiogeochem_nitrogenstate_inst) + cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, & + soilbiogeochem_nitrogenstate_inst, soilbiogeochem_nitrogenflux_inst) call t_stopf('CNUpdate2') diff --git a/src/biogeochem/CNNStateUpdate2Mod.F90 b/src/biogeochem/CNNStateUpdate2Mod.F90 index 2dbba68b82..4b6174195e 100644 --- a/src/biogeochem/CNNStateUpdate2Mod.F90 +++ b/src/biogeochem/CNNStateUpdate2Mod.F90 @@ -321,7 +321,8 @@ end subroutine NStateUpdate2h !----------------------------------------------------------------------- subroutine NStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & - cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, soilbiogeochem_nitrogenstate_inst) + cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, & + soilbiogeochem_nitrogenstate_inst, soilbiogeochem_nitrogenflux_inst) ! ! !DESCRIPTION: ! Update all the prognostic nitrogen state @@ -337,6 +338,7 @@ subroutine NStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & type(cnveg_nitrogenflux_type) , intent(in) :: cnveg_nitrogenflux_inst type(cnveg_nitrogenstate_type) , intent(inout) :: cnveg_nitrogenstate_inst type(soilbiogeochem_nitrogenstate_type) , intent(inout) :: soilbiogeochem_nitrogenstate_inst + type(soilbiogeochem_nitrogenflux_type) , intent(inout) :: soilbiogeochem_nitrogenflux_inst ! ! !LOCAL VARIABLES: integer :: c,p,j,l,i ! indices @@ -347,6 +349,7 @@ subroutine NStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & associate( & nf_veg => cnveg_nitrogenflux_inst , & ns_veg => cnveg_nitrogenstate_inst , & + nf_soil => soilbiogeochem_nitrogenflux_inst, & ns_soil => soilbiogeochem_nitrogenstate_inst & ) diff --git a/src/biogeochem/dynGrossUnrepMod.F90 b/src/biogeochem/dynGrossUnrepMod.F90 index b354744b61..0c9b1e2c53 100644 --- a/src/biogeochem/dynGrossUnrepMod.F90 +++ b/src/biogeochem/dynGrossUnrepMod.F90 @@ -158,6 +158,7 @@ subroutine CNGrossUnrep (num_soilc, filter_soilc, num_soilp, filter_soilp, & use pftconMod , only : noveg, nbrdlf_evr_shrub, nc4_grass use clm_varcon , only : secspday use clm_time_manager, only : get_step_size_real, is_beg_curr_year + use CNVegMatrixMod , only : matrix_update_gmc, matrix_update_gmn ! ! !ARGUMENTS: integer , intent(in) :: num_soilc ! number of soil columns in filter @@ -269,7 +270,44 @@ subroutine CNGrossUnrep (num_soilc, filter_soilc, num_soilp, filter_soilp, & gru_livestemn_xfer_to_atm => cnveg_nitrogenflux_inst%gru_livestemn_xfer_to_atm_patch , & ! Output: [real(r8) (:)] gru_deadstemn_xfer_to_atm => cnveg_nitrogenflux_inst%gru_deadstemn_xfer_to_atm_patch , & ! Output: [real(r8) (:)] gru_livecrootn_xfer_to_atm => cnveg_nitrogenflux_inst%gru_livecrootn_xfer_to_atm_patch , & ! Output: [real(r8) (:)] - gru_deadcrootn_xfer_to_atm => cnveg_nitrogenflux_inst%gru_deadcrootn_xfer_to_atm_patch & ! Output: [real(r8) (:)] + gru_deadcrootn_xfer_to_atm => cnveg_nitrogenflux_inst%gru_deadcrootn_xfer_to_atm_patch , & ! Output: [real(r8) (:)] + ileaf_to_iout_gmc => cnveg_carbonflux_inst%ileaf_to_iout_gm , & + ileafst_to_iout_gmc => cnveg_carbonflux_inst%ileafst_to_iout_gm , & + ileafxf_to_iout_gmc => cnveg_carbonflux_inst%ileafxf_to_iout_gm , & + ifroot_to_iout_gmc => cnveg_carbonflux_inst%ifroot_to_iout_gm , & + ifrootst_to_iout_gmc => cnveg_carbonflux_inst%ifrootst_to_iout_gm , & + ifrootxf_to_iout_gmc => cnveg_carbonflux_inst%ifrootxf_to_iout_gm , & + ilivestem_to_iout_gmc => cnveg_carbonflux_inst%ilivestem_to_iout_gm , & + ilivestemst_to_iout_gmc => cnveg_carbonflux_inst%ilivestemst_to_iout_gm , & + ilivestemxf_to_iout_gmc => cnveg_carbonflux_inst%ilivestemxf_to_iout_gm , & + ideadstem_to_iout_gmc => cnveg_carbonflux_inst%ideadstem_to_iout_gm , & + ideadstemst_to_iout_gmc => cnveg_carbonflux_inst%ideadstemst_to_iout_gm , & + ideadstemxf_to_iout_gmc => cnveg_carbonflux_inst%ideadstemxf_to_iout_gm , & + ilivecroot_to_iout_gmc => cnveg_carbonflux_inst%ilivecroot_to_iout_gm , & + ilivecrootst_to_iout_gmc => cnveg_carbonflux_inst%ilivecrootst_to_iout_gm , & + ilivecrootxf_to_iout_gmc => cnveg_carbonflux_inst%ilivecrootxf_to_iout_gm , & + ideadcroot_to_iout_gmc => cnveg_carbonflux_inst%ideadcroot_to_iout_gm , & + ideadcrootst_to_iout_gmc => cnveg_carbonflux_inst%ideadcrootst_to_iout_gm , & + ideadcrootxf_to_iout_gmc => cnveg_carbonflux_inst%ideadcrootxf_to_iout_gm , & + ileaf_to_iout_gmn => cnveg_nitrogenflux_inst%ileaf_to_iout_gm , & + ileafst_to_iout_gmn => cnveg_nitrogenflux_inst%ileafst_to_iout_gm , & + ileafxf_to_iout_gmn => cnveg_nitrogenflux_inst%ileafxf_to_iout_gm , & + ifroot_to_iout_gmn => cnveg_nitrogenflux_inst%ifroot_to_iout_gm , & + ifrootst_to_iout_gmn => cnveg_nitrogenflux_inst%ifrootst_to_iout_gm , & + ifrootxf_to_iout_gmn => cnveg_nitrogenflux_inst%ifrootxf_to_iout_gm , & + ilivestem_to_iout_gmn => cnveg_nitrogenflux_inst%ilivestem_to_iout_gm , & + ilivestemst_to_iout_gmn => cnveg_nitrogenflux_inst%ilivestemst_to_iout_gm , & + ilivestemxf_to_iout_gmn => cnveg_nitrogenflux_inst%ilivestemxf_to_iout_gm , & + ideadstem_to_iout_gmn => cnveg_nitrogenflux_inst%ideadstem_to_iout_gm , & + ideadstemst_to_iout_gmn => cnveg_nitrogenflux_inst%ideadstemst_to_iout_gm , & + ideadstemxf_to_iout_gmn => cnveg_nitrogenflux_inst%ideadstemxf_to_iout_gm , & + ilivecroot_to_iout_gmn => cnveg_nitrogenflux_inst%ilivecroot_to_iout_gm , & + ilivecrootst_to_iout_gmn => cnveg_nitrogenflux_inst%ilivecrootst_to_iout_gm , & + ilivecrootxf_to_iout_gmn => cnveg_nitrogenflux_inst%ilivecrootxf_to_iout_gm , & + ideadcroot_to_iout_gmn => cnveg_nitrogenflux_inst%ideadcroot_to_iout_gm , & + ideadcrootst_to_iout_gmn => cnveg_nitrogenflux_inst%ideadcrootst_to_iout_gm , & + ideadcrootxf_to_iout_gmn => cnveg_nitrogenflux_inst%ideadcrootxf_to_iout_gm , & + iretransn_to_iout_gmn => cnveg_nitrogenflux_inst%iretransn_to_iout_gm & ) dtime = get_step_size_real() From 1242be2f5b74d65729682322c4c8228a0b6e07aa Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 28 Dec 2023 20:44:17 -0700 Subject: [PATCH 011/194] Cheyenne GULU test now passes with these additional updates --- src/biogeochem/CNCStateUpdate2Mod.F90 | 18 ++++++++++-------- src/biogeochem/CNGapMortalityMod.F90 | 5 ----- src/biogeochem/dynGrossUnrepMod.F90 | 2 +- src/dyn_subgrid/dynHarvestMod.F90 | 5 ----- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/biogeochem/CNCStateUpdate2Mod.F90 b/src/biogeochem/CNCStateUpdate2Mod.F90 index c59d7d47f1..5fb7a283e9 100644 --- a/src/biogeochem/CNCStateUpdate2Mod.F90 +++ b/src/biogeochem/CNCStateUpdate2Mod.F90 @@ -401,6 +401,16 @@ subroutine CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & do fp = 1,num_soilp p = filter_soilp(fp) + ! xsmrpool + cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) & + - cf_veg%gru_xsmrpool_to_atm_patch(p) * dt + ! gresp storage pool + cs_veg%gresp_storage_patch(p) = cs_veg%gresp_storage_patch(p) & + - cf_veg%gru_gresp_storage_to_atm_patch(p) * dt + ! gresp transfer pool + cs_veg%gresp_xfer_patch(p) = cs_veg%gresp_xfer_patch(p) & + - cf_veg%gru_gresp_xfer_to_atm_patch(p) * dt + ! patch-level carbon fluxes from gross unrepresented landcover change mortality ! ! State update without the matrix solution @@ -422,10 +432,6 @@ subroutine CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & cs_veg%deadcrootc_patch(p) = cs_veg%deadcrootc_patch(p) & - cf_veg%gru_deadcrootc_to_litter_patch(p) * dt - ! xsmrpool - cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) & - - cf_veg%gru_xsmrpool_to_atm_patch(p) * dt - ! storage pools cs_veg%leafc_storage_patch(p) = cs_veg%leafc_storage_patch(p) & - cf_veg%gru_leafc_storage_to_atm_patch(p) * dt @@ -439,8 +445,6 @@ subroutine CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & - cf_veg%gru_livecrootc_storage_to_atm_patch(p) * dt cs_veg%deadcrootc_storage_patch(p) = cs_veg%deadcrootc_storage_patch(p) & - cf_veg%gru_deadcrootc_storage_to_atm_patch(p) * dt - cs_veg%gresp_storage_patch(p) = cs_veg%gresp_storage_patch(p) & - - cf_veg%gru_gresp_storage_to_atm_patch(p) * dt ! transfer pools cs_veg%leafc_xfer_patch(p) = cs_veg%leafc_xfer_patch(p) & @@ -455,8 +459,6 @@ subroutine CStateUpdate2g(num_soilc, filter_soilc, num_soilp, filter_soilp, & - cf_veg%gru_livecrootc_xfer_to_atm_patch(p) * dt cs_veg%deadcrootc_xfer_patch(p) = cs_veg%deadcrootc_xfer_patch(p) & - cf_veg%gru_deadcrootc_xfer_to_atm_patch(p) * dt - cs_veg%gresp_xfer_patch(p) = cs_veg%gresp_xfer_patch(p) & - - cf_veg%gru_gresp_xfer_to_atm_patch(p) * dt else ! NB (slevis) The matrix equivalent of the above is in diff --git a/src/biogeochem/CNGapMortalityMod.F90 b/src/biogeochem/CNGapMortalityMod.F90 index e9013e03b1..c99660e3c6 100644 --- a/src/biogeochem/CNGapMortalityMod.F90 +++ b/src/biogeochem/CNGapMortalityMod.F90 @@ -24,11 +24,6 @@ module CNGapMortalityMod use PatchType , only : patch use GridcellType , only : grc use CNSharedParamsMod , only : use_matrixcn - use clm_varpar , only : ileaf,ileaf_st,ileaf_xf,ifroot,ifroot_st,ifroot_xf,& - ilivestem,ilivestem_st,ilivestem_xf,& - ideadstem,ideadstem_st,ideadstem_xf,& - ilivecroot,ilivecroot_st,ilivecroot_xf,& - ideadcroot,ideadcroot_st,ideadcroot_xf,iretransn,ioutc,ioutn use CNVegMatrixMod , only : matrix_update_gmc, matrix_update_gmn ! implicit none diff --git a/src/biogeochem/dynGrossUnrepMod.F90 b/src/biogeochem/dynGrossUnrepMod.F90 index 0c9b1e2c53..1da39a0b64 100644 --- a/src/biogeochem/dynGrossUnrepMod.F90 +++ b/src/biogeochem/dynGrossUnrepMod.F90 @@ -364,7 +364,7 @@ subroutine CNGrossUnrep (num_soilc, filter_soilc, num_soilp, filter_soilp, & gru_livecrootc_xfer_to_atm(p) = livecrootc_xfer(p) * m gru_deadcrootc_xfer_to_atm(p) = deadcrootc_xfer(p) * m gru_gresp_xfer_to_atm(p) = gresp_xfer(p) * m - + ! patch-level gross unrepresented landcover change mortality nitrogen fluxes ! displayed pools gru_leafn_to_litter(p) = leafn(p) * m diff --git a/src/dyn_subgrid/dynHarvestMod.F90 b/src/dyn_subgrid/dynHarvestMod.F90 index 609ba6679b..2936a41545 100644 --- a/src/dyn_subgrid/dynHarvestMod.F90 +++ b/src/dyn_subgrid/dynHarvestMod.F90 @@ -25,11 +25,6 @@ module dynHarvestMod use PatchType , only : patch use CNSharedParamsMod , only : use_matrixcn use clm_varctl , only : use_fates - use clm_varpar , only : ileaf,ileaf_st,ileaf_xf,ifroot,ifroot_st,ifroot_xf,& - ilivestem,ilivestem_st,ilivestem_xf,& - ideadstem,ideadstem_st,ideadstem_xf,& - ilivecroot,ilivecroot_st,ilivecroot_xf,& - ideadcroot,ideadcroot_st,ideadcroot_xf,ioutc,ioutn ! ! !PUBLIC MEMBER FUNCTIONS: implicit none From 46cbf4b3e67b1b55260b6b5b6d57778c1cc54db7 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 29 Dec 2023 16:04:20 -0700 Subject: [PATCH 012/194] Remove PS from SMS_Ld3_PS test for it to work with matrixcn --- cime_config/testdefs/testlist_clm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index e1f26f0703..3551d34b1a 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -536,7 +536,7 @@ - + From 2287bb6b7b4fdb66a97dc462d37173b72a46ec73 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 29 Dec 2023 19:04:24 -0700 Subject: [PATCH 013/194] Corrections for model to build and a test to pass Used this one for testing: SMS_D.1x1_brazil.I1850Clm51BgcCrop.cheyenne_gnu.clm-mimics_matrixcn --- src/biogeochem/CNCStateUpdate1Mod.F90 | 61 ++++--------------- src/biogeochem/CNDriverMod.F90 | 8 +-- .../SoilBiogeochemNitrogenStateType.F90 | 1 + 3 files changed, 17 insertions(+), 53 deletions(-) diff --git a/src/biogeochem/CNCStateUpdate1Mod.F90 b/src/biogeochem/CNCStateUpdate1Mod.F90 index c342e36a22..e839136e11 100644 --- a/src/biogeochem/CNCStateUpdate1Mod.F90 +++ b/src/biogeochem/CNCStateUpdate1Mod.F90 @@ -215,6 +215,18 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & ! terms have been moved to CStateUpdateDynPatch. I think this is zeroed every ! time step, but to be safe, I'm explicitly setting it to zero here. cf_soil%decomp_cpools_sourcesink_col(c,j,i_cwd) = 0._r8 + + ! litter and SOM HR fluxes + do k = 1, ndecomp_cascade_transitions + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) = & + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) & + - ( cf_soil%decomp_cascade_hr_vr_col(c,j,k) + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)) * dt + if ( cascade_receiver_pool(k) /= 0 ) then ! skip terminal transitions + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) = & + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) & + + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k) * dt + end if + end do else ! ! For the matrix solution the actual state update comes after the matrix @@ -233,55 +245,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & end if fates_if end do fc_loop - - - ! litter and SOM HR fluxes - do k = 1, ndecomp_cascade_transitions - do j = 1,nlevdecomp - do fc = 1,num_soilc - c = filter_soilc(fc) - ! - ! State update without the matrix solution - ! - if (.not. use_soil_matrixcn) then - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) = & - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) & - - ( cf_soil%decomp_cascade_hr_vr_col(c,j,k) + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)) *dt - end if !not use_soil_matrixcn - end do - end do - end do - do k = 1, ndecomp_cascade_transitions - if ( cascade_receiver_pool(k) /= 0 ) then ! skip terminal transitions - do j = 1,nlevdecomp - do fc = 1,num_soilc - c = filter_soilc(fc) - if (.not. use_soil_matrixcn) then - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) = & - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) & - - ( cf_soil%decomp_cascade_hr_vr_col(c,j,k) + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)) *dt - end if !not use_soil_matrixcn - end do - end do - end do - do k = 1, ndecomp_cascade_transitions - if ( cascade_receiver_pool(k) /= 0 ) then ! skip terminal transitions - do j = 1,nlevdecomp - do fc = 1,num_soilc - c = filter_soilc(fc) - ! - ! State update without the matrix solution - ! - if (.not. use_soil_matrixcn) then - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) = & - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) & - + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)*dt - end if !not use_soil_matrixcn - end do - end do - end do - end if - end do soilpatch_loop: do fp = 1,num_soilp p = filter_soilp(fp) diff --git a/src/biogeochem/CNDriverMod.F90 b/src/biogeochem/CNDriverMod.F90 index be341477a5..67eaba1013 100644 --- a/src/biogeochem/CNDriverMod.F90 +++ b/src/biogeochem/CNDriverMod.F90 @@ -1097,10 +1097,10 @@ subroutine CNDriverLeaching(bounds, & if ( use_matrixcn ) then call t_startf('CNVMatrix') - call CNVegMatrix(bounds,num_bgc_soilp,filter_bgc_soilp(1:num_bgc_soilp),num_actfirep,filter_actfirep,cnveg_carbonstate_inst,cnveg_nitrogenstate_inst,& - cnveg_carbonflux_inst, cnveg_nitrogenflux_inst,cnveg_state_inst,soilbiogeochem_nitrogenflux_inst,& - c13_cnveg_carbonstate_inst,c14_cnveg_carbonstate_inst,c13_cnveg_carbonflux_inst,& - c14_cnveg_carbonflux_inst) + call CNVegMatrix(bounds, num_bgc_vegp, filter_bgc_vegp(1:num_bgc_vegp), & + num_actfirep, filter_actfirep, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, & + cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, cnveg_state_inst,soilbiogeochem_nitrogenflux_inst, & + c13_cnveg_carbonstate_inst, c14_cnveg_carbonstate_inst, c13_cnveg_carbonflux_inst, c14_cnveg_carbonflux_inst) call t_stopf('CNVMatrix') end if diff --git a/src/soilbiogeochem/SoilBiogeochemNitrogenStateType.F90 b/src/soilbiogeochem/SoilBiogeochemNitrogenStateType.F90 index e97ed3e6eb..a0cbc81a9e 100644 --- a/src/soilbiogeochem/SoilBiogeochemNitrogenStateType.F90 +++ b/src/soilbiogeochem/SoilBiogeochemNitrogenStateType.F90 @@ -15,6 +15,7 @@ module SoilBiogeochemNitrogenStateType use clm_varctl , only : iulog, override_bgc_restart_mismatch_dump, spinup_state use landunit_varcon , only : istcrop, istsoil use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con, use_soil_matrixcn + use SoilBiogeochemDecompCascadeConType , only : mimics_decomp, century_decomp, decomp_method use LandunitType , only : lun use ColumnType , only : col use GridcellType , only : grc From 107f854c89a237b2d1d99ad36b78ce2ef2ad2544 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sat, 30 Dec 2023 21:42:36 -0700 Subject: [PATCH 014/194] Fix for FatesCold simulations to pass --- src/biogeochem/CNCStateUpdate1Mod.F90 | 30 +++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/biogeochem/CNCStateUpdate1Mod.F90 b/src/biogeochem/CNCStateUpdate1Mod.F90 index e839136e11..4eb52d9c10 100644 --- a/src/biogeochem/CNCStateUpdate1Mod.F90 +++ b/src/biogeochem/CNCStateUpdate1Mod.F90 @@ -216,17 +216,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & ! time step, but to be safe, I'm explicitly setting it to zero here. cf_soil%decomp_cpools_sourcesink_col(c,j,i_cwd) = 0._r8 - ! litter and SOM HR fluxes - do k = 1, ndecomp_cascade_transitions - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) = & - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) & - - ( cf_soil%decomp_cascade_hr_vr_col(c,j,k) + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)) * dt - if ( cascade_receiver_pool(k) /= 0 ) then ! skip terminal transitions - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) = & - cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) & - + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k) * dt - end if - end do else ! ! For the matrix solution the actual state update comes after the matrix @@ -243,6 +232,25 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, & end do end if fates_if + + do j = 1,nlevdecomp + ! + ! State update without the matrix solution + ! + if (.not. use_soil_matrixcn) then + ! litter and SOM HR fluxes + do k = 1, ndecomp_cascade_transitions + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) = & + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_donor_pool(k)) & + - ( cf_soil%decomp_cascade_hr_vr_col(c,j,k) + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k)) * dt + if ( cascade_receiver_pool(k) /= 0 ) then ! skip terminal transitions + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) = & + cf_soil%decomp_cpools_sourcesink_col(c,j,cascade_receiver_pool(k)) & + + cf_soil%decomp_cascade_ctransfer_vr_col(c,j,k) * dt + end if + end do + end if + end do end do fc_loop From 3af4aedfbb8bc7a8b0076184197141c463e6c8fd Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 2 Jan 2024 18:39:00 -0700 Subject: [PATCH 015/194] Corrections from comparing model versions --- src/biogeochem/CNPhenologyMod.F90 | 40 +++++++++---------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index e1b7b2edb6..2d9ab51473 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -3506,17 +3506,8 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & t1 = 1.0_r8 / dt frootc_to_litter(p) = t1 * frootc(p) + cpool_to_frootc(p) - ! TODO slevis: This line didn't appear in dev159. Remove? - ! biofuel_harvfrac is only non-zero for prognostic crops. - leafc_to_litter(p) = t1 * leafc(p) * (1._r8 - biofuel_harvfrac(ivt(p))) + cpool_to_leafc(p) - - ! leafc_litter and frootc_to_litter for matrix + ! frootc_to_litter for matrix if (use_matrixcn) then - if(leafc(p) .gt. 0)then - leafc_to_litter(p) = leafc(p) * matrix_update_phc(p,ileaf_to_iout_phc,leafc_to_litter(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) - else - leafc_to_litter(p) = 0 - end if if(frootc(p) .gt. 0)then frootc_to_litter(p) = frootc(p) * matrix_update_phc(p,ifroot_to_iout_phc,frootc_to_litter(p) / frootc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else @@ -3618,6 +3609,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & ! as well as leaf C:N ratio (unaffected by biofuel harvest). It thus does not ! need to be updated here. + ! Matrix for grain, livestem to litter, leaf to litter, and biofuel if(use_matrixcn)then if(reproductivec(p,1) .gt. 0)then grainc_to_out = reproductivec(p,1) * matrix_update_phc(p,igrain_to_iout_phc,(repr_grainc_to_seed(p,1) + repr_grainc_to_food(p,1)) / reproductivec(p,1),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) @@ -3633,13 +3625,17 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & end if if(livestemc(p) .gt. 0)then livestemc_to_litter(p) = livestemc(p) * matrix_update_phc(p,ilivestem_to_iout_phc,livestemc_to_litter(p) / livestemc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) + livestemc_to_biofuelc(p) = livestemc(p) * matrix_update_gmc(p,ilivestem_to_iout_gmc,livestemc_to_biofuelc(p) / livestemc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) else livestemc_to_litter(p) = 0 + livestemc_to_biofuelc(p) = 0 end if if(livestemn(p) .gt. 0)then livestemn_to_biofueln(p) = livestemn(p) * matrix_update_gmn(p,ilivestem_to_iout_gmn,livestemn_to_biofueln(p) / livestemn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) + livestemn_to_litter(p) = livestemn(p) * matrix_update_phn(p,ilivestem_to_iout_phn, (1._r8- biofuel_harvfrac(ivt(p)))/dt, dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else livestemn_to_biofueln(p) = 0 + livestemn_to_litter(p) = 0 end if if(leafn(p) > 0)then leafn_to_biofueln(p) = leafn(p) * matrix_update_gmn(p,ileaf_to_iout_gmn,leafn_to_biofueln(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) @@ -3647,14 +3643,11 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & leafn_to_biofueln(p) = 0 end if if (leafc(p) > 0)then - leafc_to_biofuelc(p) = leafc(p) * matrix_update_gmc(p,ileaf_to_iout_gmc,leafc_to_biofuelc(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) - else - leafc_to_biofuelc(p) = 0 - end if - if(livestemc(p) .gt. 0)then - livestemc_to_biofuelc(p) = livestemc(p) * matrix_update_gmc(p,ilivestem_to_iout_gmc,livestemc_to_biofuelc(p) / livestemc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) + leafc_to_biofuelc(p) = leafc(p) * matrix_update_gmc(p,ileaf_to_iout_gmc,leafc_to_biofuelc(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) + leafc_to_litter(p) = leafc(p) * matrix_update_phc(p,ileaf_to_iout_phc,leafc_to_litter(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - livestemc_to_biofuelc(p) = 0 + leafc_to_biofuelc(p) = 0 + leafc_to_litter(p) = 0 end if else ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) @@ -3675,7 +3668,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & if(frootc(p) .gt. 0)then frootc_to_litter(p) = frootc(p) * matrix_update_phc(p,ifroot_to_iout_phc,frootc_to_litter(p) / frootc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - frootc_to_litter(p) = 0 + frootc_to_litter(p) = 0 ! TODO slevis here and elsewhere end if else ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) @@ -3824,17 +3817,6 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & endif end if - ! TODO slevis: This paragraph didn't appear in dev159. Remove? - if (ivt(p) >= npcropmin) then - ! NOTE(slevis, 2014-12) results in -ve livestemn and -ve totpftn - !X! livestemn_to_litter(p) = livestemc_to_litter(p) / livewdcn(ivt(p)) - ! NOTE(slevis, 2014-12) Beth Drewniak suggested this instead - livestemn_to_litter(p) = livestemn(p) / dt * (1._r8 - biofuel_harvfrac(ivt(p))) - if(use_matrixcn)then - livestemn_to_litter(p) = livestemn(p) * matrix_update_phn(p,ilivestem_to_iout_phn, (1._r8- biofuel_harvfrac(ivt(p)))/dt, dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) - end if - end if - ! save the current litterfall fluxes prev_leafc_to_litter(p) = leafc_to_litter(p) prev_frootc_to_litter(p) = frootc_to_litter(p) From 2ea1cecedd3a00cd98d962f9de1eaac2159ace05 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 2 Jan 2024 18:46:58 -0700 Subject: [PATCH 016/194] Corrections to lists of tests and expected failures --- cime_config/testdefs/ExpectedTestFails.xml | 4 ++-- cime_config/testdefs/testlist_clm.xml | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 6be036c485..b0f7fa860b 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -50,13 +50,13 @@ #1733 - + FAIL #640, same test with clm-ciso_soil_matrixcn_only works - + FAIL #640, same test with clm-ciso_soil_matrixcn_only works diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 114e3781a0..5ec791b7d4 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -373,7 +373,7 @@ - + @@ -632,7 +632,7 @@ - + @@ -641,7 +641,7 @@ - + @@ -729,7 +729,7 @@ - + @@ -808,7 +808,7 @@ - + @@ -1005,7 +1005,7 @@ - + @@ -1014,7 +1014,7 @@ - + @@ -2383,7 +2383,7 @@ - + @@ -2603,7 +2603,7 @@ - + From 3b4d882878204b3dcda3a651375d12a9a074940f Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 12 Mar 2024 15:51:13 -0600 Subject: [PATCH 017/194] Add matrixcn code for residue removal variables --- src/biogeochem/CNPhenologyMod.F90 | 42 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index 619b28801b..b53c195418 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -3605,43 +3605,51 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & ! Matrix for grain, livestem to litter, leaf to litter, and biofuel if(use_matrixcn)then - if(reproductivec(p,1) .gt. 0)then + if(reproductivec(p,1) > 0._r8)then grainc_to_out = reproductivec(p,1) * matrix_update_phc(p,igrain_to_iout_phc,(repr_grainc_to_seed(p,1) + repr_grainc_to_food(p,1)) / reproductivec(p,1),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - repr_grainc_to_seed(p,1) = 0 - repr_grainc_to_food(p,1) = 0 + repr_grainc_to_seed(p,1) = 0._r8 + repr_grainc_to_food(p,1) = 0._r8 end if - if(reproductiven(p,1) .gt. 0)then + if(reproductiven(p,1) > 0._r8)then grainn_to_out = reproductiven(p,1) * matrix_update_phn(p,igrain_to_iout_phn,(repr_grainn_to_seed(p,1) + repr_grainn_to_food(p,1)) / reproductiven(p,1),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - repr_grainn_to_seed(p,1) = 0 - repr_grainn_to_food(p,1) = 0 + repr_grainn_to_seed(p,1) = 0._r8 + repr_grainn_to_food(p,1) = 0._r8 end if - if(livestemc(p) .gt. 0)then + if(livestemc(p) > 0._r8)then livestemc_to_litter(p) = livestemc(p) * matrix_update_phc(p,ilivestem_to_iout_phc,livestemc_to_litter(p) / livestemc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) + livestemc_to_removedresiduec(p) = livestemc(p) * matrix_update_gmc(p,ilivestem_to_iout_gmc,livestemc_to_removedresiduec(p) / livestemc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) livestemc_to_biofuelc(p) = livestemc(p) * matrix_update_gmc(p,ilivestem_to_iout_gmc,livestemc_to_biofuelc(p) / livestemc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) else - livestemc_to_litter(p) = 0 - livestemc_to_biofuelc(p) = 0 + livestemc_to_litter(p) = 0._r8 + livestemc_to_removedresiduec(p) = 0._r8 + livestemc_to_biofuelc(p) = 0._r8 end if - if(livestemn(p) .gt. 0)then + if(livestemn(p) > 0._r8)then livestemn_to_biofueln(p) = livestemn(p) * matrix_update_gmn(p,ilivestem_to_iout_gmn,livestemn_to_biofueln(p) / livestemn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) + livestemn_to_removedresiduen(p) = livestemn(p) * matrix_update_gmn(p,ilivestem_to_iout_gmn,livestemn_to_removedresiduen(p) / livestemn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) livestemn_to_litter(p) = livestemn(p) * matrix_update_phn(p,ilivestem_to_iout_phn, (1._r8- biofuel_harvfrac(ivt(p)))/dt, dt,cnveg_nitrogenflux_inst,matrixcheck_ph,acc_ph) else - livestemn_to_biofueln(p) = 0 - livestemn_to_litter(p) = 0 + livestemn_to_biofueln(p) = 0._r8 + livestemn_to_removedresiduen(p) = 0._r8 + livestemn_to_litter(p) = 0._r8 end if - if(leafn(p) > 0)then + if(leafn(p) > 0._r8)then leafn_to_biofueln(p) = leafn(p) * matrix_update_gmn(p,ileaf_to_iout_gmn,leafn_to_biofueln(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) + leafn_to_removedresiduen(p) = leafn(p) * matrix_update_gmn(p,ileaf_to_iout_gmn,leafn_to_removedresiduen(p) / leafn(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) else - leafn_to_biofueln(p) = 0 + leafn_to_biofueln(p) = 0._r8 + leafn_to_removedresiduen(p) = 0._r8 end if - if (leafc(p) > 0)then + if (leafc(p) > 0._r8)then leafc_to_biofuelc(p) = leafc(p) * matrix_update_gmc(p,ileaf_to_iout_gmc,leafc_to_biofuelc(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) + leafc_to_removedresiduec(p) = leafc(p) * matrix_update_gmc(p,ileaf_to_iout_gmc,leafc_to_removedresiduec(p) / leafc(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) leafc_to_litter(p) = leafc(p) * matrix_update_phc(p,ileaf_to_iout_phc,leafc_to_litter(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else - leafc_to_biofuelc(p) = 0 - leafc_to_litter(p) = 0 + leafc_to_biofuelc(p) = 0._r8 + leafc_to_removedresiduec(p) = 0._r8 + leafc_to_litter(p) = 0._r8 end if else ! NOTE: The non matrix version of this is in CNCStateUpdate1::CStateUpdate1 EBK (11/26/2019) From fe50ce16c03446c86b7018d1c655ca9a71b61982 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 12 Mar 2024 16:08:18 -0600 Subject: [PATCH 018/194] Update comment based on most recent code changes --- src/biogeochem/CNPhenologyMod.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index b53c195418..c6e6cf3635 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -3603,7 +3603,8 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & ! as well as leaf C:N ratio (unaffected by biofuel harvest). It thus does not ! need to be updated here. - ! Matrix for grain, livestem to litter, leaf to litter, and biofuel + ! Matrix for grain + ! Matrix for livestem/leaf to litter, biofuel, and removed residue if(use_matrixcn)then if(reproductivec(p,1) > 0._r8)then grainc_to_out = reproductivec(p,1) * matrix_update_phc(p,igrain_to_iout_phc,(repr_grainc_to_seed(p,1) + repr_grainc_to_food(p,1)) / reproductivec(p,1),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) From acd1413ef75868c873e72c17810704049495c00f Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 12 Mar 2024 16:25:36 -0600 Subject: [PATCH 019/194] Correction to latest code mods --- src/biogeochem/CNPhenologyMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/biogeochem/CNPhenologyMod.F90 b/src/biogeochem/CNPhenologyMod.F90 index c6e6cf3635..c81dd4215d 100644 --- a/src/biogeochem/CNPhenologyMod.F90 +++ b/src/biogeochem/CNPhenologyMod.F90 @@ -3645,7 +3645,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, & end if if (leafc(p) > 0._r8)then leafc_to_biofuelc(p) = leafc(p) * matrix_update_gmc(p,ileaf_to_iout_gmc,leafc_to_biofuelc(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) - leafc_to_removedresiduec(p) = leafc(p) * matrix_update_gmc(p,ileaf_to_iout_gmc,leafc_to_removedresiduec(p) / leafc(p),dt,cnveg_nitrogenflux_inst,matrixcheck_ph,.True.) + leafc_to_removedresiduec(p) = leafc(p) * matrix_update_gmc(p,ileaf_to_iout_gmc,leafc_to_removedresiduec(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,.True.) leafc_to_litter(p) = leafc(p) * matrix_update_phc(p,ileaf_to_iout_phc,leafc_to_litter(p) / leafc(p),dt,cnveg_carbonflux_inst,matrixcheck_ph,acc_ph) else leafc_to_biofuelc(p) = 0._r8 From 82c1903287d254dc5b8ed5084c38118029eab90c Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 19 Mar 2024 11:23:05 -0600 Subject: [PATCH 020/194] Corrections for PEM...till test to PASS --- .../SoilBiogeochemDecompCascadeBGCMod.F90 | 21 +++++---------- .../SoilBiogeochemDecompCascadeMIMICSMod.F90 | 26 +++++++++++++++++-- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/soilbiogeochem/SoilBiogeochemDecompCascadeBGCMod.F90 b/src/soilbiogeochem/SoilBiogeochemDecompCascadeBGCMod.F90 index 139cdbba32..49fc95d6f5 100644 --- a/src/soilbiogeochem/SoilBiogeochemDecompCascadeBGCMod.F90 +++ b/src/soilbiogeochem/SoilBiogeochemDecompCascadeBGCMod.F90 @@ -911,23 +911,16 @@ subroutine decomp_rate_constants_bgc(bounds, num_bgc_soilc, filter_bgc_soilc, & ! Above into soil matrix if(use_soil_matrixcn)then - Ksoil%DM(c,j+nlevdecomp*(i_met_lit-1)) = k_l1 * t_scalar(c,j) * w_scalar(c,j) * & - depth_scalar(c,j) * o_scalar(c,j) * spinup_geogterm_l1(c) * dt - Ksoil%DM(c,j+nlevdecomp*(i_cel_lit-1)) = k_l2_l3 * t_scalar(c,j) * w_scalar(c,j) * & - depth_scalar(c,j) * o_scalar(c,j) * spinup_geogterm_l23(c) * dt - Ksoil%DM(c,j+nlevdecomp*(i_lig_lit-1)) = k_l2_l3 * t_scalar(c,j) * w_scalar(c,j) * & - depth_scalar(c,j) * o_scalar(c,j) * spinup_geogterm_l23(c) * dt - Ksoil%DM(c,j+nlevdecomp*(i_act_som-1)) = k_s1 * t_scalar(c,j) * w_scalar(c,j) * & - depth_scalar(c,j) * o_scalar(c,j) * spinup_geogterm_s1(c) * dt - Ksoil%DM(c,j+nlevdecomp*(i_slo_som-1)) = k_s2 * t_scalar(c,j) * w_scalar(c,j) * & - depth_scalar(c,j) * o_scalar(c,j) * spinup_geogterm_s2(c) * dt - Ksoil%DM(c,j+nlevdecomp*(i_pas_som-1)) = k_s3 * t_scalar(c,j) * w_scalar(c,j) * & - depth_scalar(c,j) * o_scalar(c,j) * spinup_geogterm_s3(c) * dt + Ksoil%DM(c,j+nlevdecomp*(i_met_lit-1)) = decomp_k(c,j,i_met_lit) * dt + Ksoil%DM(c,j+nlevdecomp*(i_cel_lit-1)) = decomp_k(c,j,i_cel_lit) * dt + Ksoil%DM(c,j+nlevdecomp*(i_lig_lit-1)) = decomp_k(c,j,i_lig_lit) * dt + Ksoil%DM(c,j+nlevdecomp*(i_act_som-1)) = decomp_k(c,j,i_act_som) * dt + Ksoil%DM(c,j+nlevdecomp*(i_slo_som-1)) = decomp_k(c,j,i_slo_som) * dt + Ksoil%DM(c,j+nlevdecomp*(i_pas_som-1)) = decomp_k(c,j,i_pas_som) * dt ! same for cwd but only if fates is not enabled; fates handles CWD ! on its own structure if (.not. use_fates) then - Ksoil%DM(c,j+nlevdecomp*(i_cwd-1)) = k_frag * t_scalar(c,j) * w_scalar(c,j) * depth_scalar(c,j) * & - o_scalar(c,j) * spinup_geogterm_cwd(c) * dt + Ksoil%DM(c,j+nlevdecomp*(i_cwd-1)) = decomp_k(c,j,i_cwd) * dt end if end if !use_soil_matrixcn end do diff --git a/src/soilbiogeochem/SoilBiogeochemDecompCascadeMIMICSMod.F90 b/src/soilbiogeochem/SoilBiogeochemDecompCascadeMIMICSMod.F90 index 65091755f5..e9bb60bcec 100644 --- a/src/soilbiogeochem/SoilBiogeochemDecompCascadeMIMICSMod.F90 +++ b/src/soilbiogeochem/SoilBiogeochemDecompCascadeMIMICSMod.F90 @@ -18,7 +18,7 @@ module SoilBiogeochemDecompCascadeMIMICSMod use spmdMod , only : masterproc use abortutils , only : endrun use CNSharedParamsMod , only : CNParamsShareInst, nlev_soildecomp_standard - use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con + use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con, InitSoilTransfer, use_soil_matrixcn use SoilBiogeochemStateType , only : soilbiogeochem_state_type use SoilBiogeochemCarbonFluxType , only : soilbiogeochem_carbonflux_type use SoilBiogeochemCarbonStateType , only : soilbiogeochem_carbonstate_type @@ -734,6 +734,8 @@ subroutine init_decompcascade_mimics(bounds, soilbiogeochem_state_inst, soilstat nue_decomp_cascade(i_cwdl2) = 1.0_r8 end if + if (use_soil_matrixcn) call InitSoilTransfer() + deallocate(params_inst%mimics_mge) deallocate(params_inst%mimics_vmod) deallocate(params_inst%mimics_vint) @@ -763,7 +765,7 @@ subroutine decomp_rates_mimics(bounds, num_bgc_soilc, filter_bgc_soilc, & ! decomposition cascade model ! ! !USES: - use clm_time_manager , only : get_average_days_per_year + use clm_time_manager , only : get_average_days_per_year, get_step_size use clm_varcon , only : secspday, secsphr, tfrz use clm_varcon , only : g_to_mg, cm3_to_m3 use subgridAveMod , only : p2c @@ -822,6 +824,7 @@ subroutine decomp_rates_mimics(bounds, num_bgc_soilc, filter_bgc_soilc, & integer :: p, fp, c, fc, j, k, l, s ! indices integer :: pf ! fates patch index integer :: nc ! clump index + real(r8):: dt ! decomposition time step real(r8):: days_per_year ! days per year real(r8):: depth_scalar(bounds%begc:bounds%endc,1:nlevdecomp) real(r8):: w_d_o_scalars ! product of w_scalar * depth_scalar * o_scalar @@ -882,6 +885,7 @@ subroutine decomp_rates_mimics(bounds, num_bgc_soilc, filter_bgc_soilc, & cn_col => soilbiogeochem_carbonflux_inst%cn_col , & ! Output: [real(r8) (:,:) ] C:N ratio ligninNratioAvg => soilbiogeochem_carbonflux_inst%litr_lig_c_to_n_col, & ! Input: [real(r8) (:) ] C:N ratio of litter lignin decomp_k => soilbiogeochem_carbonflux_inst%decomp_k_col , & ! Output: [real(r8) (:,:,:) ] rate for decomposition (1./sec) + Ksoil => soilbiogeochem_carbonflux_inst%Ksoil , & ! Output: [real(r8) (:,:,:) ] rate constant for decomposition (1./sec) spinup_factor => decomp_cascade_con%spinup_factor & ! Input: [real(r8) (:) ] factor for AD spinup associated with each pool ) @@ -892,6 +896,7 @@ subroutine decomp_rates_mimics(bounds, num_bgc_soilc, filter_bgc_soilc, & mino2lim = CNParamsShareInst%mino2lim days_per_year = get_average_days_per_year() + dt = real( get_step_size(), r8 ) ! ! Set "decomp_depth_efolding" parameter ! decomp_depth_efolding = CNParamsShareInst%decomp_depth_efolding @@ -1311,6 +1316,23 @@ subroutine decomp_rates_mimics(bounds, num_bgc_soilc, filter_bgc_soilc, & if (get_do_tillage()) then call get_apply_tillage_multipliers(idop, c, j, decomp_k(c,j,:)) end if + +! Above into soil matrix + if(use_soil_matrixcn)then + Ksoil%DM(c,j+nlevdecomp*(i_met_lit-1)) = decomp_k(c,j,i_met_lit) * dt + Ksoil%DM(c,j+nlevdecomp*(i_str_lit-1)) = decomp_k(c,j,i_str_lit) * dt + Ksoil%DM(c,j+nlevdecomp*(i_avl_som-1)) = decomp_k(c,j,i_avl_som) * dt + Ksoil%DM(c,j+nlevdecomp*(i_phys_som-1)) = decomp_k(c,j,i_phys_som) * dt + Ksoil%DM(c,j+nlevdecomp*(i_chem_som-1)) = decomp_k(c,j,i_chem_som) * dt + Ksoil%DM(c,j+nlevdecomp*(i_cop_mic-1)) = decomp_k(c,j,i_cop_mic) * dt + Ksoil%DM(c,j+nlevdecomp*(i_oli_mic-1)) = decomp_k(c,j,i_oli_mic) * dt + ! same for cwd but only if fates is not enabled; fates handles + ! CWD + ! on its own structure + if (.not. use_fates) then + Ksoil%DM(c,j+nlevdecomp*(i_cwd-1)) = decomp_k(c,j,i_cwd) * dt + end if + end if !use_soil_matrixcn end do end do From 64870fa5b51fef1f93a4d05488c0a18e2d65d7d4 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 25 Mar 2024 09:53:37 -0600 Subject: [PATCH 021/194] Getting around "file not found" error for /run directory --- cime_config/SystemTests/sspmatrixcn.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cime_config/SystemTests/sspmatrixcn.py b/cime_config/SystemTests/sspmatrixcn.py index bd41d84651..5f2d3e065e 100644 --- a/cime_config/SystemTests/sspmatrixcn.py +++ b/cime_config/SystemTests/sspmatrixcn.py @@ -207,7 +207,9 @@ def run_phase(self): linkfile = os.path.join(rundir, os.path.basename(item)) if os.path.exists(linkfile): os.remove( linkfile ) - os.symlink(item, linkfile ) + self._case.flush() + if os.path.exists(rundir): + os.symlink(item, linkfile ) for item in glob.glob("{}/*rpointer*".format(rest_path)): shutil.copy(item, rundir) @@ -215,7 +217,8 @@ def run_phase(self): # # Run the case (Archiving on) # - self._case.flush() + if not os.path.exists(rundir): + self._case.flush() self.run_indv(suffix="step{}".format(self.steps[n]), st_archive=True) # From 25f0236576b01044df8509e865dbce35587983ca Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 26 Mar 2024 09:49:24 -0600 Subject: [PATCH 022/194] Getting around "file not found" error for rundir (this time test passes) --- cime_config/SystemTests/sspmatrixcn.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cime_config/SystemTests/sspmatrixcn.py b/cime_config/SystemTests/sspmatrixcn.py index 5f2d3e065e..eec462e72c 100644 --- a/cime_config/SystemTests/sspmatrixcn.py +++ b/cime_config/SystemTests/sspmatrixcn.py @@ -207,9 +207,9 @@ def run_phase(self): linkfile = os.path.join(rundir, os.path.basename(item)) if os.path.exists(linkfile): os.remove( linkfile ) - self._case.flush() - if os.path.exists(rundir): - os.symlink(item, linkfile ) + if not os.path.isdir(rundir): + os.makedirs(rundir) + os.symlink(item, linkfile ) for item in glob.glob("{}/*rpointer*".format(rest_path)): shutil.copy(item, rundir) @@ -217,8 +217,7 @@ def run_phase(self): # # Run the case (Archiving on) # - if not os.path.exists(rundir): - self._case.flush() + self._case.flush() self.run_indv(suffix="step{}".format(self.steps[n]), st_archive=True) # From d4cbc8c58570b027adbc155b7f39d0c2faaf3f38 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 26 Mar 2024 13:03:46 -0600 Subject: [PATCH 023/194] Bug-fix discovered by izumi_nag test --- src/main/surfrdUtilsMod.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/surfrdUtilsMod.F90 b/src/main/surfrdUtilsMod.F90 index 97f5b7d80f..ac7c1304b8 100644 --- a/src/main/surfrdUtilsMod.F90 +++ b/src/main/surfrdUtilsMod.F90 @@ -282,8 +282,8 @@ subroutine collapse_to_dominant(weight, lower_bound, upper_bound, begg, endg, n_ ! original sum of all the weights wt_sum(g) = sum(weight(g,:)) - if (present(do_not_collapse) .and. do_not_collapse(g)) then - cycle + if (present(do_not_collapse)) then + if (do_not_collapse(g)) cycle end if max_indices = 0 ! initialize From f06ceb8c8e3b47d96f363a7d2c681c7a68c1432e Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 26 Mar 2024 13:15:26 -0600 Subject: [PATCH 024/194] Update derecho test from failing P64x2 to passing P24x2 --- cime_config/testdefs/testlist_clm.xml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 3d713e98ec..04200b7271 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2835,19 +2835,7 @@ - - - - - - - - - - - - - + From 0ebb7e0415809c49250ecbc1bbd355227068ae35 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 27 Mar 2024 13:22:13 -0600 Subject: [PATCH 025/194] Rename isspinup -> spinup_matrixcn, is_outmatrix -> hist_wrt_matrixcn_diag Ran aux_clm on derecho and got expected results --- bld/CLMBuildNamelist.pm | 28 +++++++++---------- bld/namelist_files/namelist_defaults_ctsm.xml | 16 +++++------ .../namelist_definition_ctsm.xml | 6 ++-- bld/unit_testers/build-namelist_test.pl | 18 ++++++------ cime_config/SystemTests/sspmatrixcn.py | 2 +- .../clm/ciso_monthly_matrixcn/user_nl_clm | 2 +- src/biogeochem/CNVegMatrixMod.F90 | 14 +++++----- src/main/clm_varctl.F90 | 4 +-- src/main/controlMod.F90 | 10 +++---- src/soilbiogeochem/CNSoilMatrixMod.F90 | 16 +++++------ 10 files changed, 58 insertions(+), 58 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 67b8bd3b5c..ca0221277f 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -114,7 +114,7 @@ OPTIONS off : run in normal mode (spinup_state = 0) To spinup using the CN soil matrix method use "sasu" SemiAnalytic Spin-Up (SASU) - sasu: Turn on matrix spinup (isspinup=T) + sasu: Turn on matrix spinup (spinup_matrixcn=T) Normal spinup sequence is: on, sasu, off Default is set by clm_accelerated_spinup mode. @@ -1234,21 +1234,21 @@ sub setup_cmdl_spinup { } $nl_flags->{$var} = $val; if ( &value_is_true($nl_flags->{'use_soil_matrixcn'}) ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, "isspinup", + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, "spinup_matrixcn", , 'use_fates'=>$nl_flags->{'use_fates'}, 'bgc_mode'=>$nl_flags->{'bgc_mode'} , 'phys'=>$nl_flags->{'phys'}, 'use_soil_matrixcn'=>$nl_flags->{'use_soil_matrixcn'}, , clm_accelerated_spinup=>$nl_flags->{'clm_accelerated_spinup'} ); my $spinup; - if ( &value_is_true($nl->get_value("isspinup") ) ) { + if ( &value_is_true($nl->get_value("spinup_matrixcn") ) ) { $spinup = ".true."; } else { $spinup = ".false."; } - $nl_flags->{'isspinup'} = $spinup; - if ( &value_is_true($nl_flags->{'isspinup'}) ) { + $nl_flags->{'spinup_matrixcn'} = $spinup; + if ( &value_is_true($nl_flags->{'spinup_matrixcn'}) ) { $nl_flags->{'bgc_spinup'} = "on"; if ( $nl_flags->{'clm_accelerated_spinup'} eq "off" ) { - $log->fatal_error("matrix spinup (isspinup) is True, but clm_accelerated_spinup is off, change one or the other"); + $log->fatal_error("matrix spinup (spinup_matrixcn) is True, but clm_accelerated_spinup is off, change one or the other"); } } else { $nl_flags->{'bgc_spinup'} = "off"; @@ -4569,14 +4569,14 @@ sub setup_logic_cnmatrix { # my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; - my @matrixlist = ( "use_matrixcn", "is_outmatrix" ); + my @matrixlist = ( "use_matrixcn", "hist_wrt_matrixcn_diag" ); foreach my $var ( @matrixlist ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var , 'use_fates'=>$nl_flags->{'use_fates'}, 'bgc_mode'=>$nl_flags->{'bgc_mode'} , 'phys'=>$nl_flags->{'phys'}, 'use_soil_matrixcn'=>$nl_flags->{'use_soil_matrixcn'}, - , 'isspinup'=>$nl_flags->{'isspinup'}, 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); + , 'spinup_matrixcn'=>$nl_flags->{'spinup_matrixcn'}, 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); } - @matrixlist = ( "use_matrixcn", "use_soil_matrixcn", "is_outmatrix", "isspinup" ); + @matrixlist = ( "use_matrixcn", "use_soil_matrixcn", "hist_wrt_matrixcn_diag", "spinup_matrixcn" ); # Matrix items can't be on for SP mode if ( $nl_flags->{'bgc_mode'} eq "sp" ) { foreach my $var ( @matrixlist ) { @@ -4607,14 +4607,14 @@ sub setup_logic_cnmatrix { } # If both matrixcn and soil_matrix are off outmatrix can't be on if ( ! &value_is_true($nl->get_value("use_matrixcn")) && ! &value_is_true($nl_flags->{"use_soil_matrixcn"}) ) { - my $var = "is_outmatrix"; + my $var = "hist_wrt_matrixcn_diag"; if ( &value_is_true($nl->get_value($var)) ) { $log->fatal_error("$var can NOT be on when both use_matrixcn and use_soil_matrixcn are off" ); } } # If soil_matrix is off ispspinup can't be on if ( ! &value_is_true($nl_flags->{"use_soil_matrixcn"}) ) { - my $var = "isspinup"; + my $var = "spinup_matrixcn"; if ( &value_is_true($nl->get_value($var)) ) { $log->fatal_error("$var can NOT be on when use_soil_matrixcn is off" ); } @@ -4623,10 +4623,10 @@ sub setup_logic_cnmatrix { # if soil matrix is on and spinup is on, set spinup specific variables my @spinup_vars = ( "nyr_forcing", "nyr_sasu", "iloop_avg" ); foreach my $var ( @spinup_vars ) { - if ( &value_is_true($nl_flags->{"use_soil_matrixcn"}) && &value_is_true($nl_flags->{'isspinup'}) ) { + if ( &value_is_true($nl_flags->{"use_soil_matrixcn"}) && &value_is_true($nl_flags->{'spinup_matrixcn'}) ) { if ( $var ne "nyr_sasu" ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, - , 'phys'=>$nl_flags->{'phys'}, 'isspinup'=>$nl_flags->{'isspinup'} ); + , 'phys'=>$nl_flags->{'phys'}, 'spinup_matrixcn'=>$nl_flags->{'spinup_matrixcn'} ); } else { # Set SASU spinup period to nyr_forcing (slow mode) by default add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, @@ -4644,7 +4644,7 @@ sub setup_logic_cnmatrix { } } } - if ( &value_is_true($nl_flags->{"use_soil_matrixcn"}) && &value_is_true($nl_flags->{'isspinup'}) ) { + if ( &value_is_true($nl_flags->{"use_soil_matrixcn"}) && &value_is_true($nl_flags->{'spinup_matrixcn'}) ) { my $nyr_forcing = $nl->get_value('nyr_forcing'); my $nyr_sasu = $nl->get_value('nyr_sasu'); if ( $nyr_sasu > $nyr_forcing ) { diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index f2e42dd6e0..1455bbf873 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -661,18 +661,18 @@ attributes from the config_cache.xml file (with keys converted to upper-case). .false. .false. -.false. -.false. -.false. -.true. -.true. -.false. +.false. +.false. +.false. +.true. +.true. +.false. 1 -20 +20 1 -999 --999 +-999 diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 5214c20942..4cf8b8ad7d 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -1149,12 +1149,12 @@ Turn on the Matrix solution for above ground biogeochemistry, requires CN to be Turn on the Matrix solution for soil biogeochemistry - Turn on extra output for the matrix solution - Turn on semi-analytic spinup solution for the CN/Soil matrix, requires soil matrix to be on This will drive the solution to equilibrium @@ -1162,7 +1162,7 @@ This will drive the solution to equilibrium -Number of years to average the storage capacitance over for the soil Matrix solution during semi-analytic spinup (isspinup=T) +Number of years to average the storage capacitance over for the soil Matrix solution during semi-analytic spinup (spinup_matrixcn=T) Normally should be the same as the number of years the atmospheric forcing is run over diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 3c3a42abc9..83429d2f18 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -326,8 +326,8 @@ sub cat_and_create_namelistinfile { "-res 0.9x1.25 -use_case 1850_control", "-res 1x1pt_US-UMB -clm_usr_name 1x1pt_US-UMB -namelist '&a fsurdat=\"/dev/null\"/'", "-res 1x1_brazil", - "-namelist '&a use_matrixcn=F,use_soil_matrixcn=F,is_outmatrix=F,isspinup=F/' -bgc sp", - "-namelist '&a use_matrixcn=T,use_soil_matrixcn=T,is_outmatrix=T,isspinup=T/' -bgc bgc -crop -clm_accelerated_spinup on", + "-namelist '&a use_matrixcn=F,use_soil_matrixcn=F,hist_wrt_matrixcn_diag=F,spinup_matrixcn=F/' -bgc sp", + "-namelist '&a use_matrixcn=T,use_soil_matrixcn=T,hist_wrt_matrixcn_diag=T,spinup_matrixcn=T/' -bgc bgc -crop -clm_accelerated_spinup on", "-namelist \"&a soil_decomp_method='MIMICSWieder2015',use_matrixcn=F/\" -bgc bgc -crop", "-namelist \"&a soil_decomp_method='MIMICSWieder2015',use_matrixcn=T/\" -bgc bgc -crop", "-bgc bgc -crop -clm_accelerated_spinup sasu", @@ -970,12 +970,12 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "outmatrixWOmatrix" =>{ options=>"-envxml_dir . -bgc bgc", - namelst=>"use_soil_matrixcn=.false.,use_matrixcn=F,is_outmatrix=T", + namelst=>"use_soil_matrixcn=.false.,use_matrixcn=F,hist_wrt_matrixcn_diag=T", GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", }, "spinupWOsoilmatrix" =>{ options=>"-envxml_dir . -bgc bgc", - namelst=>"use_soil_matrixcn=F,use_matrixcn=T,isspinup=T", + namelst=>"use_soil_matrixcn=F,use_matrixcn=T,spinup_matrixcn=T", GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", }, @@ -990,27 +990,27 @@ sub cat_and_create_namelistinfile { phys=>"clm5_1", }, "nyrforceWOspinup" =>{ options=>"-envxml_dir . -bgc bgc -clm_accelerated_spinup sasu", - namelst=>"use_matrixcn=.false.,isspinup=F,nyr_forcing=20", + namelst=>"use_matrixcn=.false.,spinup_matrixcn=F,nyr_forcing=20", GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", }, "nyrsasuGTnyrforce" =>{ options=>"-envxml_dir . -bgc bgc -clm_accelerated_spinup sasu", - namelst=>"use_matrixcn=.false.,isspinup=T,nyr_forcing=20,nyr_sasu=21", + namelst=>"use_matrixcn=.false.,spinup_matrixcn=T,nyr_forcing=20,nyr_sasu=21", GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", }, "iloopZero" =>{ options=>"-envxml_dir . -bgc bgc -clm_accelerated_spinup sasu", - namelst=>"use_matrixcn=.false.,isspinup=T,iloop_avg=0", + namelst=>"use_matrixcn=.false.,spinup_matrixcn=T,iloop_avg=0", GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", }, "matrixspinupWADmode" =>{ options=>"-envxml_dir . -bgc bgc -clm_accelerated_spinup sasu", - namelst=>"isspinup=T,spinup_state=2", + namelst=>"spinup_matrixcn=T,spinup_state=2", GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", }, "matrixspinupWclmaccell" =>{ options=>"-envxml_dir . -bgc bgc -clm_accelerated_spinup off", - namelst=>"use_soil_matrixcn=T,isspinup=T", + namelst=>"use_soil_matrixcn=T,spinup_matrixcn=T", GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", }, diff --git a/cime_config/SystemTests/sspmatrixcn.py b/cime_config/SystemTests/sspmatrixcn.py index eec462e72c..0e0d57e6c2 100644 --- a/cime_config/SystemTests/sspmatrixcn.py +++ b/cime_config/SystemTests/sspmatrixcn.py @@ -130,7 +130,7 @@ def append_user_nl(self, caseroot, n=0): # For all but last step turn extra matrix output to off b4last = self.n_steps() - 1 if ( n < b4last ): - contents_to_append = contents_to_append + ", is_outmatrix = .False." + contents_to_append = contents_to_append + ", hist_wrt_matrixcn_diag = .False." # For matrix spinup steps, set the matrix spinup and other variables associated with it if ( self.spin[n] == "sasu" ): contents_to_append = contents_to_append + ", nyr_forcing = "+str(self.nyr_forcing) diff --git a/cime_config/testdefs/testmods_dirs/clm/ciso_monthly_matrixcn/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/ciso_monthly_matrixcn/user_nl_clm index 56d4261a45..6b7eb4347d 100644 --- a/cime_config/testdefs/testmods_dirs/clm/ciso_monthly_matrixcn/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/ciso_monthly_matrixcn/user_nl_clm @@ -1,3 +1,3 @@ use_matrixcn = .true. use_soil_matrixcn = .true. - is_outmatrix = .true. + hist_wrt_matrixcn_diag = .true. diff --git a/src/biogeochem/CNVegMatrixMod.F90 b/src/biogeochem/CNVegMatrixMod.F90 index c171490bf0..bf7527bc71 100644 --- a/src/biogeochem/CNVegMatrixMod.F90 +++ b/src/biogeochem/CNVegMatrixMod.F90 @@ -41,7 +41,7 @@ module CNVegMatrixMod use CNVegNitrogenFluxType , only : cnveg_nitrogenflux_type use CNVegStateType , only : cnveg_state_type use SoilBiogeochemNitrogenFluxType , only : soilbiogeochem_nitrogenflux_type - use clm_varctl , only : isspinup, is_outmatrix, nyr_forcing, nyr_SASU, iloop_avg + use clm_varctl , only : spinup_matrixcn, hist_wrt_matrixcn_diag, nyr_forcing, nyr_SASU, iloop_avg use clm_varctl , only : use_c13, use_c14 use SparseMatrixMultiplyMod , only : sparse_matrix_type,diag_matrix_type,vector_type use MatrixMod , only : inverse @@ -1253,7 +1253,7 @@ subroutine CNVegMatrix(bounds,num_soilp,filter_soilp,num_actfirep,filter_actfire if(mod(iyr-1,nyr_forcing) .eq. 0)then iloop = iloop + 1 end if - if(.not. isspinup .or. isspinup .and. mod(iyr-1,nyr_SASU) .eq. 0)then + if(.not. spinup_matrixcn .or. spinup_matrixcn .and. mod(iyr-1,nyr_SASU) .eq. 0)then do fp = 1,num_soilp p = filter_soilp(fp) leafc0(p) = max(leafc(p), epsi) @@ -1683,7 +1683,7 @@ subroutine CNVegMatrix(bounds,num_soilp,filter_soilp,num_actfirep,filter_actfire ! Accumulate transfers during the whole calendar year call t_startf('CN veg matrix-accum. trans.') - if(isspinup .or. is_outmatrix)then + if(spinup_matrixcn .or. hist_wrt_matrixcn_diag)then do fp = 1,num_soilp p = filter_soilp(fp) matrix_calloc_leaf_acc(p) = matrix_calloc_leaf_acc(p) + vegmatrixc_input%V(p,ileaf) @@ -2439,8 +2439,8 @@ subroutine CNVegMatrix(bounds,num_soilp,filter_soilp,num_actfirep,filter_actfire call t_stopf('CN veg matrix-assign new value') ! Calculate C storage capacity. 2D matrix instead of sparse matrix is still used when calculating the inverse - if(isspinup .or. is_outmatrix)then - if((.not. isspinup .and. is_end_curr_year()) .or. (isspinup .and. is_end_curr_year() .and. mod(iyr,nyr_SASU) .eq. 0))then + if(spinup_matrixcn .or. hist_wrt_matrixcn_diag)then + if((.not. spinup_matrixcn .and. is_end_curr_year()) .or. (spinup_matrixcn .and. is_end_curr_year() .and. mod(iyr,nyr_SASU) .eq. 0))then do fp = 1,num_soilp call t_startf('CN veg matrix-prepare AK^-1') p = filter_soilp(fp) @@ -2881,7 +2881,7 @@ subroutine CNVegMatrix(bounds,num_soilp,filter_soilp,num_actfirep,filter_actfire call t_startf('CN veg matrix-finalize spinup') - if(isspinup .and. .not. is_first_step_of_this_run_segment())then + if(spinup_matrixcn .and. .not. is_first_step_of_this_run_segment())then deadstemc(p) = vegmatrixc_rt(ideadstem) deadstemc_storage(p) = vegmatrixc_rt(ideadstem_st) deadcrootc(p) = vegmatrixc_rt(ideadcroot) @@ -3184,7 +3184,7 @@ subroutine CNVegMatrix(bounds,num_soilp,filter_soilp,num_actfirep,filter_actfire end if ! Save C storage capacity from temporary variables to module variables - if(is_outmatrix)then + if(hist_wrt_matrixcn_diag)then matrix_cap_leafc(p) = vegmatrixc_rt(ileaf) matrix_cap_leafc_storage(p) = vegmatrixc_rt(ileaf_st) matrix_cap_leafc_xfer(p) = vegmatrixc_rt(ileaf_xf) diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index ffc43b4200..faead44399 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -280,8 +280,8 @@ module clm_varctl !---------------------------------------------------------- ! CN matrix !---------------------------------------------------------- - logical, public :: isspinup = .false. !.false. ! true => use acc spinup - logical, public :: is_outmatrix = .false.!.false. ! true => use acc spinup + logical, public :: spinup_matrixcn = .false. !.false. ! true => use acc spinup + logical, public :: hist_wrt_matrixcn_diag = .false.!.false. ! true => use acc spinup ! SASU integer, public :: nyr_forcing = 10 ! length of forcing years for the spin up. eg. if DATM_CLMNCEP_YR_START=1901;DATM_CLMNCEP_YR_END=1920, then nyr_forcing = 20 integer, public :: nyr_SASU = 1 ! length of each semi-analytic solution. eg. nyr_SASU=5, analytic solutions will be calculated every five years. diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index ef006bcc42..acb4d6491b 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -189,7 +189,7 @@ subroutine control_init(dtime) ! CN Matrix solution namelist /clm_inparm / & - use_matrixcn, use_soil_matrixcn, is_outmatrix, isspinup, nyr_forcing, nyr_sasu, iloop_avg + use_matrixcn, use_soil_matrixcn, hist_wrt_matrixcn_diag, spinup_matrixcn, nyr_forcing, nyr_sasu, iloop_avg ! lake_melt_icealb is of dimension numrad @@ -325,8 +325,8 @@ subroutine control_init(dtime) if(use_fates)then use_matrixcn = .false. use_soil_matrixcn = .false. - is_outmatrix = .false. - isspinup = .false. + hist_wrt_matrixcn_diag = .false. + spinup_matrixcn = .false. end if nyr_forcing = 10 @@ -850,8 +850,8 @@ subroutine control_spmd() call mpi_bcast (use_dynroot, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_matrixcn, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_soil_matrixcn, 1, MPI_LOGICAL, 0, mpicom, ier) - call mpi_bcast (is_outmatrix, 1, MPI_LOGICAL, 0, mpicom, ier) - call mpi_bcast (isspinup, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (hist_wrt_matrixcn_diag, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (spinup_matrixcn, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (nyr_forcing, 1, MPI_INTEGER, 0, mpicom, ier) call mpi_bcast (nyr_sasu, 1, MPI_INTEGER, 0, mpicom, ier) call mpi_bcast (iloop_avg, 1, MPI_INTEGER, 0, mpicom, ier) diff --git a/src/soilbiogeochem/CNSoilMatrixMod.F90 b/src/soilbiogeochem/CNSoilMatrixMod.F90 index 1248c5e1d6..56c1f11b5c 100644 --- a/src/soilbiogeochem/CNSoilMatrixMod.F90 +++ b/src/soilbiogeochem/CNSoilMatrixMod.F90 @@ -34,7 +34,7 @@ module CNSoilMatrixMod use SoilBiogeochemNitrogenFluxType , only : soilbiogeochem_nitrogenflux_type use CNSharedParamsMod , only : CNParamsShareInst use SoilStateType , only : soilstate_type - use clm_varctl , only : isspinup, is_outmatrix, nyr_forcing, nyr_SASU, iloop_avg + use clm_varctl , only : spinup_matrixcn, hist_wrt_matrixcn_diag, nyr_forcing, nyr_SASU, iloop_avg use ColumnType , only : col use GridcellType , only : grc use clm_varctl , only : use_c13, use_c14, iulog @@ -67,14 +67,14 @@ subroutine CNSoilMatrixInit( ) if ( use_soil_matrixcn ) then write(iulog,*) 'CN Soil matrix solution is on' write(iulog,*) '*****************************' - if ( isspinup ) then + if ( spinup_matrixcn ) then write(iulog,*) ' Matrix spinup is on' write(iulog,*) ' *******************' write(iulog,*) ' nyr_forcing = ', nyr_forcing write(iulog,*) ' nyr_SASU = ', nyr_SASU write(iulog,*) ' iloop_avg = ', iloop_avg end if - if ( is_outmatrix )then + if ( hist_wrt_matrixcn_diag )then write(iulog,*) ' Extra matrix solution tracability output is turned on' else write(iulog,*) ' no extra matrix solution tracability output' @@ -343,7 +343,7 @@ subroutine CNSoilMatrix(bounds,num_soilc, filter_soilc, num_actfirec, filter_act if(mod(iyr-1,nyr_forcing) .eq. 0)then iloop = iloop + 1 end if - if(.not. isspinup .or. isspinup .and. mod(iyr-1,nyr_SASU) .eq. 0)then + if(.not. spinup_matrixcn .or. spinup_matrixcn .and. mod(iyr-1,nyr_SASU) .eq. 0)then do i = 1,ndecomp_pools do j = 1, nlevdecomp do fc = 1,num_soilc @@ -550,7 +550,7 @@ subroutine CNSoilMatrix(bounds,num_soilc, filter_soilc, num_actfirec, filter_act call t_stopf('CN Soil matrix-assign back') - if(use_soil_matrixcn .and. (is_outmatrix .or. isspinup))then + if(use_soil_matrixcn .and. (hist_wrt_matrixcn_diag .or. spinup_matrixcn))then ! Accumulate C transfers during a whole calendar year to calculate the C and N capacity do j=1,ndecomp_pools*nlevdecomp @@ -665,7 +665,7 @@ subroutine CNSoilMatrix(bounds,num_soilc, filter_soilc, num_actfirec, filter_act end if call t_startf('CN Soil matrix-calc. C capacity') - if((.not. isspinup .and. is_end_curr_year()) .or. (isspinup .and. is_end_curr_year() .and. mod(iyr,nyr_SASU) .eq. 0))then + if((.not. spinup_matrixcn .and. is_end_curr_year()) .or. (spinup_matrixcn .and. is_end_curr_year() .and. mod(iyr,nyr_SASU) .eq. 0))then ! Copy C transfers from sparse matrix to 2D temporary variables tran_acc and tran_nacc ! Calculate the C and N transfer rate by dividing CN transfer by base value saved at begin of each year. do fc = 1,num_soilc @@ -816,7 +816,7 @@ subroutine CNSoilMatrix(bounds,num_soilc, filter_soilc, num_actfirec, filter_act do j = 1,nlevdecomp do fc = 1,num_soilc c = filter_soilc(fc) - if(isspinup .and. .not. is_first_step_of_this_run_segment())then + if(spinup_matrixcn .and. .not. is_first_step_of_this_run_segment())then cs_soil%decomp_cpools_vr_col(c,j,i) = soilmatrixc_cap(c,j+(i-1)*nlevdecomp,1) if(use_c13)then cs13_soil%decomp_cpools_vr_col(c,j,i) = soilmatrixc13_cap(c,j+(i-1)*nlevdecomp,1) @@ -871,7 +871,7 @@ subroutine CNSoilMatrix(bounds,num_soilc, filter_soilc, num_actfirec, filter_act end do end do - if(isspinup)call update_DA_nstep() + if(spinup_matrixcn)call update_DA_nstep() if(iloop .eq. iloop_avg .and. iyr .eq. nyr_forcing)iloop = 0 if(iyr .eq. nyr_forcing)iyr = 0 From 1a2ddffdffbae8b3140b0e751b530f21db9c5afb Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 27 Mar 2024 13:24:58 -0600 Subject: [PATCH 026/194] Replace 1.e+36 with spval in cnmatrix code --- src/biogeochem/CNVegMatrixMod.F90 | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/biogeochem/CNVegMatrixMod.F90 b/src/biogeochem/CNVegMatrixMod.F90 index bf7527bc71..5582afeffe 100644 --- a/src/biogeochem/CNVegMatrixMod.F90 +++ b/src/biogeochem/CNVegMatrixMod.F90 @@ -23,6 +23,7 @@ module CNVegMatrixMod use clm_time_manager , only : get_step_size,is_end_curr_year,is_first_step_of_this_run_segment,& is_beg_curr_year,update_DA_nstep use decompMod , only : bounds_type + use clm_varcon , only : spval use clm_varpar , only : nlevdecomp, nvegcpool, nvegnpool use clm_varpar , only : ileaf,ileaf_st,ileaf_xf,ifroot,ifroot_st,ifroot_xf,& ilivestem,ilivestem_st,ilivestem_xf,& @@ -2711,27 +2712,27 @@ subroutine CNVegMatrix(bounds,num_soilp,filter_soilp,num_actfirep,filter_actfire matrix_ntransfer_acc(iretransn,iretransn) = -matrix_nturnover_retransn_acc(p) do i=1,nvegcpool - if(matrix_ctransfer_acc(i,i) .eq. 0)then - matrix_ctransfer_acc(i,i) = 1.e+36 + if(matrix_ctransfer_acc(i,i) == 0)then + matrix_ctransfer_acc(i,i) = spval end if end do if(use_c13)then do i=1,nvegcpool - if(matrix_c13transfer_acc(i,i) .eq. 0)then - matrix_c13transfer_acc(i,i) = 1.e+36 + if(matrix_c13transfer_acc(i,i) == 0)then + matrix_c13transfer_acc(i,i) = spval end if end do end if if(use_c14)then do i=1,nvegcpool - if(matrix_c14transfer_acc(i,i) .eq. 0)then - matrix_c14transfer_acc(i,i) = 1.e+36 + if(matrix_c14transfer_acc(i,i) == 0)then + matrix_c14transfer_acc(i,i) = spval end if end do end if do i=1,nvegnpool - if(matrix_ntransfer_acc(i,i) .eq. 0)then - matrix_ntransfer_acc(i,i) = 1.e+36 + if(matrix_ntransfer_acc(i,i) == 0)then + matrix_ntransfer_acc(i,i) = spval end if end do From 47839a77229c61555e3b8932927bb54cdc511b27 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 27 Mar 2024 14:39:43 -0600 Subject: [PATCH 027/194] Black reformatting of two files --- cime_config/SystemTests/sspmatrixcn.py | 455 ++++++++++++++----------- cime_config/buildnml | 72 ++-- 2 files changed, 295 insertions(+), 232 deletions(-) diff --git a/cime_config/SystemTests/sspmatrixcn.py b/cime_config/SystemTests/sspmatrixcn.py index 0e0d57e6c2..37d4154121 100644 --- a/cime_config/SystemTests/sspmatrixcn.py +++ b/cime_config/SystemTests/sspmatrixcn.py @@ -14,15 +14,15 @@ """ import shutil, glob, os, sys -if __name__ == '__main__': - CIMEROOT = os.environ.get("CIMEROOT") - if CIMEROOT is None: - CIMEROOT = "../../cime"; +if __name__ == "__main__": + CIMEROOT = os.environ.get("CIMEROOT") + if CIMEROOT is None: + CIMEROOT = "../../cime" - sys.path.append(os.path.join( CIMEROOT, "scripts", "lib")) - sys.path.append(os.path.join( CIMEROOT, "scripts" ) ) + sys.path.append(os.path.join(CIMEROOT, "scripts", "lib")) + sys.path.append(os.path.join(CIMEROOT, "scripts")) else: - from CIME.utils import append_testlog + from CIME.utils import append_testlog from CIME.XML.standard_module_setup import * from CIME.SystemTests.system_tests_common import SystemTestsCommon @@ -31,123 +31,170 @@ logger = logging.getLogger(__name__) + class SSPMATRIXCN(SystemTestsCommon): # Class data nyr_forcing = 2 # Get different integer multiples of the number of forcing years - full = nyr_forcing - twice = 2 * nyr_forcing + full = nyr_forcing + twice = 2 * nyr_forcing thrice = 3 * nyr_forcing # Define the settings that will be used for each step - steps = ["0-AD", "1-SASU", "2-norm" ] - desc = ["Accell-Decomp(AD)-coldstart", "slow-mode Semi-Analytic SpinUp(SASU)", "normal" ] - runtyp = ["startup", "hybrid", "branch" ] - spin = ["on", "sasu", "off" ] - stop_n = [5, thrice, thrice ] - cold = [True, False, False ] - iloop = [-999, -999, -999 ] - sasu = [-999, -999, -999 ] + steps = ["0-AD", "1-SASU", "2-norm"] + desc = [ + "Accell-Decomp(AD)-coldstart", + "slow-mode Semi-Analytic SpinUp(SASU)", + "normal", + ] + runtyp = ["startup", "hybrid", "branch"] + spin = ["on", "sasu", "off"] + stop_n = [5, thrice, thrice] + cold = [True, False, False] + iloop = [-999, -999, -999] + sasu = [-999, -999, -999] def __init__(self, case=None): """ initialize an object interface to the SSPMATRIXCN system test """ - expect ( len(self.steps) == len(self.sasu), "length of steps must be the same as sasu" ) - expect ( len(self.steps) == len(self.spin), "length of steps must be the same as spin" ) - expect ( len(self.steps) == len(self.desc), "length of steps must be the same as desc" ) - expect ( len(self.steps) == len(self.cold), "length of steps must be the same as cold" ) - expect ( len(self.steps) == len(self.runtyp), "length of steps must be the same as runtyp" ) - expect ( len(self.steps) == len(self.iloop), "length of steps must be the same as iloop" ) - expect ( len(self.steps) == len(self.stop_n), "length of steps must be the same as stop_n" ) - - if __name__ != '__main__': - SystemTestsCommon.__init__(self, case) - ystart = int(self._case.get_value("DATM_YR_START")) - yend = int(self._case.get_value("DATM_YR_END")) - self.comp = self._case.get_value("COMP_LND") + expect( + len(self.steps) == len(self.sasu), + "length of steps must be the same as sasu", + ) + expect( + len(self.steps) == len(self.spin), + "length of steps must be the same as spin", + ) + expect( + len(self.steps) == len(self.desc), + "length of steps must be the same as desc", + ) + expect( + len(self.steps) == len(self.cold), + "length of steps must be the same as cold", + ) + expect( + len(self.steps) == len(self.runtyp), + "length of steps must be the same as runtyp", + ) + expect( + len(self.steps) == len(self.iloop), + "length of steps must be the same as iloop", + ) + expect( + len(self.steps) == len(self.stop_n), + "length of steps must be the same as stop_n", + ) + + if __name__ != "__main__": + SystemTestsCommon.__init__(self, case) + ystart = int(self._case.get_value("DATM_YR_START")) + yend = int(self._case.get_value("DATM_YR_END")) + self.comp = self._case.get_value("COMP_LND") else: - self._case = None - self.comp = "clm" - ystart = 2000 - yend = 2001 + self._case = None + self.comp = "clm" + ystart = 2000 + yend = 2001 for n in range(len(self.steps)): - if ( n == 0 ): - expect( self.cold[n] == True, "First step MUST be a cold-start" ) - expect( self.runtyp[n] == "startup", "First step MUST be a startup" ) - else: - expect( self.cold[n] == False, "Other steps must NOT be a cold-start" ) - expect( self.runtyp[n] != "startup", "Other steps MUST NOT be a startup" ) - - if ( self.spin[n] == "sasu" ): - expect( self.cold[n] == False, "SASU step should NOT be a cold-start" ) - if ( self.sasu[n] != -999 ): - expect( self.sasu[n] > 0, "SASU steps must set SASU cycle" ) - expect( self.sasu[n] <= self.nyr_forcing, "SASU cycles can't be greater than a full forcing cycle" ) - - expect( yend-ystart+1 == self.nyr_forcing, "Number of years run over MUST correspond to nyr_forcing" ) + if n == 0: + expect(self.cold[n] == True, "First step MUST be a cold-start") + expect(self.runtyp[n] == "startup", "First step MUST be a startup") + else: + expect(self.cold[n] == False, "Other steps must NOT be a cold-start") + expect(self.runtyp[n] != "startup", "Other steps MUST NOT be a startup") + + if self.spin[n] == "sasu": + expect(self.cold[n] == False, "SASU step should NOT be a cold-start") + if self.sasu[n] != -999: + expect(self.sasu[n] > 0, "SASU steps must set SASU cycle") + expect( + self.sasu[n] <= self.nyr_forcing, + "SASU cycles can't be greater than a full forcing cycle", + ) + + expect( + yend - ystart + 1 == self.nyr_forcing, + "Number of years run over MUST correspond to nyr_forcing", + ) self._testname = "SSPMATRIX" - def check_n( self, n): + def check_n(self, n): "Check if n is within range" - expect( ( (n >= 0) and (n < self.n_steps()) ), "Step number is out of range = " + str(n) ) + expect( + ((n >= 0) and (n < self.n_steps())), + "Step number is out of range = " + str(n), + ) def __logger__(self, n=0): "Log info on this step" - self.check_n( n ) - msg = "Step {}: {}: doing a {} run for {} years".format( self.steps[n], self.runtyp[n], self.desc[n], self.stop_n[n] ) + self.check_n(n) + msg = "Step {}: {}: doing a {} run for {} years".format( + self.steps[n], self.runtyp[n], self.desc[n], self.stop_n[n] + ) logger.info(msg) - logger.info(" spinup type: {}".format( self.spin[n] ) ) - if __name__ != '__main__': - append_testlog(msg) - if ( n+1 < self.n_steps() ): - logger.info(" writing restarts at end of run") - logger.info(" short term archiving is on ") + logger.info(" spinup type: {}".format(self.spin[n])) + if __name__ != "__main__": + append_testlog(msg) + if n + 1 < self.n_steps(): + logger.info(" writing restarts at end of run") + logger.info(" short term archiving is on ") def n_steps(self): "Total number of steps" - return( len(self.steps) ) + return len(self.steps) def total_years(self): "Total number of years needed to do the full spinup" ysum = 0 for nyr in self.stop_n: - ysum = ysum + nyr + ysum = ysum + nyr - return( ysum ) + return ysum def append_user_nl(self, caseroot, n=0): "Append needed settings to the user_nl files" - self.check_n( n ) + self.check_n(n) # For all set output to yearly contents_to_append = "hist_nhtfrq = -8760" - contents_to_append = contents_to_append + ", hist_mfilt = "+str(self.nyr_forcing) + contents_to_append = ( + contents_to_append + ", hist_mfilt = " + str(self.nyr_forcing) + ) # For all but last step turn extra matrix output to off b4last = self.n_steps() - 1 - if ( n < b4last ): - contents_to_append = contents_to_append + ", hist_wrt_matrixcn_diag = .False." + if n < b4last: + contents_to_append = ( + contents_to_append + ", hist_wrt_matrixcn_diag = .False." + ) # For matrix spinup steps, set the matrix spinup and other variables associated with it - if ( self.spin[n] == "sasu" ): - contents_to_append = contents_to_append + ", nyr_forcing = "+str(self.nyr_forcing) - if ( self.sasu[n] != -999 ): - contents_to_append = contents_to_append + ", nyr_sasu = " + str(self.sasu[n]) - if ( self.iloop[n] != -999 ): - contents_to_append = contents_to_append + ", iloop_avg = " + str(self.iloop[n]) + if self.spin[n] == "sasu": + contents_to_append = ( + contents_to_append + ", nyr_forcing = " + str(self.nyr_forcing) + ) + if self.sasu[n] != -999: + contents_to_append = ( + contents_to_append + ", nyr_sasu = " + str(self.sasu[n]) + ) + if self.iloop[n] != -999: + contents_to_append = ( + contents_to_append + ", iloop_avg = " + str(self.iloop[n]) + ) # For cold start, run with matrix off - if ( self.cold[n] ): + if self.cold[n]: contents_to_append = contents_to_append + ", use_matrixcn = .False." contents_to_append = contents_to_append + ", use_soil_matrixcn = .False." # Always append to the end - user_nl_utils.append_to_user_nl_files(caseroot = caseroot, - component = self.comp, - contents = contents_to_append) + user_nl_utils.append_to_user_nl_files( + caseroot=caseroot, component=self.comp, contents=contents_to_append + ) def run_phase(self): "Run phase" @@ -156,77 +203,80 @@ def run_phase(self): orig_case = self._case orig_casevar = self._case.get_value("CASE") - # Get a clone of each step except the last one b4last = self.n_steps() - 1 for n in range(b4last): - # - # Clone the main case, and get it setup for the next step - # - clone_path = "{}.step{}".format(caseroot,self.steps[n]) - if os.path.exists(clone_path): - shutil.rmtree(clone_path) - if ( n > 0 ): - del clone - self._set_active_case(orig_case) - clone = self._case.create_clone(clone_path, keepexe=True) - os.chdir(clone_path) - self._set_active_case(clone) - - self.__logger__(n) - - with clone: - clone.set_value("RUN_TYPE", self.runtyp[n] ) - clone.set_value("STOP_N", self.stop_n[n] ) - - clone.set_value("CLM_ACCELERATED_SPINUP", self.spin[n] ) - - if ( self.cold[n] ): - clone.set_value("CLM_FORCE_COLDSTART", "on" ) - else: - clone.set_value("CLM_FORCE_COLDSTART", "off" ) - - self.append_user_nl( clone_path, n ) - - dout_sr = clone.get_value("DOUT_S_ROOT") - - self._skip_pnl = False - # - # Start up from the previous case - # - rundir = clone.get_value("RUNDIR") - with clone: - if ( n > 0 ): - clone.set_value("GET_REFCASE", False) - expect( "refcase" in locals(), "refcase was NOT previously set" ) - clone.set_value("RUN_REFCASE", refcase ) - expect( "refdate" in locals(), "refdate was NOT previously set" ) - clone.set_value("RUN_STARTDATE", refdate ) - clone.set_value("RUN_REFDATE", refdate ) - for item in glob.glob("{}/*{}*".format(rest_path, refdate)): - linkfile = os.path.join(rundir, os.path.basename(item)) - if os.path.exists(linkfile): - os.remove( linkfile ) - if not os.path.isdir(rundir): - os.makedirs(rundir) - os.symlink(item, linkfile ) - - for item in glob.glob("{}/*rpointer*".format(rest_path)): - shutil.copy(item, rundir) - - # - # Run the case (Archiving on) - # - self._case.flush() - self.run_indv(suffix="step{}".format(self.steps[n]), st_archive=True) - - # - # Get the reference case from this step for the next step - # - refcase = clone.get_value("CASE") - refdate = run_cmd_no_fail(r'ls -1dt {}/rest/*-00000* | head -1 | sed "s/-00000.*//" | sed "s/^.*rest\///"'.format(dout_sr)) - refsec = "00000" - rest_path = os.path.join(dout_sr, "rest", "{}-{}".format(refdate, refsec)) + # + # Clone the main case, and get it setup for the next step + # + clone_path = "{}.step{}".format(caseroot, self.steps[n]) + if os.path.exists(clone_path): + shutil.rmtree(clone_path) + if n > 0: + del clone + self._set_active_case(orig_case) + clone = self._case.create_clone(clone_path, keepexe=True) + os.chdir(clone_path) + self._set_active_case(clone) + + self.__logger__(n) + + with clone: + clone.set_value("RUN_TYPE", self.runtyp[n]) + clone.set_value("STOP_N", self.stop_n[n]) + + clone.set_value("CLM_ACCELERATED_SPINUP", self.spin[n]) + + if self.cold[n]: + clone.set_value("CLM_FORCE_COLDSTART", "on") + else: + clone.set_value("CLM_FORCE_COLDSTART", "off") + + self.append_user_nl(clone_path, n) + + dout_sr = clone.get_value("DOUT_S_ROOT") + + self._skip_pnl = False + # + # Start up from the previous case + # + rundir = clone.get_value("RUNDIR") + with clone: + if n > 0: + clone.set_value("GET_REFCASE", False) + expect("refcase" in locals(), "refcase was NOT previously set") + clone.set_value("RUN_REFCASE", refcase) + expect("refdate" in locals(), "refdate was NOT previously set") + clone.set_value("RUN_STARTDATE", refdate) + clone.set_value("RUN_REFDATE", refdate) + for item in glob.glob("{}/*{}*".format(rest_path, refdate)): + linkfile = os.path.join(rundir, os.path.basename(item)) + if os.path.exists(linkfile): + os.remove(linkfile) + if not os.path.isdir(rundir): + os.makedirs(rundir) + os.symlink(item, linkfile) + + for item in glob.glob("{}/*rpointer*".format(rest_path)): + shutil.copy(item, rundir) + + # + # Run the case (Archiving on) + # + self._case.flush() + self.run_indv(suffix="step{}".format(self.steps[n]), st_archive=True) + + # + # Get the reference case from this step for the next step + # + refcase = clone.get_value("CASE") + refdate = run_cmd_no_fail( + r'ls -1dt {}/rest/*-00000* | head -1 | sed "s/-00000.*//" | sed "s/^.*rest\///"'.format( + dout_sr + ) + ) + refsec = "00000" + rest_path = os.path.join(dout_sr, "rest", "{}-{}".format(refdate, refsec)) # # Last step in original case @@ -239,25 +289,25 @@ def run_phase(self): self._set_active_case(orig_case) self.__logger__(n) self._case.set_value("DOUT_S", False) - self._case.set_value("RUN_TYPE", self.runtyp[n] ) - self._case.set_value("STOP_N", self.stop_n[n] ) + self._case.set_value("RUN_TYPE", self.runtyp[n]) + self._case.set_value("STOP_N", self.stop_n[n]) rundir = self._case.get_value("RUNDIR") self._case.set_value("GET_REFCASE", False) - expect( "refcase" in locals(), "refcase was NOT previously set" ) + expect("refcase" in locals(), "refcase was NOT previously set") self._case.set_value("RUN_REFCASE", refcase) - expect( "refdate" in locals(), "refdate was NOT previously set" ) + expect("refdate" in locals(), "refdate was NOT previously set") self._case.set_value("RUN_REFDATE", refdate) - self._case.set_value("RUN_STARTDATE", refdate ) + self._case.set_value("RUN_STARTDATE", refdate) for item in glob.glob("{}/*{}*".format(rest_path, refdate)): linkfile = os.path.join(rundir, os.path.basename(item)) if os.path.exists(linkfile): - os.remove( linkfile ) - os.symlink(item, linkfile ) + os.remove(linkfile) + os.symlink(item, linkfile) for item in glob.glob("{}/*rpointer*".format(rest_path)): shutil.copy(item, rundir) - self.append_user_nl( clone_path, n ) + self.append_user_nl(clone_path, n) # # Don't need to set COLDSTART or ACCEL_SPINUP # @@ -266,7 +316,8 @@ def run_phase(self): # Run the case (short term archiving is off) # self._case.flush() - self.run_indv( suffix="step{}".format(self.steps[n]), st_archive=False ) + self.run_indv(suffix="step{}".format(self.steps[n]), st_archive=False) + # # Unit testing for above @@ -274,59 +325,57 @@ def run_phase(self): import unittest from CIME.case import Case from CIME.utils import _LessThanFilter -from argparse import RawTextHelpFormatter +from argparse import RawTextHelpFormatter + class test_ssp_matrixcn(unittest.TestCase): + def setUp(self): + self.ssp = SSPMATRIXCN() + + def test_logger(self): + # Test the logger + stream_handler = logging.StreamHandler(sys.stdout) + logger.addHandler(stream_handler) + logger.level = logging.DEBUG + logger.info("nyr_forcing = {}".format(self.ssp.nyr_forcing)) + for n in range(self.ssp.n_steps()): + self.ssp.__logger__(n) + if self.ssp.spin[n] == "sasu": + logger.info(" SASU spinup is .true.") + if self.ssp.sasu[n] != -999: + logger.info(" nyr_sasu = {}".format(self.ssp.sasu[n])) + if self.ssp.iloop[n] != -999: + logger.info(" iloop_avg = {}".format(self.ssp.iloop[n])) + + logger.info("Total number of years {}".format(self.ssp.total_years())) + logger.removeHandler(stream_handler) + + def test_n_steps(self): + self.assertTrue(self.ssp.n_steps() == 3) + + def test_valid_n(self): + for n in range(self.ssp.n_steps()): + self.ssp.check_n(n) + + def test_negative_n(self): + self.assertRaises(SystemExit, self.ssp.check_n, -1) + + def test_n_too_big(self): + self.assertRaises(SystemExit, self.ssp.check_n, self.ssp.n_steps()) + + def test_append_user_nl_step2(self): + ufile = "user_nl_clm" + if not os.path.exists(ufile): + os.mknod(ufile) + else: + expect(0, ufile + " file already exists, not overwritting it") - def setUp( self ): - self.ssp = SSPMATRIXCN() - - def test_logger( self ): - # Test the logger - stream_handler = logging.StreamHandler(sys.stdout) - logger.addHandler(stream_handler) - logger.level = logging.DEBUG - logger.info( "nyr_forcing = {}".format(self.ssp.nyr_forcing) ) - for n in range(self.ssp.n_steps()): - self.ssp.__logger__(n) - if ( self.ssp.spin[n] == "sasu" ): - logger.info( " SASU spinup is .true." ) - if ( self.ssp.sasu[n] != -999 ): - logger.info( " nyr_sasu = {}".format(self.ssp.sasu[n]) ) - if ( self.ssp.iloop[n] != -999 ): - logger.info( " iloop_avg = {}".format(self.ssp.iloop[n]) ) - - logger.info( "Total number of years {}".format( self.ssp.total_years() ) ) - logger.removeHandler(stream_handler) - - def test_n_steps( self ): - self.assertTrue( self.ssp.n_steps() == 3) - - def test_valid_n( self ): - for n in range(self.ssp.n_steps()): - self.ssp.check_n(n) - - def test_negative_n( self ): - self.assertRaises(SystemExit, self.ssp.check_n, -1 ) - - def test_n_too_big( self ): - self.assertRaises(SystemExit, self.ssp.check_n, self.ssp.n_steps() ) - - def test_append_user_nl_step2( self ): - ufile = "user_nl_clm" - if not os.path.exists(ufile): - os.mknod(ufile) - else: - expect( 0, ufile+" file already exists, not overwritting it" ) - - self.ssp.append_user_nl( caseroot=".", n=2) - print( ufile+" for step 2" ) - log = open(ufile, "r").read() - print( log ) - os.remove(ufile) - - -if __name__ == '__main__': - unittest.main() + self.ssp.append_user_nl(caseroot=".", n=2) + print(ufile + " for step 2") + log = open(ufile, "r").read() + print(log) + os.remove(ufile) +if __name__ == "__main__": + unittest.main() diff --git a/cime_config/buildnml b/cime_config/buildnml index 11112b81f0..2f27473732 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -51,24 +51,24 @@ def buildnml(case, caseroot, compname): clm_accelerated_spinup = case.get_value("CLM_ACCELERATED_SPINUP") comp_interface = case.get_value("COMP_INTERFACE") lilac_mode = case.get_value("LILAC_MODE") - if ( comp_interface == "nuopc" ): - yr_start = case.get_value("DATM_YR_START") - yr_end = case.get_value("DATM_YR_END") + if comp_interface == "nuopc": + yr_start = case.get_value("DATM_YR_START") + yr_end = case.get_value("DATM_YR_END") else: - yr_start = case.get_value("DATM_CLMNCEP_YR_START") - yr_end = case.get_value("DATM_CLMNCEP_YR_END") + yr_start = case.get_value("DATM_CLMNCEP_YR_START") + yr_end = case.get_value("DATM_CLMNCEP_YR_END") - if ( yr_start != None and yr_start < 0 ): - yr_start = case.get_value("DATM_CPLHIST_YR_START") - yr_end = case.get_value("DATM_CPLHIST_YR_END") + if yr_start != None and yr_start < 0: + yr_start = case.get_value("DATM_CPLHIST_YR_START") + yr_end = case.get_value("DATM_CPLHIST_YR_END") # For LILAC - if ( yr_start == None or lilac_mode == "on" ): - yr_start = "0" - yr_end = "0" + if yr_start == None or lilac_mode == "on": + yr_start = "0" + yr_end = "0" yr_start = int(yr_start) - yr_end = int(yr_end) + yr_end = int(yr_end) comp_atm = case.get_value("COMP_ATM") lnd_grid = case.get_value("LND_GRID") @@ -117,7 +117,9 @@ def buildnml(case, caseroot, compname): clm_phys = case.get_value("CLM_PHYSICS_VERSION") config_cache_text = _config_cache_template.format(clm_phys=clm_phys) - config_cache_path = os.path.join(caseroot, "Buildconf", compname + "conf", "config_cache.xml") + config_cache_path = os.path.join( + caseroot, "Buildconf", compname + "conf", "config_cache.xml" + ) with open(config_cache_path, "w") as config_cache_file: config_cache_file.write(config_cache_text) @@ -206,22 +208,28 @@ def buildnml(case, caseroot, compname): else: ignore = "-ignore_ic_date" - tuning = "-lnd_tuning_mode %s "%lnd_tuning_mode - + tuning = "-lnd_tuning_mode %s " % lnd_tuning_mode + # # Spinup settings and specifics for SASU spinup # - spinup = "-clm_accelerated_spinup %s "%clm_accelerated_spinup - if ( clm_accelerated_spinup == "sasu" ): - if ( (yr_start != None) and (yr_end != None) ): - nyr = yr_end - yr_start + 1 - if ( (yr_end <= 0) or (yr_start <= 0) ): - logger.error( "ERROR: Year start and end are both negative and should not be" ) - clm_namelist_opts = "nyr_forcing={} {}".format(nyr, clm_namelist_opts) - else: - logger.warning( "WARNING: It does not make sense to do a SASU spinup with a prognostic atmosphere model" ) - logger.warning( " as it expects regular atmosphere forcing that is cycled over" ) - + spinup = "-clm_accelerated_spinup %s " % clm_accelerated_spinup + if clm_accelerated_spinup == "sasu": + if (yr_start != None) and (yr_end != None): + nyr = yr_end - yr_start + 1 + if (yr_end <= 0) or (yr_start <= 0): + logger.error( + "ERROR: Year start and end are both negative and should not be" + ) + clm_namelist_opts = "nyr_forcing={} {}".format(nyr, clm_namelist_opts) + else: + logger.warning( + "WARNING: It does not make sense to do a SASU spinup with a prognostic atmosphere model" + ) + logger.warning( + " as it expects regular atmosphere forcing that is cycled over" + ) + infile = os.path.join(ctsmconf, "namelist") inputdata_file = os.path.join(caseroot, "Buildconf", "ctsm.input_data_list") @@ -234,7 +242,9 @@ def buildnml(case, caseroot, compname): lndfrac_file = os.path.join(lnd_domain_path, lnd_domain_file) lndfrac_setting = "-lnd_frac " + lndfrac_file - config_cache_file = os.path.join(caseroot, "Buildconf", compname + "conf", "config_cache.xml") + config_cache_file = os.path.join( + caseroot, "Buildconf", compname + "conf", "config_cache.xml" + ) # ----------------------------------------------------- # Clear out old data @@ -297,7 +307,9 @@ def buildnml(case, caseroot, compname): break if not os.path.exists(os.path.join(rundir, clm_startfile)): - logger.warning("WARNING: Could NOT find a start file to use using" + clm_startfile) + logger.warning( + "WARNING: Could NOT find a start file to use using" + clm_startfile + ) clm_icfile = "%s = '%s'" % (startfile_type, clm_startfile) else: clm_icfile = "" @@ -308,7 +320,9 @@ def buildnml(case, caseroot, compname): user_nl_file = os.path.join(caseroot, "user_nl_clm" + inst_string) namelist_infile = os.path.join(ctsmconf, "namelist") - create_namelist_infile(case, user_nl_file, namelist_infile, "\n".join(infile_lines)) + create_namelist_infile( + case, user_nl_file, namelist_infile, "\n".join(infile_lines) + ) cmd = os.path.join(lnd_root, "bld", "build-namelist") From 4cef2cc63b6282c1792ef45803cfad33f2dc3737 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 27 Mar 2024 14:45:05 -0600 Subject: [PATCH 028/194] Update .git-blame-ignore-revs --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 4798c37853..2c92251e93 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -32,3 +32,4 @@ d866510188d26d51bcd6d37239283db690af7e82 6fccf682eaf718615407d9bacdd3903b8786a03d 2500534eb0a83cc3aff94b30fb62e915054030bf 78d05967c2b027dc9776a884716597db6ef7f57c +47839a77229c61555e3b8932927bb54cdc511b27 From e79364382b7f6a555a60070c6f84f52366c9c663 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 2 Apr 2024 18:08:20 -0600 Subject: [PATCH 029/194] testlist updates for LGRAIN2 and LREPRSTRUCT tests --- cime_config/testdefs/testlist_clm.xml | 67 ++------------------------- 1 file changed, 4 insertions(+), 63 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 04200b7271..f44a8e84ab 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -3377,9 +3377,9 @@ - + - + @@ -3387,19 +3387,9 @@ - - - - - - - - - - - + - + @@ -3407,26 +3397,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -3436,16 +3406,6 @@ - - - - - - - - - - @@ -3455,16 +3415,6 @@ - - - - - - - - - - @@ -3474,15 +3424,6 @@ - - - - - - - - - From 306d11a6dcb9c16f29fbc3937b1110110a5d436c Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 3 Apr 2024 14:15:58 -0600 Subject: [PATCH 030/194] testlist updates for already existing matrixcn tests --- cime_config/testdefs/testlist_clm.xml | 30 ++++++--------------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index f44a8e84ab..a47d74de5d 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -530,7 +530,7 @@ - + @@ -540,7 +540,7 @@ - + @@ -548,27 +548,9 @@ - - - - - - - - - - - - - - - - - - - + @@ -578,7 +560,7 @@ - + @@ -587,7 +569,7 @@ - + @@ -804,7 +786,7 @@ - + From 99ba6ced5d9fbfcfb42d3b4c4cd253ccc7d72c9c Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 4 Apr 2024 18:05:23 -0600 Subject: [PATCH 031/194] Removed testmod directory not in use --- .../clm/ciso_decStart_monthly_matrixcn_spinup/include_user_mods | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/ciso_decStart_monthly_matrixcn_spinup/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/ciso_decStart_monthly_matrixcn_spinup/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/ciso_decStart_monthly_matrixcn_spinup/include_user_mods deleted file mode 100644 index 442d7afb24..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/ciso_decStart_monthly_matrixcn_spinup/include_user_mods +++ /dev/null @@ -1,2 +0,0 @@ -../decStart -../ciso_monthly_matrixcn_spinup From 45dbe6247da94965e4c37593ca38592f3e25da9e Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 4 Apr 2024 18:16:10 -0600 Subject: [PATCH 032/194] Adding matrixcnOn testmods --- .../testdefs/testmods_dirs/clm/matrixcnOn/include_user_mods | 1 + cime_config/testdefs/testmods_dirs/clm/matrixcnOn/user_nl_clm | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/matrixcnOn/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/matrixcnOn/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/matrixcnOn/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn/include_user_mods new file mode 100644 index 0000000000..fe0e18cf88 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn/include_user_mods @@ -0,0 +1 @@ +../default diff --git a/cime_config/testdefs/testmods_dirs/clm/matrixcnOn/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn/user_nl_clm new file mode 100644 index 0000000000..185d6a2410 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn/user_nl_clm @@ -0,0 +1,3 @@ +hist_wrt_matrixcn_diag = .true. +use_matrixcn = .true. +use_soil_matrixcn = .true. From fef58b6d383fd750233ab4fe64086a738a41f2e2 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 4 Apr 2024 20:23:43 -0600 Subject: [PATCH 033/194] Relax tolerance for truncating small snocan values in CanopyFluxes The default of 1e-13 was letting through some state updates that look like they should have been truncated to 0: each time step, snocan was decreasing by about 12 orders of magnitude. Addresses ESCOMP/CTSM#2444 --- src/biogeophys/CanopyFluxesMod.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/biogeophys/CanopyFluxesMod.F90 b/src/biogeophys/CanopyFluxesMod.F90 index 58334a70c0..a969dc0583 100644 --- a/src/biogeophys/CanopyFluxesMod.F90 +++ b/src/biogeophys/CanopyFluxesMod.F90 @@ -1624,7 +1624,8 @@ subroutine CanopyFluxes(bounds, num_exposedvegp, filter_exposedvegp, ! snocan < rel_epsilon * snocan_baseline will be set to zero ! See NumericsMod for rel_epsilon value call truncate_small_values(fn, filterp, begp, endp, & - snocan_baseline(begp:endp), snocan(begp:endp)) + snocan_baseline(begp:endp), snocan(begp:endp), & + custom_rel_epsilon=1.e-10_r8) if ( use_fates ) then From 0d07eb28518db409863bab811dbc3b7919f967c7 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 8 Apr 2024 16:46:20 -0600 Subject: [PATCH 034/194] 45 new tests with matrixcnOn testmods --- cime_config/testdefs/testlist_clm.xml | 456 +++++++++++++++++++------- 1 file changed, 343 insertions(+), 113 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index a47d74de5d..6056439278 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2,17 +2,23 @@ - + + + + + + + + + - - @@ -21,6 +27,16 @@ + + + + + + + + + + @@ -139,13 +155,21 @@ - + + + + + + + + + @@ -350,13 +374,21 @@ - + + + + + + + + + @@ -378,13 +410,21 @@ - + + + + + + + + + @@ -396,8 +436,6 @@ - - @@ -405,6 +443,15 @@ + + + + + + + + + @@ -501,7 +548,6 @@ - @@ -509,9 +555,17 @@ + + + + + + + + + - @@ -519,15 +573,32 @@ + + + + + + + + + - + + + + + + + + + @@ -675,13 +746,13 @@ - + - + - - + + @@ -693,13 +764,13 @@ - + - + - + @@ -711,9 +782,17 @@ + + + + + + + + + - @@ -721,6 +800,15 @@ + + + + + + + + + @@ -759,12 +847,14 @@ - + - + + + @@ -775,13 +865,13 @@ - + - + - + @@ -820,36 +910,38 @@ - + - + - + + - + - + - + + @@ -961,6 +1053,16 @@ + + + + + + + + + + @@ -972,8 +1074,6 @@ - - @@ -981,6 +1081,15 @@ + + + + + + + + + @@ -1007,6 +1116,15 @@ + + + + + + + + + @@ -1035,6 +1153,15 @@ + + + + + + + + + @@ -1043,6 +1170,15 @@ + + + + + + + + + @@ -1051,27 +1187,26 @@ - + - + - + - + - @@ -1117,14 +1252,6 @@ - - - - - - - - @@ -1133,13 +1260,13 @@ - + - + - + @@ -1238,16 +1365,6 @@ - - - - - - - - - - @@ -1258,14 +1375,14 @@ - + - - + - - + + + @@ -1278,16 +1395,6 @@ - - - - - - - - - - @@ -1446,13 +1553,21 @@ - + + + + + + + + + @@ -1531,10 +1646,6 @@ - - - - @@ -1544,6 +1655,16 @@ + + + + + + + + + + @@ -1619,6 +1740,15 @@ + + + + + + + + + @@ -1647,6 +1777,16 @@ + + + + + + + + + + @@ -1666,15 +1806,6 @@ - - - - - - - - - @@ -1684,13 +1815,13 @@ - + - + - + @@ -1702,13 +1833,13 @@ - + - + - - + + @@ -1762,6 +1893,16 @@ + + + + + + + + + + @@ -1774,7 +1915,6 @@ - @@ -1782,13 +1922,13 @@ - + - + - + @@ -1800,6 +1940,15 @@ + + + + + + + + + @@ -1812,8 +1961,6 @@ - - @@ -1822,6 +1969,16 @@ + + + + + + + + + + @@ -1853,14 +2010,14 @@ - + - + + - - + @@ -1873,6 +2030,16 @@ + + + + + + + + + + @@ -1896,8 +2063,6 @@ - - @@ -1905,6 +2070,16 @@ + + + + + + + + + + @@ -2091,10 +2266,6 @@ - - - - @@ -2104,6 +2275,18 @@ + + + + + + + + + + + + @@ -2170,6 +2353,17 @@ + + + + + + + + + + + @@ -2255,7 +2449,6 @@ - @@ -2263,6 +2456,15 @@ + + + + + + + + + @@ -2427,6 +2629,15 @@ + + + + + + + + + @@ -2756,7 +2967,6 @@ - @@ -2765,6 +2975,16 @@ + + + + + + + + + + @@ -3312,7 +3532,6 @@ - @@ -3322,6 +3541,17 @@ + + + + + + + + + + + From a2fc12b8be573434ef95e23e00efecffc87a6c18 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 11 Apr 2024 12:44:38 -0600 Subject: [PATCH 035/194] Change matrixcnOn tests to Clm51 and remove redundant tests --- cime_config/testdefs/testlist_clm.xml | 95 ++++++++------------------- 1 file changed, 29 insertions(+), 66 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 6056439278..c3bda24655 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -27,7 +27,7 @@ - + @@ -161,7 +161,7 @@ - + @@ -380,7 +380,7 @@ - + @@ -555,7 +555,7 @@ - + @@ -573,7 +573,7 @@ - + @@ -590,7 +590,7 @@ - + @@ -800,7 +800,7 @@ - + @@ -847,10 +847,10 @@ - + - - + + @@ -918,7 +918,7 @@ - + @@ -935,7 +935,7 @@ - + @@ -1081,15 +1081,6 @@ - - - - - - - - - @@ -1116,15 +1107,6 @@ - - - - - - - - - @@ -1153,7 +1135,7 @@ - + @@ -1170,7 +1152,7 @@ - + @@ -1196,7 +1178,7 @@ - + @@ -1260,7 +1242,7 @@ - + @@ -1559,7 +1541,7 @@ - + @@ -1655,16 +1637,6 @@ - - - - - - - - - - @@ -1740,7 +1712,7 @@ - + @@ -1777,7 +1749,7 @@ - + @@ -1815,15 +1787,6 @@ - - - - - - - - - @@ -1893,7 +1856,7 @@ - + @@ -1922,7 +1885,7 @@ - + @@ -1940,7 +1903,7 @@ - + @@ -2030,7 +1993,7 @@ - + @@ -2070,7 +2033,7 @@ - + @@ -2275,7 +2238,7 @@ - + @@ -2456,7 +2419,7 @@ - + @@ -2629,7 +2592,7 @@ - + @@ -2975,7 +2938,7 @@ - + @@ -3541,7 +3504,7 @@ - + From bd7d031760665a5cdc920ef61c2a519bb5116b6e Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 11 Apr 2024 14:51:17 -0600 Subject: [PATCH 036/194] Rename failing Clm51 tests back to Clm50 due to missing compsets --- cime_config/testdefs/testlist_clm.xml | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index b730b62720..54c9d0fb62 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -27,7 +27,7 @@ - + @@ -199,7 +199,7 @@ - + @@ -418,7 +418,7 @@ - + @@ -611,7 +611,7 @@ - + @@ -628,7 +628,7 @@ - + @@ -956,7 +956,7 @@ - + @@ -973,7 +973,7 @@ - + @@ -1173,7 +1173,7 @@ - + @@ -1190,7 +1190,7 @@ - + @@ -1750,7 +1750,7 @@ - + @@ -1787,7 +1787,7 @@ - + @@ -1894,7 +1894,7 @@ - + @@ -2071,7 +2071,7 @@ - + @@ -2457,7 +2457,7 @@ - + From 5d0a037a71c8e97e6f7e4c12535715bfbc16722d Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 11 Apr 2024 19:45:40 -0600 Subject: [PATCH 037/194] Remove a clm/FatesCold--clm/matrixcnOn test as invalid --- cime_config/testdefs/testlist_clm.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 54c9d0fb62..aea06d7f1e 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2976,16 +2976,6 @@ - - - - - - - - - - From 48b52dc5179a4ba3388a911a8aea7f1c682ce62c Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 17 Apr 2024 17:08:50 -0600 Subject: [PATCH 038/194] Point FATES external at Charlie's LUH2 branch. --- Externals_CLM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index dc1bc3f0e7..1494217277 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.70.0_api.32.0.0 +repo_url = https://github.com/ckoven/fates +hash = d37d9733b5970dfe67a required = True [externals_description] From 526bc19b068546e4d92828cf44c86596010e9482 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 17 Apr 2024 15:39:56 -0600 Subject: [PATCH 039/194] Update CTSM to work with FATES LUH2. Some issues remain. --- bld/CLMBuildNamelist.pm | 26 +- bld/namelist_files/namelist_defaults_ctsm.xml | 10 +- .../namelist_definition_ctsm.xml | 26 +- bld/unit_testers/build-namelist_test.pl | 1 + .../testmods_dirs/clm/Fates/user_nl_clm | 2 +- .../clm/FatesColdLogging/user_nl_clm | 1 + .../usermods_dirs/fates_sp/user_nl_clm | 2 +- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 80 +++++- src/main/clm_instMod.F90 | 3 +- src/main/clm_varctl.F90 | 4 +- src/main/controlMod.F90 | 14 +- src/utils/clmfates_interfaceMod.F90 | 227 ++++++++++++++++-- 12 files changed, 351 insertions(+), 45 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 4df42d5e74..bcf68a8d61 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -783,7 +783,7 @@ sub setup_cmdl_fates_mode { # dis-allow fates specific namelist items with non-fates runs my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_cohort_age_tracking","use_fates_inventory_init","use_fates_fixed_biogeog", - "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","use_fates_logging", + "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries" ); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { @@ -4370,7 +4370,7 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_inventory_init","use_fates_fixed_biogeog","use_fates_nocomp","fates_seeddisp_cadence", - "use_fates_logging","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage","use_fates_luh" ); + "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage","use_fates_luh" ); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); @@ -4426,6 +4426,28 @@ sub setup_logic_fates { } } } + + # Check fates_harvest_mode compatibility + my $var = "fates_harvest_mode"; + if ( defined($nl->get_value($var)) ) { + # using fates_harvest_mode with CLM landuse driver data - for user convienence + # if ( $nl->get_value($var) == 2) { + # # Make sure that do_harvest is set to true + # if ( ! &value_is_true($nl->get_value('do_harvest')) ) { + # fatal_error("do_harvest must be true when $var is equal to 2" ); + # } + # using fates_harvest mode with raw luh2 harvest data + if ( $nl->get_value($var) > 2) { + # Make sure that use_fates_luh is true when using raw fates luh2 harvest data + if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { + fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); + } + # do_harvest can not be on if we are using the raw fates luh2 harvest data + if ( &value_is_true($nl->get_value('do_harvest')) ) { + fatal_error("do_harvest can not be true when $var is greater than 2" ); + } + } + } } } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 7891361238..bc962d1b0f 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1572,11 +1572,14 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 lnd/clm2/surfdata_map/release-clm5.0.18/landuse.timeseries_10x15_SSP5-3.4_16pfts_Irrig_CMIP6_simyr1850-2100_c190228.nc - + lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc + +lnd/clm2/surfdata_map/fates-sci.1.73.0_api.33.0.0/fates_landuse_pft_map_4x5_240206.nc + lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc @@ -2756,14 +2759,17 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 0 +0 .false. .false. .false. .false. .false. -.false. .false. .false. +.false. +.true. +.true. .false. 1 0 diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index b672b43125..fa2d83a3c9 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -734,10 +734,15 @@ Toggle to turn on no competition mode (only relevant if FATES is being used). Toggle to turn on FATES satellite phenology mode (only relevant if FATES is being used). - -Toggle to turn on the logging module -(Only relevant if FATES is on) + +Set FATES harvesting mode by setting fates_harvest_mode > 0. +Allowed values are: + 0 : no fates harvesting of any kind + 1 : fates logging via fates logging event codes (see fates parameter file) only + 2 : fates harvest driven by CLM landuse timeseries data (dynHarvestMod) + 3 : fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) + 4 : fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) If TRUE, enable use of land use harmonization (LUH) state and transition data from luh_timeseries file. +This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harvest +data (fates_harvest_mode >= 3) (Also, only valid for use_fates = true and is incompatible with transient runs currently.) + +If TRUE, ignore the land-use state vector and transitions, and assert that all lands +are primary, and that there is no harvest. + + @@ -793,6 +806,11 @@ types to vary over time. (Only relevant if FATES is on). + +Full pathname of fates landuse x pft data map. + + Toggle to turn on the LUNA model, to effect Photosynthesis by leaf Nitrogen diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 9b579dd9ce..899bd10b9c 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1046,6 +1046,7 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, + # TODO SSR: Replace this with fates_harvest_mode "useloggingButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", namelst=>"use_fates_logging=.true.", GLC_TWO_WAY_COUPLING=>"FALSE", diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm index 406fb598f6..91df3e2e61 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -16,7 +16,7 @@ hist_fincl1 = 'FATES_NCOHORTS', 'FATES_TRIMMING', 'FATES_AREA_PLANTS', 'FATES_SAPWOODC', 'FATES_LEAFC', 'FATES_FROOTC', 'FATES_REPROC', 'FATES_STRUCTC', 'FATES_NONSTRUCTC', 'FATES_VEGC_ABOVEGROUND', 'FATES_CANOPY_VEGC', 'FATES_USTORY_VEGC', 'FATES_PRIMARY_PATCHFUSION_ERR', -'FATES_HARVEST_CARBON_FLUX', 'FATES_DISTURBANCE_RATE_FIRE', +'FATES_HARVEST_WOODPROD_C_FLUX', 'FATES_DISTURBANCE_RATE_FIRE', 'FATES_DISTURBANCE_RATE_LOGGING', 'FATES_DISTURBANCE_RATE_TREEFALL', 'FATES_STOMATAL_COND', 'FATES_LBLAYER_COND', 'FATES_NPP', 'FATES_GPP', 'FATES_AUTORESP', 'FATES_GROWTH_RESP', 'FATES_MAINT_RESP', 'FATES_GPP_CANOPY', diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm index 3b74a4fd37..5f457f3f1c 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm @@ -1 +1,2 @@ +! TODO SSR: Replace this with fates_harvest_mode use_fates_logging= .true. diff --git a/cime_config/usermods_dirs/fates_sp/user_nl_clm b/cime_config/usermods_dirs/fates_sp/user_nl_clm index 093ecd7eda..37da8d1c67 100644 --- a/cime_config/usermods_dirs/fates_sp/user_nl_clm +++ b/cime_config/usermods_dirs/fates_sp/user_nl_clm @@ -22,7 +22,7 @@ hist_fexcl1 = 'FATES_TRIMMING', 'FATES_COLD_STATUS', 'FATES_GDD', 'FATES_NCHILLD 'FATES_SAPWOODC', 'FATES_FROOTC', 'FATES_REPROC', 'FATES_STRUCTC', 'FATES_NONSTRUCTC', 'FATES_VEGC_ABOVEGROUND', 'FATES_CANOPY_VEGC', 'FATES_USTORY_VEGC', 'FATES_PRIMARY_PATCHFUSION_ERR', 'FATES_DISTURBANCE_RATE_FIRE', 'FATES_DISTURBANCE_RATE_LOGGING', 'FATES_DISTURBANCE_RATE_TREEFALL', - 'FATES_HARVEST_CARBON_FLUX', 'FATES_GPP_CANOPY', 'FATES_AUTORESP_CANOPY', + 'FATES_HARVEST_WOODPROD_C_FLUX', 'FATES_GPP_CANOPY', 'FATES_AUTORESP_CANOPY', 'FATES_GPP_USTORY', 'FATES_AUTORESP_USTORY', 'FATES_CROWNAREA_CL', 'FATES_DEMOTION_CARBONFLUX', 'FATES_PROMOTION_CARBONFLUX', 'FATES_MORTALITY_CFLUX_CANOPY', 'FATES_MORTALITY_CFLUX_USTORY', 'FATES_DDBH_CANOPY_SZ', 'FATES_DDBH_USTORY_SZ', 'FATES_BASALAREA_SZ', diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index 45f4340d6a..4f326d82a5 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -26,13 +26,39 @@ module dynFATESLandUseChangeMod ! Landuse state at beginning of year (fraction of gridcell), landuse state name x gridcell real(r8), allocatable, public :: landuse_states(:,:) + ! TODO SSR: Ask Charlie for description to go here + real(r8), allocatable, public :: landuse_harvest(:,:) + ! Number of landuse transition and state names integer, public, parameter :: num_landuse_transition_vars = 108 integer, public, parameter :: num_landuse_state_vars = 12 + integer, public, parameter :: num_landuse_harvest_vars = 5 + + ! Define the fates landuse namelist mode switch values + integer, public, parameter :: fates_harvest_no_logging = 0 + integer, public, parameter :: fates_harvest_logging_only = 1 + integer, public, parameter :: fates_harvest_clmlanduse = 2 + integer, public, parameter :: fates_harvest_luh_area = 3 + integer, public, parameter :: fates_harvest_luh_mass = 4 + + ! Define landuse harvest unit integer representation + integer, public, parameter :: landuse_harvest_area_units = 1 + integer, public, parameter :: landuse_harvest_mass_units = 2 + integer, public :: landuse_harvest_units ! landuse filename type(dyn_file_type), target :: dynFatesLandUse_file + ! LUH2 raw wood harvest area fraction + character(len=10), target :: landuse_harvest_area_varnames(num_landuse_harvest_vars) = & + [character(len=10) :: 'primf_harv', 'primn_harv', 'secmf_harv', 'secyf_harv', 'secnf_harv'] + + ! LUH2 raw wood harvest biomass carbon + character(len=10), target :: landuse_harvest_mass_varnames(num_landuse_harvest_vars) = & + [character(len=10) :: 'primf_bioh', 'primn_bioh', 'secmf_bioh', 'secyf_bioh', 'secnf_bioh'] + + character(len=10), public, pointer :: landuse_harvest_varnames(:) => null() + ! Land use name arrays character(len=5), public, parameter :: landuse_state_varnames(num_landuse_state_vars) = & [character(len=5) :: 'primf','primn','secdf','secdn','pastr','range', & @@ -64,8 +90,9 @@ module dynFATESLandUseChangeMod 'c3nfx_to_c3ann','c3nfx_to_c4ann','c3nfx_to_c3per','c3nfx_to_c4per', & 'c3nfx_to_secdf','c3nfx_to_secdn','c3nfx_to_pastr','c3nfx_to_range','c3nfx_to_urban'] - type(dyn_var_time_uninterp_type) :: landuse_transition_vars(num_landuse_transition_vars) ! value of each landuse variable - type(dyn_var_time_uninterp_type) :: landuse_state_vars(num_landuse_state_vars) ! value of each landuse variable + type(dyn_var_time_uninterp_type) :: landuse_transition_vars(num_landuse_transition_vars) ! value of each transitions variable + type(dyn_var_time_uninterp_type) :: landuse_state_vars(num_landuse_state_vars) ! value of each state variable + type(dyn_var_time_uninterp_type) :: landuse_harvest_vars(num_landuse_harvest_vars) ! value of each harvest variable public :: dynFatesLandUseInit public :: dynFatesLandUseInterp @@ -79,14 +106,14 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) ! Initialize data structures for land use information. ! !USES: - use clm_varctl , only : use_cn, use_fates_luh + use clm_varctl , only : use_cn, use_fates_luh, fates_harvest_mode use dynVarTimeUninterpMod , only : dyn_var_time_uninterp_type use dynTimeInfoMod , only : YEAR_POSITION_START_OF_TIMESTEP use dynTimeInfoMod , only : YEAR_POSITION_END_OF_TIMESTEP ! !ARGUMENTS: type(bounds_type), intent(in) :: bounds ! proc-level bounds - character(len=*) , intent(in) :: landuse_filename ! name of file containing land use information + character(len=*) , intent(in) :: landuse_filename ! name of file containing landuse timeseries information (fates luh2) ! !LOCAL VARIABLES integer :: varnum, i ! counter for harvest variables @@ -111,17 +138,23 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) if (ier /= 0) then call endrun(msg=' allocation error for landuse_transitions'//errMsg(__FILE__, __LINE__)) end if + allocate(landuse_harvest(num_landuse_harvest_vars,bounds%begg:bounds%endg),stat=ier) + if (ier /= 0) then + call endrun(msg=' allocation error for landuse_harvest'//errMsg(__FILE__, __LINE__)) + end if + ! Initialize the states, transitions and harvest mapping percentages as zero by default landuse_states = 0._r8 landuse_transitions = 0._r8 + landuse_harvest = 0._r8 if (use_fates_luh) then - ! Generate the dyn_file_type object. Note that the land use data being read in is for the - ! transitions occuring within the current year + ! Generate the dyn_file_type object. + ! Start calls get_prev_date, whereas end calls get_curr_date dynFatesLandUse_file = dyn_file_type(landuse_filename, YEAR_POSITION_END_OF_TIMESTEP) - ! Get initial land use data + ! Get initial land use data from the fates luh2 timeseries dataset num_points = (bounds%endg - bounds%begg + 1) landuse_shape(1) = num_points ! Does this need an explicit array shape to be passed to the constructor? do varnum = 1, num_landuse_transition_vars @@ -136,6 +169,28 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) dim1name=grlnd, conversion_factor=1.0_r8, & do_check_sums_equal_1=.false., data_shape=landuse_shape) end do + + ! Get the harvest rate data from the fates luh2 timeseries dataset if enabled + if (fates_harvest_mode .ge. fates_harvest_luh_area ) then + + ! change the harvest varnames being used depending on the mode selected + if (fates_harvest_mode .eq. fates_harvest_luh_area ) then + landuse_harvest_varnames => landuse_harvest_area_varnames + landuse_harvest_units = landuse_harvest_area_units + elseif (fates_harvest_mode .eq. fates_harvest_luh_mass ) then + landuse_harvest_varnames => landuse_harvest_mass_varnames + landuse_harvest_units = landuse_harvest_mass_units + else + call endrun(msg=' undefined fates harvest mode selected'//errMsg(__FILE__, __LINE__)) + end if + + do varnum = 1, num_landuse_harvest_vars + landuse_harvest_vars(varnum) = dyn_var_time_uninterp_type( & + dyn_file=dynFatesLandUse_file, varname=landuse_harvest_varnames(varnum), & + dim1name=grlnd, conversion_factor=1.0_r8, & + do_check_sums_equal_1=.false., data_shape=landuse_shape) + end do + end if end if ! Since fates needs state data during initialization, make sure to call @@ -159,7 +214,7 @@ subroutine dynFatesLandUseInterp(bounds, init_state) ! !USES: use dynTimeInfoMod , only : time_info_type - use clm_varctl , only : use_cn + use clm_varctl , only : use_cn, fates_harvest_mode ! !ARGUMENTS: type(bounds_type), intent(in) :: bounds ! proc-level bounds @@ -181,13 +236,14 @@ subroutine dynFatesLandUseInterp(bounds, init_state) init_flag = init_state end if - ! Get the current year + ! Get the data for the current year call dynFatesLandUse_file%time_info%set_current_year() if (dynFatesLandUse_file%time_info%is_before_time_series() .and. .not.(init_flag)) then ! Reset the land use transitions to zero for safety landuse_transitions(1:num_landuse_transition_vars,bounds%begg:bounds%endg) = 0._r8 landuse_states(1:num_landuse_state_vars,bounds%begg:bounds%endg) = 0._r8 + landuse_harvest(1:num_landuse_harvest_vars,bounds%begg:bounds%endg) = 0._r8 else ! Loop through all variables on the data file and put data into the temporary array ! then update the global state and transitions array. @@ -200,6 +256,12 @@ subroutine dynFatesLandUseInterp(bounds, init_state) call landuse_state_vars(varnum)%get_current_data(this_data) landuse_states(varnum,bounds%begg:bounds%endg) = this_data(bounds%begg:bounds%endg) end do + if (fates_harvest_mode .ge. fates_harvest_luh_area ) then + do varnum = 1, num_landuse_harvest_vars + call landuse_harvest_vars(varnum)%get_current_data(this_data) + landuse_harvest(varnum,bounds%begg:bounds%endg) = this_data(bounds%begg:bounds%endg) + end do + end if deallocate(this_data) end if diff --git a/src/main/clm_instMod.F90 b/src/main/clm_instMod.F90 index 1ca450b48d..830dcfcca7 100644 --- a/src/main/clm_instMod.F90 +++ b/src/main/clm_instMod.F90 @@ -200,6 +200,7 @@ subroutine clm_instInit(bounds) use SoilWaterRetentionCurveFactoryMod , only : create_soil_water_retention_curve use decompMod , only : get_proc_bounds use BalanceCheckMod , only : GetBalanceCheckSkipSteps + use clm_varctl , only : flandusepftdat ! ! !ARGUMENTS type(bounds_type), intent(in) :: bounds ! processor bounds @@ -436,7 +437,7 @@ subroutine clm_instInit(bounds) ! Initialize the Functionaly Assembled Terrestrial Ecosystem Simulator (FATES) ! if (use_fates) then - call clm_fates%Init(bounds) + call clm_fates%Init(bounds, flandusepftdat) end if deallocate (h2osno_col) diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index e0d142bffd..9ab6c631c7 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -302,7 +302,7 @@ module clm_varctl ! > 1 for external data (lightning and/or anthropogenic ignitions) ! see bld/namelist_files/namelist_definition_clm4_5.xml for details logical, public :: use_fates_tree_damage = .false. ! true => turn on tree damage module - logical, public :: use_fates_logging = .false. ! true => turn on logging module + integer, public :: fates_harvest_mode = 0 ! 0 for no harvest/logging; 1-4 for harvest mode options logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking logical, public :: use_fates_ed_st3 = .false. ! true => static stand structure @@ -311,7 +311,9 @@ module clm_varctl logical, public :: use_fates_fixed_biogeog = .false. ! true => use fixed biogeography mode logical, public :: use_fates_nocomp = .false. ! true => use no comopetition mode logical, public :: use_fates_luh = .false. ! true => use FATES landuse data mode + logical, public :: use_fates_potentialveg = .false. ! true => FATES potential veg only character(len=256), public :: fluh_timeseries = '' ! filename for fates landuse timeseries data + character(len=256), public :: flandusepftdat = '' ! filename for fates landuse x pft data character(len=256), public :: fates_inventory_ctrl_filename = '' ! filename for inventory control ! FATES SP AND FATES BGC are MUTUTALLY EXCLUSIVE, THEY CAN'T BOTH BE ON diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index 44efec4eeb..196bc141ff 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -222,7 +222,7 @@ subroutine control_init(dtime) ! FATES Flags namelist /clm_inparm/ fates_paramfile, use_fates, & - fates_spitfire_mode, use_fates_logging, & + fates_spitfire_mode, fates_harvest_mode, & use_fates_planthydro, use_fates_ed_st3, & use_fates_cohort_age_tracking, & use_fates_ed_prescribed_phys, & @@ -231,7 +231,9 @@ subroutine control_init(dtime) use_fates_nocomp, & use_fates_sp, & use_fates_luh, & + use_fates_potentialveg, & fluh_timeseries, & + flandusepftdat, & fates_inventory_ctrl_filename, & fates_parteh_mode, & fates_seeddisp_cadence, & @@ -772,7 +774,7 @@ subroutine control_spmd() call mpi_bcast (for_testing_allow_interp_non_ciso_to_ciso, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (fates_spitfire_mode, 1, MPI_INTEGER, 0, mpicom, ier) - call mpi_bcast (use_fates_logging, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (fates_harvest_mode, 1, MPI_INTEGER, 0, mpicom, ier) call mpi_bcast (use_fates_planthydro, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_tree_damage, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_cohort_age_tracking, 1, MPI_LOGICAL, 0, mpicom, ier) @@ -783,10 +785,12 @@ subroutine control_spmd() call mpi_bcast (use_fates_nocomp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_sp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_luh, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (use_fates_potentialveg, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_bgc, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (fates_inventory_ctrl_filename, len(fates_inventory_ctrl_filename), MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (fates_paramfile, len(fates_paramfile) , MPI_CHARACTER, 0, mpicom, ier) - call mpi_bcast (fluh_timeseries, len(fates_paramfile) , MPI_CHARACTER, 0, mpicom, ier) + call mpi_bcast (fluh_timeseries, len(fluh_timeseries) , MPI_CHARACTER, 0, mpicom, ier) + call mpi_bcast (flandusepftdat, len(flandusepftdat) , MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (fates_parteh_mode, 1, MPI_INTEGER, 0, mpicom, ier) call mpi_bcast (fates_seeddisp_cadence, 1, MPI_INTEGER, 0, mpicom, ier) @@ -1144,7 +1148,7 @@ subroutine control_print () write(iulog, *) ' use_fates = ', use_fates if (use_fates) then write(iulog, *) ' fates_spitfire_mode = ', fates_spitfire_mode - write(iulog, *) ' use_fates_logging = ', use_fates_logging + write(iulog, *) ' fates_harvest_mode = ', fates_harvest_mode write(iulog, *) ' fates_paramfile = ', fates_paramfile write(iulog, *) ' fates_parteh_mode = ', fates_parteh_mode write(iulog, *) ' use_fates_planthydro = ', use_fates_planthydro @@ -1157,7 +1161,9 @@ subroutine control_print () write(iulog, *) ' use_fates_nocomp = ', use_fates_nocomp write(iulog, *) ' use_fates_sp = ', use_fates_sp write(iulog, *) ' use_fates_luh= ', use_fates_luh + write(iulog, *) ' use_fates_potentialveg = ', use_fates_potentialveg write(iulog, *) ' fluh_timeseries = ', trim(fluh_timeseries) + write(iulog, *) ' flandusepftdat = ', trim(flandusepftdat) write(iulog, *) ' fates_seeddisp_cadence = ', fates_seeddisp_cadence write(iulog, *) ' fates_seeddisp_cadence: 0, 1, 2, 3 => off, daily, monthly, or yearly dispersal' write(iulog, *) ' fates_inventory_ctrl_filename = ', trim(fates_inventory_ctrl_filename) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 83d7186021..3f84a28508 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -54,12 +54,14 @@ module CLMFatesInterfaceMod use clm_varctl , only : use_fates_cohort_age_tracking use clm_varctl , only : use_fates_ed_st3 use clm_varctl , only : use_fates_ed_prescribed_phys - use clm_varctl , only : use_fates_logging + use clm_varctl , only : fates_harvest_mode use clm_varctl , only : use_fates_inventory_init use clm_varctl , only : use_fates_fixed_biogeog use clm_varctl , only : use_fates_nocomp use clm_varctl , only : use_fates_sp use clm_varctl , only : use_fates_luh + use clm_varctl , only : use_fates_potentialveg + use clm_varctl , only : flandusepftdat use clm_varctl , only : fates_seeddisp_cadence use clm_varctl , only : fates_inventory_ctrl_filename use clm_varctl , only : use_nitrif_denitrif @@ -180,6 +182,12 @@ module CLMFatesInterfaceMod use dynFATESLandUseChangeMod, only : landuse_transitions, landuse_states use dynFATESLandUseChangeMod, only : landuse_transition_varnames, landuse_state_varnames use dynFATESLandUseChangeMod, only : dynFatesLandUseInterp + use dynFATESLandUseChangeMod, only : num_landuse_harvest_vars + use dynFATESLandUseChangeMod, only : fates_harvest_no_logging + use dynFATESLandUseChangeMod, only : fates_harvest_luh_area + use dynFATESLandUseChangeMod, only : landuse_harvest + use dynFATESLandUseChangeMod, only : landuse_harvest_units + use dynFATESLandUseChangeMod, only : landuse_harvest_varnames implicit none @@ -272,6 +280,8 @@ module CLMFatesInterfaceMod character(len=*), parameter, private :: sourcefile = & __FILE__ + integer, parameter :: num_landuse_pft_vars = 4 + public :: CLMFatesGlobals1 public :: CLMFatesGlobals2 @@ -384,8 +394,10 @@ subroutine CLMFatesGlobals2() integer :: pass_cohort_age_tracking integer :: pass_tree_damage integer :: pass_use_luh + integer :: pass_use_potentialveg integer :: pass_num_luh_states integer :: pass_num_luh_transitions + integer :: pass_lupftdat call t_startf('fates_globals2') @@ -477,7 +489,7 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_ed_st3',ival=pass_ed_st3) - if(use_fates_logging) then + if (fates_harvest_mode > fates_harvest_no_logging) then pass_logging = 1 else pass_logging = 0 @@ -505,8 +517,8 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking) - ! check fates logging namelist value first because hlm harvest overrides it - if(use_fates_logging) then + ! check fates logging namelist value first because hlm harvest can override it + if (fates_harvest_mode > fates_harvest_no_logging) then pass_logging = 1 else pass_logging = 0 @@ -521,23 +533,53 @@ subroutine CLMFatesGlobals2() pass_num_lu_harvest_cats = 0 end if - call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) - call set_fates_ctrlparms('num_lu_harvest_cats',ival=pass_num_lu_harvest_cats) - call set_fates_ctrlparms('use_logging',ival=pass_logging) - if(use_fates_luh) then pass_use_luh = 1 pass_num_luh_states = num_landuse_state_vars pass_num_luh_transitions = num_landuse_transition_vars + + ! Do not set harvest passing variables to zero not in luh harvest modes + ! as the user may want to use the CLM landuse harvest with luh2 transitions + if(fates_harvest_mode >= fates_harvest_luh_area) then + ! End the run if do_harvest is true with this run mode. + ! This should be caught be the build namelist. + if(get_do_harvest()) then + call endrun(msg="do_harvest and fates_harvest_mode using luh2 harvest data are incompatible"//& + errmsg(sourcefile, __LINE__)) + else + pass_lu_harvest = 1 + end if + end if else pass_use_luh = 0 pass_num_luh_states = 0 pass_num_luh_transitions = 0 end if + call set_fates_ctrlparms('use_luh2',ival=pass_use_luh) call set_fates_ctrlparms('num_luh2_states',ival=pass_num_luh_states) call set_fates_ctrlparms('num_luh2_transitions',ival=pass_num_luh_transitions) + if ( use_fates_potentialveg ) then + pass_use_potentialveg = 1 + else + pass_use_potentialveg = 0 + end if + call set_fates_ctrlparms('use_fates_potentialveg',ival=pass_use_potentialveg) + + if(flandusepftdat /= '') then + pass_lupftdat = 1 + else + pass_lupftdat = 0 + end if + call set_fates_ctrlparms('use_landusepft_data',ival=pass_lupftdat) + + ! Wait to set the harvest and logging variables after checking get_do_harvest + ! and fates_harvest_modes + call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) + call set_fates_ctrlparms('num_lu_harvest_cats',ival=pass_num_lu_harvest_cats) + call set_fates_ctrlparms('use_logging',ival=pass_logging) + if(use_fates_inventory_init) then pass_inventory_init = 1 else @@ -585,7 +627,7 @@ end subroutine CLMFatesTimesteps ! ==================================================================================== - subroutine init(this, bounds_proc ) + subroutine init(this, bounds_proc, flandusepftdat) ! --------------------------------------------------------------------------------- ! This initializes the hlm_fates_interface_type @@ -614,6 +656,7 @@ subroutine init(this, bounds_proc ) ! Input Arguments class(hlm_fates_interface_type), intent(inout) :: this type(bounds_type),intent(in) :: bounds_proc + character(len=*), intent(in) :: flandusepftdat ! local variables integer :: nclumps ! Number of threads @@ -631,6 +674,9 @@ subroutine init(this, bounds_proc ) integer :: ndecomp integer :: numg + real(r8), allocatable :: landuse_pft_map(:,:,:) + real(r8), allocatable :: landuse_bareground(:) + ! Initialize the FATES communicators with the HLM ! This involves to stages ! 1) allocate the vectors @@ -663,6 +709,13 @@ subroutine init(this, bounds_proc ) write(iulog,*) 'clm_fates%init(): allocating for ',nclumps,' threads' end if + ! Retrieve the landuse x pft static data if the file is present + if (flandusepftdat /= '') then + call GetLandusePFTData(bounds_proc, flandusepftdat, landuse_pft_map, landuse_bareground) + end if + + nclumps = get_proc_clumps() + allocate(copy_fates_var(bounds_proc%begc:bounds_proc%endc)) copy_fates_var(:) = .false. @@ -767,18 +820,26 @@ subroutine init(this, bounds_proc ) this%fates(nc)%sites(s)%lat = grc%latdeg(g) this%fates(nc)%sites(s)%lon = grc%londeg(g) - this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 - ! initialize static layers for reduced complexity FATES versions from HLM - ! maybe make this into a subroutine of it's own later. - do m = surfpft_lb,surfpft_ub - ft = m - surfpft_lb - this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) - end do + ! Transfer the landuse x pft data to fates via bc_in if file is given + if (flandusepftdat /= '') then + this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars) + this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g) + end if - if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then - write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s)%pft_areafrac(:)) - 1.0_r8 - call endrun(msg=errMsg(sourcefile, __LINE__)) - end if + if (flandusepftdat == '') then + ! initialize static layers for reduced complexity FATES versions from HLM + ! maybe make this into a subroutine of it's own later. + this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 + do m = surfpft_lb,surfpft_ub + ft = m - surfpft_lb + this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) + end do + + if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then + write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s) %pft_areafrac(:)) - 1.0_r8 + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + end if end do !site ! Initialize site-level static quantities dictated by the HLM @@ -820,6 +881,12 @@ subroutine init(this, bounds_proc ) ! Fire data to send to FATES call create_fates_fire_data_method( this%fates_fire_data_method ) + ! deallocate the local landuse x pft array + if (flandusepftdat /= '') then + deallocate(landuse_pft_map) + deallocate(landuse_bareground) + end if + call t_stopf('fates_init') end subroutine init @@ -1087,6 +1154,12 @@ subroutine dynamics_driv(this, nc, bounds_clump, & this%fates(nc)%bc_in(s)%hlm_luh_state_names = landuse_state_varnames this%fates(nc)%bc_in(s)%hlm_luh_transitions = landuse_transitions(:,g) this%fates(nc)%bc_in(s)%hlm_luh_transition_names = landuse_transition_varnames + + if (fates_harvest_mode >= fates_harvest_luh_area) then + this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) + this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames + this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units + end if end if end do @@ -2033,6 +2106,12 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & this%fates(nc)%bc_in(s)%hlm_luh_state_names = landuse_state_varnames this%fates(nc)%bc_in(s)%hlm_luh_transitions = landuse_transitions(:,g) this%fates(nc)%bc_in(s)%hlm_luh_transition_names = landuse_transition_varnames + + if (fates_harvest_mode >= fates_harvest_luh_area ) then + this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) + this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames + this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units + end if end if end do @@ -3646,6 +3725,114 @@ subroutine GetAndSetTime() end subroutine GetAndSetTime + ! ====================================================================================== + + subroutine GetLandusePFTData(bounds, landuse_pft_file, landuse_pft_map, landuse_bareground) + + ! !DESCRIPTION: + ! Read in static landuse x pft file + + ! !USES: + use fileutils , only : getfil + use ncdio_pio , only : file_desc_t, ncd_io, ncd_inqdlen + use ncdio_pio , only : ncd_pio_openfile, ncd_pio_closefile + use decompMod , only : BOUNDS_LEVEL_PROC + use clm_varcon, only : grlnd + use FatesConstantsMod, only : fates_unset_r8 + + + ! !ARGUMENTS: + type(bounds_type), intent(in) :: bounds ! proc-level bounds + character(len=*) , intent(in) :: landuse_pft_file ! name of file containing static landuse x pft information + real(r8), allocatable, intent(inout) :: landuse_pft_map(:,:,:) + real(r8), allocatable, intent(inout) :: landuse_bareground(:) + + ! !LOCAL VARIABLES + integer :: varnum ! variable number + integer :: dimid, dimlen ! dimension id number and length + integer :: ier ! error id + character(len=256) :: locfn ! local file name + type(file_desc_t) :: ncid ! netcdf id + real(r8), pointer :: arraylocal(:,:) ! local array for reading fraction data + real(r8), pointer :: arraylocal_bareground(:) ! local array for reading bareground data + logical :: readvar ! true => variable is on dataset + !character(len=16), parameter :: grlnd = 'lndgrid' ! name of lndgrid + + integer, parameter :: dim_landuse_pft = 14 + + ! Land use name arrays + character(len=10), parameter :: landuse_pft_map_varnames(num_landuse_pft_vars) = & + [character(len=10) :: 'frac_primr','frac_secnd','frac_pastr','frac_range'] !need to move 'frac_surf' to a different variable + + character(len=*), parameter :: subname = 'GetLandusePFTData' + + !----------------------------------------------------------------------- + + ! Check to see if the landuse file name has been provided + ! Note: getfile checks this as well + if (masterproc) then + write(iulog,*) 'Attempting to read landuse x pft data .....' + if (landuse_pft_file == ' ') then + write(iulog,*)'landuse_pft_file must be specified' + call endrun(msg=errMsg(__FILE__, __LINE__)) + endif + endif + + ! Initialize the landuse x pft arrays and initialize to unset + allocate(landuse_pft_map(bounds%begg:bounds%endg,dim_landuse_pft,num_landuse_pft_vars),stat=ier) + if (ier /= 0) then + call endrun(msg=' allocation error for landuse_pft_map'//errMsg(__FILE__, __LINE__)) + end if + landuse_pft_map = fates_unset_r8 + + allocate(landuse_bareground(bounds%begg:bounds%endg),stat=ier) + if (ier /= 0) then + call endrun(msg=' allocation error for landuse_bareground'//errMsg(__FILE__, __LINE__)) + end if + landuse_bareground = fates_unset_r8 + + + ! Get the local filename and open the file + call getfil(landuse_pft_file, locfn, 0) + call ncd_pio_openfile (ncid, trim(locfn), 0) + + ! Check that natpft dimension on the file matches the target array dimensions + call ncd_inqdlen(ncid, dimid, dimlen, 'natpft') + if (dimlen /= dim_landuse_pft) then + write(iulog,*) 'natpft dimensions on the landuse x pft file do not match target array size' + call endrun(msg=errMsg(__FILE__, __LINE__)) + end if + + ! Allocate a temporary array since ncdio expects a pointer + allocate(arraylocal(bounds%begg:bounds%endg,dim_landuse_pft)) + allocate(arraylocal_bareground(bounds%begg:bounds%endg)) + + ! Read the landuse x pft data from file + do varnum = 1, num_landuse_pft_vars + call ncd_io(ncid=ncid, varname=landuse_pft_map_varnames(varnum), flag='read', & + data=arraylocal, dim1name=grlnd, readvar=readvar) + if (.not. readvar) & + call endrun(msg='ERROR: '//trim(landuse_pft_map_varnames(varnum))// & + ' NOT on landuse x pft file'//errMsg(__FILE__, __LINE__)) + landuse_pft_map(bounds%begg:bounds%endg,:,varnum) = arraylocal(bounds%begg:bounds%endg,:) + end do + + ! Read the bareground data from file. This is per gridcell only. + call ncd_io(ncid=ncid, varname='frac_brgnd', flag='read', & + data=arraylocal_bareground, dim1name=grlnd, readvar=readvar) + if (.not. readvar) call endrun(msg='ERROR: frac_brgnd NOT on landuse x pft file'//errMsg(__FILE__, __LINE__)) + landuse_bareground(bounds%begg:bounds%endg) = arraylocal_bareground(bounds%begg:bounds%endg) + + ! Deallocate the temporary local array point and close the file + deallocate(arraylocal) + deallocate(arraylocal_bareground) + call ncd_pio_closefile(ncid) + + ! Check that sums equal to unity + + end subroutine GetLandusePFTData + + !----------------------------------------------------------------------- end module CLMFatesInterfaceMod From 46420cfb64f4ebb2b092daef9071a3f070b403bf Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 18 Apr 2024 09:40:21 -0600 Subject: [PATCH 040/194] Add fates_landuse_v2 test suite. --- cime_config/testdefs/testlist_clm.xml | 36 +++++++++++++++++++ .../clm/FatesColdLUH2Mode1/include_user_mods | 1 + .../clm/FatesColdLUH2Mode1/user_nl_clm | 1 + .../clm/FatesColdLUH2Mode2/include_user_mods | 1 + .../clm/FatesColdLUH2Mode2/user_nl_clm | 1 + .../clm/FatesColdLUH2Mode3/include_user_mods | 1 + .../clm/FatesColdLUH2Mode3/user_nl_clm | 1 + .../clm/FatesColdLUH2Mode4/include_user_mods | 1 + .../clm/FatesColdLUH2Mode4/user_nl_clm | 1 + 9 files changed, 44 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index dec8cf49d8..4184cc7e1f 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2910,6 +2910,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm new file mode 100644 index 0000000000..dea75b71e7 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 1 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm new file mode 100644 index 0000000000..fd4c74fe57 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm new file mode 100644 index 0000000000..3332e9e526 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 3 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm new file mode 100644 index 0000000000..13dae9efee --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 4 From e4c8b6a0f1dfd0392fc956cf5d3f41e197508ba5 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 18 Apr 2024 11:32:05 -0600 Subject: [PATCH 041/194] Point FATES external to my repo: Nag array index fix. --- Externals_CLM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index 1494217277..ef4406545e 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/ckoven/fates -hash = d37d9733b5970dfe67a +repo_url = https://github.com/samsrabin/fates +hash = c03a4ba64a7e59817658f1c3357ffff681d8b958 required = True [externals_description] From 7216006b1c2400d1ca2932899671f9bcec85b6af Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Thu, 18 Apr 2024 16:48:41 -0600 Subject: [PATCH 042/194] Apply relevant changes from rgknox/fates-auto-params. --- .../testdefs/testmods_dirs/clm/Fates/shell_commands | 5 +++++ .../testdefs/testmods_dirs/clm/Fates/user_nl_clm | 1 + .../testdefs/testmods_dirs/clm/_scripts/README | 2 ++ .../clm/_scripts/get_fates_shell_commands_vars.sh | 11 +++++++++++ 4 files changed, 19 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/_scripts/README create mode 100755 cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands index 41a2342a51..3443bacef0 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands @@ -1,2 +1,7 @@ ./xmlchange CLM_BLDNML_OPTS="-no-megan" --append ./xmlchange BFBFLAG="TRUE" + +SRCROOT=`./xmlquery SRCROOT --value` +. "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh + +ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm index 91df3e2e61..57adea1ff6 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -4,6 +4,7 @@ hist_nhtfrq = -24 hist_empty_htapes = .true. hist_ndens = 1 fates_spitfire_mode = 1 +fates_paramfile='${SRCROOT}/src/fates/parameter_files/binaries/${CASE}-params.nc' hist_fincl1 = 'FATES_NCOHORTS', 'FATES_TRIMMING', 'FATES_AREA_PLANTS', 'FATES_AREA_TREES', 'FATES_COLD_STATUS', 'FATES_GDD', 'FATES_NCHILLDAYS', 'FATES_NCOLDDAYS', 'FATES_DAYSINCE_COLDLEAFOFF','FATES_DAYSINCE_COLDLEAFON', diff --git a/cime_config/testdefs/testmods_dirs/clm/_scripts/README b/cime_config/testdefs/testmods_dirs/clm/_scripts/README new file mode 100644 index 0000000000..66eb22a375 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/_scripts/README @@ -0,0 +1,2 @@ +This directory contains scripts that can be called in +shell_commands of multiple testmods. diff --git a/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh b/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh new file mode 100755 index 0000000000..382fb4e53e --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh @@ -0,0 +1,11 @@ +# This script should be called in shell_commands with +# . "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh +# where the leading period ensures it's run in the same shell. + +CASE=`./xmlquery CASE --value` +FATESDIR="${SRCROOT}/src/fates" +FATESPARAMDIR="${SRCROOT}/src/fates/parameter_files/binaries" +mkdir -p "${FATESPARAMDIR}" +FATESPARAMFILE="${FATESPARAMDIR}/${CASE}-params.nc" + +# No exit status because it should be called in the same shell. From a7c21a752224c09361b4280a730e5c61273244fa Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Tue, 23 Apr 2024 12:26:35 -0600 Subject: [PATCH 043/194] Don't allow flandusepftdat to be set in non-FATES runs. --- bld/CLMBuildNamelist.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index bcf68a8d61..e3ceedeccc 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -784,7 +784,7 @@ sub setup_cmdl_fates_mode { my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_cohort_age_tracking","use_fates_inventory_init","use_fates_fixed_biogeog", "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", - "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries" ); + "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries","flandusepftdat"); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { if ( defined($nl->get_value($var)) ) { From 90a40281134953f3d371a6454642773035efe137 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Tue, 23 Apr 2024 12:27:16 -0600 Subject: [PATCH 044/194] Actually set flandusepftdat in CLMBuildNamelist.pm. --- bld/CLMBuildNamelist.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index e3ceedeccc..0f7f6891c5 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4424,6 +4424,9 @@ sub setup_logic_fates { } elsif ( ! -f "$fname" ) { $log->fatal_error("$fname does NOT point to a valid filename" ); } + + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); } } From d88fda01ba5904e80cf432f609cc10d4392f2767 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Tue, 23 Apr 2024 12:27:43 -0600 Subject: [PATCH 045/194] Update path for default flandusepftdat. --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index bc962d1b0f..66c0f837e0 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1578,7 +1578,7 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 >lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc -lnd/clm2/surfdata_map/fates-sci.1.73.0_api.33.0.0/fates_landuse_pft_map_4x5_240206.nc +lnd/clm2/surfdata_map/fates-sci.1.73.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc Date: Sun, 28 Apr 2024 13:45:50 -0600 Subject: [PATCH 046/194] Point FATES external back at Charlie's branch. --- Externals_CLM.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index ef4406545e..b689141aaf 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/samsrabin/fates -hash = c03a4ba64a7e59817658f1c3357ffff681d8b958 +repo_url = https://github.com/ckoven/fates +hash = c1a7453c8331277a156a0ee158a870c1b8598a9f required = True [externals_description] From 0191278f95a35f90c76b7922fb51d8e42d68b24e Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Sun, 28 Apr 2024 13:48:21 -0600 Subject: [PATCH 047/194] Add missing potential veg to build list. Manually cherry-picked from Greg Lemieux's b33a722. --- bld/CLMBuildNamelist.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 0f7f6891c5..7e2e4294af 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -784,7 +784,8 @@ sub setup_cmdl_fates_mode { my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_cohort_age_tracking","use_fates_inventory_init","use_fates_fixed_biogeog", "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", - "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries","flandusepftdat"); + "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries","flandusepftdat", + "use_fates_potentialveg"); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { if ( defined($nl->get_value($var)) ) { From fffb79409b29ed741c119d9fb37496898a689cd9 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 1 May 2024 15:46:26 -0700 Subject: [PATCH 048/194] add use_fates_lupft switch --- bld/CLMBuildNamelist.pm | 25 +++++++++++++++++++ bld/namelist_files/namelist_defaults_ctsm.xml | 18 +++++++------ .../namelist_definition_ctsm.xml | 6 +++++ src/main/clm_varctl.F90 | 1 + src/main/controlMod.F90 | 3 +++ src/utils/clmfates_interfaceMod.F90 | 16 ++++-------- 6 files changed, 51 insertions(+), 18 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 7e2e4294af..021381a18e 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4414,6 +4414,31 @@ sub setup_logic_fates { } } } + # make sure that fates landuse x pft mode has the necessary run mode configurations + # and add the necessary landuse x pft static mapping data default if not defined + my $var = "use_fates_lupft"; + if ( defined($nl->get_value($var)) ) { + if ( &value_is_true($nl->get_value($var)) ) { + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + fatal_error("$var is required when use_fates_lupft is set" ); + } elsif ( ! -f "$fname" ) { + fatal_error("$fname does NOT point to a valid filename" ); + } + } + # make sure that nocomp and fbg mode are enabled as well as use_fates_luh + my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); + foreach my $var ( @list ) { + if ( ! &value_is_true($nl->get_value($var)) ) { + fatal_error("$var is required when use_fates_lupft is true" ); + } + } + } + # check that fates landuse change mode has the necessary luh2 landuse timeseries data + # and add the default if not defined my $var = "use_fates_luh"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 66c0f837e0..49109c6591 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2767,17 +2767,21 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. +.false. .false. -.true. -.true. -.false. +.true. +.true. +.true. +.false. 1 0 -.true. -.false. -.true. -.false. +.true. +.true. +.false. +.true. +.true. +.false. diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index fa2d83a3c9..a2df9b1d1e 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -791,6 +791,12 @@ data (fates_harvest_mode >= 3) (Also, only valid for use_fates = true and is incompatible with transient runs currently.) + +If TRUE, enable use of fates land use x pft mapping data file. +(Only valid for use_fates = true and is incompatible with transient runs currently.) + + If TRUE, ignore the land-use state vector and transitions, and assert that all lands diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index 9ab6c631c7..64d6e15747 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -311,6 +311,7 @@ module clm_varctl logical, public :: use_fates_fixed_biogeog = .false. ! true => use fixed biogeography mode logical, public :: use_fates_nocomp = .false. ! true => use no comopetition mode logical, public :: use_fates_luh = .false. ! true => use FATES landuse data mode + logical, public :: use_fates_lupft = .false. ! true => use FATES landuse x pft static mapping mode logical, public :: use_fates_potentialveg = .false. ! true => FATES potential veg only character(len=256), public :: fluh_timeseries = '' ! filename for fates landuse timeseries data character(len=256), public :: flandusepftdat = '' ! filename for fates landuse x pft data diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index 196bc141ff..55dd92305d 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -231,6 +231,7 @@ subroutine control_init(dtime) use_fates_nocomp, & use_fates_sp, & use_fates_luh, & + use_fates_lupft, & use_fates_potentialveg, & fluh_timeseries, & flandusepftdat, & @@ -785,6 +786,7 @@ subroutine control_spmd() call mpi_bcast (use_fates_nocomp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_sp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_luh, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (use_fates_lupft, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_potentialveg, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_bgc, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (fates_inventory_ctrl_filename, len(fates_inventory_ctrl_filename), MPI_CHARACTER, 0, mpicom, ier) @@ -1161,6 +1163,7 @@ subroutine control_print () write(iulog, *) ' use_fates_nocomp = ', use_fates_nocomp write(iulog, *) ' use_fates_sp = ', use_fates_sp write(iulog, *) ' use_fates_luh= ', use_fates_luh + write(iulog, *) ' use_fates_lupft= ', use_fates_lupft write(iulog, *) ' use_fates_potentialveg = ', use_fates_potentialveg write(iulog, *) ' fluh_timeseries = ', trim(fluh_timeseries) write(iulog, *) ' flandusepftdat = ', trim(flandusepftdat) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 3f84a28508..b0ae0044f3 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -60,6 +60,7 @@ module CLMFatesInterfaceMod use clm_varctl , only : use_fates_nocomp use clm_varctl , only : use_fates_sp use clm_varctl , only : use_fates_luh + use clm_varctl , only : use_fates_lupft use clm_varctl , only : use_fates_potentialveg use clm_varctl , only : flandusepftdat use clm_varctl , only : fates_seeddisp_cadence @@ -567,13 +568,6 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_fates_potentialveg',ival=pass_use_potentialveg) - if(flandusepftdat /= '') then - pass_lupftdat = 1 - else - pass_lupftdat = 0 - end if - call set_fates_ctrlparms('use_landusepft_data',ival=pass_lupftdat) - ! Wait to set the harvest and logging variables after checking get_do_harvest ! and fates_harvest_modes call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) @@ -710,7 +704,7 @@ subroutine init(this, bounds_proc, flandusepftdat) end if ! Retrieve the landuse x pft static data if the file is present - if (flandusepftdat /= '') then + if (use_fates_lupft) then call GetLandusePFTData(bounds_proc, flandusepftdat, landuse_pft_map, landuse_bareground) end if @@ -821,12 +815,12 @@ subroutine init(this, bounds_proc, flandusepftdat) this%fates(nc)%sites(s)%lon = grc%londeg(g) ! Transfer the landuse x pft data to fates via bc_in if file is given - if (flandusepftdat /= '') then + if (use_fates_lupft) then this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars) this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g) end if - if (flandusepftdat == '') then + if (.not. use_fates_lupft) then ! initialize static layers for reduced complexity FATES versions from HLM ! maybe make this into a subroutine of it's own later. this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 @@ -882,7 +876,7 @@ subroutine init(this, bounds_proc, flandusepftdat) call create_fates_fire_data_method( this%fates_fire_data_method ) ! deallocate the local landuse x pft array - if (flandusepftdat /= '') then + if (use_fates_lupft) then deallocate(landuse_pft_map) deallocate(landuse_bareground) end if From 5d11bcf5c1ad64bb8898e54f15852315439c5d57 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 1 May 2024 15:52:27 -0700 Subject: [PATCH 049/194] add fates use_potentialveg namelist defaults settings and checks --- bld/CLMBuildNamelist.pm | 13 ++++++++++++- bld/namelist_files/namelist_defaults_ctsm.xml | 9 +++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 021381a18e..7999e9a31d 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4455,7 +4455,18 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); } } - + # check that fates landuse is on and harvest mode is off when potential veg switch is true + my $var = "use_potentialveg"; + if ( defined($nl->get_value($var)) ) { + if ( &value_is_true($nl->get_value($var)) ) { + if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { + fatal_error("use_fates_luh must be true when $var is true" ); + } + if ( $nl->get_value('fates_harvest_mode') > 0) { + fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); + } + } + } # Check fates_harvest_mode compatibility my $var = "fates_harvest_mode"; if ( defined($nl->get_value($var)) ) { diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 49109c6591..68a122e9bc 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,10 +2769,11 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.true. -.true. -.true. -.false. +.true. +.true. +.true. +.true. +.false. 1 0 From f0f2b9e17c17cc095832e4439313192fdea28a75 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 1 May 2024 16:58:18 -0600 Subject: [PATCH 050/194] Additional conflict resolution in testlist_clm.xml --- cime_config/testdefs/testlist_clm.xml | 35 +-------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index d3ee1eae35..ff3d113c53 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -955,14 +955,6 @@ - - - - - - - - @@ -981,14 +973,6 @@ - - - - - - - - @@ -1062,15 +1046,6 @@ - - - - - - - - - @@ -1088,14 +1063,6 @@ - - - - - - - - @@ -2875,7 +2842,7 @@ - + From 3cc33e59813be988d983cfca47f2e9ef99819f1d Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 2 May 2024 12:24:55 -0600 Subject: [PATCH 051/194] Update test to use a valid compset --- cime_config/testdefs/testlist_clm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index ff3d113c53..cfd81a5a2b 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -830,7 +830,7 @@ - + From 6bd7d37a956edb0fc2bb20f7d593c64e4fa6eb0c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 2 May 2024 11:49:28 -0700 Subject: [PATCH 052/194] add use_fates_lupft to default namelist --- bld/CLMBuildNamelist.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 7999e9a31d..23505492bd 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -785,7 +785,7 @@ sub setup_cmdl_fates_mode { "use_fates_cohort_age_tracking","use_fates_inventory_init","use_fates_fixed_biogeog", "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries","flandusepftdat", - "use_fates_potentialveg"); + "use_fates_potentialveg","use_fates_lupft"); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { if ( defined($nl->get_value($var)) ) { @@ -4371,7 +4371,8 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_inventory_init","use_fates_fixed_biogeog","use_fates_nocomp","fates_seeddisp_cadence", - "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage","use_fates_luh" ); + "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage", + "use_fates_luh","use_fates_lupft" ); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); From bbfe2b4542fc56b08cfeeffefc1b4e54f9572181 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 2 May 2024 15:07:50 -0600 Subject: [PATCH 053/194] Correction to last commit (1850 should have been 2000) --- cime_config/testdefs/testlist_clm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index cfd81a5a2b..bf20c1241a 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -830,7 +830,7 @@ - + From 57004d92e39e6f83393f6f7c74cf3e21062e18c3 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 3 May 2024 17:34:08 -0600 Subject: [PATCH 054/194] New conflict resolution in testlist_clm.xml, this time for an izumi test --- cime_config/testdefs/testlist_clm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index bf20c1241a..c2bb819572 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1652,7 +1652,7 @@ - + From edae95a1013439e234e7d56d57c01efc74ce063f Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sat, 4 May 2024 13:08:16 -0600 Subject: [PATCH 055/194] manually revert defaults for use_fates_lupft and fix calls to fatal_error --- bld/CLMBuildNamelist.pm | 25 +++++++++++-------- bld/namelist_files/namelist_defaults_ctsm.xml | 7 ++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 23505492bd..01d583eb16 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4371,12 +4371,16 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_inventory_init","use_fates_fixed_biogeog","use_fates_nocomp","fates_seeddisp_cadence", - "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage", - "use_fates_luh","use_fates_lupft" ); + "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage"); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); } + + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl_flags->{'use_fates_lupft'} ); + 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'}) ) { @@ -4384,6 +4388,7 @@ sub setup_logic_fates { "but and FATES-SP is not active, but fates_parteh_mode is 1, so Nitrogen is not active" . "Change suplnitro back to ALL"); } + # # For FATES SP mode make sure no-competetiion, and fixed-biogeography are also set # And also check for other settings that can't be trigged on as well @@ -4425,16 +4430,16 @@ sub setup_logic_fates { 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { - fatal_error("$var is required when use_fates_lupft is set" ); + $log->fatal_error("$var is required when use_fates_lupft is set" ); } elsif ( ! -f "$fname" ) { - fatal_error("$fname does NOT point to a valid filename" ); + $log->fatal_error("$fname does NOT point to a valid filename" ); } } # make sure that nocomp and fbg mode are enabled as well as use_fates_luh my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); foreach my $var ( @list ) { if ( ! &value_is_true($nl->get_value($var)) ) { - fatal_error("$var is required when use_fates_lupft is true" ); + $log->fatal_error("$var is required when use_fates_lupft is true" ); } } } @@ -4461,10 +4466,10 @@ sub setup_logic_fates { if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { - fatal_error("use_fates_luh must be true when $var is true" ); + $log->fatal_error("use_fates_luh must be true when $var is true" ); } if ( $nl->get_value('fates_harvest_mode') > 0) { - fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); + $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); } } } @@ -4475,17 +4480,17 @@ sub setup_logic_fates { # if ( $nl->get_value($var) == 2) { # # Make sure that do_harvest is set to true # if ( ! &value_is_true($nl->get_value('do_harvest')) ) { - # fatal_error("do_harvest must be true when $var is equal to 2" ); + # $log->fatal_error("do_harvest must be true when $var is equal to 2" ); # } # using fates_harvest mode with raw luh2 harvest data if ( $nl->get_value($var) > 2) { # Make sure that use_fates_luh is true when using raw fates luh2 harvest data if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { - fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); + $log->fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); } # do_harvest can not be on if we are using the raw fates luh2 harvest data if ( &value_is_true($nl->get_value('do_harvest')) ) { - fatal_error("do_harvest can not be true when $var is greater than 2" ); + $log->fatal_error("do_harvest can not be true when $var is greater than 2" ); } } } diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 68a122e9bc..1195ba5329 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,19 +2769,16 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.true. -.true. + .true. -.true. .false. + 1 0 .true. -.true. .false. .true. -.true. .false. From af6a1c0e87a4f3d03e3fe6976b00af3ac94398f1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sat, 4 May 2024 13:37:22 -0600 Subject: [PATCH 056/194] remove old flandusepftdat add_default and fix use_fates_lupft check this also temporarily removes the use_fates_lupft check for the use_fates_luh namelist defaults --- bld/CLMBuildNamelist.pm | 17 +++++++---------- bld/namelist_files/namelist_defaults_ctsm.xml | 6 +----- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 01d583eb16..1cb14878e7 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4389,7 +4389,6 @@ sub setup_logic_fates { "Change suplnitro back to ALL"); } - # # For FATES SP mode make sure no-competetiion, and fixed-biogeography are also set # And also check for other settings that can't be trigged on as well # @@ -4434,12 +4433,13 @@ sub setup_logic_fates { } elsif ( ! -f "$fname" ) { $log->fatal_error("$fname does NOT point to a valid filename" ); } - } - # make sure that nocomp and fbg mode are enabled as well as use_fates_luh - my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); - foreach my $var ( @list ) { - if ( ! &value_is_true($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_lupft is true" ); + + # make sure that nocomp and fbg mode are enabled as well as use_fates_luh + my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); + foreach my $var ( @list ) { + if ( ! &value_is_true($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_lupft is true" ); + } } } } @@ -4456,9 +4456,6 @@ sub setup_logic_fates { } elsif ( ! -f "$fname" ) { $log->fatal_error("$fname does NOT point to a valid filename" ); } - - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); } } # check that fates landuse is on and harvest mode is off when potential veg switch is true diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 1195ba5329..e6f6b736a6 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,13 +2769,9 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. - -.true. -.false. - +.false. 1 0 - .true. .false. .true. From d5575d5c31e0013b8e303b3bc6966f6c8e405f55 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sat, 4 May 2024 14:42:15 -0600 Subject: [PATCH 057/194] correct call to add_default for use_fates_lupft dependency with use_fates_luh --- bld/CLMBuildNamelist.pm | 2 +- bld/namelist_files/namelist_defaults_ctsm.xml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 1cb14878e7..7ad35584aa 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4379,7 +4379,7 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl_flags->{'use_fates_lupft'} ); + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft') ); my $suplnitro = $nl->get_value('suplnitro'); my $parteh_mode = $nl->get_value('fates_parteh_mode'); diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index e6f6b736a6..38a0fe6493 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,7 +2769,8 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.false. +.true. +.false. 1 0 .true. From ea773e451b78b3b7011a534a73352693600be95e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sat, 4 May 2024 14:53:16 -0600 Subject: [PATCH 058/194] add use_fates_lupft dependencies for nocomp and fbg --- bld/CLMBuildNamelist.pm | 10 ++++++++-- bld/namelist_files/namelist_defaults_ctsm.xml | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 7ad35584aa..261c775fbd 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4370,7 +4370,7 @@ sub setup_logic_fates { if (&value_is_true( $nl_flags->{'use_fates'}) ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", - "use_fates_inventory_init","use_fates_fixed_biogeog","use_fates_nocomp","fates_seeddisp_cadence", + "use_fates_inventory_init","fates_seeddisp_cadence", "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage"); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, @@ -4380,6 +4380,12 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft') ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_fixed_biogeog', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); my $suplnitro = $nl->get_value('suplnitro'); my $parteh_mode = $nl->get_value('fates_parteh_mode'); @@ -4435,7 +4441,7 @@ sub setup_logic_fates { } # make sure that nocomp and fbg mode are enabled as well as use_fates_luh - my @list = ( "use_fates_nocomp", "use_fates_fixed_biogeog, use_fates_luh" ); + my @list = ( "use_fates_luh", "use_fates_nocomp", "use_fates_fixed_biogeog" ); foreach my $var ( @list ) { if ( ! &value_is_true($nl->get_value($var)) ) { $log->fatal_error("$var is required when use_fates_lupft is true" ); diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 38a0fe6493..216ad74ca1 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2774,8 +2774,10 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 1 0 .true. +.true. .false. .true. +.true. .false. From a21181f1b3e4a89f426e4b9bdce52e76b06ffc39 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 5 May 2024 12:24:05 -0600 Subject: [PATCH 059/194] add fates_harvest_mode to use_fates_luh check --- bld/CLMBuildNamelist.pm | 3 ++- bld/namelist_files/namelist_defaults_ctsm.xml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 261c775fbd..8af5f035e9 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4379,7 +4379,8 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl->get_value('use_fates_lupft') ); + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 216ad74ca1..206ab7cd1b 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,6 +2769,8 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. +.true. +.true. .true. .false. 1 From d8178e415a399f2f0fd61b15f92b4c43f9dd4484 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 5 May 2024 12:54:52 -0600 Subject: [PATCH 060/194] add use_fates_potentialveg to use_fates_luh check --- bld/CLMBuildNamelist.pm | 4 +++- bld/namelist_files/namelist_defaults_ctsm.xml | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 8af5f035e9..b450060736 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4377,9 +4377,11 @@ sub setup_logic_fates { 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); } + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_potentialveg', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_potentialveg'=>$nl->get_value('use_fates_potentialveg'), 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), @@ -4466,7 +4468,7 @@ sub setup_logic_fates { } } # check that fates landuse is on and harvest mode is off when potential veg switch is true - my $var = "use_potentialveg"; + my $var = "use_fates_potentialveg"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 206ab7cd1b..9d2a34b7bf 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2769,10 +2769,11 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.true. -.true. +.true. +.true. .true. -.false. +.true. +.false. 1 0 .true. From 9751fb68174903134e301472087edc263bc4822e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 5 May 2024 13:01:20 -0600 Subject: [PATCH 061/194] add check to fates sp mode to make sure landuse isn't enabled --- bld/CLMBuildNamelist.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b450060736..54f0c0c997 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4414,6 +4414,10 @@ sub setup_logic_fates { if ( $nl->get_value('fates_spitfire_mode') > 0 ) { $log->fatal_error('fates_spitfire_mode can NOT be set to greater than 0 when use_fates_sp is true'); } + # fates landuse can't be on with FATES SP mode is active + if ( &value_is_true($nl->get_value('use_fates_luh')) ) { + $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); + } } } my $var = "use_fates_inventory_init"; From 75f9cc54227f39f7baabc430de7a12506b892192 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 6 May 2024 15:35:56 -0700 Subject: [PATCH 062/194] rename luh unit test that matched old test --- bld/unit_testers/build-namelist_test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 899bd10b9c..0bf0ea5390 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1062,7 +1062,7 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, - "useinventorybutnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", + "useLUH2butnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", namelst=>"use_fates_luh=.true.", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", From ff3af55931b98e9cb7b9553717d10f2388954197 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 6 May 2024 16:24:30 -0700 Subject: [PATCH 063/194] add build namelist unit tests for fates landuse v2 --- bld/unit_testers/build-namelist_test.pl | 41 +++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 0bf0ea5390..70243c5843 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -163,10 +163,10 @@ sub cat_and_create_namelistinfile { # # Figure out number of tests that will run # -my $ntests = 1999; +my $ntests = 2006; if ( defined($opts{'compare'}) ) { - $ntests += 1353; + $ntests += 1360; } plan( tests=>$ntests ); @@ -1062,11 +1062,16 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, - "useLUH2butnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", + "useFATESLUH2butnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", namelst=>"use_fates_luh=.true.", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, + "useFATESLUPFTbutnotfile" =>{ options=>"--res 0.9x1.25 --bgc fates --envxml_dir . --no-megan", + namelst=>"use_fates_lupft=.true.", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm4_5", + }, "inventoryfileDNE" =>{ options=>"-bgc fates -envxml_dir . -no-megan", namelst=>"use_fates_luh=.true., fluh_timeseries='zztop'", GLC_TWO_WAY_COUPLING=>"FALSE", @@ -1092,6 +1097,36 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, + "useFATESSPwithLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_sp=T,use_fates_luh=T", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESPOTVEGwithHARVEST" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_potentialveg=T,fates_harvest_mode=1", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESHARVEST3WOLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_luh=F,fates_harvest_mode=3", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESLUPFTWOLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_lupft=T,use_fates_luh=F", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESLUPFTWONOCOMP" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_lupft=T,use_fates_nocomp=F", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, + "useFATESLUPFTWOFBG" =>{ options=>"-bgc fates -envxml_dir . -no-megan", + namelst=>"use_fates_lupft=T,use_fates_fixedbiogeog=F", + GLC_TWO_WAY_COUPLING=>"FALSE", + phys=>"clm5_0", + }, "useFATESTRANSWdynPFT" =>{ options=>"-bgc fates -envxml_dir . -use_case 20thC_transient -no-megan", namelst=>"do_transient_pfts=T", GLC_TWO_WAY_COUPLING=>"FALSE", From 69154dab7b33706491bdabc634d9a80142bf0b35 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 6 May 2024 16:37:07 -0700 Subject: [PATCH 064/194] update fates logging unit test to use new fates harvest mode --- bld/namelist_files/namelist_definition_ctsm.xml | 2 +- bld/unit_testers/build-namelist_test.pl | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index a2df9b1d1e..edcfa36d27 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -814,7 +814,7 @@ types to vary over time. -Full pathname of fates landuse x pft data map. +Full pathname of fates landuse x pft static data map. "FALSE", phys=>"clm4_5", }, - # TODO SSR: Replace this with fates_harvest_mode "useloggingButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", - namelst=>"use_fates_logging=.true.", + namelst=>"fates_harvest_mode=1", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, From 5c5ca6f8e40cc6fe69d9b9a7edf32ce5242a7629 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 6 May 2024 17:49:34 -0600 Subject: [PATCH 065/194] minor update --- bld/unit_testers/build-namelist_test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 3b2dabd057..f674849b6f 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -163,7 +163,7 @@ sub cat_and_create_namelistinfile { # # Figure out number of tests that will run # -my $ntests = 2006; +my $ntests = 2007; if ( defined($opts{'compare'}) ) { $ntests += 1360; From 2a88002ea1a916d21da69b05c6621774cca74b39 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 7 May 2024 10:26:16 -0700 Subject: [PATCH 066/194] change lupft check to fbg + luh check to mirror fates-side logic --- src/utils/clmfates_interfaceMod.F90 | 37 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index b0ae0044f3..048824a83a 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -398,7 +398,6 @@ subroutine CLMFatesGlobals2() integer :: pass_use_potentialveg integer :: pass_num_luh_states integer :: pass_num_luh_transitions - integer :: pass_lupftdat call t_startf('fates_globals2') @@ -704,7 +703,7 @@ subroutine init(this, bounds_proc, flandusepftdat) end if ! Retrieve the landuse x pft static data if the file is present - if (use_fates_lupft) then + if (use_fates_fixed_biogeog .and. use_fates_luh) then call GetLandusePFTData(bounds_proc, flandusepftdat, landuse_pft_map, landuse_bareground) end if @@ -815,23 +814,23 @@ subroutine init(this, bounds_proc, flandusepftdat) this%fates(nc)%sites(s)%lon = grc%londeg(g) ! Transfer the landuse x pft data to fates via bc_in if file is given - if (use_fates_lupft) then - this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars) - this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g) - end if - - if (.not. use_fates_lupft) then - ! initialize static layers for reduced complexity FATES versions from HLM - ! maybe make this into a subroutine of it's own later. - this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 - do m = surfpft_lb,surfpft_ub - ft = m - surfpft_lb - this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) - end do + if (use_fates_fixed_biogeog) then + if (use_fates_luh) then + this%fates(nc)%bc_in(s)%pft_areafrac_lu(:,1:num_landuse_pft_vars) = landuse_pft_map(g,:,1:num_landuse_pft_vars) + this%fates(nc)%bc_in(s)%baregroundfrac = landuse_bareground(g) + else + ! initialize static layers for reduced complexity FATES versions from HLM + ! maybe make this into a subroutine of it's own later. + this%fates(nc)%bc_in(s)%pft_areafrac(:)=0._r8 + do m = surfpft_lb,surfpft_ub + ft = m - surfpft_lb + this%fates(nc)%bc_in(s)%pft_areafrac(ft)=wt_nat_patch(g,m) + end do - if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then - write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s) %pft_areafrac(:)) - 1.0_r8 - call endrun(msg=errMsg(sourcefile, __LINE__)) + if (abs(sum(this%fates(nc)%bc_in(s)%pft_areafrac(surfpft_lb:surfpft_ub)) - 1.0_r8) > sum_to_1_tol) then + write(iulog,*) 'pft_area error in interfc ', s, sum(this%fates(nc)%bc_in(s) %pft_areafrac(:)) - 1.0_r8 + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if end if end if end do !site @@ -876,7 +875,7 @@ subroutine init(this, bounds_proc, flandusepftdat) call create_fates_fire_data_method( this%fates_fire_data_method ) ! deallocate the local landuse x pft array - if (use_fates_lupft) then + if (use_fates_fixed_biogeog .and. use_fates_luh) then deallocate(landuse_pft_map) deallocate(landuse_bareground) end if From 0bcf80acea865f2df37d13911aa6b9d167622a66 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 1 May 2024 16:37:32 -0600 Subject: [PATCH 067/194] FatesColdLUH2 tests now use use_fates_nocomp false. --- cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm | 1 + 1 file changed, 1 insertion(+) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm index 854c21407f..917ba314b3 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm @@ -1 +1,2 @@ use_fates_luh = .true. +use_fates_nocomp = .false. From 0edcb1b5b118c7029807a05e1ce3773396c6ec7f Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 May 2024 10:22:47 -0600 Subject: [PATCH 068/194] Update FATES external to latest ckoven/luh2_nocomp_merge. --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index b689141aaf..e1bc1696af 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/ckoven/fates -hash = c1a7453c8331277a156a0ee158a870c1b8598a9f +hash = 153b0bda9c96f18e8d2a93887a082bc7a31b574b required = True [externals_description] From 92fb80687f707c1799cacea85bc64bc9c1cd9f89 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 May 2024 13:25:19 -0600 Subject: [PATCH 069/194] Update FatesColdLUH2 testdef. --- .../testmods_dirs/clm/FatesColdLUH2/user_nl_clm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm index 917ba314b3..970e7df7cd 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm @@ -1,2 +1,11 @@ + +! Run a transient case, with vegetation starting from bare ground, but land use starting from LUH state vector on starting date, in a nocomp configuration. +! From Charlie's list of valid FATES configurations: +! https://docs.google.com/spreadsheets/d/1eE3sRMYxfocZKbT8uIQhXpjjtfM2feXPRSWXJNoo4jM/edit#gid=0 +flandusepftdat = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/fates-sci.1.73.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc' use_fates_luh = .true. -use_fates_nocomp = .false. +use_fates_nocomp = .true. +use_fates_fixed_biogeog = .true. +use_fates_sp = .false. +use_fates_potentialveg = .false. +fluh_timeseries = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc' From f6728017c7726f947492179f88031cccfa81181f Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 8 May 2024 13:26:56 -0600 Subject: [PATCH 070/194] Add FatesColdLUH2Mode0 testdef. --- cime_config/testdefs/testlist_clm.xml | 9 +++++++++ .../clm/FatesColdLUH2Mode0/include_user_mods | 1 + .../testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm | 1 + 3 files changed, 11 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 4184cc7e1f..022bb9ad73 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2910,6 +2910,15 @@ + + + + + + + + + diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods new file mode 100644 index 0000000000..7eb8bb1579 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods @@ -0,0 +1 @@ +../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm new file mode 100644 index 0000000000..929a8e6e14 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 0 From 05332fb117e7ed94abcc09c5c66f5db8d8885638 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 10:53:59 -0700 Subject: [PATCH 071/194] Remove get_do_harvest dependency for fates harvest modes --- src/dyn_subgrid/dynSubgridDriverMod.F90 | 7 ++- src/utils/clmfates_interfaceMod.F90 | 71 +++++++++---------------- 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/src/dyn_subgrid/dynSubgridDriverMod.F90 b/src/dyn_subgrid/dynSubgridDriverMod.F90 index e5ca3f002e..b12b135b59 100644 --- a/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -89,6 +89,11 @@ subroutine dynSubgrid_init(bounds_proc, glc_behavior, crop_inst) ! Note that dynpft_init needs to be called from outside any loops over clumps - so ! this routine needs to be called from outside any loops over clumps. ! + ! + ! !USES: + use clm_varctl , only : fates_harvest_mode + use dynFATESLandUseChangeMod , only : fates_harvest_clmlanduse + ! ! !ARGUMENTS: type(bounds_type) , intent(in) :: bounds_proc ! processor-level bounds type(glc_behavior_type) , intent(in) :: glc_behavior @@ -123,7 +128,7 @@ subroutine dynSubgrid_init(bounds_proc, glc_behavior, crop_inst) ! flanduse_timeseries file. However, this could theoretically be changed so that the ! harvest data were separated from the pftdyn data, allowing them to differ in the ! years over which they apply. - if (get_do_harvest()) then + if (get_do_harvest() .or. fates_harvest_mode >= fates_harvest_clmlanduse) then call dynHarvest_init(bounds_proc, harvest_filename=get_flanduse_timeseries()) end if diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 048824a83a..308d5cee8e 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -169,7 +169,6 @@ module CLMFatesInterfaceMod use FATESFireBase , only : fates_fire_base_type use FATESFireFactoryMod , only : no_fire, scalar_lightning, successful_ignitions,& anthro_ignitions, anthro_suppression - use dynSubgridControlMod , only : get_do_harvest use dynHarvestMod , only : num_harvest_inst, harvest_varnames use dynHarvestMod , only : harvest_units, mass_units, unitless_units use dynHarvestMod , only : dynHarvest_interp_resolve_harvesttypes @@ -185,6 +184,7 @@ module CLMFatesInterfaceMod use dynFATESLandUseChangeMod, only : dynFatesLandUseInterp use dynFATESLandUseChangeMod, only : num_landuse_harvest_vars use dynFATESLandUseChangeMod, only : fates_harvest_no_logging + use dynFATESLandUseChangeMod, only : fates_harvest_clmlanduse use dynFATESLandUseChangeMod, only : fates_harvest_luh_area use dynFATESLandUseChangeMod, only : landuse_harvest use dynFATESLandUseChangeMod, only : landuse_harvest_units @@ -489,13 +489,6 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_ed_st3',ival=pass_ed_st3) - if (fates_harvest_mode > fates_harvest_no_logging) then - pass_logging = 1 - else - pass_logging = 0 - end if - call set_fates_ctrlparms('use_logging',ival=pass_logging) - if(use_fates_ed_prescribed_phys) then pass_ed_prescribed_phys = 1 else @@ -517,39 +510,28 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking) - ! check fates logging namelist value first because hlm harvest can override it + ! FATES logging and harvest modes if (fates_harvest_mode > fates_harvest_no_logging) then - pass_logging = 1 - else - pass_logging = 0 - end if - - if(get_do_harvest()) then - pass_logging = 1 - pass_num_lu_harvest_cats = num_harvest_inst - pass_lu_harvest = 1 - else - pass_lu_harvest = 0 - pass_num_lu_harvest_cats = 0 - end if + pass_logging = 1 ! Time driven logging, without landuse harvest + ! CLM landuse timeseries driven harvest rates + if (fates_harvest_mode == fates_harvest_clmlanduse) + pass_num_lu_harvest_cats = num_harvest_inst + pass_lu_harvest = 1 + + ! LUH2 landuse timeseries driven harvest rates + else if (fates_harvest_mode >= fates_harvest_luh_area) then + pass_lu_harvest = 1 + pass_num_lu_harvest_types = num_landuse_harvest_vars + else + pass_lu_harvest = 0 + pass_num_lu_harvest_cats = 0 + end if + ! FATES landuse modes if(use_fates_luh) then pass_use_luh = 1 pass_num_luh_states = num_landuse_state_vars pass_num_luh_transitions = num_landuse_transition_vars - - ! Do not set harvest passing variables to zero not in luh harvest modes - ! as the user may want to use the CLM landuse harvest with luh2 transitions - if(fates_harvest_mode >= fates_harvest_luh_area) then - ! End the run if do_harvest is true with this run mode. - ! This should be caught be the build namelist. - if(get_do_harvest()) then - call endrun(msg="do_harvest and fates_harvest_mode using luh2 harvest data are incompatible"//& - errmsg(sourcefile, __LINE__)) - else - pass_lu_harvest = 1 - end if - end if else pass_use_luh = 0 pass_num_luh_states = 0 @@ -567,8 +549,7 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_fates_potentialveg',ival=pass_use_potentialveg) - ! Wait to set the harvest and logging variables after checking get_do_harvest - ! and fates_harvest_modes + ! Wait to set the harvest and logging variables after checking fates_harvest_modes call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) call set_fates_ctrlparms('num_lu_harvest_cats',ival=pass_num_lu_harvest_cats) call set_fates_ctrlparms('use_logging',ival=pass_logging) @@ -996,7 +977,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! Set the FATES global time and date variables call GetAndSetTime - if (get_do_harvest()) then + ! Get harvest rates for CLM landuse timeseries driven rates + if (fates_harvest_mode == fates_harvest_clmlanduse) call dynHarvest_interp_resolve_harvesttypes(bounds_clump, & harvest_rates=harvest_rates(begg:endg,1:num_harvest_inst), & after_start_of_harvest_ts=after_start_of_harvest_ts) @@ -1122,7 +1104,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! for now there is one veg column per gridcell, so store all harvest data in each site ! this will eventually change ! today's hlm harvest flag needs to be set no matter what - if (get_do_harvest()) then + if (fates_harvest_mode == fates_harvest_clmlanduse) if (after_start_of_harvest_ts) then this%fates(nc)%bc_in(s)%hlm_harvest_rates(1:num_harvest_inst) = harvest_rates(g,1:num_harvest_inst) else @@ -1140,6 +1122,11 @@ subroutine dynamics_driv(this, nc, bounds_clump, & write(iulog,*) harvest_units call endrun(msg=errMsg(sourcefile, __LINE__)) end if + + else if (fates_harvest_mode >= fates_harvest_luh_area) then + this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) + this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames + this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units endif if (use_fates_luh) then @@ -1147,12 +1134,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, & this%fates(nc)%bc_in(s)%hlm_luh_state_names = landuse_state_varnames this%fates(nc)%bc_in(s)%hlm_luh_transitions = landuse_transitions(:,g) this%fates(nc)%bc_in(s)%hlm_luh_transition_names = landuse_transition_varnames - - if (fates_harvest_mode >= fates_harvest_luh_area) then - this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) - this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames - this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units - end if end if end do From a35f91d53444c2ac7af2ee1434ae0f85431208b4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 11:15:18 -0700 Subject: [PATCH 072/194] fix check to be only during use of clm landuse timeseries for fates --- src/dyn_subgrid/dynSubgridDriverMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dyn_subgrid/dynSubgridDriverMod.F90 b/src/dyn_subgrid/dynSubgridDriverMod.F90 index b12b135b59..162247a0ff 100644 --- a/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -128,7 +128,7 @@ subroutine dynSubgrid_init(bounds_proc, glc_behavior, crop_inst) ! flanduse_timeseries file. However, this could theoretically be changed so that the ! harvest data were separated from the pftdyn data, allowing them to differ in the ! years over which they apply. - if (get_do_harvest() .or. fates_harvest_mode >= fates_harvest_clmlanduse) then + if (get_do_harvest() .or. fates_harvest_mode == fates_harvest_clmlanduse) then call dynHarvest_init(bounds_proc, harvest_filename=get_flanduse_timeseries()) end if From 74e86669d21c18043a057d955f55e17bd5e7913e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 11:48:57 -0700 Subject: [PATCH 073/194] fix passing num landuse harvest vars to the fates landuse harvest categories --- src/utils/clmfates_interfaceMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 308d5cee8e..cd94b6a15c 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -521,7 +521,7 @@ subroutine CLMFatesGlobals2() ! LUH2 landuse timeseries driven harvest rates else if (fates_harvest_mode >= fates_harvest_luh_area) then pass_lu_harvest = 1 - pass_num_lu_harvest_types = num_landuse_harvest_vars + pass_num_lu_harvest_cats = num_landuse_harvest_vars else pass_lu_harvest = 0 pass_num_lu_harvest_cats = 0 From fd07890223b3e92d91caa1a034055d1184bcff2e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 11:51:20 -0700 Subject: [PATCH 074/194] fix missing end if --- src/utils/clmfates_interfaceMod.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index cd94b6a15c..b9e9bf3031 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -526,6 +526,7 @@ subroutine CLMFatesGlobals2() pass_lu_harvest = 0 pass_num_lu_harvest_cats = 0 end if + end if ! FATES landuse modes if(use_fates_luh) then From 72ed62381b8312b0f0355b938d30c8b1a852cb31 Mon Sep 17 00:00:00 2001 From: loaner Date: Thu, 9 May 2024 16:25:53 -0700 Subject: [PATCH 075/194] update do_harvest to not be compatible with fates --- bld/CLMBuildNamelist.pm | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 54f0c0c997..e422109078 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2932,7 +2932,7 @@ sub setup_logic_do_harvest { $cannot_be_true = "$var can only be set to true when running a transient case (flanduse_timeseries non-blank)"; } - elsif (!&value_is_true($nl->get_value('use_cn')) && !&value_is_true($nl->get_value('use_fates'))) { + elsif (!&value_is_true($nl->get_value('use_cn')) && &value_is_true($nl->get_value('use_fates'))) { $cannot_be_true = "$var can only be set to true when running with either CN or FATES"; } @@ -4486,22 +4486,12 @@ sub setup_logic_fates { # Check fates_harvest_mode compatibility my $var = "fates_harvest_mode"; if ( defined($nl->get_value($var)) ) { - # using fates_harvest_mode with CLM landuse driver data - for user convienence - # if ( $nl->get_value($var) == 2) { - # # Make sure that do_harvest is set to true - # if ( ! &value_is_true($nl->get_value('do_harvest')) ) { - # $log->fatal_error("do_harvest must be true when $var is equal to 2" ); - # } # using fates_harvest mode with raw luh2 harvest data if ( $nl->get_value($var) > 2) { # Make sure that use_fates_luh is true when using raw fates luh2 harvest data if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); } - # do_harvest can not be on if we are using the raw fates luh2 harvest data - if ( &value_is_true($nl->get_value('do_harvest')) ) { - $log->fatal_error("do_harvest can not be true when $var is greater than 2" ); - } } } } From f00ba49d552a3dc3578012f1cf32e6925ac224f9 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 9 May 2024 17:58:07 -0600 Subject: [PATCH 076/194] remove fates from the do_harvest section altogether --- bld/CLMBuildNamelist.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index e422109078..aafc7739a3 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -2932,8 +2932,8 @@ sub setup_logic_do_harvest { $cannot_be_true = "$var can only be set to true when running a transient case (flanduse_timeseries non-blank)"; } - elsif (!&value_is_true($nl->get_value('use_cn')) && &value_is_true($nl->get_value('use_fates'))) { - $cannot_be_true = "$var can only be set to true when running with either CN or FATES"; + elsif (!&value_is_true($nl->get_value('use_cn'))) { + $cannot_be_true = "$var can only be set to true when running with CN. Please set use_cn to true."; } if ($cannot_be_true) { From 278a901fc4821e0c6abef4e0c5ed9bbf41f64516 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 10 May 2024 10:43:41 -0700 Subject: [PATCH 077/194] fix if statements --- src/utils/clmfates_interfaceMod.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index b9e9bf3031..5c23f1c1dc 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -514,7 +514,7 @@ subroutine CLMFatesGlobals2() if (fates_harvest_mode > fates_harvest_no_logging) then pass_logging = 1 ! Time driven logging, without landuse harvest ! CLM landuse timeseries driven harvest rates - if (fates_harvest_mode == fates_harvest_clmlanduse) + if (fates_harvest_mode == fates_harvest_clmlanduse) then pass_num_lu_harvest_cats = num_harvest_inst pass_lu_harvest = 1 @@ -979,7 +979,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & call GetAndSetTime ! Get harvest rates for CLM landuse timeseries driven rates - if (fates_harvest_mode == fates_harvest_clmlanduse) + if (fates_harvest_mode == fates_harvest_clmlanduse) then call dynHarvest_interp_resolve_harvesttypes(bounds_clump, & harvest_rates=harvest_rates(begg:endg,1:num_harvest_inst), & after_start_of_harvest_ts=after_start_of_harvest_ts) @@ -1105,7 +1105,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! for now there is one veg column per gridcell, so store all harvest data in each site ! this will eventually change ! today's hlm harvest flag needs to be set no matter what - if (fates_harvest_mode == fates_harvest_clmlanduse) + if (fates_harvest_mode == fates_harvest_clmlanduse) then if (after_start_of_harvest_ts) then this%fates(nc)%bc_in(s)%hlm_harvest_rates(1:num_harvest_inst) = harvest_rates(g,1:num_harvest_inst) else From d66ddff54439bd192b9ed8b07419a17cd3282656 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 13 May 2024 11:21:08 -0700 Subject: [PATCH 078/194] update fates_harvest_mode to use chars to set namelist options initial commit --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 10 ++++++---- src/main/clm_varctl.F90 | 2 +- src/main/controlMod.F90 | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index 4f326d82a5..d9bd0352ca 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -171,13 +171,14 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) end do ! Get the harvest rate data from the fates luh2 timeseries dataset if enabled - if (fates_harvest_mode .ge. fates_harvest_luh_area ) then + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area .or. & + trim(fates_harvest_mode) .eq. fates_harvest_luh_mass) then ! change the harvest varnames being used depending on the mode selected - if (fates_harvest_mode .eq. fates_harvest_luh_area ) then + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area ) then landuse_harvest_varnames => landuse_harvest_area_varnames landuse_harvest_units = landuse_harvest_area_units - elseif (fates_harvest_mode .eq. fates_harvest_luh_mass ) then + elseif (trim(fates_harvest_mode) .eq. fates_harvest_luh_mass ) then landuse_harvest_varnames => landuse_harvest_mass_varnames landuse_harvest_units = landuse_harvest_mass_units else @@ -256,7 +257,8 @@ subroutine dynFatesLandUseInterp(bounds, init_state) call landuse_state_vars(varnum)%get_current_data(this_data) landuse_states(varnum,bounds%begg:bounds%endg) = this_data(bounds%begg:bounds%endg) end do - if (fates_harvest_mode .ge. fates_harvest_luh_area ) then + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area .or. & + trim(fates_harvest_mode) .eq. fates_harvest_luh_mass) then do varnum = 1, num_landuse_harvest_vars call landuse_harvest_vars(varnum)%get_current_data(this_data) landuse_harvest(varnum,bounds%begg:bounds%endg) = this_data(bounds%begg:bounds%endg) diff --git a/src/main/clm_varctl.F90 b/src/main/clm_varctl.F90 index 64d6e15747..59b72c8e74 100644 --- a/src/main/clm_varctl.F90 +++ b/src/main/clm_varctl.F90 @@ -302,7 +302,7 @@ module clm_varctl ! > 1 for external data (lightning and/or anthropogenic ignitions) ! see bld/namelist_files/namelist_definition_clm4_5.xml for details logical, public :: use_fates_tree_damage = .false. ! true => turn on tree damage module - integer, public :: fates_harvest_mode = 0 ! 0 for no harvest/logging; 1-4 for harvest mode options + character(len=256), public :: fates_harvest_mode = '' ! five different harvest modes; see namelist definition logical, public :: use_fates_planthydro = .false. ! true => turn on fates hydro logical, public :: use_fates_cohort_age_tracking = .false. ! true => turn on cohort age tracking logical, public :: use_fates_ed_st3 = .false. ! true => static stand structure diff --git a/src/main/controlMod.F90 b/src/main/controlMod.F90 index 55dd92305d..1dd432bb7e 100644 --- a/src/main/controlMod.F90 +++ b/src/main/controlMod.F90 @@ -775,7 +775,7 @@ subroutine control_spmd() call mpi_bcast (for_testing_allow_interp_non_ciso_to_ciso, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (fates_spitfire_mode, 1, MPI_INTEGER, 0, mpicom, ier) - call mpi_bcast (fates_harvest_mode, 1, MPI_INTEGER, 0, mpicom, ier) + call mpi_bcast (fates_harvest_mode, len(fates_harvest_mode) , MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (use_fates_planthydro, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_tree_damage, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (use_fates_cohort_age_tracking, 1, MPI_LOGICAL, 0, mpicom, ier) From 458c788eb6b7ca8b6351a5c3e4ebfae7d8364e21 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 13 May 2024 15:07:05 -0700 Subject: [PATCH 079/194] add default pass values for logging and harvest --- src/utils/clmfates_interfaceMod.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 5c23f1c1dc..ba6c59143f 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -511,6 +511,9 @@ subroutine CLMFatesGlobals2() call set_fates_ctrlparms('use_cohort_age_tracking',ival=pass_cohort_age_tracking) ! FATES logging and harvest modes + pass_logging = 0 + pass_lu_harvest = 0 + pass_num_lu_harvest_cats = 0 if (fates_harvest_mode > fates_harvest_no_logging) then pass_logging = 1 ! Time driven logging, without landuse harvest ! CLM landuse timeseries driven harvest rates @@ -522,9 +525,6 @@ subroutine CLMFatesGlobals2() else if (fates_harvest_mode >= fates_harvest_luh_area) then pass_lu_harvest = 1 pass_num_lu_harvest_cats = num_landuse_harvest_vars - else - pass_lu_harvest = 0 - pass_num_lu_harvest_cats = 0 end if end if From 28f5bc36108af5281f3fdfd286b43bac5a849786 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 13 May 2024 15:25:00 -0700 Subject: [PATCH 080/194] update fates_harvest_mode to accept strings --- bld/CLMBuildNamelist.pm | 4 +-- bld/namelist_files/namelist_defaults_ctsm.xml | 6 ++--- .../namelist_definition_ctsm.xml | 17 ++++++------ bld/unit_testers/build-namelist_test.pl | 6 ++--- .../clm/FatesColdLUH2Mode0/user_nl_clm | 2 +- .../clm/FatesColdLUH2Mode1/user_nl_clm | 2 +- .../clm/FatesColdLUH2Mode2/user_nl_clm | 2 +- .../clm/FatesColdLUH2Mode3/user_nl_clm | 2 +- .../clm/FatesColdLUH2Mode4/user_nl_clm | 2 +- src/dyn_subgrid/dynSubgridDriverMod.F90 | 2 +- src/utils/clmfates_interfaceMod.F90 | 27 ++++++++++--------- 11 files changed, 37 insertions(+), 35 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index aafc7739a3..456447925c 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4478,7 +4478,7 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh must be true when $var is true" ); } - if ( $nl->get_value('fates_harvest_mode') > 0) { + if ( $nl->get_value('fates_harvest_mode') ne 'no_harvest') { $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); } } @@ -4487,7 +4487,7 @@ sub setup_logic_fates { my $var = "fates_harvest_mode"; if ( defined($nl->get_value($var)) ) { # using fates_harvest mode with raw luh2 harvest data - if ( $nl->get_value($var) > 2) { + if ( $nl->get_value($var) eq 'luhdata_area' || $nl->get_value($var) eq 'luhdata_mass' ) { # Make sure that use_fates_luh is true when using raw fates luh2 harvest data if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 9d2a34b7bf..5da9cb22bf 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2759,7 +2759,7 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 0 -0 +no_harvest .false. .false. .false. @@ -2769,8 +2769,8 @@ use_crop=".true.">lnd/clm2/surfdata_map/ctsm5.1.dev052/landuse.timeseries_mpasa1 .false. .false. .false. -.true. -.true. +.true. +.true. .true. .true. .false. diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index edcfa36d27..03b1e9e64d 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -735,14 +735,14 @@ Toggle to turn on FATES satellite phenology mode (only relevant if FATES is bein -Set FATES harvesting mode by setting fates_harvest_mode > 0. + group="clm_inparm" valid_values="no_harvest_event_code,surfdata_file,luhdata_area,luhdata_mass"> +Set FATES harvesting mode by setting fates_harvest_mode to a valid string option. Allowed values are: - 0 : no fates harvesting of any kind - 1 : fates logging via fates logging event codes (see fates parameter file) only - 2 : fates harvest driven by CLM landuse timeseries data (dynHarvestMod) - 3 : fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) - 4 : fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) + no_harvest: no fates harvesting of any kind + event_code: fates logging via fates logging event codes (see fates parameter file) only + surfdata_file: fates harvest driven by CLM landuse timeseries data (dynHarvestMod) + luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) + luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) If TRUE, enable use of land use harmonization (LUH) state and transition data from luh_timeseries file. -This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harvest -data (fates_harvest_mode >= 3) +This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harvest data (Also, only valid for use_fates = true and is incompatible with transient runs currently.) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index f674849b6f..973fdffd16 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1047,7 +1047,7 @@ sub cat_and_create_namelistinfile { phys=>"clm4_5", }, "useloggingButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", - namelst=>"fates_harvest_mode=1", + namelst=>"fates_harvest_mode=event_code", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, @@ -1102,12 +1102,12 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "useFATESPOTVEGwithHARVEST" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_potentialveg=T,fates_harvest_mode=1", + namelst=>"use_fates_potentialveg=T,fates_harvest_mode=event_code", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, "useFATESHARVEST3WOLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_luh=F,fates_harvest_mode=3", + namelst=>"use_fates_luh=F,fates_harvest_mode=luhdata_area", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm index 929a8e6e14..b3b338e232 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 0 +fates_harvest_mode = no_harvest diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm index dea75b71e7..c0e1c476be 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 1 +fates_harvest_mode = event_code diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm index fd4c74fe57..61e1daaa93 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 2 +fates_harvest_mode = surfdata_file diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm index 3332e9e526..d760105e68 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 3 +fates_harvest_mode = luhdata_area diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm index 13dae9efee..bb5f30f75d 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = 4 +fates_harvest_mode = luhdata_mass diff --git a/src/dyn_subgrid/dynSubgridDriverMod.F90 b/src/dyn_subgrid/dynSubgridDriverMod.F90 index 162247a0ff..faef029b40 100644 --- a/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -128,7 +128,7 @@ subroutine dynSubgrid_init(bounds_proc, glc_behavior, crop_inst) ! flanduse_timeseries file. However, this could theoretically be changed so that the ! harvest data were separated from the pftdyn data, allowing them to differ in the ! years over which they apply. - if (get_do_harvest() .or. fates_harvest_mode == fates_harvest_clmlanduse) then + if (get_do_harvest() .or. trim(fates_harvest_mode) == fates_harvest_clmlanduse) then call dynHarvest_init(bounds_proc, harvest_filename=get_flanduse_timeseries()) end if diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index ba6c59143f..4205802088 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -186,6 +186,7 @@ module CLMFatesInterfaceMod use dynFATESLandUseChangeMod, only : fates_harvest_no_logging use dynFATESLandUseChangeMod, only : fates_harvest_clmlanduse use dynFATESLandUseChangeMod, only : fates_harvest_luh_area + use dynFATESLandUseChangeMod, only : fates_harvest_luh_mass use dynFATESLandUseChangeMod, only : landuse_harvest use dynFATESLandUseChangeMod, only : landuse_harvest_units use dynFATESLandUseChangeMod, only : landuse_harvest_varnames @@ -514,20 +515,25 @@ subroutine CLMFatesGlobals2() pass_logging = 0 pass_lu_harvest = 0 pass_num_lu_harvest_cats = 0 - if (fates_harvest_mode > fates_harvest_no_logging) then + if (trim(fates_harvest_mode) /= fates_harvest_no_logging) then pass_logging = 1 ! Time driven logging, without landuse harvest ! CLM landuse timeseries driven harvest rates - if (fates_harvest_mode == fates_harvest_clmlanduse) then + if (trim(fates_harvest_mode) == fates_harvest_clmlanduse) then pass_num_lu_harvest_cats = num_harvest_inst pass_lu_harvest = 1 ! LUH2 landuse timeseries driven harvest rates - else if (fates_harvest_mode >= fates_harvest_luh_area) then + else if (trim(fates_harvest_mode)== fates_harvest_luh_area .or. & + trim(fates_harvest_mode)== fates_harvest_luh_mass) then pass_lu_harvest = 1 pass_num_lu_harvest_cats = num_landuse_harvest_vars end if end if + call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) + call set_fates_ctrlparms('num_lu_harvest_cats',ival=pass_num_lu_harvest_cats) + call set_fates_ctrlparms('use_logging',ival=pass_logging) + ! FATES landuse modes if(use_fates_luh) then pass_use_luh = 1 @@ -550,11 +556,6 @@ subroutine CLMFatesGlobals2() end if call set_fates_ctrlparms('use_fates_potentialveg',ival=pass_use_potentialveg) - ! Wait to set the harvest and logging variables after checking fates_harvest_modes - call set_fates_ctrlparms('use_lu_harvest',ival=pass_lu_harvest) - call set_fates_ctrlparms('num_lu_harvest_cats',ival=pass_num_lu_harvest_cats) - call set_fates_ctrlparms('use_logging',ival=pass_logging) - if(use_fates_inventory_init) then pass_inventory_init = 1 else @@ -979,7 +980,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & call GetAndSetTime ! Get harvest rates for CLM landuse timeseries driven rates - if (fates_harvest_mode == fates_harvest_clmlanduse) then + if (trim(fates_harvest_mode) == fates_harvest_clmlanduse) then call dynHarvest_interp_resolve_harvesttypes(bounds_clump, & harvest_rates=harvest_rates(begg:endg,1:num_harvest_inst), & after_start_of_harvest_ts=after_start_of_harvest_ts) @@ -1105,7 +1106,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! for now there is one veg column per gridcell, so store all harvest data in each site ! this will eventually change ! today's hlm harvest flag needs to be set no matter what - if (fates_harvest_mode == fates_harvest_clmlanduse) then + if (trim(fates_harvest_mode) == fates_harvest_clmlanduse) then if (after_start_of_harvest_ts) then this%fates(nc)%bc_in(s)%hlm_harvest_rates(1:num_harvest_inst) = harvest_rates(g,1:num_harvest_inst) else @@ -1124,7 +1125,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & call endrun(msg=errMsg(sourcefile, __LINE__)) end if - else if (fates_harvest_mode >= fates_harvest_luh_area) then + else if (trim(fates_harvest_mode) == fates_harvest_luh_area .or. & + trim(fates_harvest_mode) == fates_harvest_luh_mass) then this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units @@ -2082,7 +2084,8 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, & this%fates(nc)%bc_in(s)%hlm_luh_transitions = landuse_transitions(:,g) this%fates(nc)%bc_in(s)%hlm_luh_transition_names = landuse_transition_varnames - if (fates_harvest_mode >= fates_harvest_luh_area ) then + if (trim(fates_harvest_mode) == fates_harvest_luh_area .or. & + trim(fates_harvest_mode) == fates_harvest_luh_mass) then this%fates(nc)%bc_in(s)%hlm_harvest_rates = landuse_harvest(:,g) this%fates(nc)%bc_in(s)%hlm_harvest_catnames = landuse_harvest_varnames this%fates(nc)%bc_in(s)%hlm_harvest_units = landuse_harvest_units From f19a080721f5fffa96b580da51a170cbe80d4244 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 15 May 2024 17:59:34 -0600 Subject: [PATCH 081/194] add more landuse graceful failures If luh + fbg are present fail if flandusepftdat isn't valid. Don't allow fluh_timeseries to be defined if in potential veg mode to avoid confusing users that it is needed. --- bld/CLMBuildNamelist.pm | 71 ++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index aafc7739a3..0d8ca732b4 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4433,21 +4433,9 @@ sub setup_logic_fates { } } # make sure that fates landuse x pft mode has the necessary run mode configurations - # and add the necessary landuse x pft static mapping data default if not defined my $var = "use_fates_lupft"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, - 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_lupft is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$fname does NOT point to a valid filename" ); - } - - # make sure that nocomp and fbg mode are enabled as well as use_fates_luh my @list = ( "use_fates_luh", "use_fates_nocomp", "use_fates_fixed_biogeog" ); foreach my $var ( @list ) { if ( ! &value_is_true($nl->get_value($var)) ) { @@ -4457,31 +4445,56 @@ sub setup_logic_fates { } } # check that fates landuse change mode has the necessary luh2 landuse timeseries data - # and add the default if not defined + # and add the default if not defined. Do not add default if use_fates_potentialveg is true. + # If fixed biogeography is on, make sure that flandusepftdat is avilable. my $var = "use_fates_luh"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "fluh_timeseries"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_luh is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$fname does NOT point to a valid filename" ); - } + $var = "use_fates_potentialveg"; + if ( defined($nl->get_value($var)) ) { + if ( ! &value_is_true($nl->get_value($var)) ) { + $var = "fluh_timeseries"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, + 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh is set and use_fates_potentialveg is false" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } + $var = "use_fates_fixed_biogeog"; + if ( defined($nl->get_value($var)) ) { + if ( &value_is_true($nl->get_value($var)) ) { + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } } } # check that fates landuse is on and harvest mode is off when potential veg switch is true my $var = "use_fates_potentialveg"; if ( defined($nl->get_value($var)) ) { - if ( &value_is_true($nl->get_value($var)) ) { - if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { - $log->fatal_error("use_fates_luh must be true when $var is true" ); - } - if ( $nl->get_value('fates_harvest_mode') > 0) { - $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); - } - } + if ( &value_is_true($nl->get_value($var)) ) { + if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { + $log->fatal_error("use_fates_luh must be true when $var is true" ); + } + if ( $nl->get_value('fates_harvest_mode') > 0) { + $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); + } + my $var = "fluh_timeseries"; + if ( defined($nl->get_value($var)) ) { + $log->fatal_error("fluh_timeseries can not be defined when use_fates_potentialveg is true" ); + } + } } # Check fates_harvest_mode compatibility my $var = "fates_harvest_mode"; From 7c5c632f02b54f2285bdfb3902834d78715077f7 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 16 May 2024 15:03:31 -0600 Subject: [PATCH 082/194] fix namelist definition --- bld/namelist_files/namelist_definition_ctsm.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 03b1e9e64d..58e0aca3a6 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -734,8 +734,8 @@ Toggle to turn on no competition mode (only relevant if FATES is being used). Toggle to turn on FATES satellite phenology mode (only relevant if FATES is being used). - + Set FATES harvesting mode by setting fates_harvest_mode to a valid string option. Allowed values are: no_harvest: no fates harvesting of any kind From 5e9bc2e9a40987ff5477d0b3cdc742c3fbcf5f23 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 16 May 2024 15:04:39 -0600 Subject: [PATCH 083/194] Update finidat that previously failing test now picks up by default --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index c62df7d77b..90e397d544 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1097,7 +1097,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). ic_ymd="20110101" sim_year="2000" do_transient_pfts=".false." ic_tod="0" glc_nec="10" use_crop=".true." irrigate=".true." lnd_tuning_mode="clm6_0_GSWP3v1" ->lnd/clm2/initdata_esmf/ctsm5.2/clmi.I2000Clm50BgcCrop.2011-01-01.1.9x2.5_gx1v7_gl4_simyr2000_c240223.nc +>lnd/clm2/initdata_esmf/ctsm5.2/clmi.I2000Clm52BgcCrop.2000-01-01.1.9x2.5_gx1v7_gl4_simyr2000_c240515.nc From 0266a70e98142750e6c34494740a8dd3e600a93c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 16 May 2024 15:22:10 -0600 Subject: [PATCH 084/194] update landuse parameters from ints to chars --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index d9bd0352ca..f330ee2b78 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -35,11 +35,11 @@ module dynFATESLandUseChangeMod integer, public, parameter :: num_landuse_harvest_vars = 5 ! Define the fates landuse namelist mode switch values - integer, public, parameter :: fates_harvest_no_logging = 0 - integer, public, parameter :: fates_harvest_logging_only = 1 - integer, public, parameter :: fates_harvest_clmlanduse = 2 - integer, public, parameter :: fates_harvest_luh_area = 3 - integer, public, parameter :: fates_harvest_luh_mass = 4 + character(len=13), public, parameter :: fates_harvest_no_logging = 'no_harvest' + character(len=13), public, parameter :: fates_harvest_logging_only = 'event_code' + character(len=13), public, parameter :: fates_harvest_clmlanduse = 'surfdata_file' + character(len=13), public, parameter :: fates_harvest_luh_area = 'luhdata_area' + character(len=13), public, parameter :: fates_harvest_luh_mass = 'luhdata_mass' ! Define landuse harvest unit integer representation integer, public, parameter :: landuse_harvest_area_units = 1 From 438d85a58b120a1329db4c47520ff473a40bcc5b Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Fri, 17 May 2024 09:27:55 -0600 Subject: [PATCH 085/194] Added a missing bracket --- bld/CLMBuildNamelist.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index ad378ffc6d..3658f681af 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -785,7 +785,7 @@ sub setup_cmdl_fates_mode { "use_fates_cohort_age_tracking","use_fates_inventory_init","use_fates_fixed_biogeog", "use_fates_nocomp","use_fates_sp","fates_inventory_ctrl_filename","fates_harvest_mode", "fates_parteh_mode","use_fates_tree_damage","fates_seeddisp_cadence","use_fates_luh","fluh_timeseries", - "flandusepftdat","use_fates_potentialveg","use_fates_lupft","fates_history_dimlevel"); + "flandusepftdat","use_fates_potentialveg","use_fates_lupft","fates_history_dimlevel" ); # dis-allow fates specific namelist items with non-fates runs foreach my $var ( @list ) { @@ -4517,7 +4517,7 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fates_paramfile', 'phys'=>$nl_flags->{'phys'}); my @list = ( "fates_spitfire_mode", "use_fates_planthydro", "use_fates_ed_st3", "use_fates_ed_prescribed_phys", "use_fates_inventory_init","fates_seeddisp_cadence","fates_history_dimlevel", - "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage"); + "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage" ); foreach my $var ( @list ) { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, @@ -4564,12 +4564,12 @@ sub setup_logic_fates { # fates landuse can't be on with FATES SP mode is active if ( &value_is_true($nl->get_value('use_fates_luh')) ) { - $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); + $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); + } # hydro isn't currently supported to work when FATES SP mode is active if (&value_is_true( $nl->get_value('use_fates_planthydro') )) { $log->fatal_error('fates sp mode is currently not supported to work with fates hydro'); - } } } From e6f62c431b05460f62c6549e464797df7a7ebf58 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 17 May 2024 15:56:00 -0600 Subject: [PATCH 086/194] fix reading of fates_harvest_modes during namelist build checks --- bld/CLMBuildNamelist.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 01f7918d62..c1ec60fb33 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4487,8 +4487,9 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh must be true when $var is true" ); } - if ( $nl->get_value('fates_harvest_mode') ne 'no_harvest') { - $log->fatal_error("fates_harvest_mode must be off (i.e. set to zero) when $var is true" ); + my $var = remove_leading_and_trailing_quotes($nl->get_value('fates_harvest_mode')); + if ( $var ne 'no_harvest') { + $log->fatal_error("fates_harvest_mode set to $var. It must set to no_harvest when use_potential_veg is true." ); } my $var = "fluh_timeseries"; if ( defined($nl->get_value($var)) ) { @@ -4500,10 +4501,22 @@ sub setup_logic_fates { my $var = "fates_harvest_mode"; if ( defined($nl->get_value($var)) ) { # using fates_harvest mode with raw luh2 harvest data - if ( $nl->get_value($var) eq 'luhdata_area' || $nl->get_value($var) eq 'luhdata_mass' ) { + my $mode = remove_leading_and_trailing_quotes($nl->get_value($var)); + if ( $mode eq 'luhdata_area' || $mode eq 'luhdata_mass' ) { # Make sure that use_fates_luh is true when using raw fates luh2 harvest data if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { - $log->fatal_error("use_fates_luh is required to be true when $var is greater than 2" ); + $log->fatal_error("use_fates_luh is required to be true when $var is luhdata_mass or luhdata_area" ); + } + } elsif ( $mode eq 'surfdata_file' ) { + # Check to make sure that the user set the flanduse_timeseries file + # Since the flanduse_timeseries logic checking is upstream of the fates logic, + # don't try and add the default here + my $var = "flanduse_timeseries"; + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when fates_harvest_mode is surfdata_file" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); } } } From 093f0666b9b1d78701240a2036e1efca8e073133 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 17 May 2024 16:18:20 -0600 Subject: [PATCH 087/194] minor comment update --- bld/CLMBuildNamelist.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index c1ec60fb33..e563bdffa8 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4510,7 +4510,8 @@ sub setup_logic_fates { } elsif ( $mode eq 'surfdata_file' ) { # Check to make sure that the user set the flanduse_timeseries file # Since the flanduse_timeseries logic checking is upstream of the fates logic, - # don't try and add the default here + # don't add the default here. The onus is on the user to match the correct timeseries + # data to the correct surface dataset resolution my $var = "flanduse_timeseries"; my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { From 3967d77a17e4e6a02362aec42aa3feb187ba6c72 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 22 May 2024 10:28:47 -0600 Subject: [PATCH 088/194] new fates api 36 paramfile default --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 6ef91bb4a0..fdfeba7719 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -481,7 +481,7 @@ attributes from the config_cache.xml file (with keys converted to upper-case). -lnd/clm2/paramdata/fates_params_api.35.0.0_12pft_c240326.nc +lnd/clm2/paramdata/fates_params_api.36.0.0_12pft_c240517.nc From 5b30740bd91e421639bb46239f4d921b8e767b54 Mon Sep 17 00:00:00 2001 From: Sam Rabin Date: Wed, 22 May 2024 13:37:16 -0600 Subject: [PATCH 089/194] Pin FATES external to commit a997af5. --- Externals_CLM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index cfb7beb40f..a8d53e4fdb 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/ckoven/fates -branch = luh2_nocomp_merge +hash = a997af58f38db8ffda259e11f3abcc65478a4903 required = True [externals_description] From 2a7ca01b2177b480e8897fd2921bf00a7ac9c48f Mon Sep 17 00:00:00 2001 From: loaner Date: Wed, 22 May 2024 17:43:48 -0700 Subject: [PATCH 090/194] add systemtest for potential vegetation spin up --- cime_config/SystemTests/pvt.py | 120 ++++++++++++++++++++ cime_config/SystemTests/systemtest_utils.py | 20 +++- 2 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 cime_config/SystemTests/pvt.py diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py new file mode 100644 index 0000000000..e18022220d --- /dev/null +++ b/cime_config/SystemTests/pvt.py @@ -0,0 +1,120 @@ +""" +FATES land use potential vegetation spin up + transient test + +This is a FATES specific test: + +1) conduct a spinup with use_fates_potentialveg on + - write restart file + - use CLM_ACCELERATED_SPINUP? +2) run a transient landuse case with use_fates_lupft + - start from the restart file generated in (1) + +""" +from CIME.XML.standard_module_setup import * +from CIME.SystemTests.system_tests_common import SystemTestsCommon +from systemtest_utils import read_user_nl_clm +import shutil, glob, os + +logger = logging.getLogger(__name__) + +class PVT(SystemTestsCommon): + def __init_(self,case): + SystemTestsCommon.__init__(self,case) + + # Do not allow PVT to be run with certain testmods + # Should this be targeted to a specific testmod for simplicity for now? + # Technically this could be run with the luh fates_harvest_modes + casebaseid = self._case.get_value("CASEBASEID") + casebasid = casebaseid.split("-")[-1] + if casebaseid[0:10] != "FatesLUPFT": + error_message = ( + "Only call PVT with test FatesLUPFT" + ) + logger.error(error_message) + raise RuntimeError(error_message) + + # Only allow to run if resolution is 4x5 for now + # Eventually we could set this up to generate the necessary land use x pft mapping + # on the fly, although this would also require generating the land use timeseries + # regridding on the fly which is a more time consuming endevour currently + lnd_grid = self._case.get_value("LND_GRID") + if lnd_grid != "4x5": + error_message = ( + "PVT can currently only be run with 4x5 resolution" + ) + logger.error(error_message) + raise RuntimeError(error_message) + + def run_phase(self): + # ------------------------------------------------------------------- + # (1) Run FATES spin-up case in potential vegetation mode + # ------------------------------------------------------------------- + orig_case = self._case + orig_casevar = self._case.get_value("CASE") + caseroot = self._case.get_value("CASEROOT") + + # clone the main case to create spinup case + logger.info("PVT log: cloning setup") + clone_path = "{}.potveg".format(caseroot) + if os.path.exists(clone_path): + shutil.rmtree(clone_path) + logger.info("PVT log: cloning") + clone = self._case.create_clone(clone_path, keepexe=True) + logger.info("PVT log: cloning complete") + + # setup the clone case + os.chdir(clone_path) + self._set_active_case(clone) + self._setup_all() + + # Modify the spin up case to use the potential vegetation mode. + # Checks for incompatible cases and necessary mapping files are + # handled in the build case. + # use_fates_lupft should be set to true in the testmod + # save off the harvest mode for reinstating later + found, hmode = self.read_user_nl_clm('fates_harvest_mode') + logger.info("PVT log: modify user_nl_clm file for spin up run") + # TODO: remove fates_harvest_mode if found + self._append_to_user_nl_clm( + [ + "use_fates_potentialveg = .true.", + ] + ) + + stop_n_pveg = 1 + with clone: + # clone.set_value("CLM_ACCELERATED_SPINUP", "on") + clone.set_value("STOP_N", stop_n_pveg) + + # Run the spin up case + # As per SSP test: + # "No history files expected, set suffix=None to avoid compare error" + logger.info("PVT log: starting spin-up run") + dout_sr = clone.get_value("DOUT_S_ROOT") + self._skip_pnl = False + self.run_indv(suffix=None, st_archive=True) + + # ------------------------------------------------------------------- + # (2) Run FATES transient case using restart file from spin-up + # ------------------------------------------------------------------- + os.chdir(caseroot) + self._set_active_case(orig_case) + + # logger.info("PVT log: modify user_nl_clm file for transient run") + # self._append_to_user_nl_clm( + # [ + # "use_fates_potentialveg = .true.", + # ] + # ) + + + self._case.set_value("CLM_ACCELERATED_SPINUP", "off") + self._case.set_value("RUN_TYPE", "hybrid") + self._case.set_value("GET_REFCASE", False) + self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) + self._case.set_value("RUN_REFDATE", "1700-01-01") + self._case.set_value("DOUT_S", False) + self._case.flush() + + # do the restart run (short term archiving is off) + self.run_indv() diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index c5ac986abd..8447934797 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -2,7 +2,7 @@ Reduce code duplication by putting reused functions here. """ -import os, subprocess +import os, subprocess, re def cmds_to_setup_conda(caseroot): @@ -84,3 +84,21 @@ def run_python_script(caseroot, this_conda_env, command_in, tool_path): except: print(f"ERROR trying to run {tool_name}.") raise + +def read_user_nl_clm(self,namelist_option): + user_nl_clm_path = os.path.join(self._get_caseroot(), "user_nl_clm") + with open(user_nl_clm_path) as f: + user_nl_clm_text = f.read() + reg = fr'{namelist_option}\s*=\s*([^\n]+)' + find_out = re.findall(reg, user_nl_clm_text) + # This could be more robust + if len(find_out) == 0: + return 0, False + elif len(find_out) > 1: + error_message = ( + "ERROR: read_user_nl_clm: namelist option is set more than once" + ) + # logger.error(error_message) + raise RuntimeError(error_message) + else: + return find_out[0], True From b7cf13f6dcfd6c975de294ef90122bb4e2fc0d3e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 13:47:07 -0700 Subject: [PATCH 091/194] add PVT system test to the config_test xml file --- cime_config/config_tests.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cime_config/config_tests.xml b/cime_config/config_tests.xml index c0b6afed9d..8a4388c664 100644 --- a/cime_config/config_tests.xml +++ b/cime_config/config_tests.xml @@ -123,6 +123,18 @@ This defines various CTSM-specific system tests $STOP_N + + FATES potential vegetarion spin-up + land use transient run test + 1 + ndays + startup + 4 + FALSE + FALSE + $STOP_OPTION + $STOP_N + + Generate prescribed maturity requirements, then test with them 1 From 8e35d80baf507185ef0dac47a4adee4bf975d47e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 14:29:02 -0600 Subject: [PATCH 092/194] add test mode for use_fates_lupft --- .../testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods | 1 + cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm | 1 + 2 files changed, 2 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods new file mode 100644 index 0000000000..4c7aa0f2b4 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/include_user_mods @@ -0,0 +1 @@ +../Fates diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm new file mode 100644 index 0000000000..10044848a0 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/user_nl_clm @@ -0,0 +1 @@ +use_fates_lupft = .true. From af5451b7e37d53d1192fb87315d01fb16b527ba1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 14:39:45 -0700 Subject: [PATCH 093/194] remove tabs and correct whitespace --- bld/CLMBuildNamelist.pm | 58 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index acdad5c5cc..b17a245715 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4520,22 +4520,22 @@ sub setup_logic_fates { "fates_harvest_mode","fates_parteh_mode", "use_fates_cohort_age_tracking","use_fates_tree_damage" ); foreach my $var ( @list ) { - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); } - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_potentialveg', 'use_fates'=>$nl_flags->{'use_fates'}); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), - 'use_fates_potentialveg'=>$nl->get_value('use_fates_potentialveg'), - 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), - 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_fixed_biogeog', 'use_fates'=>$nl_flags->{'use_fates'}, - 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), - 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_potentialveg', 'use_fates'=>$nl_flags->{'use_fates'}); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_lupft', 'use_fates'=>$nl_flags->{'use_fates'}); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_potentialveg'=>$nl->get_value('use_fates_potentialveg'), + 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_fixed_biogeog', 'use_fates'=>$nl_flags->{'use_fates'}, + 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), + 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); my $suplnitro = $nl->get_value('suplnitro'); my $parteh_mode = $nl->get_value('fates_parteh_mode'); @@ -4564,8 +4564,8 @@ sub setup_logic_fates { # fates landuse can't be on with FATES SP mode is active if ( &value_is_true($nl->get_value('use_fates_luh')) ) { - $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); - } + $log->fatal_error('use_fates_luh can NOT be true when use_fates_sp is true'); + } # hydro isn't currently supported to work when FATES SP mode is active if (&value_is_true( $nl->get_value('use_fates_planthydro') )) { @@ -4608,7 +4608,7 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value($var)) ) { $var = "fluh_timeseries"; add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, - 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); + 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { $log->fatal_error("$var is required when use_fates_luh is set and use_fates_potentialveg is false" ); @@ -4616,21 +4616,21 @@ sub setup_logic_fates { $log->fatal_error("$var does NOT point to a valid filename" ); } } - } + } $var = "use_fates_fixed_biogeog"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, - 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$var does NOT point to a valid filename" ); - } - } - } + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } } } # check that fates landuse is on and harvest mode is off when potential veg switch is true From 00d23e9adb4139847dc5f855ff4ce43bc845b41e Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 16:48:55 -0600 Subject: [PATCH 094/194] correct add default for fluh and flandusepftdat --- bld/CLMBuildNamelist.pm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index b17a245715..d952e7fe89 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4607,8 +4607,8 @@ sub setup_logic_fates { if ( defined($nl->get_value($var)) ) { if ( ! &value_is_true($nl->get_value($var)) ) { $var = "fluh_timeseries"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'phys'=>$nl_flags->{'phys'}, - 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}, nofail=>1 ); + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, + 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { $log->fatal_error("$var is required when use_fates_luh is set and use_fates_potentialveg is false" ); @@ -4620,17 +4620,17 @@ sub setup_logic_fates { $var = "use_fates_fixed_biogeog"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, - 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$var does NOT point to a valid filename" ); - } - } - } + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } } } # check that fates landuse is on and harvest mode is off when potential veg switch is true From 2ac13bcb7aeec5a1772635edfe7c0f99be9c532d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 17:39:57 -0600 Subject: [PATCH 095/194] correct typos causing RunTimeError to be missed --- cime_config/SystemTests/pvt.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index e18022220d..c45c514f39 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -18,20 +18,17 @@ logger = logging.getLogger(__name__) class PVT(SystemTestsCommon): - def __init_(self,case): + def __init__(self,case): SystemTestsCommon.__init__(self,case) # Do not allow PVT to be run with certain testmods # Should this be targeted to a specific testmod for simplicity for now? # Technically this could be run with the luh fates_harvest_modes + error_message = None casebaseid = self._case.get_value("CASEBASEID") - casebasid = casebaseid.split("-")[-1] + casebaseid = casebaseid.split("-")[-1] if casebaseid[0:10] != "FatesLUPFT": - error_message = ( - "Only call PVT with test FatesLUPFT" - ) - logger.error(error_message) - raise RuntimeError(error_message) + error_message = (f"Only call PVT with testmod FatesLUPFT. {casebaseid} selected.") # Only allow to run if resolution is 4x5 for now # Eventually we could set this up to generate the necessary land use x pft mapping @@ -39,12 +36,11 @@ def __init_(self,case): # regridding on the fly which is a more time consuming endevour currently lnd_grid = self._case.get_value("LND_GRID") if lnd_grid != "4x5": - error_message = ( - "PVT can currently only be run with 4x5 resolution" - ) + error_message = (f"PVT can currently only be run with 4x5 resolution. {lnd_grid} selected.") + + if error_message is not None: logger.error(error_message) raise RuntimeError(error_message) - def run_phase(self): # ------------------------------------------------------------------- # (1) Run FATES spin-up case in potential vegetation mode From f4ff559c831533ab9c901d1f44e5744740a8f302 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 23 May 2024 16:45:42 -0700 Subject: [PATCH 096/194] remove tabs again --- bld/CLMBuildNamelist.pm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index d952e7fe89..0fb7ba9692 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4608,7 +4608,7 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value($var)) ) { $var = "fluh_timeseries"; add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, - 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); + 'hgrid'=>$nl_flags->{'res'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'}); my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { $log->fatal_error("$var is required when use_fates_luh is set and use_fates_potentialveg is false" ); @@ -4620,17 +4620,17 @@ sub setup_logic_fates { $var = "use_fates_fixed_biogeog"; if ( defined($nl->get_value($var)) ) { if ( &value_is_true($nl->get_value($var)) ) { - $var = "flandusepftdat"; - add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, - 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); - my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); - if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); - } elsif ( ! -f "$fname" ) { - $log->fatal_error("$var does NOT point to a valid filename" ); - } - } - } + $var = "flandusepftdat"; + add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, $var, 'use_fates'=>$nl_flags->{'use_fates'}, + 'phys'=>$nl_flags->{'phys'}, 'hgrid'=>$nl_flags->{'res'}, nofail=>1 ); + my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); + if ( ! defined($nl->get_value($var)) ) { + $log->fatal_error("$var is required when use_fates_luh and use_fates_fixed_biogeog is set" ); + } elsif ( ! -f "$fname" ) { + $log->fatal_error("$var does NOT point to a valid filename" ); + } + } + } } } # check that fates landuse is on and harvest mode is off when potential veg switch is true From de8c0a33315693c9dc66b267bd255e703f9010c0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 13:53:13 -0600 Subject: [PATCH 097/194] update what new utility function returns as output --- cime_config/SystemTests/systemtest_utils.py | 41 ++++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index 8447934797..9470799a27 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -2,7 +2,7 @@ Reduce code duplication by putting reused functions here. """ -import os, subprocess, re +import os, subprocess, re, glob def cmds_to_setup_conda(caseroot): @@ -84,21 +84,26 @@ def run_python_script(caseroot, this_conda_env, command_in, tool_path): except: print(f"ERROR trying to run {tool_name}.") raise +""" +Read a user_nl file and return the namelist option if found +""" +def find_user_nl_option(caseroot, component, namelist_option): + + # This is a copy of the CIME _get_list_of_user_nl_files + # which could be used if this moved into the CIME project + file_pattern = "user_nl_" + component + "*" + file_list = glob.glob(os.path.join(caseroot, file_pattern)) + + # Check that there is at least one file + if len(file_list) == 0: + raise RuntimeError("No user_nl files found for component " + component) -def read_user_nl_clm(self,namelist_option): - user_nl_clm_path = os.path.join(self._get_caseroot(), "user_nl_clm") - with open(user_nl_clm_path) as f: - user_nl_clm_text = f.read() - reg = fr'{namelist_option}\s*=\s*([^\n]+)' - find_out = re.findall(reg, user_nl_clm_text) - # This could be more robust - if len(find_out) == 0: - return 0, False - elif len(find_out) > 1: - error_message = ( - "ERROR: read_user_nl_clm: namelist option is set more than once" - ) - # logger.error(error_message) - raise RuntimeError(error_message) - else: - return find_out[0], True + # Read through the file list and look for a match and return the whole entry + output = {} + for one_file in file_list: + with open(one_file, "r") as user_nl_file: + user_nl_text = user_nl_file.read() + reg = fr'{namelist_option}.*?(?=,|\n)' + find_out = re.findall(reg, user_nl_text) + output[one_file] = find_out + return output From cd04c06c06e1399c262c970180f291d583eaf72b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 14:06:36 -0600 Subject: [PATCH 098/194] change dictionary to ordered dict --- cime_config/SystemTests/systemtest_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index 9470799a27..2591ac4223 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -3,6 +3,7 @@ """ import os, subprocess, re, glob +from collections import OrderedDict def cmds_to_setup_conda(caseroot): @@ -99,7 +100,7 @@ def find_user_nl_option(caseroot, component, namelist_option): raise RuntimeError("No user_nl files found for component " + component) # Read through the file list and look for a match and return the whole entry - output = {} + output = OrderedDict() for one_file in file_list: with open(one_file, "r") as user_nl_file: user_nl_text = user_nl_file.read() From dab63611a6088551ff2959f1c04bcfbc4b61c2db Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 16:13:59 -0600 Subject: [PATCH 099/194] pvt system init step update --- cime_config/SystemTests/pvt.py | 149 ++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 67 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index c45c514f39..184c5de289 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -12,7 +12,8 @@ """ from CIME.XML.standard_module_setup import * from CIME.SystemTests.system_tests_common import SystemTestsCommon -from systemtest_utils import read_user_nl_clm +from CIME.SystemTests.test_utils.user_nl_utils import append_to_user_nl_files +from systemtest_utils import find_user_nl_option import shutil, glob, os logger = logging.getLogger(__name__) @@ -41,76 +42,90 @@ def __init__(self,case): if error_message is not None: logger.error(error_message) raise RuntimeError(error_message) - def run_phase(self): - # ------------------------------------------------------------------- - # (1) Run FATES spin-up case in potential vegetation mode - # ------------------------------------------------------------------- - orig_case = self._case - orig_casevar = self._case.get_value("CASE") - caseroot = self._case.get_value("CASEROOT") - - # clone the main case to create spinup case - logger.info("PVT log: cloning setup") - clone_path = "{}.potveg".format(caseroot) - if os.path.exists(clone_path): - shutil.rmtree(clone_path) - logger.info("PVT log: cloning") - clone = self._case.create_clone(clone_path, keepexe=True) - logger.info("PVT log: cloning complete") - # setup the clone case - os.chdir(clone_path) - self._set_active_case(clone) - self._setup_all() + # Look to see if a harvest mode has been set in the namelist and save off for the transient run + # If there are more than one entries in the dict, i.e. multiple user_nl_clm's found, abort. + # If there are multiple enteries the user_nl_clm, use the last one as the dict is ordered + caseroot = self._case.get_value("CASEROOT") + harvest_mode_dict = find_user_nl_option(caseroot, 'clm', 'fates_harvest_mode') + harvest_mode = None + if len(harvest_mode_dict) == 1: + hmod = harvest_mode_dict[next(reversed(harvest_mode_dict))] + if len(hmod) != 0: + harvest_mode = hmod[-1] + elif (len(harvest_mode_dict)) > 1: + raise RuntimeError('Multiple user_nl_clm files found. PVT assumes only a single user_nl_clm case') # Modify the spin up case to use the potential vegetation mode. # Checks for incompatible cases and necessary mapping files are # handled in the build case. # use_fates_lupft should be set to true in the testmod - # save off the harvest mode for reinstating later - found, hmode = self.read_user_nl_clm('fates_harvest_mode') - logger.info("PVT log: modify user_nl_clm file for spin up run") - # TODO: remove fates_harvest_mode if found - self._append_to_user_nl_clm( - [ - "use_fates_potentialveg = .true.", - ] - ) - - stop_n_pveg = 1 - with clone: - # clone.set_value("CLM_ACCELERATED_SPINUP", "on") - clone.set_value("STOP_N", stop_n_pveg) - - # Run the spin up case - # As per SSP test: - # "No history files expected, set suffix=None to avoid compare error" - logger.info("PVT log: starting spin-up run") - dout_sr = clone.get_value("DOUT_S_ROOT") - self._skip_pnl = False - self.run_indv(suffix=None, st_archive=True) + # If the testmod has a fates harvest mode, make sure to append 'no_harvest' + # to the spin up case - # ------------------------------------------------------------------- - # (2) Run FATES transient case using restart file from spin-up - # ------------------------------------------------------------------- - os.chdir(caseroot) - self._set_active_case(orig_case) - - # logger.info("PVT log: modify user_nl_clm file for transient run") - # self._append_to_user_nl_clm( - # [ - # "use_fates_potentialveg = .true.", - # ] - # ) - - - self._case.set_value("CLM_ACCELERATED_SPINUP", "off") - self._case.set_value("RUN_TYPE", "hybrid") - self._case.set_value("GET_REFCASE", False) - self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) - self._case.set_value("RUN_REFDATE", "1700-01-01") - self._case.set_value("DOUT_S", False) - self._case.flush() - - # do the restart run (short term archiving is off) - self.run_indv() + logger.info("PVT log: modify user_nl_clm file for spin up run") + added_content = ["use_fates_potentialveg = .true."] + if harvest_mode is not None: + added_content.append("fates_harvest_mode = 'no_harvest'") + append_to_user_nl_files(caseroot, "clm", added_content) + +# def run_phase(self): +# # ------------------------------------------------------------------- +# # (1) Run FATES spin-up case in potential vegetation mode +# # ------------------------------------------------------------------- +# orig_case = self._case +# orig_casevar = self._case.get_value("CASE") +# caseroot = self._case.get_value("CASEROOT") +# +# # clone the main case to create spinup case +# logger.info("PVT log: cloning setup") +# clone_path = "{}.potveg".format(caseroot) +# if os.path.exists(clone_path): +# shutil.rmtree(clone_path) +# logger.info("PVT log: cloning") +# clone = self._case.create_clone(clone_path, keepexe=True) +# logger.info("PVT log: cloning complete") +# +# # setup the clone case +# os.chdir(clone_path) +# self._set_active_case(clone) +# self._setup_all() +# +# +# stop_n_pveg = 1 +# with clone: +# # clone.set_value("CLM_ACCELERATED_SPINUP", "on") +# clone.set_value("STOP_N", stop_n_pveg) +# +# # Run the spin up case +# # As per SSP test: +# # "No history files expected, set suffix=None to avoid compare error" +# logger.info("PVT log: starting spin-up run") +# dout_sr = clone.get_value("DOUT_S_ROOT") +# self._skip_pnl = False +# self.run_indv(suffix=None, st_archive=True) +# +# # ------------------------------------------------------------------- +# # (2) Run FATES transient case using restart file from spin-up +# # ------------------------------------------------------------------- +# os.chdir(caseroot) +# self._set_active_case(orig_case) +# +# # logger.info("PVT log: modify user_nl_clm file for transient run") +# # self._append_to_user_nl_clm( +# # [ +# # "use_fates_potentialveg = .true.", +# # ] +# # ) +# +# +# self._case.set_value("CLM_ACCELERATED_SPINUP", "off") +# self._case.set_value("RUN_TYPE", "hybrid") +# self._case.set_value("GET_REFCASE", False) +# self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) +# self._case.set_value("RUN_REFDATE", "1700-01-01") +# self._case.set_value("DOUT_S", False) +# self._case.flush() +# +# # do the restart run (short term archiving is off) +# self.run_indv() From 175a3d01082437945f15660f75aca860c626d0a4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 18:14:18 -0600 Subject: [PATCH 100/194] pvt system test setup looks correct --- cime_config/SystemTests/pvt.py | 132 +++++++++++++-------------------- 1 file changed, 53 insertions(+), 79 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index 184c5de289..6b2a958eaa 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -43,89 +43,63 @@ def __init__(self,case): logger.error(error_message) raise RuntimeError(error_message) - # Look to see if a harvest mode has been set in the namelist and save off for the transient run - # If there are more than one entries in the dict, i.e. multiple user_nl_clm's found, abort. - # If there are multiple enteries the user_nl_clm, use the last one as the dict is ordered + def run_phase(self): + # ------------------------------------------------------------------- + # (1) Run FATES spin-up case in potential vegetation mode + # ------------------------------------------------------------------- + orig_case = self._case + orig_casevar = self._case.get_value("CASE") caseroot = self._case.get_value("CASEROOT") - harvest_mode_dict = find_user_nl_option(caseroot, 'clm', 'fates_harvest_mode') - harvest_mode = None - if len(harvest_mode_dict) == 1: - hmod = harvest_mode_dict[next(reversed(harvest_mode_dict))] - if len(hmod) != 0: - harvest_mode = hmod[-1] - elif (len(harvest_mode_dict)) > 1: - raise RuntimeError('Multiple user_nl_clm files found. PVT assumes only a single user_nl_clm case') + + # clone the main case to create spinup case + logger.info("PVT log: cloning setup") + clone_path = "{}.potveg".format(caseroot) + if os.path.exists(clone_path): + shutil.rmtree(clone_path) + logger.info("PVT log: cloning") + clone = self._case.create_clone(clone_path, keepexe=True) + logger.info("PVT log: cloning complete") + + # setup the clone case + os.chdir(clone_path) + self._set_active_case(clone) + + # set the clone case values + stop_n_pveg = 1 + with clone: + # clone.set_value("CLM_ACCELERATED_SPINUP", "on") + clone.set_value("STOP_N", stop_n_pveg) # Modify the spin up case to use the potential vegetation mode. # Checks for incompatible cases and necessary mapping files are # handled in the build case. - # use_fates_lupft should be set to true in the testmod - # If the testmod has a fates harvest mode, make sure to append 'no_harvest' - # to the spin up case + # Turn off fates_harvest_mode for the spin up. logger.info("PVT log: modify user_nl_clm file for spin up run") - added_content = ["use_fates_potentialveg = .true."] - if harvest_mode is not None: - added_content.append("fates_harvest_mode = 'no_harvest'") - append_to_user_nl_files(caseroot, "clm", added_content) - -# def run_phase(self): -# # ------------------------------------------------------------------- -# # (1) Run FATES spin-up case in potential vegetation mode -# # ------------------------------------------------------------------- -# orig_case = self._case -# orig_casevar = self._case.get_value("CASE") -# caseroot = self._case.get_value("CASEROOT") -# -# # clone the main case to create spinup case -# logger.info("PVT log: cloning setup") -# clone_path = "{}.potveg".format(caseroot) -# if os.path.exists(clone_path): -# shutil.rmtree(clone_path) -# logger.info("PVT log: cloning") -# clone = self._case.create_clone(clone_path, keepexe=True) -# logger.info("PVT log: cloning complete") -# -# # setup the clone case -# os.chdir(clone_path) -# self._set_active_case(clone) -# self._setup_all() -# -# -# stop_n_pveg = 1 -# with clone: -# # clone.set_value("CLM_ACCELERATED_SPINUP", "on") -# clone.set_value("STOP_N", stop_n_pveg) -# -# # Run the spin up case -# # As per SSP test: -# # "No history files expected, set suffix=None to avoid compare error" -# logger.info("PVT log: starting spin-up run") -# dout_sr = clone.get_value("DOUT_S_ROOT") -# self._skip_pnl = False -# self.run_indv(suffix=None, st_archive=True) -# -# # ------------------------------------------------------------------- -# # (2) Run FATES transient case using restart file from spin-up -# # ------------------------------------------------------------------- -# os.chdir(caseroot) -# self._set_active_case(orig_case) -# -# # logger.info("PVT log: modify user_nl_clm file for transient run") -# # self._append_to_user_nl_clm( -# # [ -# # "use_fates_potentialveg = .true.", -# # ] -# # ) -# -# -# self._case.set_value("CLM_ACCELERATED_SPINUP", "off") -# self._case.set_value("RUN_TYPE", "hybrid") -# self._case.set_value("GET_REFCASE", False) -# self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) -# self._case.set_value("RUN_REFDATE", "1700-01-01") -# self._case.set_value("DOUT_S", False) -# self._case.flush() -# -# # do the restart run (short term archiving is off) -# self.run_indv() + added_content = ["use_fates_potentialveg = .true.","fates_harvest_mode = 'no_harvest'"] + append_to_user_nl_files(clone_path, "clm", added_content) + + # Run the spin up case + # As per SSP test: + # "No history files expected, set suffix=None to avoid compare error" + logger.info("PVT log: starting spin-up run") + dout_sr = clone.get_value("DOUT_S_ROOT") + self._skip_pnl = False + self.run_indv(suffix=None, st_archive=True) + + # ------------------------------------------------------------------- + # (2) Run FATES transient case using restart file from spin-up + # ------------------------------------------------------------------- + os.chdir(caseroot) + self._set_active_case(orig_case) + + self._case.set_value("CLM_ACCELERATED_SPINUP", "off") + self._case.set_value("RUN_TYPE", "hybrid") + self._case.set_value("GET_REFCASE", False) + self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) + self._case.set_value("RUN_REFDATE", "1700-01-01") + self._case.set_value("DOUT_S", False) + self._case.flush() + + # do the restart run (short term archiving is off) + self.run_indv() From 10728d91c8dcaeeb0719429ba11cf857fec50f68 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 24 May 2024 18:15:04 -0600 Subject: [PATCH 101/194] add non-Cold based testmod for spinup + transient --- .../testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods | 1 + .../testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm | 1 + 2 files changed, 2 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods new file mode 100644 index 0000000000..1ceba4c200 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/include_user_mods @@ -0,0 +1 @@ +../FatesLUPFT diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm new file mode 100644 index 0000000000..426b41b49e --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFTAreaHarvest/user_nl_clm @@ -0,0 +1 @@ +fates_harvest_mode = 'luhdata_area' From 0537a6a32d586e62c237b6e2a6d645b7895bf76a Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 29 May 2024 11:23:15 -0600 Subject: [PATCH 102/194] add potential veg check to avoid accessing timeseries file --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 88 ++++++++++---------- src/dyn_subgrid/dynSubgridDriverMod.F90 | 4 +- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index f330ee2b78..d7c1063494 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -107,6 +107,7 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) ! !USES: use clm_varctl , only : use_cn, use_fates_luh, fates_harvest_mode + use clm_varctl , only : use_fates_potentialveg use dynVarTimeUninterpMod , only : dyn_var_time_uninterp_type use dynTimeInfoMod , only : YEAR_POSITION_START_OF_TIMESTEP use dynTimeInfoMod , only : YEAR_POSITION_END_OF_TIMESTEP @@ -148,55 +149,58 @@ subroutine dynFatesLandUseInit(bounds, landuse_filename) landuse_transitions = 0._r8 landuse_harvest = 0._r8 - if (use_fates_luh) then + ! Avoid initializing the landuse timeseries file if in fates potential vegetation mode + if (.not. use_fates_potentialveg) then + if (use_fates_luh) then - ! Generate the dyn_file_type object. - ! Start calls get_prev_date, whereas end calls get_curr_date - dynFatesLandUse_file = dyn_file_type(landuse_filename, YEAR_POSITION_END_OF_TIMESTEP) + ! Generate the dyn_file_type object. + ! Start calls get_prev_date, whereas end calls get_curr_date + dynFatesLandUse_file = dyn_file_type(landuse_filename, YEAR_POSITION_END_OF_TIMESTEP) - ! Get initial land use data from the fates luh2 timeseries dataset - num_points = (bounds%endg - bounds%begg + 1) - landuse_shape(1) = num_points ! Does this need an explicit array shape to be passed to the constructor? - do varnum = 1, num_landuse_transition_vars - landuse_transition_vars(varnum) = dyn_var_time_uninterp_type( & - dyn_file=dynFatesLandUse_file, varname=landuse_transition_varnames(varnum), & - dim1name=grlnd, conversion_factor=1.0_r8, & - do_check_sums_equal_1=.false., data_shape=landuse_shape) - end do - do varnum = 1, num_landuse_state_vars - landuse_state_vars(varnum) = dyn_var_time_uninterp_type( & - dyn_file=dynFatesLandUse_file, varname=landuse_state_varnames(varnum), & - dim1name=grlnd, conversion_factor=1.0_r8, & - do_check_sums_equal_1=.false., data_shape=landuse_shape) - end do - - ! Get the harvest rate data from the fates luh2 timeseries dataset if enabled - if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area .or. & - trim(fates_harvest_mode) .eq. fates_harvest_luh_mass) then - - ! change the harvest varnames being used depending on the mode selected - if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area ) then - landuse_harvest_varnames => landuse_harvest_area_varnames - landuse_harvest_units = landuse_harvest_area_units - elseif (trim(fates_harvest_mode) .eq. fates_harvest_luh_mass ) then - landuse_harvest_varnames => landuse_harvest_mass_varnames - landuse_harvest_units = landuse_harvest_mass_units - else - call endrun(msg=' undefined fates harvest mode selected'//errMsg(__FILE__, __LINE__)) - end if - - do varnum = 1, num_landuse_harvest_vars - landuse_harvest_vars(varnum) = dyn_var_time_uninterp_type( & - dyn_file=dynFatesLandUse_file, varname=landuse_harvest_varnames(varnum), & + ! Get initial land use data from the fates luh2 timeseries dataset + num_points = (bounds%endg - bounds%begg + 1) + landuse_shape(1) = num_points ! Does this need an explicit array shape to be passed to the constructor? + do varnum = 1, num_landuse_transition_vars + landuse_transition_vars(varnum) = dyn_var_time_uninterp_type( & + dyn_file=dynFatesLandUse_file, varname=landuse_transition_varnames(varnum), & + dim1name=grlnd, conversion_factor=1.0_r8, & + do_check_sums_equal_1=.false., data_shape=landuse_shape) + end do + do varnum = 1, num_landuse_state_vars + landuse_state_vars(varnum) = dyn_var_time_uninterp_type( & + dyn_file=dynFatesLandUse_file, varname=landuse_state_varnames(varnum), & dim1name=grlnd, conversion_factor=1.0_r8, & do_check_sums_equal_1=.false., data_shape=landuse_shape) end do + + ! Get the harvest rate data from the fates luh2 timeseries dataset if enabled + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area .or. & + trim(fates_harvest_mode) .eq. fates_harvest_luh_mass) then + + ! change the harvest varnames being used depending on the mode selected + if (trim(fates_harvest_mode) .eq. fates_harvest_luh_area ) then + landuse_harvest_varnames => landuse_harvest_area_varnames + landuse_harvest_units = landuse_harvest_area_units + elseif (trim(fates_harvest_mode) .eq. fates_harvest_luh_mass ) then + landuse_harvest_varnames => landuse_harvest_mass_varnames + landuse_harvest_units = landuse_harvest_mass_units + else + call endrun(msg=' undefined fates harvest mode selected'//errMsg(__FILE__, __LINE__)) + end if + + do varnum = 1, num_landuse_harvest_vars + landuse_harvest_vars(varnum) = dyn_var_time_uninterp_type( & + dyn_file=dynFatesLandUse_file, varname=landuse_harvest_varnames(varnum), & + dim1name=grlnd, conversion_factor=1.0_r8, & + do_check_sums_equal_1=.false., data_shape=landuse_shape) + end do + end if end if - end if - ! Since fates needs state data during initialization, make sure to call - ! the interpolation routine at the start - call dynFatesLandUseInterp(bounds,init_state=.true.) + ! Since fates needs state data during initialization, make sure to call + ! the interpolation routine at the start + call dynFatesLandUseInterp(bounds,init_state=.true.) + end if end subroutine dynFatesLandUseInit diff --git a/src/dyn_subgrid/dynSubgridDriverMod.F90 b/src/dyn_subgrid/dynSubgridDriverMod.F90 index faef029b40..ea1210521d 100644 --- a/src/dyn_subgrid/dynSubgridDriverMod.F90 +++ b/src/dyn_subgrid/dynSubgridDriverMod.F90 @@ -206,7 +206,7 @@ subroutine dynSubgrid_driver(bounds_proc, ! OUTSIDE any loops over clumps in the driver. ! ! !USES: - use clm_varctl , only : use_cn, use_fates, use_fates_luh + use clm_varctl , only : use_cn, use_fates, use_fates_luh, use_fates_potentialveg use dynInitColumnsMod , only : initialize_new_columns use dynConsBiogeophysMod , only : dyn_hwcontent_init, dyn_hwcontent_final use dynEDMod , only : dyn_ED @@ -295,7 +295,7 @@ subroutine dynSubgrid_driver(bounds_proc, call dynurban_interp(bounds_proc) end if - if (use_fates_luh) then + if (use_fates_luh .and. .not. use_fates_potentialveg) then call dynFatesLandUseInterp(bounds_proc) end if From dbbd7954a9b5e9a38d0afe45648b19dd5597c4fe Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 29 May 2024 12:17:31 -0600 Subject: [PATCH 103/194] change fluh_timeseries to use an file with wider time range --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index fe34e9f4b8..37aff979f9 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1557,7 +1557,7 @@ lnd/clm2/surfdata_esmf/NEON/surfdata_1x1_NEON_TOOL_hist_78pfts_CMIP6_simyr2000_c lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc + >lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1650-2015_c240216.nc .false. From 2848873409be7eddecb0f62326116afaf9a2e319 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 29 May 2024 12:18:24 -0600 Subject: [PATCH 104/194] fix pvt system test --- cime_config/SystemTests/pvt.py | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index 6b2a958eaa..05da935a0e 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -51,6 +51,11 @@ def run_phase(self): orig_casevar = self._case.get_value("CASE") caseroot = self._case.get_value("CASEROOT") + # Set the run start date based on the desired starting reference case year + refcase_year = 1700 + stop_n_pveg = 5 + startyear_pveg = refcase_year - stop_n_pveg + # clone the main case to create spinup case logger.info("PVT log: cloning setup") clone_path = "{}.potveg".format(caseroot) @@ -65,10 +70,11 @@ def run_phase(self): self._set_active_case(clone) # set the clone case values - stop_n_pveg = 1 with clone: - # clone.set_value("CLM_ACCELERATED_SPINUP", "on") + clone.set_value("CLM_ACCELERATED_SPINUP", "off") clone.set_value("STOP_N", stop_n_pveg) + clone.set_value("STOP_OPTION", "nyears") + clone.set_value("RUN_STARTDATE", "{}-01-01".format(startyear_pveg)) # Modify the spin up case to use the potential vegetation mode. # Checks for incompatible cases and necessary mapping files are @@ -93,11 +99,33 @@ def run_phase(self): os.chdir(caseroot) self._set_active_case(orig_case) + # Copy restart files from spin up to the transient case run directory + # obtain rpointer files and necessary restart files from short term archiving directory + rundir = self._case.get_value("RUNDIR") + + refdate = str(refcase_year) + '-01-01-00000' + rest_path = os.path.join(dout_sr, "rest", "{}".format(refdate)) + + for item in glob.glob("{}/*{}*".format(rest_path, refdate)): + link_name = os.path.join(rundir, os.path.basename(item)) + if os.path.islink(link_name) and os.readlink(link_name) == item: + # Link is already set up correctly: do nothing + # (os.symlink raises an exception if you try to replace an + # existing file) + pass + else: + os.symlink(item, link_name) + + for item in glob.glob("{}/*rpointer*".format(rest_path)): + shutil.copy(item, rundir) + + # Update run case settings self._case.set_value("CLM_ACCELERATED_SPINUP", "off") self._case.set_value("RUN_TYPE", "hybrid") self._case.set_value("GET_REFCASE", False) self._case.set_value("RUN_REFCASE", "{}.potveg".format(orig_casevar)) - self._case.set_value("RUN_REFDATE", "1700-01-01") + self._case.set_value("RUN_REFDATE", "{}-01-01".format(refcase_year)) + self._case.set_value("RUN_STARTDATE", "{}-01-01".format(refcase_year)) self._case.set_value("DOUT_S", False) self._case.flush() From 709c3da94d1816b42268bf98a4b3d947bdc29a9d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 29 May 2024 16:30:06 -0600 Subject: [PATCH 105/194] remove unnecessary import call --- cime_config/SystemTests/pvt.py | 2 -- cime_config/SystemTests/systemtest_utils.py | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index 05da935a0e..feef6cb04c 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -8,12 +8,10 @@ - use CLM_ACCELERATED_SPINUP? 2) run a transient landuse case with use_fates_lupft - start from the restart file generated in (1) - """ from CIME.XML.standard_module_setup import * from CIME.SystemTests.system_tests_common import SystemTestsCommon from CIME.SystemTests.test_utils.user_nl_utils import append_to_user_nl_files -from systemtest_utils import find_user_nl_option import shutil, glob, os logger = logging.getLogger(__name__) diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index 2591ac4223..c39f5171ba 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -85,9 +85,8 @@ def run_python_script(caseroot, this_conda_env, command_in, tool_path): except: print(f"ERROR trying to run {tool_name}.") raise -""" -Read a user_nl file and return the namelist option if found -""" + +# Read a user_nl file and return the namelist option if found def find_user_nl_option(caseroot, component, namelist_option): # This is a copy of the CIME _get_list_of_user_nl_files From aed9d31c060ce247a3c7dd29ccf138552e56a1f4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 4 Jun 2024 10:40:46 -0700 Subject: [PATCH 106/194] remove hydro tests that are now passing per NGEET/FATES#1164 --- cime_config/testdefs/ExpectedTestFails.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 23e481222b..2d59568602 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -190,20 +190,6 @@ - - - FAIL - #2373 - - - - - - FAIL - FATES#701 - - - FAIL From 5431850c991fbed4a2c7e3ac7d9f321e7d907ed0 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 4 Jun 2024 15:57:53 -0600 Subject: [PATCH 107/194] Add cime_config/usermods_dirs/NEON/NIWO/user_nl_clm for tests to pass --- cime_config/usermods_dirs/NEON/NIWO/user_nl_clm | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 cime_config/usermods_dirs/NEON/NIWO/user_nl_clm diff --git a/cime_config/usermods_dirs/NEON/NIWO/user_nl_clm b/cime_config/usermods_dirs/NEON/NIWO/user_nl_clm new file mode 100644 index 0000000000..cf427d738b --- /dev/null +++ b/cime_config/usermods_dirs/NEON/NIWO/user_nl_clm @@ -0,0 +1,8 @@ +! 20240604 slevis introduced this file to bypass test failures in the +! cnmatrix branch (so cnmatrix on by default) with two izumi tests: +! SMS_Ld10_D_Mmpi-serial.CLM_USRDAT.I1PtClm60Bgc.izumi_nag.clm-default--clm-NEON-NIWO--clm-matrixcnOn +! SMS_Ld10_D_Mmpi-serial.CLM_USRDAT.I1PtClm60Bgc.izumi_nag.clm-default--clm-NEON-NIWO +! when the tests point to the default finidat, as documented in this post: +! https://github.com/ESCOMP/CTSM/pull/640#issuecomment-2143101361 +use_init_interp = .true. +finidat = '$DIN_LOC_ROOT/lnd/clm2/initdata_esmf/ctsm5.2/clmi.I2000Clm50BgcCrop.2011-01-01.1.9x2.5_gx1v7_gl4_simyr2000_c240223.nc' From 0edef8a33450154a60d0d50af5419dc57e5c0996 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 4 Jun 2024 16:00:30 -0600 Subject: [PATCH 108/194] Update ntests in bld/unit_testers/build-namelist_test.pl --- bld/unit_testers/build-namelist_test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 152430d514..28a2392736 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -163,7 +163,7 @@ sub cat_and_create_namelistinfile { # # Figure out number of tests that will run # -my $ntests = 3357; +my $ntests = 3283; if ( defined($opts{'compare'}) ) { $ntests += 2045; From 1a49e547ba3c48fa483f9ae81a8f05adcd6b888c Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 4 Jun 2024 16:01:28 -0600 Subject: [PATCH 109/194] Reformatting by "make run-black" --- cime_config/SystemTests/sspmatrixcn.py | 20 +++++--------------- cime_config/buildnml | 24 ++++++------------------ 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/cime_config/SystemTests/sspmatrixcn.py b/cime_config/SystemTests/sspmatrixcn.py index 37d4154121..f4a09a277e 100644 --- a/cime_config/SystemTests/sspmatrixcn.py +++ b/cime_config/SystemTests/sspmatrixcn.py @@ -163,28 +163,18 @@ def append_user_nl(self, caseroot, n=0): self.check_n(n) # For all set output to yearly contents_to_append = "hist_nhtfrq = -8760" - contents_to_append = ( - contents_to_append + ", hist_mfilt = " + str(self.nyr_forcing) - ) + contents_to_append = contents_to_append + ", hist_mfilt = " + str(self.nyr_forcing) # For all but last step turn extra matrix output to off b4last = self.n_steps() - 1 if n < b4last: - contents_to_append = ( - contents_to_append + ", hist_wrt_matrixcn_diag = .False." - ) + contents_to_append = contents_to_append + ", hist_wrt_matrixcn_diag = .False." # For matrix spinup steps, set the matrix spinup and other variables associated with it if self.spin[n] == "sasu": - contents_to_append = ( - contents_to_append + ", nyr_forcing = " + str(self.nyr_forcing) - ) + contents_to_append = contents_to_append + ", nyr_forcing = " + str(self.nyr_forcing) if self.sasu[n] != -999: - contents_to_append = ( - contents_to_append + ", nyr_sasu = " + str(self.sasu[n]) - ) + contents_to_append = contents_to_append + ", nyr_sasu = " + str(self.sasu[n]) if self.iloop[n] != -999: - contents_to_append = ( - contents_to_append + ", iloop_avg = " + str(self.iloop[n]) - ) + contents_to_append = contents_to_append + ", iloop_avg = " + str(self.iloop[n]) # For cold start, run with matrix off if self.cold[n]: diff --git a/cime_config/buildnml b/cime_config/buildnml index 9be7c447fb..3eb45dff31 100755 --- a/cime_config/buildnml +++ b/cime_config/buildnml @@ -182,9 +182,7 @@ def buildnml(case, caseroot, compname): clm_phys = case.get_value("CLM_PHYSICS_VERSION") config_cache_text = _config_cache_template.format(clm_phys=clm_phys) - config_cache_path = os.path.join( - caseroot, "Buildconf", compname + "conf", "config_cache.xml" - ) + config_cache_path = os.path.join(caseroot, "Buildconf", compname + "conf", "config_cache.xml") with open(config_cache_path, "w") as config_cache_file: config_cache_file.write(config_cache_text) @@ -283,17 +281,13 @@ def buildnml(case, caseroot, compname): if (yr_start != None) and (yr_end != None): nyr = yr_end - yr_start + 1 if (yr_end <= 0) or (yr_start <= 0): - logger.error( - "ERROR: Year start and end are both negative and should not be" - ) + logger.error("ERROR: Year start and end are both negative and should not be") clm_namelist_opts = "nyr_forcing={} {}".format(nyr, clm_namelist_opts) else: logger.warning( "WARNING: It does not make sense to do a SASU spinup with a prognostic atmosphere model" ) - logger.warning( - " as it expects regular atmosphere forcing that is cycled over" - ) + logger.warning(" as it expects regular atmosphere forcing that is cycled over") infile = os.path.join(ctsmconf, "namelist") @@ -307,9 +301,7 @@ def buildnml(case, caseroot, compname): lndfrac_file = os.path.join(lnd_domain_path, lnd_domain_file) lndfrac_setting = "-lnd_frac " + lndfrac_file - config_cache_file = os.path.join( - caseroot, "Buildconf", compname + "conf", "config_cache.xml" - ) + config_cache_file = os.path.join(caseroot, "Buildconf", compname + "conf", "config_cache.xml") # ----------------------------------------------------- # Clear out old data @@ -372,9 +364,7 @@ def buildnml(case, caseroot, compname): break if not os.path.exists(os.path.join(rundir, clm_startfile)): - logger.warning( - "WARNING: Could NOT find a start file to use using" + clm_startfile - ) + logger.warning("WARNING: Could NOT find a start file to use using" + clm_startfile) clm_icfile = "%s = '%s'" % (startfile_type, clm_startfile) else: clm_icfile = "" @@ -385,9 +375,7 @@ def buildnml(case, caseroot, compname): user_nl_file = os.path.join(caseroot, "user_nl_clm" + inst_string) namelist_infile = os.path.join(ctsmconf, "namelist") - create_namelist_infile( - case, user_nl_file, namelist_infile, "\n".join(infile_lines) - ) + create_namelist_infile(case, user_nl_file, namelist_infile, "\n".join(infile_lines)) cmd = os.path.join(lnd_root, "bld", "build-namelist") From 66e1c3d6dd330accc670b8ea281e43e938d2018d Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 4 Jun 2024 16:05:05 -0600 Subject: [PATCH 110/194] Update .git-blame-ignore-revs --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index c62b279ba0..bc3600b925 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -47,3 +47,4 @@ aa04d1f7d86cc2503b98b7e2b2d84dbfff6c316b 6c6f57e948bfa31e60b383536cc21663fedb8b70 9660667b1267dcd4150889f5f39db540158be74a 665cf86102e09b4c4c5a140700676dca23bc55a9 +1a49e547ba3c48fa483f9ae81a8f05adcd6b888c From dfebe5fdbdce10ba25cbdc6419c95f41f82f3848 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 7 Jun 2024 14:08:42 -0600 Subject: [PATCH 111/194] Remove user_nl_clm (added in 5431850) and replace 2 NIWO tests with HARV --- cime_config/testdefs/ExpectedTestFails.xml | 17 +---------------- cime_config/testdefs/testlist_clm.xml | 6 +++--- cime_config/usermods_dirs/NEON/NIWO/user_nl_clm | 8 -------- 3 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 cime_config/usermods_dirs/NEON/NIWO/user_nl_clm diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 03f60ad824..5968e73760 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -78,15 +78,11 @@ - + FAIL #2310 - - FAIL - #2310 - @@ -100,17 +96,6 @@ - - - FAIL - #2310 - - - FAIL - #2310 - - - FAIL diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 782af8bc34..9a2390bd58 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2257,7 +2257,7 @@ - + @@ -2268,7 +2268,7 @@ - + @@ -2276,7 +2276,7 @@ - + diff --git a/cime_config/usermods_dirs/NEON/NIWO/user_nl_clm b/cime_config/usermods_dirs/NEON/NIWO/user_nl_clm deleted file mode 100644 index cf427d738b..0000000000 --- a/cime_config/usermods_dirs/NEON/NIWO/user_nl_clm +++ /dev/null @@ -1,8 +0,0 @@ -! 20240604 slevis introduced this file to bypass test failures in the -! cnmatrix branch (so cnmatrix on by default) with two izumi tests: -! SMS_Ld10_D_Mmpi-serial.CLM_USRDAT.I1PtClm60Bgc.izumi_nag.clm-default--clm-NEON-NIWO--clm-matrixcnOn -! SMS_Ld10_D_Mmpi-serial.CLM_USRDAT.I1PtClm60Bgc.izumi_nag.clm-default--clm-NEON-NIWO -! when the tests point to the default finidat, as documented in this post: -! https://github.com/ESCOMP/CTSM/pull/640#issuecomment-2143101361 -use_init_interp = .true. -finidat = '$DIN_LOC_ROOT/lnd/clm2/initdata_esmf/ctsm5.2/clmi.I2000Clm50BgcCrop.2011-01-01.1.9x2.5_gx1v7_gl4_simyr2000_c240223.nc' From 628be7bd39fb48acab7a456504be05c424f4510f Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 11 Jun 2024 12:20:30 -0700 Subject: [PATCH 112/194] temporarily update fates to point to latest pull request commit hash --- .gitmodules | 4 ++-- src/fates | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 699ad22969..5b679e62bf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "fates"] path = src/fates -url = https://github.com/NGEET/fates -fxtag = sci.1.73.0_api.35.0.0 +url = https://github.com/ckoven/fates +fxtag = 4b018eade498d063b21dddf26f77c9658ff80261 fxrequired = AlwaysRequired fxDONOTUSEurl = https://github.com/NCAR/fates-release diff --git a/src/fates b/src/fates index adfa664806..4b018eade4 160000 --- a/src/fates +++ b/src/fates @@ -1 +1 @@ -Subproject commit adfa6648063408d443f5cae671bd37f713d3e3e8 +Subproject commit 4b018eade498d063b21dddf26f77c9658ff80261 From d3e68143a2ca5e52568965a666cd6c53be7d0434 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 20 Jun 2024 17:30:14 -0600 Subject: [PATCH 113/194] Temporary .gitmodules points to the branches of the modules that changed --- .gitmodules | 20 ++++++++++---------- ccs_config | 2 +- components/cism | 2 +- components/cmeps | 2 +- components/mosart | 2 +- components/rtm | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitmodules b/.gitmodules index 699ad22969..e1df4e650c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,22 +7,22 @@ fxDONOTUSEurl = https://github.com/NCAR/fates-release [submodule "cism"] path = components/cism -url = https://github.com/ESCOMP/CISM-wrapper -fxtag = cismwrap_2_2_001 +url = https://github.com/mvertens/CISM-wrapper +fxtag = 34339777afa7b810fd4822fce1039826668b33e4 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/CISM-wrapper [submodule "rtm"] path = components/rtm -url = https://github.com/ESCOMP/RTM -fxtag = rtm1_0_79 +url = https://github.com/swensosc/RTM +fxtag = 420c5979d8abf05184992fdfba5ac41c41c91c2e fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/RTM [submodule "mosart"] path = components/mosart -url = https://github.com/ESCOMP/MOSART -fxtag = mosart1_0_49 +url = https://github.com/mvertens/MOSART +fxtag = 01f40dcf589d4e6c5932c76128e3d42faea91e9f fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/MOSART @@ -35,8 +35,8 @@ fxDONOTUSEurl = https://github.com/ESCOMP/mizuRoute [submodule "ccs_config"] path = ccs_config -url = https://github.com/ESMCI/ccs_config_cesm.git -fxtag = ccs_config_cesm0.0.106 +url = https://github.com/mvertens/ccs_config_cesm.git +fxtag = dbb02c0ccd1492fe278885f8a07a71fa80064319 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESMCI/ccs_config_cesm.git @@ -49,8 +49,8 @@ fxDONOTUSEurl = https://github.com/ESMCI/cime [submodule "cmeps"] path = components/cmeps -url = https://github.com/ESCOMP/CMEPS.git -fxtag = cmeps0.14.63 +url = https://github.com/mvertens/CMEPS.git +fxtag = 4dca7c602e54189b74b1d0195c433d1b83475553 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/CMEPS.git diff --git a/ccs_config b/ccs_config index 2ff978f92a..dbb02c0ccd 160000 --- a/ccs_config +++ b/ccs_config @@ -1 +1 @@ -Subproject commit 2ff978f92a5ac9a6ab243e5c14d06a7e2d2f5799 +Subproject commit dbb02c0ccd1492fe278885f8a07a71fa80064319 diff --git a/components/cism b/components/cism index c05dd5c4fc..34339777af 160000 --- a/components/cism +++ b/components/cism @@ -1 +1 @@ -Subproject commit c05dd5c4fc85327e76523aaea9cfe1e388748928 +Subproject commit 34339777afa7b810fd4822fce1039826668b33e4 diff --git a/components/cmeps b/components/cmeps index 6384ff4e4a..4dca7c602e 160000 --- a/components/cmeps +++ b/components/cmeps @@ -1 +1 @@ -Subproject commit 6384ff4e4a6bc82a678f9419a43ffbd5d53ac209 +Subproject commit 4dca7c602e54189b74b1d0195c433d1b83475553 diff --git a/components/mosart b/components/mosart index 8c682b1b7f..01f40dcf58 160000 --- a/components/mosart +++ b/components/mosart @@ -1 +1 @@ -Subproject commit 8c682b1b7f15d146816de302e0d359da3e957056 +Subproject commit 01f40dcf589d4e6c5932c76128e3d42faea91e9f diff --git a/components/rtm b/components/rtm index 88503adbc2..420c5979d8 160000 --- a/components/rtm +++ b/components/rtm @@ -1 +1 @@ -Subproject commit 88503adbc275fb2ccbb6b598e460deaeb140e515 +Subproject commit 420c5979d8abf05184992fdfba5ac41c41c91c2e From 540d87fcc791c68ecac02eb786ca58a2e6874b9c Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 21 Jun 2024 16:34:58 -0600 Subject: [PATCH 114/194] Update .gitmodules with latest mosart commit --- .gitmodules | 2 +- components/mosart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index e1df4e650c..3d3cb88e80 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,7 +22,7 @@ fxDONOTUSEurl = https://github.com/ESCOMP/RTM [submodule "mosart"] path = components/mosart url = https://github.com/mvertens/MOSART -fxtag = 01f40dcf589d4e6c5932c76128e3d42faea91e9f +fxtag = ca0acc0336365456bec653c4c233abb57d9bc62d fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/MOSART diff --git a/components/mosart b/components/mosart index 01f40dcf58..ca0acc0336 160000 --- a/components/mosart +++ b/components/mosart @@ -1 +1 @@ -Subproject commit 01f40dcf589d4e6c5932c76128e3d42faea91e9f +Subproject commit ca0acc0336365456bec653c4c233abb57d9bc62d From 596dc135a49918c225ce726122874ed55611ad87 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 21 Jun 2024 17:52:16 -0600 Subject: [PATCH 115/194] Update .gitmodules with new mosart and rtm tags --- .gitmodules | 8 ++++---- components/mosart | 2 +- components/rtm | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index 3d3cb88e80..6d4298befc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,15 +14,15 @@ fxDONOTUSEurl = https://github.com/ESCOMP/CISM-wrapper [submodule "rtm"] path = components/rtm -url = https://github.com/swensosc/RTM -fxtag = 420c5979d8abf05184992fdfba5ac41c41c91c2e +url = https://github.com/ESCOMP/RTM +fxtag = rtm1_0_80 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/RTM [submodule "mosart"] path = components/mosart -url = https://github.com/mvertens/MOSART -fxtag = ca0acc0336365456bec653c4c233abb57d9bc62d +url = https://github.com/ESCOMP/MOSART +fxtag = mosart1.1.02 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/MOSART diff --git a/components/mosart b/components/mosart index ca0acc0336..e2ffe00004 160000 --- a/components/mosart +++ b/components/mosart @@ -1 +1 @@ -Subproject commit ca0acc0336365456bec653c4c233abb57d9bc62d +Subproject commit e2ffe00004cc416cfc8bcfae2a949474075c1d1f diff --git a/components/rtm b/components/rtm index 420c5979d8..b3dfcfbba5 160000 --- a/components/rtm +++ b/components/rtm @@ -1 +1 @@ -Subproject commit 420c5979d8abf05184992fdfba5ac41c41c91c2e +Subproject commit b3dfcfbba58c151ac5a6ab513b3515ef3deff798 From 463fac1241827d975948a418dc6a9c90ee34fbc0 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 24 Jun 2024 17:32:47 -0600 Subject: [PATCH 116/194] Minor comment updates --- bld/CLMBuildNamelist.pm | 4 ++-- bld/unit_testers/build-namelist_test.pl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 44aa07ee28..d0d9328218 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4678,14 +4678,14 @@ sub setup_logic_cnmatrix { if ( &value_is_true($nl->get_value("use_matrixcn")) && &value_is_true($nl_flags->{"for_testing_use_repr_structure_pool"}) ) { $log->fatal_error("for_testing_use_repr_structure_pool can NOT be on when use_matrixcn is on" ); } - # If both matrixcn and soil_matrix are off outmatrix can't be on + # If both matrixcn and soil_matrix are off hist_wrt_matrixcn_diag can't be on if ( ! &value_is_true($nl->get_value("use_matrixcn")) && ! &value_is_true($nl_flags->{"use_soil_matrixcn"}) ) { my $var = "hist_wrt_matrixcn_diag"; if ( &value_is_true($nl->get_value($var)) ) { $log->fatal_error("$var can NOT be on when both use_matrixcn and use_soil_matrixcn are off" ); } } - # If soil_matrix is off ispspinup can't be on + # If soil_matrix is off spinup_matrixcn can't be on if ( ! &value_is_true($nl_flags->{"use_soil_matrixcn"}) ) { my $var = "spinup_matrixcn"; if ( &value_is_true($nl->get_value($var)) ) { diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 28a2392736..9b83f9e7ec 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -942,12 +942,12 @@ sub cat_and_create_namelistinfile { GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", }, - "outmatrixWOmatrix" =>{ options=>"-envxml_dir . -bgc bgc", + "matrixcn_diagWOmatrix" =>{ options=>"-envxml_dir . -bgc bgc", namelst=>"use_soil_matrixcn=.false.,use_matrixcn=F,hist_wrt_matrixcn_diag=T", GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", }, - "spinupWOsoilmatrix" =>{ options=>"-envxml_dir . -bgc bgc", + "spinupWOsoilmatrix" =>{ options=>"-envxml_dir . -bgc bgc", namelst=>"use_soil_matrixcn=F,use_matrixcn=T,spinup_matrixcn=T", GLC_TWO_WAY_COUPLING=>"TRUE", phys=>"clm5_0", From 47234a9d429e29612599bcf0590e647b895c28d2 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 24 Jun 2024 18:06:30 -0600 Subject: [PATCH 117/194] Add overridable warning that cnmatrix may fail in transient mode --- bld/CLMBuildNamelist.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index d0d9328218..ffe1c4e522 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4650,6 +4650,16 @@ sub setup_logic_cnmatrix { , 'spinup_matrixcn'=>$nl_flags->{'spinup_matrixcn'}, 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); } @matrixlist = ( "use_matrixcn", "use_soil_matrixcn", "hist_wrt_matrixcn_diag", "spinup_matrixcn" ); + # Matrix items can't be on for transient + $nl_flags->{'flanduse_timeseries'} = "null"; + my $flanduse_timeseries = $nl->get_value('flanduse_timeseries'); + if ( $flanduse_timeseries ne "null" ) { + foreach my $var ( @matrixlist ) { + if ( &value_is_true($nl->get_value($var)) ) { + $log->warning("$var may FAIL with balance error in transient mode" ); + } + } + } # Matrix items can't be on for SP mode if ( $nl_flags->{'bgc_mode'} eq "sp" ) { foreach my $var ( @matrixlist ) { From 18e63e354e604d43c6dd0bca4a43abef3f4480ee Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 25 Jun 2024 12:02:01 -0600 Subject: [PATCH 118/194] Abort if matrixcn is .true. and nrepr is not 1 --- src/biogeochem/CropReprPoolsMod.F90 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/biogeochem/CropReprPoolsMod.F90 b/src/biogeochem/CropReprPoolsMod.F90 index dcbb4e4fd9..695af9f00e 100644 --- a/src/biogeochem/CropReprPoolsMod.F90 +++ b/src/biogeochem/CropReprPoolsMod.F90 @@ -98,6 +98,10 @@ subroutine crop_repr_pools_init() end if nrepr = nrepr_grain + nrepr_structure + ! matrixcn works with nrepr = 1 only + if (use_matrixcn .and. nrepr != 1) then + call endrun(msg="ERROR: nrepr should be 1 when use_matrixcn = .true."//errMsg(sourcefile, __LINE__)) + end if allocate(repr_hist_fnames(nrepr)) allocate(repr_rest_fnames(nrepr)) allocate(repr_longnames(nrepr)) From 422f06f7389094b32baa763628865a53467d0830 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 25 Jun 2024 13:33:42 -0700 Subject: [PATCH 119/194] add fates potential vegetation spin up to transient test mod --- cime_config/testdefs/testlist_clm.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 85824a4404..0706a1ef53 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2615,6 +2615,15 @@ + + + + + + + + + From f9d8349021458c56912edf626a0c8e229e4f58da Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 25 Jun 2024 13:53:01 -0700 Subject: [PATCH 120/194] rename fates luh2 harvest modes --- .../include_user_mods | 0 .../{FatesColdLUH2Mode3 => FatesColdLUH2HarvestArea}/user_nl_clm | 0 .../include_user_mods | 0 .../{FatesColdLUH2Mode1 => FatesColdLUH2HarvestEvent}/user_nl_clm | 0 .../include_user_mods | 0 .../{FatesColdLUH2Mode4 => FatesColdLUH2HarvestMass}/user_nl_clm | 0 .../include_user_mods | 0 .../{FatesColdLUH2Mode2 => FatesColdLUH2HarvestSurf}/user_nl_clm | 0 .../include_user_mods | 0 .../{FatesColdLUH2Mode0 => FatesColdLUH2NoHarvest}/user_nl_clm | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode0 => FatesColdLUH2HarvestArea}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode3 => FatesColdLUH2HarvestArea}/user_nl_clm (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode1 => FatesColdLUH2HarvestEvent}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode1 => FatesColdLUH2HarvestEvent}/user_nl_clm (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode2 => FatesColdLUH2HarvestMass}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode4 => FatesColdLUH2HarvestMass}/user_nl_clm (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode3 => FatesColdLUH2HarvestSurf}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode2 => FatesColdLUH2HarvestSurf}/user_nl_clm (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode4 => FatesColdLUH2NoHarvest}/include_user_mods (100%) rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2Mode0 => FatesColdLUH2NoHarvest}/user_nl_clm (100%) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode1/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode3/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode2/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode4/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2Mode0/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm From f8330c9a7fba12652562efbc87a56f0de358b669 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 25 Jun 2024 17:16:45 -0600 Subject: [PATCH 121/194] Correct earlier commit 47234a9: warning about cnmatrix and transient --- bld/CLMBuildNamelist.pm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index ffe1c4e522..329030d985 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4651,9 +4651,7 @@ sub setup_logic_cnmatrix { } @matrixlist = ( "use_matrixcn", "use_soil_matrixcn", "hist_wrt_matrixcn_diag", "spinup_matrixcn" ); # Matrix items can't be on for transient - $nl_flags->{'flanduse_timeseries'} = "null"; - my $flanduse_timeseries = $nl->get_value('flanduse_timeseries'); - if ( $flanduse_timeseries ne "null" ) { + if (not string_is_undef_or_empty($nl->get_value('flanduse_timeseries'))) { foreach my $var ( @matrixlist ) { if ( &value_is_true($nl->get_value($var)) ) { $log->warning("$var may FAIL with balance error in transient mode" ); From 17143eea0e9c447eca85bde97b7f1dda7c2b1ffe Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 25 Jun 2024 17:24:15 -0600 Subject: [PATCH 122/194] Correct earlier commit 18e63e3: abort if matrixcn and nrepr not 1 --- src/biogeochem/CropReprPoolsMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/biogeochem/CropReprPoolsMod.F90 b/src/biogeochem/CropReprPoolsMod.F90 index 695af9f00e..cbc2f3e2a2 100644 --- a/src/biogeochem/CropReprPoolsMod.F90 +++ b/src/biogeochem/CropReprPoolsMod.F90 @@ -99,7 +99,7 @@ subroutine crop_repr_pools_init() nrepr = nrepr_grain + nrepr_structure ! matrixcn works with nrepr = 1 only - if (use_matrixcn .and. nrepr != 1) then + if (use_matrixcn .and. nrepr /= 1) then call endrun(msg="ERROR: nrepr should be 1 when use_matrixcn = .true."//errMsg(sourcefile, __LINE__)) end if allocate(repr_hist_fnames(nrepr)) From 4b18e79ae14e8c56c51b718aad722ce679b37972 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 25 Jun 2024 17:29:56 -0600 Subject: [PATCH 123/194] Replace clm45_monthly_matrixcn_soilCN30 testmod and test with clm60 --- .../clm/clm45_monthly_matrixcn_soilCN30/user_nl_clm | 2 -- .../include_user_mods | 0 .../clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm | 4 ++++ 3 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/clm45_monthly_matrixcn_soilCN30/user_nl_clm rename cime_config/testdefs/testmods_dirs/clm/{clm45_monthly_matrixcn_soilCN30 => clm60_monthly_matrixcn_soilCN30}/include_user_mods (100%) create mode 100644 cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45_monthly_matrixcn_soilCN30/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm45_monthly_matrixcn_soilCN30/user_nl_clm deleted file mode 100644 index c7436f5acb..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/clm45_monthly_matrixcn_soilCN30/user_nl_clm +++ /dev/null @@ -1,2 +0,0 @@ - use_soil_matrixcn = .true. - paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/clm45_params.soilCN30.c220321.nc' diff --git a/cime_config/testdefs/testmods_dirs/clm/clm45_monthly_matrixcn_soilCN30/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/clm45_monthly_matrixcn_soilCN30/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm new file mode 100644 index 0000000000..d22154bef6 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm @@ -0,0 +1,4 @@ +use_soil_matrixcn = .true. +paramfile = '/glade/u/home/slevis/paramfiles/ctsm60_params_cn30.c240625.nc' +! If we keep this paramfile, it should move to the repository +! paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm60_params_cn30.c240625.nc' From 1761a7becb50cad2849db794243b1f2d37e602c3 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 25 Jun 2024 17:34:50 -0600 Subject: [PATCH 124/194] Move new param file to inputdata and rimport --- .../clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm index d22154bef6..df20ced9e8 100644 --- a/cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/clm60_monthly_matrixcn_soilCN30/user_nl_clm @@ -1,4 +1,2 @@ use_soil_matrixcn = .true. -paramfile = '/glade/u/home/slevis/paramfiles/ctsm60_params_cn30.c240625.nc' -! If we keep this paramfile, it should move to the repository -! paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm60_params_cn30.c240625.nc' +paramfile = '$DIN_LOC_ROOT/lnd/clm2/paramdata/ctsm60_params_cn30.c240625.nc' From 1e97001d0dc5e7359d8fb3b11c37118e3e429fe3 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 25 Jun 2024 17:59:00 -0600 Subject: [PATCH 125/194] Change use_matrixcn, use_soil_matrixcn to default .false. before merge --- bld/namelist_files/namelist_defaults_ctsm.xml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 90e397d544..933b504606 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -618,19 +618,11 @@ attributes from the config_cache.xml file (with keys converted to upper-case). +.false. .true. -.true. -.false. -.false. -.false. - +.false. .true. -.true. -.false. -.false. -.false. -.false. .false. .false. From 7feb6572d51e5d3ba2596ae9a1b4ededd045928d Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 25 Jun 2024 18:04:46 -0600 Subject: [PATCH 126/194] Rm redunant LG* and LR* tests and corresponding expected fails --- cime_config/testdefs/ExpectedTestFails.xml | 13 ------------- cime_config/testdefs/testlist_clm.xml | 20 -------------------- 2 files changed, 33 deletions(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 5968e73760..664b1c8e35 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -58,19 +58,6 @@ - - - FAIL - #640, same test with clm-ciso_soil_matrixcn_only works - - - - - FAIL - #640, same test with clm-ciso_soil_matrixcn_only works - - - FAIL diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 9a2390bd58..625a9f3504 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -3386,26 +3386,6 @@ - - - - - - - - - - - - - - - - - - - - From 5a46b9382ee15fea803cb5e7091ed6915c2169a1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 26 Jun 2024 10:53:02 -0700 Subject: [PATCH 127/194] remove fates land use no harvest due to overlap --- .../testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods | 1 - .../testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm | 1 - 2 files changed, 2 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods deleted file mode 100644 index 7eb8bb1579..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/include_user_mods +++ /dev/null @@ -1 +0,0 @@ -../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm deleted file mode 100644 index b3b338e232..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2NoHarvest/user_nl_clm +++ /dev/null @@ -1 +0,0 @@ -fates_harvest_mode = no_harvest From 3318d3b46df34013afcb5fadc4ad9f4184779f28 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 26 Jun 2024 11:03:10 -0700 Subject: [PATCH 128/194] update fates landuse harvest test mod names --- cime_config/testdefs/testlist_clm.xml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 0706a1ef53..ed0627f242 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2570,7 +2570,7 @@ - + @@ -2579,7 +2579,7 @@ - + @@ -2588,7 +2588,7 @@ - + @@ -2597,16 +2597,7 @@ - - - - - - - - - - + @@ -2621,7 +2612,7 @@ - + From 34c4db0b185b4cb62fc6fa22de96b23c949c0dfd Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 26 Jun 2024 23:47:14 -0700 Subject: [PATCH 129/194] Revert "Apply relevant changes from rgknox/fates-auto-params." This reverts commit 7216006b1c2400d1ca2932899671f9bcec85b6af. --- .../testdefs/testmods_dirs/clm/Fates/shell_commands | 5 ----- .../testdefs/testmods_dirs/clm/Fates/user_nl_clm | 1 - .../testdefs/testmods_dirs/clm/_scripts/README | 2 -- .../clm/_scripts/get_fates_shell_commands_vars.sh | 11 ----------- 4 files changed, 19 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/_scripts/README delete mode 100755 cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands index 3443bacef0..41a2342a51 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/shell_commands @@ -1,7 +1,2 @@ ./xmlchange CLM_BLDNML_OPTS="-no-megan" --append ./xmlchange BFBFLAG="TRUE" - -SRCROOT=`./xmlquery SRCROOT --value` -. "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh - -ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm index 57adea1ff6..91df3e2e61 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -4,7 +4,6 @@ hist_nhtfrq = -24 hist_empty_htapes = .true. hist_ndens = 1 fates_spitfire_mode = 1 -fates_paramfile='${SRCROOT}/src/fates/parameter_files/binaries/${CASE}-params.nc' hist_fincl1 = 'FATES_NCOHORTS', 'FATES_TRIMMING', 'FATES_AREA_PLANTS', 'FATES_AREA_TREES', 'FATES_COLD_STATUS', 'FATES_GDD', 'FATES_NCHILLDAYS', 'FATES_NCOLDDAYS', 'FATES_DAYSINCE_COLDLEAFOFF','FATES_DAYSINCE_COLDLEAFON', diff --git a/cime_config/testdefs/testmods_dirs/clm/_scripts/README b/cime_config/testdefs/testmods_dirs/clm/_scripts/README deleted file mode 100644 index 66eb22a375..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/_scripts/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains scripts that can be called in -shell_commands of multiple testmods. diff --git a/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh b/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh deleted file mode 100755 index 382fb4e53e..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh +++ /dev/null @@ -1,11 +0,0 @@ -# This script should be called in shell_commands with -# . "${SRCROOT}"/cime_config/testdefs/testmods_dirs/clm/_scripts/get_fates_shell_commands_vars.sh -# where the leading period ensures it's run in the same shell. - -CASE=`./xmlquery CASE --value` -FATESDIR="${SRCROOT}/src/fates" -FATESPARAMDIR="${SRCROOT}/src/fates/parameter_files/binaries" -mkdir -p "${FATESPARAMDIR}" -FATESPARAMFILE="${FATESPARAMDIR}/${CASE}-params.nc" - -# No exit status because it should be called in the same shell. From 99d0f2bb4c93c739e5875781070a3d66c6bb8cbd Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 16:56:21 -0700 Subject: [PATCH 130/194] move fates landuse test mods to fates suite --- cime_config/testdefs/testlist_clm.xml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index ef4358f763..347fd33e8e 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2573,8 +2573,7 @@ - - + @@ -2582,8 +2581,7 @@ - - + @@ -2591,8 +2589,7 @@ - - + @@ -2600,8 +2597,7 @@ - - + @@ -2609,8 +2605,7 @@ - - + From 535033b959f6eab9c5d39d7edff410c47dfacb80 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 17:11:47 -0700 Subject: [PATCH 131/194] remove flandusepft and fluh_times pointers for testmod Use default currently. --- .../testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm | 2 -- 1 file changed, 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm index 970e7df7cd..e25490ffbb 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/user_nl_clm @@ -2,10 +2,8 @@ ! Run a transient case, with vegetation starting from bare ground, but land use starting from LUH state vector on starting date, in a nocomp configuration. ! From Charlie's list of valid FATES configurations: ! https://docs.google.com/spreadsheets/d/1eE3sRMYxfocZKbT8uIQhXpjjtfM2feXPRSWXJNoo4jM/edit#gid=0 -flandusepftdat = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/fates-sci.1.73.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc' use_fates_luh = .true. use_fates_nocomp = .true. use_fates_fixed_biogeog = .true. use_fates_sp = .false. use_fates_potentialveg = .false. -fluh_timeseries = '$DIN_LOC_ROOT/lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc' From 8793f477483bf0332bf423e3c7b3bb66b31f88aa Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 17:15:29 -0700 Subject: [PATCH 132/194] add readme noting grid resolution limitation --- cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README new file mode 100644 index 0000000000..79d6511d17 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README @@ -0,0 +1,2 @@ +Currently the FATES LUH2 category of test mods currently only supports +4x5 grid resolutions. From 95bf3f82fb09d4022ac1af285569e9c1fd1aefa0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 13:52:40 -0700 Subject: [PATCH 133/194] add fates harvest event expected failure --- cime_config/testdefs/ExpectedTestFails.xml | 7 +++++++ cime_config/testdefs/testlist_clm.xml | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 65419a5903..de864aeee6 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -165,6 +165,13 @@ + + + FAIL + FATES#1216 + + + FAIL diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 347fd33e8e..16359b88be 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2579,7 +2579,7 @@ - + @@ -2609,6 +2609,7 @@ + From 889cc97d4172e85edc7f6c53f4a71ec89048a4d5 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 17:51:13 -0600 Subject: [PATCH 134/194] update seed dispersal test mod to put on-the-fly generated paramfile in the case directory --- .../testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands | 2 +- .../testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands index 94a832af25..db5a1f8672 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands @@ -1,7 +1,7 @@ SRCDIR=`./xmlquery SRCROOT --value` CASEDIR=`./xmlquery CASEROOT --value` FATESDIR=$SRCDIR/src/fates/ -FATESPARAMFILE=$SRCDIR/fates_params_seeddisp_4x5.nc +FATESPARAMFILE=$CASEDIR/fates_params_seeddisp_4x5.nc ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm index e8d24253c1..ecd1dc8b57 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm @@ -1,3 +1,3 @@ -fates_paramfile = '$SRCROOT/fates_params_seeddisp_4x5.nc' +fates_paramfile = '$CASEROOT/fates_params_seeddisp_4x5.nc' fates_seeddisp_cadence = 1 hist_fincl1 = 'FATES_SEEDS_IN_GRIDCELL_PF', 'FATES_SEEDS_OUT_GRIDCELL_PF' From f58cd7ee463f5ad7d8838a618f6e51bc7c37fb07 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 23:43:20 -0600 Subject: [PATCH 135/194] reinstate fates-landuse as a second, shorter test list --- cime_config/testdefs/testlist_clm.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 16359b88be..68862c0dce 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2565,6 +2565,7 @@ + @@ -2574,6 +2575,7 @@ + @@ -2582,6 +2584,7 @@ + @@ -2590,6 +2593,7 @@ + @@ -2598,6 +2602,7 @@ + @@ -2606,6 +2611,7 @@ + From 9465da6202b0fd2ca8cbd9d39b6ffb5cc2e9f1e0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 23:44:49 -0600 Subject: [PATCH 136/194] fix luh2 harvest testmod --- .../testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm | 2 +- .../testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm index d760105e68..426b41b49e 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestArea/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = luhdata_area +fates_harvest_mode = 'luhdata_area' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm index bb5f30f75d..7b6bc24f5a 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestMass/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = luhdata_mass +fates_harvest_mode = 'luhdata_mass' From c2deb25a278e7b177c47b5ae189f1c8697cd8d58 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 27 Jun 2024 23:48:18 -0600 Subject: [PATCH 137/194] rename fates landuse to luh2harvestevent --- .../testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm | 3 ++- .../testmods_dirs/clm/FatesColdLandUse/include_user_mods | 1 - .../testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm index 61e1daaa93..a23336f36c 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm @@ -1 +1,2 @@ -fates_harvest_mode = surfdata_file +flanduse_timeseries = '$DIN_LOC_ROOT/lnd/clm2/surfdata_esmf/ctsm5.2.0/landuse.timeseries_4x5_hist_16_CMIP6_1850-2015_c230620.nc' +fates_harvest_mode = 'surfdata_file' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods deleted file mode 100644 index 14f7591b72..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods +++ /dev/null @@ -1 +0,0 @@ -../FatesCold diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm deleted file mode 100644 index 668f9c861d..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm +++ /dev/null @@ -1,2 +0,0 @@ -flanduse_timeseries = '$DIN_LOC_ROOT/lnd/clm2/surfdata_esmf/ctsm5.2.0/landuse.timeseries_4x5_hist_16_CMIP6_1850-2015_c230620.nc' -do_harvest = .true. From 4d0b49a81fa68653ba92ca59cfdd791cc053378a Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 12:32:36 -0600 Subject: [PATCH 138/194] fix fates harvest event code testmod --- .../testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm index c0e1c476be..d2079d9e43 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm @@ -1 +1 @@ -fates_harvest_mode = event_code +fates_harvest_mode = 'event_code' From 387ac5ed9163f77bd037ff8f935e56e73a832702 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:49:55 -0600 Subject: [PATCH 139/194] add description to flandusepftdat definition --- bld/namelist_files/namelist_definition_ctsm.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index c12cb75ab6..fd3020f320 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -826,7 +826,13 @@ types to vary over time. -Full pathname of fates landuse x pft static data map. +Full pathname of fates landuse x pft association static data map. +The file associates land use types with pfts across a static global map. +This file is necessary for running FATES with use_fates_luh, +use_fates_nocomp, and use_fates_fixedbiogeo engaged. The file is output +by the FATES land use data tool (https://github.com/NGEET/tools-fates-landusedata) +which processes the raw land use data from the THEMIS tool data sets +(https://doi.org/10.5065/29s7-7b41) Date: Fri, 28 Jun 2024 14:04:09 -0700 Subject: [PATCH 140/194] update flandusepftdat description with note about use_fates_lupft --- bld/namelist_files/namelist_definition_ctsm.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index fd3020f320..fb4f5d07a9 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -829,7 +829,8 @@ types to vary over time. Full pathname of fates landuse x pft association static data map. The file associates land use types with pfts across a static global map. This file is necessary for running FATES with use_fates_luh, -use_fates_nocomp, and use_fates_fixedbiogeo engaged. The file is output +use_fates_nocomp, and use_fates_fixedbiogeo engaged (note that use_fates_lupft +is provided as a namelist option to engage all necessary options). The file is output by the FATES land use data tool (https://github.com/NGEET/tools-fates-landusedata) which processes the raw land use data from the THEMIS tool data sets (https://doi.org/10.5065/29s7-7b41) From f985fbafafd5710e944d7715522966e042743361 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:23:29 -0700 Subject: [PATCH 141/194] rename misleading surfdata_file option name to the landuse_timeseries --- bld/CLMBuildNamelist.pm | 4 ++-- bld/namelist_files/namelist_definition_ctsm.xml | 7 ++++--- .../testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm | 2 +- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index c336d41ca9..0fb7963c67 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4652,7 +4652,7 @@ sub setup_logic_fates { if ( ! &value_is_true($nl->get_value('use_fates_luh')) ) { $log->fatal_error("use_fates_luh is required to be true when $var is luhdata_mass or luhdata_area" ); } - } elsif ( $mode eq 'surfdata_file' ) { + } elsif ( $mode eq 'landuse_timeseries' ) { # Check to make sure that the user set the flanduse_timeseries file # Since the flanduse_timeseries logic checking is upstream of the fates logic, # don't add the default here. The onus is on the user to match the correct timeseries @@ -4660,7 +4660,7 @@ sub setup_logic_fates { my $var = "flanduse_timeseries"; my $fname = remove_leading_and_trailing_quotes( $nl->get_value($var) ); if ( ! defined($nl->get_value($var)) ) { - $log->fatal_error("$var is required when fates_harvest_mode is surfdata_file" ); + $log->fatal_error("$var is required when fates_harvest_mode is landuse_timeseries" ); } elsif ( ! -f "$fname" ) { $log->fatal_error("$var does NOT point to a valid filename" ); } diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index fb4f5d07a9..046de32c11 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -734,15 +734,16 @@ Toggle to turn on no competition mode (only relevant if FATES is being used). Toggle to turn on FATES satellite phenology mode (only relevant if FATES is being used). - + Set FATES harvesting mode by setting fates_harvest_mode to a valid string option. Allowed values are: no_harvest: no fates harvesting of any kind event_code: fates logging via fates logging event codes (see fates parameter file) only - surfdata_file: fates harvest driven by CLM landuse timeseries data (dynHarvestMod) + landuse_timeseries: fates harvest driven by CLM flanduse_timeseries file (dynHarvestMod) luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) +Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. Date: Fri, 28 Jun 2024 14:25:37 -0700 Subject: [PATCH 142/194] add language about age and possible future deprication of landuse_timeseries option --- bld/namelist_files/namelist_definition_ctsm.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 046de32c11..9b495ccda4 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -744,6 +744,7 @@ Allowed values are: luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. +This option is older than the luhdata options and may be depricated at some point in the future. Date: Fri, 28 Jun 2024 14:29:38 -0700 Subject: [PATCH 143/194] fix copy/paste typo --- bld/namelist_files/namelist_definition_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 9b495ccda4..b80bbda2d6 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -806,7 +806,7 @@ This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harv + group="clm_inparm" valid_values="" value=".false."> If TRUE, enable use of fates land use x pft mapping data file. (Only valid for use_fates = true and is incompatible with transient runs currently.) From 32b2554189d6cbdb11361ed376eb53c4bb8d2857 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:32:39 -0700 Subject: [PATCH 144/194] add clarifying language for use_fates_potentialveg --- bld/namelist_files/namelist_definition_ctsm.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index b80bbda2d6..bbc860df6c 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -814,7 +814,9 @@ If TRUE, enable use of fates land use x pft mapping data file. If TRUE, ignore the land-use state vector and transitions, and assert that all lands -are primary, and that there is no harvest. +are primary, and that there is no harvest. This mode is only relevant for FATES +spin-up workflows that are intending to use the spin-up restart output to start a +FATES land use transient case using the use_fates_lupft namelist option. From aaaff224b18585a4f93c4b83595b2017ee96f607 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:40:32 -0700 Subject: [PATCH 145/194] add clearer instructions about when to use_fates_potentialveg --- bld/namelist_files/namelist_definition_ctsm.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index bbc860df6c..252d83aa21 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -816,7 +816,8 @@ If TRUE, enable use of fates land use x pft mapping data file. If TRUE, ignore the land-use state vector and transitions, and assert that all lands are primary, and that there is no harvest. This mode is only relevant for FATES spin-up workflows that are intending to use the spin-up restart output to start a -FATES land use transient case using the use_fates_lupft namelist option. +FATES land use transient case using the use_fates_lupft namelist option. The option +should be set to true for the spin-up case and false for the transient case. From f6f7b2d135253f5a13dbd6e5ae66328a01c97d76 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 14:45:13 -0700 Subject: [PATCH 146/194] add language explaining what use_fates_lupft does --- bld/namelist_files/namelist_definition_ctsm.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 252d83aa21..5a478f0bfa 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -807,7 +807,9 @@ This is enabled by default if fates_harvest_mode is set to use the raw LUH2 harv -If TRUE, enable use of fates land use x pft mapping data file. +If TRUE, enable use of FATES land use with no competition and fixed biogeography. This mode +requires the use of the land use x pft association static data map file. See the +flandusepftdat definition entry in this file for more information. (Only valid for use_fates = true and is incompatible with transient runs currently.) From 2539cea91b481f4680e2696c6c517df3d952befa Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 28 Jun 2024 16:31:36 -0700 Subject: [PATCH 147/194] add readme to FatesLUPFT test mod --- cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README new file mode 100644 index 0000000000..88f5c2c8fb --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesLUPFT/README @@ -0,0 +1,9 @@ +This test mod does not use cold start and is intended to +be used in conjunction with a test workflow that provides +an initialization file. Currently this is accomplished +by using the test mod in conjunction with the PVT +system test. The PVT system test runs a FATES spin-up +case using the use_fates_potentialveg mode and then +references the restart output to run a use_fates_lupft +transient mode case. + From bf46d33d289f85077082dc01ec79c1945c42c3f4 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 30 Jun 2024 23:04:07 -0700 Subject: [PATCH 148/194] update fates logging test with new harvest event code Remove duplicate and misnamed FatesColdLUH2HarvestEvent --- .../clm/FatesColdLUH2HarvestEvent/include_user_mods | 1 - .../testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm | 1 - .../testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods deleted file mode 100644 index 7eb8bb1579..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/include_user_mods +++ /dev/null @@ -1 +0,0 @@ -../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm deleted file mode 100644 index d2079d9e43..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestEvent/user_nl_clm +++ /dev/null @@ -1 +0,0 @@ -fates_harvest_mode = 'event_code' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm index 5f457f3f1c..d2079d9e43 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLogging/user_nl_clm @@ -1,2 +1 @@ -! TODO SSR: Replace this with fates_harvest_mode -use_fates_logging= .true. +fates_harvest_mode = 'event_code' From 96d1a78b3c28c9f1bc8185e646f6a4f975236a42 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 30 Jun 2024 23:07:59 -0700 Subject: [PATCH 149/194] reinstate FatesColdLandUse This will provide continuity to the previous test and fixes the incorrect use of FatesColdLUH2 as the test to inherit from --- .../testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods | 1 - .../testmods_dirs/clm/FatesColdLandUse/include_user_mods | 1 + .../{FatesColdLUH2HarvestSurf => FatesColdLandUse}/user_nl_clm | 0 3 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods rename cime_config/testdefs/testmods_dirs/clm/{FatesColdLUH2HarvestSurf => FatesColdLandUse}/user_nl_clm (100%) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods deleted file mode 100644 index 7eb8bb1579..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/include_user_mods +++ /dev/null @@ -1 +0,0 @@ -../FatesColdLUH2 diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods new file mode 100644 index 0000000000..14f7591b72 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/include_user_mods @@ -0,0 +1 @@ +../FatesCold diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2HarvestSurf/user_nl_clm rename to cime_config/testdefs/testmods_dirs/clm/FatesColdLandUse/user_nl_clm From f47e2bfe035571268743f5bed11b2b97169d31e0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Sun, 30 Jun 2024 23:10:43 -0700 Subject: [PATCH 150/194] remove duplicate tests --- cime_config/testdefs/testlist_clm.xml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 68862c0dce..272d4093d8 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -2581,15 +2581,6 @@ - - - - - - - - - @@ -2599,15 +2590,6 @@ - - - - - - - - - From 6dd55eeef55c093e53f500867d516df1beb16f39 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 1 Jul 2024 11:31:06 -0600 Subject: [PATCH 151/194] Update .gitmodules with new cismwrapper, cmeps, and ccs_config tags --- .gitmodules | 12 ++++++------ ccs_config | 2 +- components/cism | 2 +- components/cmeps | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitmodules b/.gitmodules index 6d4298befc..eb2a0980f4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,8 +7,8 @@ fxDONOTUSEurl = https://github.com/NCAR/fates-release [submodule "cism"] path = components/cism -url = https://github.com/mvertens/CISM-wrapper -fxtag = 34339777afa7b810fd4822fce1039826668b33e4 +url = https://github.com/ESCOMP/CISM-wrapper +fxtag = cismwrap_2_2_001 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/CISM-wrapper @@ -35,8 +35,8 @@ fxDONOTUSEurl = https://github.com/ESCOMP/mizuRoute [submodule "ccs_config"] path = ccs_config -url = https://github.com/mvertens/ccs_config_cesm.git -fxtag = dbb02c0ccd1492fe278885f8a07a71fa80064319 +url = https://github.com/ESMCI/ccs_config_cesm.git +fxtag = ccs_config_cesm0.0.110 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESMCI/ccs_config_cesm.git @@ -49,8 +49,8 @@ fxDONOTUSEurl = https://github.com/ESMCI/cime [submodule "cmeps"] path = components/cmeps -url = https://github.com/mvertens/CMEPS.git -fxtag = 4dca7c602e54189b74b1d0195c433d1b83475553 +url = https://github.com/ESCOMP/CMEPS.git +fxtag = cmeps0.14.67 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/CMEPS.git diff --git a/ccs_config b/ccs_config index dbb02c0ccd..c30a283155 160000 --- a/ccs_config +++ b/ccs_config @@ -1 +1 @@ -Subproject commit dbb02c0ccd1492fe278885f8a07a71fa80064319 +Subproject commit c30a2831556f269675971b11c5c156ea92599878 diff --git a/components/cism b/components/cism index 34339777af..c05dd5c4fc 160000 --- a/components/cism +++ b/components/cism @@ -1 +1 @@ -Subproject commit 34339777afa7b810fd4822fce1039826668b33e4 +Subproject commit c05dd5c4fc85327e76523aaea9cfe1e388748928 diff --git a/components/cmeps b/components/cmeps index 4dca7c602e..90f815ba9e 160000 --- a/components/cmeps +++ b/components/cmeps @@ -1 +1 @@ -Subproject commit 4dca7c602e54189b74b1d0195c433d1b83475553 +Subproject commit 90f815ba9e7493d71043b5d8e627a3f20bd5dc78 From fb9529577c1e1f294cce17c0a0285f78b98554ce Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 1 Jul 2024 12:59:23 -0600 Subject: [PATCH 152/194] Update cismwrapper tag to the correct new one --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index eb2a0980f4..615de28b6f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,7 +8,7 @@ fxDONOTUSEurl = https://github.com/NCAR/fates-release [submodule "cism"] path = components/cism url = https://github.com/ESCOMP/CISM-wrapper -fxtag = cismwrap_2_2_001 +fxtag = cismwrap_2_2_002 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/CISM-wrapper From de1b44ca4c9ef7c9116b41f1969a7998bcf21a84 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 1 Jul 2024 13:01:37 -0600 Subject: [PATCH 153/194] Ran ./bin/git-fleximod update, so now update the cism module itself --- components/cism | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/cism b/components/cism index c05dd5c4fc..c84cc9f5b3 160000 --- a/components/cism +++ b/components/cism @@ -1 +1 @@ -Subproject commit c05dd5c4fc85327e76523aaea9cfe1e388748928 +Subproject commit c84cc9f5b3103766a35d0a7ddd5e9dbd7deae762 From e1b2bdabb4b2c74a27bbf12d4cca677452396de7 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 2 Jul 2024 17:03:19 -0600 Subject: [PATCH 154/194] Correct the tags that I used for ccs_config and cmeps --- .gitmodules | 4 ++-- ccs_config | 2 +- components/cmeps | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index 615de28b6f..897824e9cc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -36,7 +36,7 @@ fxDONOTUSEurl = https://github.com/ESCOMP/mizuRoute [submodule "ccs_config"] path = ccs_config url = https://github.com/ESMCI/ccs_config_cesm.git -fxtag = ccs_config_cesm0.0.110 +fxtag = ccs_config_cesm1.0.0 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESMCI/ccs_config_cesm.git @@ -50,7 +50,7 @@ fxDONOTUSEurl = https://github.com/ESMCI/cime [submodule "cmeps"] path = components/cmeps url = https://github.com/ESCOMP/CMEPS.git -fxtag = cmeps0.14.67 +fxtag = cmeps0.14.77 fxrequired = ToplevelRequired fxDONOTUSEurl = https://github.com/ESCOMP/CMEPS.git diff --git a/ccs_config b/ccs_config index c30a283155..69a958581e 160000 --- a/ccs_config +++ b/ccs_config @@ -1 +1 @@ -Subproject commit c30a2831556f269675971b11c5c156ea92599878 +Subproject commit 69a958581ecd2d32ee9cb1c38bcd3847b8b920bf diff --git a/components/cmeps b/components/cmeps index 90f815ba9e..47fb4e633a 160000 --- a/components/cmeps +++ b/components/cmeps @@ -1 +1 @@ -Subproject commit 90f815ba9e7493d71043b5d8e627a3f20bd5dc78 +Subproject commit 47fb4e633a76ec6d60969b1af751f90790387246 From 0e6eed5f399eb85744410ecf1962c0416c7846ba Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 5 Jul 2024 10:57:34 -0700 Subject: [PATCH 155/194] Revert "update seed dispersal test mod to put on-the-fly generated paramfile in the case directory" This reverts commit 889cc97d4172e85edc7f6c53f4a71ec89048a4d5. I forgot that #2322 prevents this from working. --- .../testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands | 2 +- .../testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands index db5a1f8672..94a832af25 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/shell_commands @@ -1,7 +1,7 @@ SRCDIR=`./xmlquery SRCROOT --value` CASEDIR=`./xmlquery CASEROOT --value` FATESDIR=$SRCDIR/src/fates/ -FATESPARAMFILE=$CASEDIR/fates_params_seeddisp_4x5.nc +FATESPARAMFILE=$SRCDIR/fates_params_seeddisp_4x5.nc ncgen -o $FATESPARAMFILE $FATESDIR/parameter_files/fates_params_default.cdl diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm index ecd1dc8b57..e8d24253c1 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdSeedDisp/user_nl_clm @@ -1,3 +1,3 @@ -fates_paramfile = '$CASEROOT/fates_params_seeddisp_4x5.nc' +fates_paramfile = '$SRCROOT/fates_params_seeddisp_4x5.nc' fates_seeddisp_cadence = 1 hist_fincl1 = 'FATES_SEEDS_IN_GRIDCELL_PF', 'FATES_SEEDS_OUT_GRIDCELL_PF' From 03fb25a2a6d94753d7abbb4300fa32b917883969 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 5 Jul 2024 16:18:47 -0600 Subject: [PATCH 156/194] Two new tests in testlist_clm and two new tests in expected fails --- cime_config/testdefs/ExpectedTestFails.xml | 15 +++++++++++++++ cime_config/testdefs/testlist_clm.xml | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 664b1c8e35..59802d9109 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -44,6 +44,21 @@ + + + FAIL + #2619 + This failure relates to the following REP failure. + + + + + FAIL + #2619 + This failure relates to the preceding ERP failure. + + + FAIL diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 625a9f3504..23cc5ebcc5 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -1445,6 +1445,26 @@ + + + + + + + + + + + + + + + + + + + + From 0efd37fe16814134389b9c49a30c7c033828c462 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 5 Jul 2024 17:55:44 -0600 Subject: [PATCH 157/194] New testmods /matrixcnOn_Hist to use -ignore_warnings in IHist compsets --- cime_config/testdefs/ExpectedTestFails.xml | 4 +-- cime_config/testdefs/testlist_clm.xml | 28 +++++++++---------- .../clm/matrixcnOn_Hist/include_user_mods | 1 + .../clm/matrixcnOn_Hist/shell_commands | 3 ++ 4 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/include_user_mods create mode 100644 cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/shell_commands diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 59802d9109..1243c125c0 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -44,14 +44,14 @@ - + FAIL #2619 This failure relates to the following REP failure. - + FAIL #2619 diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 23cc5ebcc5..1fe5ed770d 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -548,7 +548,7 @@ - + @@ -794,7 +794,7 @@ - + @@ -1002,7 +1002,7 @@ - + @@ -1020,7 +1020,7 @@ - + @@ -1038,7 +1038,7 @@ - + @@ -1234,7 +1234,7 @@ - + @@ -1354,7 +1354,7 @@ - + @@ -1435,7 +1435,7 @@ - + @@ -1445,7 +1445,7 @@ - + @@ -1455,7 +1455,7 @@ - + @@ -1793,7 +1793,7 @@ - + @@ -1849,7 +1849,7 @@ - + @@ -1925,7 +1925,7 @@ - + @@ -2369,7 +2369,7 @@ - + diff --git a/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/include_user_mods new file mode 100644 index 0000000000..a3c70cba11 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/include_user_mods @@ -0,0 +1 @@ +../matrixcnOn diff --git a/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/shell_commands b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/shell_commands new file mode 100644 index 0000000000..f0547f3f26 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/shell_commands @@ -0,0 +1,3 @@ +#!/bin/bash + +./xmlchange CLM_BLDNML_OPTS="-ignore_warnings" --append From a486e86065223a882790a6078647a82c592ffdaf Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 5 Jul 2024 17:15:08 -0700 Subject: [PATCH 158/194] update harvest parameter variables lengths Updating all lengths to account for the update to the clmlanduse name option change --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index b440b55dc9..681d39f38c 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -35,11 +35,11 @@ module dynFATESLandUseChangeMod integer, public, parameter :: num_landuse_harvest_vars = 5 ! Define the fates landuse namelist mode switch values - character(len=13), public, parameter :: fates_harvest_no_logging = 'no_harvest' - character(len=13), public, parameter :: fates_harvest_logging_only = 'event_code' - character(len=13), public, parameter :: fates_harvest_clmlanduse = 'landuse_timeseries' - character(len=13), public, parameter :: fates_harvest_luh_area = 'luhdata_area' - character(len=13), public, parameter :: fates_harvest_luh_mass = 'luhdata_mass' + character(len=18), public, parameter :: fates_harvest_no_logging = 'no_harvest' + character(len=18), public, parameter :: fates_harvest_logging_only = 'event_code' + character(len=18), public, parameter :: fates_harvest_clmlanduse = 'landuse_timeseries' + character(len=18), public, parameter :: fates_harvest_luh_area = 'luhdata_area' + character(len=18), public, parameter :: fates_harvest_luh_mass = 'luhdata_mass' ! Define landuse harvest unit integer representation integer, public, parameter :: landuse_harvest_area_units = 1 From fafc8137baeb39c07c65e697def4488b86aab612 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 8 Jul 2024 14:53:52 -0700 Subject: [PATCH 159/194] update fates submodule to api 36 --- .gitmodules | 4 ++-- src/fates | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 049c62ade8..9ed4402c7e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,8 +27,8 @@ # [submodule "fates"] path = src/fates -url = https://github.com/ckoven/fates -fxtag = 4b018eade498d063b21dddf26f77c9658ff80261 +url = https://github.com/NGEET/fates +fxtag = sci.1.77.0_api.36.0.0 fxrequired = AlwaysRequired # Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed fxDONOTUSEurl = https://github.com/NCAR/fates-release diff --git a/src/fates b/src/fates index 4b018eade4..fd7f3438c2 160000 --- a/src/fates +++ b/src/fates @@ -1 +1 @@ -Subproject commit 4b018eade498d063b21dddf26f77c9658ff80261 +Subproject commit fd7f3438c2ff821672b703050e7011f293649ee9 From e49c11dafe49ec306848a31cabfbf6b87d0d62da Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 10:25:04 -0700 Subject: [PATCH 160/194] update ChangeLog and ChangeSum --- doc/ChangeLog | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ doc/ChangeSum | 1 + 2 files changed, 118 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 2ab7676ddc..26deed83db 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,121 @@ =============================================================== +Tag name: ctsm5.2.009 +Originator(s): glemieux (Gregory Lemieux, LBNL, glemieux@lbl.gov) +Date: Tue 9 Jul 2024 10:50:00 AM MDT +One-line Summary: FATES Land Use V2 + +Purpose and description of changes +---------------------------------- + +This tag enables FATES to utilize its land use mode with fixed +biogeography and no competition mode engaged. To facilitate +this update, the host land model reads in a new static map data +set that associates land use with FATES plant functional types. +This tag also updates the pre-existing FATES dynamic land use +module to provide access to the raw LUH2 harvest data from the +FATES LUH2 timeseries data set (added in ctsm5.1.dev160). + +Significant changes to scientifically-supported configurations +-------------------------------------------------------------- + +Does this tag change answers significantly for any of the following physics configurations? +(Details of any changes will be given in the "Answer changes" section below.) + + [Put an [X] in the box for any configuration with significant answer changes.] + +[ ] clm6_0 + +[ ] clm5_1 + +[ ] clm5_0 + +[ ] ctsm5_0-nwp + +[ ] clm4_5 + + +Notes of particular relevance for users +--------------------------------------- + +Caveats for users (e.g., need to interpolate initial conditions): + FATES satellite phenology mode and land use mode are currently incompatible + and trying to engage both will result in a graceful build failure message + +Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): + New FATES namelist option: fates_harvest_mode + - This new option provides five harvest modes + - The 'event_code' mode takes over the now defunct use_fates_logging option + + New FATES namelist option: use_fates_lupft + - This option enables the necessary namelist options and data sets to run + FATES with land use, no competition, and fixed biogeography modes. + + New FATES namelist option: flandusepftdat + - This data set is necessary for running with use_fates_lupft. + + New FATES namelist option: use_potential_veg + - This option is only necessary for use with FATES spin-up to transient + workflows that will engage the use_fates_lupft mode for the transient case + +Changes made to namelist defaults (e.g., changed parameter values): + The default FATES parameter file has been updated to account for the new + parameters necessary for land use v2. + + A new default data set has been provided for flandusepftdat. Only a 4x5 grid + resolution is currently provided. + +Changes to the datasets (e.g., parameter, surface or initial files): + The FATES land use timeseries data set, fluh_timeseries, has been updated to + provide a wider timeseries range, from 0850-2015. + + +Notes of particular relevance for developers: +--------------------------------------------- +Changes to tests or testing: + New FATES testmods have been added to account for the additional harvest mode + and use_fates_lupft namelist options. Additoinally a new system text prefix, + PVT, has been added to test the use_fates_potentialveg spin-up to use_fates_lupft + transient workflow. These have been added to the fates test suite. + + +Testing summary: +---------------- + + build-namelist tests (if CLMBuildNamelist.pm has changed): + + derecho - PASS + + regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): + + derecho ----- TBD + izumi ------- TBD + + fates tests: (give name of baseline if different from CTSM tagname, normally fates baselines are fates--) + derecho ----- OK + +If the tag used for baseline comparisons was NOT the previous tag, note that here: + fates tested against fates-sci.1.76.4_api.35.1.0-ctsm5.2.008 + + +Answer changes +-------------- + +Changes answers relative to baseline: Only for FATES test mods, otherwise B4B + + +Other details +------------- +List any git submodules updated (cime, rtm, mosart, cism, fates, etc.): + FATES: sci.1.73.0_api.35.0.0 -> sci.1.77.0_api.36.0.0 + +Pull Requests that document the changes (include PR ids): +(https://github.com/ESCOMP/ctsm/pull) + +#2507 -- FATES land use v2 API update (CTSM-side) +NGEET#1116 -- V2 Land Use Change + +=============================================================== +=============================================================== Tag name: ctsm5.2.008 Originator(s): erik (Erik Kluzek,UCAR/TSS,303-497-1326) Date: Fri 28 Jun 2024 12:22:46 PM MDT diff --git a/doc/ChangeSum b/doc/ChangeSum index ea9417fe41..209c7e9a51 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,5 +1,6 @@ Tag Who Date Summary ============================================================================================================================ + ctsm5.2.009 glemieux 07/09/2024 FATES Land Use V2 ctsm5.2.008 erik 06/28/2024 Bring changes on temp-branch to master: b4b-dev, git-fleximod, hillslope fsat tmp-240620.n03.ctsm5.2.007 06/27/2024 Set upland hillslope column fsat values to zero (samrabin) tmp-240620.n02.ctsm5.2.007 06/21/2024 Another update of git-fleximod (erik) From da50efd1477e53db42abc11db90b97648daabadf Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 10:27:48 -0700 Subject: [PATCH 161/194] add clarifying language for user about FATES and do_harvest --- doc/ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 26deed83db..7b40fe908a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -45,6 +45,8 @@ Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): New FATES namelist option: fates_harvest_mode - This new option provides five harvest modes - The 'event_code' mode takes over the now defunct use_fates_logging option + - The 'landuse_timeseries' option supersedes the use of do_harvest option + with FATES. Using do_harvest is no longer compatible with FATES. New FATES namelist option: use_fates_lupft - This option enables the necessary namelist options and data sets to run From 2b50ebb8dfcfaa609a13b50d04270ed3169fcce8 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 10:29:14 -0700 Subject: [PATCH 162/194] correct fluh_timeseries file name --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 754510289f..97424eb13a 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1558,7 +1558,7 @@ lnd/clm2/surfdata_esmf/NEON/surfdata_1x1_NEON_TOOL_hist_78pfts_CMIP6_simyr2000_c lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1650-2015_c240216.nc + >lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr0850-2015_c240216.nc .false. From 03ab3bdefa98b776263c057b50cf4b803f6c4fd7 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 10:41:40 -0700 Subject: [PATCH 163/194] remove out-dated-comment Checking the landuse x pft data is handled on the fates-side --- src/utils/clmfates_interfaceMod.F90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 43a574d6e3..d15288d3a3 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -3915,8 +3915,6 @@ subroutine GetLandusePFTData(bounds, landuse_pft_file, landuse_pft_map, landuse_ deallocate(arraylocal_bareground) call ncd_pio_closefile(ncid) - ! Check that sums equal to unity - end subroutine GetLandusePFTData From 272f99f405e95adec9774519323a34c0f2f9c874 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 9 Jul 2024 13:41:55 -0700 Subject: [PATCH 164/194] remove unused land use mod subroutine --- src/utils/clmfates_interfaceMod.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index d15288d3a3..e3e7644b90 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -182,7 +182,6 @@ module CLMFatesInterfaceMod use dynFATESLandUseChangeMod, only : num_landuse_transition_vars, num_landuse_state_vars use dynFATESLandUseChangeMod, only : landuse_transitions, landuse_states use dynFATESLandUseChangeMod, only : landuse_transition_varnames, landuse_state_varnames - use dynFATESLandUseChangeMod, only : dynFatesLandUseInterp use dynFATESLandUseChangeMod, only : num_landuse_harvest_vars use dynFATESLandUseChangeMod, only : fates_harvest_no_logging use dynFATESLandUseChangeMod, only : fates_harvest_clmlanduse From 4ca2b6aeeb3388efa9b4026b826d902d8a9f6f95 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Wed, 10 Jul 2024 18:17:29 -0600 Subject: [PATCH 165/194] Add error: matrixcn not ok with NTHRDS_LND > 1 (the check does not work) --- bld/CLMBuildNamelist.pm | 16 ++++++++++++++-- bld/unit_testers/build-namelist_test.pl | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 329030d985..7038351688 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -1655,7 +1655,7 @@ sub process_namelist_inline_logic { if ( remove_leading_and_trailing_quotes($nl_flags->{'clm_start_type'}) ne "branch" ) { setup_logic_initial_conditions($opts, $nl_flags, $definition, $defaults, $nl, $physv); } - setup_logic_cnmatrix($opts, $nl_flags, $definition, $defaults, $nl); + setup_logic_cnmatrix($opts, $nl_flags, $definition, $defaults, $nl, $envxml_ref); setup_logic_spinup($opts, $nl_flags, $definition, $defaults, $nl); setup_logic_supplemental_nitrogen($opts, $nl_flags, $definition, $defaults, $nl); setup_logic_snowpack($opts, $nl_flags, $definition, $defaults, $nl); @@ -4640,7 +4640,7 @@ sub setup_logic_cnmatrix { # # Set some default options related to the CN Matrix options # - my ($opts, $nl_flags, $definition, $defaults, $nl) = @_; + my ($opts, $nl_flags, $definition, $defaults, $nl, $envxml_ref) = @_; my @matrixlist = ( "use_matrixcn", "hist_wrt_matrixcn_diag" ); foreach my $var ( @matrixlist ) { @@ -4650,6 +4650,18 @@ sub setup_logic_cnmatrix { , 'spinup_matrixcn'=>$nl_flags->{'spinup_matrixcn'}, 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); } @matrixlist = ( "use_matrixcn", "use_soil_matrixcn", "hist_wrt_matrixcn_diag", "spinup_matrixcn" ); + # Matrix items can't be on for NTHRDS_LND > 1 + my $var_xml = "NTHRDS_LND"; + my $val_xml = int($envxml_ref->{$var_xml}); + print "$var_xml = $val_xml"; + if ( $val_xml > 1) { + foreach my $var ( @matrixlist ) { + if ( &value_is_true($nl->get_value($var)) ) { + $log->warning("$var and $var_xml > 1 causes a clm threading test to FAIL (as of 2024/7/10), so use at your own risk." ); + } + } + } + # Matrix items can't be on for transient if (not string_is_undef_or_empty($nl->get_value('flanduse_timeseries'))) { foreach my $var ( @matrixlist ) { diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 9b83f9e7ec..df159a8870 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -42,7 +42,7 @@ sub make_env_run { my %settings = @_; # Set default settings - my %env_vars = ( DIN_LOC_ROOT=>"MYDINLOCROOT", GLC_TWO_WAY_COUPLING=>"FALSE", NEONSITE=>"" ); + my %env_vars = ( DIN_LOC_ROOT=>"MYDINLOCROOT", GLC_TWO_WAY_COUPLING=>"FALSE", NTHRDS_LND=>"1", NEONSITE=>"" ); # Set any settings that came in from function call foreach my $item ( keys(%settings) ) { $env_vars{$item} = $settings{$item}; From 4f436dcc855d00d0daf69c8d351cf8b19f525924 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 11 Jul 2024 15:48:50 -0600 Subject: [PATCH 166/194] Draft ChangeLog/ChangeSum files --- doc/ChangeLog | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ doc/ChangeSum | 1 + 2 files changed, 67 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 2ab7676ddc..4ebd09163a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,70 @@ =============================================================== +Tag name: ctsm5.2.013 +Originator(s): sacks (Bill Sacks, UCAR/NCAR/CGD) +Date: Thu 11 Jul 2024 03:38:12 PM MDT +One-line Summary: Relax tolerance for truncating small snocan values in CanopyFluxes + +Purpose and description of changes +---------------------------------- + +Details in the PR #2457. + + +Significant changes to scientifically-supported configurations +-------------------------------------------------------------- + +Does this tag change answers significantly for any of the following physics configurations? +(Details of any changes will be given in the "Answer changes" section below.) + + [Put an [X] in the box for any configuration with significant answer changes.] + +[ ] clm6_0 + +[ ] clm5_1 + +[ ] clm5_0 + +[ ] ctsm5_0-nwp + +[ ] clm4_5 + + +Bugs fixed +---------- +List of CTSM issues fixed (include CTSM Issue # and description) [one per line]: +Fixes #2444 Failing water isotope test on the ctsm5.2 branch + +Notes of particular relevance for users +--------------------------------------- +Changes to documentation: None + +Testing summary: +---------------- + + [PASS means all tests PASS; OK means tests PASS other than expected fails.] + + regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): + + derecho ----- OK + izumi ------- OK + +Answer changes +-------------- + +Changes answers relative to baseline: + Yes, roundoff. + + - what code configurations: All + - what platforms/compilers: All + - nature of change: Changes start roundoff level and grow over time. + +Other details +------------- +Pull Requests that document the changes (include PR ids): + https://github.com/ESCOMP/ctsm/pull/2457 + +=============================================================== +=============================================================== Tag name: ctsm5.2.008 Originator(s): erik (Erik Kluzek,UCAR/TSS,303-497-1326) Date: Fri 28 Jun 2024 12:22:46 PM MDT diff --git a/doc/ChangeSum b/doc/ChangeSum index ea9417fe41..1af9fcf58e 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,5 +1,6 @@ Tag Who Date Summary ============================================================================================================================ + ctsm5.2.013 sacks 07/??/2024 Relax tolerance for truncating small snocan values in CanopyFluxes ctsm5.2.008 erik 06/28/2024 Bring changes on temp-branch to master: b4b-dev, git-fleximod, hillslope fsat tmp-240620.n03.ctsm5.2.007 06/27/2024 Set upland hillslope column fsat values to zero (samrabin) tmp-240620.n02.ctsm5.2.007 06/21/2024 Another update of git-fleximod (erik) From 3ce1bb42c09670d87cd9fdca86cdbd24b19fd1f2 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 11 Jul 2024 17:34:25 -0600 Subject: [PATCH 167/194] Code mods to get the error check in the previous commit to work --- bld/CLMBuildNamelist.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 7038351688..caa116e3bc 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4650,14 +4650,13 @@ sub setup_logic_cnmatrix { , 'spinup_matrixcn'=>$nl_flags->{'spinup_matrixcn'}, 'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} ); } @matrixlist = ( "use_matrixcn", "use_soil_matrixcn", "hist_wrt_matrixcn_diag", "spinup_matrixcn" ); - # Matrix items can't be on for NTHRDS_LND > 1 - my $var_xml = "NTHRDS_LND"; - my $val_xml = int($envxml_ref->{$var_xml}); - print "$var_xml = $val_xml"; + # Matrix items can't be on for OMP_NUM_THREADS (also known as NTHRDS_LND) > 1 + my $var_xml = "OMP_NUM_THREADS"; + my $val_xml = $ENV{$var_xml}; if ( $val_xml > 1) { foreach my $var ( @matrixlist ) { if ( &value_is_true($nl->get_value($var)) ) { - $log->warning("$var and $var_xml > 1 causes a clm threading test to FAIL (as of 2024/7/10), so use at your own risk." ); + $log->warning("$var and $var_xml > 1 (in this case $val_xml) causes a clm threading test to FAIL (as of 2024/7/10), so use at your own risk." ); } } } From 093f5fb615988c4ec3cf9e41997178ca45e4808c Mon Sep 17 00:00:00 2001 From: Gregory Lemieux <7565064+glemieux@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:55:43 -0700 Subject: [PATCH 168/194] Update bld/namelist_files/namelist_definition_ctsm.xml with note asterisks --- bld/namelist_files/namelist_definition_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index c8118031cc..ce2c1b3c5a 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -740,7 +740,7 @@ Set FATES harvesting mode by setting fates_harvest_mode to a valid string option Allowed values are: no_harvest: no fates harvesting of any kind event_code: fates logging via fates logging event codes (see fates parameter file) only - landuse_timeseries: fates harvest driven by CLM flanduse_timeseries file (dynHarvestMod) + landuse_timeseries: fates harvest driven by CLM flanduse_timeseries file (dynHarvestMod)** luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. From 63c458254274edf650aac6bb0da359630446bfca Mon Sep 17 00:00:00 2001 From: Gregory Lemieux <7565064+glemieux@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:57:09 -0700 Subject: [PATCH 169/194] Update bld/namelist_files/namelist_definition_ctsm.xml with astericks Link to note --- bld/namelist_files/namelist_definition_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index ce2c1b3c5a..208c42038e 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -743,7 +743,7 @@ Allowed values are: landuse_timeseries: fates harvest driven by CLM flanduse_timeseries file (dynHarvestMod)** luhdata_area: fates harvest driven by LUH2 raw harvest data, area-based (dynFATESLandUseChangeMod) luhdata_mass: fates harvest driven by LUH2 raw harvest data, mass-based (dynFATESLandUseChangeMod) -Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. +**Note that the landuse_timeseries option is not the same as the FATES fluh_timeseries data file. This option is older than the luhdata options and may be depricated at some point in the future. From 7417640e49d9b83932b0ba608b13987b5e62de2c Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 12 Jul 2024 11:07:12 -0600 Subject: [PATCH 170/194] Allow tests with threading to proceed with -ignore_warnings --- cime_config/testdefs/testlist_clm.xml | 42 +++++++++---------- .../clm/matrixcnOn_Hist/shell_commands | 3 -- .../include_user_mods | 0 .../matrixcnOn_ignore_warnings/shell_commands | 7 ++++ 4 files changed, 28 insertions(+), 24 deletions(-) delete mode 100644 cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/shell_commands rename cime_config/testdefs/testmods_dirs/clm/{matrixcnOn_Hist => matrixcnOn_ignore_warnings}/include_user_mods (100%) create mode 100644 cime_config/testdefs/testmods_dirs/clm/matrixcnOn_ignore_warnings/shell_commands diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 1fe5ed770d..7ead363a6d 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -548,7 +548,7 @@ - + @@ -794,7 +794,7 @@ - + @@ -1002,7 +1002,7 @@ - + @@ -1020,7 +1020,7 @@ - + @@ -1038,7 +1038,7 @@ - + @@ -1074,7 +1074,7 @@ - + @@ -1092,7 +1092,7 @@ - + @@ -1145,7 +1145,7 @@ - + @@ -1162,7 +1162,7 @@ - + @@ -1234,7 +1234,7 @@ - + @@ -1354,7 +1354,7 @@ - + @@ -1390,7 +1390,7 @@ - + @@ -1435,7 +1435,7 @@ - + @@ -1445,7 +1445,7 @@ - + @@ -1455,7 +1455,7 @@ - + @@ -1793,7 +1793,7 @@ - + @@ -1849,7 +1849,7 @@ - + @@ -1897,7 +1897,7 @@ - + @@ -1925,7 +1925,7 @@ - + @@ -1982,7 +1982,7 @@ - + @@ -2369,7 +2369,7 @@ - + diff --git a/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/shell_commands b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/shell_commands deleted file mode 100644 index f0547f3f26..0000000000 --- a/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/shell_commands +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./xmlchange CLM_BLDNML_OPTS="-ignore_warnings" --append diff --git a/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/include_user_mods b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_ignore_warnings/include_user_mods similarity index 100% rename from cime_config/testdefs/testmods_dirs/clm/matrixcnOn_Hist/include_user_mods rename to cime_config/testdefs/testmods_dirs/clm/matrixcnOn_ignore_warnings/include_user_mods diff --git a/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_ignore_warnings/shell_commands b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_ignore_warnings/shell_commands new file mode 100644 index 0000000000..d94ef06a5c --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/clm/matrixcnOn_ignore_warnings/shell_commands @@ -0,0 +1,7 @@ +#!/bin/bash + +./xmlchange CLM_BLDNML_OPTS="-ignore_warnings" --append + +# In this testmod directory we are ignoring warnings about running +# matrixcn in transient simulations AND/OR +# warnings about running matrixcn with threading NTHRDS_LND > 1. From 1e9df4973fdfcb9e685026ecaed2b56745b24663 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux <7565064+glemieux@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:27:07 -0700 Subject: [PATCH 171/194] update comment regarding landuse x pft data set Pre-generating files is a more likely next step relative to auto-gen --- cime_config/SystemTests/pvt.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index feef6cb04c..2a3dbafdc3 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -30,9 +30,8 @@ def __init__(self,case): error_message = (f"Only call PVT with testmod FatesLUPFT. {casebaseid} selected.") # Only allow to run if resolution is 4x5 for now - # Eventually we could set this up to generate the necessary land use x pft mapping - # on the fly, although this would also require generating the land use timeseries - # regridding on the fly which is a more time consuming endevour currently + # Other grid resolutions will be pre-processed and included in the namelist defaults at a future date. + # Potentially we could generate these on the fly although doing so would result in increased build time lnd_grid = self._case.get_value("LND_GRID") if lnd_grid != "4x5": error_message = (f"PVT can currently only be run with 4x5 resolution. {lnd_grid} selected.") From 48aeb43c9575c80a1547a85c1b02b529b690ac05 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux <7565064+glemieux@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:40:15 -0700 Subject: [PATCH 172/194] Update README with suggested clarification --- cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README index 79d6511d17..9b782cb2a7 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdLUH2/README @@ -1,2 +1,4 @@ Currently the FATES LUH2 category of test mods currently only supports -4x5 grid resolutions. +4x5 grid resolutions. This is because we only have one LUH2 time series +dataset for the 4x5 resolution. In the future we will provide more resolutions +which will be added to the namelist defaults. From 9ee75610973c32376f6dc407c99a0bc8d55cad83 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 12 Jul 2024 14:09:26 -0700 Subject: [PATCH 173/194] fix how harvest mode is passed to add_default for use_fates_luh --- bld/CLMBuildNamelist.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 47e0fff402..ac87d6f4ca 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -4522,7 +4522,7 @@ sub setup_logic_fates { add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_luh', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), 'use_fates_potentialveg'=>$nl->get_value('use_fates_potentialveg'), - 'fates_harvest_mode'=>$nl->get_value('fates_harvest_mode') ); + 'fates_harvest_mode'=>remove_leading_and_trailing_quotes($nl->get_value('fates_harvest_mode')) ); add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fates_nocomp', 'use_fates'=>$nl_flags->{'use_fates'}, 'use_fates_lupft'=>$nl->get_value('use_fates_lupft'), 'use_fates_sp'=>$nl_flags->{'use_fates_sp'} ); From 48368ac9a5fd2c36fb57cd21c3be76f773e3744d Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 12 Jul 2024 15:11:48 -0700 Subject: [PATCH 174/194] add comment pointing to luh2 data set readme --- src/dyn_subgrid/dynFATESLandUseChangeMod.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 index 681d39f38c..1bc6ab929e 100644 --- a/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 +++ b/src/dyn_subgrid/dynFATESLandUseChangeMod.F90 @@ -50,6 +50,7 @@ module dynFATESLandUseChangeMod type(dyn_file_type), target :: dynFatesLandUse_file ! LUH2 raw wood harvest area fraction + ! LUH2 data set variable names can be found at https://luh.umd.edu/LUH2/LUH2_v2h_README.pdf character(len=10), target :: landuse_harvest_area_varnames(num_landuse_harvest_vars) = & [character(len=10) :: 'primf_harv', 'primn_harv', 'secmf_harv', 'secyf_harv', 'secnf_harv'] From b0e6565a8d802db3c1a4a2ad3322726ed680b09f Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 12 Jul 2024 15:18:54 -0700 Subject: [PATCH 175/194] add single quotes around fates_harvest_mode in unit tests --- bld/unit_testers/build-namelist_test.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index b343e3d194..e60a411ccb 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1009,7 +1009,7 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "useloggingButNOTFATES" =>{ options=>"-envxml_dir . -no-megan", - namelst=>"fates_harvest_mode=event_code", + namelst=>"fates_harvest_mode='event_code'", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm4_5", }, @@ -1064,12 +1064,12 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "useFATESPOTVEGwithHARVEST" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_potentialveg=T,fates_harvest_mode=event_code", + namelst=>"use_fates_potentialveg=T,fates_harvest_mode='event_code'", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, "useFATESHARVEST3WOLUH" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_luh=F,fates_harvest_mode=luhdata_area", + namelst=>"use_fates_luh=F,fates_harvest_mode='luhdata_area'", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, From 8e618bb5384ba72d2b53b45a778aad29be542221 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 12 Jul 2024 16:44:47 -0600 Subject: [PATCH 176/194] Add new test to build-namelist_test.pl (currently failing) --- bld/unit_testers/build-namelist_test.pl | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 005f2c3f96..1810d4434b 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -41,7 +41,7 @@ sub make_env_run { # my %settings = @_; - # Set default settings + # Set default settings TODO slevis: NTHRDS_LND fails, OMP_NUM_THREADS fails my %env_vars = ( DIN_LOC_ROOT=>"MYDINLOCROOT", GLC_TWO_WAY_COUPLING=>"FALSE", NTHRDS_LND=>"1", NEONSITE=>"" ); # Set any settings that came in from function call foreach my $item ( keys(%settings) ) { @@ -163,7 +163,7 @@ sub cat_and_create_namelistinfile { # # Figure out number of tests that will run # -my $ntests = 3306; +my $ntests = 3309; if ( defined($opts{'compare'}) ) { $ntests += 2045; @@ -1320,6 +1320,12 @@ sub cat_and_create_namelistinfile { my %warntest = ( # Warnings without the -ignore_warnings option given + "matrixcnOn_with_threading" =>{ options=>"-envxml_dir . -bgc bgc", + namelst=>"use_matrixcn=.true.", + GLC_TWO_WAY_COUPLING=>"TRUE", + NTHRDS_LND=>"2", + phys=>"clm5_0", + }, "dustemisLeung" =>{ options=>"-envxml_dir .", namelst=>"dust_emis_method = 'Leung_2023'", GLC_TWO_WAY_COUPLING=>"FALSE", @@ -1376,7 +1382,13 @@ sub cat_and_create_namelistinfile { &make_config_cache($warntest{$key}{"phys"}); my $options = $warntest{$key}{"options"}; my $namelist = $warntest{$key}{"namelst"}; - &make_env_run( GLC_TWO_WAY_COUPLING=>$warntest{$key}{"GLC_TWO_WAY_COUPLING"} ); + my %settings; + foreach my $xmlvar ( "GLC_TWO_WAY_COUPLING", "NTHRDS_LND") { + if ( defined($failtest{$key}{$xmlvar}) ) { + $settings{$xmlvar} = $failtest{$key}{$xmlvar}; + } + } + &make_env_run( %settings ); eval{ system( "$bldnml $options -namelist \"&clmexp $namelist /\" > $tempfile 2>&1 " ); }; isnt( $?, 0, $key ); system( "cat $tempfile" ); From 12c60f3de477bbdaa2cf7a8afe0d089886d2c960 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 12 Jul 2024 16:01:12 -0700 Subject: [PATCH 177/194] correct POTVEG fail unit test This needs to have use_fates_luh to avoid the false negative of failing due to not having this mode with use_fates_potentialveg --- bld/unit_testers/build-namelist_test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index fc1e83f162..741964d8a1 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -1063,7 +1063,7 @@ sub cat_and_create_namelistinfile { phys=>"clm5_0", }, "useFATESPOTVEGwithHARVEST" =>{ options=>"-bgc fates -envxml_dir . -no-megan", - namelst=>"use_fates_potentialveg=T,fates_harvest_mode='event_code'", + namelst=>"use_fates_potentialveg=T,fates_harvest_mode='event_code',use_fates_luh=T", GLC_TWO_WAY_COUPLING=>"FALSE", phys=>"clm5_0", }, From af11aaab0644357cbff66aecbbc2f94a25778ab7 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 15 Jul 2024 14:02:15 -0600 Subject: [PATCH 178/194] Remove new test from build-namelist_test.pl for now --- bld/unit_testers/build-namelist_test.pl | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 1810d4434b..16f6ba2a62 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -41,8 +41,8 @@ sub make_env_run { # my %settings = @_; - # Set default settings TODO slevis: NTHRDS_LND fails, OMP_NUM_THREADS fails - my %env_vars = ( DIN_LOC_ROOT=>"MYDINLOCROOT", GLC_TWO_WAY_COUPLING=>"FALSE", NTHRDS_LND=>"1", NEONSITE=>"" ); + # Set default settings + my %env_vars = ( DIN_LOC_ROOT=>"MYDINLOCROOT", GLC_TWO_WAY_COUPLING=>"FALSE", NEONSITE=>"" ); # Set any settings that came in from function call foreach my $item ( keys(%settings) ) { $env_vars{$item} = $settings{$item}; @@ -1320,12 +1320,6 @@ sub cat_and_create_namelistinfile { my %warntest = ( # Warnings without the -ignore_warnings option given - "matrixcnOn_with_threading" =>{ options=>"-envxml_dir . -bgc bgc", - namelst=>"use_matrixcn=.true.", - GLC_TWO_WAY_COUPLING=>"TRUE", - NTHRDS_LND=>"2", - phys=>"clm5_0", - }, "dustemisLeung" =>{ options=>"-envxml_dir .", namelst=>"dust_emis_method = 'Leung_2023'", GLC_TWO_WAY_COUPLING=>"FALSE", @@ -1383,7 +1377,7 @@ sub cat_and_create_namelistinfile { my $options = $warntest{$key}{"options"}; my $namelist = $warntest{$key}{"namelst"}; my %settings; - foreach my $xmlvar ( "GLC_TWO_WAY_COUPLING", "NTHRDS_LND") { + foreach my $xmlvar ( "GLC_TWO_WAY_COUPLING" ) { if ( defined($failtest{$key}{$xmlvar}) ) { $settings{$xmlvar} = $failtest{$key}{$xmlvar}; } From 322097f0a2b5cf0c3b6bdd5a3eccb70845cb6990 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 15 Jul 2024 13:05:59 -0700 Subject: [PATCH 179/194] change folder name for fates land use x pft files This matches the corresponding fates tag that also impliments using this file --- bld/namelist_files/namelist_defaults_ctsm.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 6f29513e6b..d4167228b9 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -2019,7 +2019,7 @@ lnd/clm2/surfdata_esmf/NEON/surfdata_1x1_NEON_TOOL_hist_78pfts_CMIP6_simyr2000_c >lnd/clm2/surfdata_map/fates-sci.1.68.3_api.31.0.0_tools.1.0.1/LUH2_states_transitions_management.timeseries_4x5_hist_simyr1850-2015_c231101.nc -lnd/clm2/surfdata_map/fates-sci.1.73.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc +lnd/clm2/surfdata_map/fates-sci.1.77.0_api.36.0.0/fates_landuse_pft_map_4x5_240206.nc Date: Tue, 16 Jul 2024 08:58:38 -0600 Subject: [PATCH 180/194] Final ChangeLog/ChangeSum --- doc/ChangeLog | 2 +- doc/ChangeSum | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index b723b849ae..00c576d0d8 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,7 +1,7 @@ =============================================================== Tag name: ctsm5.2.012 Originator(s): sacks (Bill Sacks, UCAR/NCAR/CGD) -Date: Mon 15 Jul 2024 11:55:45 AM MDT +Date: Tue 16 Jul 2024 08:57:42 AM MDT One-line Summary: Relax tolerance for truncating small snocan values in CanopyFluxes Purpose and description of changes diff --git a/doc/ChangeSum b/doc/ChangeSum index 034c02429c..381b0db858 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,6 +1,6 @@ Tag Who Date Summary ============================================================================================================================ - ctsm5.2.012 sacks 07/15/2024 Relax tolerance for truncating small snocan values in CanopyFluxes + ctsm5.2.012 sacks 07/16/2024 Relax tolerance for truncating small snocan values in CanopyFluxes ctsm5.2.011 slevis 07/12/2024 Merge b4b-dev ctsm5.2.010 multiple 07/11/2024 Explicit A/C adoption ctsm5.2.009 erik 07/10/2024 Allow for CAM7 in lnd_tuning_mode and handle C or E in long compset names From aa923a4d2dc279cd9a85c2f691fd73ab7ab83e56 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 16 Jul 2024 12:12:33 -0600 Subject: [PATCH 181/194] Correct two test names in ExpectedTestFails.xml --- cime_config/testdefs/ExpectedTestFails.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index 6a2186d6d9..7a07a056f7 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -37,14 +37,14 @@ - + FAIL #2619 This failure relates to the following REP failure. - + FAIL #2619 From ef970e2e8062e0852583216acda18c4ade60cd5e Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 16 Jul 2024 12:13:21 -0600 Subject: [PATCH 182/194] Make hillslope_fsat_equals_zero .false. unless use_hillslope = .true. --- bld/namelist_files/namelist_defaults_ctsm.xml | 3 ++- bld/namelist_files/namelist_definition_ctsm.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index 0777f423ca..e2ba2de74b 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -625,7 +625,8 @@ attributes from the config_cache.xml file (with keys converted to upper-case). Standard Uniform .true. -.true. +.false. +.true. .false. diff --git a/bld/namelist_files/namelist_definition_ctsm.xml b/bld/namelist_files/namelist_definition_ctsm.xml index 52f5aee138..bc92dafbf0 100644 --- a/bld/namelist_files/namelist_definition_ctsm.xml +++ b/bld/namelist_files/namelist_definition_ctsm.xml @@ -829,7 +829,7 @@ Toggle to turn on surface water routing in the hillslope hydrology model + group="clm_inparm" valid_values="" value=".false."> If true, set fsat to zero for hillslope columns From 9db4d48623697669e5120830ded96ea2cb7047e0 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 16 Jul 2024 15:38:28 -0700 Subject: [PATCH 183/194] add izumi luh2 failure to expected list --- cime_config/testdefs/ExpectedTestFails.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cime_config/testdefs/ExpectedTestFails.xml b/cime_config/testdefs/ExpectedTestFails.xml index a4033aa6cd..ee1f188f15 100644 --- a/cime_config/testdefs/ExpectedTestFails.xml +++ b/cime_config/testdefs/ExpectedTestFails.xml @@ -150,6 +150,13 @@ + + + FAIL + #2653 + + + FAIL From 1de58fbb04d862245f69239835a00c15e062dc54 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 17 Jul 2024 12:37:45 -0700 Subject: [PATCH 184/194] update fates to sci.1.77.1_api.36.0.0 --- .gitmodules | 2 +- src/fates | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 9ed4402c7e..8127cac482 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,7 +28,7 @@ [submodule "fates"] path = src/fates url = https://github.com/NGEET/fates -fxtag = sci.1.77.0_api.36.0.0 +fxtag = sci.1.77.1_api.36.0.0 fxrequired = AlwaysRequired # Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed fxDONOTUSEurl = https://github.com/NCAR/fates-release diff --git a/src/fates b/src/fates index fd7f3438c2..1982b0032c 160000 --- a/src/fates +++ b/src/fates @@ -1 +1 @@ -Subproject commit fd7f3438c2ff821672b703050e7011f293649ee9 +Subproject commit 1982b0032c3cab6278892eccb85f643114ffb1af From 47571d844674d836a7501c3cd98f65ac545f4e39 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 17 Jul 2024 13:23:11 -0700 Subject: [PATCH 185/194] formatting fixed for changelog --- doc/ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 71b07aa2f2..54e3b4cc4b 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,5 @@ +=============================================================== +Tag name: ctsm5.2.013 Originator(s): samrabin (Sam Rabin, UCAR/TSS, samrabin@ucar.edu) glemieux (Gregory Lemieux, LBNL, glemieux@lbl.gov) Date: Wed 17 Jul 2024 01:20:00 PM MDT From e4142b96425712afa44cb6ab440d297a56aeaae1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 17 Jul 2024 13:26:45 -0700 Subject: [PATCH 186/194] fixing bad merge with changelog --- doc/ChangeLog | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 54e3b4cc4b..3c6a104725 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -79,7 +79,6 @@ Changes to tests or testing: and use_fates_lupft namelist options. Additoinally a new system text prefix, PVT, has been added to test the use_fates_potentialveg spin-up to use_fates_lupft transient workflow. These have been added to the fates test suite. -======= Bugs fixed ---------- @@ -154,6 +153,19 @@ Does this tag change answers significantly for any of the following physics conf [ ] clm4_5 + +Bugs fixed +---------- +List of CTSM issues fixed (include CTSM Issue # and description) [one per line]: +Fixes #2444 Failing water isotope test on the ctsm5.2 branch + +Notes of particular relevance for users +--------------------------------------- +Changes to documentation: None + +Testing summary: +---------------- + [PASS means all tests PASS; OK means tests PASS other than expected fails.] regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): From 75cd2f4c866bd8148dff0e310e1ba0711bef13f3 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Wed, 17 Jul 2024 14:07:23 -0700 Subject: [PATCH 187/194] reformat new and updated systests with black --- cime_config/SystemTests/pvt.py | 15 +++++++++------ cime_config/SystemTests/systemtest_utils.py | 7 ++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cime_config/SystemTests/pvt.py b/cime_config/SystemTests/pvt.py index 2a3dbafdc3..cf923dd334 100644 --- a/cime_config/SystemTests/pvt.py +++ b/cime_config/SystemTests/pvt.py @@ -16,9 +16,10 @@ logger = logging.getLogger(__name__) + class PVT(SystemTestsCommon): - def __init__(self,case): - SystemTestsCommon.__init__(self,case) + def __init__(self, case): + SystemTestsCommon.__init__(self, case) # Do not allow PVT to be run with certain testmods # Should this be targeted to a specific testmod for simplicity for now? @@ -27,14 +28,16 @@ def __init__(self,case): casebaseid = self._case.get_value("CASEBASEID") casebaseid = casebaseid.split("-")[-1] if casebaseid[0:10] != "FatesLUPFT": - error_message = (f"Only call PVT with testmod FatesLUPFT. {casebaseid} selected.") + error_message = f"Only call PVT with testmod FatesLUPFT. {casebaseid} selected." # Only allow to run if resolution is 4x5 for now # Other grid resolutions will be pre-processed and included in the namelist defaults at a future date. # Potentially we could generate these on the fly although doing so would result in increased build time lnd_grid = self._case.get_value("LND_GRID") if lnd_grid != "4x5": - error_message = (f"PVT can currently only be run with 4x5 resolution. {lnd_grid} selected.") + error_message = ( + f"PVT can currently only be run with 4x5 resolution. {lnd_grid} selected." + ) if error_message is not None: logger.error(error_message) @@ -79,7 +82,7 @@ def run_phase(self): # Turn off fates_harvest_mode for the spin up. logger.info("PVT log: modify user_nl_clm file for spin up run") - added_content = ["use_fates_potentialveg = .true.","fates_harvest_mode = 'no_harvest'"] + added_content = ["use_fates_potentialveg = .true.", "fates_harvest_mode = 'no_harvest'"] append_to_user_nl_files(clone_path, "clm", added_content) # Run the spin up case @@ -100,7 +103,7 @@ def run_phase(self): # obtain rpointer files and necessary restart files from short term archiving directory rundir = self._case.get_value("RUNDIR") - refdate = str(refcase_year) + '-01-01-00000' + refdate = str(refcase_year) + "-01-01-00000" rest_path = os.path.join(dout_sr, "rest", "{}".format(refdate)) for item in glob.glob("{}/*{}*".format(rest_path, refdate)): diff --git a/cime_config/SystemTests/systemtest_utils.py b/cime_config/SystemTests/systemtest_utils.py index c39f5171ba..c252f73251 100644 --- a/cime_config/SystemTests/systemtest_utils.py +++ b/cime_config/SystemTests/systemtest_utils.py @@ -86,14 +86,15 @@ def run_python_script(caseroot, this_conda_env, command_in, tool_path): print(f"ERROR trying to run {tool_name}.") raise + # Read a user_nl file and return the namelist option if found def find_user_nl_option(caseroot, component, namelist_option): - + # This is a copy of the CIME _get_list_of_user_nl_files # which could be used if this moved into the CIME project file_pattern = "user_nl_" + component + "*" file_list = glob.glob(os.path.join(caseroot, file_pattern)) - + # Check that there is at least one file if len(file_list) == 0: raise RuntimeError("No user_nl files found for component " + component) @@ -103,7 +104,7 @@ def find_user_nl_option(caseroot, component, namelist_option): for one_file in file_list: with open(one_file, "r") as user_nl_file: user_nl_text = user_nl_file.read() - reg = fr'{namelist_option}.*?(?=,|\n)' + reg = rf"{namelist_option}.*?(?=,|\n)" find_out = re.findall(reg, user_nl_text) output[one_file] = find_out return output From 3416574a862e2f1df62d29abb82efe76686084dd Mon Sep 17 00:00:00 2001 From: adrifoster Date: Thu, 18 Jul 2024 10:51:28 -0600 Subject: [PATCH 188/194] update date --- doc/ChangeLog | 2 +- doc/ChangeSum | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 3c6a104725..8cc3198fae 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -2,7 +2,7 @@ Tag name: ctsm5.2.013 Originator(s): samrabin (Sam Rabin, UCAR/TSS, samrabin@ucar.edu) glemieux (Gregory Lemieux, LBNL, glemieux@lbl.gov) -Date: Wed 17 Jul 2024 01:20:00 PM MDT +Date: Thu Jul 18 10:51:11 MDT 2024 One-line Summary: FATES Land Use V2 Purpose and description of changes diff --git a/doc/ChangeSum b/doc/ChangeSum index 92ca8281cf..df8e6dcf6a 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,6 +1,6 @@ Tag Who Date Summary ============================================================================================================================ - ctsm5.2.013 glemieux 07/17/2024 FATES Land Use V2 + ctsm5.2.013 glemieux 07/18/2024 FATES Land Use V2 ctsm5.2.012 sacks 07/16/2024 Relax tolerance for truncating small snocan values in CanopyFluxes ctsm5.2.011 slevis 07/12/2024 Merge b4b-dev ctsm5.2.010 multiple 07/11/2024 Explicit A/C adoption From c031e1c699be02a96123df5c0ed780f4c9ce73bc Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 18 Jul 2024 15:14:14 -0600 Subject: [PATCH 189/194] Update ntests in build-namelist_test.pl --- bld/unit_testers/build-namelist_test.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/unit_testers/build-namelist_test.pl b/bld/unit_testers/build-namelist_test.pl index 16f6ba2a62..9b283af334 100755 --- a/bld/unit_testers/build-namelist_test.pl +++ b/bld/unit_testers/build-namelist_test.pl @@ -163,7 +163,7 @@ sub cat_and_create_namelistinfile { # # Figure out number of tests that will run # -my $ntests = 3309; +my $ntests = 3306; if ( defined($opts{'compare'}) ) { $ntests += 2045; From c2b6c43f44c0dc3b6b9ad65b5dc979951090c3da Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Thu, 18 Jul 2024 17:35:07 -0600 Subject: [PATCH 190/194] Draft ChangeLog/ChangeSum --- doc/ChangeLog | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++ doc/ChangeSum | 1 + 2 files changed, 145 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 8cc3198fae..5f2896ebc9 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,148 @@ =============================================================== +Tag name: ctsm5.2.014 +Originator(s): chrislxj (Xingjie Lu, Northern Arizona U., xingjie.lu@nau.edu) +Date: Thu 18 Jul 2024 03:50:56 PM MDT +One-line Summary: use_matrixcn, use_soil_matrixcn come in but as default .false. + +Purpose and description of changes +---------------------------------- + + Currently set as default .false.: + - Add matrix module for vegetation and soil C and N cycle + - Add diagnostic variables C and N storage capacity in history files + - Add Sparse matrix module to increase the code efficiency + - Create spin-up switch, and be ready for matrix spin up development + + Additional contributors: Yuanyuan Huang, Zhenggang Du, and Yiqi Luo from + Professor Yiqi Luo's EcoLab at Northern Arizona University, now at Cornell U. + + In TSS/CGD/NCAR, contributors in the last year include slevis, ekluzek, wwieder. + Others may have been involved prior. I apologize for omissions. + +Significant changes to scientifically-supported configurations +-------------------------------------------------------------- + +Does this tag change answers significantly for any of the following physics configurations? +(Details of any changes will be given in the "Answer changes" section below.) + + [Put an [X] in the box for any configuration with significant answer changes.] + +[ ] clm6_0 + +[ ] clm5_1 + +[ ] clm5_0 + +[ ] ctsm5_0-nwp + +[ ] clm4_5 + + +Bugs fixed +---------- +List of CTSM issues fixed (include CTSM Issue # and description) [one per line]: + Fixes #903 Bring CN-Matrix solution into CTSM + Fixes #2450 Cn-matrix testing in the aux_clm test-suites + Fixes #2621 matrixcn does not work with nrepr != 1 (number of crop reproductive pools) + +Notes of particular relevance for users +--------------------------------------- + +Caveats for users (e.g., need to interpolate initial conditions): + use_matrixcn and use_soil_matrixcn ARE recommended for accelerating bgc spin-ups + and NOT recommended for + - transient simulations (e.g. IHist) + - simulations that use threading (e.g. see tests with P64x2) + - NWP compsets + +Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): + New: use_matrixcn, use_soil_matrixcn, hist_wrt_matrixcn_diag. + All three are default .false. at this time. + +Changes made to namelist defaults (e.g., changed parameter values): + Changed hillslope_fsat_equals_zero to default .false. when + use_hillslope = .false. as per issue #2652 + clm_accelerated_spinup can be set to off, on, sasu, the latter being + the setting that uses matrixcn + +Changes to the datasets (e.g., parameter, surface or initial files): + No. + +Changes to documentation: + None at this time. A description of the spinup procedure appears in + https://github.com/NCAR/LMWG_dev/issues/58 + +Substantial timing or memory changes: + ***Check PFS test in the test suite and look at timings + + +Notes of particular relevance for developers: +--------------------------------------------- + +Caveats for developers (e.g., code that is duplicated that requires double maintenance): + - Future changes to the bgc will likely require changes in both + matrix and non-matrix parts of the code. + - I have found matrixcn to be sensitive to changes in the subgrid + heterogeneity and other subtleties. For example, matrixcn simulations + have failed from using a finidat file from a different simulation (#2592), + from running in transient mode (#2592), from running with threading (#2619), + and from setting hillslope_fsat_equals_zero = .true. (issue #2652). + - We recommend using matrixcn to accelerate bgc spin-ups and not for + most (possibly any) other purposes. + +Changes to tests or testing: + Numerous new tests in aux_clm and in build-namelist_test.pl that can be + identified by searching "matr" + + +Testing summary: +---------------- + + [PASS means all tests PASS; OK means tests PASS other than expected fails.] + + build-namelist tests (if CLMBuildNamelist.pm has changed): + + derecho - PASS + + python testing (if python code has changed; see instructions in python/README.md; document testing done): + + derecho - PASS + + regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): + + derecho ----- IN PROG + izumi ------- IN PROG + + ctsm_sci + derecho ---- IN PROG + + +Answer changes +-------------- + +Changes answers relative to baseline: Yes, roundoff + + Summarize any changes to answers, i.e., + - what code configurations: All + - what platforms/compilers: All + - nature of change: roundoff + use_matrixcn and use_soil_matrixcn are default .false.. We get + roundoff diffs due to order-of-operation changes in a few locations, + done to improve code readability and streamlining in the presence of matrix. + + Testing with the non-default use_matrixcn = .true. and use_soil_matrixcn = .true. + appears here: https://github.com/NCAR/LMWG_dev/issues/58 + + PR #640 associated with this tag explains how answers are expected to + change from non-matrix to matrix simulations. + +Other details +------------- +Pull Requests that document the changes (include PR ids): + https://github.com/ESCOMP/ctsm/pull/640 + +=============================================================== +=============================================================== Tag name: ctsm5.2.013 Originator(s): samrabin (Sam Rabin, UCAR/TSS, samrabin@ucar.edu) glemieux (Gregory Lemieux, LBNL, glemieux@lbl.gov) diff --git a/doc/ChangeSum b/doc/ChangeSum index df8e6dcf6a..8579fbee98 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,5 +1,6 @@ Tag Who Date Summary ============================================================================================================================ + ctsm5.2.014 chrislxj 07/18/2024 use_matrixcn, use_soil_matrixcn come in but as default .false. ctsm5.2.013 glemieux 07/18/2024 FATES Land Use V2 ctsm5.2.012 sacks 07/16/2024 Relax tolerance for truncating small snocan values in CanopyFluxes ctsm5.2.011 slevis 07/12/2024 Merge b4b-dev From 5aeb618ebffdb8ab49521d47aa2d04037f76aa6f Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 19 Jul 2024 11:53:37 -0600 Subject: [PATCH 191/194] Update ChangeLog/ChangeSum --- doc/ChangeLog | 57 +++++++++++++++++++++++++-------------------------- doc/ChangeSum | 2 +- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 5f2896ebc9..35ad747636 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,8 +1,8 @@ =============================================================== Tag name: ctsm5.2.014 Originator(s): chrislxj (Xingjie Lu, Northern Arizona U., xingjie.lu@nau.edu) -Date: Thu 18 Jul 2024 03:50:56 PM MDT -One-line Summary: use_matrixcn, use_soil_matrixcn come in but as default .false. +Date: Fri 19 Jul 2024 11:04:17 AM MDT +One-line Summary: use_matrixcn, use_soil_matrixcn come in as default .false. Purpose and description of changes ---------------------------------- @@ -16,8 +16,9 @@ Purpose and description of changes Additional contributors: Yuanyuan Huang, Zhenggang Du, and Yiqi Luo from Professor Yiqi Luo's EcoLab at Northern Arizona University, now at Cornell U. - In TSS/CGD/NCAR, contributors in the last year include slevis, ekluzek, wwieder. - Others may have been involved prior. I apologize for omissions. + In TSS/CGD/NCAR/UCAR, contributors in the last year include slevis, ekluzek, wwieder. + I apologize if I have omitted others who may have been involved prior. + Significant changes to scientifically-supported configurations -------------------------------------------------------------- @@ -45,12 +46,13 @@ List of CTSM issues fixed (include CTSM Issue # and description) [one per line]: Fixes #2450 Cn-matrix testing in the aux_clm test-suites Fixes #2621 matrixcn does not work with nrepr != 1 (number of crop reproductive pools) + Notes of particular relevance for users --------------------------------------- Caveats for users (e.g., need to interpolate initial conditions): - use_matrixcn and use_soil_matrixcn ARE recommended for accelerating bgc spin-ups - and NOT recommended for + use_matrixcn and use_soil_matrixcn ARE recommended for accelerating bgc + spin-ups (keep reading for more info) and NOT recommended for - transient simulations (e.g. IHist) - simulations that use threading (e.g. see tests with P64x2) - NWP compsets @@ -60,21 +62,17 @@ Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): All three are default .false. at this time. Changes made to namelist defaults (e.g., changed parameter values): - Changed hillslope_fsat_equals_zero to default .false. when + - hillslope_fsat_equals_zero is now default .false. when use_hillslope = .false. as per issue #2652 - clm_accelerated_spinup can be set to off, on, sasu, the latter being - the setting that uses matrixcn - -Changes to the datasets (e.g., parameter, surface or initial files): - No. + - clm_accelerated_spinup can be set to on, sasu, off; matrixcn spin-up + is performed in that order (on, sasu, off); in the "on" phase, matrixcn + is not active, in the "sasu" phase matrixcn is active, and in the "off" + phase, matrixcn may be active Changes to documentation: None at this time. A description of the spinup procedure appears in https://github.com/NCAR/LMWG_dev/issues/58 -Substantial timing or memory changes: - ***Check PFS test in the test suite and look at timings - Notes of particular relevance for developers: --------------------------------------------- @@ -82,17 +80,17 @@ Notes of particular relevance for developers: Caveats for developers (e.g., code that is duplicated that requires double maintenance): - Future changes to the bgc will likely require changes in both matrix and non-matrix parts of the code. - - I have found matrixcn to be sensitive to changes in the subgrid - heterogeneity and other subtleties. For example, matrixcn simulations - have failed from using a finidat file from a different simulation (#2592), + - matrixcn seems sensitive to changes in subgrid heterogeneity and + other subtleties. For example, matrixcn simulations have failed from + using a finidat file from a different simulation (#2592), from running in transient mode (#2592), from running with threading (#2619), and from setting hillslope_fsat_equals_zero = .true. (issue #2652). - We recommend using matrixcn to accelerate bgc spin-ups and not for - most (possibly any) other purposes. + most (any?) other purposes. Changes to tests or testing: - Numerous new tests in aux_clm and in build-namelist_test.pl that can be - identified by searching "matr" + We introduced numerous new tests to the aux_clm and build-namelist_test.pl + test-suites that can be identified by searching "matrix" Testing summary: @@ -110,11 +108,11 @@ Testing summary: regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): - derecho ----- IN PROG - izumi ------- IN PROG + derecho ----- OK + izumi ------- OK ctsm_sci - derecho ---- IN PROG + derecho ---- OK Answer changes @@ -123,17 +121,18 @@ Answer changes Changes answers relative to baseline: Yes, roundoff Summarize any changes to answers, i.e., - - what code configurations: All + - what code configurations: Non-matrix - what platforms/compilers: All - nature of change: roundoff use_matrixcn and use_soil_matrixcn are default .false.. We get - roundoff diffs due to order-of-operation changes in a few locations, - done to improve code readability and streamlining in the presence of matrix. + roundoff diffs due to order-of-operation changes in a few sections + of code, which improve readability and streamlining of the code + in the presence of matrix. - Testing with the non-default use_matrixcn = .true. and use_soil_matrixcn = .true. + Testing with the non-default use_matrixcn and use_soil_matrixcn = .true. appears here: https://github.com/NCAR/LMWG_dev/issues/58 - PR #640 associated with this tag explains how answers are expected to + PR #640 explains how answers are expected to change from non-matrix to matrix simulations. Other details diff --git a/doc/ChangeSum b/doc/ChangeSum index 8579fbee98..21237cbac8 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,6 +1,6 @@ Tag Who Date Summary ============================================================================================================================ - ctsm5.2.014 chrislxj 07/18/2024 use_matrixcn, use_soil_matrixcn come in but as default .false. + ctsm5.2.014 chrislxj 07/19/2024 use_matrixcn, use_soil_matrixcn come in as default .false. ctsm5.2.013 glemieux 07/18/2024 FATES Land Use V2 ctsm5.2.012 sacks 07/16/2024 Relax tolerance for truncating small snocan values in CanopyFluxes ctsm5.2.011 slevis 07/12/2024 Merge b4b-dev From 63b3c3fdfa8e9d5aec763bd872a81a69b2832d8e Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 19 Jul 2024 17:19:36 -0600 Subject: [PATCH 192/194] Namelist corrections after an izumi test failed ERS_D.f19_g17.I1850Clm50BgcCrop.izumi_nag.clm-ciso_monthly_matrixcn_spinup failed during the build because a namelist variable needed renaming --- .../user_nl_mosart | 2 +- .../testmods_dirs/clm/rtmColdSSP/user_nl_rtm | 8 +++---- lilac/bld_templates/mosart_in | 22 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cime_config/testdefs/testmods_dirs/clm/ciso_monthly_matrixcn_spinup/user_nl_mosart b/cime_config/testdefs/testmods_dirs/clm/ciso_monthly_matrixcn_spinup/user_nl_mosart index 9e109fc131..82243d7d3d 100644 --- a/cime_config/testdefs/testmods_dirs/clm/ciso_monthly_matrixcn_spinup/user_nl_mosart +++ b/cime_config/testdefs/testmods_dirs/clm/ciso_monthly_matrixcn_spinup/user_nl_mosart @@ -1 +1 @@ -frivinp_rtm = '/dev/null' +frivinp = '/dev/null' diff --git a/cime_config/testdefs/testmods_dirs/clm/rtmColdSSP/user_nl_rtm b/cime_config/testdefs/testmods_dirs/clm/rtmColdSSP/user_nl_rtm index d1a0254a0b..e78d13a51c 100644 --- a/cime_config/testdefs/testmods_dirs/clm/rtmColdSSP/user_nl_rtm +++ b/cime_config/testdefs/testmods_dirs/clm/rtmColdSSP/user_nl_rtm @@ -1,4 +1,4 @@ -finidat_rtm = " " -rtmhist_mfilt = 1 -rtmhist_ndens = 2 -rtmhist_nhtfrq = 0 +finidat = " " +mfilt = 1 +ndens = 2 +nhtfrq = 0 diff --git a/lilac/bld_templates/mosart_in b/lilac/bld_templates/mosart_in index 091ec69285..0bc2242dda 100644 --- a/lilac/bld_templates/mosart_in +++ b/lilac/bld_templates/mosart_in @@ -4,18 +4,18 @@ delt_mosart = 1800 do_rtm = .true. do_rtmflood = .false. - finidat_rtm = " " - frivinp_rtm = "/glade/campaign/cesm/cesmdata/cseg/inputdata/rof/mosart/MOSART_routing_Global_0.5x0.5_c170601.nc" + finidat = " " + frivinp = "/glade/campaign/cesm/cesmdata/cseg/inputdata/rof/mosart/MOSART_routing_Global_0.5x0.5_c170601.nc" ice_runoff = .true. qgwl_runoff_option = "threshold" - rtmhist_fexcl1 = "" - rtmhist_fexcl2 = "" - rtmhist_fexcl3 = "" - rtmhist_fincl1 = "" - rtmhist_fincl2 = "" - rtmhist_fincl3 = "" - rtmhist_mfilt = 1 - rtmhist_ndens = 1 - rtmhist_nhtfrq = 0 + fexcl1 = "" + fexcl2 = "" + fexcl3 = "" + fincl1 = "" + fincl2 = "" + fincl3 = "" + mfilt = 1 + ndens = 1 + nhtfrq = 0 smat_option = "Xonly" / From a32a9eb121af3fcb7de1af94b5812f51eac49666 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 19 Jul 2024 18:42:31 -0600 Subject: [PATCH 193/194] Draft ChangeLog/ChangeSum (comments welcome) --- doc/ChangeLog | 130 +++++++++++++++++++++++++++++++++++++++++++++++++- doc/ChangeSum | 3 +- 2 files changed, 131 insertions(+), 2 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 35ad747636..785b26db9e 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,131 @@ =============================================================== +Tag name: ctsm5.2.015 +Originator(s): multiple (Samuel Levis,UCAR/TSS,303-665-1310, @mvertens, @jedwards4b, @billsacks, @Katetc) +Date: Fri 19 Jul 2024 06:02:22 PM MDT +One-line Summary: Update submodule tags to pass runoff from cism to rof + +Purpose and description of changes +---------------------------------- + + - Update MOSART, CMEPS, and CISM so CISM runoff goes to ROF rather than CTSM + - Update RTM with fix needed for Paleo LGM work + + +Significant changes to scientifically-supported configurations +-------------------------------------------------------------- + +Does this tag change answers significantly for any of the following physics configurations? +(Details of any changes will be given in the "Answer changes" section below.) + + [Put an [X] in the box for any configuration with significant answer changes.] + +[ ] clm6_0 + +[ ] clm5_1 + +[ ] clm5_0 + +[ ] ctsm5_0-nwp + +[ ] clm4_5 + + +Bugs fixed +---------- +List of CTSM issues fixed (include CTSM Issue # and description) [one per line]: + Fixes #2590 Update CMEPS/MOSART/CISM/RTM tags + Fixes https://github.com/ESCOMP/RTM/issues/50 Likely wrong RTM river flux to MOM6 within cesm2_3_beta17 + +Notes of particular relevance for users +--------------------------------------- + +Caveats for users (e.g., need to interpolate initial conditions): + Issue https://github.com/ESCOMP/RTM/issues/50 + Likely wrong RTM river flux to MOM6 within cesm2_3_beta17 is now fixed with + https://github.com/ESCOMP/RTM/pull/51 + +Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): + Differences in namelist 'mosart_inparm': + missing variable: 'do_rtmflood' + missing variable: 'finidat_rtm' + missing variable: 'frivinp_rtm' + missing variable: 'rtmhist_fexcl1' + missing variable: 'rtmhist_fexcl2' + missing variable: 'rtmhist_fexcl3' + missing variable: 'rtmhist_fincl1' + missing variable: 'rtmhist_fincl2' + missing variable: 'rtmhist_fincl3' + missing variable: 'rtmhist_mfilt' + missing variable: 'rtmhist_ndens' + missing variable: 'rtmhist_nhtfrq' + found extra variable: 'budget_frq' + found extra variable: 'fexcl1' + found extra variable: 'fexcl2' + found extra variable: 'fexcl3' + found extra variable: 'fincl1' + found extra variable: 'fincl2' + found extra variable: 'fincl3' + found extra variable: 'finidat' + found extra variable: 'frivinp' + found extra variable: 'mfilt' + found extra variable: 'mosart_euler_calc' + found extra variable: 'mosart_tracers' + found extra variable: 'ndens' + found extra variable: 'nhtfrq' + found extra variable: 'use_halo_option' + +Changes to documentation: + Not that I am aware of + + +Testing summary: +---------------- + + [PASS means all tests PASS; OK means tests PASS other than expected fails.] + + build-namelist tests (if CLMBuildNamelist.pm has changed): + + derecho - PASS + + python testing (if python code has changed; see instructions in python/README.md; document testing done): + + derecho - PASS + + regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing): + + derecho ----- OK + izumi ------- OK + + ctsm_sci + derecho ---- OK (while in tag ctsm5.2.007; I did not repeat with the latest; see checklist in #2590) + + +Answer changes +-------------- + +Changes answers relative to baseline: Yes + + Summarize any changes to answers, i.e., + - what code configurations: mosart and rtm + - what platforms/compilers: all + - nature of change: mosart roundoff; rtm larger than roundoff due to bug fix + + +Other details +------------- +List any git submodules updated (cime, rtm, mosart, cism, fates, etc.): + See .gitmodules: cism, rtm, mosart, ccs_config, cmeps + +Pull Requests that document the changes (include PR ids): + https://github.com/ESCOMP/ctsm/pull/2605 + https://github.com/ESCOMP/RTM/pull/51 + https://github.com/ESCOMP/MOSART/pull/94 + https://github.com/ESCOMP/CISM-wrapper/pull/100 + https://github.com/ESCOMP/CMEPS/pull/463 + https://github.com/ESMCI/ccs_config_cesm/pull/174 + +=============================================================== +=============================================================== Tag name: ctsm5.2.014 Originator(s): chrislxj (Xingjie Lu, Northern Arizona U., xingjie.lu@nau.edu) Date: Fri 19 Jul 2024 11:04:17 AM MDT @@ -51,7 +178,8 @@ Notes of particular relevance for users --------------------------------------- Caveats for users (e.g., need to interpolate initial conditions): - use_matrixcn and use_soil_matrixcn ARE recommended for accelerating bgc + use_matrixcn and use_soil_matrixcn ARE NOT available for clm4_5 + and ARE recommended for accelerating bgc spin-ups (keep reading for more info) and NOT recommended for - transient simulations (e.g. IHist) - simulations that use threading (e.g. see tests with P64x2) diff --git a/doc/ChangeSum b/doc/ChangeSum index 21237cbac8..5c7123b5e0 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,6 +1,7 @@ Tag Who Date Summary ============================================================================================================================ - ctsm5.2.014 chrislxj 07/19/2024 use_matrixcn, use_soil_matrixcn come in as default .false. + ctsm5.2.015 multiple 07/19/2024 Update submodule tags to pass runoff from cism to rof + ctsm5.2.014 multiple 07/19/2024 use_matrixcn, use_soil_matrixcn come in as default .false. ctsm5.2.013 glemieux 07/18/2024 FATES Land Use V2 ctsm5.2.012 sacks 07/16/2024 Relax tolerance for truncating small snocan values in CanopyFluxes ctsm5.2.011 slevis 07/12/2024 Merge b4b-dev From a4a9ede604eb36e1b1f6541fb1e40b712176ffa5 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 22 Jul 2024 16:04:00 -0600 Subject: [PATCH 194/194] Update ChangeLog/ChangeSum --- doc/ChangeLog | 4 +++- doc/ChangeSum | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 785b26db9e..506b3d5ad0 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,7 +1,7 @@ =============================================================== Tag name: ctsm5.2.015 Originator(s): multiple (Samuel Levis,UCAR/TSS,303-665-1310, @mvertens, @jedwards4b, @billsacks, @Katetc) -Date: Fri 19 Jul 2024 06:02:22 PM MDT +Date: Mon 22 Jul 2024 12:46:17 PM MDT One-line Summary: Update submodule tags to pass runoff from cism to rof Purpose and description of changes @@ -110,6 +110,8 @@ Changes answers relative to baseline: Yes - what platforms/compilers: all - nature of change: mosart roundoff; rtm larger than roundoff due to bug fix + We are ignoring strange diffs from baseline in two tests in variable + FATES_TRANSITION_MATRIX_LULU as explained in issue #2656. Other details ------------- diff --git a/doc/ChangeSum b/doc/ChangeSum index 5c7123b5e0..9c6524b33d 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,6 +1,6 @@ Tag Who Date Summary ============================================================================================================================ - ctsm5.2.015 multiple 07/19/2024 Update submodule tags to pass runoff from cism to rof + ctsm5.2.015 multiple 07/22/2024 Update submodule tags to pass runoff from cism to rof ctsm5.2.014 multiple 07/19/2024 use_matrixcn, use_soil_matrixcn come in as default .false. ctsm5.2.013 glemieux 07/18/2024 FATES Land Use V2 ctsm5.2.012 sacks 07/16/2024 Relax tolerance for truncating small snocan values in CanopyFluxes