Skip to content

Commit

Permalink
Bugfix: clm history files always instantaneous with ED on
Browse files Browse the repository at this point in the history
Bugfix for incorrect ED history files. Changeset eb26be6 incorrectly
moved the history buffer updates inside an if (use_ed
.and. is_day_boundry) block. This caused all clm history variables to
only be written at the day boundary, giving the appearence of
instantaneous output. Discussin with clm SE group and Rosie proposed
removing the if block around the hist buff update and moving the call
to ed_driver earlier in the call sequence.

Fixes: #24

User interface changes?: Yes history output changes

Code review: self, clm SE discussion, needs further science review

Test suite: ed, yellowstone - intel, gnu, pgi
Test baseline: d8a9ee5
Test namelist changes: none
Test answer changes: yes, history output bug fix. order of operations
                     change (call to ed driver moved)?
Test summary: answer changing, baseline failures, expecetd failures
 in f09 and f10 restarts.
  • Loading branch information
bandre-ucar committed Mar 23, 2016
1 parent d8a9ee5 commit 45cf097
Showing 1 changed file with 21 additions and 58 deletions.
79 changes: 21 additions & 58 deletions components/clm/src/main/clm_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate)

if (use_ed) then
call ed_clm_inst%SetValues( bounds_clump, 0._r8 )
end if
end if

! Dry Deposition of chemical tracers (Wesely (1998) parameterizaion)

Expand Down Expand Up @@ -791,6 +791,23 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate)

end if

if ( use_ed .and. is_beg_curr_day() ) then ! run ED at the start of each day

if ( masterproc ) then
write(iulog,*) 'clm: calling ED model ', get_nstep()
end if

call ed_driver( bounds_clump, &
ed_allsites_inst(bounds_clump%begg:bounds_clump%endg), &
ed_clm_inst, ed_phenology_inst, &
atm2lnd_inst, soilstate_inst, temperature_inst, &
waterstate_inst, canopystate_inst)

call setFilters( bounds_clump, glc2lnd_inst%icemask_grc )

end if ! use_ed branch


! ============================================================================
! Check the energy and water balance and also carbon and nitrogen balance
! ============================================================================
Expand Down Expand Up @@ -960,17 +977,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate)
! ============================================================================


!
! TODO(SPM,012715) - XIX Note to CSEG. I had to put this logical block around
! this call as it was updating the history buffer prematurely when ED was
! running and happened to be restarted on the same timestep as a history
! write
!
if (.not. use_ed) then
call t_startf('hbuf')
call hist_update_hbuf(bounds_proc)
call t_stopf('hbuf')
end if
call t_startf('hbuf')
call hist_update_hbuf(bounds_proc)
call t_stopf('hbuf')

! ============================================================================
! Call dv (dynamic vegetation) at last time step of year
Expand Down Expand Up @@ -1011,52 +1020,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate)
! Call ED model on daily timestep
! ============================================================================

if ( use_ed .and. is_beg_curr_day() ) then ! run ED at the start of each day

if ( masterproc ) then
write(iulog,*) 'clm: calling ED model ', get_nstep()
end if

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

call get_clump_bounds(nc, bounds_clump)

call ed_driver( bounds_clump, &
ed_allsites_inst(bounds_clump%begg:bounds_clump%endg), &
ed_clm_inst, ed_phenology_inst, &
atm2lnd_inst, soilstate_inst, temperature_inst, &
waterstate_inst, canopystate_inst)

!
! TODO(SPM, 012715) - see note XIX above regarding hbuf updates
!
call t_startf('hbuf')
call hist_update_hbuf(bounds_proc)
call t_stopf('hbuf')

call setFilters( bounds_clump, glc2lnd_inst%icemask_grc )

!reset surface albedo fluxes in case there is a mismatch between elai and canopy absorbtion.
call SurfaceAlbedo(bounds_clump, &
filter_inactive_and_active(nc)%num_nourbanc, &
filter_inactive_and_active(nc)%nourbanc, &
filter_inactive_and_active(nc)%num_nourbanp, &
filter_inactive_and_active(nc)%nourbanp, &
filter_inactive_and_active(nc)%num_urbanc, &
filter_inactive_and_active(nc)%urbanc, &
filter_inactive_and_active(nc)%num_urbanp, &
filter_inactive_and_active(nc)%urbanp, &
nextsw_cday, declinp1, &
ed_allsites_inst(bounds_clump%begg:bounds_clump%endg), &
aerosol_inst, canopystate_inst, waterstate_inst, &
lakestate_inst, temperature_inst, surfalb_inst)

end do
!$OMP END PARALLEL DO

end if ! use_ed branch

! ============================================================================
! History/Restart output
! ============================================================================
Expand Down

0 comments on commit 45cf097

Please sign in to comment.