-
Notifications
You must be signed in to change notification settings - Fork 0
/
E3SMv1-FUN3.0.patch
11527 lines (11134 loc) · 657 KB
/
E3SMv1-FUN3.0.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -ruN /home/braghiere/E3SM_latest/E3SM/components/clm/src/biogeochem/AllocationMod.F90 /home/braghiere/models_v3.2/E3SM_global/components/clm/src/biogeochem/AllocationMod.F90
--- /home/braghiere/E3SM_latest/E3SM/components/clm/src/biogeochem/AllocationMod.F90 2020-06-10 13:56:35.013392274 -0400
+++ /home/braghiere/models_v3.2/E3SM_global/components/clm/src/biogeochem/AllocationMod.F90 2020-07-30 20:38:47.951609989 -0400
@@ -9,7 +9,7 @@
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_log_mod , only : errMsg => shr_log_errMsg
use clm_varcon , only : dzsoi_decomp
- use clm_varctl , only : use_c13, use_c14, use_nitrif_denitrif, spinup_state
+ use clm_varctl , only : use_c13, use_c14, use_nitrif_denitrif, spinup_state, use_fun, use_funp
use clm_varctl , only : nyears_ad_carbon_only
use abortutils , only : endrun
use decompMod , only : bounds_type
@@ -41,6 +41,14 @@
use WaterStateType , only : waterstate_type
use clm_varctl , only : NFIX_PTASE_plant
+ ! used variables for FUN
+ use SoilHydrologyType , only : soilhydrology_type
+ use TemperatureType , only : temperature_type
+ use WaterFluxType , only : waterflux_type
+ use perf_mod , only : t_startf, t_stopf
+ use CNFUNMod , only : CNFUN, CNFUNInit
+ use subgridAveMod , only : p2c_2d
+ !
!
implicit none
save
@@ -330,6 +338,7 @@
! !! add phosphorus -X.YANG
type(phosphorusstate_type) , intent(inout) :: phosphorusstate_vars
type(phosphorusflux_type) , intent(inout) :: phosphorusflux_vars
+
!
! !LOCAL VARIABLES:
real(r8) :: compet_decomp_no3 ! (unitless) relative competitiveness of immobilizers for NO3 for BGC module
@@ -651,10 +660,15 @@
smin_no3_to_plant_patch => veg_nf%smin_no3_to_plant , &
sminn_to_plant_patch => veg_nf%sminn_to_plant , &
pnup_pfrootc => veg_ns%pnup_pfrootc , &
- leafn => veg_ns%leafn &
+ leafn => veg_ns%leafn , &
+ stress_decid => veg_vp%stress_decid , & ! Input: binary flag for stress
+ season_decid => veg_vp%season_decid , & ! Input: binary flag for seasonal
+ ! -deciduous leaf habit (0 or 1)
+ perecm => veg_vp%perecm & ! Input: binary flag for seasonal
+ ! -deciduous leaf habit (0 or 1)
+
)
-
sminp_to_plant_patch => veg_pf%sminp_to_plant
secondp_vr => col_ps%secondp_vr
leafp => veg_ps%leafp
@@ -681,6 +695,8 @@
plant_n_uptake_flux => col_nf%plant_n_uptake_flux
plant_p_uptake_flux => col_pf%plant_p_uptake_flux
+
+
! set time steps
dt = real( get_step_size(), r8 )
@@ -741,6 +757,8 @@
! carbon flux available for allocation
availc(p) = gpp(p) - mr
+
+
! new code added for isotope calculations, 7/1/05, PET
! If mr > gpp, then some mr comes from gpp, the rest comes from
! cpool (xsmr)
@@ -783,6 +801,8 @@
cpool_to_xsmrpool(p) = xsmrpool_recover(p)
end if
+
+
f1 = froot_leaf(ivt(p))
f2 = croot_stem(ivt(p))
@@ -908,6 +928,7 @@
if (ivt(p) /= nsoybean .or. astem(p) == astemf(ivt(p)) .or. peaklai(p) == 1._r8) then
if (grain_flag(p) == 0._r8) then
+ if(.not.use_fun) then
t1 = 1 / dt
leafn_to_retransn(p) = t1 * ((leafc(p) / leafcn(ivt(p))) - (leafc(p) / &
fleafcn(ivt(p))))
@@ -918,6 +939,14 @@
frootn_to_retransn(p) = t1 * ((frootc(p) / frootcn(ivt(p))) - (frootc(p) / &
ffrootcn(ivt(p))))
end if
+ else !leafn retrans flux is handled in phenology
+ frootn_to_retransn(p) = 0._r8
+ livestemn_to_retransn(p) = 0._r8
+ !if(use_funp)then
+ ! frootp_to_retransp(p) = 0._r8
+ ! livestemp_to_retransp(p) = 0._r8
+ !end if
+ end if !fun
grain_flag(p) = 1._r8
end if
end if
@@ -948,6 +977,7 @@
! determine N requirements
! determine P requirements -X. YANG
+ if(.not.use_fun)then
if (woody(ivt(p)) == 1.0_r8) then
c_allometry(p) = (1._r8+g1)*(1._r8+f1+f3*(1._r8+f2))
n_allometry(p) = 1._r8/cnl + f1/cnfr + (f3*f4*(1._r8+f2))/cnlw + &
@@ -969,6 +999,30 @@
n_allometry(p) = 1._r8/cnl + f1/cnfr
p_allometry(p) = 1._r8/cpl + f1/cpfr
end if
+ else !no FUN.
+ if (woody(ivt(p)) == 1.0_r8) then
+ c_allometry(p) = (1._r8)*(1._r8+f1+f3*(1._r8+f2))
+ n_allometry(p) = 1._r8/cnl + f1/cnfr + (f3*f4*(1._r8+f2))/cnlw + &
+ (f3*(1._r8-f4)*(1._r8+f2))/cndw
+ p_allometry(p) = 1._r8/cpl + f1/cpfr + (f3*f4*(1._r8+f2))/cplw + &
+ (f3*(1._r8-f4)*(1._r8+f2))/cpdw
+
+ else if (ivt(p) >= npcropmin) then ! skip generic crops
+ cng = graincn(ivt(p))
+ cpg = graincp(ivt(p))
+ c_allometry(p) = (1._r8)*(1._r8+f1+f5+f3*(1._r8+f2))
+ n_allometry(p) = 1._r8/cnl + f1/cnfr + f5/cng + (f3*f4*(1._r8+f2))/cnlw + &
+ (f3*(1._r8-f4)*(1._r8+f2))/cndw
+ p_allometry(p) = 1._r8/cpl + f1/cpfr + f5/cpg + (f3*f4*(1._r8+f2))/cplw + &
+ (f3*(1._r8-f4)*(1._r8+f2))/cpdw
+ else
+ c_allometry(p) = 1._r8+f1
+ n_allometry(p) = 1._r8/cnl + f1/cnfr
+ p_allometry(p) = 1._r8/cpl + f1/cpfr
+ end if
+ end if !use_fun
+
+
plant_ndemand(p) = availc(p)*(n_allometry(p)/c_allometry(p))
plant_pdemand(p) = availc(p)*(p_allometry(p)/c_allometry(p))
@@ -985,6 +1039,8 @@
! retransn pool has N from leaves, stems, and roots for
! retranslocation
+ if(.not.use_fun)then
+
if (ivt(p) >= npcropmin .and. grain_flag(p) == 1._r8) then
avail_retransn(p) = plant_ndemand(p)
avail_retransp(p) = plant_pdemand(p)
@@ -1011,16 +1067,29 @@
retransn_to_npool(p) = plant_ndemand(p)
end if
+ if ( .not. use_fun ) then
plant_ndemand(p) = plant_ndemand(p) - retransn_to_npool(p)
+ else
+ if (season_decid(ivt(p)) == 1._r8.or.stress_decid(ivt(p))==1._r8) then
+ plant_ndemand(p) = plant_ndemand(p) - retransn_to_npool(p)
+ end if
+ end if
if (plant_pdemand(p) > avail_retransp(p)) then
retransp_to_ppool(p) = avail_retransp(p)
else
retransp_to_ppool(p) = plant_pdemand(p)
end if
- plant_pdemand(p) = plant_pdemand(p) - retransp_to_ppool(p)
+ if ( .not. use_funp ) then
+ plant_pdemand(p) = plant_pdemand(p) - retransp_to_ppool(p)
+ else
+ if (season_decid(ivt(p)) == 1._r8.or.stress_decid(ivt(p))==1._r8) then
+ plant_pdemand(p) = plant_pdemand(p) - retransp_to_ppool(p)
+ end if
+ end if
+ end if !use_fun
end do ! end pft loop
! now use the p2c routine to get the column-averaged plant_ndemand
@@ -1068,9 +1137,14 @@
num_soilp, filter_soilp , &
cnstate_vars , &
carbonstate_vars, carbonflux_vars , &
+ c13_carbonflux_vars, c14_carbonflux_vars , &
nitrogenstate_vars, nitrogenflux_vars , &
phosphorusstate_vars,phosphorusflux_vars , &
- soilstate_vars,waterstate_vars)
+ soilstate_vars,waterstate_vars, &
+ crop_vars, &
+ soilhydrology_vars, temperature_vars, waterflux_vars, &
+ canopystate_vars)
+
! PHASE-2 of Allocation: resolving N/P limitation
! !USES:
use shr_sys_mod , only: shr_sys_flush
@@ -1102,6 +1176,18 @@
type(soilstate_type) , intent(in) :: soilstate_vars
type(waterstate_type) , intent(in) :: waterstate_vars
+
+ !! add varibles needed for FUN
+ type(crop_type) , intent(inout) :: crop_vars
+ type(carbonflux_type) , intent(inout) :: c13_carbonflux_vars
+ type(carbonflux_type) , intent(inout) :: c14_carbonflux_vars
+ type(soilhydrology_type) , intent(in) :: soilhydrology_vars
+ type(temperature_type) , intent(in) :: temperature_vars
+ type(waterflux_type) , intent(in) :: waterflux_vars
+ type(canopystate_type) , intent(in) :: canopystate_vars
+
+
+
!
! !LOCAL VARIABLES:
real(r8) :: sum_pdemand_scaled(bounds%begc:bounds%endc,1:nlevdecomp) ! sum of total P demand, scaled with relative competitiveness
@@ -1167,6 +1253,9 @@
real(r8):: solution_pconc(bounds%begc:bounds%endc, 1:nlevdecomp)
real(r8):: cn_stoich_var=0.2 ! variability of CN ratio
real(r8):: cp_stoich_var=0.4 ! variability of CP ratio
+
+ real(r8) :: sminn_to_plant_new(bounds%begc:bounds%endc)
+ real(r8) :: sminp_to_plant_new(bounds%begc:bounds%endc)
!-----------------------------------------------------------------------
associate( &
@@ -1306,9 +1395,19 @@
leafn_storage => veg_ns%leafn_storage , &
leafn_xfer => veg_ns%leafn_xfer , &
leafp_storage => veg_ps%leafp_storage , &
- leafp_xfer => veg_ps%leafp_xfer &
+ leafp_xfer => veg_ps%leafp_xfer , &
+
+ sminn_to_plant_fun_vr => col_nf%sminn_to_plant_fun_vr , & ! Output:
+ sminn_to_plant_fun_no3_vr => col_nf%sminn_to_plant_fun_no3_vr , & ! Output:
+ sminn_to_plant_fun_nh4_vr => col_nf%sminn_to_plant_fun_nh4_vr , & ! Output:
+ sminp_to_plant_fun_vr => col_pf%sminp_to_plant_fun_vr & ! Output:
+ ! [real(r8) (:) ] Total layer soil P uptake of FUN (gP/m2
+ ! /s)
)
+ sminn_to_plant_new(bounds%begc:bounds%endc) = 0._r8
+ sminp_to_plant_new(bounds%begc:bounds%endc) = 0._r8
+
! set time steps
dt = real( get_step_size(), r8 )
@@ -1321,6 +1420,7 @@
col_plant_pdemand(c) = plant_pdemand_col(c)
end do
+
! Starting resolving N/P limitation
! calculate nuptake & puptake profile
call calc_nuptake_prof(bounds, num_soilc, filter_soilc, cnstate_vars, nitrogenstate_vars, nuptake_prof)
@@ -1335,668 +1435,6 @@
! (2) nitrogen and phosphorus uptake is based on root kinetics
! (3) no second pass nutrient uptake for plants
! =============================================================
- if (.not. use_nitrif_denitrif) then
-
- if (nu_com .eq. 'RD') then ! 'RD' : relative demand approach
-
- ! column loops to resolve plant/heterotroph competition for mineral N
- ! init sminn_tot
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- sum_ndemand_vr(c,j) = col_plant_ndemand(c) * nuptake_prof(c,j) + potential_immob_vr(c,j)
- sum_pdemand_vr(c,j) = col_plant_pdemand(c) * puptake_prof(c,j) + potential_immob_p_vr(c,j)
- end do
- end do
-
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- l = col_pp%landunit(c)
- if (sum_ndemand_vr(c,j)*dt < sminn_vr(c,j)) then
-
- ! N availability is not limiting immobilization or plant
- ! uptake, and both can proceed at their potential rates
- nlimit(c,j) = 0
- fpi_vr(c,j) = 1.0_r8
- actual_immob_vr(c,j) = potential_immob_vr(c,j)
- sminn_to_plant_vr(c,j) = col_plant_ndemand(c) * nuptake_prof(c,j)
- else if ( cnallocate_carbon_only() .or. cnallocate_carbonphosphorus_only() ) then !.or. &
- ! (crop_supln .and. (lun_pp%itype(l) == istcrop) .and. &
- ! (ivt(col_pp%pfti(c)) >= npcropmin)) )then
- ! this code block controls the addition of N to sminn pool
- ! to eliminate any N limitation, when Carbon_Only is set. This lets the
- ! model behave essentially as a carbon-only model, but with the
- ! benefit of keeping track of the N additions needed to
- ! eliminate N limitations, so there is still a diagnostic quantity
- ! that describes the degree of N limitation at steady-state.
-
- nlimit(c,j) = 1
- fpi_vr(c,j) = 1.0_r8
- actual_immob_vr(c,j) = potential_immob_vr(c,j)
- sminn_to_plant_vr(c,j) = col_plant_ndemand(c) * nuptake_prof(c,j)
- supplement_to_sminn_vr(c,j) = sum_ndemand_vr(c,j) - (sminn_vr(c,j)/dt)
- else
- ! N availability can not satisfy the sum of immobilization and
- ! plant growth demands, so these two demands compete for available
- ! soil mineral N resource.
-
- nlimit(c,j) = 1
- if (sum_ndemand_vr(c,j) > 0.0_r8 .and. sminn_vr(c,j) > 0.0_r8) then
- actual_immob_vr(c,j) = (sminn_vr(c,j)/dt)*(potential_immob_vr(c,j) / sum_ndemand_vr(c,j))
- else
- actual_immob_vr(c,j) = 0.0_r8
- end if
-
- if (potential_immob_vr(c,j) > 0.0_r8) then
- fpi_vr(c,j) = actual_immob_vr(c,j) / potential_immob_vr(c,j)
- else
- fpi_vr(c,j) = 1.0_r8
- end if
-
- sminn_to_plant_vr(c,j) = (sminn_vr(c,j)/dt) - actual_immob_vr(c,j)
- end if
- end do
- end do
-
- else ! ECA mode or MIC outcompete plant mode
-
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- ! plant, microbial decomposer compete for N
- ! loop over each pft within the same column
- ! calculate competition coefficients for N/P
- ! first need to convert concentration to per soil water based
- ! 2.76 consider soil adsorption effect on [NH4+] availability, based on Zhu et al., 2016 DOI: 10.1002/2016JG003554
- solution_nh4conc(c,j) = sminn_vr(c,j) / (bd(c,j)*2.76 + h2osoi_vol(c,j)) ! convert to per soil water based
- e_km_n = 0._r8
- decompmicc(c,j) = 0.0_r8
- do p = col_pp%pfti(c), col_pp%pftf(c)
- if (veg_pp%active(p).and. (veg_pp%itype(p) .ne. noveg)) then
- e_km_n = e_km_n + e_plant_scalar*frootc(p)*froot_prof(p,j)*veg_pp%wtcol(p)/km_plant_nh4(ivt(p))
- decompmicc(c,j) = decompmicc(c,j) + decompmicc_patch_vr(ivt(p),j)*veg_pp%wtcol(p)
- end if
- end do
- e_km_n = e_km_n + e_decomp_scalar*decompmicc(c,j)*(1._r8/km_decomp_nh4 )
- do p = col_pp%pfti(c), col_pp%pftf(c)
- if (veg_pp%active(p).and. (veg_pp%itype(p) .ne. noveg)) then
- compet_plant_n(p) = solution_nh4conc(c,j) / ( km_plant_nh4(ivt(p)) * (1 + &
- solution_nh4conc(c,j)/km_plant_nh4(ivt(p)) + e_km_n))
- else
- compet_plant_n(p) = 0.0_r8
- end if
- end do
- compet_decomp_n = solution_nh4conc(c,j) / (km_decomp_nh4 * (1 + solution_nh4conc(c,j)/km_decomp_nh4 + e_km_n))
-
- ! relative demand approach: root nutrient uptake profile is based on nutrient concentration profile
- ! nu_com with ECA or MIC: root nutrient uptake profile is based on fine root density profile
- col_plant_ndemand_vr(c,j) = 0._r8
- do p = col_pp%pfti(c), col_pp%pftf(c)
- if (veg_pp%active(p).and. (veg_pp%itype(p) .ne. noveg)) then
- ! scaling factor based on CN ratio flexibility
- if (cnallocate_carbonphosphorus_only() .or. cnallocate_carbon_only()) then
- cn_scalar(p) = 0.0_r8
- else
- cn_scalar(p) = min(max(((leafc(p) + leafc_storage(p) + leafc_xfer(p))/ &
- max(leafn(p) + leafn_storage(p) + leafn_xfer(p), 1e-20_r8) - &
- leafcn(ivt(p))*(1- cn_stoich_var)) / &
- (leafcn(ivt(p)) - leafcn(ivt(p))*(1- cn_stoich_var)),0.0_r8),1.0_r8)
- endif
- plant_ndemand_vr_patch(p,j) = vmax_plant_nh4(ivt(p))* frootc(p) * &
- froot_prof(p,j) * cn_scalar(p) * t_scalar(c,j) * compet_plant_n(p)
-
- plant_ndemand_vr_patch(p,j) = max(plant_ndemand_vr_patch(p,j), 0.0_r8)
- col_plant_ndemand_vr(c,j) = col_plant_ndemand_vr(c,j) + plant_ndemand_vr_patch(p,j)*veg_pp%wtcol(p)
- else
- cn_scalar(p) = 0.0_r8
- plant_ndemand_vr_patch(p,j) = 0.0_r8
- end if
- end do
-
- ! compete for nitrogen
- sum_ndemand_vr(c,j) = col_plant_ndemand_vr(c,j) + potential_immob_vr(c,j)
- if (nu_com .eq. 'ECA') then ! 'ECA' mode
- sum_ndemand_scaled(c,j) = col_plant_ndemand_vr(c,j) + &
- potential_immob_vr(c,j)*compet_decomp_n
- else ! 'MIC' mode
- sum_ndemand_scaled(c,j) = potential_immob_vr(c,j)*compet_decomp_n
- end if
- if (sum_ndemand_vr(c,j)*dt < sminn_vr(c,j)) then
- ! N availability is not limiting immobilization or plant
- ! uptake, and all can proceed at their potential rates
- nlimit(c,j) = 0
- fpi_vr(c,j) = 1.0_r8
- actual_immob_vr(c,j) = potential_immob_vr(c,j)
- sminn_to_plant_vr(c,j) = col_plant_ndemand_vr(c,j)
- else if ( cnallocate_carbon_only() .or. cnallocate_carbonphosphorus_only() ) then !.or. &
- ! (crop_supln .and. (lun_pp%itype(l) == istcrop) .and. &
- ! (ivt(col_pp%pfti(c)) >= npcropmin)) )then
- ! this code block controls the addition of N to sminn pool
- ! to eliminate any N limitation, when Carbon_Only is set. This lets the
- ! model behave essentially as a carbon-only model, but with the
- ! benefit of keeping track of the N additions needed to
- ! eliminate N limitations, so there is still a diagnostic quantity
- ! that describes the degree of N limitation at steady-state.
- nlimit(c,j) = 1
- fpi_vr(c,j) = 1.0_r8
- actual_immob_vr(c,j) = potential_immob_vr(c,j)
- sminn_to_plant_vr(c,j) = col_plant_ndemand_vr(c,j)
- supplement_to_sminn_vr(c,j) = sum_ndemand_vr(c,j) - (sminn_vr(c,j)/dt)
- else
- ! N availability can not satisfy the sum of immobilization, nitrification, and
- ! plant growth demands, so these three demands compete for available
- ! soil mineral NH4 resource.
- nlimit(c,j) = 1
- if (sum_ndemand_vr(c,j) > 0.0_r8 .and. sminn_vr(c,j) > 0.0_r8 .and. sum_ndemand_scaled(c,j) > 0.0 ) then
- actual_immob_vr(c,j) = min((sminn_vr(c,j)/dt)*(potential_immob_vr(c,j)* &
- compet_decomp_n / sum_ndemand_scaled(c,j)), potential_immob_vr(c,j))
- if (nu_com .eq. 'ECA') sminn_to_plant_vr(c,j) = min((sminn_vr(c,j)/dt)* &
- (col_plant_ndemand_vr(c,j)/sum_ndemand_scaled(c,j)), col_plant_ndemand_vr(c,j))
- else
- actual_immob_vr(c,j) = 0.0_r8
- sminn_to_plant_vr(c,j) = 0.0_r8
- end if
- if (potential_immob_vr(c,j) > 0.0_r8) then
- fpi_vr(c,j) = actual_immob_vr(c,j) / potential_immob_vr(c,j)
- else
- fpi_vr(c,j) = 1.0_r8
- end if
- if (nu_com .eq. 'MIC') sminn_to_plant_vr(c,j) = min( max( 0._r8, &
- (sminn_vr(c,j)/dt) - actual_immob_vr(c,j)) , col_plant_ndemand_vr(c,j))
- end if
- end do
- end do
- end if ! end of N competition
-
- ! add phosphorus
- if (nu_com .eq. 'RD') then ! 'RD' : relative demand approach
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- l = col_pp%landunit(c)
- if (sum_pdemand_vr(c,j)*dt < solutionp_vr(c,j)) then
-
- ! P availability is not limiting immobilization or plant
- ! uptake, and both can proceed at their potential rates
- plimit(c,j) = 0
- fpi_p_vr(c,j) = 1.0_r8
- actual_immob_p_vr(c,j) = potential_immob_p_vr(c,j)
- sminp_to_plant_vr(c,j) = col_plant_pdemand(c) * puptake_prof(c,j)
-
- else if ( cnallocate_carbon_only() .or. cnallocate_carbonnitrogen_only() ) then !.or. &
-
- plimit(c,j) = 1
- fpi_p_vr(c,j) = 1.0_r8
- actual_immob_p_vr(c,j) = potential_immob_p_vr(c,j)
- sminp_to_plant_vr(c,j) = col_plant_pdemand(c) * puptake_prof(c,j)
- supplement_to_sminp_vr(c,j) = sum_pdemand_vr(c,j) - (solutionp_vr(c,j)/dt)
-
- else
- ! P availability can not satisfy the sum of immobilization and
- ! plant growth demands, so these two demands compete for
- ! available soil mineral solution P resource.
-
- plimit(c,j) = 1
- if (sum_pdemand_vr(c,j) > 0.0_r8 .and. solutionp_vr(c,j) >0._r8) then
- actual_immob_p_vr(c,j) = (solutionp_vr(c,j)/dt)*(potential_immob_p_vr(c,j) / sum_pdemand_vr(c,j))
- else
- actual_immob_p_vr(c,j) = 0.0_r8
- end if
-
- if (potential_immob_p_vr(c,j) > 0.0_r8) then
- fpi_p_vr(c,j) = actual_immob_p_vr(c,j) / potential_immob_p_vr(c,j)
- else
- fpi_p_vr(c,j) = 1.0_r8
- end if
-
- sminp_to_plant_vr(c,j) = max( 0._r8,(solutionp_vr(c,j)/dt) - actual_immob_p_vr(c,j) )
- end if
- end do
- end do
- else ! ECA mode or MIC outcompete plant mode
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
-
- ! ECA and MIC mode assume mineral surface adsorption flux is a potential competitor of solution P
- ! assume solutionP - labileP not equilibrate within 30 min, due to instantaneous
- ! plant P uptake, microbial P uptake/release
- ! secondary P desorption is assumed to go into solution P pool
-
- ! potential adsorption rate without plant and microbial interaction
- ! including weathering, deposition, phosphatase, mineralization, immobilization, plant uptake
- dsolutionp_dt(c,j) = gross_pmin_vr(c,j) -potential_immob_p_vr(c,j) - &
- col_plant_pdemand_vr(c,j) + biochem_pmin_vr_col(c,j) + &
- primp_to_labilep_vr_col(c,j) + pdep_to_sminp(c) *ndep_prof(c,j)
- adsorb_to_labilep_vr(c,j) = (vmax_minsurf_p_vr(isoilorder(c),j)* km_minsurf_p_vr(isoilorder(c),j)) / &
- ((km_minsurf_p_vr(isoilorder(c),j)+max(solutionp_vr(c,j),0._r8))**2._r8 ) * dsolutionp_dt(c,j)
- ! sign convention: if adsorb_to_labilep_vr(c,j) < 0, then it's desorption
- if (adsorb_to_labilep_vr(c,j) >= 0) then
- adsorb_to_labilep_vr(c,j) = max(min(adsorb_to_labilep_vr(c,j), &
- (vmax_minsurf_p_vr(isoilorder(c),j) - labilep_vr(c,j))/dt),0.0_r8)
- desorb_to_solutionp_vr(c,j) = 0.0_r8
- else
- desorb_to_solutionp_vr(c,j) = min(-1.0*adsorb_to_labilep_vr(c,j), labilep_vr(c,j)/dt)
- adsorb_to_labilep_vr(c,j) = 0.0_r8
- end if
-
- ! plant, microbial decomposer, mineral surface compete for P
- ! loop over each pft within the same column
- ! calculate competition coefficients for N/P
- solution_pconc(c,j) = solutionp_vr(c,j)/h2osoi_vol(c,j) ! convert to per soil water based
- solution_pconc(c,j) = max(solution_pconc(c,j), 0._r8)
- e_km_p = 0._r8
- decompmicc(c,j) = 0.0_r8
- do p = col_pp%pfti(c), col_pp%pftf(c)
- if (veg_pp%active(p).and. (veg_pp%itype(p) .ne. noveg)) then
- e_km_p = e_km_p + e_plant_scalar*frootc(p)*froot_prof(p,j)*veg_pp%wtcol(p)/km_plant_p(ivt(p))
- decompmicc(c,j) = decompmicc(c,j) + decompmicc_patch_vr(ivt(p),j)*veg_pp%wtcol(p)
- end if
- end do
- e_km_p = e_km_p + e_decomp_scalar*decompmicc(c,j)/km_decomp_p + &
- max(0._r8,vmax_minsurf_p_vr(isoilorder(c),j)-labilep_vr(c,j))/km_minsurf_p_vr(isoilorder(c),j)
- do p = col_pp%pfti(c), col_pp%pftf(c)
- if (veg_pp%active(p).and. (veg_pp%itype(p) .ne. noveg)) then
- compet_plant_p(p) = solution_pconc(c,j) / ( km_plant_p(ivt(p)) * (1 + &
- solution_pconc(c,j)/km_plant_p(ivt(p)) + e_km_p))
- else
- compet_plant_p(p) = 0.0_r8
- end if
- end do
- compet_decomp_p = solution_pconc(c,j) / (km_decomp_p * (1 + solution_pconc(c,j)/km_decomp_p + e_km_p))
- compet_minsurf_p = solution_pconc(c,j) / (km_minsurf_p_vr(isoilorder(c),j) * &
- (1 + solution_pconc(c,j)/km_minsurf_p_vr(isoilorder(c),j) + e_km_p))
-
- ! relative demand approach: root nutrient uptake profile is based on nutrient concentration profile
- ! nu_com with ECA or MIC: root nutrient uptake profile is based on fine root density profile
- col_plant_pdemand_vr(c,j) = 0._r8
- do p = col_pp%pfti(c), col_pp%pftf(c)
- if (veg_pp%active(p).and. (veg_pp%itype(p) .ne. noveg)) then
- ! scaling factor based on CP ratio flexibility
- if (cnallocate_carbonnitrogen_only() .or. cnallocate_carbon_only()) then
- cp_scalar(p) = 0.0_r8
- else
- cp_scalar(p) = min(max(((leafc(p) + leafc_storage(p) + leafc_xfer(p)) / &
- max(leafp(p) + leafp_storage(p) + leafp_xfer(p), 1e-20_r8) - &
- leafcp(ivt(p))*(1- cp_stoich_var)) / &
- (leafcp(ivt(p)) - leafcp(ivt(p))*(1- cp_stoich_var)),0.0_r8),1.0_r8)
- endif
-
- plant_pdemand_vr_patch(p,j) = vmax_plant_p(ivt(p)) * frootc(p) * froot_prof(p,j) * &
- cp_scalar(p) * t_scalar(c,j) * compet_plant_p(p)
- plant_pdemand_vr_patch(p,j) = max(plant_pdemand_vr_patch(p,j),0.0_r8)
- col_plant_pdemand_vr(c,j) = col_plant_pdemand_vr(c,j) + plant_pdemand_vr_patch(p,j)*veg_pp%wtcol(p)
- else
- cp_scalar(p) = 0.0_r8
- plant_pdemand_vr_patch(p,j) = 0.0_r8
- end if
- end do
-
- ! compete for phosphorus
- sum_pdemand_vr(c,j) = col_plant_pdemand_vr(c,j) + potential_immob_p_vr(c,j) + adsorb_to_labilep_vr(c,j)
- if (nu_com .eq. 'ECA') then ! ECA mode
- sum_pdemand_scaled(c,j) = col_plant_pdemand_vr(c,j) + potential_immob_p_vr(c,j)*compet_decomp_p + &
- adsorb_to_labilep_vr(c,j)*compet_minsurf_p
- else ! 'MIC' mode
- sum_pdemand_scaled(c,j) = potential_immob_p_vr(c,j)*compet_decomp_p + &
- adsorb_to_labilep_vr(c,j)*compet_minsurf_p
- end if
- if (sum_pdemand_vr(c,j)*dt < solutionp_vr(c,j)) then
- ! P availability is not limiting immobilization or plant
- ! uptake, and both can proceed at their potential rates
- plimit(c,j) = 0
- fpi_p_vr(c,j) = 1.0_r8
- actual_immob_p_vr(c,j) = potential_immob_p_vr(c,j)
- sminp_to_plant_vr(c,j) = col_plant_pdemand_vr(c,j)
- adsorb_to_labilep_vr(c,j) = adsorb_to_labilep_vr(c,j)
- else if ( cnallocate_carbon_only() .or. cnallocate_carbonnitrogen_only() ) then !.or. &
- plimit(c,j) = 1
- fpi_p_vr(c,j) = 1.0_r8
- actual_immob_p_vr(c,j) = potential_immob_p_vr(c,j)
- sminp_to_plant_vr(c,j) = col_plant_pdemand_vr(c,j)
- adsorb_to_labilep_vr(c,j) = adsorb_to_labilep_vr(c,j)
- supplement_to_sminp_vr(c,j) = sum_pdemand_vr(c,j) - solutionp_vr(c,j)/dt
-
- else
- ! P availability can not satisfy the sum of immobilization and
- ! plant growth demands, so these two demands compete for
- ! available soil mineral solution P resource.
- plimit(c,j) = 1
- if (sum_pdemand_vr(c,j) > 0.0_r8 .and. solutionp_vr(c,j) >0._r8 .and. sum_pdemand_scaled(c,j) > 0.0) then
- if (nu_com .eq. 'ECA') sminp_to_plant_vr(c,j) = min(solutionp_vr(c,j)/dt * &
- col_plant_pdemand_vr(c,j)/ sum_pdemand_scaled(c,j),col_plant_pdemand_vr(c,j))
- actual_immob_p_vr(c,j) = min(solutionp_vr(c,j)/dt * potential_immob_p_vr(c,j) * compet_decomp_p /&
- sum_pdemand_scaled(c,j), potential_immob_p_vr(c,j))
- adsorb_to_labilep_vr(c,j) = min(solutionp_vr(c,j)/dt * adsorb_to_labilep_vr(c,j) * compet_minsurf_p /&
- sum_pdemand_scaled(c,j), adsorb_to_labilep_vr(c,j))
- else
- sminp_to_plant_vr(c,j) = 0.0_r8
- actual_immob_p_vr(c,j) = 0.0_r8
- adsorb_to_labilep_vr(c,j) = 0.0_r8
- end if
- if (potential_immob_p_vr(c,j) > 0.0_r8) then
- fpi_p_vr(c,j) = actual_immob_p_vr(c,j) / potential_immob_p_vr(c,j)
- else
- fpi_p_vr(c,j) = 1.0_r8
- end if
-
- if (nu_com .eq. 'MIC') sminp_to_plant_vr(c,j) = min(max( 0._r8, &
- (solutionp_vr(c,j)/dt) - actual_immob_p_vr(c,j) - adsorb_to_labilep_vr(c,j) ), &
- col_plant_pdemand_vr(c,j))
- end if
-
- end do
- end do
- end if ! end of P competition
-
- !!! resolving N limitation vs. P limitation for decomposition
- !!! update (1) actual immobilization for N and P (2) sminn_to_plant and sminp_to_plant
- if( .not.cnallocate_carbonphosphorus_only().and. .not.cnallocate_carbonnitrogen_only() &
- .and. .not.cnallocate_carbon_only() )then
-
- if (nu_com .eq. 'RD') then
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
-
- if (nlimit(c,j) == 1.and.plimit(c,j) == 0) then
-
- actual_immob_p_vr(c,j) = potential_immob_p_vr(c,j) * fpi_vr(c,j)
-
- sminp_to_plant_vr(c,j) = col_plant_pdemand(c) * puptake_prof(c,j)
-
- elseif (nlimit(c,j) == 0.and.plimit(c,j) == 1) then
-
- actual_immob_vr(c,j) = potential_immob_vr(c,j) *fpi_p_vr(c,j)
- sminn_to_plant_vr(c,j) = col_plant_ndemand(c) * nuptake_prof(c,j)
-
- elseif (nlimit(c,j) == 1.and.plimit(c,j) == 1)then
-
- if( fpi_vr(c,j) <=fpi_p_vr(c,j) )then
-
- actual_immob_p_vr(c,j) = potential_immob_p_vr(c,j) *fpi_vr(c,j)
-
- sminp_to_plant_vr(c,j) = min( max( 0._r8,(solutionp_vr(c,j)/dt) - actual_immob_p_vr(c,j) ), &
- col_plant_pdemand(c)*puptake_prof(c,j) )
- else
-
- actual_immob_vr(c,j)=potential_immob_vr(c,j) * fpi_p_vr(c,j)
- sminn_to_plant_vr(c,j) = min( (sminn_vr(c,j)/dt) - actual_immob_vr(c,j), &
- col_plant_ndemand(c)*nuptake_prof(c,j) )
- endif
- endif
- enddo
- enddo
-
- else ! 'ECA' or 'MIC' mode
-
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
-
- if (nlimit(c,j) == 1.and.plimit(c,j) == 0) then
-
- actual_immob_p_vr(c,j) = potential_immob_p_vr(c,j) * fpi_vr(c,j)
-
- sminp_to_plant_vr(c,j) = col_plant_pdemand_vr(c,j)
-
- elseif (nlimit(c,j) == 0.and.plimit(c,j) == 1) then
-
- actual_immob_vr(c,j) = potential_immob_vr(c,j) *fpi_p_vr(c,j)
- sminn_to_plant_vr(c,j) = col_plant_ndemand_vr(c,j)
-
- elseif (nlimit(c,j) == 1.and.plimit(c,j) == 1)then
-
- if( fpi_vr(c,j) <=fpi_p_vr(c,j) )then
-
- actual_immob_p_vr(c,j) = potential_immob_p_vr(c,j) *fpi_vr(c,j)
- sminp_to_plant_vr(c,j) = min( max( 0._r8,(solutionp_vr(c,j)/dt) - actual_immob_p_vr(c,j) ), &
- col_plant_pdemand_vr(c,j) )
-
- else
-
- actual_immob_vr(c,j)=potential_immob_vr(c,j) * fpi_p_vr(c,j)
- sminn_to_plant_vr(c,j) = min( (sminn_vr(c,j)/dt) - actual_immob_vr(c,j),col_plant_ndemand_vr(c,j) )
-
- endif
- endif
- enddo
- enddo
- end if
-
- end if
-
- if(cnallocate_carbonnitrogen_only())then
- !! add loops for c,j
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- actual_immob_p_vr(c,j) = potential_immob_p_vr(c,j) * fpi_vr(c,j)
- sminp_to_plant_vr(c,j) = col_plant_pdemand(c) * puptake_prof(c,j)
- end do
- end do
- endif
-
- ! sum up N and P fluxes to plant ??????WAS sminn_to_plant(c)
- ! INITIALIZED AS ZERO --- CHECK X.YANG
-
- do fc=1,num_soilc
- c = filter_soilc(fc)
- sminn_to_plant(c) = 0._r8
- sminp_to_plant(c) = 0._r8
- end do
-
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- sminn_to_plant(c) = sminn_to_plant(c) + sminn_to_plant_vr(c,j) * dzsoi_decomp(j)
- sminp_to_plant(c) = sminp_to_plant(c) + sminp_to_plant_vr(c,j) * dzsoi_decomp(j)
-
- end do
- end do
-
- ! update column plant N/P demand, pft level plant NP uptake for ECA and MIC mode
- if (nu_com .eq. 'ECA' .or. nu_com .eq. 'MIC') then
- do fc=1,num_soilc
- c = filter_soilc(fc)
- col_plant_ndemand(c) = 0._r8
- col_plant_pdemand(c) = 0._r8
- end do
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- col_plant_ndemand(c) = col_plant_ndemand(c) + col_plant_ndemand_vr(c,j) * dzsoi_decomp(j)
- col_plant_pdemand(c) = col_plant_pdemand(c) + col_plant_pdemand_vr(c,j) * dzsoi_decomp(j)
- end do
- end do
- do fp=1,num_soilp
- p = filter_soilp(fp)
- sminn_to_plant_patch(p) = 0.0_r8
- sminp_to_plant_patch(p) = 0.0_r8
- end do
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- if (col_plant_ndemand_vr(c,j) > 0._r8 ) then
- fpg_vr(c,j) = sminn_to_plant_vr(c,j)/col_plant_ndemand_vr(c,j)
- else
- fpg_vr(c,j) = 1.0_r8
- end if
-
- if (col_plant_pdemand_vr(c,j) > 0._r8) then
- fpg_p_vr(c,j) = sminp_to_plant_vr(c,j)/col_plant_pdemand_vr(c,j)
- else
- fpg_p_vr(c,j) = 1.0_r8
- end if
- do p = col_pp%pfti(c), col_pp%pftf(c)
- if (veg_pp%active(p).and. (veg_pp%itype(p) .ne. noveg)) then
- sminn_to_plant_patch(p) = sminn_to_plant_patch(p) + plant_ndemand_vr_patch(p,j) * &
- fpg_vr(c,j) *dzsoi_decomp(j)
- sminp_to_plant_patch(p) = sminp_to_plant_patch(p) + plant_pdemand_vr_patch(p,j) * &
- fpg_p_vr(c,j) *dzsoi_decomp(j)
- end if
- end do
- end do
- end do
- end if
-
- ! RD: plants have second pass to obtain nutrient
- ! ECA/MIC: plants nutrient uptake is based on kinetics, no second pass nutrient uptake
- if (nu_com .eq. 'RD') then
- ! give plants a second pass to see if there is any mineral N left over with which to satisfy residual N demand.
- do fc=1,num_soilc
- c = filter_soilc(fc)
- residual_sminn(c) = 0._r8
- residual_sminp(c) = 0._r8
- end do
-
- ! sum up total N left over after initial plant and immobilization fluxes
- do fc=1,num_soilc
- c = filter_soilc(fc)
- residual_plant_ndemand(c) = col_plant_ndemand(c) - sminn_to_plant(c)
- residual_plant_pdemand(c) = col_plant_pdemand(c) - sminp_to_plant(c)
- end do
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- if (residual_plant_ndemand(c) > 0._r8 ) then
- if (nlimit(c,j) .eq. 0) then
- residual_sminn_vr(c,j) = max(sminn_vr(c,j) - (actual_immob_vr(c,j) + sminn_to_plant_vr(c,j) ) * dt, 0._r8)
- residual_sminn(c) = residual_sminn(c) + residual_sminn_vr(c,j) * dzsoi_decomp(j)
- else
- residual_sminn_vr(c,j) = 0._r8
- endif
- endif
- !!! add phosphorus - X.YANG
- if (residual_plant_pdemand(c) > 0._r8 ) then
- if (plimit(c,j) .eq. 0) then
- residual_sminp_vr(c,j) = max(solutionp_vr(c,j) - (actual_immob_p_vr(c,j) + sminp_to_plant_vr(c,j) ) &
- * dt, 0._r8)
- residual_sminp(c) = residual_sminp(c) + residual_sminp_vr(c,j) * dzsoi_decomp(j)
- else
- residual_sminp_vr(c,j) = 0._r8
- endif
- endif
- end do
- end do
-
- ! distribute residual N and P to plants
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- if ( residual_plant_ndemand(c) > 0._r8 .and. residual_sminn(c) > 0._r8 .and. nlimit(c,j) .eq. 0) then
- sminn_to_plant_vr(c,j) = sminn_to_plant_vr(c,j) + residual_sminn_vr(c,j) * &
- min(( residual_plant_ndemand(c) * dt ) / residual_sminn(c), 1._r8) / dt
- endif
-
- if ( residual_plant_pdemand(c) > 0._r8 .and. residual_sminp(c) > 0._r8 .and. plimit(c,j) .eq. 0) then
- sminp_to_plant_vr(c,j) = sminp_to_plant_vr(c,j) + residual_sminp_vr(c,j) * &
- min(( residual_plant_pdemand(c) * dt ) / residual_sminp(c), 1._r8) / dt
- endif
- end do
- end do
-
- ! re-sum up N and P fluxes to plant
- do fc=1,num_soilc
- c = filter_soilc(fc)
- sminn_to_plant(c) = 0._r8
- sminp_to_plant(c) = 0._r8
- end do
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- sminn_to_plant(c) = sminn_to_plant(c) + sminn_to_plant_vr(c,j) * dzsoi_decomp(j)
- sum_ndemand_vr(c,j) = potential_immob_vr(c,j) + sminn_to_plant_vr(c,j)
-
- !!! for phosphorus
- sminp_to_plant(c) = sminp_to_plant(c) + sminp_to_plant_vr(c,j) * dzsoi_decomp(j)
- sum_pdemand_vr(c,j) = potential_immob_p_vr(c,j) + sminp_to_plant_vr(c,j)
- end do
- end do
- end if
-
- ! under conditions of excess N, some proportion is assumed to
- ! be lost to denitrification, in addition to the constant
- ! proportion lost in the decomposition pathways
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- if ((sminn_to_plant_vr(c,j) + actual_immob_vr(c,j))*dt < sminn_vr(c,j)) then
- sminn_to_denit_excess_vr(c,j) = max(bdnr*((sminn_vr(c,j)/dt) - sum_ndemand_vr(c,j)),0._r8)
- else
- sminn_to_denit_excess_vr(c,j) = 0._r8
- endif
- end do
- end do
-
- ! sum up N and P fluxes to immobilization
- do j = 1, nlevdecomp
- do fc=1,num_soilc
- c = filter_soilc(fc)
- actual_immob(c) = actual_immob(c) + actual_immob_vr(c,j) * dzsoi_decomp(j)
- potential_immob(c) = potential_immob(c) + potential_immob_vr(c,j) * dzsoi_decomp(j)
- !!! phosphorus
- actual_immob_p(c) = actual_immob_p(c) + actual_immob_p_vr(c,j) * dzsoi_decomp(j)
- potential_immob_p(c) = potential_immob_p(c) + potential_immob_p_vr(c,j) * dzsoi_decomp(j)
- end do
- end do
-
- do fc=1,num_soilc
- c = filter_soilc(fc)
- ! calculate the fraction of potential growth that can be
- ! acheived with the N available to plants
- if (col_plant_ndemand(c) > 0.0_r8) then
- fpg(c) = sminn_to_plant(c) / col_plant_ndemand(c)
- else
- fpg(c) = 1.0_r8
- end if
-
- ! calculate the fraction of immobilization realized (for diagnostic purposes)
- if (potential_immob(c) > 0.0_r8) then
- fpi(c) = actual_immob(c) / potential_immob(c)
- else
- fpi(c) = 1.0_r8
- end if
- end do
-
- do fc=1,num_soilc
- c = filter_soilc(fc)
- ! calculate the fraction of potential growth that can be
- ! acheived with the P available to plants
- if (col_plant_pdemand(c) > 0.0_r8) then
- fpg_p(c) = sminp_to_plant(c) / col_plant_pdemand(c)
- else
- fpg_p(c) = 1.0_r8
- end if
-
- ! calculate the fraction of immobilization realized (for diagnostic purposes)
- if (potential_immob_p(c) > 0.0_r8) then
- fpi_p(c) = actual_immob_p(c) / potential_immob_p(c)
- else
- fpi_p(c) = 1.0_r8
- end if
- end do
-
- ! for np imbalance
- if (nu_com .ne. 'RD') then
- do fc=1,num_soilc
- c = filter_soilc(fc)
- do p = col_pp%pfti(c), col_pp%pftf(c)
- pnup_pfrootc(p) = 0.0_r8
- if (veg_pp%active(p).and. (veg_pp%itype(p) .ne. noveg)) then
- do j = 1, nlevdecomp
- pnup_pfrootc(p) = pnup_pfrootc(p) + plant_ndemand_vr_patch(p,j) / max(frootc(p) * froot_prof(p,j)&
- ,1e-20_r8) * fpg_nh4_vr(c,j) / max(cn_scalar(p),1e-20_r8) / max(t_scalar(c,j),1e-20_r8) &
- * dzsoi_decomp(j)
- end do
- end if
- pnup_pfrootc(p) = pnup_pfrootc(p) / zisoi(nlevdecomp-1)
- end do
- end do
- end if
-
- else !----------NITRIF_DENITRIF-------------!
if (nu_com .eq. 'RD') then
! calculate competition coefficients
@@ -2011,6 +1449,7 @@
compet_decomp_no3 = AllocParamsInst%compet_decomp_no3
compet_denit = AllocParamsInst%compet_denit
+
! main column/vertical loop
do j = 1, nlevdecomp
do fc=1,num_soilc
@@ -2022,15 +1461,23 @@
sum_nh4_demand(c,j) = col_plant_ndemand(c) * nuptake_prof(c,j) + potential_immob_vr(c,j) + pot_f_nit_vr(c,j)
sum_nh4_demand_scaled(c,j) = col_plant_ndemand(c)* nuptake_prof(c,j) * compet_plant_nh4(p) + &
potential_immob_vr(c,j)*compet_decomp_nh4 + pot_f_nit_vr(c,j)*compet_nit
+
if (sum_nh4_demand(c,j)*dt < smin_nh4_vr(c,j)) then
! NH4 availability is not limiting immobilization or plant
! uptake, and all can proceed at their potential rates
nlimit_nh4(c,j) = 0
fpi_nh4_vr(c,j) = 1.0_r8
actual_immob_nh4_vr(c,j) = potential_immob_vr(c,j)
- smin_nh4_to_plant_vr(c,j) = col_plant_ndemand(c) * nuptake_prof(c,j)
+ !RF added new term.
f_nit_vr(c,j) = pot_f_nit_vr(c,j)
+
+
+ if ( .not. use_fun ) then
+ smin_nh4_to_plant_vr(c,j) = col_plant_ndemand(c) * nuptake_prof(c,j)
+ else
+ smin_nh4_to_plant_vr(c,j) = smin_nh4_vr(c,j)/dt - actual_immob_nh4_vr(c,j) - f_nit_vr(c,j)
+ end if
else
@@ -2038,15 +1485,29 @@
! plant growth demands, so these three demands compete for available
! soil mineral NH4 resource.
nlimit_nh4(c,j) = 1
- if (sum_nh4_demand(c,j) > 0.0_r8 .and. smin_nh4_vr(c,j) > 0.0_r8 &
- .and. sum_nh4_demand_scaled(c,j) > 0.0_r8) then
+ !Original ELM
+ !if (sum_nh4_demand(c,j) > 0.0_r8 .and. smin_nh4_vr(c,j) > 0.0_r8 &
+ ! .and. sum_nh4_demand_scaled(c,j) > 0.0_r8) then
+ !As in CLM5
+ if (sum_nh4_demand(c,j) > 0.0_r8) then
+ ! RF microbes compete based on the hypothesised plant demand.
actual_immob_nh4_vr(c,j) = min((smin_nh4_vr(c,j)/dt)*(potential_immob_vr(c,j)* &
compet_decomp_nh4 / sum_nh4_demand_scaled(c,j)), potential_immob_vr(c,j))
- smin_nh4_to_plant_vr(c,j) = min((smin_nh4_vr(c,j)/dt)*(col_plant_ndemand(c)* &
- nuptake_prof(c,j)*compet_plant_nh4(p) / sum_nh4_demand_scaled(c,j)), &
- col_plant_ndemand(c)*nuptake_prof(c,j))
+ !smin_nh4_to_plant_vr(c,j) = min((smin_nh4_vr(c,j)/dt)*(col_plant_ndemand(c)* &
+ ! nuptake_prof(c,j)*compet_plant_nh4(p) / sum_nh4_demand_scaled(c,j)), &
+ ! col_plant_ndemand(c)*nuptake_prof(c,j))
f_nit_vr(c,j) = min((smin_nh4_vr(c,j)/dt)*(pot_f_nit_vr(c,j)*compet_nit / &
sum_nh4_demand_scaled(c,j)), pot_f_nit_vr(c,j))
+
+ if ( .not. use_fun ) then
+ smin_nh4_to_plant_vr(c,j) = min((smin_nh4_vr(c,j)/dt)*(col_plant_ndemand(c)* &
+ nuptake_prof(c,j)*compet_plant_nh4(p) / sum_nh4_demand_scaled(c,j)), col_plant_ndemand(c)*nuptake_prof(c,j))
+
+ else
+ ! RF added new term. send rest of N to plant - which decides whether it should pay or not?
+ smin_nh4_to_plant_vr(c,j) = smin_nh4_vr(c,j)/dt - actual_immob_nh4_vr(c,j) - f_nit_vr(c,j)
+ end if
+
else
actual_immob_nh4_vr(c,j) = 0.0_r8
smin_nh4_to_plant_vr(c,j) = 0.0_r8
@@ -2061,44 +1522,91 @@
end if
+ if(.not.use_fun)then
! next compete for no3
sum_no3_demand(c,j) = (col_plant_ndemand(c)*nuptake_prof(c,j)-smin_nh4_to_plant_vr(c,j)) + &