From dc495fbca99a18621e18350dc39bc82a6b2723e5 Mon Sep 17 00:00:00 2001 From: Gautam Bisht Date: Fri, 1 Mar 2024 12:44:33 -0800 Subject: [PATCH] Makes C-budget SetEndingMonthlyStates consistent The subroutines for water and carbon are made consistent. --- .../elm/src/biogeochem/CNPBudgetMod.F90 | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/components/elm/src/biogeochem/CNPBudgetMod.F90 b/components/elm/src/biogeochem/CNPBudgetMod.F90 index a06e9b512c68..e4f705f1fe5c 100644 --- a/components/elm/src/biogeochem/CNPBudgetMod.F90 +++ b/components/elm/src/biogeochem/CNPBudgetMod.F90 @@ -1193,8 +1193,7 @@ subroutine CBudget_SetEndingMonthlyStates(bounds, col_cs, grc_cs) type(gridcell_carbon_state), intent(inout) :: grc_cs ! ! !LOCAL VARIABLES: - integer :: year_prev, month_prev, day_prev, sec_prev - integer :: year_curr, month_curr, day_curr, sec_curr + integer :: year, month, day, sec !----------------------------------------------------------------------- associate( & @@ -1203,26 +1202,19 @@ subroutine CBudget_SetEndingMonthlyStates(bounds, col_cs, grc_cs) tcs_month_end_grc => grc_cs%tcs_month_end & ! Output: [real(r8) (:) ] grid-level carbon mass at the ending of a month ) - ! Get current and previous dates to determine if a new month started - call get_curr_date(year_curr, month_curr, day_curr, sec_curr); - - ! If at the beginning of a simulation, save grid-level TCS based on - ! 'begcb' from the current time step - if ( day_curr == 1 .and. sec_curr == 0 .and. get_nstep() <= 1 ) then - call c2g( bounds, & - begcb(bounds%begc:bounds%endc), & - tcs_month_end_grc(bounds%begg:bounds%endg), & - c2l_scale_type= 'unity', l2g_scale_type='unity' ) - endif + ! Get current dates to determine if a new month started + call get_curr_date(year, month, day, sec); ! If multiple steps into a simulation and the last time step was the ! end of a month, save grid-level TCS based on 'endcb' from the last ! time step - if (get_nstep() > 1 .and. day_curr == 1 .and. sec_curr == 0) then + if (get_nstep() > 1 .and. day == 1 .and. sec == 0) then call c2g( bounds, & endcb(bounds%begc:bounds%endc), & tcs_month_end_grc(bounds%begg:bounds%endg), & c2l_scale_type= 'unity', l2g_scale_type='unity' ) + else + tcs_month_end_grc(bounds%begg:bounds%endg) = spval endif end associate