Skip to content

Commit dc495fb

Browse files
committed
Makes C-budget SetEndingMonthlyStates consistent
The subroutines for water and carbon are made consistent.
1 parent 92a1a98 commit dc495fb

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

components/elm/src/biogeochem/CNPBudgetMod.F90

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,8 +1193,7 @@ subroutine CBudget_SetEndingMonthlyStates(bounds, col_cs, grc_cs)
11931193
type(gridcell_carbon_state), intent(inout) :: grc_cs
11941194
!
11951195
! !LOCAL VARIABLES:
1196-
integer :: year_prev, month_prev, day_prev, sec_prev
1197-
integer :: year_curr, month_curr, day_curr, sec_curr
1196+
integer :: year, month, day, sec
11981197
!-----------------------------------------------------------------------
11991198

12001199
associate( &
@@ -1203,26 +1202,19 @@ subroutine CBudget_SetEndingMonthlyStates(bounds, col_cs, grc_cs)
12031202
tcs_month_end_grc => grc_cs%tcs_month_end & ! Output: [real(r8) (:) ] grid-level carbon mass at the ending of a month
12041203
)
12051204

1206-
! Get current and previous dates to determine if a new month started
1207-
call get_curr_date(year_curr, month_curr, day_curr, sec_curr);
1208-
1209-
! If at the beginning of a simulation, save grid-level TCS based on
1210-
! 'begcb' from the current time step
1211-
if ( day_curr == 1 .and. sec_curr == 0 .and. get_nstep() <= 1 ) then
1212-
call c2g( bounds, &
1213-
begcb(bounds%begc:bounds%endc), &
1214-
tcs_month_end_grc(bounds%begg:bounds%endg), &
1215-
c2l_scale_type= 'unity', l2g_scale_type='unity' )
1216-
endif
1205+
! Get current dates to determine if a new month started
1206+
call get_curr_date(year, month, day, sec);
12171207

12181208
! If multiple steps into a simulation and the last time step was the
12191209
! end of a month, save grid-level TCS based on 'endcb' from the last
12201210
! time step
1221-
if (get_nstep() > 1 .and. day_curr == 1 .and. sec_curr == 0) then
1211+
if (get_nstep() > 1 .and. day == 1 .and. sec == 0) then
12221212
call c2g( bounds, &
12231213
endcb(bounds%begc:bounds%endc), &
12241214
tcs_month_end_grc(bounds%begg:bounds%endg), &
12251215
c2l_scale_type= 'unity', l2g_scale_type='unity' )
1216+
else
1217+
tcs_month_end_grc(bounds%begg:bounds%endg) = spval
12261218
endif
12271219

12281220
end associate

0 commit comments

Comments
 (0)