diff --git a/components/clm/src/ED/main/FatesInterfaceMod.F90 b/components/clm/src/ED/main/FatesInterfaceMod.F90 index 26302b19f9..a55585613e 100644 --- a/components/clm/src/ED/main/FatesInterfaceMod.F90 +++ b/components/clm/src/ED/main/FatesInterfaceMod.F90 @@ -42,7 +42,7 @@ module FatesInterfaceMod contains ! Procedures for initializing FATES threaded memory and communicators - procedure, public :: fates_init + procedure, public :: init procedure, public :: fates_clean procedure, public :: site_init procedure, public :: fates_restart @@ -52,7 +52,7 @@ module FatesInterfaceMod contains - subroutine fates_init(this,bounds_clump) + subroutine init(this,bounds_clump) implicit none @@ -70,7 +70,7 @@ subroutine fates_init(this,bounds_clump) allocate (this%sites(bounds_clump%begg:bounds_clump%endg)) return - end subroutine fates_init + end subroutine init ! ------------------------------------------------------------------------------------ diff --git a/components/clm/src/main/clm_driver.F90 b/components/clm/src/main/clm_driver.F90 index db2ec1e75b..16390ac18d 100644 --- a/components/clm/src/main/clm_driver.F90 +++ b/components/clm/src/main/clm_driver.F90 @@ -473,7 +473,7 @@ 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') - call clm_fates%fates2hlm_inst%SummarizeProductivityFluxes( bounds_clump, & + call clm_fates%fates2hlm%SummarizeProductivityFluxes( bounds_clump, & clm_fates%fates(nc)%sites(bounds_clump%begg:bounds_clump%endg)) call t_stopf('edclmsumprodfluxes') endif @@ -710,7 +710,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) c13_cnveg_carbonflux_inst, c13_cnveg_carbonstate_inst, & c14_cnveg_carbonflux_inst, c14_cnveg_carbonstate_inst, & cnveg_nitrogenflux_inst, cnveg_nitrogenstate_inst, & - clm_fates%fates2hlm_inst, & + clm_fates%fates2hlm, & soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst, & c13_soilbiogeochem_carbonflux_inst, c13_soilbiogeochem_carbonstate_inst, & c14_soilbiogeochem_carbonflux_inst, c14_soilbiogeochem_carbonstate_inst, & @@ -738,7 +738,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) ! Zero some of the FATES->CLM communicators if (use_ed) then - call clm_fates%fates2hlm_inst%SetValues(bounds_clump,0._r8) + call clm_fates%fates2hlm%SetValues(bounds_clump,0._r8) end if ! Dry Deposition of chemical tracers (Wesely (1998) parameterizaion) @@ -854,7 +854,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) filter(nc)%num_pcropp, filter(nc)%pcropp, doalb, & cnveg_state_inst, & cnveg_carbonflux_inst, cnveg_carbonstate_inst, & - clm_fates%fates2hlm_inst, & + clm_fates%fates2hlm, & soilbiogeochem_carbonflux_inst, soilbiogeochem_carbonstate_inst, & soilbiogeochem_state_inst, & soilbiogeochem_nitrogenflux_inst, soilbiogeochem_nitrogenstate_inst, & @@ -871,7 +871,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate) c13_soilbiogeochem_carbonflux_inst, c13_soilbiogeochem_carbonstate_inst, & c14_soilbiogeochem_carbonflux_inst, c14_soilbiogeochem_carbonstate_inst, & soilbiogeochem_nitrogenflux_inst, soilbiogeochem_nitrogenstate_inst, & - clm_fates%fates2hlm_inst, & + clm_fates%fates2hlm, & clm_fates%fates(nc)%sites(bounds_clump%begg:bounds_clump%endg)) end if diff --git a/components/clm/src/main/clm_instMod.F90 b/components/clm/src/main/clm_instMod.F90 index 844080ab01..c6e899be12 100644 --- a/components/clm/src/main/clm_instMod.F90 +++ b/components/clm/src/main/clm_instMod.F90 @@ -23,7 +23,6 @@ module clm_instMod use UrbanParamsType , only : IsSimpleBuildTemp, IsProgBuildTemp use SoilBiogeochemDecompCascadeConType , only : decomp_cascade_con use CNDVType , only : dgv_ecophyscon ! Constants - use EDEcophysConType , only : EDecophyscon ! ED Constants !----------------------------------------- ! Definition of component types @@ -168,12 +167,11 @@ subroutine clm_instInit(bounds) use SoilBiogeochemDecompCascadeBGCMod , only : init_decompcascade_bgc use SoilBiogeochemDecompCascadeCNMod , only : init_decompcascade_cn use SoilBiogeochemDecompCascadeContype , only : init_decomp_cascade_constants - use EDEcophysConType , only : EDecophysconInit - use EDPftVarcon , only : EDpftvarcon_inst + use initVerticalMod , only : initVertical use accumulMod , only : print_accum_fields use SoilWaterRetentionCurveFactoryMod , only : create_soil_water_retention_curve - use decompMod , only : get_proc_bounds, get_proc_clumps, get_clump_bounds + use decompMod , only : get_proc_bounds ! ! !ARGUMENTS type(bounds_type), intent(in) :: bounds ! processor bounds @@ -429,27 +427,7 @@ subroutine clm_instInit(bounds) ! NOTE (RGK, 04-25-2016) : Updating names, ED is now part of FATES ! Incrementally changing to ED names to FATES - ! INTERF-TODO: we should not be allocating thread and sites when ed - ! is not on, but until canopyfluxes and surfaceabledo are teased apart, the - ! allocation needs to happen so that it can be passed as an argument (RGK) - - nclumps = get_proc_clumps() - allocate(clm_fates%fates(nclumps)) - do nc = 1,nclumps - call get_clump_bounds(nc, bounds_clump) - ! 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 FATES_INIT - call clm_fates%fates(nc)%fates_init(bounds_clump) - end do - - if( use_ed )then - call clm_fates%Init(bounds) - - ! INTERF-TODO: AT SOME POINT WE MAY HAVE FATES DOING ITS OWN PARAMETER - ! READS, AND THIS CALL WILL BE EMBEDDED IN THE FATES SIDE OF INTERFACE - call EDecophysconInit( EDpftvarcon_inst, numpft ) - end if + call clm_fates%Init(bounds,use_ed) deallocate (h2osno_col) @@ -618,7 +596,7 @@ subroutine clm_instRest(bounds, ncid, flag) end if end do - call clm_fates%fates2hlm_inst%restart(bounds, ncid, flag) + call clm_fates%fates2hlm%restart(bounds, ncid, flag) end if diff --git a/components/clm/src/utils/clmfates_interfaceMod.F90 b/components/clm/src/utils/clmfates_interfaceMod.F90 index 16c41c5bb4..9c41bac3cb 100644 --- a/components/clm/src/utils/clmfates_interfaceMod.F90 +++ b/components/clm/src/utils/clmfates_interfaceMod.F90 @@ -40,6 +40,7 @@ module CLMFatesInterfaceMod use TemperatureType , only : temperature_type use SoilStateType , only : soilstate_type use clm_varctl , only : iulog + use clm_varpar , only : numpft use atm2lndType , only : atm2lnd_type use SurfaceAlbedoType , only : surfalb_type use SolarAbsorbedType , only : solarabs_type @@ -48,6 +49,7 @@ module CLMFatesInterfaceMod use clm_time_manager , only : get_days_per_year, get_curr_date use clm_time_manager , only : get_ref_date, timemgr_datediff use spmdMod , only : masterproc + use decompMod , only : get_proc_bounds, get_proc_clumps, get_clump_bounds ! Used FATES Modules use FatesInterfaceMod , only : fates_interface_type @@ -56,7 +58,8 @@ module CLMFatesInterfaceMod use EDTypesMod , only : udata use EDMainMod , only : ed_ecosystem_dynamics use EDMainMod , only : ed_update_site - + use EDPftVarcon , only : EDpftvarcon_inst + use EDEcophysConType , only : EDecophysconInit implicit none type, public :: hlm_fates_interface_type @@ -71,11 +74,11 @@ module CLMFatesInterfaceMod type(fates_interface_type), allocatable :: fates (:) - ! fates2hlm_inst (previously called "clm_ed_inst") contains types and variables + ! fates2hlm (previously called "clm_ed_inst") contains types and variables ! that are passed back to the driving land model, ie fates-to-hlm. ! usefull to a calling model. In this case HLM means "Hosting Land Model" ! prev: type(ed_clm_type)::ed_clm_inst - type(ed_clm_type) :: fates2hlm_inst + type(ed_clm_type) :: fates2hlm ! These are phenology relevant variables (strange how phenology gets @@ -105,7 +108,7 @@ module CLMFatesInterfaceMod contains - subroutine init(this,bounds_proc) + subroutine init(this,bounds_proc, use_ed) ! --------------------------------------------------------------------------------- ! This initializes the dlm_fates_interface_type @@ -128,24 +131,48 @@ subroutine init(this,bounds_proc) ! Input Arguments class(hlm_fates_interface_type), intent(inout) :: this type(bounds_type),intent(in) :: bounds_proc - - - ! Initialize the FATES communicators with the HLM - ! This involves to stages - ! 1) allocate the vectors hlm_inst - ! 2) add the history variables defined in clm_inst to the history machinery - call this%fates2hlm_inst%Init(bounds_proc) - - ! Initialize ED phenology variables - ! This also involves two stages - ! 1) allocate the vectors in phen_inst - ! 2) add the phenology history variables to the history machinery - call this%phen_inst%Init(bounds_proc) - - ! --------------------------------------------------------------------------------- - ! Initialization of the state-threads is handled by the calling subroutine - ! clm_instInit - ! --------------------------------------------------------------------------------- + logical,intent(in) :: use_ed ! NEEDS TO BE PASSED (FOR NOW) + ! BC THE FATES SITE VECTORS + ! NEED TO BE GENERATED + ! FOR NON-ED AS WELL. SO + ! ONLY PART OF THIS MAY BE OPERATIVE + ! local variables + integer :: nclumps ! Number of threads + integer :: nc ! thread index + type(bounds_type) :: bounds_clump + + if (use_ed) then + + ! Initialize the FATES communicators with the HLM + ! This involves to stages + ! 1) allocate the vectors + ! 2) add the history variables defined in clm_inst to the history machinery + call this%fates2hlm%Init(bounds_proc) + + ! Initialize ED phenology variables + ! This also involves two stages + ! 1) allocate the vectors in phen_inst + ! 2) add the phenology history variables to the history machinery + call this%phen_inst%Init(bounds_proc) + + + call EDecophysconInit( EDpftvarcon_inst, numpft ) + + end if + + + nclumps = get_proc_clumps() + allocate(this%fates(nclumps)) + + do nc = 1,nclumps + call get_clump_bounds(nc, bounds_clump) + ! INTERF-TODO: BOUNDS CLUMP SHOULD NOT BE PASSED TO THE FATES PUBLIC + ! WILL REQUIRE MAPPING PRIOR TO THIS STEP AND EITHER A FATES-BOUNDS + ! OR NATIVE TYPE SHOULD BE PASSED, ALL THAT HAPPENS IN THIS CALL IS ALLOCATION + ! OF SITES() + call this%fates(nc)%init(bounds_clump) + end do + end subroutine init @@ -163,7 +190,7 @@ subroutine fates2hlm_link(this, bounds_clump, nc, waterstate_inst, canopystate_i type(canopystate_type) , intent(inout) :: canopystate_inst integer, intent(in) :: nc - call this%fates2hlm_inst%ed_clm_link( bounds_clump, & + call this%fates2hlm%ed_clm_link( bounds_clump, & this%fates(nc)%sites(bounds_clump%begg:bounds_clump%endg), & this%phen_inst, & waterstate_inst, & @@ -219,7 +246,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! --------------------------------------------------------------------------------- - call this%fates2hlm_inst%SetValues( bounds_clump, 0._r8 ) + call this%fates2hlm%SetValues( bounds_clump, 0._r8 ) ! timing statements. udata%n_sub = get_days_per_year() @@ -246,9 +273,9 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! where most things happen do g = bounds_clump%begg,bounds_clump%endg if (this%fates(nc)%sites(g)%istheresoil) then - call ed_ecosystem_dynamics(this%fates(nc)%sites(g), & - this%fates2hlm_inst, & - this%phen_inst, atm2lnd_inst, & + call ed_ecosystem_dynamics(this%fates(nc)%sites(g), & + this%fates2hlm, & + this%phen_inst, atm2lnd_inst, & soilstate_inst, temperature_inst, waterstate_inst) call ed_update_site(this%fates(nc)%sites(g)) @@ -256,7 +283,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & enddo ! link to CLM/ALM structures - call this%fates2hlm_inst%ed_clm_link( bounds_clump, & + call this%fates2hlm%ed_clm_link( bounds_clump, & this%fates(nc)%sites(bounds_clump%begg:bounds_clump%endg), & this%phen_inst, & waterstate_inst, & @@ -274,7 +301,7 @@ end subroutine dynamics_driv ! ------------------------------------------------------------------------------------ ! THESE WRAPPERS MAY COME IN HANDY, KEEPING FOR NOW - ! subroutine set_fates2hlm_inst(this,bounds_clump, setval_scalar) + ! subroutine set_fates2hlm(this,bounds_clump, setval_scalar) ! ! ! This is a simple wrapper to flush some FATES -> CLM communicators ! @@ -283,8 +310,8 @@ end subroutine dynamics_driv ! type(bounds_type),intent(in) :: bounds_clump ! real(r8),intent(in) :: setval_scalar ! This value will flush all ! - ! call this%fates2hlm_inst%SetValues( bounds_clump, setval_scalar ) - ! end subroutine set_fates2hlm_inst + ! call this%fates2hlm%SetValues( bounds_clump, setval_scalar ) + ! end subroutine set_fates2hlm ! ------------------------------------------------------------------------------------ ! subroutine phen_accvars_init(this,bounds_clump) !