-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaespa.f90
1382 lines (1173 loc) · 72.3 KB
/
maespa.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
subroutine run_maespa
! =======================================================
! MAESPA: Version 2013
! For more information see www.bio.mq.edu.au/maespa
! =======================================================
!------------------------------------------------------------------------
! This file contains the main program.
! It also contains subroutines to zero arrays (ZEROHR, ZEROHIST, ZEROD)
! and to sum arrays (SUMHR, SUMDAILY).
! All other code is contained in the additional files: -
! radn.for - calculation of radiation interception
! physiol.for - physiology subroutines
! getmet.for - read in met data
! inout.for - handle input & output data
! utils.for - utility subroutines
! unstor.for - understorey calculations
! watbal.for - water balance and soil surface energy budget calculations.
!------------------------------------------------------------------------
!-----------------------------------------------------------------------
! An array model to predict radiation regime inside a plant
! community. Especially suited to forest stands where crown shape
! is described using a cone or elipsoid.
! This program consists of three main parts, i.e.
! 1: radiation in the atmosphere , daylength and the position of
! the sun at different hours of the day;
! 2: plant canopy architecture.3-D leaf area distribution and random
! and nonrandom leaf area dispersion inside crown has been incorporated
! into the radiation model with the spherical leaf angular distribution
! assumption;radiation penetration and scattering processes.
! A multi-scattering model proposed by John Norman is used.
! 3: both photosynthesis and transpiration are calculated using the
! combined gs-A-E-H model.
! 4: Water balance based on SPA routines: root water uptake, soil evaporation,
! drainage, overflow, rainfall interception, soil heat balance (RAD).
!------------------------------------------------------------------------
USE switches
USE metcom
USE maestcom
USE maindeclarations
IMPLICIT NONE
REAL, EXTERNAL :: AVERAGEVAL,CALCRMW,TK,ETCAN,RESP,GRESP
!***********************************************************************!
! Begin daily loop !
!***********************************************************************!
!WRITE(*,105) IDAY
!105 FORMAT(' DAY:',I5)
!**********************************************************************
CALL INTERPOLATEDIST(IDAY,ISTART,FRACROOTTABLE,NOROOTDATES,DATESROOT,FRACROOT,NROOTLAYER, NALPHASPEC, &
FALPHATABLESPEC,DATESLIA,NOLIADATES,FALPHASPEC,NSPECIES, &
ISMAESPA)
IF(ISMAESPA)THEN
CALL INTERPOLATEW(IDAY,ISTART,NOKPDATES,DATESKP,PLANTKTABLE,PLANTK, &
NOROOTDATES,DATESROOT,ROOTRADTABLE,ROOTDENSTABLE,ROOTMASSTOTTABLE, &
FRACROOT,LAYTHICK,ROOTRESFRAC,ROOTXSECAREA, ROOTLEN, ROOTRESIST, ROOTMASS,NROOTLAYER,ROOTRAD)
ENDIF
CALL LADCHOOSE(IDAY,ISTART,NSPECIES,NOLADDATES,DATESLAD,BPTTABLESPEC,BPTSPEC)
! FAIRE SORTIR BPTSPEC - English comments please
DO I=1,NSPECIES
CALL EXDIFF(NALPHASPEC(I),ALPHASPEC(1:MAXANG,I),FALPHASPEC(1:MAXANG,I),& ! dans la boucle Mathias février 2012
NZEN,DIFZEN,RANDOMSPEC(I),DEXTSPEC(I,1:MAXANG))
END DO
! Added 29-3-2008 (RAD): reposition met file correctly,
! to account for the looping order change.
CALL RESTARTMETF(IDAY+ISTART,MSTART,MFLAG)
! Prepare histogram
CALL ZEROSTART(HISTO,CANOPYDIMS)
! Calculate zenith angle of sun
CALL SUN(IDAY+ISTART,ALAT,TTIMD,DEC,EQNTIM,DAYL,SUNSET)
CALL ZENAZ(ALAT,TTIMD,BEAR,DEC,EQNTIM,ZEN,AZ)
! If requested in the confile, reset zenith angle to that read on the first day.
! (For simulation experiments; keep day of year the same).
IF(KEEPZEN.EQ.1.AND.IDAY.EQ.0)THEN ! Save first day.
DEC0 = DEC
EQNTIM0 = EQNTIM
DAYL0 = DAYL
SUNSET0 = SUNSET
ZEN0 = ZEN
AZ0 = AZ
ENDIF
IF(KEEPZEN.EQ.1.AND.IDAY.GT.0)THEN ! Read first day.
DEC = DEC0
EQNTIM = EQNTIM0
DAYL = DAYL0
SUNSET = SUNSET0
ZEN = ZEN0
AZ = AZ0
ENDIF
! Get meteorological data
CALL GETMET(IDAY+ISTART,MFLAG,ZEN,METCOLS,NOMETCOLS,CAK,PRESSK,SWMIN,SWMAX,DELTAT, &
ALAT,DEC,DAYL,WINDAH,TSOIL,TAIR,RADABV,FBEAM,RH,VPD,VMFD,CA,PRESS, &
PPT,SOILMOIST,SOILDATA,TSOILDATA,ETMEAS)
! Moving average air temperature (for acclimation of respiration - not currently documented feature).
MOVEWINDOW = 7 * KHRS
TAIRMEM = CSHIFT(TAIRMEM, -KHRS)
CALL REVARRAY(TAIR, MAXHRS, KHRS, TAIRR)
TAIRMEM(1:KHRS) = TAIRR(1:KHRS)
NTAIRADD = NTAIRADD + KHRS ! Keep track of how many tairs remembered.
IWHICH = MIN(MOVEWINDOW,NTAIRADD)
TMOVE = SUM(TAIRMEM(1:IWHICH))/REAL(IWHICH)
! Rain is halfhourly, re-assign it here to half-hourly values if option is set.
! Useful if rain data is really daily, and want to make realistic HH data.
IF(REASSIGNRAIN.EQ.1)THEN
PPTDAY = SUM(PPT)
CALL ASSIGNRAIN(PPTDAY,PPT)
ENDIF
IF (ICC.EQ.0) CALL ALTERMETCC(CA,TAIR,TSOIL,RH,VPD,VMFD,PRESS,CO2INC,TINC)
IF (IOTC.EQ.0) CALL ALTERMETOTC(TOTC,WINDOTC,PAROTC,FBEAMOTC,TAIR,TSOIL,WINDAH,RADABV,&
FBEAM,RH,VPD,VMFD,PRESS)
!********************************************************************
! Zero daily fluxes
CALL ZEROD(TDYAB,TOTCO2,TOTRESPF,TOTRESPWM,TOTRESPB,TOTRESPCR,TOTRESPFR,TOTH2O,TOTHFX,&
WSOILMEAN,WSOILROOTMEAN,SWPMEAN,PPTTOT,ETMMTOT,ETMEASTOT,DISCHARGETOT,SOILEVAPTOT,&
FSOILMEAN,TFALLTOT,QHTOT,QETOT,QNTOT,QCTOT,RADINTERCTOT)
NSUMMEDW = 0
! Zero hourly fluxes
CALL ZEROHR(THRAB,FCO2,FRESPF,FRESPW,FRESPB,FRESPFR,FRESPCR,FH2O,GSCAN,GBHCAN,FHEAT,PPAR,PPS,&
PTRANSP,TCAN,FSOIL1,PSILCAN,PSILCANMIN,CICAN,NSUMMED,TOTTMP,ECANMAX,ACANMAX)
!**********************************************************************
! Do understorey calculations
IF(ISIMUS .EQ. 1)THEN
IF((MOD(IDAY,IOTUTD).EQ.0).OR.IDAY.EQ.0)THEN
! Sort trees to middle of understorey points.
AX = AVERAGEVAL(XLU,NOUSPOINTS)
AY = AVERAGEVAL(YLU,NOUSPOINTS)
! Sort overstorey dimensions, save in separate arrays.
! Can move this out of loop, only needs to be done once.
CALL SORTTREESP(AX,AY,NOALLTREES,NOTREES,DXT1,DYT1,DZT1,RXTABLE1,RYTABLE1,RZTABLE1, &
ZBCTABLE1,FOLTABLE1,DIAMTABLE1,DXTUS,DYTUS,DZTUS,RXTABLEUS,RYTABLEUS, &
RZTABLEUS,FOLTABLEUS,ZBCTABLEUS,DIAMTABLEUS,ISPECIES,ISPECIESTUS,ITUUS)
! Interpolate overstorey dimensions for use in understorey calcs.
CALL INTERPOLATET(IDAY,ISTART,IHOUR,NOXDATES,DATESX,RXTABLEUS,NOYDATES,DATESY,RYTABLEUS, &
NOZDATES,DATESZ,RZTABLEUS,NOTDATES,DATEST,ZBCTABLEUS,NODDATES,DATESD, &
DIAMTABLEUS,NOLADATES,DATESLA,FOLTABLEUS,TOTLAITABLE,NOTREES, &
RXUS,RYUS,RZUS,ZBCUS,FOLTUS,TOTLAI,DIAM,STOCKING,IFLUSH,DT1,DT2,DT3, &
DT4,EXPTIME,APP,EXPAN,NEWCANOPY,CANOPYDIMS)
! Interpolate understorey dimensions
CALL INTERPUS(IDAY,ISTART,NOUSPOINTS,UNMIN,EXTKUS,GRDAREAI,DATESFU,NOFUDATES,USLAITAB,USLAI,&
DATESHU,NOHUDATES,HTUS,ZLU,DATESNU,NONUDATES,FOLNUS,FN0US,AREAUS)
! Make tree arrays of radiation-extinction related parameters,
! that may vary between species.
DO I = 1,NOTREES
JSHAPETUS(I) = JSHAPESPEC(ISPECIESTUS(I))
SHAPETUS(I) = SHAPESPEC(ISPECIESTUS(I))
DEXTTUS(I,1:MAXANG) = DEXTSPEC(ISPECIESTUS(I),1:MAXANG)
JLEAFTUS(I) = JLEAFSPEC(ISPECIESTUS(I))
NOAGECTUS(I) = NOAGECSPEC(ISPECIESTUS(I))
BPTTUS(1:8,1:MAXC,I) = BPTSPEC(1:8,1:MAXC,ISPECIESTUS(I))
PROPPTUS(1:MAXC,I) = PROPPSPEC(1:MAXC,ISPECIESTUS(I))
PROPCTUS(1:MAXC,I) = PROPCSPEC(1:MAXC,ISPECIESTUS(I))
END DO
! Diffuse transmission to the understorey points.
CALL TRANSD(IDAY,IOTUTD,NEWCANOPY,IPROGUS,NOTREES,XSLOPE,YSLOPE,NZEN,DIFZEN,NAZ,NOUSPOINTS, &
DEXTTUS,DIFSKY,XLU,YLU,ZLU,RXUS,RYUS,RZUS,DXTUS,DYTUS,DZTUS,XMAX,YMAX,SHADEHT, &
FOLTUS,ZBCUS,JLEAFTUS,BPTTUS,NOAGECTUS,PROPCT,JSHAPETUS,SHAPETUS,NEWTUTD,TUUS, &
TDUS,RELDFUS,DEXT)
ENDIF
ENDIF ! ISIMUS.EQ.1
! Loop through all trees, calculate diffuse transmittances.
! Once every IOTUTD days:
IF((MOD(IDAY,IOTUTD).EQ.0).OR.IDAY.EQ.0)THEN
DO ITAR = 1,NOTARGETS
ITREE = ITARGETS(ITAR)
ISPEC = ISPECIES(ITREE)
JLEAF = JLEAFSPEC(ISPEC)
JSHAPE = JSHAPESPEC(ISPEC)
SHAPE = SHAPESPEC(ISPEC)
BPT(1:8,1:MAXC) = BPTSPEC(1:8,1:MAXC,ISPEC)
RANDOM = RANDOMSPEC(ISPEC)
NOAGEC = NOAGECSPEC(ISPEC)
EXTWIND = EXTWINDSPEC(ISPEC)
NALPHA = NALPHASPEC(ISPEC)
ALPHA(1:MAXANG) = ALPHASPEC(1:MAXANG,ISPEC)
FALPHA(1:MAXANG) = FALPHASPEC(1:MAXANG,ISPEC)
COEFFT = COEFFTSPEC(ISPEC)
EXPONT = EXPONTSPEC(ISPEC)
WINTERC = WINTERCSPEC(ISPEC)
BCOEFFT = BCOEFFTSPEC(ISPEC)
BEXPONT = BEXPONTSPEC(ISPEC)
BINTERC = BINTERCSPEC(ISPEC)
RCOEFFT = RCOEFFTSPEC(ISPEC)
REXPONT = REXPONTSPEC(ISPEC)
RINTERC = RINTERCSPEC(ISPEC)
FRFRAC = FRFRACSPEC(ISPEC)
NOAGEP = NOAGEPSPEC(ISPEC)
PROPC(1:MAXC) = PROPCSPEC(1:MAXC,ISPEC)
PROPP(1:MAXC) = PROPPSPEC(1:MAXC,ISPEC)
ABSRP(1:MAXLAY,1:3) = ABSRPSPEC(1:MAXLAY,1:3,ISPEC)
ARHO(1:MAXLAY,1:3) = ARHOSPEC(1:MAXLAY,1:3,ISPEC)
ATAU(1:MAXLAY,1:3) = ATAUSPEC(1:MAXLAY,1:3,ISPEC)
RHOSOL(1:3) = RHOSOLSPEC(1:3,ISPEC)
JMAXTABLE(1:MAXDATE,1:MAXLAY,1:MAXC) = JMAXTABLESPEC(1:MAXDATE,1:MAXLAY,1:MAXC,ISPEC)
DATESJ(1:MAXDATE) = DATESJSPEC(1:MAXDATE,ISPEC)
NOJDATES = NOJDATESSPEC(ISPEC)
IECO = IECOSPEC(ISPEC)
EAVJ = EAVJSPEC(ISPEC)
EDVJ = EDVJSPEC(ISPEC)
DELSJ = DELSJSPEC(ISPEC)
THETA = THETASPEC(ISPEC)
VCMAXTABLE(1:MAXDATE,1:MAXLAY,1:MAXC) = VCMAXTABLESPEC(1:MAXDATE,1:MAXLAY,1:MAXC,ISPEC)
DATESV(1:MAXDATE) = DATESVSPEC(1:MAXDATE,ISPEC)
NOVDATES = NOVDATESSPEC(ISPEC)
EAVC = EAVCSPEC(ISPEC)
EDVC = EDVCSPEC(ISPEC)
DELSC = DELSCSPEC(ISPEC)
TVJUP = TVJUPSPEC(ISPEC)
TVJDN = TVJDNSPEC(ISPEC)
SLATABLE(1:maxdate,1:MAXLAY,1:MAXC) = SLATABLESPEC(1:MAXDATE,1:MAXLAY,1:MAXC,ISPEC)
DATESSLA(1:maxdate) = DATESSLASPEC(1:maxdate,ISPEC)
NOSLADATES = NOSLADATESSPEC (ISPEC)
NOADATES = NOADATESSPEC(ISPEC)
DATESA(1:MAXDATE) = DATESASPEC(1:MAXDATE,ISPEC)
AJQTABLE(1:MAXDATE,1:MAXLAY,1:MAXC) = AJQTABLESPEC(1:MAXDATE,1:MAXLAY,1:MAXC,ISPEC)
RDTABLE(1:MAXDATE,1:MAXLAY,1:MAXC) = RDTABLESPEC(1:MAXDATE,1:MAXLAY,1:MAXC,ISPEC)
DATESRD(1:MAXDATE) = DATESRDSPEC(1:MAXDATE,ISPEC)
NORDATES = NORDATESSPEC(ISPEC)
RTEMP = RTEMPSPEC(ISPEC)
DAYRESP = DAYRESPSPEC(ISPEC)
TBELOW = TBELOWSPEC(ISPEC)
EFFYRW = EFFYRWSPEC(ISPEC)
RMW = RMWSPEC(ISPEC)
RTEMPW = RTEMPWSPEC(ISPEC)
COLLA = COLLASPEC(ISPEC)
COLLK = COLLKSPEC(ISPEC)
STEMSDW = STEMSDWSPEC(ISPEC)
RMWAREA = RMWAREASPEC(ISPEC)
STEMFORM = STEMFORMSPEC(ISPEC)
NOFQDATES = NOFQDATESSPEC(ISPEC)
DATESFQ(1:MAXDATE) = DATESFQSPEC(1:maxdate,ISPEC)
Q10FTABLE(1:MAXDATE) = Q10FTABLESPEC(1:maxdate,ISPEC)
K10F = K10FSPEC(ISPEC)
NOWQDATES = NOWQDATESSPEC(ISPEC)
DATESWQ = DATESWQSPEC(1:MAXDATE,ISPEC)
Q10WTABLE(1:maxdate) = Q10WTABLESPEC(1:MAXDATE,ISPEC)
RMFR = RMFRSPEC(ISPEC)
RMCR = RMCRSPEC(ISPEC)
Q10R = Q10RSPEC(ISPEC)
RTEMPR = RTEMPRSPEC(ISPEC)
EFFYRF = EFFYRFSPEC(ISPEC)
RMB = RMBSPEC(ISPEC)
Q10B = Q10BSPEC(ISPEC)
RTEMPB = RTEMPBSPEC(ISPEC)
GSREF = GSREFSPEC(ISPEC)
GSMIN = GSMINSPEC(ISPEC)
PAR0 = PAR0SPEC(ISPEC)
D0 = D0SPEC(ISPEC)
VK1 = VK1SPEC(ISPEC)
VK2 = VK2SPEC(ISPEC)
VPD1 = VPD1SPEC(ISPEC)
VPD2 = VPD2SPEC(ISPEC)
VMFD0 = VMFD0SPEC(ISPEC)
GSJA = GSJASPEC(ISPEC)
GSJB = GSJBSPEC(ISPEC)
T0 = T0SPEC(ISPEC)
TREF = TREFSPEC(ISPEC)
TMAX = TMAXSPEC(ISPEC)
SMD1 = SMD1SPEC(ISPEC)
SMD2 = SMD2SPEC(ISPEC)
WC1 = WC1SPEC(ISPEC)
WC2 = WC2SPEC(ISPEC)
SWPEXP = SWPEXPSPEC(ISPEC)
G0TABLE = G0TABLESPEC(1:maxdate,ISPEC)
G1TABLE = G1TABLESPEC(1:maxdate,ISPEC)
DATESGS = DATESGSSPEC(1:maxdate,ISPEC)
NOGSDATES = NOGSDATESSPEC(ISPEC)
WLEAFTABLE = WLEAFTABLESPEC(1:maxdate,ISPEC)
DATESWLEAF = DATESWLEAFSPEC(1:maxdate,ISPEC)
NOWLEAFDATES = NOWLEAFDATESSPEC(ISPEC)
D0L = D0LSPEC(ISPEC)
GAMMA = GAMMASPEC(ISPEC)
VPDMIN = VPDMINSPEC(ISPEC)
SF = SFSPEC(ISPEC)
PSIV = PSIVSPEC(ISPEC)
NSIDES = NSIDESSPEC(ISPEC)
VPARA = VPARASPEC(ISPEC)
VPARB = VPARBSPEC(ISPEC)
VPARC = VPARCSPEC(ISPEC)
VFUN = VFUNSPEC(ISPEC)
! Sort the trees every timestep.
!! Arrays DXT through IT should be assigned here, sorting to be done
!! outside loop, stored in larger array.
CALL SORTTREES(NOALLTREES,NOTREES,ITREE,DXT1,DYT1,DZT1,RXTABLE1,RYTABLE1,RZTABLE1, &
ZBCTABLE1,FOLTABLE1,DIAMTABLE1,DXT,DYT,DZT,RXTABLE,RYTABLE,RZTABLE, &
FOLTABLE,ZBCTABLE,DIAMTABLE,ISPECIES,ISPECIEST,IT)
! Interpolate to get daily values of parameters
! This we can probably also do outside the hourly loop.
CALL INTERPOLATEP(IDAY,ISTART,NOJDATES,DATESJ,JMAXTABLE,NOVDATES,DATESV,VCMAXTABLE, &
NORDATES,DATESRD,RDTABLE,NOSLADATES,DATESSLA,SLATABLE,NOADATES, &
DATESA,AJQTABLE,NOFQDATES,DATESFQ,Q10FTABLE,NOWQDATES,DATESWQ, &
Q10WTABLE,NOLAY,NOAGEP,JMAX25,VCMAX25,RD0,SLA,AJQ,Q10F,Q10W, &
NOGSDATES,DATESGS,G0TABLE,G1TABLE,G0,G1,NOWLEAFDATES,DATESWLEAF,WLEAFTABLE,WLEAF)
CALL INTERPOLATET(IDAY,ISTART,IHOUR,NOXDATES,DATESX,RXTABLE,NOYDATES,DATESY,RYTABLE, &
NOZDATES,DATESZ,RZTABLE,NOTDATES,DATEST,ZBCTABLE,NODDATES,DATESD, &
DIAMTABLE,NOLADATES,DATESLA,FOLTABLE,TOTLAITABLE,NOTREES,RX,RY,RZ, &
ZBC,FOLT,TOTLAI,DIAM,STOCKING,IFLUSH,DT1,DT2,DT3,DT4,EXPTIME,APP, &
EXPAN,NEWCANOPY,CANOPYDIMS)
!!!! can move this outside the loop as well... !!!!
DO I = 1,NOTREES
JSHAPET(I) = JSHAPESPEC(ISPECIEST(I))
SHAPET(I) = SHAPESPEC(ISPECIEST(I))
DEXTT(I,1:MAXANG) = DEXTSPEC(ISPECIEST(I),1:MAXANG)
JLEAFT(I) = JLEAFSPEC(ISPECIEST(I))
NOAGECT(I) = NOAGECSPEC(ISPECIEST(I))
BPTT(1:8,1:MAXC,I) = BPTSPEC(1:8,1:MAXC,ISPECIEST(I))
PROPPT(1:MAXC,I) = PROPPSPEC(1:MAXC,ISPECIEST(I))
PROPCT(1:MAXC,I) = PROPCSPEC(1:MAXC,ISPECIEST(I))
END DO
CALL POINTSNEW(NOLAY,PPLAY,JLEAF,JSHAPE,SHAPE,RX(1),RY(1),RZ(1),ZBC(1),DXT(1),DYT(1),DZT(1), &
FOLT(1),PROPC,PROPP, &
BPT,NOAGEC,NOAGEP, XL,YL,ZL,VL,DLT,DLI,LGP,FOLLAY)
! Output xyz coordinates of crown grid points.
! This is actually useful; might make this an output option.
! Note in R: require(rgl);plot3d(x,y,z) can plot the points nicely...
! DO I =1,NUMPNT
! WRITE(UWATTEST,891)XL(I),YL(I),ZL(I)
! END DO
!891 FORMAT (6(F6.2,1X))
! Calculate diffuse transmittances
CALL TRANSD(IDAY,IOTUTD,NEWCANOPY,IPROG,NOTREES,XSLOPE,YSLOPE,NZEN,DIFZEN,NAZ,NUMPNT,DEXTT, &
DIFSKY,XL,YL,ZL,RX,RY,RZ,DXT,DYT,DZT,XMAX,YMAX,SHADEHT,FOLT,ZBC,JLEAFT,BPTT,NOAGECT,PROPCT, &
JSHAPET,SHAPET,NEWTUTD,TU,TD,RELDF,DEXT)
TUAR(ITAR, 1:NUMPNT) = TU(1:NUMPNT)
TDAR(ITAR, 1:NUMPNT) = TD(1:NUMPNT)
RELDFAR(ITAR, 1:NUMPNT) = RELDF(1:NUMPNT)
END DO ! End precalculate diffuse transmittance.
! Undocumented feature:
! Assign plant hydraulic conductance cf. Peltoniemi. This is assumed to scale with fractional diffuse
! radiation (because Kplant is proportional to APPFD in an optimal plant).
!PLANTKCR = 0.0
!DO ITAR = 1,NOTARGETS
! DO J = 1,NUMPNT
! PLANTKCR(ITAR,J) = PLANTK * RELDFAR(ITAR,J) ** KSCALING
! ENDDO
!ENDDO
! Make sure that value given in input file (PLANTK) corresponds to maximum
! -actual- plantk in the crown.
!RESCALE = PLANTK / MAXVAL(PLANTKCR)
!PLANTKCR = PLANTKCR * RESCALE
ENDIF ! IDAY=0 or IOTUTDth day.
!**********************************************************************!
! Begin hourly loop !
!**********************************************************************!
DO IHOUR = 1,KHRS
CALL ZEROFSOIL(FSOIL1,NSUMMED,TOTTMP)
! Loop over all chosen trees within subplot
DO ITAR = 1,NOTARGETS
ITREE = ITARGETS(ITAR)
! Read diffuse transmittance from precalculated array
TU(1:NUMPNT) = TUAR(ITAR, 1:NUMPNT)
TD(1:NUMPNT) = TDAR(ITAR, 1:NUMPNT)
RELDF(1:NUMPNT) = RELDFAR(ITAR, 1:NUMPNT)
! Assign arrays.
ISPEC = ISPECIES(ITREE)
JLEAF = JLEAFSPEC(ISPEC)
BPT(1:8,1:MAXC) = BPTSPEC(1:8,1:MAXC,ISPEC)
RANDOM = RANDOMSPEC(ISPEC)
NOAGEC = NOAGECSPEC(ISPEC)
JSHAPE = JSHAPESPEC(ISPEC)
SHAPE = SHAPESPEC(ISPEC)
EXTWIND = EXTWINDSPEC(ISPEC)
NALPHA = NALPHASPEC(ISPEC)
ALPHA(1:MAXANG) = ALPHASPEC(1:MAXANG,ISPEC)
FALPHA(1:MAXANG) = FALPHASPEC(1:MAXANG,ISPEC)
COEFFT = COEFFTSPEC(ISPEC)
EXPONT = EXPONTSPEC(ISPEC)
WINTERC = WINTERCSPEC(ISPEC)
BCOEFFT = BCOEFFTSPEC(ISPEC)
BEXPONT = BEXPONTSPEC(ISPEC)
BINTERC = BINTERCSPEC(ISPEC)
RCOEFFT = RCOEFFTSPEC(ISPEC)
REXPONT = REXPONTSPEC(ISPEC)
RINTERC = RINTERCSPEC(ISPEC)
FRFRAC = FRFRACSPEC(ISPEC)
NOAGEP = NOAGEPSPEC(ISPEC)
PROPC(1:MAXC) = PROPCSPEC(1:MAXC,ISPEC)
PROPP(1:MAXC) = PROPPSPEC(1:MAXC,ISPEC)
ABSRP(1:MAXLAY,1:3) = ABSRPSPEC(1:MAXLAY,1:3,ISPEC)
ARHO(1:MAXLAY,1:3) = ARHOSPEC(1:MAXLAY,1:3,ISPEC)
ATAU(1:MAXLAY,1:3) = ATAUSPEC(1:MAXLAY,1:3,ISPEC)
RHOSOL(1:3) = RHOSOLSPEC(1:3,ISPEC)
JMAXTABLE(1:maxdate,1:MAXLAY,1:MAXC) = JMAXTABLESPEC(1:maxdate,1:MAXLAY,1:MAXC,ISPEC)
DATESJ(1:maxdate) = DATESJSPEC(1:maxdate,ISPEC)
NOJDATES = NOJDATESSPEC(ISPEC)
IECO = IECOSPEC(ISPEC)
EAVJ = EAVJSPEC(ISPEC)
EDVJ = EDVJSPEC(ISPEC)
DELSJ = DELSJSPEC(ISPEC)
THETA = THETASPEC(ISPEC)
VCMAXTABLE(1:maxdate,1:MAXLAY,1:MAXC) = VCMAXTABLESPEC(1:maxdate,1:MAXLAY,1:MAXC,ISPEC)
DATESV(1:maxdate) = DATESVSPEC(1:maxdate,ISPEC)
NOVDATES = NOVDATESSPEC(ISPEC)
EAVC = EAVCSPEC(ISPEC)
EDVC = EDVCSPEC(ISPEC)
DELSC = DELSCSPEC(ISPEC)
TVJUP = TVJUPSPEC(ISPEC)
TVJDN = TVJDNSPEC(ISPEC)
SLATABLE(1:maxdate,1:MAXLAY,1:MAXC) = SLATABLESPEC(1:maxdate,1:MAXLAY,1:MAXC,ISPEC)
DATESSLA(1:maxdate) = DATESSLASPEC(1:maxdate,ISPEC)
NOSLADATES = NOSLADATESSPEC (ISPEC)
NOADATES = NOADATESSPEC(ISPEC)
DATESA(1:maxdate) = DATESASPEC(1:maxdate,ISPEC)
AJQTABLE(1:maxdate,1:MAXLAY,1:MAXC) = AJQTABLESPEC(1:maxdate,1:MAXLAY,1:MAXC,ISPEC)
RDTABLE(1:maxdate,1:MAXLAY,1:MAXC) = RDTABLESPEC(1:maxdate,1:MAXLAY,1:MAXC,ISPEC)
DATESRD(1:maxdate) = DATESRDSPEC(1:maxdate,ISPEC)
NORDATES = NORDATESSPEC(ISPEC)
RTEMP = RTEMPSPEC(ISPEC)
DAYRESP = DAYRESPSPEC(ISPEC)
TBELOW = TBELOWSPEC(ISPEC)
EFFYRW = EFFYRWSPEC(ISPEC)
RMW = RMWSPEC(ISPEC)
RTEMPW = RTEMPWSPEC(ISPEC)
COLLA = COLLASPEC(ISPEC)
COLLK = COLLKSPEC(ISPEC)
STEMSDW = STEMSDWSPEC(ISPEC)
RMWAREA = RMWAREASPEC(ISPEC)
STEMFORM = STEMFORMSPEC(ISPEC)
NOFQDATES = NOFQDATESSPEC(ISPEC)
DATESFQ(1:maxdate) = DATESFQSPEC(1:maxdate,ISPEC)
Q10FTABLE(1:maxdate) = Q10FTABLESPEC(1:maxdate,ISPEC)
K10F = K10FSPEC(ISPEC)
NOWQDATES = NOWQDATESSPEC(ISPEC)
DATESWQ = DATESWQSPEC(1:maxdate,ISPEC)
Q10WTABLE(1:maxdate) = Q10WTABLESPEC(1:maxdate,ISPEC)
RMFR = RMFRSPEC(ISPEC)
RMCR = RMCRSPEC(ISPEC)
Q10R = Q10RSPEC(ISPEC)
RTEMPR = RTEMPRSPEC(ISPEC)
EFFYRF = EFFYRFSPEC(ISPEC)
RMB = RMBSPEC(ISPEC)
Q10B = Q10BSPEC(ISPEC)
RTEMPB = RTEMPBSPEC(ISPEC)
GSREF = GSREFSPEC(ISPEC)
GSMIN = GSMINSPEC(ISPEC)
PAR0 = PAR0SPEC(ISPEC)
D0 = D0SPEC(ISPEC)
VK1 = VK1SPEC(ISPEC)
VK2 = VK2SPEC(ISPEC)
VPD1 = VPD1SPEC(ISPEC)
VPD2 = VPD2SPEC(ISPEC)
VMFD0 = VMFD0SPEC(ISPEC)
GSJA = GSJASPEC(ISPEC)
GSJB = GSJBSPEC(ISPEC)
T0 = T0SPEC(ISPEC)
TREF = TREFSPEC(ISPEC)
TMAX = TMAXSPEC(ISPEC)
SMD1 = SMD1SPEC(ISPEC)
SMD2 = SMD2SPEC(ISPEC)
WC1 = WC1SPEC(ISPEC)
WC2 = WC2SPEC(ISPEC)
SWPEXP = SWPEXPSPEC(ISPEC)
G0TABLE = G0TABLESPEC(1:maxdate,ISPEC)
G1TABLE = G1TABLESPEC(1:maxdate,ISPEC)
WLEAFTABLE = WLEAFTABLESPEC(1:maxdate,ISPEC)
GK = GKSPEC(ISPEC)
!DATESGS = DATESGSSPEC(1:MASPDATE,ISPEC)
DATESGS = DATESGSSPEC(1:maxdate,ISPEC)
!DATESWLEAF = DATESWLEAFSPEC(1:MASPDATE,ISPEC)
DATESWLEAF = DATESWLEAFSPEC(1:maxdate,ISPEC)
NOGSDATES= NOGSDATESSPEC(ISPEC)
NOWLEAFDATES= NOWLEAFDATESSPEC(ISPEC)
D0L = D0LSPEC(ISPEC)
GAMMA = GAMMASPEC(ISPEC)
SF = SFSPEC(ISPEC)
PSIV = PSIVSPEC(ISPEC)
NSIDES = NSIDESSPEC(ISPEC)
! Sort the trees every timestep.
! This should be done outside the hourly loop, and stored in an array.
CALL SORTTREES(NOALLTREES,NOTREES,ITREE,DXT1,DYT1,DZT1,RXTABLE1,RYTABLE1,RZTABLE1,ZBCTABLE1,&
FOLTABLE1,DIAMTABLE1,DXT,DYT,DZT,RXTABLE,RYTABLE,RZTABLE,FOLTABLE,ZBCTABLE, &
DIAMTABLE,ISPECIES,ISPECIEST,IT)
DO I = 1,NOTREES
JSHAPET(I) = JSHAPESPEC(ISPECIEST(I))
SHAPET(I) = SHAPESPEC(ISPECIEST(I))
DEXTT(I,1:MAXANG) = DEXTSPEC(ISPECIEST(I),1:MAXANG)
JLEAFT(I) = JLEAFSPEC(ISPECIEST(I))
NOAGECT(I) = NOAGECSPEC(ISPECIEST(I))
BPTT(1:8,1:MAXC,I) = BPTSPEC(1:8,1:MAXC,ISPECIEST(I))
PROPPT(1:MAXC,I) = PROPPSPEC(1:MAXC,ISPECIEST(I))
PROPCT(1:MAXC,I) = PROPCSPEC(1:MAXC,ISPECIEST(I))
END DO
! Interpolate to get daily values of parameters
! This we can probably also do outside the hourly loop.
CALL INTERPOLATEP(IDAY,ISTART,NOJDATES,DATESJ,JMAXTABLE,NOVDATES,DATESV,VCMAXTABLE,NORDATES,&
DATESRD,RDTABLE,NOSLADATES,DATESSLA,SLATABLE,NOADATES,DATESA,AJQTABLE, &
NOFQDATES,DATESFQ,Q10FTABLE,NOWQDATES,DATESWQ,Q10WTABLE,NOLAY,NOAGEP, &
JMAX25,VCMAX25,RD0,SLA,AJQ,Q10F,Q10W,NOGSDATES,DATESGS,G0TABLE,G1TABLE,G0,G1,NOWLEAFDATES,DATESWLEAF,WLEAFTABLE,WLEAF)
CALL INTERPOLATET(IDAY,ISTART,IHOUR,NOXDATES,DATESX,RXTABLE,NOYDATES,DATESY,RYTABLE,NOZDATES, &
DATESZ,RZTABLE,NOTDATES,DATEST,ZBCTABLE,NODDATES,DATESD,DIAMTABLE, &
NOLADATES,DATESLA,FOLTABLE,TOTLAITABLE,NOTREES,RX,RY,RZ,ZBC,FOLT, &
TOTLAI,DIAM,STOCKING,IFLUSH,DT1,DT2,DT3,DT4,EXPTIME,APP,EXPAN,NEWCANOPY, &
CANOPYDIMS)
CALL POINTSNEW(NOLAY,PPLAY,JLEAF,JSHAPE,SHAPE,RX(1),RY(1),RZ(1),ZBC(1),DXT(1),DYT(1),&
DZT(1),FOLT(1),PROPC,PROPP,BPT,NOAGECT(1),NOAGEP,XL,YL,ZL,VL,DLT,DLI,&
LGP,FOLLAY)
! Following function s need FOLLAY.
CALL GETWIND(FOLLAY,FOLT(1),TOTLAI,EXTWIND,WINDLAY)
! Calculate woody biomass and woody biomass increment
CALL CALCWBIOM(IDAY,RZ(1)+ZBC(1),DIAM(1),COEFFT,EXPONT,WINTERC,WBIOM,WBINC)
CALL CALCWBIOM(IDAY,RZ(1)+ZBC(1),DIAM(1),BCOEFFT,BEXPONT,BINTERC,BBIOM,BBINC)
CALL CALCWBIOM(IDAY,RZ(1)+ZBC(1),DIAM(1),RCOEFFT,REXPONT,RINTERC,RBIOM,RBINC)
! Calculate foliar biomass and increment
CALL CALCFBIOM(IDAY,NOSLADATES,FOLLAY,SLA,PROPP,NOLAY,NOAGEP,FBIOM,FBINC)
! Calculate stem respiration rate per unit biomas
RMW = CALCRMW(MODELRW,COLLA,COLLK,STEMSDW,DIAM(1),RZ(1)+ZBC(1),STEMFORM,RMWAREA,WBIOM,RMW)
! Output information to layer flux file if required
IF (IOHRLY.GT.1) CALL OUTPUTLAY(ULAY,FOLLAY,JMAX25,VCMAX25,NOLAY)
! If the diffuse transmittances have changed, must set up the EHC
IF (NEWTUTD.EQ.1.AND.TOTLAI.GT.0) THEN
CALL EHC(NUMPNT,TU,TD,TOTLAI,XSLOPE,YSLOPE,NAZ,NZEN,DIFZEN,DEXT,DLAI,EXPDIF,LAYER,MLAYER)
END IF
IF(ISMAESPA)THEN
! Assign soil water measurement to SOILMOIST, depending on settings.
CALL ASSIGNSOILWATER(WSOILMETHOD,USEMEASSW,SWMIN,SWMAX,SOILMOIST(IHOUR), WSOILROOT, &
SOILDEPTH,SOILDATA, SOILMOISTURE)
! Soil water potential, conductivity & conductance, fractional uptake (but no uptake yet).
CALL CALCSOILPARS(NLAYER,NROOTLAYER,SOILWP,FRACWATER,FRACORGANIC,POREFRAC,SOILCOND,THERMCOND, &
ROOTMASS,ROOTLEN,LAYTHICK,ICEPROP,EQUALUPTAKE,RETFUNCTION,USEMEASSW, &
SOILDATA, SOILMOISTURE,PSIE,BPAR,KSAT,ROOTRESIST,ROOTRESFRAC, &
ROOTRAD,MINROOTWP,TOTLAI,WINDAH(IHOUR),ZHT,Z0HT,GAMSOIL, &
WEIGHTEDSWP,TOTESTEVAP, &
FRACUPTAKE,TOTSOILRES,ALPHARET,WS,WR,NRET)
! Soil surface T for SCATTER routine:
IF(SIMTSOIL.EQ.0)THEN ! No Tsoil simulated.
PREVTSOIL = TK(TSOIL(IHOUR))
ELSE
PREVTSOIL = SOILTEMP(1)
ENDIF
ELSE
WEIGHTEDSWP = 0
ENDIF
! Test to see if daylight hours or if any foliage
IF ((ABS(ZEN(IHOUR)) < PI/2.0 ) .AND. (RADABV(IHOUR,1) > 1.0) .AND. (FOLT(1) > 0.0)) THEN
! Get slope correction factor
CALL SLOPES(IHOUR,TTIMD,EQNTIM,ALAT,DEC,XSLOPE,YSLOPE,BEAR,ZEN(IHOUR),BMULT,DMULT2,SOMULT)
! Get extinction coefficients
DO I=1,NSPECIES
CALL EXDIFF(NALPHASPEC(I),ALPHASPEC(1:MAXANG,I),FALPHASPEC(1:MAXANG,I),NZEN,DIFZEN,&
RANDOMSPEC(I),DEXTSPEC(I,1:MAXANG))
CALL EXBEAM(NALPHASPEC(I),ALPHASPEC(1:MAXANG,I),FALPHASPEC(1:MAXANG,I),RANDOMSPEC(I),&
ZEN(IHOUR),BEXTSPEC(I),BEXTANGSPEC(I,1:MAXANG))
END DO
DO I=1,NOTREES
BEXTT(I) = BEXTSPEC(ISPECIEST(I))
BEXTANGT(I,1:MAXANG) = BEXTANGSPEC(ISPECIEST(I),1:MAXANG)
END DO
! Understorey calculations.
IF(ISIMUS.EQ.1)THEN
! Find extinction coefficients for beam component,
! sorted to understorey midpoint (ISPECIESTUS).
DO I=1,NOTREES
BEXTTUS(I) = BEXTSPEC(ISPECIESTUS(I))
BEXTANGTUS(I,1:MAXANG) = BEXTANGSPEC(ISPECIESTUS(I),1:MAXANG)
END DO
DO IPTUS = 1,NOUSPOINTS
! Beam radiation on the understorey points.
CALL TRANSB(IHOUR,IPROGUS,ZEN(IHOUR),AZ(IHOUR),XSLOPE,YSLOPE,FBEAM,BEXTTUS,XLU(IPTUS), &
YLU(IPTUS),ZLU(IPTUS),RXUS,RYUS,RZUS,DXTUS,DYTUS,DZTUS,XMAX,YMAX,SHADEHT, &
FOLTUS,ZBCUS,JLEAFTUS,BPTTUS,NOAGECTUS,PROPCTUS,JSHAPETUS,SHAPETUS,NOTREES, &
SUNLA,BEXTUS,BEXTANGTUS,BEXTANGUS) ! BEXTUS not used...
! Output transmittances (Note IWAVE=1 only).
PAR = RADABV(IHOUR,1)
TDIFF = (1-FBEAM(IHOUR,1))*PAR*TDUS(IPTUS)
TSCAT = 0 !DIFDN(IPTUS,1)*UMOLPERJ
! PAR at all understorey points, diffuse, direct, and total.
UIBEAM(IHOUR,IPTUS) = FBEAM(IHOUR,1)*PAR*SUNLA
UIDIFF(IHOUR,IPTUS) = TDIFF + TSCAT
PARUS(IHOUR,IPTUS) = UIDIFF(IHOUR,IPTUS) + UIBEAM(IHOUR,IPTUS)
! Global radiation to understorey points
!NIRUS(IHOUR,IPTUS) = FBEAM(IHOUR,1)*RADABV(IHOUR,1)*SUNLA
! Get parameters of BEWDY model
CALL BEWDYPARMS(IHOUR,TAIR(IHOUR),RH(IHOUR),CA(IHOUR),JMAXN25,IECOU,EAVJU,EDVJU,DELSJU, &
TVJUPU,TVJDNU,VCMAXN25,EAVCU,EDVCU,DELSCU,AJQU,GSBG0U,GSBG1U,CICARAT, &
BALPHA,BLAMBDA)
IF (MOSS.EQ.1) THEN
CALL PSMOSS(UMOLPERJ*PARUS(IHOUR,IPTUS),TAIR(IHOUR),RH(IHOUR),CA(IHOUR),JMAX25M,IECOU, &
EAVJU,EDVJU,DELSJU,TVJUPU,TVJDNU,VCMAX25M,EAVCU,EDVCU,DELSCU,AJQU,THETAM, &
PSUS(IHOUR,IPTUS))
GSIPT = 0.0
ETUS = 0.0
ELSE
! Otherwise call BEWDY model to calculate understorey photosynthesis
!! Note UIBEAM is divided by SUNLA, gets back-converted in BEWDY subr.
IF(SUNLA.GT.0.0) THEN
BEAMP = UMOLPERJ*UIBEAM(IHOUR,IPTUS)/SUNLA
ELSE
BEAMP = 0.0
ENDIF
CALL BEWDY(IHOUR,BEAMP,UMOLPERJ*UIDIFF(IHOUR,IPTUS),SUNLA,BALPHA,BLAMBDA,FN0US(IPTUS), &
UNMIN,EXTKUS,ABSRPU,USLAI(IPTUS), APARUS(IHOUR,IPTUS),PSUS(IHOUR,IPTUS), &
PARUNDER(IHOUR,IPTUS))
! Net photosynthesis
PSUS(IHOUR,IPTUS) = PSUS(IHOUR,IPTUS) - RD0US
! Bewdy outputs in mu mol, convert to W m-2
APARUS(IHOUR,IPTUS) = APARUS(IHOUR,IPTUS) / UMOLPERJ
PARUNDER(IHOUR,IPTUS) = PARUNDER(IHOUR,IPTUS) / UMOLPERJ
! Stomatal conductance and transpiration - estimated at whole-clump level, mol CO2 m-2 s-1
GSIPT = GSBG0U + GSBG1U*PSUS(IHOUR,IPTUS) * RH(IHOUR)/CA(IHOUR)
! mmol H2O m-2 s-1
ETUS(IHOUR,IPTUS) = GSIPT*1.6*VPD(IHOUR)/PRESS(IHOUR)*1E3
END IF
END DO ! Loop over understorey points.
! Sum understorey arrays over all points:
CALL SUMHRUS(IHOUR,NOUSPOINTS,GRDAREAI,AREAUS,PARUS,PARUSMEAN,PARUSSD,APARUS,PSUS,ETUS,THRABUS,&
FCO2US,FH2OUS)
ENDIF ! Understorey calculations
! Loop over grid points
DO IPT = 1,NUMPNT
! Calculate the weighted pathlengths for beam radiation.
CALL TRANSB(IHOUR,IPROG,ZEN(IHOUR),AZ(IHOUR),XSLOPE,YSLOPE,FBEAM,BEXTT,XL(IPT),YL(IPT),ZL(IPT),&
RX,RY,RZ,DXT,DYT,DZT,XMAX,YMAX,SHADEHT,FOLT,ZBC,JLEAFT,BPTT,NOAGECT,PROPCT,JSHAPET,&
SHAPET,NOTREES,SUNLA,BEXT,BEXTANGT,BEXTANG)
! Assign plant hydraulic conductance
!PLANTK = PLANTKCR(ITAR,IPT)
! Loop over the 3 wavelengths
DO IWAVE = 1,3
! Calculate the scattered radiation
CALL SCATTER(IPT,IWAVE,MLAYER(IPT),LAYER(IPT),DLAI,EXPDIF,ZEN(IHOUR),BEXT,DMULT2,SOMULT,BMULT,&
RADABV(IHOUR,IWAVE),FBEAM(IHOUR,IWAVE),TAIR(IHOUR),PREVTSOIL,ARHO(LGP(IPT),IWAVE),&
ATAU(LGP(IPT),IWAVE),RHOSOL(IWAVE),DIFUP,DIFDN,SCLOST,DOWNTH)
! Lost scattered radiation for each tree (W m-2), averaged over the grid points.
! RAD June 2008.
SCLOSTTREE(ITAR,1) = SUM(SCLOST(1:NUMPNT,1)) / NUMPNT
SCLOSTTREE(ITAR,2) = SUM(SCLOST(1:NUMPNT,2)) / NUMPNT
! Assume zero reflectance in TR waveband (Norman 1979)
! But store in the same array the lost tranmission at top of canopy.
SCLOSTTREE(ITAR,3) = SUM(SCLOST(1:NUMPNT,2)) / NUMPNT
! Downwelling longwave radiation (calculated for each gridpoint
! with the EHC) averaged across the grid points.
IF(IWAVE.EQ.3)DOWNTHTREE(ITAR) = SUM(DOWNTH) / NUMPNT
! Calculate absorbed radiation
CALL ABSRAD(IPT,IWAVE,NZEN,DEXT,BEXT,BMULT,RELDF(IPT),RADABV(IHOUR,IWAVE),&
FBEAM(IHOUR,IWAVE),ZEN(IHOUR),ABSRP(LGP(IPT),IWAVE),DIFDN(IPT,IWAVE),&
DIFUP(IPT,IWAVE),DFLUX,BFLUX,SCATFX)
END DO
! Calculation of photosynthesis may be done for sunlit & shaded leaves
! separately, or by averaging PAR over the total leaf area
IF ((MODELSS.EQ.0).AND.(FBEAM(IHOUR,1).NE.0.0)) THEN
! Do calculations separately for sunlit & shaded leaves
DO ISUNLIT = 1,2 ! Loop over sunlit & shaded leaves
IF (ISUNLIT.EQ.1) THEN
APAR = (BFLUX(IPT,1)*BEXT + DFLUX(IPT,1))*UMOLPERJ
ANIR = BFLUX(IPT,2)*BEXT + DFLUX(IPT,2)
FAREA = SUNLA
ELSE
APAR = DFLUX(IPT,1)*UMOLPERJ
ANIR = DFLUX(IPT,2)
FAREA = 1.0 - SUNLA
END IF
ATHR = DFLUX(IPT,3)
RNET = APAR/UMOLPERJ + ANIR + ATHR
DO IAGE = 1,NOAGEP ! Loop over age classes
AREA = FAREA * DLI(IAGE,IPT) * VL(IPT) ! m2
IF (IOHIST.EQ.1) CALL CATEGO(AREA,APAR,HISTO,BINSIZE,ITAR)
! Call physiology routine
CALL PSTRANSPIF(iday,ihour,RELDF(IPT),TU(IPT),TD(IPT),RNET,WINDAH(IHOUR)*WINDLAY(LGP(IPT)),APAR, &
TAIR(IHOUR),TMOVE,CA(IHOUR),RH(IHOUR),VPD(IHOUR),VMFD(IHOUR),PRESS(IHOUR), &
JMAX25(LGP(IPT),IAGE),IECO,EAVJ,EDVJ,DELSJ,VCMAX25(LGP(IPT),IAGE),EAVC, &
EDVC,DELSC,TVJUP,TVJDN,THETA,AJQ(LGP(IPT),IAGE),RD0(LGP(IPT),IAGE),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,HFX,TLEAF,GBH,PLANTK,TOTSOILRES,MINLEAFWP,WEIGHTEDSWP,KTOT, &
HMSHAPE,PSIL,ETEST,CI,ISMAESPA)
892 FORMAT (1(I10),6(F10.5,1X))
! Sum (or average) outputs for the hour
CALL SUMHR(APAR/UMOLPERJ,ANIR,ATHR,ALEAF,RD,GSC,GBH,ET,HFX,TLEAF,FSOIL,PSIL,CI,AREA,IHOUR,LGP(IPT),ITAR,&
NOTARGETS,NUMPNT,NSUMMED,TOTTMP,PPAR,PPS,PTRANSP,THRAB,FCO2,FRESPF,GSCAN,GBHCAN,FH2O, &
FHEAT,TCAN,FSOIL1,PSILCAN,PSILCANMIN,CICAN,ECANMAX,ACANMAX)
END DO
END DO ! End loop over sunlit / shaded leaves
ELSE IF ((MODELSS.EQ.1).OR.(FBEAM(IHOUR,1).EQ.0.0)) THEN
! Do calculations for PAR averaged over all leaf area
APAR = (BFLUX(IPT,1)*BEXT*SUNLA + DFLUX(IPT,1))*UMOLPERJ
ANIR = BFLUX(IPT,2)*BEXT*SUNLA + DFLUX(IPT,2)
ATHR = DFLUX(IPT,3)
RNET = APAR/UMOLPERJ + ANIR + ATHR
DO IAGE = 1,NOAGEP ! Loop over age classes
AREA = DLI(IAGE,IPT) * VL(IPT)
IF (IOHIST.EQ.1) CALL CATEGO(AREA,APAR,HISTO,BINSIZE,ITAR)
! Call physiology routine
CALL PSTRANSPIF(iday,ihour,RELDF(IPT),TU(IPT),TD(IPT),RNET,WINDAH(IHOUR)*WINDLAY(LGP(IPT)), &
APAR,TAIR(IHOUR),TMOVE,CA(IHOUR),RH(IHOUR),VPD(IHOUR), &
VMFD(IHOUR),PRESS(IHOUR),JMAX25(LGP(IPT),IAGE), &
IECO,EAVJ,EDVJ,DELSJ,VCMAX25(LGP(IPT),IAGE),EAVC,EDVC,DELSC, &
TVJUP,TVJDN,THETA,AJQ(LGP(IPT),IAGE),RD0(LGP(IPT),IAGE),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,HFX,TLEAF, &
GBH,PLANTK,TOTSOILRES,MINLEAFWP,WEIGHTEDSWP,KTOT,HMSHAPE,PSIL,ETEST,CI,ISMAESPA)
! Sum outputs for the hour
CALL SUMHR(APAR/UMOLPERJ,ANIR,ATHR,ALEAF,RD,GSC,GBH,ET,HFX,TLEAF,FSOIL,PSIL,CI,AREA,IHOUR,LGP(IPT),ITAR,&
NOTARGETS,NUMPNT,NSUMMED,TOTTMP,PPAR,PPS,PTRANSP,THRAB,FCO2,FRESPF,GSCAN,GBHCAN,FH2O, &
FHEAT,TCAN,FSOIL1,PSILCAN,PSILCANMIN,CICAN,ECANMAX,ACANMAX)
END DO ! End loop over age classes
ELSE IF ((MODELSS.EQ.2).AND.(FBEAM(IHOUR,1).NE.0.0)) THEN
! Do calculations separately for sunlit & shaded. Further separate sunlit
! into leaf angle classes.
DO ISUNLIT = 1,NALPHA+1
IF (ISUNLIT.GT.NALPHA) THEN
APAR = DFLUX(IPT,1)*UMOLPERJ
ANIR = DFLUX(IPT,2)
FAREA = 1.0 - SUNLA
ELSE
APAR = (BFLUX(IPT,1)*BEXTANG(ISUNLIT) + DFLUX(IPT,1))*UMOLPERJ
ANIR = BFLUX(IPT,2)*BEXTANG(ISUNLIT) + DFLUX(IPT,2)
FAREA = SUNLA*FALPHA(ISUNLIT)
END IF
ATHR = DFLUX(IPT,3)
RNET = APAR/UMOLPERJ + ANIR + ATHR
DO IAGE = 1,NOAGEP ! Loop over age classes
AREA = FAREA * DLI(IAGE,IPT) * VL(IPT) ! m2
IF (IOHIST.EQ.1) CALL CATEGO(AREA,APAR,HISTO,BINSIZE,ITAR)
! Call physiology routine
CALL PSTRANSPIF(iday,ihour,RELDF(IPT),TU(IPT),TD(IPT),RNET,WINDAH(IHOUR)*WINDLAY(LGP(IPT)), &
APAR,TAIR(IHOUR),TMOVE,CA(IHOUR),RH(IHOUR),VPD(IHOUR), &
VMFD(IHOUR),PRESS(IHOUR),JMAX25(LGP(IPT),IAGE),IECO, &
EAVJ,EDVJ,DELSJ,VCMAX25(LGP(IPT),IAGE), &
EAVC,EDVC,DELSC,TVJUP,TVJDN,THETA,AJQ(LGP(IPT),IAGE), &
RD0(LGP(IPT),IAGE),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,HFX,TLEAF,GBH,PLANTK,TOTSOILRES,MINLEAFWP,WEIGHTEDSWP,KTOT, &
HMSHAPE,PSIL,ETEST,CI,ISMAESPA)
! Sum outputs for the hour
CALL SUMHR(APAR/UMOLPERJ,ANIR,ATHR,ALEAF,RD,GSC,GBH,ET,HFX,TLEAF,FSOIL,PSIL,CI,AREA,IHOUR, &
LGP(IPT),ITAR,NOTARGETS,NUMPNT,NSUMMED,TOTTMP, PPAR,PPS,PTRANSP, &
THRAB,FCO2,FRESPF,GSCAN,GBHCAN,FH2O,FHEAT,TCAN,FSOIL1,PSILCAN,PSILCANMIN,CICAN, &
ECANMAX,ACANMAX)
END DO
END DO ! End loop over sunlit / shaded leaves
END IF ! Separating sunlit & shaded foliage, or not
! Write sunlit leaf area to file.
IF(ISUNLA.EQ.1)THEN
AREA = DLT(IPT) * VL(IPT) ! LEAF AREA FOR THIS GRIDPOINT ! Modification Mathias 27/11/2012
WRITE(USUNLA, 112) IDAY, IHOUR, ITREE, IPT, SUNLA, &
AREA, BEXT, &
FBEAM(IHOUR,1), ZEN,ABSRP(LGP(IPT),1),ABSRP(LGP(IPT),2),ABSRP(LGP(IPT),3), &
BFLUX(IPT,1), DFLUX(IPT,1), BFLUX(IPT,2),DFLUX(IPT,2),DFLUX(IPT,3), &
SCLOST(IPT,1),SCLOST(IPT,2),SCLOST(IPT,3),DOWNTH(IPT),RADABV(IHOUR,1),RADABV(IHOUR,2),RADABV(IHOUR,3)
ENDIF
112 FORMAT(4(1X,I4), 7(1X,F12.3), 13(1X,F12.3))
END DO ! End loop over grid points
! Calculate transpiration by applying Penman-Monteith to canopy
FH2OCAN(ITAR,IHOUR) = ETCAN(WINDAH(IHOUR),ZHT,Z0HT,ZPD,PRESS(IHOUR),TAIR(IHOUR), &
THRAB(ITAR,IHOUR,1)+THRAB(ITAR,IHOUR,2)+THRAB(ITAR,IHOUR,3),&
VPD(IHOUR),GSCAN(ITAR,IHOUR),STOCKING)
! Normalise to get average foliage temperature
TCAN(ITAR,IHOUR) = TCAN(ITAR,IHOUR)/FOLT(1)
! Same for leaf water potential
PSILCAN(ITAR,IHOUR) = PSILCAN(ITAR,IHOUR)/FOLT(1)
! And ci
CICAN(ITAR,IHOUR) = CICAN(ITAR,IHOUR)/FOLT(1)
ELSE ! Night-time
! Canopy T at nighttime is same as air temperature.
TCAN(ITAR,IHOUR) = TAIR(IHOUR)
! Leaf water potential same as soil water potential
PSILCAN(ITAR,IHOUR) = WEIGHTEDSWP
PSILCANMIN(ITAR,IHOUR) = WEIGHTEDSWP
! And ci the same as ca
CICAN(ITAR,IHOUR) = CA(IHOUR)
! Loop over grid points
DO IPT = 1,NUMPNT
! Calculate the scattered radiation, for thermal only.
CALL SCATTER(IPT,3,MLAYER(IPT),LAYER(IPT),DLAI,EXPDIF,ZEN(IHOUR),BEXT,DMULT2,SOMULT,&
BMULT,RADABV(IHOUR,3), &
FBEAM(IHOUR,3),TAIR(IHOUR),PREVTSOIL, ARHO(LGP(IPT),3), &
ATAU(LGP(IPT),3),RHOSOL(3),DIFUP, &
DIFDN,SCLOST,DOWNTH)
! Lost scattered radiation for each tree (W m-2), averaged over the grid points.
! RAD June 2008.
SCLOSTTREE(ITAR,1) = SUM(SCLOST(1:NUMPNT,1)) / NUMPNT
SCLOSTTREE(ITAR,2) = SUM(SCLOST(1:NUMPNT,2)) / NUMPNT
! Assume zero reflectance in TR waveband (Norman 1979)
SCLOSTTREE(ITAR,3) = 0.
! Downward thermal flux, averaged across grid points in this tree:
DOWNTHTREE(ITAR) = SUM(DOWNTH) / NUMPNT
! Calculate absorbed radiation
CALL ABSRAD(IPT,3,NZEN,DEXT,BEXT,BMULT,RELDF(IPT),RADABV(IHOUR,3),FBEAM(IHOUR,3),ZEN(IHOUR),&
ABSRP(LGP(IPT),3),DIFDN(IPT,3),DIFUP(IPT,3),DFLUX,BFLUX,SCATFX)
! Absorbed thermal radiation
ATHR = DFLUX(IPT,3)
DO IAGE = 1,NOAGEP ! Loop over age classes
AREA = DLI(IAGE,IPT) * VL(IPT) ! m2
! Sum outputs for the hour (Added RAD, Aug. 2008).
CALL SUMHR(0.0,0.0,ATHR,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,AREA,IHOUR,LGP(IPT),&
ITAR,NOTARGETS,NUMPNT,NSUMMED,TOTTMP,PPAR,PPS,PTRANSP,THRAB,&
FCO2,FRESPF,GSCAN,GBHCAN,FH2O,FHEAT,TCAN,FSOIL1,PSILCAN,PSILCANMIN,CICAN, &
ECANMAX,ACANMAX)
END DO ! End loop over age classes.
END DO ! Loop over gridpoints (nighttime).
! Calculate night-time foliage respiration
DO IPT = 1,NUMPNT
DO IAGE = 1,NOAGEP
AREA = DLI(IAGE,IPT) * VL(IPT)
RESPF = AREA * RESP(RD0(LGP(IPT),IAGE),RD0ACC,TAIR(IHOUR),TMOVE,Q10F,K10F,RTEMP,1.0,TBELOW)
FCO2(ITAR,IHOUR) = FCO2(ITAR,IHOUR) - RESPF
FRESPF(ITAR,IHOUR) = FRESPF(ITAR,IHOUR) + RESPF
END DO
END DO
END IF ! If day or night
! No good (does not run for Tumbarumba, and has not been updated since looping order change).
! Calculate non-foliage maintenance respiration (in umol tree-1 s-1)
FRESPW(ITAR,IHOUR) = RESP(RMW,RMW,TAIR(IHOUR),TAIR(IHOUR),Q10W,0.0,RTEMPW,1.0,TBELOW) * WBIOM
FRESPB(ITAR,IHOUR) = RESP(RMB,RMB,TAIR(IHOUR),TAIR(IHOUR),Q10B,0.0,RTEMPB,1.0,TBELOW) * BBIOM
FRESPFR(ITAR,IHOUR) = RESP(RMFR,RMFR,TSOIL(IHOUR),TAIR(IHOUR),Q10R,0.0,RTEMPR,1.0,TBELOW) * RBIOM * FRFRAC
FRESPCR(ITAR,IHOUR) = RESP(RMCR,RMCR,TSOIL(IHOUR),TAIR(IHOUR),Q10R,0.0,RTEMPR,1.0,TBELOW) * RBIOM * (1. - FRFRAC)
END DO ! End loop over trees
! Do the water balance.
! Throughfall, soil evaporation, root water uptake, infiltration of surface water,
! gravitational drainage.
! Get the leaf areas of all the target trees this timestep.
! Because Maestra works like this :
! 1) sort trees around current target tree
! 2) interpolate leaf area if not directly input
! we have to 'unsort' the leaf areas to find all current target tree leaf areas.
! This is needed in the SCALEUP routine below.
TARGETFOLS = 0
DO K=1,NOTARGETS
DO I = 1,NOALLTREES ! modification Christina March 2013
IF(IT(I).EQ.ITARGETS(K)) THEN
TARGETFOLS(K)=FOLT(I)
ENDIF
ENDDO
ENDDO
! K = 1
! DO I = 1,NOALLTREES
! IF(IT(I).EQ.ITARGETS(K))THEN
! TARGETFOLS(K) = FOLT(I)
! K = K + 1
! ENDIF
! ENDDO
!
IF(ISMAESPA)THEN
! Get area-based estimates of radiation interception and transpiration rate.
CALL SCALEUP(IHOUR, USESTAND, NOTARGETS, NOALLTREES, TARGETFOLS,ITARGETS,TOTLAI,STOCKING, &
SCLOSTTREE,THRAB,RADABV,FH2O,PLOTAREA, &
DOWNTHTREE,RGLOBABV,RGLOBUND,RADINTERC,FRACAPAR,ISIMUS,FH2OUS(IHOUR),THRABUS(IHOUR), &
PARUSMEAN(IHOUR),SCLOSTTOT,GSCAN,WINDAH(IHOUR),ZHT,Z0HT,ZPD,PRESS(IHOUR),TAIR(IHOUR), &
VPD(IHOUR),ETMM,ETUSMM)
! Find soil surface temperature, unless this is input data.
! Note this uses DRYTHICK from previous timestep (or initial value in first go).
IF(SIMTSOIL.EQ.1) THEN
VIEWFACTOR = 1.0 ! OBSOLETE...
CALL FINDSOILTK(iday, TAIR(IHOUR) + FREEZE, GAMSOIL, PRESS(IHOUR),SOILTK, SOILTEMP(2), VPD(IHOUR)/1000, &
RGLOBUND,THERMCOND(1), LAYTHICK(1), POREFRAC(1),SOILWP(1),DRYTHICK,TORTPAR,VIEWFACTOR)
ELSE
SOILTK = TSOIL(IHOUR) + FREEZE
ENDIF
! Calculate components of heat balance. (latent heat flux (QE) is needed for water balance).
IF(USEMEASET.EQ.0.AND.SIMSOILEVAP.EQ.1) THEN
CALL ENERGYCALC(SOILTK,GAMSOIL,PRESS(IHOUR),SOILTEMP(2), &
VPD(IHOUR)/1000,RGLOBUND,TAIR(IHOUR) + FREEZE,THERMCOND(1), &
LAYTHICK(1),POREFRAC(1),SOILWP(1),DRYTHICK,TORTPAR,VIEWFACTOR, &
QH,QE,QN,QC,ESOIL)
!ENDIF