@@ -1193,37 +1193,28 @@ 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( &
12011200 begcb = > col_cs% begcb , & ! Input : [real(r8) (:) ] carbon mass begining of the time step
12021201 endcb = > col_cs% endcb , & ! Input : [real(r8) (:) ] carbon mass begining of the time step
1203- tcs_month_end_grc = > grc_cs% tcs_month_beg & ! Output: [real(r8) (:) ] grid-level carbon mass at the begining of a month
1202+ 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_prev_date(year_curr, month_curr, day_curr, sec_curr);
1208- call get_prev_date(year_prev, month_prev, day_prev, sec_prev)
1209-
1210- ! If at the beginning of a simulation, save grid-level TCS based on
1211- ! 'begcb' from the current time step
1212- if ( day_curr == 1 .and. sec_curr == 0 .and. get_nstep() <= 1 ) then
1213- call c2g( bounds, &
1214- begcb(bounds% begc:bounds% endc), &
1215- tcs_month_end_grc(bounds% begg:bounds% endg), &
1216- c2l_scale_type= ' unity' , l2g_scale_type= ' unity' )
1217- endif
1205+ ! Get current dates to determine if a new month started
1206+ call get_curr_date(year, month, day, sec);
12181207
12191208 ! If multiple steps into a simulation and the last time step was the
12201209 ! end of a month, save grid-level TCS based on 'endcb' from the last
12211210 ! time step
1222- if (get_nstep() > 1 .and. day_prev == 1 .and. sec_prev == 0 ) then
1211+ if (get_nstep() > 1 .and. day == 1 .and. sec == 0 ) then
12231212 call c2g( bounds, &
12241213 endcb(bounds% begc:bounds% endc), &
12251214 tcs_month_end_grc(bounds% begg:bounds% endg), &
12261215 c2l_scale_type= ' unity' , l2g_scale_type= ' unity' )
1216+ else
1217+ tcs_month_end_grc(bounds% begg:bounds% endg) = spval
12271218 endif
12281219
12291220 end associate
0 commit comments