Skip to content

Commit a64e71b

Browse files
authored
Merge branch 'bishtgautam/lnd/tcs-fix' (PR #6273)
The TCS_MONTH_BEGIN and TCS_MONTH_END variables are written and read from the ELM restart file. [non-BFB] just for those variables. No change in answers otherwise.
2 parents d6e9af3 + dc495fb commit a64e71b

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

components/elm/src/biogeochem/CNPBudgetMod.F90

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

components/elm/src/data_types/GridcellDataType.F90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ subroutine grc_cs_restart(this, bounds, ncid, flag)
647647
long_name='total carbon storage at the beginning of a month', units='gC/m^2', &
648648
interpinic_flag='interp', readvar=readvar, data=this%tcs_month_beg)
649649

650+
call restartvar(ncid=ncid, flag=flag, varname='TCS_MONTH_END', xtype=ncd_double, &
651+
dim1name='gridcell', &
652+
long_name='total carbon storage at the end of a month', units='gC/m^2', &
653+
interpinic_flag='interp', readvar=readvar, data=this%tcs_month_end)
650654
end subroutine grc_cs_restart
651655

652656
!------------------------------------------------------------------------

components/elm/src/main/restFileMod.F90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ subroutine restFile_write( bounds, file, &
404404
call veg_ps%Restart(bounds, ncid, flag='write')
405405
call veg_pf%Restart(bounds, ncid, flag='write')
406406
call crop_vars%Restart(bounds, ncid, flag='write')
407+
408+
call grc_cs%Restart(bounds, ncid, flag='write')
407409
end if
408410

409411

@@ -627,6 +629,8 @@ subroutine restFile_read( bounds, file, &
627629
call veg_ps%Restart(bounds, ncid, flag='read')
628630
call veg_pf%Restart(bounds, ncid, flag='read')
629631
call crop_vars%Restart(bounds, ncid, flag='read')
632+
633+
call grc_cs%Restart(bounds, ncid, flag='read')
630634
end if
631635

632636
if (use_fates) then

0 commit comments

Comments
 (0)