-
Notifications
You must be signed in to change notification settings - Fork 92
/
FatesAllometryMod.F90
3553 lines (2884 loc) · 149 KB
/
FatesAllometryMod.F90
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
!===============================================================================
!
! FatesAllometryMod.F90
!
! A library of functions that calculate plant allometry and their
! derivatives. Most relationships are related to diameter [cm]. All
! derivatives with respect to change in diameter have same units.
! In some cases multiple areguments will be provided, yet
! those arguments in those cases are trivially determined from diameter.
!
! Each function presented in this library is written to also return the
! derivative with respect to diameter, if the argument is provided.
!
! The name convention of the functions follows the form d... Which
! indicates "diameter to ...". Allometries for the following variables are
! calculated:
! h: height [m]
! bagw: biomass above ground woody tissues [kgC]
! this is an all encompassing definition of "woody", which
! is intended to include all non-leaf woody or fibrous
! tissues, including sap and structural materials
! blmax: biomass in leaves when leaves are "on allometry"
! this also is the "pre-trimmed" value, which is the maximum
! or potential leaf mass a tree may have [kgC]
! bbgw: biomass below ground woody tissues [kgC]
! similar to AGBW, this essentially encompasses
! all non-fineroot belowground tissues
! bfrmax: biomass in fine roots when "on allometry" [kgC]
! bsap: biomass in sapwood (above and below) [kgC]
! bdead: biomass (above and below) in the structural pool [kgC]
!
!
! The following function switches are rused
!
! allom_hmode, integer, height allometry function type
! allom_lmode, integer, maximum leaf allometry function type
! allom_rmode, integer, maximum root allometry function type
! allom_amode, integer, AGB allometry function type
! allom_cmode, integer, coarse root allometry function type
! allom_smode, integer, sapwood allometry function type
! allom_stmode, integer, storage allometry function type
!
! The following parameters (traits) are used
!
! wood_density, mean stem wood specific gravity (heart,sap,bark)
! allom_la_per_sa_int, leaf area per sapwood area, intercept [m2/cm2]
! allom_la_per_sa_slp, leaf area per sapwood area, slope on diameter [m2/cm2/cm]
! c2b, real, carbon to biomass multiplier (~2.0)
! allom_l2fr, fine root biomass per leaf biomass ratio [kgC/kgC]
! allom_agb_frac, the fraction of stem above ground [-]
! allom_d2h1, parameter 1 for d2h allometry (intercept)
! allom_d2h2, parameter 2 for d2h allometry (slope)
! allom_d2h3, parameter 3 for d2h allometry (optional)
! allom_d2bl1, parameter 1 for d2bl allometry (intercept)
! allom_d2bl2, parameter 2 for d2bl allometry (slope)
! allom_d2bl3, parameter 3 for d2bl allometry (optional)
! allom_agb1
! allom_agb2
! allom_agb3
! allom_dbh_maxheight, dbh at maximum height [cm]
! h_min, the height associated with newly recruited plant [m]
!
! Note - i4 types are expressed explicitly to accomodate unit testing calls
! to this module
!
! Explanation of pools and their control volumes
!
! ------------------------------------------------------------------------------
!
! total biomass = bleaf + bfineroot + agbw + bgbw
! ... or ...
! total biomass = bleaf + bfineroot + bdead + bsap
! ... and ...
! bdead = agbw + bgbw - bsap
!
! ------------------------------------------------------------------------------
!
! Initial Implementation: Ryan Knox July 2017
!
!===============================================================================
module FatesAllometryMod
! If this is a unit-test, these globals will be provided by a wrapper
use PRTParametersMod, only : prt_params
use FatesConstantsMod, only : r8 => fates_r8
use FatesConstantsMod, only : i4 => fates_int
use FatesConstantsMod, only : g_per_kg
use FatesConstantsMod, only : cm2_per_m2
use FatesConstantsMod, only : kg_per_Megag
use FatesConstantsMod, only : calloc_abs_error
use FatesConstantsMod, only : fates_unset_r8
use FatesConstantsMod, only : itrue
use FatesConstantsMod, only : nearzero
use FatesConstantsMod, only : pi_const
use shr_log_mod , only : errMsg => shr_log_errMsg
use FatesGlobals , only : fates_log
use FatesGlobals , only : endrun => fates_endrun
use FatesGlobals , only : FatesWarn,N2S,A2S,I2S
use EDParamsMod , only : nlevleaf,dinc_vai,dlower_vai
use DamageMainMod , only : GetCrownReduction
implicit none
private
public :: h2d_allom ! Generic height to diameter wrapper
public :: h_allom ! Generic diameter to height wrapper
public :: bagw_allom ! Generic AGWB (above grnd. woody bio) wrapper
public :: blmax_allom ! Generic maximum leaf biomass wrapper
public :: bleaf ! Generic actual leaf biomass wrapper
public :: storage_fraction_of_target ! storage as fraction of leaf biomass
public :: tree_lai ! Calculate tree-level LAI from actual leaf biomass
public :: tree_sai ! Calculate tree-level SAI from tree-level LAI
public :: bsap_allom ! Generic sapwood wrapper
public :: bbgw_allom ! Generic coarse root wrapper
public :: bfineroot ! Generic actual fine root biomass wrapper
public :: bdead_allom ! Generic bdead wrapper
public :: carea_allom ! Generic crown area wrapper
public :: bstore_allom ! Generic maximum storage carbon wrapper
public :: decay_coeff_vcmax ! vertical canopy decay rate, scaled on vcmax
public :: ForceDBH ! Method to set DBH to sync with structure
! or fineroot biomass
public :: CheckIntegratedAllometries
public :: CrownDepth
public :: set_root_fraction ! Generic wrapper to calculate normalized
! root profiles
public :: leafc_from_treelai ! Calculate target leaf carbon for a given treelai for SP mode
public :: VegAreaLayer
logical , parameter :: verbose_logging = .false.
character(len=*), parameter :: sourcefile = __FILE__
logical, parameter :: debug = .false.
character(len=1024) :: warn_msg ! for defining a warning message
! If testing b4b with older versions, do not remove sapwood
! Our old methods with saldarriaga did not remove sapwood from the
! bdead pool. But newer allometries are providing total agb
! which includes sapwood. Although a small quantity, it needs to be removed
! from the agb pool.
! Additionally, our calculation of sapwood biomass may be missing some unit conversions
contains
! ============================================================================
! Parameter Checks
! ============================================================================
! Checks to make sure parameters are not within expected ranges for each
! functions
! Check to make sure Martinez-Cano height cap is not on, or explicitly allowed
! ===========================================================================
! Helper Routines
! ===========================================================================
! ============================================================================
subroutine CheckIntegratedAllometries(dbh,ipft,crowndamage, &
canopy_trim, elongf_leaf, elongf_fnrt, elongf_stem, &
l2fr, bl,bfr,bsap,bstore,bdead, &
grow_leaf, grow_fr, grow_sap, grow_store, grow_dead, &
max_err, l_pass)
! This routine checks the error on the carbon allocation
! integration step. The integrated quantities should
! be a close match on the diagnosed quantities.
! We don't have to worry about small accumulating biases,
! or small errors because the scheme automatically pushes
! all carbon pools towards the allometric value corresponding
! to the diameter on each step, prior to performing an integration.
real(r8),intent(in) :: dbh ! diameter of plant [cm]
integer,intent(in) :: ipft ! plant functional type index
integer,intent(in) :: crowndamage ! crowndamage [1: undamaged, >1 damaged]
real(r8),intent(in) :: canopy_trim ! trimming function
real(r8),intent(in) :: elongf_leaf ! Leaf elongation factor
real(r8),intent(in) :: elongf_fnrt ! Fine-root elongation factor
real(r8),intent(in) :: elongf_stem ! Stem elongation factor
real(r8),intent(in) :: l2fr ! leaf to fine-root biomass multiplier (fr/leaf)
real(r8),intent(in) :: bl ! integrated leaf biomass [kgC]
real(r8),intent(in) :: bfr ! integrated fine root biomass [kgC]
real(r8),intent(in) :: bsap ! integrated sapwood biomass [kgC]
real(r8),intent(in) :: bstore ! integrated storage biomass [kgC]
real(r8),intent(in) :: bdead ! integrated structural biomass [kgc]
logical,intent(in) :: grow_leaf ! on-off switch for leaf growth
logical,intent(in) :: grow_fr ! on-off switch for root growth
logical,intent(in) :: grow_sap ! on-off switch for sapwood
logical,intent(in) :: grow_store! on-off switch for storage
logical,intent(in) :: grow_dead ! on-off switch for structure
real(r8),intent(in) :: max_err ! maximum allowable error
logical,intent(out) :: l_pass ! Error flag (pass=true,no-pass=false)
real(r8) :: height ! diagnosed height [m]
real(r8) :: bl_diag ! diagnosed leaf biomass [kgC]
real(r8) :: bfr_diag ! diagnosed fine-root biomass [kgC]
real(r8) :: bsap_diag ! diagnosed sapwood biomass [kgC]
real(r8) :: asap_diag ! sapwood area (dummy) [m2]
real(r8) :: bdead_diag ! diagnosed structural biomass [kgC]
real(r8) :: bstore_diag ! diagnosed storage biomass [kgC]
real(r8) :: bagw_diag ! diagnosed agbw [kgC]
real(r8) :: bbgw_diag ! diagnosed below ground wood [kgC]
l_pass = .true. ! Default assumption is that step passed
if (grow_leaf) then
call bleaf(dbh,ipft,crowndamage, canopy_trim, elongf_leaf, bl_diag)
if( abs(bl_diag-bl) > max_err ) then
if(verbose_logging) then
write(fates_log(),*) 'disparity in integrated/diagnosed leaf carbon'
write(fates_log(),*) 'resulting from the on-allometry growth integration step'
write(fates_log(),*) 'bl (integrated): ',bl
write(fates_log(),*) 'bl (diagnosed): ',bl_diag
write(fates_log(),*) 'relative error: ',abs(bl_diag-bl)/bl_diag
end if
l_pass = .false.
end if
end if
if (grow_fr) then
call bfineroot(dbh,ipft,canopy_trim,l2fr, elongf_fnrt, bfr_diag)
if( abs(bfr_diag-bfr) > max_err ) then
if(verbose_logging) then
write(fates_log(),*) 'disparity in integrated/diagnosed fineroot carbon'
write(fates_log(),*) 'resulting from the on-allometry growth integration step'
write(fates_log(),*) 'bfr (integrated): ',bfr
write(fates_log(),*) 'bfr (diagnosed): ',bfr_diag
write(fates_log(),*) 'relative error: ',abs(bfr_diag-bfr)/bfr_diag
end if
l_pass = .false.
end if
end if
if (grow_sap) then
call bsap_allom(dbh,ipft,crowndamage, canopy_trim, elongf_stem, asap_diag,bsap_diag)
if( abs(bsap_diag-bsap) > max_err ) then
if(verbose_logging) then
write(fates_log(),*) 'disparity in integrated/diagnosed sapwood carbon'
write(fates_log(),*) 'resulting from the on-allometry growth integration step'
write(fates_log(),*) 'bsap (integrated): ',bsap
write(fates_log(),*) 'bsap (diagnosed): ',bsap_diag
write(fates_log(),*) 'relative error: ',abs(bsap_diag-bsap)/bsap_diag
end if
l_pass = .false.
end if
end if
if (grow_store) then
call bstore_allom(dbh,ipft,crowndamage, canopy_trim,bstore_diag)
if( abs(bstore_diag-bstore) > max_err ) then
if(verbose_logging) then
write(fates_log(),*) 'disparity in integrated/diagnosed storage carbon'
write(fates_log(),*) 'resulting from the on-allometry growth integration step'
write(fates_log(),*) 'bsap (integrated): ',bstore
write(fates_log(),*) 'bsap (diagnosed): ',bstore_diag
write(fates_log(),*) 'relative error: ',abs(bstore_diag-bstore)/bstore_diag
end if
l_pass = .false.
end if
end if
if (grow_dead) then
call bsap_allom(dbh,ipft,crowndamage, canopy_trim, elongf_stem,asap_diag,bsap_diag)
call bagw_allom(dbh,ipft,crowndamage, elongf_stem, bagw_diag)
call bbgw_allom(dbh,ipft, elongf_stem,bbgw_diag)
call bdead_allom( bagw_diag, bbgw_diag, bsap_diag, ipft, bdead_diag )
if( abs(bdead_diag-bdead) > max_err ) then
if(verbose_logging) then
write(fates_log(),*) 'disparity in integrated/diagnosed structural carbon'
write(fates_log(),*) 'resulting from the on-allometry growth integration step'
write(fates_log(),*) 'bdead (integrated): ',bdead
write(fates_log(),*) 'bdead (diagnosed): ',bdead_diag
write(fates_log(),*) 'relative error: ',abs(bdead_diag-bdead)/bdead_diag
end if
l_pass = .false.
end if
end if
return
end subroutine CheckIntegratedAllometries
! ============================================================================
! Generic height to diameter interface
! ============================================================================
subroutine h2d_allom(h,ipft,d,dddh)
real(r8),intent(in) :: h ! height of plant [m]
integer(i4),intent(in) :: ipft ! PFT index
real(r8),intent(out) :: d ! plant diameter [cm]
real(r8),intent(out),optional :: dddh ! change in diameter per height [cm/m]
associate( p1 => prt_params%allom_d2h1(ipft), &
p2 => prt_params%allom_d2h2(ipft), &
p3 => prt_params%allom_d2h3(ipft), &
allom_hmode => prt_params%allom_hmode(ipft))
select case(allom_hmode)
case (1) ! O'Brien et al 1995, BCI
call h2d_obrien(h,p1,p2,d,dddh)
case (2) ! poorter 2006
call h2d_poorter2006(h,p1,p2,p3,d,dddh)
case (3) ! 2 parameter power function
call h2d_2pwr(h,p1,p2,d,dddh)
case (4) ! chave 2014
call h2d_chave2014(h,p1,p2,p3,d,dddh)
case (5) ! Martinez-Cano
call h2d_martcano(h,p1,p2,p3,d,dddh)
case DEFAULT
write(fates_log(),*) 'An undefined h2d allometry was specified: ',allom_hmode
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end select
end associate
return
end subroutine h2d_allom
! ============================================================================
! Generic height interface
! ============================================================================
subroutine h_allom(d,ipft,h,dhdd)
! Arguments
real(r8),intent(in) :: d ! plant diameter [cm]
integer(i4),intent(in) :: ipft ! PFT index
real(r8),intent(out) :: h ! plant height [m]
real(r8),intent(out),optional :: dhdd ! change in height per diameter [m/cm]
associate( dbh_maxh => prt_params%allom_dbh_maxheight(ipft), &
p1 => prt_params%allom_d2h1(ipft), &
p2 => prt_params%allom_d2h2(ipft), &
p3 => prt_params%allom_d2h3(ipft), &
allom_hmode => prt_params%allom_hmode(ipft))
select case(allom_hmode)
case (1) ! "obrien"
call d2h_obrien(d,p1,p2,dbh_maxh,h,dhdd)
case (2) ! "poorter06"
call d2h_poorter2006(d,p1,p2,p3,dbh_maxh,h,dhdd)
case (3) ! "2parameter power function h=a*d^b "
call d2h_2pwr(d,p1,p2,dbh_maxh,h,dhdd)
case (4) ! "chave14")
call d2h_chave2014(d,p1,p2,p3,dbh_maxh,h,dhdd)
case (5) ! Martinez-Cano
call d2h_martcano(d,p1,p2,p3,dbh_maxh,h,dhdd)
case DEFAULT
write(fates_log(),*) 'An undefined height allometry was specified: ',allom_hmode
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end select
end associate
return
end subroutine h_allom
! ============================================================================
! Generic AGB interface
! ============================================================================
subroutine bagw_allom(d,ipft,crowndamage, elongf_stem, bagw,dbagwdd)
use DamageMainMod, only : GetCrownReduction
use FatesParameterDerivedMod, only : param_derived
real(r8),intent(in) :: d ! plant diameter [cm]
integer(i4),intent(in) :: ipft ! PFT index
integer(i4),intent(in) :: crowndamage ! crowndamage [1: undamaged, >1: damaged]
real(r8),intent(in) :: elongf_stem ! Stem elongation factor
real(r8),intent(out) :: bagw ! biomass above ground woody tissues
real(r8),intent(out),optional :: dbagwdd ! change in agbw per diameter [kgC/cm]
real(r8) :: h ! height
real(r8) :: dhdd ! change in height wrt d
real(r8) :: crown_reduction ! crown reduction from damage
real(r8) :: branch_frac ! fraction of aboveground woody biomass in branches
associate( p1 => prt_params%allom_agb1(ipft), &
p2 => prt_params%allom_agb2(ipft), &
p3 => prt_params%allom_agb3(ipft), &
p4 => prt_params%allom_agb4(ipft), &
wood_density => prt_params%wood_density(ipft), &
c2b => prt_params%c2b(ipft), &
agb_frac => prt_params%allom_agb_frac(ipft), &
allom_amode => prt_params%allom_amode(ipft))
branch_frac = param_derived%branch_frac(ipft)
select case(allom_amode)
case (1) !"salda")
call h_allom(d,ipft,h,dhdd)
call dh2bagw_salda(d,h,dhdd,p1,p2,p3,p4,wood_density,c2b,agb_frac,bagw,dbagwdd)
case (2) !"2par_pwr")
! Switch for woodland dbh->drc
call d2bagw_2pwr(d,p1,p2,c2b,bagw,dbagwdd)
case (3) !"chave14")
call h_allom(d,ipft,h,dhdd)
call dh2bagw_chave2014(d,h,dhdd,p1,p2,wood_density,c2b,bagw,dbagwdd)
case (4) ! 3par_pwr
call h_allom(d,ipft,h,dhdd)
call dh2bagw_3pwr(d,h,dhdd,p1,p2,p3,wood_density,c2b,bagw,dbagwdd)
case (5) ! 3par_pwr_grass
call h_allom(d,ipft,h,dhdd)
call dh2bagw_3pwr_grass(d,h,dhdd,p1,p2,p3,c2b,bagw,dbagwdd)
case DEFAULT
write(fates_log(),*) 'An undefined AGB allometry was specified: ',allom_amode
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end select
! Potentially reduce AGB based on crown damage (crown_reduction) and/or
! phenology (elongf_stem).
if(crowndamage > 1) then
call GetCrownReduction(crowndamage, crown_reduction)
bagw = elongf_stem * ( bagw - (bagw * branch_frac * crown_reduction) )
if(present(dbagwdd))then
dbagwdd = elongf_stem * ( dbagwdd - (dbagwdd * branch_frac * crown_reduction) )
end if
else
bagw = elongf_stem * bagw
if (present(dbagwdd)) then
dbagwdd = elongf_stem * dbagwdd
end if
end if
end associate
return
end subroutine bagw_allom
! ============================================================================
! Generic diameter to maximum leaf biomass interface
! ============================================================================
subroutine blmax_allom(d,ipft,blmax,dblmaxdd)
real(r8),intent(in) :: d ! plant diameter [cm]
integer(i4),intent(in) :: ipft ! PFT index
real(r8),intent(out) :: blmax ! plant leaf biomass [kg]
real(r8),intent(out),optional :: dblmaxdd ! change leaf bio per diameter [kgC/cm]
real(r8) :: h ! height
real(r8) :: dhdd ! change in height wrt d
associate( dbh_maxh => prt_params%allom_dbh_maxheight(ipft), &
rho => prt_params%wood_density(ipft), &
slatop => prt_params%slatop(ipft), &
c2b => prt_params%c2b(ipft), &
allom_lmode => prt_params%allom_lmode(ipft), &
p1 => prt_params%allom_d2bl1(ipft), &
p2 => prt_params%allom_d2bl2(ipft), &
p3 => prt_params%allom_d2bl3(ipft))
select case(allom_lmode)
case(1) !"salda")
call d2blmax_salda(d,p1,p2,p3,rho,dbh_maxh,c2b,blmax,dblmaxdd)
case(2) !"2par_pwr")
call d2blmax_2pwr(d,p1,p2,c2b,blmax,dblmaxdd)
case(3) ! dh2blmax_2pwr
call dh2blmax_2pwr(d,p1,p2,dbh_maxh,c2b,blmax,dblmaxdd)
case(4) ! dh2blmax_3pwr
call h_allom(d,ipft,h,dhdd)
call dh2blmax_3pwr(d,h,dhdd,p1,p2,p3,slatop,dbh_maxh,c2b,blmax,dblmaxdd)
case (5) ! dh2blmax_3pwr_grass
call h_allom(d,ipft,h,dhdd)
call dh2blmax_3pwr_grass(d,h,dhdd,p1,p2,p3,dbh_maxh,c2b,blmax,dblmaxdd)
case DEFAULT
write(fates_log(),*) 'An undefined leaf allometry was specified: ', &
allom_lmode
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end select
end associate
return
end subroutine blmax_allom
! ============================================================================
! Generic crown area allometry wrapper
! ============================================================================
subroutine carea_allom(dbh,nplant,site_spread,ipft,crowndamage,c_area,inverse)
real(r8),intent(inout) :: dbh ! plant diameter at breast (reference) height [cm]
real(r8),intent(in) :: site_spread ! site level spread factor (crowdedness)
real(r8),intent(in) :: nplant ! number of plants [1/ha]
integer(i4),intent(in) :: ipft ! PFT index
integer(i4),intent(in) :: crowndamage ! crown damage class [1: undamaged, >1: damaged]
real(r8),intent(inout) :: c_area ! crown area per cohort (m2)
logical,optional,intent(in) :: inverse ! if true, calculate dbh from crown area
! instead of crown area from dbh
real(r8) :: dbh_eff ! Effective diameter (cm)
real(r8) :: height ! height
logical :: do_inverse ! local copy of the inverse argument
! defaults to false
logical :: capped_allom ! if we are using an allometry that caps
! crown area at height, we need to make
! special considerations
associate( dbh_maxh => prt_params%allom_dbh_maxheight(ipft), &
allom_lmode => prt_params%allom_lmode(ipft), &
d2bl_p2 => prt_params%allom_d2bl2(ipft), &
d2bl_ediff => prt_params%allom_blca_expnt_diff(ipft), &
d2ca_min => prt_params%allom_d2ca_coefficient_min(ipft), &
d2ca_max => prt_params%allom_d2ca_coefficient_max(ipft))
if( .not. present(inverse) ) then
do_inverse = .false.
else
do_inverse = inverse
if (do_inverse) then
c_area = c_area / nplant
endif
endif
select case(allom_lmode)
case(1)
dbh_eff = min(dbh,dbh_maxh)
call carea_2pwr(dbh_eff,site_spread,d2bl_p2,d2bl_ediff,d2ca_min,d2ca_max, &
crowndamage,c_area, do_inverse)
capped_allom = .true.
case(2) ! "2par_pwr")
call carea_2pwr(dbh,site_spread,d2bl_p2,d2bl_ediff,d2ca_min,d2ca_max, &
crowndamage, c_area, do_inverse)
capped_allom = .false.
case(3,5)
dbh_eff = min(dbh,dbh_maxh)
call carea_2pwr(dbh_eff,site_spread,d2bl_p2,d2bl_ediff,d2ca_min,d2ca_max, &
crowndamage, c_area, do_inverse)
capped_allom = .true.
case (4)
dbh_eff = min(dbh,dbh_maxh)
call h_allom(dbh,ipft,height)
call carea_3pwr(dbh_eff,height,ipft,dbh_maxh, site_spread,d2bl_p2, &
d2bl_ediff, d2ca_min,d2ca_max,crowndamage, c_area, do_inverse)
capped_allom = .true.
case DEFAULT
write(fates_log(),*) 'An undefined leaf allometry was specified: ', &
allom_lmode
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
end select
if (capped_allom .and. do_inverse) then
if (dbh_eff .lt. dbh_maxh) then
dbh = dbh_eff
else
! In this situation, we are signaling to the
! calling routine that we we cannot calculate
! dbh from crown area, because we have already
! hit the area cap, and the two are not proportional
! anymore. hopefully, the calling routine has an alternative
dbh = fates_unset_r8
endif
endif
c_area = c_area * nplant
end associate
return
end subroutine carea_allom
! =====================================================================================
subroutine bleaf(d,ipft,crowndamage,canopy_trim,elongf_leaf,bl,dbldd)
! -------------------------------------------------------------------------
! This subroutine calculates the actual target bleaf
! based on trimming. Because trimming
! is not allometry and rather an emergent property,
! this routine is not name-spaced with allom_
! -------------------------------------------------------------------------
use DamageMainMod , only : GetCrownReduction
real(r8),intent(in) :: d ! plant diameter [cm]
integer(i4),intent(in) :: ipft ! PFT index
integer(i4),intent(in) :: crowndamage ! crown damage class [1: undamaged, >1: damaged]
real(r8),intent(in) :: canopy_trim ! trimming function
real(r8),intent(in) :: elongf_leaf ! Leaf elongation factor (phenology)
real(r8),intent(out) :: bl ! plant leaf biomass [kgC]
real(r8),intent(out),optional :: dbldd ! change leaf bio per diameter [kgC/cm]
real(r8) :: blmax
real(r8) :: dblmaxdd
real(r8) :: crown_reduction
call blmax_allom(d,ipft,blmax,dblmaxdd)
! -------------------------------------------------------------------------
! Adjust for canopies that have become so deep that their bottom layer is
! not producing any carbon...
! nb this will change the allometry and the effects of this remain untested
! RF. April 2014
! -------------------------------------------------------------------------
bl = blmax * canopy_trim
if(present(dbldd))then
dbldd = dblmaxdd * canopy_trim
end if
! Potentially reduce leaf biomass based on crown damage (crown_reduction) and/or
! phenology (elongf_leaf).
if ( crowndamage > 1 ) then
call GetCrownReduction(crowndamage, crown_reduction)
bl = elongf_leaf * bl * (1.0_r8 - crown_reduction)
if(present(dbldd))then
dbldd = elongf_leaf * dblmaxdd * canopy_trim * (1.0_r8 - crown_reduction)
end if
else
bl = elongf_leaf * bl
if (present(dbldd)) then
dbldd = elongf_leaf * dbldd
end if
end if
return
end subroutine bleaf
! =====================================================================================
subroutine storage_fraction_of_target(c_store_target, c_store, frac)
!--------------------------------------------------------------------------------
! This subroutine returns the ratio between the storage pool and the target
! storage. This subroutine is used both the carbon starvation mortality scheme
! and the optional respiration throttling. We impose checks so it cannot go negative
! due to truncation errors, but this function can return values greater than 1.
!
! Fractions exceeding do not impact the default linear carbon starvation model
! (mort_cstarvation_model=2), because mortality becomes zero, but they allow carbon
! starvation mortality rates to continue decaying when the exponential carbon
! starvation model is used (mort_cstarvation_model=2).
!
! Fraction values above 1 do not impact lowstorage_maintresp_reduction either,
! as that routine imposes no reduction once the fraction exceeds 1.
!--------------------------------------------------------------------------------
real(r8),intent(in) :: c_store_target ! target storage carbon [kg]
real(r8),intent(in) :: c_store ! storage carbon [kg]
real(r8),intent(out) :: frac
frac = max(0._r8, c_store / max( c_store_target, nearzero) )
end subroutine storage_fraction_of_target
! =====================================================================================
real(r8) function tree_lai( leaf_c, pft, c_area, nplant, cl, canopy_lai, vcmax25top)
! -----------------------------------------------------------------------------------
! LAI of individual trees is a function of the total leaf area and the total
! canopy area.
! ----------------------------------------------------------------------------------
! !ARGUMENTS
real(r8), intent(in) :: leaf_c ! plant leaf carbon [kg]
integer, intent(in) :: pft ! Plant Functional Type index
real(r8), intent(in) :: c_area ! areal extent of canopy (m2)
real(r8), intent(in) :: nplant ! number of individuals in cohort per ha
integer, intent(in) :: cl ! canopy layer index
real(r8), intent(in) :: canopy_lai(:) ! total leaf area index of
! each canopy layer
real(r8), intent(in) :: vcmax25top ! maximum carboxylation rate at canopy
! top, ref 25C
! !LOCAL VARIABLES:
real(r8) :: leafc_per_unitarea ! KgC of leaf per m2 area of ground.
real(r8) :: slat ! the sla of the top leaf layer. m2/kgC
real(r8) :: canopy_lai_above ! total LAI of canopy layer overlying this tree
real(r8) :: vai_per_lai ! ratio of vegetation area index (ie. sai+lai)
! to lai for individual tree
real(r8) :: kn ! coefficient for exponential decay of 1/sla and
! vcmax with canopy depth
real(r8) :: sla_max ! Observational constraint on how large sla
! (m2/gC) can become
real(r8) :: leafc_slamax ! Leafc_per_unitarea at which sla_max is reached
real(r8) :: clim ! Upper limit for leafc_per_unitarea in exponential
! tree_lai function
!----------------------------------------------------------------------
if( leaf_c < -1.1_r8*calloc_abs_error .or. pft == 0 ) then
write(fates_log(),*) 'negative leaf carbon in LAI calculation?'
write(fates_log(),*) 'or.. pft was zero?'
write(fates_log(),*) 'problem in treelai',leaf_c,pft
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
slat = g_per_kg * prt_params%slatop(pft) ! m2/g to m2/kg
leafc_per_unitarea = leaf_c/(c_area/nplant) !KgC/m2
if(leafc_per_unitarea > 0.0_r8)then
if (cl==1) then ! if in we are in the canopy (top) layer)
canopy_lai_above = 0._r8
else
canopy_lai_above = sum(canopy_lai(1:cl-1))
end if
! Coefficient for exponential decay of 1/sla with canopy depth:
kn = decay_coeff_vcmax(vcmax25top, &
prt_params%leafn_vert_scaler_coeff1(pft), &
prt_params%leafn_vert_scaler_coeff2(pft))
! take PFT-level maximum SLA value, even if under a thick canopy (which has units of m2/gC),
! and put into units of m2/kgC
sla_max = g_per_kg*prt_params%slamax(pft)
! Leafc_per_unitarea at which sla_max is reached due to exponential sla profile in canopy:
leafc_slamax = (slat - sla_max * exp(-1.0_r8 * kn * canopy_lai_above)) / &
(-1.0_r8 * kn * slat * sla_max)
if(leafc_slamax < 0.0_r8)then
leafc_slamax = 0.0_r8
endif
! Calculate tree_lai (m2 leaf area /m2 ground) = unitless LAI
!----------------------------------------------------------------------
! If leafc_per_unitarea is less than leafc_slamax,
! sla with depth in the canopy will not exceed sla_max.
! In this case, we can use an exponential profile for sla throughout the entire canopy.
! The exponential profile for sla is given by:
! sla(at a given canopy depth) = slat / exp(-kn (canopy_lai_above + tree_lai)
!
! We can solve for tree_lai using the above function for the sla profile and first setting
! leafc_per_unitarea = integral of e^(-kn(x + canopy_lai_above)) / slatop
! over x = 0 to tree_lai
! Then, rearranging the equation to solve for tree_lai.
if (leafc_per_unitarea <= leafc_slamax)then
tree_lai = (log(exp(-1.0_r8 * kn * canopy_lai_above) - &
kn * slat * leafc_per_unitarea) + &
(kn * canopy_lai_above)) / (-1.0_r8 * kn)
! If leafc_per_unitarea becomes too large, tree_lai becomes an imaginary number
! (because the tree_lai equation requires us to take the natural log of something >0)
! Thus, we include the following error message in case leafc_per_unitarea becomes too large.
clim = (exp(-1.0_r8 * kn * canopy_lai_above)) / (kn * slat)
if (leafc_per_unitarea >= clim) then
write(fates_log(),*) 'too much leafc_per_unitarea' , leafc_per_unitarea, clim, pft, canopy_lai_above
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
! When leafc_per_unitarea is greater than leafc_slamax,
! tree_lai could become so great that the sla profile surpasses sla_max at depth.
! In this case, we use the exponential profile to calculate tree_lai until
! we reach the maximum allowed value for sla (sla_max).
! Then, calculate the remaining tree_lai using a linear function of sla_max and the remaining leafc.
else if(leafc_per_unitarea > leafc_slamax)then
! Add exponential and linear portions of tree_lai
! Exponential term for leafc = leafc_slamax;
! Linear term (static sla = sla_max) for portion of leafc > leafc_slamax
tree_lai = ((log(exp(-1.0_r8 * kn * canopy_lai_above) - &
kn * slat * leafc_slamax) + &
(kn * canopy_lai_above)) / (-1.0_r8 * kn)) + &
(leafc_per_unitarea - leafc_slamax) * sla_max
! if leafc_slamax becomes too large, tree_lai_exp becomes an imaginary number
! (because the tree_lai equation requires us to take the natural log of something >0)
! Thus, we include the following error message in case leafc_slamax becomes too large.
clim = (exp(-1.0_r8 * kn * canopy_lai_above)) / (kn * slat)
if(leafc_slamax >= clim)then
write(fates_log(),*) 'too much leafc_slamax' , &
leafc_per_unitarea, leafc_slamax, clim, pft, canopy_lai_above
write(fates_log(),*) 'Aborting'
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
end if ! (leafc_per_unitarea > leafc_slamax)
else
tree_lai = 0.0_r8
endif ! (leafc_per_unitarea > 0.0_r8)
return
end function tree_lai
! ============================================================================
real(r8) function tree_sai(pft, dbh, crowndamage, canopy_trim, elongf_stem, c_area, nplant, &
cl, canopy_lai, treelai, vcmax25top, call_id )
! ============================================================================
! SAI of individual trees is a function of the LAI of individual trees
! ============================================================================
integer, intent(in) :: pft
real(r8), intent(in) :: dbh
integer, intent(in) :: crowndamage
real(r8), intent(in) :: canopy_trim ! trimming function (0-1)
real(r8), intent(in) :: elongf_stem ! Elongation factor for stems.
real(r8), intent(in) :: c_area ! crown area (m2)
real(r8), intent(in) :: nplant ! number of plants
integer, intent(in) :: cl ! canopy layer index
real(r8), intent(in) :: canopy_lai(:) ! total leaf area index of
! each canopy layer
real(r8), intent(in) :: treelai ! tree LAI for checking purposes only
real(r8), intent(in) :: vcmax25top ! maximum carboxylation rate at top of crown
integer,intent(in) :: call_id ! flag specifying where this is called
! from
real(r8) :: h
real(r8) :: target_lai
real(r8) :: target_bleaf
! Assume fully flushed leaves, so stem area index is independent on leaf phenology.
! SAI can be downscaled by stem phenology (typically applied to grasses only).
call bleaf(dbh, pft, crowndamage, canopy_trim, 1.0_r8, target_bleaf)
target_lai = tree_lai(target_bleaf, pft, c_area, nplant, cl,&
canopy_lai, vcmax25top)
tree_sai = elongf_stem * prt_params%allom_sai_scaler(pft) * target_lai
if( (treelai + tree_sai) > (sum(dinc_vai)) )then
call h_allom(dbh,pft,h)
write(fates_log(),*) 'The leaf and stem are predicted for a cohort, maxed out the array size'
write(fates_log(),*) 'lai: ',treelai
write(fates_log(),*) 'sai: ',tree_sai
write(fates_log(),*) 'lai+sai: ',treelai+tree_sai
write(fates_log(),*) 'target_bleaf: ', target_bleaf
write(fates_log(),*) 'area: ', c_area
write(fates_log(),*) 'target_lai: ',target_lai
write(fates_log(),*) 'dinc_vai:',dinc_vai
write(fates_log(),*) 'nlevleaf,sum(dinc_vai):',nlevleaf,sum(dinc_vai)
write(fates_log(),*) 'pft: ',pft
write(fates_log(),*) 'call id: ',call_id
write(fates_log(),*) 'n: ',nplant
write(fates_log(),*) 'dbh: ',dbh,' dbh_max: ',prt_params%allom_dbh_maxheight(pft)
write(fates_log(),*) 'h: ',h
write(fates_log(),*) 'canopy_trim: ',canopy_trim
write(fates_log(),*) 'canopy layer: ',cl
write(fates_log(),*) 'canopy_tlai: ',canopy_lai(:)
write(fates_log(),*) 'vcmax25top: ',vcmax25top
call endrun(msg=errMsg(sourcefile, __LINE__))
end if
return
end function tree_sai
! =====================================================================================
real(r8) function leafc_from_treelai( treelai, pft, c_area, nplant, cl, vcmax25top)
! -----------------------------------------------------------------------------------
! Calculates the amount of leaf carbon which is needed to generate a given treelai.
! iss the inverse of the 'tree_lai function.
! ----------------------------------------------------------------------------------
! !ARGUMENTS
real(r8), intent(in) :: treelai ! desired tree lai m2/m2
integer, intent(in) :: pft ! Plant Functional Type index
real(r8), intent(in) :: c_area ! areal extent of canopy (m2)
real(r8), intent(in) :: nplant ! number of individuals in cohort per ha
integer, intent(in) :: cl ! canopy layer index
real(r8), intent(in) :: vcmax25top ! maximum carboxylation rate at canopy
! top, ref 25C
! !LOCAL VARIABLES:
real(r8) :: leaf_c ! plant leaf carbon [kg]
real(r8) :: leafc_per_unitarea ! KgC of leaf per m2 area of ground.
real(r8) :: slat ! the sla of the top leaf layer. m2/kgC
real(r8) :: vai_per_lai ! ratio of vegetation area index (ie. sai+lai)
! to lai for individual tree
real(r8) :: kn ! coefficient for exponential decay of 1/sla and
! vcmax with canopy depth
real(r8) :: sla_max ! Observational constraint on how large sla
! (m2/gC) can become
real(r8) :: leafc_slamax ! Leafc_per_unitarea at which sla_max is reached
real(r8) :: clim ! Upper limit for leafc_per_unitarea in exponential
! tree_lai function
real(r8) :: tree_lai_at_slamax ! lai at which we reach the maximum sla value.
real(r8) :: leafc_linear_phase ! amount of leaf carbon needed to get to the target treelai
! when the slamax value has been reached (i.e. deep layers with unchanging sla)
!----------------------------------------------------------------------
if( treelai < 0._r8.or. pft == 0 ) then
write(fates_log(),*) 'negative tree lai in leafc_from_treelai?'
write(fates_log(),*) 'or.. pft was zero?'
write(fates_log(),*) 'problem in leafc_from_treelai',treelai,pft
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
if(cl>1)then
write(fates_log(),*) 'in sub-canopy layer in leafc_from_treelai'
write(fates_log(),*) 'this is not set up to work for lower canopy layers.'
write(fates_log(),*) 'problem in leafc_from_treelai',cl,pft
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
! convert PFT-level canopy top and maximum SLA values and convert from m2/gC to m2/kgC
slat = g_per_kg * prt_params%slatop(pft)
sla_max = g_per_kg * prt_params%slamax(pft)
! Coefficient for exponential decay of 1/sla with canopy depth:
kn = decay_coeff_vcmax(vcmax25top, &
prt_params%leafn_vert_scaler_coeff1(pft), &
prt_params%leafn_vert_scaler_coeff2(pft))
if(treelai > 0.0_r8)then
! Leafc_per_unitarea at which sla_max is reached due to exponential sla profile in canopy:
leafc_slamax = max(0.0_r8,(slat - sla_max) / (-1.0_r8 * kn * slat * sla_max))
! treelai at which we reach maximum sla.
tree_lai_at_slamax = (log( 1.0_r8- kn * slat * leafc_slamax)) / (-1.0_r8 * kn)
if(treelai < tree_lai_at_slamax)then
! Inversion of the exponential phase calculation of treelai for a given leafc_per_unitarea
leafc_per_unitarea = (1.0_r8-exp(treelai*(-1.0_r8 * kn)))/(kn*slat)
else ! we exceed the maxumum sla
! Add exponential and linear portions of tree_lai
! Exponential term for leafc = leafc_slamax;
leafc_linear_phase = (treelai-tree_lai_at_slamax)/sla_max
leafc_per_unitarea = leafc_slamax + leafc_linear_phase
end if
leafc_from_treelai = leafc_per_unitarea*(c_area/nplant)
else
leafc_from_treelai = 0.0_r8
endif ! (leafc_per_unitarea > 0.0_r8)
return
end function leafc_from_treelai
! =====================================================================================
! ============================================================================
! Generic sapwood biomass interface
! ============================================================================
subroutine bsap_allom(d,ipft,crowndamage,canopy_trim,elongf_stem, sapw_area,bsap,dbsapdd)
use DamageMainMod , only : GetCrownReduction
use FatesParameterDerivedMod, only : param_derived
real(r8),intent(in) :: d ! plant diameter [cm]
integer(i4),intent(in) :: ipft ! PFT index
integer(i4),intent(in) :: crowndamage ! Crown damage class [1: undamaged, >1: damaged]
real(r8),intent(in) :: canopy_trim
real(r8),intent(in) :: elongf_stem ! Elongation factor for stems (phenology)
real(r8),intent(out) :: sapw_area ! cross section area of
! plant sapwood at reference [m2]
real(r8),intent(out) :: bsap ! sapwood biomass [kgC]
real(r8),intent(out),optional :: dbsapdd ! change in sapwood biomass
! per d [kgC/cm]
real(r8) :: h ! Plant height [m]
real(r8) :: dhdd
real(r8) :: bl
real(r8) :: dbldd
real(r8) :: bbgw
real(r8) :: dbbgwdd
real(r8) :: bagw
real(r8) :: dbagwdd
real(r8) :: bsap_cap ! cap sapwood so that it is no larger
! than some specified proportion of woody biomass
! should not trip, and only in small plants
real(r8) :: crown_reduction ! amount that crown is damage by
real(r8) :: agb_frac ! aboveground biomass fraction
real(r8) :: branch_frac ! fraction of aboveground woody biomass in branches
! Constrain sapwood so that its above ground portion be no larger than
! X% of total woody/fibrous (ie non leaf/fineroot) tissues
real(r8),parameter :: max_frac = 0.95_r8
agb_frac = prt_params%allom_agb_frac(ipft)
branch_frac = param_derived%branch_frac(ipft)
select case(prt_params%allom_smode(ipft))
! ---------------------------------------------------------------------
! Currently only one sapwood allometry model. the slope
! of the la:sa to diameter line is zero.