diff --git a/Externals_CLM.cfg b/Externals_CLM.cfg index b440c99ea3..9e1fae0333 100644 --- a/Externals_CLM.cfg +++ b/Externals_CLM.cfg @@ -2,7 +2,7 @@ local_path = src/fates protocol = git repo_url = https://github.com/NGEET/fates -tag = sci.1.27.1_api.7.3.0 +tag = sci.1.30.0_api.8.0.0 required = True [PTCLM] diff --git a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm index 3f6a4dbc56..c40769a62e 100644 --- a/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/Fates/user_nl_clm @@ -3,9 +3,11 @@ hist_mfilt = 365 hist_nhtfrq = -24 hist_empty_htapes = .true. use_fates_spitfire= .true. -hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT', +hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN_ELEM','LITTER_OUT_ELEM', 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', 'PFTleafbiomass','FIRE_ROS','WIND','AREA_TREES','AREA_PLANT', - 'TOTSOMC','TOTLITC','T_SCALAR','NEP','NBP','HR','TOTECOSYSC','NPLANT_SCAG','NPLANT_SCPF', - 'BA_SCLS','NPP_BY_AGE','CWD_AG_CWDSC','PARSUN_Z_CNLF','PARSUN_Z_CNLFPFT','PARSHA_Z_CAN' + 'TOTSOMC','TOTLITC','T_SCALAR','NEP','HR','NPLANT_SCAG','NPLANT_SCPF', + 'BA_SCLS','NPP_BY_AGE','CWD_AG_CWDSC','PARSUN_Z_CNLF','PARSUN_Z_CNLFPFT','PARSHA_Z_CAN', + 'LITTER_FINES_AG_ELEM','LITTER_FINES_BG_ELEM','LITTER_CWD_AG_ELEM','LITTER_CWD_BG_ELEM', + 'SEED_BANK' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm index 66c94f3cc2..9b9243cee5 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesAllVars/user_nl_clm @@ -27,4 +27,6 @@ hist_fincl1 = 'NCL_BY_AGE','NPATCH_BY_AGE','BIOMASS_BY_AGE','NPP_BY_AGE',' 'NPP_LEAF_UNDERSTORY_SCLS','NPP_FROOT_UNDERSTORY_SCLS','NPP_BSW_UNDERSTORY_SCLS', 'NPP_BDEAD_UNDERSTORY_SCLS','NPP_BSEED_UNDERSTORY_SCLS','NPP_STORE_UNDERSTORY_SCLS','RDARK_UNDERSTORY_SCLS', 'LIVESTEM_MR_UNDERSTORY_SCLS','LIVECROOT_MR_UNDERSTORY_SCLS','FROOT_MR_UNDERSTORY_SCLS','RESP_G_UNDERSTORY_SCLS', - 'RESP_M_UNDERSTORY_SCLS' + 'RESP_M_UNDERSTORY_SCLS','LITTER_IN_ELEM','LITTER_OUT_ELEM','SEED_BANK_ELEM','SEEDS_IN_LOCAL_ELEM','SEEDS_IN_EXTERN_ELEM', + 'SEED_GERM_ELEM','SEED_DECAY','CBALANCE_ERROR_FATES','ERROR_FATES','LITTER_FINES_AG_ELEM','LITTER_FINES_BG_ELEM','LITTER_CWD_BG_ELEM', + 'LITTER_CWD_AG_ELEM','LITTER_CWD' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm index bae4c2cb9e..97cafd9d42 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesColdDef/user_nl_clm @@ -6,5 +6,5 @@ hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT' 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', 'PFTleafbiomass','FIRE_ROS','WIND','AREA_TREES','AREA_PLANT', - 'TOTSOMC','TOTLITC','T_SCALAR','NEP','NBP','HR','TOTECOSYSC','NPLANT_SCAG','NPLANT_SCPF', + 'TOTSOMC','TOTLITC','T_SCALAR','NEP','HR','NPLANT_SCAG','NPLANT_SCPF', 'BA_SCLS','NPP_BY_AGE','CWD_AG_CWDSC','PARSUN_Z_CNLF','PARSUN_Z_CNLFPFT','PARSHA_Z_CAN' diff --git a/cime_config/testdefs/testmods_dirs/clm/FatesShortList/user_nl_clm b/cime_config/testdefs/testmods_dirs/clm/FatesShortList/user_nl_clm index f9d31eecbb..fc057c0be3 100644 --- a/cime_config/testdefs/testmods_dirs/clm/FatesShortList/user_nl_clm +++ b/cime_config/testdefs/testmods_dirs/clm/FatesShortList/user_nl_clm @@ -2,4 +2,4 @@ hist_fincl1 = 'NPP','GPP','BTRAN','H2OSOI','TLAI','LITTER_IN','LITTER_OUT' 'FIRE_AREA','SCORCH_HEIGHT','FIRE_INTENSITY','FIRE_TFC_ROS','fire_fuel_mef', 'fire_fuel_bulkd','fire_fuel_sav','FIRE_NESTEROV_INDEX','PFTbiomass', 'PFTleafbiomass','FIRE_ROS','WIND','AREA_TREES','AREA_PLANT', - 'TOTSOMC','TOTLITC','T_SCALAR','NEP','NBP','HR','TOTECOSYSC' + 'TOTSOMC','TOTLITC','T_SCALAR','NEP','HR' diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index 74b7aeea24..822dc249ce 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -24,8 +24,10 @@ module histFileMod use EDTypesMod , only : nlevleaf use FatesInterfaceMod , only : nlevsclass, nlevage use FatesInterfaceMod , only : nlevheight - use EDTypesMod , only : nfsc, ncwd - use FatesInterfaceMod , only : numpft_ed => numpft + use EDTypesMod , only : nfsc + use FatesLitterMod , only : ncwd + use EDTypesMod , only : num_elements_fates => num_elements + use FatesInterfaceMod , only : numpft_fates => numpft use ncdio_pio ! @@ -191,6 +193,9 @@ module histFileMod integer :: beg1d_out ! on-node 1d hbuf pointer start index integer :: end1d_out ! on-node 1d hbuf pointer end index integer :: num1d_out ! size of hbuf first dimension (all nodes) + integer :: numdims ! the actual number of dimensions, this allows + ! for 2D arrays, where the second dimension is allowed + ! to be 1 integer :: num2d ! size of hbuf second dimension (e.g. number of vertical levels) integer :: hpindex ! history pointer index character(len=scale_type_strlen) :: p2c_scale_type ! scale factor when averaging patch to column @@ -306,7 +311,7 @@ subroutine hist_printflds() end subroutine hist_printflds !----------------------------------------------------------------------- - subroutine masterlist_addfld (fname, type1d, type1d_out, & + subroutine masterlist_addfld (fname, numdims, type1d, type1d_out, & type2d, num2d, units, avgflag, long_name, hpindex, & p2c_scale_type, c2l_scale_type, l2g_scale_type, & no_snow_behavior) @@ -322,6 +327,7 @@ subroutine masterlist_addfld (fname, type1d, type1d_out, & ! ! !ARGUMENTS: character(len=*), intent(in) :: fname ! field name + integer , intent(in) :: numdims ! number of dimensions character(len=*), intent(in) :: type1d ! 1d data type character(len=*), intent(in) :: type1d_out ! 1d output type character(len=*), intent(in) :: type2d ! 2d output type @@ -400,6 +406,7 @@ subroutine masterlist_addfld (fname, type1d, type1d_out, & masterlist(f)%field%type1d = type1d masterlist(f)%field%type1d_out = type1d_out masterlist(f)%field%type2d = type2d + masterlist(f)%field%numdims = numdims masterlist(f)%field%num2d = num2d masterlist(f)%field%hpindex = hpindex masterlist(f)%field%p2c_scale_type = p2c_scale_type @@ -1054,6 +1061,7 @@ subroutine hist_update_hbuf(bounds) integer :: t ! tape index integer :: f ! field index integer :: num2d ! size of second dimension (e.g. number of vertical levels) + integer :: numdims ! number of dimensions character(len=*),parameter :: subname = 'hist_update_hbuf' character(len=hist_dim_name_length) :: type2d ! hbuf second dimension type ["levgrnd","levlak","numrad","ltype","natpft","cft","glc_nec","elevclas","subname(n)"] !----------------------------------------------------------------------- @@ -1061,10 +1069,12 @@ subroutine hist_update_hbuf(bounds) do t = 1,ntapes !$OMP PARALLEL DO PRIVATE (f, num2d) do f = 1,tape(t)%nflds - num2d = tape(t)%hlist(f)%field%num2d - if ( num2d == 1) then + numdims = tape(t)%hlist(f)%field%numdims + + if ( numdims == 1) then call hist_update_hbuf_field_1d (t, f, bounds) else + num2d = tape(t)%hlist(f)%field%num2d call hist_update_hbuf_field_2d (t, f, bounds, num2d) end if end do @@ -2056,18 +2066,22 @@ subroutine htape_create (t, histrest) if(use_fates)then call ncd_defdim(lnfid, 'fates_levscag', nlevsclass * nlevage, dimid) - call ncd_defdim(lnfid, 'fates_levscagpf', nlevsclass * nlevage * numpft_ed, dimid) - call ncd_defdim(lnfid, 'fates_levagepft', nlevage * numpft_ed, dimid) + call ncd_defdim(lnfid, 'fates_levscagpf', nlevsclass * nlevage * numpft_fates, dimid) + call ncd_defdim(lnfid, 'fates_levagepft', nlevage * numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levscls', nlevsclass, dimid) - call ncd_defdim(lnfid, 'fates_levpft', numpft_ed, dimid) + call ncd_defdim(lnfid, 'fates_levpft', numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levage', nlevage, dimid) call ncd_defdim(lnfid, 'fates_levheight', nlevheight, dimid) call ncd_defdim(lnfid, 'fates_levfuel', nfsc, dimid) call ncd_defdim(lnfid, 'fates_levcwdsc', ncwd, dimid) - call ncd_defdim(lnfid, 'fates_levscpf', nlevsclass*numpft_ed, dimid) + call ncd_defdim(lnfid, 'fates_levscpf', nlevsclass*numpft_fates, dimid) call ncd_defdim(lnfid, 'fates_levcan', nclmax, dimid) call ncd_defdim(lnfid, 'fates_levcnlf', nlevleaf * nclmax, dimid) - call ncd_defdim(lnfid, 'fates_levcnlfpf', nlevleaf * nclmax * numpft_ed, dimid) + call ncd_defdim(lnfid, 'fates_levcnlfpf', nlevleaf * nclmax * numpft_fates, dimid) + call ncd_defdim(lnfid, 'fates_levelem', num_elements_fates, dimid) + call ncd_defdim(lnfid, 'fates_levelpft', num_elements_fates * numpft_fates, dimid) + call ncd_defdim(lnfid, 'fates_levelcwd', num_elements_fates * ncwd, dimid) + call ncd_defdim(lnfid, 'fates_levelage', num_elements_fates * nlevage, dimid) end if if ( .not. lhistrest )then @@ -2502,6 +2516,15 @@ subroutine htape_timeconst(t, mode) use FatesInterfaceMod, only : fates_hdim_canmap_levcnlfpf use FatesInterfaceMod, only : fates_hdim_lfmap_levcnlfpf use FatesInterfaceMod, only : fates_hdim_pftmap_levcnlfpf + use FatesInterfaceMod, only : fates_hdim_levelem + use FatesInterfaceMod, only : fates_hdim_elmap_levelpft + use FatesInterfaceMod, only : fates_hdim_pftmap_levelpft + use FatesInterfaceMod, only : fates_hdim_elmap_levelcwd + use FatesInterfaceMod, only : fates_hdim_cwdmap_levelcwd + use FatesInterfaceMod, only : fates_hdim_elmap_levelage + use FatesInterfaceMod, only : fates_hdim_agemap_levelage + + ! ! !ARGUMENTS: integer, intent(in) :: t ! tape index @@ -2598,6 +2621,20 @@ subroutine htape_timeconst(t, mode) long_name='FATES pft map into patch age x pft', units='-', ncid=nfid(t)) call ncd_defvar(varname='fates_agmap_levagepft', xtype=ncd_int, dim1name='fates_levagepft', & long_name='FATES age-class map into patch age x pft', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_levelem',xtype=ncd_int, dim1name='fates_levelem', & + long_name='FATES element (C,N,P,...) identifier', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_elmap_levelpft', xtype=ncd_int, dim1name='fates_levelpft', & + long_name='FATES element map into element x pft ', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_pftmap_levelpft', xtype=ncd_int, dim1name='fates_levelpft', & + long_name='FATES pft map into element x pft', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_elmap_levelcwd', xtype=ncd_int, dim1name='fates_levelcwd', & + long_name='FATES element map into element x cwd', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_cwdmap_levelcwd', xtype=ncd_int, dim1name='fates_levelcwd', & + long_name='FATES cwd map into element x cwd', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_elmap_levelage', xtype=ncd_int, dim1name='fates_levelage', & + long_name='FATES element map into age x pft', units='-', ncid=nfid(t)) + call ncd_defvar(varname='fates_agemap_levelage', xtype=ncd_int, dim1name='fates_levelage', & + long_name='FATES element map into age x pft', units='-', ncid=nfid(t)) end if @@ -2633,7 +2670,14 @@ subroutine htape_timeconst(t, mode) call ncd_io(varname='fates_agmap_levscagpft',data=fates_hdim_agmap_levscagpft, ncid=nfid(t), flag='write') call ncd_io(varname='fates_pftmap_levscagpft',data=fates_hdim_pftmap_levscagpft, ncid=nfid(t), flag='write') call ncd_io(varname='fates_pftmap_levagepft',data=fates_hdim_pftmap_levagepft, ncid=nfid(t), flag='write') - call ncd_io(varname='fates_agmap_levagepft',data=fates_hdim_agmap_levagepft, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_agmap_levagepft',data=fates_hdim_agmap_levagepft, ncid=nfid(t), flag='write') + call ncd_io(varname='fates_levelem',data=fates_hdim_levelem, ncid=nfid(t),flag='write') + call ncd_io(varname='fates_elmap_levelpft',data=fates_hdim_elmap_levelpft, ncid=nfid(t),flag='write') + call ncd_io(varname='fates_pftmap_levelpft',data=fates_hdim_pftmap_levelpft, ncid=nfid(t),flag='write') + call ncd_io(varname='fates_elmap_levelcwd',data=fates_hdim_elmap_levelcwd, ncid=nfid(t),flag='write') + call ncd_io(varname='fates_cwdmap_levelcwd',data=fates_hdim_cwdmap_levelcwd, ncid=nfid(t),flag='write') + call ncd_io(varname='fates_elmap_levelage',data=fates_hdim_elmap_levelage, ncid=nfid(t),flag='write') + call ncd_io(varname='fates_agemap_levelage',data=fates_hdim_agemap_levelage, ncid=nfid(t),flag='write') end if endif @@ -2879,6 +2923,7 @@ subroutine hfields_write(t, mode) integer :: num2d ! hbuf second dimension size integer :: nt ! time index integer :: ier ! error status + integer :: numdims ! number of dimensions character(len=avgflag_strlen) :: avgflag ! time averaging flag character(len=max_chars) :: long_name! long name character(len=max_chars) :: units ! units @@ -2922,6 +2967,7 @@ subroutine hfields_write(t, mode) end1d_out = tape(t)%hlist(f)%field%end1d_out num1d_out = tape(t)%hlist(f)%field%num1d_out type2d = tape(t)%hlist(f)%field%type2d + numdims = tape(t)%hlist(f)%field%numdims num2d = tape(t)%hlist(f)%field%num2d nt = tape(t)%ntimes @@ -2954,7 +3000,7 @@ subroutine hfields_write(t, mode) endif if (dim2name == 'undefined') then - if (num2d == 1) then + if (numdims == 1) then call ncd_defvar(ncid=nfid(t), varname=varname, xtype=tape(t)%ncprec, & dim1name=dim1name, dim2name='time', & long_name=long_name, units=units, cell_method=avgstr, & @@ -2966,7 +3012,7 @@ subroutine hfields_write(t, mode) missing_value=spval, fill_value=spval) end if else - if (num2d == 1) then + if (numdims == 1) then call ncd_defvar(ncid=nfid(t), varname=varname, xtype=tape(t)%ncprec, & dim1name=dim1name, dim2name=dim2name, dim3name='time', & long_name=long_name, units=units, cell_method=avgstr, & @@ -2987,7 +3033,7 @@ subroutine hfields_write(t, mode) ! Allocate dynamic memory - if (num2d == 1) then + if (numdims == 1) then allocate(hist1do(beg1d_out:end1d_out), stat=ier) if (ier /= 0) then write(iulog,*) trim(subname),' ERROR: allocation' @@ -2998,7 +3044,7 @@ subroutine hfields_write(t, mode) ! Write history output. Always output land and ocean runoff on xy grid. - if (num2d == 1) then + if (numdims == 1) then call ncd_io(flag='write', varname=varname, & dim1name=type1d_out, data=hist1do, ncid=nfid(t), nt=nt) else @@ -3009,7 +3055,7 @@ subroutine hfields_write(t, mode) ! Deallocate dynamic memory - if (num2d == 1) then + if (numdims == 1) then deallocate(hist1do) end if @@ -4667,10 +4713,11 @@ subroutine hist_addfld1d (fname, units, avgflag, long_name, type1d_out, & ! Add field to masterlist - call masterlist_addfld (fname=trim(fname), type1d=l_type1d, type1d_out=l_type1d_out, & - type2d='unset', num2d=1, & - units=units, avgflag=avgflag, long_name=long_name, hpindex=hpindex, & - p2c_scale_type=scale_type_p2c, c2l_scale_type=scale_type_c2l, l2g_scale_type=scale_type_l2g) + call masterlist_addfld (fname=trim(fname), numdims=1, type1d=l_type1d, & + type1d_out=l_type1d_out, type2d='unset', num2d=1, & + units=units, avgflag=avgflag, long_name=long_name, hpindex=hpindex, & + p2c_scale_type=scale_type_p2c, c2l_scale_type=scale_type_c2l, & + l2g_scale_type=scale_type_l2g) l_default = 'active' if (present(default)) then @@ -4786,7 +4833,7 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, case ('fates_levscls') num2d = nlevsclass case ('fates_levpft') - num2d = numpft_ed + num2d = numpft_fates case ('fates_levage') num2d = nlevage case ('fates_levheight') @@ -4796,23 +4843,31 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, case ('fates_levcwdsc') num2d = ncwd case ('fates_levscpf') - num2d = nlevsclass*numpft_ed + num2d = nlevsclass*numpft_fates case ('fates_levscag') num2d = nlevsclass*nlevage case ('fates_levscagpf') - num2d = nlevsclass*nlevage*numpft_ed + num2d = nlevsclass*nlevage*numpft_fates case ('fates_levagepft') - num2d = nlevage*numpft_ed + num2d = nlevage*numpft_fates case ('fates_levcan') num2d = nclmax case ('fates_levcnlf') num2d = nlevleaf * nclmax case ('fates_levcnlfpf') - num2d = nlevleaf * nclmax * numpft_ed + num2d = nlevleaf * nclmax * numpft_fates case ('ltype') num2d = max_lunit case ('natpft') num2d = natpft_size + case ('fates_levelem') + num2d = num_elements_fates + case ('fates_levelpft') + num2d = num_elements_fates*numpft_fates + case ('fates_levelcwd') + num2d = num_elements_fates*ncwd + case ('fates_levelage') + num2d = num_elements_fates*nlevage case('cft') if (cft_size > 0) then num2d = cft_size @@ -4974,12 +5029,12 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, ! Add field to masterlist - call masterlist_addfld (fname=trim(fname), type1d=l_type1d, type1d_out=l_type1d_out, & - type2d=type2d, num2d=num2d, & - units=units, avgflag=avgflag, long_name=long_name, hpindex=hpindex, & - p2c_scale_type=scale_type_p2c, c2l_scale_type=scale_type_c2l, l2g_scale_type=scale_type_l2g, & - no_snow_behavior=no_snow_behavior) - + call masterlist_addfld (fname=trim(fname), numdims=2, type1d=l_type1d, & + type1d_out=l_type1d_out, type2d=type2d, num2d=num2d, & + units=units, avgflag=avgflag, long_name=long_name, hpindex=hpindex, & + p2c_scale_type=scale_type_p2c, c2l_scale_type=scale_type_c2l, & + l2g_scale_type=scale_type_l2g, no_snow_behavior=no_snow_behavior) + l_default = 'active' if (present(default)) then l_default = default diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 84c4e5901f..d1d3d45308 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -107,8 +107,8 @@ module CLMFatesInterfaceMod use FatesHistoryInterfaceMod, only : fates_history_interface_type use FatesRestartInterfaceMod, only : fates_restart_interface_type - use ChecksBalancesMod , only : SummarizeNetFluxes, FATES_BGC_Carbon_BalanceCheck use EDTypesMod , only : ed_patch_type + use EDTypesMod , only : num_elements use FatesInterfaceMod , only : hlm_numlevgrnd use EDMainMod , only : ed_ecosystem_dynamics use EDMainMod , only : ed_update_site @@ -123,7 +123,7 @@ module CLMFatesInterfaceMod use EDCanopyStructureMod , only : canopy_summarization, update_hlm_dynamics use FatesPlantRespPhotosynthMod, only : FatesPlantRespPhotosynthDrive use EDAccumulateFluxesMod , only : AccumulateFluxes_ED - use EDPhysiologyMod , only : flux_into_litter_pools + use EDPhysiologyMod , only : FluxIntoLitterPools use FatesPlantHydraulicsMod, only : hydraulics_drive use FatesPlantHydraulicsMod, only : HydrSiteColdStart use FatesPlantHydraulicsMod, only : InitHydrSites @@ -688,7 +688,7 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! call subroutine to aggregate fates litter output fluxes and ! package them for handing across interface - call flux_into_litter_pools(this%fates(nc)%nsites, & + call FluxIntoLitterPools(this%fates(nc)%nsites, & this%fates(nc)%sites, & this%fates(nc)%bc_in, & this%fates(nc)%bc_out) @@ -709,11 +709,14 @@ subroutine dynamics_driv(this, nc, bounds_clump, & nld_si = this%fates(nc)%bc_in(s)%nlevdecomp soilbiogeochem_carbonflux_inst%FATES_c_to_litr_lab_c_col(c,1:nld_si) = & - this%fates(nc)%bc_out(s)%FATES_c_to_litr_lab_c_col(1:nld_si) + this%fates(nc)%bc_out(s)%litt_flux_lab_c_si(1:nld_si) + soilbiogeochem_carbonflux_inst%FATES_c_to_litr_cel_c_col(c,1:nld_si) = & - this%fates(nc)%bc_out(s)%FATES_c_to_litr_cel_c_col(1:nld_si) + this%fates(nc)%bc_out(s)%litt_flux_cel_c_si(1:nld_si) + soilbiogeochem_carbonflux_inst%FATES_c_to_litr_lig_c_col(c,1:nld_si) = & - this%fates(nc)%bc_out(s)%FATES_c_to_litr_lig_c_col(1:nld_si) + this%fates(nc)%bc_out(s)%litt_flux_lig_c_si(1:nld_si) + end do @@ -1226,11 +1229,12 @@ subroutine init_coldstart(this, waterstate_inst, canopystate_inst, soilstate_ins call get_clump_bounds(nc, bounds_clump) do s = 1,this%fates(nc)%nsites - call init_site_vars(this%fates(nc)%sites(s)) + call init_site_vars(this%fates(nc)%sites(s),this%fates(nc)%bc_in(s) ) call zero_site(this%fates(nc)%sites(s)) end do - call set_site_properties(this%fates(nc)%nsites, this%fates(nc)%sites) + call set_site_properties(this%fates(nc)%nsites, & + this%fates(nc)%sites) ! ---------------------------------------------------------------------------- ! Initialize Hydraulics Code if turned on @@ -1301,7 +1305,7 @@ subroutine init_coldstart(this, waterstate_inst, canopystate_inst, soilstate_ins end if end do !$OMP END PARALLEL DO - + end subroutine init_coldstart ! ====================================================================================== @@ -1878,30 +1882,13 @@ subroutine wrap_bgc_summary(this, nc, soilbiogeochem_carbonflux_inst, & this%fates(nc)%bc_in(s)%tot_somc = totsomc(c) this%fates(nc)%bc_in(s)%tot_litc = totlitc(c) end do - - is_beg_day = is_beg_curr_day() - dtime = get_step_size() - nstep = get_nstep() - - call SummarizeNetFluxes(this%fates(nc)%nsites, & - this%fates(nc)%sites, & - this%fates(nc)%bc_in, & - is_beg_day) - - call FATES_BGC_Carbon_Balancecheck(this%fates(nc)%nsites, & - this%fates(nc)%sites, & - this%fates(nc)%bc_in, & - is_beg_day, & - dtime, nstep) - - ! Update history variables that track these variables call this%fates_hist%update_history_cbal(nc, & - this%fates(nc)%nsites, & - this%fates(nc)%sites) + this%fates(nc)%nsites, & + this%fates(nc)%sites, & + this%fates(nc)%bc_in) - end associate end subroutine wrap_bgc_summary @@ -1954,7 +1941,8 @@ subroutine init_history_io(this,bounds_proc) use FatesIOVariableKindMod, only : site_fuel_r8, site_cwdsc_r8, site_scag_r8 use FatesIOVariableKindMod, only : site_scagpft_r8, site_agepft_r8 use FatesIOVariableKindMod, only : site_can_r8, site_cnlf_r8, site_cnlfpft_r8 - use FatesIOVariableKindMod, only : site_height_r8 + use FatesIOVariableKindMod, only : site_height_r8, site_elem_r8, site_elpft_r8 + use FatesIOVariableKindMod, only : site_elcwd_r8, site_elage_r8 use FatesIODimensionsMod, only : fates_bounds_type @@ -2075,151 +2063,29 @@ subroutine init_history_io(this,bounds_proc) default=trim(vdefault), & set_lake=0._r8,set_urb=0._r8) - case(patch_ground_r8) + case(patch_ground_r8, patch_size_pft_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index dim2name = this%fates_hist%dim_bounds(d_index)%name call hist_addfld2d(fname=trim(vname),units=trim(vunits), & ! <--- addfld2d type2d=trim(dim2name), & ! <--- type2d avgflag=trim(vavgflag),long_name=trim(vlong), & ptr_patch=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) + default=trim(vdefault)) - case(patch_size_pft_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_patch=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_ground_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_size_pft_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_size_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_pft_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_age_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_height_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_fuel_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_cwdsc_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_can_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_cnlf_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_cnlfpft_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_scag_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_scagpft_r8) - d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index - dim2name = this%fates_hist%dim_bounds(d_index)%name - call hist_addfld2d(fname=trim(vname),units=trim(vunits), & - type2d=trim(dim2name), & - avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) - case(site_agepft_r8) + case(site_ground_r8, site_size_pft_r8, site_size_r8, site_pft_r8, & + site_age_r8, site_height_r8, site_fuel_r8, site_cwdsc_r8, & + site_can_r8,site_cnlf_r8, site_cnlfpft_r8, site_scag_r8, & + site_scagpft_r8, site_agepft_r8, site_elem_r8, site_elpft_r8, & + site_elcwd_r8, site_elage_r8) + d_index = this%fates_hist%dim_kinds(dk_index)%dim2_index dim2name = this%fates_hist%dim_bounds(d_index)%name call hist_addfld2d(fname=trim(vname),units=trim(vunits), & type2d=trim(dim2name), & avgflag=trim(vavgflag),long_name=trim(vlong), & - ptr_col=this%fates_hist%hvars(ivar)%r82d, & - default=trim(vdefault), & - set_lake=0._r8,set_urb=0._r8) + ptr_col=this%fates_hist%hvars(ivar)%r82d, & + default=trim(vdefault)) case default write(iulog,*) 'A FATES iotype was created that was not registerred' @@ -2257,6 +2123,27 @@ subroutine init_soil_depths(this, nc) this%fates(nc)%bc_in(s)%z_sisl(1:nlevsoil) = col%z(c,1:nlevsoil) this%fates(nc)%bc_in(s)%dz_decomp_sisl(1:nlevdecomp) = & dzsoi_decomp(1:nlevdecomp) + + if (use_vertsoilc) then + do j=1,nlevsoil + this%fates(nc)%bc_in(s)%decomp_id(j) = j + ! Check to make sure that dz = dz_decomp_sisl when vertical soil dynamics + ! are active + if(abs(this%fates(nc)%bc_in(s)%dz_decomp_sisl(j)-this%fates(nc)%bc_in(s)%dz_sisl(j))>1.e-10_r8)then + write(iulog,*) 'when vertical soil decomp dynamics are on' + write(iulog,*) 'fates assumes that the decomposition depths equal the soil depths' + write(iulog,*) 'layer: ',j + write(iulog,*) 'dz_decomp_sisl(j): ',this%fates(nc)%bc_in(s)%dz_decomp_sisl(j) + write(iulog,*) 'dz_sisl(j): ',this%fates(nc)%bc_in(s)%dz_sisl(j) + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + end do + else + do j=1,nlevsoil + this%fates(nc)%bc_in(s)%decomp_id(j) = 1 + end do + end if + end do return @@ -2442,10 +2329,11 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) use FatesIODimensionsMod, only : fates_bounds_type use FatesInterfaceMod, only : nlevsclass, nlevage use FatesInterfaceMod, only : nlevheight - use EDtypesMod, only : nfsc, ncwd - use EDtypesMod, only : nlevleaf, nclmax + use EDtypesMod, only : nfsc + use FatesLitterMod, only : ncwd + use EDtypesMod, only : nlevleaf, nclmax use FatesInterfaceMod, only : numpft_fates => numpft - use clm_varpar, only : nlevgrnd + use clm_varpar, only : nlevgrnd implicit none @@ -2502,6 +2390,19 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) fates%cnlfpft_begin = 1 fates%cnlfpft_end = nlevleaf * nclmax * numpft_fates + + fates%elem_begin = 1 + fates%elem_end = num_elements + + fates%elpft_begin = 1 + fates%elpft_end = num_elements * numpft_fates + + fates%elcwd_begin = 1 + fates%elcwd_end = num_elements * ncwd + + fates%elage_begin = 1 + fates%elage_end = num_elements * nlevage + end subroutine hlm_bounds_to_fates_bounds