From 155853162d100a33f73856e2f6644846426e2878 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 14 Jun 2022 10:04:44 -0600 Subject: [PATCH 1/9] Modify the SP mode InterpMonthly call so will work with dry-deposition and FATES, and add comments to try to explain --- src/main/clm_driver.F90 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 1d6101fdf4..1b06c4ac31 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -221,10 +221,12 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ============================================================================ ! Specified phenology + ! Done in SP mode, FATES-SP mode and also when dry-deposition is active ! ============================================================================ if (use_cn) then ! For dry-deposition need to call CLMSP so that mlaidiff is obtained + ! NOTE: This is also true of FATES below if ( n_drydep > 0 .and. drydep_method == DD_XLND ) then call t_startf('interpMonthlyVeg') call interpMonthlyVeg(bounds_proc, canopystate_inst) @@ -233,22 +235,25 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro elseif(use_fates) then - ! FATES does not use any leaf/stem/htop data unless in satphen mode - if ( use_fates_sp) then + ! For FATES-Specified phenology mode interpolate the weights for + ! time-interpolation of monthly vegetation data (as in SP mode below) + ! Also for FATES with dry-deposition as above need to call CLMSP so that mlaidiff is obtained + if ( use_fates_sp .or. (n_drydep > 0 .and. drydep_method == DD_XLND ) )then call t_startf('interpMonthlyVeg') call interpMonthlyVeg(bounds_proc, canopystate_inst) call t_stopf('interpMonthlyVeg') end if - + else - + ! Determine weights for time interpolation of monthly vegetation data. ! This also determines whether it is time to read new monthly vegetation and ! obtain updated leaf area index [mlai1,mlai2], stem area index [msai1,msai2], ! vegetation top [mhvt1,mhvt2] and vegetation bottom [mhvb1,mhvb2]. The ! weights obtained here are used in subroutine SatellitePhenology to obtain time ! interpolated values. - if ( doalb .or. ( n_drydep > 0 .and. drydep_method == DD_XLND ) )then + ! This is also done for FATES-SP mode above + if (doalb .or. ( n_drydep > 0 .and. drydep_method == DD_XLND ) )then call t_startf('interpMonthlyVeg') call interpMonthlyVeg(bounds_proc, canopystate_inst) call t_stopf('interpMonthlyVeg') @@ -256,7 +261,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro end if - ! ================================================================================== ! Determine decomp vertical profiles ! From f418d198ecac60369f9f22f92aba17f6ce0efece Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 14 Jun 2022 10:38:49 -0600 Subject: [PATCH 2/9] readAnnualVeg if dry-deposition even if FATES is on, and remove some trailing blanks --- src/main/clm_initializeMod.F90 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index c22b5e12ff..27bc845790 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -41,7 +41,7 @@ module clm_initializeMod integer :: actual_numcft ! numcft from sfc dataset integer :: actual_numpft ! numpft from sfc dataset - + !----------------------------------------------------------------------- contains !----------------------------------------------------------------------- @@ -105,7 +105,7 @@ subroutine initialize1(dtime) if(use_fates) then call CLMFatesGlobals1(actual_numpft, actual_numcft, actual_maxsoil_patches) end if - + call clm_varpar_init(actual_maxsoil_patches, actual_numpft, actual_numcft) call decomp_cascade_par_init( NLFilename ) call clm_varcon_init( IsSimpleBuildTemp() ) @@ -228,7 +228,7 @@ subroutine initialize2(ni,nj) allocate (haslake (begg:endg )) allocate (pct_urban_max(begg:endg, numurbl )) allocate (wt_nat_patch (begg:endg, natpft_lb:natpft_ub )) - + ! Read list of Patches and their corresponding parameter values ! Independent of model resolution, Needs to stay before surfrd_get_data call pftcon%Init() @@ -250,9 +250,9 @@ subroutine initialize2(ni,nj) ! to allocate space) ! This also sets up various global constants in FATES ! ------------------------------------------------------------------------ - + call CLMFatesGlobals2() - + end if ! Determine decomposition of subgrid scale landunits, columns, patches @@ -439,9 +439,9 @@ subroutine initialize2(ni,nj) if ( use_c13 .and. use_c13_timeseries ) then call C13_init_TimeSeries() end if - + else ! FATES OR Satellite phenology - + if(use_fates_sp .or. .not.use_fates)then call SatellitePhenologyInit(bounds_proc) end if @@ -607,9 +607,9 @@ subroutine initialize2(ni,nj) end if ! Read monthly vegetation - ! Even if CN is on, and dry-deposition is active, read CLMSP annual 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 .and. drydep_method == DD_XLND .and. .not.use_fates )then + if ( n_drydep > 0 .and. drydep_method == DD_XLND )then call readAnnualVegetation(bounds_proc, canopystate_inst) if (nsrest == nsrStartup .and. finidat /= ' ') then ! Call interpMonthlyVeg for dry-deposition so that mlaidiff will be calculated @@ -621,7 +621,7 @@ subroutine initialize2(ni,nj) elseif ( use_fates_sp ) then call interpMonthlyVeg(bounds_proc, canopystate_inst) end if - + ! Determine gridcell averaged properties to send to atm if (nsrest == nsrStartup) then call t_startf('init_map2gc') From 635cb1e77ec08a82f14be0ed8906e78933511e11 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 14 Jun 2022 16:21:22 -0600 Subject: [PATCH 3/9] Make sure if FATES and DryDep is on SatellitePhenologyInit will be done, remove extra logic for IntepMonthlyVegetation about startup and cold-start as doesn't matter if it's done an extra time --- src/main/clm_initializeMod.F90 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 27bc845790..6b8402062b 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -442,7 +442,7 @@ subroutine initialize2(ni,nj) else ! FATES OR Satellite phenology - if(use_fates_sp .or. .not.use_fates)then + if(use_fates_sp .or. (.not.use_cn) .or. (n_drydep > 0 .and. drydep_method == DD_XLND) )then call SatellitePhenologyInit(bounds_proc) end if @@ -611,11 +611,9 @@ subroutine initialize2(ni,nj) ! to get estimates of monthly LAI if ( n_drydep > 0 .and. drydep_method == DD_XLND )then call readAnnualVegetation(bounds_proc, canopystate_inst) - if (nsrest == nsrStartup .and. finidat /= ' ') then - ! Call interpMonthlyVeg for dry-deposition so that mlaidiff will be calculated - ! This needs to be done even if CN or CNDV is on! - call interpMonthlyVeg(bounds_proc, canopystate_inst) - end if + ! Call interpMonthlyVeg for dry-deposition so that mlaidiff will be calculated + ! This needs to be done even if CN or CNDV is on! + call interpMonthlyVeg(bounds_proc, canopystate_inst) ! If fates has satellite phenology enabled, get the monthly veg values ! prior to the first call to SatellitePhenology() elseif ( use_fates_sp ) then From 83433df4ed3f24ef503a8e367d6a9153ad0bb1f4 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Tue, 14 Jun 2022 16:26:03 -0600 Subject: [PATCH 4/9] Work on comments a bit --- src/main/clm_initializeMod.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 6b8402062b..4d8258ee1b 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -431,6 +431,7 @@ subroutine initialize2(ni,nj) if (n_drydep > 0 .and. drydep_method == DD_XLND) then ! Must do this also when drydeposition is used so that estimates of monthly ! differences in LAI can be computed + ! Also do this for FATES see below call SatellitePhenologyInit(bounds_proc) end if if ( use_c14 .and. use_c14_bombspike ) then @@ -442,6 +443,8 @@ subroutine initialize2(ni,nj) else ! FATES OR Satellite phenology + ! For SP FATES-SP Initialize SP + ! Also for FATES with Dry-Deposition on as well (see above) if(use_fates_sp .or. (.not.use_cn) .or. (n_drydep > 0 .and. drydep_method == DD_XLND) )then call SatellitePhenologyInit(bounds_proc) end if From d3fa22b8ba723c992063a5541f28a6aa37749192 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 17 Jun 2022 14:11:14 -0600 Subject: [PATCH 5/9] Comment out the dry-dep change and add a note about it with the issue regarding it --- src/main/clm_driver.F90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 1b06c4ac31..68b476313a 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -238,7 +238,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! For FATES-Specified phenology mode interpolate the weights for ! time-interpolation of monthly vegetation data (as in SP mode below) ! Also for FATES with dry-deposition as above need to call CLMSP so that mlaidiff is obtained - if ( use_fates_sp .or. (n_drydep > 0 .and. drydep_method == DD_XLND ) )then + !if ( use_fates_sp .or. (n_drydep > 0 .and. drydep_method == DD_XLND ) ) then ! Replace this when we have dry-deposition working + ! For now don't allow for dry-deposition because of issues in #1044 EBK Jun/17/2022 + if ( use_fates_sp ) then call t_startf('interpMonthlyVeg') call interpMonthlyVeg(bounds_proc, canopystate_inst) call t_stopf('interpMonthlyVeg') @@ -253,7 +255,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! weights obtained here are used in subroutine SatellitePhenology to obtain time ! interpolated values. ! This is also done for FATES-SP mode above - if (doalb .or. ( n_drydep > 0 .and. drydep_method == DD_XLND ) )then + if ( doalb .or. ( n_drydep > 0 .and. drydep_method == DD_XLND ) )then call t_startf('interpMonthlyVeg') call interpMonthlyVeg(bounds_proc, canopystate_inst) call t_stopf('interpMonthlyVeg') From 37f25fb6b9f1cb9f1fde6ff91aff0707267e2036 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 17 Jun 2022 14:25:34 -0600 Subject: [PATCH 6/9] Change if statements about drydep back to how they were before, but add a commented out line about what the expected correct line should be --- src/main/clm_driver.F90 | 2 +- src/main/clm_initializeMod.F90 | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/clm_driver.F90 b/src/main/clm_driver.F90 index 68b476313a..b9a7bc7f36 100644 --- a/src/main/clm_driver.F90 +++ b/src/main/clm_driver.F90 @@ -238,7 +238,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! For FATES-Specified phenology mode interpolate the weights for ! time-interpolation of monthly vegetation data (as in SP mode below) ! Also for FATES with dry-deposition as above need to call CLMSP so that mlaidiff is obtained - !if ( use_fates_sp .or. (n_drydep > 0 .and. drydep_method == DD_XLND ) ) then ! Replace this when we have dry-deposition working + !if ( use_fates_sp .or. (n_drydep > 0 .and. drydep_method == DD_XLND ) ) then ! Replace with this when we have dry-deposition working ! For now don't allow for dry-deposition because of issues in #1044 EBK Jun/17/2022 if ( use_fates_sp ) then call t_startf('interpMonthlyVeg') diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index a1b83ea159..79b61ae656 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -445,7 +445,9 @@ subroutine initialize2(ni,nj) ! For SP FATES-SP Initialize SP ! Also for FATES with Dry-Deposition on as well (see above) - if(use_fates_sp .or. (.not.use_cn) .or. (n_drydep > 0 .and. drydep_method == DD_XLND) )then + !if(use_fates_sp .or. (.not.use_cn) .or. (n_drydep > 0 .and. drydep_method == DD_XLND) )then ! Replace with this when we have dry-deposition working + ! For now don't allow for dry-deposition because of issues in #1044 EBK Jun/17/2022 + if( use_fates_sp .or. .not. use_fates )then call SatellitePhenologyInit(bounds_proc) end if @@ -612,10 +614,12 @@ 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 .and. drydep_method == DD_XLND )then + !if ( n_drydep > 0 .and. drydep_method == DD_XLND )then ! Replace with this when we have dry-deposition working + ! For now don't allow for dry-deposition because of issues in #1044 EBK Jun/17/2022 + if ( n_drydep > 0 .and. drydep_method == DD_XLND .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 CN or CNDV is on! + ! This needs to be done even if FATES, CN or CNDV is on! call interpMonthlyVeg(bounds_proc, canopystate_inst) ! If fates has satellite phenology enabled, get the monthly veg values ! prior to the first call to SatellitePhenology() From 52e9ee1f4c8d31e1111469e8b7c2ad8b41596263 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 17 Jun 2022 14:43:30 -0600 Subject: [PATCH 7/9] Add a check that aborts if drydep or megan is on and FATES is on, outside of FATES-SP --- src/biogeochem/DryDepVelocity.F90 | 5 +++++ src/biogeochem/VOCEmissionMod.F90 | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/biogeochem/DryDepVelocity.F90 b/src/biogeochem/DryDepVelocity.F90 index 7646699ffa..dda6f8679f 100644 --- a/src/biogeochem/DryDepVelocity.F90 +++ b/src/biogeochem/DryDepVelocity.F90 @@ -103,9 +103,14 @@ Module DryDepVelocity !------------------------------------------------------------------------ subroutine Init(this, bounds) + use clm_varctl , only : use_fates, use_fates_sp class(drydepvel_type) :: this type(bounds_type), intent(in) :: bounds + if ( (.not. use_fates_sp) .and. (n_drydep > 0 .and. drydep_method == DD_XLND) )then + call endrun( msg='ERROR: Dry-deposition currently does NOT work with FATES outside of FATES-SP mode (see github issue #1044)'//& + errMsg(sourcefile, __LINE__)) + end if call this%InitAllocate(bounds) call this%InitHistory(bounds) diff --git a/src/biogeochem/VOCEmissionMod.F90 b/src/biogeochem/VOCEmissionMod.F90 index 88ae7c08cc..f1865af3b7 100644 --- a/src/biogeochem/VOCEmissionMod.F90 +++ b/src/biogeochem/VOCEmissionMod.F90 @@ -84,10 +84,15 @@ module VOCEmissionMod !------------------------------------------------------------------------ subroutine Init(this, bounds) + use clm_varctl , only : use_fates, use_fates_sp class(vocemis_type) :: this type(bounds_type), intent(in) :: bounds if ( shr_megan_mechcomps_n > 0) then + if ( use_fates .and. (.not. use_fates_sp) ) then + call endrun( msg='ERROR: MEGAN currently does NOT work with FATES outside of FATES-SP mode (see github issue #115)'//& + errMsg(sourcefile, __LINE__)) + end if call this%InitAllocate(bounds) call this%InitHistory(bounds) call this%InitCold(bounds) From b71d464efd21e471c12bbef4b430484903e7fc0e Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 17 Jun 2022 14:43:55 -0600 Subject: [PATCH 8/9] surfpft_lb and ub where required --- src/main/clm_initializeMod.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index 79b61ae656..b66424297a 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -127,6 +127,7 @@ subroutine initialize2(ni,nj) ! !USES: use clm_varcon , only : spval use clm_varpar , only : natpft_lb, natpft_ub, cft_lb, cft_ub, maxpatch_glc + use clm_varpar , only : surfpft_lb, surfpft_ub use clm_varpar , only : nlevsno use clm_varpar , only : natpft_size,cft_size use clm_varctl , only : fsurdat From 46e76976b8add2156dd724f7aa77b0d870687a9e Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 17 Jun 2022 14:52:30 -0600 Subject: [PATCH 9/9] This is required to get the FATES-SP drydep mode to work --- src/main/clm_initializeMod.F90 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index b66424297a..44ac50b27c 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -615,9 +615,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 .and. drydep_method == DD_XLND )then ! Replace with this when we have dry-deposition working - ! For now don't allow for dry-deposition because of issues in #1044 EBK Jun/17/2022 - if ( n_drydep > 0 .and. drydep_method == DD_XLND .and. .not. use_fates )then + if ( n_drydep > 0 .and. drydep_method == DD_XLND )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!