Skip to content

Commit

Permalink
Reset lake baselines in branch or continue run, too
Browse files Browse the repository at this point in the history
I went back and forth about whether we should do this, but I actually
feel that it's best if we do reset the lake baselines in a branch or
continue run, if using an older restart file. If we didn't do this, we'd
want to add some logic for writing out the issue-fixed metadata for any
further restart files written from these runs, to note that this issue
isn't actually fixed yet on these restart files.
  • Loading branch information
billsacks committed Sep 3, 2020
1 parent de3e12c commit acf0984
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 49 deletions.
19 changes: 1 addition & 18 deletions src/dyn_subgrid/dynConsBiogeophysMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ module dynConsBiogeophysMod
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_log_mod , only : errMsg => shr_log_errMsg
use decompMod , only : bounds_type
use spmdMod , only : masterproc
use clm_varctl , only : iulog
use UrbanParamsType , only : urbanparams_type
use EnergyFluxType , only : energyflux_type
use SoilHydrologyType , only : soilhydrology_type
Expand Down Expand Up @@ -69,7 +67,7 @@ module dynConsBiogeophysMod
subroutine dyn_hwcontent_set_baselines(bounds, num_icemecc, filter_icemecc, &
num_lakec, filter_lakec, &
urbanparams_inst, soilstate_inst, lakestate_inst, water_inst, temperature_inst, &
reset_all_baselines, reset_lake_baselines, print_resets)
reset_all_baselines, reset_lake_baselines)
!
! !DESCRIPTION:
! Set start-of-run baseline values for heat and water content in some columns.
Expand Down Expand Up @@ -125,9 +123,6 @@ subroutine dyn_hwcontent_set_baselines(bounds, num_icemecc, filter_icemecc, &
! for lakes on older initial conditions files.
logical, intent(in) :: reset_lake_baselines

! Whether to print information about the reset flags
logical, intent(in) :: print_resets

!
! !LOCAL VARIABLES:
integer :: i
Expand All @@ -136,18 +131,6 @@ subroutine dyn_hwcontent_set_baselines(bounds, num_icemecc, filter_icemecc, &
character(len=*), parameter :: subname = 'dyn_hwcontent_set_baselines'
!-----------------------------------------------------------------------

if (masterproc .and. print_resets) then
if (reset_all_baselines) then
write(iulog,*) ' '
write(iulog,*) 'Resetting dynbal baselines for all columns'
write(iulog,*) ' '
else if (reset_lake_baselines) then
write(iulog,*) ' '
write(iulog,*) 'Resetting dynbal baselines for lake columns'
write(iulog,*) ' '
end if
end if

! Note that we include inactive points in the following. This could be important if
! an inactive point later becomes active, so that we have an appropriate baseline
! value for that point.
Expand Down
71 changes: 40 additions & 31 deletions src/main/clm_initializeMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ subroutine initialize2( )
logical :: lexist
integer :: closelatidx,closelonidx
real(r8) :: closelat,closelon
logical :: reset_dynbal_baselines_all_columns
logical :: reset_dynbal_baselines_lake_columns
integer :: begp, endp
integer :: begc, endc
Expand Down Expand Up @@ -494,10 +495,7 @@ subroutine initialize2( )
urbanparams_inst, soilstate_inst, lakestate_inst, water_inst, temperature_inst, &
reset_all_baselines = .true., &
! reset_lake_baselines is irrelevant since reset_all_baselines is true
reset_lake_baselines = .false., &
! no need to print information about these resets for this initial resetting,
! which is always done
print_resets = .false.)
reset_lake_baselines = .false.)
end do

! ------------------------------------------------------------------------
Expand Down Expand Up @@ -582,12 +580,6 @@ subroutine initialize2( )
end if
call restFile_read(bounds_proc, fnamer, glc_behavior, &
reset_dynbal_baselines_lake_columns = reset_dynbal_baselines_lake_columns)
! But for a continue or branch run, it seems safest to NOT reset lake dynbal
! baselines. In nearly all cases, this will be irrelevant, because the restart
! file will have been a recent one, where reset_dynbal_baselines_lake_columns
! should be false already.
reset_dynbal_baselines_lake_columns = .false.

end if

! ------------------------------------------------------------------------
Expand Down Expand Up @@ -629,31 +621,48 @@ subroutine initialize2( )
! interpolated restart file, if applicable).
! ------------------------------------------------------------------------

if (nsrest == nsrStartup) then

!$OMP PARALLEL DO PRIVATE (nc, bounds_clump)
do nc = 1,nclumps
call get_clump_bounds(nc, bounds_clump)

call dyn_hwcontent_set_baselines(bounds_clump, &
filter_inactive_and_active(nc)%num_icemecc, &
filter_inactive_and_active(nc)%icemecc, &
filter_inactive_and_active(nc)%num_lakec, &
filter_inactive_and_active(nc)%lakec, &
urbanparams_inst, soilstate_inst, lakestate_inst, &
water_inst, temperature_inst, &
reset_all_baselines = get_reset_dynbal_baselines(), &
reset_lake_baselines = reset_dynbal_baselines_lake_columns, &
print_resets = .true.)
end do
else if (nsrest == nsrBranch) then
if (get_reset_dynbal_baselines()) then
reset_dynbal_baselines_all_columns = get_reset_dynbal_baselines()
if (nsrest == nsrBranch) then
if (reset_dynbal_baselines_all_columns) then
call endrun(msg='ERROR clm_initializeMod: '//&
'Cannot set reset_dynbal_baselines in a branch run')
end if
else if (nsrest == nsrContinue) then
! It's okay for the reset_dynbal_baselines flag to remain set in a continue
! run, but we'll ignore it. (This way, the user doesn't have to change their
! namelist file for the continue run.)
reset_dynbal_baselines_all_columns = .false.
end if
! Note that we will still honor reset_dynbal_baselines_lake_columns even in a branch
! or continue run: even in these runs, we want to reset those baselines if they are
! wrong on the restart file.

if (masterproc) then
if (reset_dynbal_baselines_all_columns) then
write(iulog,*) ' '
write(iulog,*) 'Resetting dynbal baselines for all columns'
write(iulog,*) ' '
else if (reset_dynbal_baselines_lake_columns) then
write(iulog,*) ' '
write(iulog,*) 'Resetting dynbal baselines for lake columns'
write(iulog,*) ' '
end if
end if
! nsrContinue not explicitly handled: it's okay for reset_dynbal_baselines to
! remain set in a continue run, but it has no effect

!$OMP PARALLEL DO PRIVATE (nc, bounds_clump)
do nc = 1,nclumps
call get_clump_bounds(nc, bounds_clump)

call dyn_hwcontent_set_baselines(bounds_clump, &
filter_inactive_and_active(nc)%num_icemecc, &
filter_inactive_and_active(nc)%icemecc, &
filter_inactive_and_active(nc)%num_lakec, &
filter_inactive_and_active(nc)%lakec, &
urbanparams_inst, soilstate_inst, lakestate_inst, &
water_inst, temperature_inst, &
reset_all_baselines = reset_dynbal_baselines_all_columns, &
reset_lake_baselines = reset_dynbal_baselines_lake_columns)
end do

! ------------------------------------------------------------------------
! Initialize nitrogen deposition
Expand Down

0 comments on commit acf0984

Please sign in to comment.