-
Notifications
You must be signed in to change notification settings - Fork 0
/
physiol.f90
1625 lines (1399 loc) · 64.6 KB
/
physiol.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
! PHYSIOL.FOR
!**********************************************************************
! This file contains all physiology calculations - photosynthesis,
! stomatal conductance, transpiration, respiration.
!
! The main subroutines (called externally) are:
! PSTRANSP - calls the other functions, does the leaf temp iteration calcn
! RESP - calculates maintenance respiration rate
! GRESP - calculates growth respiration rate
! CALCRMW - calculates stem maintenance respiration rate per unit mass
! CALCFBIOM - calculates foliar biomass from leaf area & SLA
! CALCWBIOM - calculates woody biomass from height & diameter
! For water balance: not finished
! ETCAN - calculates canopy transpiration rate
! PartitionPPT - partitions precip between drainage & canopy storage
!
! Subsidiary subroutines are
! 1. Photosynthesis
! PHOTOSYN - calculates photosynthesis from the FvC model
! GAMMAFN - calculates T dependence of Gamma*
! KMFN - calculates T dependence of Km
! ARRH - Arrhenius T dependence
! JMAXTFN - calculates T dependence of Jmax
! VCMAXTFN - calculates T dependence of Vcmax
! 2. Conductances & transpiration
! GBHFREE - calculates conductance to heat through free convection
! GBHFORCED - calculates conductance to heat through forced convection
! GRADIATION - calculates radiation conductance
! GBCAN - calculates boundary layer conductance of canopy
! PENMON - implements the Penman-Monteith equation
!**********************************************************************
!**********************************************************************
SUBROUTINE PSTRANSPIF(iday,ihour,RDFIPT,TUIPT,TDIPT,RNET,WIND,PAR,TAIR,TMOVE,CA,RH,VPD,VMFD,PRESS,JMAX25,&
IECO,EAVJ,EDVJ,DELSJ,VCMAX25,EAVC,EDVC,DELSC,TVJUP,TVJDN,THETA,AJQ,RD0, &
Q10F,K10F,RTEMP,DAYRESP,TBELOW,MODELGS,WSOILMETHOD,EMAXLEAF,SOILMOISTURE, &
SMD1,SMD2,WC1,WC2,SOILDATA,SWPEXP,FSOIL,G0,D0L,GAMMA,VPDMIN,G1,GK,WLEAF,NSIDES, &
VPARA,VPARB,VPARC,VFUN,SF,PSIV,ITERMAX,GSC,ALEAF,RD,ET,FHEAT, &
TLEAF,GBH,PLANTK,TOTSOILRES,MINLEAFWP,WEIGHTEDSWP,KTOT,HMSHAPE,PSIL,ETEST,CI, &
ISMAESPA,isNight,athr,tLeafCalc)
!
! 'Interface' to PSTRANSP (new subroutine, Feb. 2011).
! Calculates (numericall) the leaf water potential for the Tuzet model;
! otherwise (at the moment), proceeds to call PSTRANSP.
!**********************************************************************
USE maestcom
IMPLICIT NONE
INTEGER MODELGS,SOILDATA,WSOILMETHOD,ITER
INTEGER IECO,ITERMAX,tLeafCalc,NSIDES,VFUN
integer iday,ihour
REAL JMAX25,I0,LHV,MINROOTWP,KTOT,PSIL,K10F
REAL TLEAF,TAIR,DLEAF,VPD,VMLEAF,VMFD,RHLEAF,RH,CS,CA
REAL SLOPE,GRADN,RDFIPT,TUIPT,TDIPT,GBHU,PRESS,WIND
REAL WLEAF,PAR,TMOVE,EAVJ,EDVJ,DELSJ,VCMAX25,EAVC,EDVC
REAL DELSC,TVJUP,TVJDN,THETA,AJQ,RD0,Q10F,RTEMP,DAYRESP
REAL TBELOW,GSREF,GSMIN,D0,VK1,VK2,VPD1,VPD2,VMDF0
REAL GSJA,GSJB,T0,TREF,TMAX,SOILMOISTURE,EMAXLEAF
REAL SMD1,SMD2,WC1,WC2,SWPEXP,FSOIL,G0,D0L,GAMMA,G1
REAL GSC,ALEAF,RD,WEIGHTEDSWP,GBHF,GBH,GH,VMFD0,GBV,GSV,GV
REAL ET,RNET,GBC,TDIFF,TLEAF1,FHEAT,ETEST,SF,PSIV,HMSHAPE
REAL PSILIN,PLANTK,TOTSOILRES,MINLEAFWP,CI
REAL TMP,VPARA,VPARB,VPARC,VPDMIN,GK
LOGICAL ISMAESPA, isNight
REAL ATHR !STH 2015-0911
! Find leaf water potential that matches Tuzet model (tuzet gs = f(psi), and psi = f(gs)).
! The result is PSILIN, which is then used below to (re-)estimate all gas exchange variables.
IF(MODELGS.EQ.6)THEN
if(isNight) then
PSILIN = WEIGHTEDSWP ! borrowed from montpellier branch 2015.1019. STH
else
CALL PSILFIND(RDFIPT,TUIPT,TDIPT,RNET,WIND,PAR,TAIR,TMOVE,CA,RH,VPD,VMFD,PRESS,JMAX25,&
IECO,EAVJ,EDVJ,DELSJ,VCMAX25,EAVC,EDVC,DELSC,TVJUP,TVJDN,THETA,AJQ,RD0, &
Q10F,K10F,RTEMP,DAYRESP,TBELOW,MODELGS,WSOILMETHOD,EMAXLEAF,SOILMOISTURE, &
SMD1,SMD2,WC1,WC2,SOILDATA,SWPEXP,FSOIL,G0,D0L,GAMMA,VPDMIN,G1,GK,WLEAF,NSIDES, &
VPARA,VPARB,VPARC,VFUN,SF,PSIV,ITERMAX,GSC,ALEAF,RD,ET,FHEAT,TLEAF,GBH,PLANTK,TOTSOILRES,MINLEAFWP, &
WEIGHTEDSWP,HMSHAPE,PSILIN,ETEST, IDAY, IHOUR, tLeafCalc) ! modification mathias mars iday ihour
endif
ENDIF
!STH including ATHR in what is passed to PSTRANSPIF. 2015-0911
CALL PSTRANSP(iday,ihour,RDFIPT,TUIPT,TDIPT,RNET,WIND,PAR,TAIR,TMOVE,CA,RH,VPD,VMFD,PRESS,JMAX25,&
IECO,EAVJ,EDVJ,DELSJ,VCMAX25,EAVC,EDVC,DELSC,TVJUP,TVJDN,THETA,AJQ,RD0, &
Q10F,K10F,RTEMP,DAYRESP,TBELOW,MODELGS,WSOILMETHOD,EMAXLEAF,SOILMOISTURE, &
SMD1,SMD2,WC1,WC2,SOILDATA,SWPEXP,FSOIL,G0,D0L,GAMMA,VPDMIN,G1,GK,WLEAF,NSIDES, &
VPARA,VPARB,VPARC,VFUN,SF,PSIV,ITERMAX,GSC,ALEAF,RD,ET,FHEAT,TLEAF,GBH,PLANTK,TOTSOILRES,MINLEAFWP, &
WEIGHTEDSWP,KTOT,HMSHAPE,PSILIN,PSIL,ETEST,CI,ISMAESPA,isNight,ATHR,tLeafCalc)
END SUBROUTINE PSTRANSPIF
!**********************************************************************
SUBROUTINE PSTRANSP(iday,ihour,RDFIPT,TUIPT,TDIPT,RNET,WIND,PAR,TAIR,TMOVE,CA,RH,VPD,VMFD,PRESS,JMAX25,&
IECO,EAVJ,EDVJ,DELSJ,VCMAX25,EAVC,EDVC,DELSC,TVJUP,TVJDN,THETA,AJQ,RD0, &
Q10F,K10F,RTEMP,DAYRESP,TBELOW,MODELGS,WSOILMETHOD,EMAXLEAF,SOILMOISTURE, &
SMD1,SMD2,WC1,WC2,SOILDATA,SWPEXP,FSOIL,G0,D0L,GAMMA,VPDMIN,G1,GK,WLEAF,NSIDES, &
VPARA,VPARB,VPARC,VFUN,SF,PSIV,ITERMAX,GSC,ALEAF,RD,ET,FHEAT, &
TLEAF,GBH,PLANTK,TOTSOILRES,MINLEAFWP, &
WEIGHTEDSWP,KTOT,HMSHAPE,PSILIN,PSIL,ETEST,CI,ISMAESPA,isNight, ATHR,tLeafCalc)
! This subroutine calculates leaf photosynthesis and transpiration.
! These may be calculated by
! (1) assuming leaf temperature = air temperature, Cs = Ca and Ds = Da
! (2) using iterative scheme of Leuning et al (1995) (PC&E 18:1183-1200)
! to calculate leaf temp, Cs & Ca.
! Setting ITERMAX = 0 gives (1); ITERMAX > 0 (suggest 100) gives (2).
!**********************************************************************
USE maestcom
use switches
IMPLICIT NONE
INTEGER MODELGS,SOILDATA,WSOILMETHOD,ITER
INTEGER IECO,ITERMAX,NSIDES,VFUN
integer iday,ihour
REAL JMAX25,I0,LHV,MINROOTWP,KTOT,PSIL,K10F
REAL PLANTK,TOTSOILRES,MINLEAFWP
REAL TLEAF,TAIR,DLEAF,VPD,VMLEAF,VMFD,RHLEAF,RH,CS,CA
REAL SLOPE,GRADN,RDFIPT,TUIPT,TDIPT,GBHU,PRESS,WIND
REAL WLEAF,PAR,TMOVE,EAVJ,EDVJ,DELSJ,VCMAX25,EAVC,EDVC
REAL DELSC,TVJUP,TVJDN,THETA,AJQ,RD0,Q10F,RTEMP,DAYRESP
REAL TBELOW,GSREF,GSMIN,D0,VK1,VK2,VPD1,VPD2,VMDF0
REAL GSJA,GSJB,T0,TREF,TMAX,SOILMOISTURE,EMAXLEAF
REAL SMD1,SMD2,WC1,WC2,SWPEXP,FSOIL,G0,D0L,GAMMA,G1
REAL GSC,ALEAF,RD,WEIGHTEDSWP,GBHF,GBH,GH,VMFD0,GBV,GSV,GV
REAL ET,RNET,GBC,TDIFF,TLEAF1,FHEAT,ETEST,SF,PSIV,HMSHAPE
REAL PSILIN,CI,VPARA,VPARB,VPARC,VPDMIN,GK
!***STH addition***
REAL theAbsorbance, theReflectance, theRSolar, theSolarIn !fraction, fraction, watts/m2, watts/m2
REAL theIRAbsorbance, theTempSurroundings, theTempSky, theLeafUpperAbsorbed, theLeafLowerAbsorbed, theLeafAbsorbed
integer tLeafCalc
real RD0ACC
!^^^fraction, K, K, W/m2, W/m2, W/m2
REAL theIREmittance, theROut !fraction, W/m2
REAL STHRnet !W/m2
REAL theBoundaryLayerThickness !m
REAL theDWV !m2 s-1
REAL CMOLAR, theBoundaryLayerConductance, theBoundaryLayerResistance !?mol/?, mol/m2*sec, m2*sec/mol
REAL Kair, theSensibleForced !W m-1 °C-1 for temps 20-25°C, W/m2
REAL theWaterDiffusion, theFicksLatentHeat, thePenmanMonteithLatentHeat! W/m2, ?
REAL theEsat, theEair, theConcWaterEvap, theConcWaterAir, theFicksWatts
REAL theLHWV, thePartialPressureDryAir, thePartialPressureWaterVapour, Rdry, Rvapour, theCalcAirDensity
REAL GSDIVA
!***CJS additions
REAL t1, t2, ctr, SWdown, alb, LWdown, Ra, tempk, Re, Rn, dR, CPA, H, dH, dLE, Y, Dt, E, LE, ATHR
logical failconv
LOGICAL ISMAESPA, isNight
CHARACTER*70 errormessage
REAL, EXTERNAL :: TK
REAL, EXTERNAL :: SATUR
REAL, EXTERNAL :: GRADIATION
REAL, EXTERNAL :: GBHFORCED
REAL, EXTERNAL :: GBHFREE
REAL, EXTERNAL :: PENMON
failconv = .FALSE.
! Hydraulic conductance of the entire soil-to-leaf pathway
IF(ISMAESPA)THEN
KTOT = 1./(TOTSOILRES + 1./PLANTK)
ENDIF
!write(uwattest, *)ktot,plantk
! Set initial values of leaf temp and surface CO2 & VPD
TLEAF = TAIR !start by assuming temp of leaf is temp of air
DLEAF = VPD
VMLEAF = VMFD
RHLEAF = RH
CS = CA
! Following calculations do not depend on TLEAF
! Latent heat of water vapour at air temperature (J mol-1)
LHV = (H2OLV0 - 2.365E3 * TAIR) * H2OMW
! Const s in Penman-Monteith equation (Pa K-1)
SLOPE = (SATUR(TAIR + 0.1) - SATUR(TAIR)) / 0.1
! Radiation conductance (mol m-2 s-1)
GRADN = GRADIATION(TAIR,RDFIPT,TUIPT,TDIPT)
! Boundary layer conductance for heat - single sided, forced convection
GBHU = GBHFORCED(TAIR,PRESS,WIND,WLEAF)
!***Paw U/Berry
!print *,"------------"
!print *, tLeafCalc
if (tLeafCalc.eq.3)then
! Ra = radiation absorbed (W m^-2)
!first calculate downwelling shortwave from PAR, as it is not passed in but PAR is
SWdown = 1. / FPAR ! Global SW from fraction of total SW radiation that is PAR, set to 0.5 in Maestcom
SWdown = (SWdown / UMOLPERJ)*PAR ! now convert from umol/m2/s to W/m2 using conversion from J to umol quanta
alb = 0.5! not sure where leaf reflectivity in SW (albedo) is, so will specify it here
! also not sure where downwelling LW but assume it is either
!LWdown = ATHR
! where DOWNTHAV is the average downward thermal flux - averaged across trees
! or LWdown = DIFDN
! where DIFDN: the downwards scattered flux above gridpoint IPT
!Ra = SWdown * (1 - alb) + LWdown * EMLEAF
Ra = SWdown * (1 - alb) + ATHR !We think ATHR is long wave down * emleaf STH, CJS
endif
!**********************************************************************
ITER = 0 ! Counter for iterations - finding leaf temperature
100 CONTINUE ! Return point for iterations
!Call photosyn to get the stomatal conductance
if(isNight)then
PAR=0.001 !Just assign a very low value. STH 2015-1201
endif
CALL PHOTOSYN(PAR,TLEAF,TMOVE,CS,RHLEAF,DLEAF,VMLEAF,JMAX25,IECO,EAVJ,EDVJ,DELSJ,VCMAX25,&
EAVC,EDVC,DELSC,TVJUP,TVJDN,THETA,AJQ,RD0,Q10F,K10F,RTEMP,DAYRESP,TBELOW,&
MODELGS,GSREF,GSMIN,I0,D0,VK1,VK2,VPD1,VPD2,VMFD0,GSJA,GSJB,T0,TREF,TMAX,&
WSOILMETHOD,SOILMOISTURE,EMAXLEAF,SMD1,SMD2,WC1,WC2,SOILDATA,SWPEXP,FSOIL,&
G0,D0L,GAMMA,VPDMIN,G1,GK,GSC,ALEAF,RD,MINLEAFWP,KTOT,WEIGHTEDSWP, &
VPARA,VPARB,VPARC,VFUN,SF,PSIV,HMSHAPE,PSILIN,PSIL,CI,ISMAESPA)
! if(.not.isNight)then
! !in day time
! CALL PHOTOSYN(PAR,TLEAF,TMOVE,CS,RHLEAF,DLEAF,VMLEAF,JMAX25,IECO,EAVJ,EDVJ,DELSJ,VCMAX25,&
! EAVC,EDVC,DELSC,TVJUP,TVJDN,THETA,AJQ,RD0,Q10F,K10F,RTEMP,DAYRESP,TBELOW,&
! MODELGS,GSREF,GSMIN,I0,D0,VK1,VK2,VPD1,VPD2,VMFD0,GSJA,GSJB,T0,TREF,TMAX,&
! WSOILMETHOD,SOILMOISTURE,EMAXLEAF,SMD1,SMD2,WC1,WC2,SOILDATA,SWPEXP,FSOIL,&
! G0,D0L,GAMMA,VPDMIN,G1,GK,GSC,ALEAF,RD,MINLEAFWP,KTOT,WEIGHTEDSWP, &
! VPARA,VPARB,VPARC,VFUN,SF,PSIV,HMSHAPE,PSILIN,PSIL,CI,ISMAESPA)
! else
! CALL PHOTOSYN(0.0007,TLEAF,TMOVE,CS,RHLEAF,DLEAF,VMLEAF,JMAX25,IECO,EAVJ,EDVJ,DELSJ,VCMAX25,&
! EAVC,EDVC,DELSC,TVJUP,TVJDN,THETA,AJQ,RD0,Q10F,K10F,RTEMP,DAYRESP,TBELOW,&
! MODELGS,GSREF,GSMIN,I0,D0,VK1,VK2,VPD1,VPD2,VMFD0,GSJA,GSJB,T0,TREF,TMAX,&
! WSOILMETHOD,SOILMOISTURE,EMAXLEAF,SMD1,SMD2,WC1,WC2,SOILDATA,SWPEXP,FSOIL,&
! G0,D0L,GAMMA,VPDMIN,G1,GK,GSC,ALEAF,RD,MINLEAFWP,KTOT,WEIGHTEDSWP, &
! VPARA,VPARB,VPARC,VFUN,SF,PSIV,HMSHAPE,PSILIN,PSIL,CI,ISMAESPA)
! !in night time
! !THIS IS THE REGION TO PUT THE CIRCADIAN STOMATAL OPENING CODE
! !LOOK AT CURRENT TEIM STEP+1. IF IT HAS LIGHT, USE THAT TO CALCULATE STOMATAL
! !OPENING, BUT _NOT_ PHOTOSYNTHESIS
! !Mostly Ccopied from the photosyn subroutine 2015-1020. STH
! !GSC is GS in photosyn. STH
! GSC = 0.05!Not very elegant, but just set it to a value. STH 2015-1019
! EMAXLEAF = KTOT * (WEIGHTEDSWP - MINLEAFWP)! Maximum transpiration rate
! !IF(EMAXLEAF.LT.0.0)then
! ! EMAXLEAF = 0.0
! !endif
! ETEST = 1000 * (VPD/PATM) * GSC * GSVGSC! Leaf transpiration in mmol m-2 s-1 - ignoring boundary layer effects!
! IF(ETEST>EMAXLEAF)THEN
! GSV = 1E-03 * EMAXLEAF / (VPD/PATM)
! GSC = GSV / GSVGSC! Gsc in mol m-2 s-1
! IF(GSC.LT.1E-09)THEN
! GSC = 1E-09! A very low minimum; for numerical stability.
! ENDIF
! ENDIF
! !IF(GS.GT.0.AND.ALEAF.GT.0)THEN
! ! CI = CS - ALEAF/GS
! ! !chris wants a new function here
! ! !D13C=a+((b-a)*(CI/CA))
! ! !where a=4.4 ppt diffusive fraction of Carbon
! ! !where b=27.5 ppt fractionation of Rubisco
! ! !define the d13 variable at the very end of physiol.f90 (this file)
! !ELSE
! CI = CS! Return CI.
! ! !d13c=0.0
! !ENDIF
! !from start of photosyn. 2015-1019.STH
! !RD = RESP(RD0,RD0ACC,TLEAF,TMOVE,Q10F,K10F,RTEMP,DAYRESP,TBELOW)
! ALEAF = -RD!from start of photosyn. 2015-1019.STH
!endif
!this is wasteful in terms of lines of code, but is easier to keep track of this way
!STH 2015-1008
if (tLeafCalc.eq.0) then
! Boundary layer conductance for heat - single sided, free convection
GBHF = GBHFREE(TAIR,TLEAF,PRESS,WLEAF)
! Total boundary layer conductance for heat
GBH = GBHU + GBHF
! Total conductance for heat - two-sided
GH = 2.*(GBH + GRADN)
! Total conductance for water vapour
GBV = GBVGBH*GBH !GBVGBH is from maestcom.f90. Ratio of Gbw:Gbh magic number
!GSC is being modified in the photosyn function call. In photosyn GSC is called GS
GSV = GSVGSC*GSC !GSVGSC is from maestcom.f90. Ratio of Gsw:Gsc magic number
!GV = NSIDES*(GBV*GSV)/(GBV+GSV) ! already one-sided value
GV = (GBV*GSV)/(GBV+GSV)
! Call Penman-Monteith equation
ET = PENMON(PRESS,SLOPE,LHV,RNET,VPD,GH,GV)
! End of subroutine if no iterations wanted.
!IF (ITERMAX.EQ.0.OR.ALEAF.LE.0.0) GOTO 200
IF (ITERMAX.EQ.0) GOTO 200
! Otherwise, calculate new TLEAF, DLEAF, RHLEAF & CS
GBC = GBH/GBHGBC
CS = CA - ALEAF/GBC
TDIFF = (RNET - ET*LHV) / (CPAIR * AIRMA * GH)
TLEAF1 = TAIR + TDIFF
DLEAF = ET * PRESS / GV
RHLEAF = 1. - DLEAF/SATUR(TLEAF1)
VMLEAF = DLEAF/PRESS*1E-3
! Check to see whether convergence achieved or failed
IF (ABS(TLEAF - TLEAF1).LT.TOL) then
if(verbose.eq.2.)print *," Leaf temp convergence at iteration ", iter
GOTO 200
endif
elseif (tLeafCalc.eq.1) then
! Boundary layer conductance for heat - single sided, free convection
GBHF = GBHFREE(TAIR,TLEAF,PRESS,WLEAF)
! Total boundary layer conductance for heat
GBH = GBHU + GBHF
! Total conductance for heat - two-sided
GH = 2.*(GBH + GRADN)
! Total conductance for water vapour
GBV = GBVGBH*GBH !GBVGBH is from maestcom.f90. Ratio of Gbw:Gbh magic number
!GSC is being modified in the photosyn function call. In photosyn GSC is called GS
GSV = GSVGSC*GSC !GSVGSC is from maestcom.f90. Ratio of Gsw:Gsc magic number
!GV = NSIDES*(GBV*GSV)/(GBV+GSV) ! already one-sided value
GV = (GBV*GSV)/(GBV+GSV)
! Call Penman-Monteith equation
ET = PENMON(PRESS,SLOPE,LHV,RNET,VPD,GH,GV)
! End of subroutine if no iterations wanted.
IF (ITERMAX.EQ.0) GOTO 200
! Otherwise, calculate new TLEAF, DLEAF, RHLEAF & CS
GBC = GBH/GBHGBC
CS = CA - ALEAF/GBC
TDIFF = (RNET - ET*LHV) / (CPAIR * AIRMA * GH)
!****This is where differences from maestra start****
TLEAF1 = TAIR + TDIFF/4
! on recalcule ET modification mathias avril 2013
! Boundary layer conductance for heat - single sided, free convection
GBHF = GBHFREE(TAIR,TLEAF,PRESS,WLEAF)
! Total boundary layer conductance for heat
GBH = GBHU + GBHF
! Total conductance for heat - two-sided
GH = 2.*(GBH + GRADN)
! Total conductance for water vapour
GBV = GBVGBH*GBH
GSV = GSVGSC*GSC
! GV = NSIDES*(GBV*GSV)/(GBV+GSV) ! already one-sided value
GV = (GBV*GSV)/(GBV+GSV)
! Call Penman-Monteith equation
ET = PENMON(PRESS,SLOPE,LHV,RNET,VPD,GH,GV)
!***** fin de la modification
DLEAF = ET * PRESS / GV
RHLEAF = 1. - DLEAF/SATUR(TLEAF1)
VMLEAF = DLEAF/PRESS*1E-3
! Check to see whether convergence achieved or failed
IF (ABS(TLEAF - TLEAF1).LT.TOL/4) then
if(verbose.eq.2.)print *," Leaf temp convergence at iteration ", iter
GOTO 200
endif
elseif (tLeafCalc.eq.2) then
! Boundary layer conductance for heat - single sided, free convection
GBHF = GBHFREE(TAIR,TLEAF,PRESS,WLEAF)
! Total boundary layer conductance for heat
GBH = GBHU + GBHF
! Total conductance for heat - two-sided
GH = 2.*(GBH + GRADN)
! Total conductance for water vapour
GBV = GBVGBH*GBH !GBVGBH is from maestcom.f90. Ratio of Gbw:Gbh magic number
!GSC is being modified in the photosyn function call. In photosyn GSC is called GS
GSV = GSVGSC*GSC !GSVGSC is from maestcom.f90. Ratio of Gsw:Gsc magic number
!GV = NSIDES*(GBV*GSV)/(GBV+GSV) ! already one-sided value
GV = (GBV*GSV)/(GBV+GSV)
! Call Penman-Monteith equation
ET = PENMON(PRESS,SLOPE,LHV,RNET,VPD,GH,GV)
! End of subroutine if no iterations wanted.
!IF (ITERMAX.EQ.0.OR.ALEAF.LE.0.0) GOTO 200
IF (ITERMAX.EQ.0) GOTO 200
! Otherwise, calculate new TLEAF, DLEAF, RHLEAF & CS
GBC = GBH/GBHGBC
CS = CA - ALEAF/GBC
TDIFF = (RNET - ET*LHV) / (CPAIR * AIRMA * GH)
TLEAF1 = TAIR + TDIFF
!****This is where differences from maestra start****
! on recalcule ET modification mathias avril 2013
! Boundary layer conductance for heat - single sided, free convection
GBHF = GBHFREE(TAIR,TLEAF,PRESS,WLEAF)
! Total boundary layer conductance for heat
GBH = GBHU + GBHF
! Total conductance for heat - two-sided
GH = 2.*(GBH + GRADN)
! Total conductance for water vapour
GBV = GBVGBH*GBH
GSV = GSVGSC*GSC
! GV = NSIDES*(GBV*GSV)/(GBV+GSV) ! already one-sided value
GV = (GBV*GSV)/(GBV+GSV)
! Call Penman-Monteith equation
ET = PENMON(PRESS,SLOPE,LHV,RNET,VPD,GH,GV)
!***** fin de la modification
DLEAF = ET * PRESS / GV
RHLEAF = 1. - DLEAF/SATUR(TLEAF1)
VMLEAF = DLEAF/PRESS*1E-3
! Check to see whether convergence achieved or failed
IF (ABS(TLEAF - TLEAF1).LT.TOL) then
if(verbose.eq.2.)print *," Leaf temp convergence at iteration ", iter
GOTO 200
endif
elseif (tLeafCalc.eq.3) then
! Boundary layer conductance for heat - single sided, free convection
GBHF = GBHFREE(TAIR,TLEAF,PRESS,WLEAF)
! Total boundary layer conductance for heat
GBH = GBHU + GBHF
! Total conductance for heat - two-sided
GH = 2.*(GBH + GRADN)
! Total conductance for water vapour
GBV = GBVGBH*GBH !GBVGBH is from maestcom.f90. Ratio of Gbw:Gbh magic number
!GSC is being modified in the photosyn function call. In photosyn GSC is called GS
!GSV should already be calculated elsewhere. STH 2015-1201
GSV = GSVGSC*GSC !GSVGSC is from maestcom.f90. Ratio of Gsw:Gsc magic number
!GV = NSIDES*(GBV*GSV)/(GBV+GSV) ! already one-sided value
GV = (GBV*GSV)/(GBV+GSV)
! Call Penman-Monteith equation
!print *, "rnet: ",rnet
ET = PENMON(PRESS,SLOPE,LHV,RNET,VPD,GH,GV)
!print *, "hour: ", ihour, "rnet: ",rnet, "e: ", ET
! End of subroutine if no iterations wanted.
IF (ITERMAX.EQ.0) GOTO 200
! Otherwise, calculate new TLEAF, DLEAF, RHLEAF & CS
GBC = GBH/GBHGBC
CS = CA - ALEAF/GBC
!****This is where differences from maestra start****
!start with guessing that t1 = TLEAF = TAIR
t1 = TLEAF
!initialize t2 to TAIR plus a small offset to prevent escape
t2 = TAIR + 0.1
t1 = (t1 + t2)/2
tempk=tk(t1)!need to convert to K for S-B calculation
dR = 4.* EMLEAF * SIGMA * tempk ** 3 ! derivative of radiative dissipation; should be similar to dR = GRADN
!dR = 8.* EMLEAF * SIGMA * tempk ** 3 ! derivative of radiative dissipation; should be similar to dR = GRADN
! H = sensible heat transfer to air(W m^-2)
! molar specific heat of air (joules mol^-1 oC^-1)
CPA = 25.9
H = CPA * (t1 - TAIR) *2 * GBH
dH = CPA *2 * GBH ! dH = derivative of H; GBH should be the same as gb (total conductance to heat); multiply by 2 for 2-sided
LE = ET * LHV ! LE = latent heat (W m^-2)
dLE = GV * LHV * (VPD/PATM)! dle = derivative of LE
!print *, "hour: ", ihour, "rNet: ", rNet, "H: ", H, "LE: ", LE
Y = Rnet - H - LE! Y = error in energy balance calculation
Dt = Y / (dR + dH + dLE)! Dt = Delta-temperature
t2 = t1 + Dt ! t2 = new guess for leaf temperature
TLEAF1 = t2
!***** fin de la modification
DLEAF = ET * PRESS / GV
RHLEAF = 1. - DLEAF/SATUR(TLEAF1)
VMLEAF = DLEAF/PRESS*1E-3
! Check to see whether convergence achieved or failed
IF (ABS(TLEAF - TLEAF1).LT.TOL) then
if(verbose.eq.2.)print *," Leaf temp convergence at iteration ", iter
GOTO 200
endif
elseif (tLeafCalc.eq.4) then
!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Boundary layer conductance for heat - single sided, free convection
GBHF = GBHFREE(TAIR,TLEAF,PRESS,WLEAF)
! Total boundary layer conductance for heat
GBH = GBHU + GBHF
! Total conductance for heat - two-sided
GH = 2.*(GBH + GRADN)
! Total conductance for water vapour
GBV = GBVGBH*GBH !GBVGBH is from maestcom.f90. Ratio of Gbw:Gbh magic number
!GSC is being modified in the photosyn function call. In photosyn GSC is called GS
!GSV should already be calculated elsewhere. STH 2015-1201
GSV = GSVGSC*GSC !GSVGSC is from maestcom.f90. Ratio of Gsw:Gsc magic number
!GV = NSIDES*(GBV*GSV)/(GBV+GSV) ! already one-sided value
GV = (GBV*GSV)/(GBV+GSV)
! Call Penman-Monteith equation
!print *, "rnet: ",rnet
ET = PENMON(PRESS,SLOPE,LHV,RNET,VPD,GH,GV)
!print *, "hour: ", ihour, "rnet: ",rnet, "e: ", ET
! End of subroutine if no iterations wanted.
IF (ITERMAX.EQ.0) GOTO 200
! Otherwise, calculate new TLEAF, DLEAF, RHLEAF & CS
GBC = GBH/GBHGBC
CS = CA - ALEAF/GBC
!****This is where differences from maestra start****
!start with guessing that t1 = TLEAF = TAIR
!initialize t2 to TAIR plus a small offset to prevent escape
!t2 = TAIR + TOL
!TLEAF1 = (TLEAF1 + t2)/2
dR = 4.* EMLEAF * SIGMA * tk(TLEAF) ** 3 ! derivative of radiative dissipation; should be similar to dR = GRADN
!dR = 8.* EMLEAF * SIGMA * tempk ** 3 ! derivative of radiative dissipation; should be similar to dR = GRADN
! H = sensible heat transfer to air(W m^-2)
! molar specific heat of air (joules mol^-1 oC^-1)
CPA = 25.9
H = CPA * (TLEAF - TAIR) *2 * GBH
print *, H
print *, 2*(0.0259/(0.004*((wind/WLEAF)**0.5)))*(Tleaf-Tair)
H = 2*(0.0259/(0.004*((wind/WLEAF)**0.5)))*(Tleaf-Tair)
dH = CPA *2 * GBH ! dH = derivative of H; GBH should be the same as gb (total conductance to heat); multiply by 2 for 2-sided
LE = ET * LHV ! LE = latent heat (W m^-2)
dLE = GV * LHV * (VPD/PATM)! dle = derivative of LE
!print *, "hour: ", ihour, "rNet: ", rNet, "H: ", H, "LE: ", LE
Y = Rnet - H - LE! Y = error in energy balance calculation
TDIFF = Y / (dR + dH + dLE)! Delta-temperature
TLEAF1 = TLEAF + TDIFF ! New guess for leaf temperature
!***** fin de la modification
DLEAF = ET * PRESS / GV
RHLEAF = 1. - DLEAF/SATUR(TLEAF1)
VMLEAF = DLEAF/PRESS*1E-3
! Check to see whether convergence achieved or failed
print *, iter, ABS(TLEAF-TLEAF1), TOL
IF (ABS(TLEAF - TLEAF1).LT.TOL) then
print *, "converged"
if(verbose.eq.2.)print *," Leaf temp convergence at iteration ", iter
GOTO 200
endif
endif
IF (ITER.GT.ITERMAX) THEN
write(errormessage, '(I4,A,I2,A)') IDAY,' ', IHOUR, ' FAILED CONVERGENCE IN PSTRANSP'
CALL SUBERROR(errormessage,IWARN,0)
failconv = .TRUE.
GOTO 200
END IF
! Update temperature & do another iteration
TLEAF = TLEAF1
ITER = ITER + 1
GOTO 100
200 FHEAT = RNET - LHV*ET
! FHEAT = (TLEAF - TAIR)*2.*GBH*CPAIR*AIRMA !BM 12/05 Not correct - use energy bal instead
ET = ET*1E6 ! Return ET,EI in umol m-2 s-1
IF(ISMAESPA)THEN
! Simple transpiration rate assuming perfect coupling (for comparison).
ETEST = 1E6 * (VPD/PRESS) * GSV
! Return re-calculated leaf water potential (using ET without boundary layer conductance).
! We use ETEST otherwise PSIL < PSILMIN quite frequently when soil is dry. This is difficult to interpret,
! especially because PHOTOSYN does not account for boundary layer conductance.
!IF(MODELGS.EQ.6)THEN
PSIL = WEIGHTEDSWP - (ETEST/1000)/KTOT
ENDIF
RETURN
END SUBROUTINE PSTRANSP
!**********************************************************************
SUBROUTINE PHOTOSYN(PAR,TLEAF,TMOVE,CS,RH,VPD,VMFD, &
JMAX25,IECO,EAVJ,EDVJ,DELSJ,VCMAX25,EAVC,EDVC,DELSC,TVJUP,TVJDN, &
THETA,AJQ,RD0,Q10F,K10F,RTEMP,DAYRESP,TBELOW, &
MODELGS,GSREF,GSMIN,I0,D0,VK1,VK2,VPD1,VPD2,VMFD0, &
GSJA,GSJB,T0,TREF,TMAX,WSOILMETHOD,SOILMOISTURE, &
EMAXLEAF,SMD1,SMD2,WC1,WC2, &
SOILDATA,SWPEXP, &
FSOIL,G0,D0L,GAMMA,VPDMIN,G1,GK,GS,ALEAF,RD,MINLEAFWP,KTOT,WEIGHTEDSWP, &
VPARA,VPARB,VPARC,VFUN,SF,PSIV,HMSHAPE,PSILIN,PSIL,CI,ISMAESPA)
! This subroutine calculates photosynthesis according to the ECOCRAFT
! agreed formulation of the Farquhar & von Caemmerer (1982) equations.
! Stomatal conductance may be calculated according to the Jarvis,
! Ball-Berry or BB-Leuning models.
! NB ALEAF is NET leaf photosynthesis.
! FSOIL is now output (RAD 2008).
!**********************************************************************
USE maestcom
IMPLICIT NONE
INTEGER MODELGS,IQERROR,IECO,SOILDATA, WSOILMETHOD,IQERROR1
INTEGER VFUN
REAL PAR,TLEAF,CS,RH,VPD,VMFD,PSIL,KTOT
REAL JMAX25,EAVJ,EDVJ,DELSJ,VCMAX25,EAVC,EDVC,DELSC,TVJUP,TVJDN
REAL THETA,AJQ,RD0,Q10F,K10F,RTEMP,DAYRESP,TBELOW
REAL GSREF,GSMIN,I0,D0,VK1,VK2,VPD1,VPD2,VMFD0
REAL GSJA,GSJB,T0,TREF,TMAX
REAL G0,D0L,GAMMA,G1,MINLEAFWP
REAL GS,ALEAF,RD,MINROOTWP,RD0ACC
REAL TMOVE,RESP,FSOIL,SOILMOISTURE,SMD1,SMD2,WC1,WC2,SWPEXP
REAL VPDG,ETEST,WEIGHTEDSWP,EMAXLEAF,GSV
REAL SF,PSIV,HMSHAPE,PSILIN,VJMOD
REAL GAMMASTAR,KM,JMAX,VCMAX,J,VJ
REAL A,B,C,AC,AJ,GSDIVA,CIC,CIJ,FPSIF
REAL KMFN,JMAXTFN,CHK,CI,tmp,VPDMIN
REAL VPARA,VPARB,VPARC,GK
LOGICAL ISMAESPA
REAL, EXTERNAL :: GAMMAFN
REAL, EXTERNAL :: VCMAXTFN
REAL, EXTERNAL :: QUADM
REAL, EXTERNAL :: CALCFSOIL
REAL, EXTERNAL :: QUADP
REAL, EXTERNAL :: FPSIL
REAL, EXTERNAL :: VJMAXWFN
! Calculate photosynthetic parameters from leaf temperature.
GAMMASTAR = GAMMAFN(TLEAF,IECO) ! CO2 compensati
KM = KMFN(TLEAF,IECO) ! Michaelis-Ment
JMAX = JMAXTFN(JMAX25,TLEAF,EAVJ,EDVJ,DELSJ,TVJUP,TVJDN) ! Po
VCMAX = VCMAXTFN(VCMAX25,TLEAF,EAVC,EDVC,DELSC,TVJUP,TVJDN) ! Ma
RD = RESP(RD0,RD0ACC,TLEAF,TMOVE,Q10F,K10F,RTEMP,DAYRESP,TBELOW)
! Effect of soil water stress on Vcmax and Jmax.
IF(ISMAESPA)THEN
VJMOD = VJMAXWFN(WEIGHTEDSWP, VPARA, VPARB, VPARC, VFUN)
VCMAX = VCMAX * VJMOD
JMAX = JMAX * VJMOD
ENDIF
! Actual electron transport rate
J = QUADM(THETA,-(AJQ*PAR+JMAX),AJQ*PAR*JMAX,IQERROR)
! RuBP regeneration rate
VJ = J/4.0
! Deal with extreme cases
IF ((JMAX.LE.0.0).OR.(VCMAX.LE.0.0)) THEN
ALEAF = -RD
GS = G0
RETURN
END IF
! Calculate soil moisture modifying factor
! MAESPA uses Emax approach, or Tuzet. MAESTRA calculates it various ways based on input data.
IF(.NOT.ISMAESPA.AND.WSOILMETHOD.NE.0)THEN
FSOIL = CALCFSOIL(WSOILMETHOD,SOILMOISTURE,SOILDATA,SMD1,SMD2,WC1,WC2,SWPEXP)
ELSE
FSOIL = 1.0
ENDIF
! Note that MODELGS=5 is not implemented (but it is in Maestra).
IF (MODELGS.EQ.2) THEN
! Ball-Berry model
GSDIVA = G1 * RH / (CS - GAMMA) * FSOIL
ELSE IF (MODELGS.EQ.3) THEN
! Ball-Berry-Leuning model
GSDIVA = G1 / (CS - GAMMA) / (1 + VPD/D0L) * FSOIL
ELSE IF (MODELGS.EQ.4) THEN
IF(VPD.LT.VPDMIN)THEN
VPDG = VPDMIN/1000.0
ELSE
VPDG =VPD/1000.0
ENDIF
! Old, linearized version of BBOpti model
!GSDIVA = G1 / (CS - GAMMA) / VPDG**(1-GK)
! Full version
! NOTE: 1.6 (from corrigendum to Medlyn et al 2011) is missing here,
! because we are calculating conductance to CO2!
GSDIVA = (1.0 + G1 / VPDG**(1-GK)) / CS
ELSE IF (MODELGS.EQ.6) THEN
IF(VPD.LT.VPDMIN)THEN
VPDG = VPDMIN/1000.0
ELSE
VPDG =VPD/1000.0
ENDIF
FPSIF = FPSIL(PSILIN,SF,PSIV)
GSDIVA = (G1 / (CS - GAMMA)) * FPSIF
END IF
! Following calculations are used for both BB & BBL models.
! Solution when Rubisco activity is limiting
A = G0 + GSDIVA * (VCMAX - RD)
B = (1. - CS*GSDIVA) * (VCMAX - RD) + G0 * (KM - CS)- GSDIVA * (VCMAX*GAMMASTAR + KM*RD)
C = -(1. - CS*GSDIVA) * (VCMAX*GAMMASTAR + KM*RD) - G0*KM*CS
CIC = QUADP(A,B,C,IQERROR)
IF ((IQERROR.EQ.1).OR.(CIC.LE.0.0).OR.(CIC.GT.CS)) THEN
AC = 0.0
ELSE
AC = VCMAX * (CIC - GAMMASTAR) / (CIC + KM)
END IF
! Solution when electron transport rate is limiting
A = G0 + GSDIVA * (VJ - RD)
B = (1. - CS*GSDIVA) * (VJ - RD) + G0 * (2.*GAMMASTAR - CS) &
- GSDIVA * (VJ*GAMMASTAR + 2.*GAMMASTAR*RD)
C = -(1. - CS*GSDIVA) * GAMMASTAR * (VJ + 2.*RD) &
- G0*2.*GAMMASTAR*CS
CIJ = QUADP(A,B,C,IQERROR)
AJ = VJ * (CIJ - GAMMASTAR) / (CIJ + 2.*GAMMASTAR)
IF (AJ-RD.LT.1E-6) THEN ! Below light compensation point
CIJ = CS
AJ = VJ * (CIJ - GAMMASTAR) / (CIJ + 2.*GAMMASTAR)
END IF
ALEAF = AMIN1(AC,AJ) - RD ! Solution for Ball-Berry model
GS = G0 + GSDIVA*ALEAF
! Set nearly zero conductance (for numerical reasons).
GSMIN = 1E-09
IF (GS.LT.GSMIN) GS = GSMIN
!GS is in mmol m-2 s-1 at this point I think. STH 2015-0921
! If E > Emax, set E to Emax, and corresponding gs and A.
! Do not use this routine when the Tuzet model of gs (6) is used.
IF(ISMAESPA)THEN
IF(WSOILMETHOD.EQ.1.AND.MODELGS.NE.6)THEN
! Maximum transpiration rate
EMAXLEAF = KTOT * (WEIGHTEDSWP - MINLEAFWP)
! Leaf transpiration in mmol m-2 s-1 - ignoring boundary layer effects!
ETEST = 1000 * (VPD/PATM) * GS * GSVGSC
! Leaf water potential
PSIL = WEIGHTEDSWP - ETEST/KTOT
IF(ETEST > EMAXLEAF)THEN
! Just for output:
FSOIL = EMAXLEAF / ETEST
! Gs in mol m-2 s-1
GSV = 1E-03 * EMAXLEAF / (VPD/PATM)
GS = GSV / GSVGSC
! Minimum leaf water potential reached
! Recalculate PSIL
PSIL = WEIGHTEDSWP - EMAXLEAF/KTOT
! Matter of choice? What happens when calculated GS < G0? Is G0 a hard minimum or only in well-watered conditions?
!IF(GS.LT.G0.AND.G0.GT.0)THEN
! GS = G0
!ENDIF
! A very low minimum; for numerical stability.
IF(GS.LT.1E-09)THEN
GS = 1E-09
ENDIF
! Now that GS is known, solve for CI and A as in the Jarvis model.
! Photosynthesis when Rubisco is limiting
A = 1./GS
B = (RD - VCMAX)/GS - CS - KM
C = VCMAX * (CS - GAMMASTAR) - RD * (CS + KM)
A = 1./GS
B = (0.0 - VCMAX)/GS - CS - KM
C = VCMAX * (CS - GAMMASTAR)
AC = QUADM(A,B,C,IQERROR1)
! Photosynthesis when electron transport is limiting
A = 1./GS
B = (RD - VJ)/GS - CS - 2*GAMMASTAR
C = VJ * (CS - GAMMASTAR) - RD * (CS + 2*GAMMASTAR)
AJ = QUADM(A,B,C,IQERROR)
ALEAF = AMIN1(AC,AJ) ! Emax model solution.
ENDIF ! if (E>EMAX)
ENDIF
ENDIF
! Return CI.
IF(GS.GT.0.AND.ALEAF.GT.0)THEN
CI = CS - ALEAF/GS
!chris wants a new function here
!D13C=a+((b-a)*(CI/CA))
!where a=4.4 ppt diffusive fraction of Carbon
!where b=27.5 ppt fractionation of Rubisco
!define the d13 variable at the very end of physiol.f90 (this file)
ELSE
CI = CS
!d13c=0.0
ENDIF
RETURN
END SUBROUTINE PHOTOSYN
!**********************************************************************
REAL FUNCTION GAMMAFN(TLEAF, IECO)
! This subroutine calculates Gamma(star), or the CO2 compensation point
! in the absence of non-photorespiratory respiration.
! This is the ECOCRAFT-agreed formulation of this function.
!**********************************************************************
USE maestcom
IMPLICIT NONE
INTEGER IECO
REAL TLEAF
REAL, EXTERNAL :: ARRH
IF (IECO.EQ.1) THEN
! Ecocraft fomulation; based on Brooks & Farquhar and von Caemmerer et al.
! If TLEAF < -1.0 then calculate Gamma for T = -1 (quadratic not applicable)
IF (TLEAF.LT.-1.0) THEN
GAMMAFN = 36.9 + 1.88*(-26.0) + 0.036*(-26.0)*(-26.0)
ELSE
GAMMAFN = 36.9 + 1.88*(TLEAF-25) + 0.036*(TLEAF-25)*(TLEAF-25)
END IF
ELSE ! Bernacchi et al 2001 PCE 24: 253-260
GAMMAFN = ARRH(42.75,37830.0,TLEAF,25.0)
ENDIF
RETURN
END FUNCTION GAMMAFN
!**********************************************************************
REAL FUNCTION KMFN(TLEAF,IECO)
! This subroutine calculates Km, or the effective Michaelis-Menten
! coefficient of Rubisco activity.
! This is the ECOCRAFT-agreed formulation of this function.
!**********************************************************************
USE maestcom
IMPLICIT NONE
INTEGER IECO
REAL OI,KC25,KO25,KCEA,KOEA,KC,KO, TLEAF
REAL, EXTERNAL :: ARRH
OI = 205000 ! Oxygen partial pressure (umol mol-1)
IF (IECO.EQ.1) THEN
! Physiological constants - values agreed by Ecocraft - Badger & Collatz values
KC25 = 404 ! MM coefft of Rubisco for CO2 (umol mol-1)
KO25 = 248000 ! MM coefft of Rubisco for O2 (umol mol-1)
KCEA = 59400 ! Temp. response of Kc (J mol-1)
KOEA = 36000 ! Temp. response of Ko (J mol-1)
ELSE ! Bernacchi et al 2001 PCE 24: 253-260
KC25 = 404.9 ! MM coefft of Rubisco for CO2 (umol mol-1)
KO25 = 278400 ! MM coefft of Rubisco for O2 (umol mol-1)
KCEA = 79430 ! Temp. response of Kc (J mol-1)
KOEA = 36380 ! Temp. response of Ko (J mol-1)
END IF
! Km <- exp(38.05-79430/(8.314*(Tleaf+273)))*(1+210/exp(20.3-36380/(8.314*(Tleaf+273))))
! ARRH = KT*EXP(EA*(T-TREF)/(RCONST*(T-ABSZERO)*(TREF-ABSZERO)))
! ARRH(KT,EA,T,TREF)
! This function is well-behaved for TLEAF < 0.0
KC = ARRH(KC25,KCEA,TLEAF,25.0)
KO = ARRH(KO25,KOEA,TLEAF,25.0)
KMFN = KC * (1. + OI/KO)
RETURN
END FUNCTION KMFN
!**********************************************************************
REAL FUNCTION JMAXTFN(JMAX25,TLEAF,EAVJ,EDVJ,DELSJ,TVJUP,TVJDN)
! This subroutine calculates the potential electron transport rate
! (Jmax) at the leaf temperature.
! This is the ECOCRAFT-agreed formulation of this function.
!**********************************************************************
USE maestcom
IMPLICIT NONE
REAL JMAX25,TLEAF,EAVJ,EDVJ,DELSJ, TVJUP, TVJDN
REAL, EXTERNAL :: TK
! This function is well-behaved for TLEAF < 0.0
JMAXTFN = JMAX25 * EXP((TLEAF-25)*EAVJ/(RCONST*TK(TLEAF)*TK(25.))) &
* (1.+EXP((DELSJ*TK(25.)-EDVJ)/(RCONST*TK(25.)))) &
/ (1.+EXP((DELSJ*TK(TLEAF)-EDVJ)/(RCONST*TK(TLEAF))))
! Function allowing Vcmax to be forced linearly to zero at low T -
! introduced for Duke data
IF (TLEAF.LT.TVJDN) THEN
JMAXTFN = 0.0
ELSE IF (TLEAF.LT.TVJUP) THEN
JMAXTFN = (TLEAF - TVJDN)/(TVJUP - TVJDN)*JMAXTFN
END IF
RETURN
END FUNCTION JMAXTFN
!**********************************************************************
REAL FUNCTION VJMAXWFN(SWP, VPARA, VPARB, VPARC, VFUN)
! Dependance of Vcmax and Jmax on soil water potential (SWP).
! Modifier function (returns value between 0 and 1).
!**********************************************************************
USE maestcom
IMPLICIT NONE
REAL SWP, VPARA, VPARB, VPARC
INTEGER VFUN
IF(VFUN.EQ.0)THEN
VJMAXWFN = 1
ENDIF
! Simple linear dependance.
! VPARA is SWP where Vcmax is zero, VPARB is SWP where Vcmax is one.
IF(VFUN.EQ.1)THEN
IF(SWP.LT.VPARA)THEN
VJMAXWFN = 0
ELSEIF(SWP.GT.VPARB) THEN
VJMAXWFN = 1
ELSE
VJMAXWFN = (SWP - VPARA) / (VPARB - VPARA)
ENDIF
ENDIF
! As in Zhou, et al. Agricultural and Forest Meteorology. 2013.
IF(VFUN.EQ.2)THEN
VJMAXWFN = (1 + EXP(VPARA*VPARB) )/ (1 + EXP(VPARA*(VPARB-SWP)))
ENDIF
RETURN
END FUNCTION VJMAXWFN
!**********************************************************************
REAL FUNCTION VCMAXTFN(VCMAX25,TLEAF,EAVC,EDVC,DELSC,TVJUP,TVJDN)
! This subroutine calculates the maximum Rubisco activity
! (Vcmax) at the leaf temperature.
! This is the ECOCRAFT-agreed formulation of this function.
!**********************************************************************
USE maestcom
IMPLICIT NONE
REAL VCMAX25,TLEAF,EAVC,EDVC,DELSC
REAL TVJDN,TVJUP
REAL, EXTERNAL :: TK
! There is still disagreement as to whether this function has an
! optimum or not. Both forms are available here. If EDVC <= 0 (default 0)
! then the no-optimum form is used.
! Both functions are well-behaved for TLEAF < 0.0
IF (EDVC.LE.0.0) THEN
VCMAXTFN = VCMAX25 * EXP(EAVC*(TLEAF - 25)/ (TK(25.)*RCONST*TK(TLEAF)))
ELSE
VCMAXTFN = VCMAX25 * EXP((TLEAF-25.)*EAVC/(RCONST*TK(TLEAF)*TK(25.))) &
* (1.+EXP((DELSC*TK(25.)-EDVC)/(RCONST*TK(25.)))) &
/ (1.+EXP((DELSC*TK(TLEAF)-EDVC)/(RCONST*TK(TLEAF))))
END IF
! Function allowing Vcmax to be forced linearly to zero at low T -
! introduced for Duke data
IF (TLEAF.LT.TVJDN) THEN
VCMAXTFN = 0.0
ELSE IF (TLEAF.LT.TVJUP) THEN
VCMAXTFN = (TLEAF - TVJDN)/(TVJUP - TVJDN)*VCMAXTFN
END IF
RETURN
END FUNCTION VCMAXTFN
!**********************************************************************
REAL FUNCTION RESP(RD0,RD0ACC,TLEAF,TMOVE,Q10F,K10F,RTEMP,DAYRESP,TBELOW)
! This function calculates respiration from temperature
! using a Q10 (exponential) formulation.
!**********************************************************************
IMPLICIT NONE
REAL RD0,TLEAF,Q10F,RTEMP,DAYRESP,K10F,RD0ACC,TMOVE,TBELOW
IF (TLEAF.GE.TBELOW) THEN
RD0ACC = RD0 * EXP(K10F*(TMOVE-RTEMP))
RESP = RD0ACC * EXP(Q10F * (TLEAF-RTEMP)) * DAYRESP
ELSE
RESP = 0.0
END IF
RETURN
END FUNCTION RESP
!**********************************************************************
REAL FUNCTION ARRH(KT,EA,T,TREF)
! The Arrhenius function.
! KT is the value at Tref deg C; Ea the activation energy (J mol-1) and T the temp (deg C).
!**********************************************************************
USE maestcom
IMPLICIT NONE
REAL KT, EA, T, TREF
ARRH = KT*EXP(EA*(T-TREF)/(RCONST*(T-ABSZERO)*(TREF-ABSZERO)))
RETURN
END FUNCTION ARRH
!**********************************************************************
REAL FUNCTION ETCAN(WIND,ZHT,Z0HT,ZPD,PRESS,TAIR,RNET,VPD,GSCAN,STOCKING)
! Calculate transpiration by applying Penman-Monteith to whole canopy.
! Returns umol m-2 s-1.
!**********************************************************************
USE maestcom
IMPLICIT NONE
REAL LHV,WIND,ZHT,Z0HT,ZPD,PRESS,TAIR,RNET,VPD,GSCAN,STOCKING
REAL GB,GSV,RNETM2,SLOPE,GH,GV
REAL, EXTERNAL :: GBCAN