From a9f0483073727626aed3fea18039e569bedab9fc Mon Sep 17 00:00:00 2001 From: Rosie Fisher Date: Thu, 19 Sep 2024 14:55:53 +0200 Subject: [PATCH 01/11] added ctsm side variable to receive wesley vegetation type --- src/biogeophys/CanopyStateType.F90 | 2 ++ src/utils/clmfates_interfaceMod.F90 | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index 313f7a83f3..4df5658eb7 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -52,6 +52,7 @@ module CanopyStateType real(r8) , pointer :: dleaf_patch (:) ! patch characteristic leaf width (diameter) [m] ! for non-ED/FATES this is the same as pftcon%dleaf() + integer , pointer :: wesley_pft_index_patch (:) ! Wesley PFT index for FATES drydep calculations real(r8) , pointer :: rscanopy_patch (:) ! patch canopy stomatal resistance (s/m) (ED specific) real(r8) , pointer :: vegwp_patch (:,:) ! patch vegetation water matric potential (mm) @@ -142,6 +143,7 @@ subroutine InitAllocate(this, bounds) allocate(this%fsun240_patch (begp:endp)) ; this%fsun240_patch (:) = nan allocate(this%dleaf_patch (begp:endp)) ; this%dleaf_patch (:) = nan + allocate(this%wesley_pft_index_patch (begp:endp)) ; this%wesley_pft_index_patch (:) = nan allocate(this%rscanopy_patch (begp:endp)) ; this%rscanopy_patch (:) = nan ! allocate(this%gccanopy_patch (begp:endp)) ; this%gccanopy_patch (:) = 0.0_r8 allocate(this%vegwp_patch (begp:endp,1:nvegwcs)) ; this%vegwp_patch (:,:) = nan diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index fcd5cb5230..8fffca8767 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1445,6 +1445,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & z0m => canopystate_inst%z0m_patch , & ! Output: [real(r8) (:) ] momentum roughness length (m) displa => canopystate_inst%displa_patch, & dleaf_patch => canopystate_inst%dleaf_patch, & + wesley_pft_index_patch => canopystate_inst%wesley_pft_index_patch, & snow_depth => waterdiagnosticbulk_inst%snow_depth_col, & frac_sno_eff => waterdiagnosticbulk_inst%frac_sno_eff_col, & frac_veg_nosno_alb => canopystate_inst%frac_veg_nosno_alb_patch) @@ -1568,7 +1569,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & z0m(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 displa(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 dleaf_patch(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 - + wesley_pft_index_patch(col%patchi(c)+1:col%patchf(c)) = 0 frac_veg_nosno_alb(col%patchi(c):col%patchf(c)) = 0.0_r8 ! Set the bareground patch indicator @@ -1630,6 +1631,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & z0m(p) = this%fates(nc)%bc_out(s)%z0m_pa(ifp) displa(p) = this%fates(nc)%bc_out(s)%displa_pa(ifp) dleaf_patch(p) = this%fates(nc)%bc_out(s)%dleaf_pa(ifp) + wesley_pft_index_patch(p) = this%fates(nc)%bc_out(s)%wesley_pft_label_pa(ifp) end do ! veg pach if(abs(areacheck - 1.0_r8).gt.1.e-9_r8)then From b20d03575c0c9d81ebcc209a7fd45b9ca3cbd394 Mon Sep 17 00:00:00 2001 From: Rosie Fisher Date: Thu, 19 Sep 2024 15:12:56 +0200 Subject: [PATCH 02/11] use FATES wespft index when fates is on --- src/biogeochem/DryDepVelocity.F90 | 4 ++++ src/biogeophys/CanopyStateType.F90 | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/biogeochem/DryDepVelocity.F90 b/src/biogeochem/DryDepVelocity.F90 index e6572beb81..a4775fe460 100644 --- a/src/biogeochem/DryDepVelocity.F90 +++ b/src/biogeochem/DryDepVelocity.F90 @@ -359,6 +359,10 @@ subroutine depvel_compute( bounds, & errMsg(sourcefile, __LINE__)) end if + if(use_fates)then + wesveg = canopystate_inst%wesley_pft_index_patch + endif + ! create seasonality index used to index wesely data tables from LAI, Bascially !if elai is between max lai from input data and half that max the index_season=1 diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index 4df5658eb7..f784adc099 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -143,7 +143,7 @@ subroutine InitAllocate(this, bounds) allocate(this%fsun240_patch (begp:endp)) ; this%fsun240_patch (:) = nan allocate(this%dleaf_patch (begp:endp)) ; this%dleaf_patch (:) = nan - allocate(this%wesley_pft_index_patch (begp:endp)) ; this%wesley_pft_index_patch (:) = nan + allocate(this%wesley_pft_index_patch (begp:endp)) ; ! is an integer so can't be nan allocate(this%rscanopy_patch (begp:endp)) ; this%rscanopy_patch (:) = nan ! allocate(this%gccanopy_patch (begp:endp)) ; this%gccanopy_patch (:) = 0.0_r8 allocate(this%vegwp_patch (begp:endp,1:nvegwcs)) ; this%vegwp_patch (:,:) = nan From 254646103278f101f5bff535e54372f8dbcf6900 Mon Sep 17 00:00:00 2001 From: Rosie Fisher Date: Thu, 19 Sep 2024 15:55:09 +0200 Subject: [PATCH 03/11] bug fixes --- src/biogeochem/DryDepVelocity.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/biogeochem/DryDepVelocity.F90 b/src/biogeochem/DryDepVelocity.F90 index a4775fe460..ba88f9ead9 100644 --- a/src/biogeochem/DryDepVelocity.F90 +++ b/src/biogeochem/DryDepVelocity.F90 @@ -208,6 +208,7 @@ subroutine depvel_compute( bounds, & use pftconMod , only : nc3_nonarctic_grass, nc4_grass, nc3crop use pftconMod , only : nc3irrig, npcropmin, npcropmax use clm_varcon , only : spval + use clm_varctl , only : use_fates ! ! !ARGUMENTS: @@ -360,7 +361,7 @@ subroutine depvel_compute( bounds, & end if if(use_fates)then - wesveg = canopystate_inst%wesley_pft_index_patch + wesveg = canopystate_inst%wesley_pft_index_patch(pi) endif ! create seasonality index used to index wesely data tables from LAI, Bascially From ba814fec83eae46aedca469086f8bd0c458c645f Mon Sep 17 00:00:00 2001 From: Rosie Fisher Date: Thu, 19 Sep 2024 16:05:05 +0200 Subject: [PATCH 04/11] make drydep_season_patch variable in canopystate --- src/biogeophys/CanopyStateType.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index f784adc099..137f2e241b 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -53,6 +53,8 @@ module CanopyStateType real(r8) , pointer :: dleaf_patch (:) ! patch characteristic leaf width (diameter) [m] ! for non-ED/FATES this is the same as pftcon%dleaf() integer , pointer :: wesley_pft_index_patch (:) ! Wesley PFT index for FATES drydep calculations + integer , pointer :: drydep_season_patch (:) ! Season for dry deposition calculations + real(r8) , pointer :: rscanopy_patch (:) ! patch canopy stomatal resistance (s/m) (ED specific) real(r8) , pointer :: vegwp_patch (:,:) ! patch vegetation water matric potential (mm) @@ -144,6 +146,7 @@ subroutine InitAllocate(this, bounds) allocate(this%dleaf_patch (begp:endp)) ; this%dleaf_patch (:) = nan allocate(this%wesley_pft_index_patch (begp:endp)) ; ! is an integer so can't be nan + allocate(this%drydep_season_patch (begp:endp)) ; ! is an integer so can't be nan allocate(this%rscanopy_patch (begp:endp)) ; this%rscanopy_patch (:) = nan ! allocate(this%gccanopy_patch (begp:endp)) ; this%gccanopy_patch (:) = 0.0_r8 allocate(this%vegwp_patch (begp:endp,1:nvegwcs)) ; this%vegwp_patch (:,:) = nan From 7555556f4611f1f8a05a7609c2bd3761b3988cef Mon Sep 17 00:00:00 2001 From: Rosie Fisher Date: Thu, 19 Sep 2024 16:09:12 +0200 Subject: [PATCH 05/11] retrieve drydep_season from interface and use in drydep routine --- src/biogeochem/DryDepVelocity.F90 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/biogeochem/DryDepVelocity.F90 b/src/biogeochem/DryDepVelocity.F90 index ba88f9ead9..ae86a86b4e 100644 --- a/src/biogeochem/DryDepVelocity.F90 +++ b/src/biogeochem/DryDepVelocity.F90 @@ -381,12 +381,12 @@ subroutine depvel_compute( bounds, & ! 4 - Winter, snow on ground and subfreezing ! 5 - Transitional spring with partially green short annuals - - !mlaidiff=jan-feb - minlai=minval(annlai(:,pi)) - maxlai=maxval(annlai(:,pi)) - - index_season = -1 + if(.not. use_fates)then + !mlaidiff=jan-feb + minlai=minval(annlai(:,pi)) + maxlai=maxval(annlai(:,pi)) + endif + index_season = -1 if ( lun%itype(l) /= istsoil )then if ( lun%itype(l) == istice ) then @@ -404,10 +404,14 @@ subroutine depvel_compute( bounds, & end if else if ( snow_depth(c) > 0 ) then index_season = 4 - else if(elai(pi) > 0.5_r8*maxlai) then + else if(.not.use_fates .and. elai(pi) > 0.5_r8*maxlai) then index_season = 1 endif + if(use_fates)then + index_season = canopystate_inst%drydep_season_patch(pi) + endif + if (index_season<0) then if (elai(pi) < (minlai+0.05_r8*(maxlai-minlai))) then index_season = 3 From 2aa1e9d2a150b5cd8aa7bd0590c8442c61875c76 Mon Sep 17 00:00:00 2001 From: Rosie Fisher Date: Thu, 19 Sep 2024 16:10:01 +0200 Subject: [PATCH 06/11] pass interface var into canopystate var --- src/utils/clmfates_interfaceMod.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 8fffca8767..f7496ebced 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1446,6 +1446,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & displa => canopystate_inst%displa_patch, & dleaf_patch => canopystate_inst%dleaf_patch, & wesley_pft_index_patch => canopystate_inst%wesley_pft_index_patch, & + drydep_season_patch => canopystate_inst%drydep_season_patch, & snow_depth => waterdiagnosticbulk_inst%snow_depth_col, & frac_sno_eff => waterdiagnosticbulk_inst%frac_sno_eff_col, & frac_veg_nosno_alb => canopystate_inst%frac_veg_nosno_alb_patch) @@ -1570,6 +1571,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & displa(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 dleaf_patch(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 wesley_pft_index_patch(col%patchi(c)+1:col%patchf(c)) = 0 + drydep_season_patch(col%patchi(c)+1:col%patchf(c)) = 0 frac_veg_nosno_alb(col%patchi(c):col%patchf(c)) = 0.0_r8 ! Set the bareground patch indicator @@ -1632,6 +1634,7 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & displa(p) = this%fates(nc)%bc_out(s)%displa_pa(ifp) dleaf_patch(p) = this%fates(nc)%bc_out(s)%dleaf_pa(ifp) wesley_pft_index_patch(p) = this%fates(nc)%bc_out(s)%wesley_pft_label_pa(ifp) + drydep_season_patch(p) = this%fates(nc)%bc_out(s)%drydep_season_pa(ifp) end do ! veg pach if(abs(areacheck - 1.0_r8).gt.1.e-9_r8)then From e9316af1b164399c7078a0958adbe18f42366c37 Mon Sep 17 00:00:00 2001 From: Rosie Fisher Date: Wed, 9 Oct 2024 23:21:36 +0200 Subject: [PATCH 07/11] turn off the call to readannualvegetation in non-SP fates modes --- src/main/clm_initializeMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index d3b6824f3d..4670bc02f0 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -705,7 +705,7 @@ subroutine initialize2(ni,nj) ! Read monthly vegetation ! Even if CN or FATES is on, and dry-deposition is active, read CLMSP annual vegetation ! to get estimates of monthly LAI - if ( n_drydep > 0 ) then + if ( n_drydep > 0 .and. .not. use_fates ) then call readAnnualVegetation(bounds_proc, canopystate_inst) ! Call interpMonthlyVeg for dry-deposition so that mlaidiff will be calculated ! This needs to be done even if FATES, CN or CNDV is on! From e2f7b37c53e75419df088a7016ab962b4cf4ca5b Mon Sep 17 00:00:00 2001 From: rosiealice Date: Thu, 10 Oct 2024 14:10:39 +0200 Subject: [PATCH 08/11] change the names of drydep variables & season logic in drydepvelocity --- src/biogeochem/DryDepVelocity.F90 | 35 ++++++++++++++++-------------- src/biogeophys/CanopyStateType.F90 | 8 +++---- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/biogeochem/DryDepVelocity.F90 b/src/biogeochem/DryDepVelocity.F90 index ae86a86b4e..e56c879124 100644 --- a/src/biogeochem/DryDepVelocity.F90 +++ b/src/biogeochem/DryDepVelocity.F90 @@ -361,7 +361,7 @@ subroutine depvel_compute( bounds, & end if if(use_fates)then - wesveg = canopystate_inst%wesley_pft_index_patch(pi) + wesveg = canopystate_inst%wesley_veg_index_patch(pi) endif ! create seasonality index used to index wesely data tables from LAI, Bascially @@ -409,25 +409,28 @@ subroutine depvel_compute( bounds, & endif if(use_fates)then - index_season = canopystate_inst%drydep_season_patch(pi) - endif + write(iulog,*) 'fates season index',pi,canopystate_inst%wesley_season_index_patch(pi) + index_season = canopystate_inst%wesley_season_index_patch(pi) + else - if (index_season<0) then - if (elai(pi) < (minlai+0.05_r8*(maxlai-minlai))) then - index_season = 3 + if (index_season<0) then + if (elai(pi) < (minlai+0.05_r8*(maxlai-minlai))) then + index_season = 3 + endif endif - endif - if (index_season<0) then - if (mlaidiff(pi) > 0.0_r8) then - index_season = 2 - elseif (mlaidiff(pi) < 0.0_r8) then - index_season = 5 - elseif (mlaidiff(pi).eq.0.0_r8) then - index_season = 3 + if (index_season<0) then + if (mlaidiff(pi) > 0.0_r8) then + index_season = 2 + elseif (mlaidiff(pi) < 0.0_r8) then + index_season = 5 + elseif (mlaidiff(pi).eq.0.0_r8) then + index_season = 3 + endif endif - endif - + + endif ! use_fates + if (index_season<0) then call endrun('ERROR: not able to determine season'//errmsg(sourcefile, __LINE__)) endif diff --git a/src/biogeophys/CanopyStateType.F90 b/src/biogeophys/CanopyStateType.F90 index cbb8ed1163..ea5fc3b0f5 100644 --- a/src/biogeophys/CanopyStateType.F90 +++ b/src/biogeophys/CanopyStateType.F90 @@ -52,8 +52,8 @@ module CanopyStateType real(r8) , pointer :: dleaf_patch (:) ! patch characteristic leaf width (diameter) [m] ! for non-ED/FATES this is the same as pftcon%dleaf() - integer , pointer :: wesley_pft_index_patch (:) ! Wesley PFT index for FATES drydep calculations - integer , pointer :: drydep_season_patch (:) ! Season for dry deposition calculations + integer , pointer :: wesley_veg_index_patch (:) ! Wesley PFT index for FATES dry deposition calculations + integer , pointer :: wesley_season_index_patch (:) ! Season for dry deposition calculations real(r8) , pointer :: rscanopy_patch (:) ! patch canopy stomatal resistance (s/m) (ED specific) @@ -147,8 +147,8 @@ subroutine InitAllocate(this, bounds) allocate(this%fsun240_patch (begp:endp)) ; this%fsun240_patch (:) = nan allocate(this%dleaf_patch (begp:endp)) ; this%dleaf_patch (:) = nan - allocate(this%wesley_pft_index_patch (begp:endp)) ; ! is an integer so can't be nan - allocate(this%drydep_season_patch (begp:endp)) ; ! is an integer so can't be nan + allocate(this%wesley_veg_index_patch (begp:endp)) ; ! is an integer so can't be nan + allocate(this%wesley_season_index_patch (begp:endp)) ; ! is an integer so can't be nan allocate(this%rscanopy_patch (begp:endp)) ; this%rscanopy_patch (:) = nan ! allocate(this%gccanopy_patch (begp:endp)) ; this%gccanopy_patch (:) = 0.0_r8 allocate(this%vegwp_patch (begp:endp,1:nvegwcs)) ; this%vegwp_patch (:,:) = nan From 2e2ec4ebd8c88e9f863944ddae90ba8a3286eeaf Mon Sep 17 00:00:00 2001 From: rosiealice Date: Fri, 11 Oct 2024 16:53:50 +0200 Subject: [PATCH 09/11] edge case debugging --- src/biogeochem/DryDepVelocity.F90 | 26 +++++++++++++++++--------- src/main/clm_initializeMod.F90 | 5 +++-- src/utils/clmfates_interfaceMod.F90 | 12 ++++++------ 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/biogeochem/DryDepVelocity.F90 b/src/biogeochem/DryDepVelocity.F90 index e56c879124..7268a6c65f 100644 --- a/src/biogeochem/DryDepVelocity.F90 +++ b/src/biogeochem/DryDepVelocity.F90 @@ -359,10 +359,14 @@ subroutine depvel_compute( bounds, & msg='ERROR: Not able to determine Wesley vegetation type'//& errMsg(sourcefile, __LINE__)) end if - + if(use_fates)then - wesveg = canopystate_inst%wesley_veg_index_patch(pi) - endif + if(patch%is_fates(pi))then + wesveg = canopystate_inst%wesley_veg_index_patch(pi) + else + wesveg = 8 + endif + endif ! create seasonality index used to index wesely data tables from LAI, Bascially !if elai is between max lai from input data and half that max the index_season=1 @@ -407,11 +411,15 @@ subroutine depvel_compute( bounds, & else if(.not.use_fates .and. elai(pi) > 0.5_r8*maxlai) then index_season = 1 endif - - if(use_fates)then - write(iulog,*) 'fates season index',pi,canopystate_inst%wesley_season_index_patch(pi) - index_season = canopystate_inst%wesley_season_index_patch(pi) - else + + if(use_fates.and.index_season<1)then + if(patch%is_fates(pi))then + index_season = canopystate_inst%wesley_season_index_patch(pi) + else + index_season = 1 !set arbitrary seson for bare ground. + endif + + else ! not fates if (index_season<0) then if (elai(pi) < (minlai+0.05_r8*(maxlai-minlai))) then @@ -484,7 +492,6 @@ subroutine depvel_compute( bounds, & ! correction for frost cts = 1000._r8*exp( -tc - 4._r8 ) - !ground resistance rgsx(ispec) = 1._r8/((heff(ispec)/(1.e5_r8*(rgss(index_season,wesveg)+cts))) + & (foxd(ispec)/(rgso(index_season,wesveg)+cts))) @@ -492,6 +499,7 @@ subroutine depvel_compute( bounds, & !------------------------------------------------------------------------------------- ! special case for H2 and CO;; CH4 is set ot a fraction of dv(H2) !------------------------------------------------------------------------------------- + if( ispec == index_h2 .or. ispec == index_co .or. ispec == index_ch4 ) then if( ispec == index_co ) then diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index cd93372529..4285ba7e14 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -481,7 +481,7 @@ subroutine initialize2(ni,nj) ! Also for FATES with Dry-Deposition on as well (see above) ! For now don't allow for dry-deposition with full fates ! because of issues in #1044 EBK Jun/17/2022 - if( use_fates_nocomp .or. (.not. use_fates )) then + if( use_fates_sp .or. (.not. use_fates )) then if (masterproc) then write(iulog,'(a)')'Initializing Satellite Phenology' end if @@ -703,7 +703,8 @@ subroutine initialize2(ni,nj) ! Call interpMonthlyVeg for dry-deposition so that mlaidiff will be calculated ! This needs to be done even if FATES, CN or CNDV is on! call interpMonthlyVeg(bounds_proc, canopystate_inst) - elseif ( use_fates_sp ) then + endif + if ( use_fates_sp ) then ! If fates has satellite phenology enabled, get the monthly veg values ! prior to the first call to SatellitePhenology() call interpMonthlyVeg(bounds_proc, canopystate_inst) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 9572f21b9b..92b49624f3 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -1485,8 +1485,8 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & z0m => canopystate_inst%z0m_patch , & ! Output: [real(r8) (:) ] momentum roughness length (m) displa => canopystate_inst%displa_patch, & dleaf_patch => canopystate_inst%dleaf_patch, & - wesley_pft_index_patch => canopystate_inst%wesley_pft_index_patch, & - drydep_season_patch => canopystate_inst%drydep_season_patch, & + wesley_veg_index_patch => canopystate_inst%wesley_veg_index_patch, & + wesley_season_index_patch => canopystate_inst%wesley_season_index_patch, & snow_depth => waterdiagnosticbulk_inst%snow_depth_col, & frac_sno_eff => waterdiagnosticbulk_inst%frac_sno_eff_col, & frac_veg_nosno_alb => canopystate_inst%frac_veg_nosno_alb_patch) @@ -1610,8 +1610,8 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & z0m(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 displa(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 dleaf_patch(col%patchi(c)+1:col%patchf(c)) = 0.0_r8 - wesley_pft_index_patch(col%patchi(c)+1:col%patchf(c)) = 0 - drydep_season_patch(col%patchi(c)+1:col%patchf(c)) = 0 + wesley_veg_index_patch(col%patchi(c)+1:col%patchf(c)) = 0 + wesley_season_index_patch(col%patchi(c)+1:col%patchf(c)) = 0 frac_veg_nosno_alb(col%patchi(c):col%patchf(c)) = 0.0_r8 ! Set the bareground patch indicator @@ -1673,8 +1673,8 @@ subroutine wrap_update_hlmfates_dyn(this, nc, bounds_clump, & z0m(p) = this%fates(nc)%bc_out(s)%z0m_pa(ifp) displa(p) = this%fates(nc)%bc_out(s)%displa_pa(ifp) dleaf_patch(p) = this%fates(nc)%bc_out(s)%dleaf_pa(ifp) - wesley_pft_index_patch(p) = this%fates(nc)%bc_out(s)%wesley_pft_label_pa(ifp) - drydep_season_patch(p) = this%fates(nc)%bc_out(s)%drydep_season_pa(ifp) + wesley_veg_index_patch(p) = this%fates(nc)%bc_out(s)%wesley_pft_label_pa(ifp) + wesley_season_index_patch(p) = this%fates(nc)%bc_out(s)%drydep_season_pa(ifp) end do ! veg pach if(abs(areacheck - 1.0_r8).gt.1.e-9_r8)then From 2e4293d1281dbac04684488e75b4c188c8387df0 Mon Sep 17 00:00:00 2001 From: rosiealice Date: Mon, 14 Oct 2024 15:46:30 +0200 Subject: [PATCH 10/11] add checks for sensible sason index and wesley vegetation type in drydep --- src/biogeochem/DryDepVelocity.F90 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/biogeochem/DryDepVelocity.F90 b/src/biogeochem/DryDepVelocity.F90 index 7268a6c65f..c8bacb97ee 100644 --- a/src/biogeochem/DryDepVelocity.F90 +++ b/src/biogeochem/DryDepVelocity.F90 @@ -364,10 +364,15 @@ subroutine depvel_compute( bounds, & if(patch%is_fates(pi))then wesveg = canopystate_inst%wesley_veg_index_patch(pi) else - wesveg = 8 + wesveg = 8 !make bare ground for non-fates patches. Some of these are overwritten below. endif endif + if(wesveg<0 .or. wesveg>1 )then + call endrun(subgrid_index=pi, subgrid_level=subgrid_level_patch, & + msg='ERROR: No sensible Wesley vegetation type'//& + errMsg(sourcefile, __LINE__)) + endif ! create seasonality index used to index wesely data tables from LAI, Bascially !if elai is between max lai from input data and half that max the index_season=1 @@ -385,11 +390,12 @@ subroutine depvel_compute( bounds, & ! 4 - Winter, snow on ground and subfreezing ! 5 - Transitional spring with partially green short annuals - if(.not. use_fates)then + if(.not. use_fates)then !for non-FATES runs we use satellite phenology to choose the season for the ressistance parameters. !mlaidiff=jan-feb minlai=minval(annlai(:,pi)) maxlai=maxval(annlai(:,pi)) - endif + endif + index_season = -1 if ( lun%itype(l) /= istsoil )then @@ -412,11 +418,11 @@ subroutine depvel_compute( bounds, & index_season = 1 endif - if(use_fates.and.index_season<1)then + if(use_fates.and.index_season<1)then if(patch%is_fates(pi))then index_season = canopystate_inst%wesley_season_index_patch(pi) else - index_season = 1 !set arbitrary seson for bare ground. + index_season = 2 !set intermediate spring seson for bare ground. (as for urban) endif else ! not fates @@ -439,7 +445,7 @@ subroutine depvel_compute( bounds, & endif ! use_fates - if (index_season<0) then + if (index_season<0.or.index_season>5) then call endrun('ERROR: not able to determine season'//errmsg(sourcefile, __LINE__)) endif From 7ccafa012f2c791790092f3ad35802037ebb7c1c Mon Sep 17 00:00:00 2001 From: Rosie Fisher Date: Tue, 15 Oct 2024 10:46:30 +0200 Subject: [PATCH 11/11] Update .gitmodules to point to drydep fates branch --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 402ffcadf8..f792b3cfb9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,8 +27,8 @@ # [submodule "fates"] path = src/fates -url = https://github.com/NGEET/fates -fxtag = sci.1.78.2_api.36.0.0 +url = https://github.com/rosiealice/fates +fxtag = drydep_main fxrequired = AlwaysRequired # Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed fxDONOTUSEurl = https://github.com/NCAR/fates-release