@@ -97,6 +97,7 @@ subroutine InitAllocate(this, bounds)
9797
9898 allocate (this% actual_leafcn(bounds% begp:bounds% endp)) ; this% actual_leafcn(:) = nan
9999 allocate (this% actual_storage_leafcn(bounds% begp:bounds% endp)) ; this% actual_storage_leafcn(:) = nan
100+
100101 end subroutine InitAllocate
101102
102103 !- -----------------------------------------------------------------------
@@ -403,12 +404,14 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, &
403404
404405 ! set time steps
405406 dt = real ( get_step_size(), r8 )
407+
406408 ! patch loop to distribute the available N between the competing patches
407409 ! on the basis of relative demand, and allocate C and N to new growth and storage
408410
409411 do fp = 1 ,num_soilp
410412 p = filter_soilp(fp)
411413 c = patch% column(p)
414+
412415 ! set some local allocation variables
413416 f1 = froot_leaf(ivt(p))
414417 f2 = croot_stem(ivt(p))
@@ -517,6 +520,7 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, &
517520 ! transfer pools
518521
519522 nlc = plant_calloc(p) / c_allometry(p)
523+
520524 cpool_to_leafc(p) = nlc * fcur
521525 cpool_to_leafc_storage(p) = nlc * (1._r8 - fcur)
522526 cpool_to_frootc(p) = nlc * f1 * fcur
@@ -886,6 +890,8 @@ subroutine calc_plant_cn_alloc(this, bounds, num_soilp, filter_soilp, &
886890 + cpool_to_grainc_storage(p)
887891 end if
888892 cpool_to_gresp_storage(p) = gresp_storage * g1 * (1._r8 - g2)
893+
894+
889895 ! computing 1.) fractional N demand and 2.) N allocation after uptake for different plant parts
890896 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
891897 if (downreg_opt .eqv. .false. .AND. CN_partition_opt == 1 ) then
@@ -1594,11 +1600,13 @@ subroutine calc_plant_nitrogen_demand(this, bounds, num_soilp, filter_soilp, &
15941600
15951601 ! no allocation when available c is negative
15961602 availc(p) = max (availc(p),0.0_r8 )
1603+
15971604 ! test for an xsmrpool deficit
15981605 if (xsmrpool(p) < 0.0_r8 ) then
15991606 ! Running a deficit in the xsmrpool, so the first priority is to let
16001607 ! some availc from this timestep accumulate in xsmrpool.
16011608 ! Determine rate of recovery for xsmrpool deficit
1609+
16021610 xsmrpool_recover(p) = - xsmrpool(p)/ (dayscrecover* secspday)
16031611 if (xsmrpool_recover(p) < availc(p)) then
16041612 ! available carbon reduced by amount for xsmrpool recovery
0 commit comments