Skip to content

Commit

Permalink
Merge pull request #4 from ekluzek/fates_drydep_changes
Browse files Browse the repository at this point in the history
Fates drydep changes
  • Loading branch information
rgknox authored Jun 19, 2022
2 parents de1ca54 + 46e7697 commit fc73c8a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
5 changes: 5 additions & 0 deletions src/biogeochem/DryDepVelocity.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions src/biogeochem/VOCEmissionMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 11 additions & 5 deletions src/main/clm_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -233,21 +235,26 @@ 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 ! 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')
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.
! 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)
Expand All @@ -256,7 +263,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro

end if


! ==================================================================================
! Determine decomp vertical profiles
!
Expand Down
34 changes: 19 additions & 15 deletions src/main/clm_initializeMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module clm_initializeMod

integer :: actual_numcft ! numcft from sfc dataset
integer :: actual_numpft ! numpft from sfc dataset

!-----------------------------------------------------------------------
contains
!-----------------------------------------------------------------------
Expand Down Expand Up @@ -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() )
Expand All @@ -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
Expand Down Expand Up @@ -250,9 +251,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
Expand Down Expand Up @@ -431,6 +432,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
Expand All @@ -439,10 +441,14 @@ 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

! 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 ! 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

Expand Down Expand Up @@ -607,21 +613,19 @@ 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
! 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 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()
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')
Expand Down

0 comments on commit fc73c8a

Please sign in to comment.