diff --git a/components/clm/src/ED/main/FatesInterfaceMod.F90 b/components/clm/src/ED/main/FatesInterfaceMod.F90 index d5dd53135b..fb1a9a0e64 100644 --- a/components/clm/src/ED/main/FatesInterfaceMod.F90 +++ b/components/clm/src/ED/main/FatesInterfaceMod.F90 @@ -27,6 +27,7 @@ module FatesInterfaceMod use EDSurfaceRadiationMod , only : ED_SunShadeFracs use EDMainMod , only : ed_update_site use EDRestVectorMod , only : EDRest + use EDInitMod , only : zero_site, set_site_properties, init_patches type, public :: fates_interface_type @@ -46,10 +47,9 @@ module FatesInterfaceMod contains ! Procedures for initializing FATES threaded memory and communicators - procedure, public :: init procedure, public :: fates_clean - procedure, public :: site_init - procedure, public :: fates_restart + procedure, public :: init_coldstart +! procedure, public :: init_restart procedure, public :: canopy_sunshade_fracs end type fates_interface_type @@ -132,17 +132,18 @@ end subroutine init_coldstart ! ------------------------------------------------------------------------------------ - subroutine init_restart(this, bounds_clump, ncid, flag, fcolumn ) - - implicit none - class(fates_interface_type), intent(inout) :: this - type(bounds_type),intent(in) :: bounds_clump - type(file_desc_t) , intent(inout) :: ncid ! netcdf id - character(len=*) , intent(in) :: flag !'read' or 'write' - - call EDRest( bounds_clump, this%sites, this%nsites, fcolumn, ncid, flag ) - return - end subroutine init_restart +! subroutine init_restart(this, bounds_clump, ncid, flag, fcolumn ) +! +! implicit none +! class(fates_interface_type), intent(inout) :: this +! type(bounds_type),intent(in) :: bounds_clump +! type(file_desc_t) , intent(inout) :: ncid ! netcdf id +! integer , intent(in) :: fcolumn(this%nsites) +! character(len=*) , intent(in) :: flag !'read' or 'write' +! +! call EDRest( bounds_clump, this%sites, this%nsites, fcolumn, ncid, flag ) +! return +! end subroutine init_restart ! ------------------------------------------------------------------------------------ diff --git a/components/clm/src/main/clm_driver.F90 b/components/clm/src/main/clm_driver.F90 index d28f76089c..f968d9643e 100644 --- a/components/clm/src/main/clm_driver.F90 +++ b/components/clm/src/main/clm_driver.F90 @@ -475,8 +475,11 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) if (use_ed) then ! if ED enabled, summarize productivity fluxes onto CLM history file structure call t_startf('edclmsumprodfluxes') + ! INTERF-TODO: THIS NEEDS A WRAPPER call clm_fates%sumprod(bounds_clump) call clm_fates%fates2hlm%SummarizeProductivityFluxes( bounds_clump, & - clm_fates%fates(nc)%sites,clm_fates%fates(nc)%nsites ) + clm_fates%fates(nc)%sites, & + clm_fates%fates(nc)%nsites, & + clm_fates%f2hmap(nc)%fcolumn) call t_stopf('edclmsumprodfluxes') endif diff --git a/components/clm/src/main/clm_initializeMod.F90 b/components/clm/src/main/clm_initializeMod.F90 index 5c4e2b8e7c..7a2274e3ab 100644 --- a/components/clm/src/main/clm_initializeMod.F90 +++ b/components/clm/src/main/clm_initializeMod.F90 @@ -691,8 +691,16 @@ subroutine initialize2( ) ! INTERF-TODO: THIS CALL SHOULD NOT CALL FATES(NC) DIRECTLY ! BUT IT SHOULD PASS bounds_clump TO A CLM_FATES WRAPPER ! WHICH WILL IN TURN PASS A FATES API DEFINED BOUNDS TO SITE_INIT - call clm_fates%fates(nc)%site_init(bounds_clump) - call clm_fates%fates2hlm_link(bounds_clump,nc,waterstate_inst,canopystate_inst) + ! IE CREATE clm_fates%init_coldstart() + call clm_fates%fates(nc)%init_coldstart(clm_fates%f2hmap(nc)%fcolumn ) + + call clm_fates%fates2hlm%ed_clm_link( bounds_clump, & + clm_fates%fates(nc)%sites, & + clm_fates%fates(nc)%nsites, & + clm_fates%f2hmap(nc)%fcolumn, & + waterstate_inst, & + canopystate_inst) + end do !$OMP END PARALLEL DO diff --git a/components/clm/src/main/clm_instMod.F90 b/components/clm/src/main/clm_instMod.F90 index 0d4db35e69..ed22ed6117 100644 --- a/components/clm/src/main/clm_instMod.F90 +++ b/components/clm/src/main/clm_instMod.F90 @@ -571,7 +571,7 @@ subroutine clm_instRest(bounds, ncid, flag) ! Bounds are not passed to FATES init_restart because ! we call a loop on clumps within this subroutine anyway - call clmfates%init_restart(ncid,flag) + call clm_fates%init_restart(ncid,flag, waterstate_inst, canopystate_inst) end if diff --git a/components/clm/src/utils/clmfates_interfaceMod.F90 b/components/clm/src/utils/clmfates_interfaceMod.F90 index 48861110f9..9809eb2246 100644 --- a/components/clm/src/utils/clmfates_interfaceMod.F90 +++ b/components/clm/src/utils/clmfates_interfaceMod.F90 @@ -62,6 +62,7 @@ module CLMFatesInterfaceMod use EDMainMod , only : ed_update_site use EDPftVarcon , only : EDpftvarcon_inst use EDEcophysConType , only : EDecophysconInit + use EDRestVectorMod , only : EDRest implicit none type, private :: f2hmap_type @@ -120,7 +121,7 @@ module CLMFatesInterfaceMod contains procedure, public :: init - procedure, public :: fates2hlm_link + procedure, public :: init_restart procedure, public :: dynamics_driv end type hlm_fates_interface_type @@ -160,8 +161,10 @@ subroutine init(this,bounds_proc, use_ed) integer :: nc ! thread index integer :: s ! FATES site index integer :: c ! HLM column index + integer :: l ! HLM LU index integer, allocatable :: collist (:) type(bounds_type) :: bounds_clump + integer :: nmaxcol if (use_ed) then @@ -187,10 +190,10 @@ subroutine init(this,bounds_proc, use_ed) allocate(collist(1:nmaxcol)) ! Allocate the mapping that points columns to FATES sites, 0 is NA - allocate(self%f2hmap(nc)%hsites(bounds_clump%begc:bounds_clump%endc)) + allocate(this%f2hmap(nc)%hsites(bounds_clump%begc:bounds_clump%endc)) ! Initialize all columns with a zero index, which indicates no FATES site - self%f2hmap(nc)%hsites(:) = 0 + this%f2hmap(nc)%hsites(:) = 0 s = 0 do c = bounds_clump%begc,bounds_clump%endc @@ -201,16 +204,16 @@ subroutine init(this,bounds_proc, use_ed) if (col%active(c) .and. lun%itype(l) == istsoil ) then s = s + 1 collist(s) = c - self%f2hmap(nc)%hsites(c) = s + this%f2hmap(nc)%hsites(c) = s endif enddo ! Allocate vectors that match FATES sites with HLM columns - allocate(self%f2hmap(nc)%fcolumn(s)) + allocate(this%f2hmap(nc)%fcolumn(s)) ! Assign the h2hmap indexing - self%f2hmap(nc)%fcolumn(1:s) = collist(1:s) + this%f2hmap(nc)%fcolumn(1:s) = collist(1:s) ! Deallocate the temporary arrays deallocate(collist) @@ -252,7 +255,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! !LOCAL VARIABLES: real(r8) :: dayDiff ! day of run integer :: dayDiffInt ! integer of day of run - integer :: g ! gridcell + integer :: s ! site integer :: yr ! year (0, ...) integer :: mon ! month (1, ..., 12) integer :: day ! day of month (1, ..., 31) @@ -312,9 +315,11 @@ subroutine dynamics_driv(this, nc, bounds_clump, & enddo ! link to CLM/ALM structures - call this%fates2hlm%ed_clm_link( bounds_clump, & - this%fates(nc)%sites, & - waterstate_inst, & + call this%fates2hlm%ed_clm_link( bounds_clump, & + this%fates(nc)%sites, & + this%fates(nc)%nsites, & + this%f2hmap(nc)%fcolumn, & + waterstate_inst, & canopystate_inst) @@ -338,8 +343,8 @@ subroutine init_restart(this, ncid, flag, waterstate_inst, canopystate_inst ) class(hlm_fates_interface_type), intent(inout) :: this type(file_desc_t) , intent(inout) :: ncid ! netcdf id character(len=*) , intent(in) :: flag !'read' or 'write' - type(waterstate_type) , intent(in) :: waterstate_inst - type(canopystate_type) , intent(in) :: canopystate_inst + type(waterstate_type) , intent(inout) :: waterstate_inst + type(canopystate_type) , intent(inout) :: canopystate_inst ! Locals type(bounds_type) :: bounds_clump @@ -350,13 +355,17 @@ subroutine init_restart(this, ncid, flag, waterstate_inst, canopystate_inst ) do nc = 1, nclumps call get_clump_bounds(nc, bounds_clump) - call EDRest( bounds_clump, this%fates(nc)%sites, this%fates(nc)%nsites, & - this%f2hmap(nc)%fcolumn, ncid, flag ) + call EDRest( bounds_clump, & + this%fates(nc)%sites, & + this%fates(nc)%nsites, & + this%f2hmap(nc)%fcolumn, ncid, flag ) if ( trim(flag) == 'read' ) then call this%fates2hlm%ed_clm_link( bounds_clump, & this%fates(nc)%sites, & + this%fates(nc)%nsites, & + this%f2hmap(nc)%fcolumn, & waterstate_inst, & canopystate_inst) @@ -364,7 +373,7 @@ subroutine init_restart(this, ncid, flag, waterstate_inst, canopystate_inst ) end if end do - call clm_fates%fates2hlm%restart(bounds, ncid, flag) + call this%fates2hlm%restart(bounds_clump, ncid, flag) return end subroutine init_restart