Skip to content

Commit 1dbab6a

Browse files
odombrokvrigor
authored andcommitted
Fix orchard rotation carbon balance error
1 parent cbf5e76 commit 1dbab6a

5 files changed

Lines changed: 25 additions & 34 deletions

File tree

src/clm5/biogeochem/CNCIsoFluxMod.F90

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module CNCIsoFluxMod
1818
use SoilBiogeochemCarbonFluxType , only : soilbiogeochem_carbonflux_type
1919
use ColumnType , only : col
2020
use PatchType , only : patch
21-
use clm_varctl , only : use_crop, iulog
21+
use clm_varctl , only : use_crop
2222
use clm_varctl , only : use_grainproduct
2323
!
2424
implicit none
@@ -1503,7 +1503,6 @@ subroutine CNCIsoHarvestPftToColumn (num_soilc, filter_soilc, &
15031503
hrv_livecrootc_to_litter(p) * wtcol(p) * croot_prof(p,j)
15041504
harvest_c_to_cwdc(c,j) = harvest_c_to_cwdc(c,j) + &
15051505
hrv_deadcrootc_to_litter(p) * wtcol(p) * croot_prof(p,j)
1506-
15071506
! storage harvest mortality carbon fluxes
15081507
harvest_c_to_litr_met_c(c,j) = harvest_c_to_litr_met_c(c,j) + &
15091508
hrv_leafc_storage_to_litter(p) * wtcol(p) * leaf_prof(p,j)

src/clm5/biogeochem/CNCStateUpdate1Mod.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ subroutine CStateUpdateDynPatch(bounds, num_soilc_with_inactive, filter_soilc_wi
8383
do g = bounds%begg, bounds%endg
8484
cs_veg%seedc_grc(g) = cs_veg%seedc_grc(g) - cf_veg%dwt_seedc_to_leaf_grc(g) * dt
8585
cs_veg%seedc_grc(g) = cs_veg%seedc_grc(g) - cf_veg%dwt_seedc_to_deadstem_grc(g) * dt
86-
write(iulog,*) 'dwt_seedc is calculated',cs_veg%seedc_grc(g)
8786
end do
8887

8988
end if
@@ -523,7 +522,6 @@ subroutine CStateUpdate1( num_soilc, filter_soilc, num_soilp, filter_soilp, &
523522
cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) - cf_veg%grain_xsmr_patch(p)*dt
524523
end if
525524
if (harvdate(p) < 999) then ! beginning at harvest, send to atm
526-
write(iulog,*) 'entering harvdate < 999 in CNCStateUpdate1Mod, date is:', harvdate(p)
527525
! TODO (mv, 11-02-2014) the following lines are why the cf_veg is
528526
! an intent(inout)
529527
! fluxes should not be updated in this module - not sure where

src/clm5/biogeochem/CNCStateUpdate2Mod.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ subroutine CStateUpdate2h(num_soilc, filter_soilc, num_soilp, filter_soilp, &
178178
cs_soil%decomp_cpools_vr_col(c,j,i_lig_lit) + cf_veg%harvest_c_to_litr_lig_c_col(c,j) * dt
179179
cs_soil%decomp_cpools_vr_col(c,j,i_cwd) = &
180180
cs_soil%decomp_cpools_vr_col(c,j,i_cwd) + cf_veg%harvest_c_to_cwdc_col(c,j) * dt
181-
182181
! wood to product pools - states updated in CNProducts
183182
end do
184183
end do
@@ -201,7 +200,6 @@ subroutine CStateUpdate2h(num_soilc, filter_soilc, num_soilp, filter_soilp, &
201200
- cf_veg%hrv_livecrootc_to_litter_patch(p) * dt
202201
cs_veg%deadcrootc_patch(p) = cs_veg%deadcrootc_patch(p) &
203202
- cf_veg%hrv_deadcrootc_to_litter_patch(p) * dt
204-
205203
! xsmrpool
206204
cs_veg%xsmrpool_patch(p) = cs_veg%xsmrpool_patch(p) &
207205
- cf_veg%hrv_xsmrpool_to_atm_patch(p) * dt

src/clm5/biogeochem/CNPhenologyMod.F90

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ subroutine CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
326326
cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst)
327327

328328
call CNOffsetLitterfall(num_soilp, filter_soilp, &
329-
crop_inst,cnveg_state_inst, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst)
329+
crop_inst,cnveg_state_inst, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst,soilbiogeochem_state_inst,num_soilc, filter_soilc)
330330

331331
call CNBackgroundLitterfall(num_soilp, filter_soilp, &
332332
cnveg_state_inst, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst)
@@ -339,9 +339,9 @@ subroutine CNPhenology (bounds, num_soilc, filter_soilc, num_soilp, &
339339

340340
! gather all patch-level litterfall fluxes to the column for litter C and N inputs
341341

342-
call CNLitterToColumn(bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, &
343-
cnveg_state_inst,soilbiogeochem_state_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, &
344-
cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, leaf_prof_patch(bounds%begp:bounds%endp,1:nlevdecomp_full), &
342+
call CNLitterToColumn(bounds, num_soilc, filter_soilc, &
343+
cnveg_state_inst,cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, &
344+
leaf_prof_patch(bounds%begp:bounds%endp,1:nlevdecomp_full), &
345345
froot_prof_patch(bounds%begp:bounds%endp,1:nlevdecomp_full), stem_prof_patch(bounds%begp:bounds%endp,1:nlevdecomp_full))
346346
else
347347
call endrun( 'bad phase' )
@@ -2015,7 +2015,6 @@ subroutine FruitTreePhenology(num_pcropp, filter_pcropp , &
20152015
if (tlai(p) <= 0._r8 .and. harvest_flag(p) == 0._r8) then ! plant never emerged or died
20162016
croplive(p) = .false.
20172017
if (harvdate(p) >= NOT_Harvested) harvdate(p) = jday
2018-
write(iulog,*) 'WARNING: croplive is set to false and harvdate to jday:',harvdate(p)
20192018
crop_seedc_to_leaf(c) = crop_seedc_to_leaf(c) - leafc_xfer(p)/dt
20202019
crop_seedc_to_froot(c) = crop_seedc_to_froot(c) - frootc_xfer(p)/dt
20212020
crop_seedn_to_leaf(c) = crop_seedn_to_leaf(c) - leafn_xfer(p)/dt
@@ -3068,7 +3067,7 @@ end subroutine CNOnsetGrowth
30683067

30693068
!-----------------------------------------------------------------------
30703069
subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
3071-
crop_inst,cnveg_state_inst, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst)
3070+
crop_inst,cnveg_state_inst, cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, soilbiogeochem_state_inst,num_soilc,filter_soilc)
30723071
!
30733072
! !DESCRIPTION:
30743073
! Determines the flux of C and N from displayed pools to litter
@@ -3079,6 +3078,7 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
30793078
use CNSharedParamsMod, only : use_fun
30803079
use clm_varctl , only : CNratio_floating
30813080
use clm_time_manager , only : get_curr_date, get_curr_calday, get_days_per_year, is_beg_curr_year
3081+
use dynHarvestMod , only : CNHarvestPftToColumn
30823082
!
30833083
! !ARGUMENTS:
30843084
integer , intent(in) :: num_soilp ! number of soil patches in filter
@@ -3089,6 +3089,9 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
30893089
type(cnveg_nitrogenstate_type), intent(in) :: cnveg_nitrogenstate_inst
30903090
type(cnveg_carbonflux_type) , intent(inout) :: cnveg_carbonflux_inst
30913091
type(cnveg_nitrogenflux_type) , intent(inout) :: cnveg_nitrogenflux_inst
3092+
type(soilbiogeochem_state_type) , intent(in) :: soilbiogeochem_state_inst
3093+
integer , intent(in) :: num_soilc ! number of soil columns in filter
3094+
integer , intent(in) :: filter_soilc(:) ! filter for soil columns
30923095
!
30933096
! !LOCAL VARIABLES:
30943097
integer :: p, c ! indices
@@ -3272,12 +3275,12 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
32723275
if (perennial(ivt(p)) == 1._r8) then
32733276
if (grainc(p) > 0._r8) then
32743277
t1 = 1.0_r8 / dt
3275-
! replenish seed deficit (needed to balance seedc used for orchard establishment
3278+
! replenish seed deficit (needed to balance seedc used for orchard establishment)
32763279
grainc_to_seed(p) = t1 * min(-cropseedc_deficit(p), grainc(p))
32773280
grainn_to_seed(p) = t1 * min(-cropseedn_deficit(p), grainn(p))
32783281
! send remaining grainc to food product pool
3279-
grainc_to_food(p) = t1 * grainc(p) + cpool_to_grainc(p)
3280-
grainn_to_food(p) = t1 * grainn(p) + npool_to_grainn(p)
3282+
grainc_to_food(p) = t1 * grainc(p) + cpool_to_grainc(p) - grainc_to_seed(p)
3283+
grainn_to_food(p) = t1 * grainn(p) + npool_to_grainn(p) - grainn_to_seed(p)
32813284

32823285
end if
32833286
end if
@@ -3425,15 +3428,14 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
34253428
! lifespan is reached
34263429
! (introduced in CLM-Palm (Fan et al. 2015), and adopted here by O.Dombrowski)
34273430
if (offset2_flag(p) == 1._r8 .and. perennial(ivt(p)) == 1._r8) then
3428-
34293431
! Apply all harvest at the start of the year, otherwise will get
34303432
! error because of non zero delta mid-year for dribbler
34313433
! hrv_xsmrpool_to_atm_c
34323434
if (is_beg_curr_year()) then
3433-
croplive = .false.
3435+
croplive(p) = .false.
34343436
t1 = 1.0_r8 / dt
34353437
else
3436-
croplive = .true.
3438+
croplive(p) = .true.
34373439
t1 = 0._r8
34383440
end if
34393441
! clear-cut carbon fluxes, remove all displayed/storage/transfer pools
@@ -3487,6 +3489,13 @@ subroutine CNOffsetLitterfall (num_soilp, filter_soilp, &
34873489
! retransn pools
34883490
hrv_retransn_to_litter(p) = retransn(p) * t1
34893491

3492+
! summarize all fuxes at orchard rotation to column level (added by O. Dombrowski adapted based on CLM-Palm (Fan et al.(2015))
3493+
if (.not. croplive(p)) then
3494+
call CNHarvestPftToColumn (num_soilc, filter_soilc, &
3495+
soilbiogeochem_state_inst, CNVeg_carbonflux_inst, cnveg_nitrogenflux_inst)
3496+
end if
3497+
3498+
34903499
end if ! end orchard rotation
34913500
end do ! end patch loop
34923501

@@ -3788,9 +3797,9 @@ subroutine CNGrainToProductPools(bounds, num_soilp, filter_soilp, num_soilc, fil
37883797
end subroutine CNGrainToProductPools
37893798

37903799
!-----------------------------------------------------------------------
3791-
subroutine CNLitterToColumn (bounds, num_soilc, filter_soilc, num_soilp, filter_soilp, &
3792-
cnveg_state_inst,soilbiogeochem_state_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, &
3793-
cnveg_carbonstate_inst, cnveg_nitrogenstate_inst, leaf_prof_patch, froot_prof_patch, stem_prof_patch)
3800+
subroutine CNLitterToColumn (bounds, num_soilc, filter_soilc, &
3801+
cnveg_state_inst, cnveg_carbonflux_inst, cnveg_nitrogenflux_inst, &
3802+
leaf_prof_patch, froot_prof_patch, stem_prof_patch)
37943803
!
37953804
! !DESCRIPTION:
37963805
! called at the end of cn_phenology to gather all patch-level litterfall fluxes
@@ -3800,20 +3809,14 @@ subroutine CNLitterToColumn (bounds, num_soilc, filter_soilc, num_soilp, filter_
38003809
use clm_varpar , only : max_patch_per_col,maxpatch_pft, nlevdecomp
38013810
use pftconMod , only : npcropmin
38023811
use clm_varctl , only : use_grainproduct
3803-
use dynHarvestMod , only: CNHarvestPftToColumn
38043812
!
38053813
! !ARGUMENTS:
38063814
type(bounds_type) , intent(in) :: bounds
38073815
integer , intent(in) :: num_soilc ! number of soil columns in filter
38083816
integer , intent(in) :: filter_soilc(:) ! filter for soil columns
3809-
integer , intent(in) :: num_soilp ! number of soil patches in filter
3810-
integer , intent(in) :: filter_soilp(:) ! patch filter for soil points
38113817
type(cnveg_state_type) , intent(in) :: cnveg_state_inst
38123818
type(cnveg_carbonflux_type) , intent(inout) :: cnveg_carbonflux_inst
38133819
type(cnveg_nitrogenflux_type) , intent(inout) :: cnveg_nitrogenflux_inst
3814-
type(cnveg_carbonstate_type) , intent(in) :: cnveg_carbonstate_inst
3815-
type(cnveg_nitrogenstate_type) , intent(in) :: cnveg_nitrogenstate_inst
3816-
type(soilbiogeochem_state_type) , intent(in) :: soilbiogeochem_state_inst
38173820
real(r8) , intent(in) :: leaf_prof_patch(bounds%begp:,1:)
38183821
real(r8) , intent(in) :: froot_prof_patch(bounds%begp:,1:)
38193822
real(r8) , intent(in) :: stem_prof_patch(bounds%begp:,1:)
@@ -4052,12 +4055,6 @@ subroutine CNLitterToColumn (bounds, num_soilc, filter_soilc, num_soilp, filter_
40524055

40534056
end do
40544057

4055-
! summarize all fuxes at orchard rotation to column level (added by O. Dombrowski adapted based on CLM-Palm (Fan et al.(2015))
4056-
if ( perennial(ivt(p)) == 1._r8 .and. offset2_flag(p) == 1._r8) then
4057-
call CNHarvestPftToColumn (num_soilc, filter_soilc, &
4058-
soilbiogeochem_state_inst, CNVeg_carbonflux_inst, cnveg_nitrogenflux_inst)
4059-
end if
4060-
40614058
end associate
40624059

40634060
end subroutine CNLitterToColumn

src/clm5/biogeochem/dynHarvestMod.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ subroutine CNHarvestPftToColumn (num_soilc, filter_soilc, &
523523
hrv_livecrootc_to_litter(p) * wtcol(p) * croot_prof(p,j)
524524
harvest_c_to_cwdc(c,j) = harvest_c_to_cwdc(c,j) + &
525525
hrv_deadcrootc_to_litter(p) * wtcol(p) * croot_prof(p,j)
526-
527526
! storage harvest mortality carbon fluxes
528527
harvest_c_to_litr_met_c(c,j) = harvest_c_to_litr_met_c(c,j) + &
529528
hrv_leafc_storage_to_litter(p) * wtcol(p) * leaf_prof(p,j)

0 commit comments

Comments
 (0)