Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fates history flushing #2594

Merged
merged 14 commits into from
Sep 5, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ hist_fincl1 = 'FATES_TLONGTERM',
'FATES_MORTALITY_CROWNSCORCH_SZPF','FATES_MORTALITY_CAMBIALBURN_SZPF','FATES_MORTALITY_TERMINATION_SZPF',
'FATES_MORTALITY_LOGGING_SZPF','FATES_MORTALITY_FREEZING_SZPF','FATES_MORTALITY_SENESCENCE_SZPF',
'FATES_MORTALITY_AGESCEN_SZPF','FATES_MORTALITY_AGESCEN_ACPF','FATES_MORTALITY_CANOPY_SZPF',
'FATES_M3_MORTALITY_CANOPY_SZPF','FATES_M3_MORTALITY_USTORY_SZPF','FATES_C13DISC_SZPF',
'FATES_M3_MORTALITY_CANOPY_SZPF','FATES_M3_MORTALITY_USTORY_SZPF',
'FATES_STOREC_CANOPY_SZPF','FATES_LEAFC_CANOPY_SZPF','FATES_LAI_CANOPY_SZPF','FATES_CROWNAREA_CANOPY_SZPF',
'FATES_CROWNAREA_USTORY_SZPF','FATES_NPLANT_CANOPY_SZPF','FATES_MORTALITY_USTORY_SZPF','FATES_STOREC_USTORY_SZPF',
'FATES_LEAFC_USTORY_SZPF','FATES_LAI_USTORY_SZPF','FATES_NPLANT_USTORY_SZPF','FATES_CWD_ABOVEGROUND_DC',
Expand Down
58 changes: 16 additions & 42 deletions src/utils/clmfates_interfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ module CLMFatesInterfaceMod
use FatesParametersInterface, only : fates_parameters_type

use FatesInterfaceMod , only : DetermineGridCellNeighbors
use FatesIOVariableKindMod, only : group_dyna_simple, group_dyna_complx
use FatesHistoryInterfaceMod, only : fates_hist
use FatesRestartInterfaceMod, only : fates_restart_interface_type

Expand Down Expand Up @@ -1192,14 +1191,6 @@ subroutine dynamics_driv(this, nc, bounds_clump, &
call this%WrapUpdateFatesSeedInOut(bounds_clump)
end if

! ---------------------------------------------------------------------------------
! Flush arrays to values defined by %flushval (see registry entry in
! subroutine define_history_vars()
! ---------------------------------------------------------------------------------
call fates_hist%flush_hvars(nc,upfreq_in=group_dyna_simple)

call fates_hist%flush_hvars(nc,upfreq_in=group_dyna_complx)

! ---------------------------------------------------------------------------------
! Part II: Call the FATES model now that input boundary conditions have been
! provided.
Expand Down Expand Up @@ -1970,23 +1961,16 @@ subroutine restart( this, bounds_proc, ncid, flag, waterdiagnosticbulk_inst, &
this%fates(nc)%sites, &
this%fates(nc)%bc_out)


! ------------------------------------------------------------------------
! Update history IO fields that depend on ecosystem dynamics
! Flush FATES history variables.
! The flushing process sets all columns outside of FATES perview to
! the ignore value. This only needs to be done once, because FATES will
! not overwright values outside the columns that it is in charge of.
! ------------------------------------------------------------------------
if(fates_history_dimlevel(2)>0) then
call fates_hist%flush_hvars(nc,upfreq_in=group_dyna_simple)
do s = 1,this%fates(nc)%nsites
call fates_hist%zero_site_hvars(this%fates(nc)%sites(s), &
upfreq_in=group_dyna_simple)
end do
if(fates_history_dimlevel(2)>1) then
call fates_hist%flush_hvars(nc,upfreq_in=group_dyna_complx)
do s = 1,this%fates(nc)%nsites
call fates_hist%zero_site_hvars(this%fates(nc)%sites(s), &
upfreq_in=group_dyna_complx)
end do
end if
end if

call fates_hist%flush_all_hvars(nc)

call fates_hist%update_history_dyn( nc, &
this%fates(nc)%nsites, &
this%fates(nc)%sites, &
Expand Down Expand Up @@ -2164,22 +2148,15 @@ subroutine init_coldstart(this, waterstatebulk_inst, waterdiagnosticbulk_inst, &
soilbiogeochem_carbonflux_inst, .false.)

! ------------------------------------------------------------------------
! Update history IO fields that depend on ecosystem dynamics
! Flush and zero FATES history variables.
! The flushing process sets all columns outside of FATES perview to
! the ignore value. This only needs to be done once, because FATES will
! not overwright values outside the columns that it is in charge of.
! We also start off by setting all values on FATES columns to zero.
! ------------------------------------------------------------------------
if(fates_history_dimlevel(2)>0) then
call fates_hist%flush_hvars(nc,upfreq_in=group_dyna_simple)
do s = 1,this%fates(nc)%nsites
call fates_hist%zero_site_hvars(this%fates(nc)%sites(s), &
upfreq_in=group_dyna_simple)
end do
if(fates_history_dimlevel(2)>1) then
call fates_hist%flush_hvars(nc,upfreq_in=group_dyna_complx)
do s = 1,this%fates(nc)%nsites
call fates_hist%zero_site_hvars(this%fates(nc)%sites(s), &
upfreq_in=group_dyna_complx)
end do
end if
end if

call fates_hist%flush_all_hvars(nc)

call fates_hist%update_history_dyn( nc, &
this%fates(nc)%nsites, &
this%fates(nc)%sites, &
Expand Down Expand Up @@ -3570,9 +3547,6 @@ subroutine wrap_hydraulics_drive(this, bounds_clump, nc, &
this%fates(nc)%bc_out(s)%plant_stored_h2o_si
end do


! Update History Buffers that need to be updated after hydraulics calls

call fates_hist%update_history_hydraulics(nc, &
this%fates(nc)%nsites, &
this%fates(nc)%sites, &
Expand Down
Loading