From 8c905eb15766b28ccbaf9359a0970bcba627c528 Mon Sep 17 00:00:00 2001 From: Wuyin Lin Date: Fri, 27 Sep 2024 11:57:47 -0500 Subject: [PATCH 1/4] Make bgc balance_check_tolerance a nml variable and increase the default --- components/elm/bld/namelist_files/namelist_definition.xml | 6 ++++++ .../elm/src/biogeochem/EcosystemBalanceCheckMod.F90 | 7 +++++-- components/elm/src/main/controlMod.F90 | 8 +++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/components/elm/bld/namelist_files/namelist_definition.xml b/components/elm/bld/namelist_files/namelist_definition.xml index 7063d7a11054..1ba599031709 100644 --- a/components/elm/bld/namelist_files/namelist_definition.xml +++ b/components/elm/bld/namelist_files/namelist_definition.xml @@ -139,6 +139,12 @@ If TRUE consider priority of plant to get a fraction of symbiotic N fixation and P phosphatase + +BGC balance check tolerance +Default 1.0e-7 hardwired + + Set date for beginning of adding temperature to atmospheric forcing diff --git a/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 b/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 index ffe1be5d909b..dab999478ebc 100644 --- a/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 +++ b/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 @@ -48,7 +48,8 @@ module EcosystemBalanceCheckMod implicit none save private - real(r8), parameter :: balance_check_tolerance = 1e-8_r8 + + real(r8), public :: balance_check_tolerance = 1e-7_r8 ! ! !PUBLIC MEMBER FUNCTIONS: public :: BeginColCBalance @@ -64,6 +65,8 @@ module EcosystemBalanceCheckMod public :: EndGridCBalanceAfterDynSubgridDriver public :: EndGridNBalanceAfterDynSubgridDriver public :: EndGridPBalanceAfterDynSubgridDriver + + !----------------------------------------------------------------------- contains @@ -498,7 +501,7 @@ subroutine ColNBalanceCheck(bounds, & ! here is '-' adjustment. It says that the adding to PF decomp n pools was less. end if - if (abs(col_errnb(c)) > 1e-8_r8) then + if (abs(col_errnb(c)) > balance_check_tolerance) then err_found = .true. err_index = c end if diff --git a/components/elm/src/main/controlMod.F90 b/components/elm/src/main/controlMod.F90 index 1d8f48d7cc7d..7775a59dbbf7 100755 --- a/components/elm/src/main/controlMod.F90 +++ b/components/elm/src/main/controlMod.F90 @@ -55,6 +55,7 @@ module controlMod use elm_varctl , only: const_climate_hist use elm_varctl , only: use_top_solar_rad use elm_varctl , only: snow_shape, snicar_atm_type, use_dust_snow_internal_mixing + use EcosystemBalanceCheckMod, only: balance_check_tolerance ! ! !PUBLIC TYPES: @@ -181,6 +182,10 @@ subroutine control_init( ) namelist /elm_inparm/ & NFIX_PTASE_plant + ! BGC balance check + namelist /elm_inparm/ & + balance_check_tolerance + ! For experimental manipulations namelist /elm_inparm/ & startdate_add_temperature @@ -325,7 +330,7 @@ subroutine control_init( ) namelist /elm_mosart/ & lnd_rof_coupling_nstep - + namelist /elm_inparm/ & snow_shape, snicar_atm_type, use_dust_snow_internal_mixing @@ -796,6 +801,7 @@ subroutine control_spmd() call mpi_bcast (forest_fert_exp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (ECA_Pconst_RGspin, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (NFIX_PTASE_plant, 1, MPI_LOGICAL, 0, mpicom, ier) + call mpi_bcast (balance_check_tolerance, 1, MPI_REAL8, 0, mpicom, ier) call mpi_bcast (use_pheno_flux_limiter, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (startdate_add_temperature, 1, MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (startdate_add_co2, 1, MPI_CHARACTER, 0, mpicom, ier) From c1631a81ecad43dfaf4dec371aec14eb0b145ea7 Mon Sep 17 00:00:00 2001 From: Wuyin Lin Date: Fri, 27 Sep 2024 12:12:57 -0500 Subject: [PATCH 2/4] Remove extra blank lines --- components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 b/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 index dab999478ebc..879bd6cc64d5 100644 --- a/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 +++ b/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 @@ -65,8 +65,6 @@ module EcosystemBalanceCheckMod public :: EndGridCBalanceAfterDynSubgridDriver public :: EndGridNBalanceAfterDynSubgridDriver public :: EndGridPBalanceAfterDynSubgridDriver - - !----------------------------------------------------------------------- contains From f46455b88ad7f60e70d4322915353e080f31a717 Mon Sep 17 00:00:00 2001 From: Wuyin Lin Date: Fri, 27 Sep 2024 15:23:24 -0500 Subject: [PATCH 3/4] Rename the nml variable as bgc_balance_check_tolerance --- components/elm/bld/namelist_files/namelist_definition.xml | 2 +- components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 | 2 ++ components/elm/src/main/controlMod.F90 | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/elm/bld/namelist_files/namelist_definition.xml b/components/elm/bld/namelist_files/namelist_definition.xml index 1ba599031709..959279120147 100644 --- a/components/elm/bld/namelist_files/namelist_definition.xml +++ b/components/elm/bld/namelist_files/namelist_definition.xml @@ -139,7 +139,7 @@ If TRUE consider priority of plant to get a fraction of symbiotic N fixation and P phosphatase - BGC balance check tolerance Default 1.0e-7 hardwired diff --git a/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 b/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 index 879bd6cc64d5..a2ad41bf6658 100644 --- a/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 +++ b/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 @@ -49,7 +49,9 @@ module EcosystemBalanceCheckMod save private + ! This corersponds to namelist variable bgc_balance_check_tolerance real(r8), public :: balance_check_tolerance = 1e-7_r8 + ! ! !PUBLIC MEMBER FUNCTIONS: public :: BeginColCBalance diff --git a/components/elm/src/main/controlMod.F90 b/components/elm/src/main/controlMod.F90 index 7775a59dbbf7..dc7fa975dbb4 100755 --- a/components/elm/src/main/controlMod.F90 +++ b/components/elm/src/main/controlMod.F90 @@ -55,7 +55,7 @@ module controlMod use elm_varctl , only: const_climate_hist use elm_varctl , only: use_top_solar_rad use elm_varctl , only: snow_shape, snicar_atm_type, use_dust_snow_internal_mixing - use EcosystemBalanceCheckMod, only: balance_check_tolerance + use EcosystemBalanceCheckMod, only: bgc_balance_check_tolerance => balance_check_tolerance ! ! !PUBLIC TYPES: @@ -184,7 +184,7 @@ subroutine control_init( ) ! BGC balance check namelist /elm_inparm/ & - balance_check_tolerance + bgc_balance_check_tolerance ! For experimental manipulations namelist /elm_inparm/ & @@ -801,7 +801,7 @@ subroutine control_spmd() call mpi_bcast (forest_fert_exp, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (ECA_Pconst_RGspin, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (NFIX_PTASE_plant, 1, MPI_LOGICAL, 0, mpicom, ier) - call mpi_bcast (balance_check_tolerance, 1, MPI_REAL8, 0, mpicom, ier) + call mpi_bcast (bgc_balance_check_tolerance, 1, MPI_REAL8, 0, mpicom, ier) call mpi_bcast (use_pheno_flux_limiter, 1, MPI_LOGICAL, 0, mpicom, ier) call mpi_bcast (startdate_add_temperature, 1, MPI_CHARACTER, 0, mpicom, ier) call mpi_bcast (startdate_add_co2, 1, MPI_CHARACTER, 0, mpicom, ier) From 632faeb0ff03a1f012b658de68d4b11f7c6ced45 Mon Sep 17 00:00:00 2001 From: Wuyin Lin Date: Mon, 30 Sep 2024 14:53:49 -0500 Subject: [PATCH 4/4] Use same balance_check_tolerance for C and P --- components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 b/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 index a2ad41bf6658..1a9b59f776ea 100644 --- a/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 +++ b/components/elm/src/biogeochem/EcosystemBalanceCheckMod.F90 @@ -281,7 +281,7 @@ subroutine ColCBalanceCheck(bounds, & end if ! check for significant errors - if (abs(col_errcb(c)) > 1e-8_r8) then + if (abs(col_errcb(c)) > balance_check_tolerance) then err_found = .true. err_index = c end if @@ -734,7 +734,7 @@ subroutine ColPBalanceCheck(bounds, & col_errpb(c) = (col_pinputs(c) - col_poutputs(c))*dt - & (col_endpb(c) - col_begpb(c)) - if (abs(col_errpb(c)) > 1e-8_r8) then + if (abs(col_errpb(c)) > balance_check_tolerance) then err_found = .true. err_index = c end if