From d1135f64f9359a4653f8dbadac17ee7a0550afb8 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 15 Jan 2025 09:36:55 -0700 Subject: [PATCH 1/2] Initializing itype as spval for fates patches --- src/biogeophys/SurfaceAlbedoMod.F90 | 36 ++++++++++++++--------------- src/main/clm_driver.F90 | 22 ++++++++++++------ src/utils/clmfates_interfaceMod.F90 | 4 +++- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/biogeophys/SurfaceAlbedoMod.F90 b/src/biogeophys/SurfaceAlbedoMod.F90 index 6628f0fa4d..cc628cc409 100644 --- a/src/biogeophys/SurfaceAlbedoMod.F90 +++ b/src/biogeophys/SurfaceAlbedoMod.F90 @@ -864,23 +864,6 @@ subroutine SurfaceAlbedo(bounds,nc, & end if end do - ! Weight reflectance/transmittance by lai and sai - ! Only perform on vegetated patches where coszen > 0 - - do fp = 1,num_vegsol - p = filter_vegsol(fp) - wl(p) = elai(p) / max( elai(p)+esai(p), mpe ) - ws(p) = esai(p) / max( elai(p)+esai(p), mpe ) - end do - - do ib = 1, numrad - do fp = 1,num_vegsol - p = filter_vegsol(fp) - rho(p,ib) = max( rhol(patch%itype(p),ib)*wl(p) + rhos(patch%itype(p),ib)*ws(p), mpe ) - tau(p,ib) = max( taul(patch%itype(p),ib)*wl(p) + taus(patch%itype(p),ib)*ws(p), mpe ) - end do - end do - ! Diagnose number of canopy layers for radiative transfer, in increments of dincmax. ! Add to number of layers so long as cumulative leaf+stem area does not exceed total ! leaf+stem area. Then add any remaining leaf+stem area to next layer and exit the loop. @@ -1051,7 +1034,24 @@ subroutine SurfaceAlbedo(bounds,nc, & fcansno(bounds%begp:bounds%endp), surfalb_inst) else - + + ! Weight reflectance/transmittance by lai and sai + ! Only perform on vegetated patches where coszen > 0 + + do fp = 1,num_vegsol + p = filter_vegsol(fp) + wl(p) = elai(p) / max( elai(p)+esai(p), mpe ) + ws(p) = esai(p) / max( elai(p)+esai(p), mpe ) + end do + + do ib = 1, numrad + do fp = 1,num_vegsol + p = filter_vegsol(fp) + rho(p,ib) = max( rhol(patch%itype(p),ib)*wl(p) + rhos(patch%itype(p),ib)*ws(p), mpe ) + tau(p,ib) = max( taul(patch%itype(p),ib)*wl(p) + taus(patch%itype(p),ib)*ws(p), mpe ) + end do + end do + call TwoStream (bounds, filter_vegsol, num_vegsol, & coszen_patch(bounds%begp:bounds%endp), & rho(bounds%begp:bounds%endp, :), & diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 454ff87463..4650f9469f 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -18,6 +18,7 @@ module clm_driver use clm_time_manager , only : get_nstep, is_beg_curr_day, is_beg_curr_year use clm_time_manager , only : get_prev_date, is_first_step use clm_varpar , only : nlevsno, nlevgrnd + use clm_varcon , only : spval use clm_varorb , only : obliqr use spmdMod , only : masterproc, mpicom use decompMod , only : get_proc_clumps, get_clump_bounds, get_proc_bounds, bounds_type @@ -704,16 +705,23 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! bugs. allocate(downreg_patch(bounds_clump%begp:bounds_clump%endp)) allocate(leafn_patch(bounds_clump%begp:bounds_clump%endp)) - downreg_patch = bgc_vegetation_inst%get_downreg_patch(bounds_clump) - leafn_patch = bgc_vegetation_inst%get_leafn_patch(bounds_clump) - allocate(froot_carbon(bounds_clump%begp:bounds_clump%endp)) allocate(croot_carbon(bounds_clump%begp:bounds_clump%endp)) - froot_carbon = bgc_vegetation_inst%get_froot_carbon_patch( & - bounds_clump, canopystate_inst%tlai_patch(bounds_clump%begp:bounds_clump%endp)) - croot_carbon = bgc_vegetation_inst%get_croot_carbon_patch( & - bounds_clump, canopystate_inst%tlai_patch(bounds_clump%begp:bounds_clump%endp)) + if(use_fates)then + downreg_patch(:) = spval + leafn_patch(:) = spval + froot_carbon(:) = spval + croot_carbon(:) = spval + else + downreg_patch = bgc_vegetation_inst%get_downreg_patch(bounds_clump) + leafn_patch = bgc_vegetation_inst%get_leafn_patch(bounds_clump) + froot_carbon = bgc_vegetation_inst%get_froot_carbon_patch( & + bounds_clump, canopystate_inst%tlai_patch(bounds_clump%begp:bounds_clump%endp)) + croot_carbon = bgc_vegetation_inst%get_croot_carbon_patch( & + bounds_clump, canopystate_inst%tlai_patch(bounds_clump%begp:bounds_clump%endp)) + end if + call CanopyFluxes(bounds_clump, & filter(nc)%num_exposedvegp, filter(nc)%exposedvegp, & clm_fates,nc, & diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 269189d1b7..3b7d697317 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -930,8 +930,10 @@ subroutine init(this, bounds_proc, flandusepftdat) c = this%f2hmap(nc)%fcolumn(s) pi = col%patchi(c)+1 pf = col%patchf(c) -! patch%itype(pi:pf) = ispval + patch%itype(pi:pf) = ispval patch%is_fates(pi:pf) = .true. + !write(iulog,*)'SETTING ISPVAL' + !call endrun(msg=errMsg(sourcefile, __LINE__)) end do end do From 7bd963b7094a49882ed7c245d79daf3fe2780593 Mon Sep 17 00:00:00 2001 From: Ryan Knox Date: Wed, 15 Jan 2025 09:47:42 -0700 Subject: [PATCH 2/2] removed commented out test code --- src/utils/clmfates_interfaceMod.F90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 3b7d697317..2f8dba08d7 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -932,8 +932,6 @@ subroutine init(this, bounds_proc, flandusepftdat) pf = col%patchf(c) patch%itype(pi:pf) = ispval patch%is_fates(pi:pf) = .true. - !write(iulog,*)'SETTING ISPVAL' - !call endrun(msg=errMsg(sourcefile, __LINE__)) end do end do