-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinout.f90
5115 lines (4358 loc) · 184 KB
/
inout.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
!**********************************************************************
! INOUT.FOR
! This file contains all the subroutines for reading and writing to
! input and output files.
! The main subroutines (called externally) are:
! OPENINPUTF - opens the input files
! open_output_files - opens the output files
! CLOSEF - closes the files
! INPUTSTR - reads the canopy structure file str.dat
! INPUTPHY - reads the physiology file phy.dat
! INPUTTREE - reads the trees.dat file
! INPUTCON - reads the control file confile.dat
! INPUTSOIL - reads the soil/understorey file soil.dat // DOES NOT EXIST! (RAD)
! INPUTWATBAL - read the water balance / soil file watpars.dat (RAD, 2008).
! OUTPUTDY - outputs daily fluxes
! OUTPUTHR - outputs hourly fluxes
! OUTPUTLAY - outputs to layer flux file
! OUTPUTHIST - outputs PAR histogram
! SORTTREES - sorts the trees into order of distance from the target tree
! INTERPOLATEP - calls the daily interpolation routines for physiology
! INTERPOLATET - calls the daily interpolation routines for tree dimensions
! NB The subroutines to do with reading the met file are in getmet.for.
! Subsidiary subroutines are:
! INPUTSTR
! READCROWN - read crown shape
! READAERO - read aerodynamic properties (e.g. extinction of wind)
! READBETA - read leaf area density distribution
! READALLOM - read parameters for biomass vs height & diameter
! READLIA - read leaf incidence angle
! READLIA uses the following
! ANGLE - calculate the fraction of leaf area in each angle class
! AVGLIA - calculate the average LIA for a given ellipsoidal parameter
! INTEG - integrate leaf angle dist over specified range
! FANG - ellipsoidal leaf angle density function
! CALCELP - calculate ellipsoidal parameter from average LIA
! INPUTCON
! READDATES - read in start & end dates of simulation
! READMODEL - read in options for which model to use
! READZEN - read in number of angle classes & layers to use
! READHIST - read in details of PAR histogram required
! READCCSCEN - read in climate change scenario
! READOTC - read in effects of OTC on met data
! INPUTPHY
! READAGEP - read number of age classes for physiology parameters
! READPROP - read proportions of leaf area in each age class
! READABSRP - get leaf absorptance, reflectance & transmittance arrays
! READGS - read parameters of stomatal model
! READLEAFN - read in leaf nitrogen concentrations
! READJMAX - read in Jmax and Vcmax values
! READRD - read in parameters of leaf respiration
! READPHYARRAY - read array of physiological parameters
! (called by READLEAFN, READJMAX, READRD)
! READRW - read in parameters for woody respiration
! READRR - read in parameters for root respiration
! READRB - read in parameters for branch respiration
! RINTEG - convert physiology parameters spec. in layers to layers used
! (called by READBASRP, READPHYARRAY)
! INPUTTREE
! READPLOT - read dimensions of plot
! READXYZ - read co-ordinates of trees
! READTREEARRAY - read arrays of tree dimensions eg height, diameter
! GETLEAFAREA - A subroutine to read in leaf area array.
! CALCLAI - calculate plot LAI
! READZPD - read canopy dimensions (roughness length etc)
! READCONTREES - get list of target trees
! INEDGES - determine whether given tree is in plot edges or not
! INTERPOLATEP
! PHYINTERP - do interpolation of physiological parameters
! INTERPOLATET
! PHENOL - calculate leaf area from phenology parameters
! TREEINTERP - do interpolation of tree dimensions
! Unused: NOTREEGET, GETTREENO, READRSOIL
!**********************************************************************
!**********************************************************************
SUBROUTINE OPENINPUTF(CTITLE,TTITLE,PTITLE,STITLE,WTITLE,UTITLE,IWATFILE,KEEPZEN, &
IUSTFILE,in_path,out_path)
! This routine opens the input files.
! The filenames are defined in this routine.
!**********************************************************************
USE switches
USE maestcom
IMPLICIT NONE
INTEGER LEN1,IOERROR,IWATFILE,IUSTFILE, KEEPZEN
CHARACTER(LEN=*) CTITLE, TTITLE, PTITLE, STITLE, WTITLE, UTITLE
CHARACTER(LEN=*) in_path, out_path
CHARACTER(LEN=256) :: fin_dir, fout_dir
LOGICAL EXT
! Modified RAD
NAMELIST /CONTROL/ IOHRLY,IOTUTD,IOHIST,IORESP,IOWATBAL,IOFORMAT,ISUNLA,KEEPZEN
NAMELIST /flocations/ fin_dir, fout_dir ! MGDK
990 FORMAT (A80) ! For reading titles in input files.
! Output file for errors and warnings
OPEN (UERROR, FILE = 'Maeserr.dat', STATUS = 'UNKNOWN')
! Read input file as tradition from confile.dat with control switches
OPEN (UCONTROL, FILE = 'confile.dat', STATUS = 'OLD',IOSTAT=IOERROR)
IF(IOERROR.NE.0)THEN
CALL SUBERROR('ERROR: CONFILE.DAT DOES NOT EXIST' ,IFATAL,0)
ENDIF
! get locations of input files and where to write the output files
READ (UCONTROL, flocations, IOSTAT=IOERROR)
IF (IOERROR == -1) THEN
! i.e. it has reached the end of the file and not found the tag, I am sure
! there is a nicer way to do this
!WRITE(*,*) 'You have chosen not to set the in/out directories, so using current dir'
REWIND(UCONTROL)
ENDIF
READ (UCONTROL, 990) CTITLE
CTITLE = TRIM(CTITLE)
! Default
KEEPZEN = 0
READ (UCONTROL, CONTROL, IOSTAT = IOERROR)
IF (IOERROR.NE.0) CALL SUBERROR('WARNING: USING DEFAULT VALUES FOR CONTROL FILE', IWARN, IOERROR)
! Input file with data on tree position and size
OPEN (UTREES, FILE = trim(in_path)//'trees.dat', STATUS='OLD', IOSTAT=IOERROR)
IF (IOERROR.NE.0) THEN
CALL SUBERROR('ERROR: TREES.DAT DOES NOT EXIST', IFATAL, 0)
ENDIF
! Input file with water balance parameters (RAD)
OPEN (UWATPARS, FILE = trim(in_path)//'watpars.dat', STATUS='OLD',IOSTAT=IOERROR)
IF(IOERROR.NE.0)THEN
!CALL SUBERROR('WATPARS.DAT NOT FOUND. NO WATER BALANCE SIMULATED.',IWARN,IOERROR)
IWATFILE = 0
ELSE
IWATFILE = 1
ENDIF
! Input/output file with diffuse transmittances
OPEN (UTUTD, FILE = 'tutd.dat', STATUS='UNKNOWN')
! Input file for understorey parameters.
! Or if filename is missing:
INQUIRE (FILE=trim(in_path)//'USTOREY.DAT', EXIST=EXT)
IF(.NOT.EXT)THEN
CALL SUBERROR('USTOREY.DAT NOT FOUND. NO UNDERSTOREY SIMULATED.',IWARN,IOERROR)
IUSTFILE = 0
ELSE
IUSTFILE = 1
ENDIF
IF(EXT)THEN
OPEN(USTOREYI, FILE=trim(in_path)//'ustorey.dat', STATUS='UNKNOWN',IOSTAT=IOERROR)
ENDIF
IF(IUSTFILE.EQ.1.AND.IOERROR.EQ.0)THEN
UTITLE = ' ' !READ (USTOREYI, 990) UTITLE
ELSE
UTITLE = ' '
ENDIF
! Read titles from input files
READ (UTREES, 990) TTITLE
IF(IWATFILE.EQ.1)THEN
READ (UWATPARS, 990) WTITLE !RAD
WTITLE = TRIM(WTITLE)
ELSE
WTITLE = ' '
ENDIF
RETURN
END SUBROUTINE OPENINPUTF
!**********************************************************************
SUBROUTINE open_output_files(ISIMUS,CTITLE,TTITLE,PTITLE,&
STITLE,MTITLE,VTITLE,WTITLE, &
NSPECIES,SPECIESNAMES,OUT_PATH,ISMAESPA)
! This routine opens the output files.
! The filenames are defined in this routine.
! It also writes initial comments to the output files.
!**********************************************************************
USE switches
USE maestcom
IMPLICIT NONE
INTEGER NSPECIES, IOERROR, DUMMY, ISIMUS
!CHARACTER(*), INTENT(IN) :: CTITLE,TTITLE,PTITLE,STITLE,MTITLE,WTITLE,VTITLE,out_path
CHARACTER(*) :: CTITLE,TTITLE,PTITLE,STITLE,MTITLE,WTITLE,VTITLE,OUT_PATH
LOGICAL ISMAESPA
CHARACTER SPECIESNAMES(MAXSP)*30
! Output file with daily fluxes
IF (IODAILY .GT. 0 .AND. IOFORMAT .EQ. 0) THEN
CALL open_file(trim(out_path)//'Dayflx.dat', UDAILY, 'write', 'asc', 'replace')
ELSE IF (IODAILY .GT. 0 .AND. IOFORMAT .EQ. 1) THEN
CALL open_file(trim(out_path)//'Dayflx.bin', UDAILY, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'Dayflx.hdr', UDAYHDR, 'write', 'asc', 'replace')
END IF
! Output file with hourly fluxes (if required).
IF (IOHRLY.GT.0 .AND. IOFORMAT .EQ. 0) THEN
CALL open_file(trim(out_path)//'hrflux.dat', UHRLY, 'write', 'asc', 'replace')
ELSE IF (IOHRLY.GT.0 .AND. IOFORMAT .EQ. 1) THEN
CALL open_file(trim(out_path)//'hrflux.bin', UHRLY, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'hrflux.hdr', UHRLYHDR, 'write', 'asc', 'replace')
ENDIF
! Output file with layer fluxes (if required).
IF (IOHRLY.GT.1 .AND. IOFORMAT .EQ. 0) THEN
CALL open_file(trim(out_path)//'layflx.dat', ULAY, 'write', 'asc', 'replace')
ELSE IF (IOHRLY.GT.1 .AND. IOFORMAT .EQ. 1) THEN
CALL open_file(trim(out_path)//'layflx.bin', ULAY, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'layflx.hdr', ULAYHDR, 'write', 'asc', 'replace')
ENDIF
! Output file with histogram (if required).
IF (IOHIST.EQ.1 .AND. IOFORMAT .EQ. 0) THEN
CALL open_file(trim(out_path)//'histo.dat', UHIST, 'write', 'asc', 'replace')
ELSE IF (IOHIST.EQ.1 .AND. IOFORMAT .EQ. 1) THEN
CALL open_file(trim(out_path)//'histo.bin', UHIST, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'histo.hdr', UHISTHDR, 'write', 'asc', 'replace')
END IF
! Output file for respiration (if required).
IF (IORESP.EQ.1 .AND. IOFORMAT .EQ. 0) THEN
CALL open_file(trim(out_path)//'resp.dat', URESP, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'resphr.dat', URESPHR, 'write', 'asc', 'replace')
ELSE IF (IORESP .EQ. 1 .AND. IOFORMAT .EQ. 1) THEN
CALL open_file(trim(out_path)//'resp.bin', URESP, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'resp.hdr', URESPHDR, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'resphr.bin', URESPHR, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'resphr.hdr', URESPHRHDR, 'write', 'asc', 'replace')
END IF
CALL open_file(trim(out_path)//'wattest.dat', UWATTEST, 'write', 'asc', 'replace')
! Output file for water balance (if requested by setting IOWATBAL = 1 in confile.dat).
IF (ISMAESPA .AND. IOFORMAT .EQ. 0) THEN
CALL open_file(trim(out_path)//'watbal.dat', UWATBAL, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'watlay.dat', UWATLAY, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'swplay.dat', USWPLAY, 'write', 'asc', 'replace') ! mathias décembre 2012
CALL open_file(trim(out_path)//'watsoilt.dat', USOILT, 'write', 'asc', 'replace')
!CALL open_file(trim(out_path)//'wattest.dat', UWATTEST, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'watupt.dat', UWATUPT, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'watbalday.dat', UWATDAY, 'write', 'asc', 'replace')
ELSE IF (ISMAESPA .AND. IOFORMAT .EQ. 1) THEN
CALL open_file(trim(out_path)//'watbal.bin', UWATBAL, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'watbal.hdr', UWATBALHDR, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'watlay.bin', UWATLAY, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'watlay.hdr', UWATLAYHDR, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'watsoilt.bin', USOILT, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'watsoilt.hdr', USOILTHDR, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'wattest.bin', UWATTEST, 'write', 'bin', 'replace')
!CALL open_file(trim(out_path)//'wattest.hdr', UWATTESTHDR, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'watupt.bin', UWATUPT, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'watupt.hdr', UWATUPTHDR, 'write', 'asc', 'replace')
CALL open_file(trim(out_path)//'watbalday.bin', UWATDAY, 'write', 'bin', 'replace')
CALL open_file(trim(out_path)//'watbalday.hdr', UWATDAYHDR, 'write', 'asc', 'replace')
END IF
! Write to sunla flux !!!!!
IF(ISUNLA.EQ.1)THEN ! Mathias 27/11/12
CALL open_file(trim(out_path)//'sunla.dat', USUNLA, 'write', 'asc', 'replace')
ENDIF
IF(ISIMUS.EQ.1 .AND. IOFORMAT .EQ. 0) THEN
CALL open_file(trim(out_path)//'uspar.dat', UPARUS, 'write', 'asc', 'replace')
ELSE IF(ISIMUS.EQ.1 .AND. IOFORMAT .EQ. 1) THEN
CALL open_file(trim(out_path)//'uspar.bin', UPARUS, 'write', 'bin', 'replace')
ENDIF
CALL write_header_information(NSPECIES,SPECIESNAMES, &
CTITLE,TTITLE,PTITLE,STITLE,MTITLE,WTITLE,VTITLE,ISMAESPA)
RETURN
END SUBROUTINE open_output_files
!**********************************************************************
SUBROUTINE write_header_information(NSPECIES,SPECIESNAMES, &
CTITLE,TTITLE,PTITLE,STITLE,MTITLE,WTITLE,VTITLE, &
ISMAESPA)
!**********************************************************************
USE switches
USE maestcom
IMPLICIT NONE
INTEGER I
!INTEGER, INTENT(IN) :: NSPECIES
INTEGER NSPECIES
CHARACTER(*), INTENT(IN) :: CTITLE,TTITLE,PTITLE,STITLE,MTITLE,WTITLE,VTITLE
CHARACTER SPECIESNAMES(MAXSP)*30
LOGICAL ISMAESPA
! write headers to single ascii file
IF (IOFORMAT .EQ. 0) THEN
IF (ISUNLA.EQ.1) THEN
WRITE (USUNLA,461) ! MAthias 27/11/12
END IF
! Write headings to daily flux file
IF (IODAILY.GT.0) THEN
WRITE (UDAILY, 991) 'Program: ', VTITLE
WRITE (UDAILY, 991) 'Control: ', CTITLE
WRITE (UDAILY, 991) 'Trees: ', TTITLE
WRITE (UDAILY, 991) 'Structure: ', 'Multispecies' ! STITLE
WRITE (UDAILY, 991) 'Physiology: ', 'Multispecies' !PTITLE
WRITE (UDAILY, 991) 'Met data: ', MTITLE
IF(IOWATBAL.EQ.1)WRITE (UDAILY, 991) 'Water bal.: ', WTITLE
WRITE (UDAILY, 990) ' '
IF(NSPECIES.GT.1)THEN
WRITE(UDAILY, *)'Species codes:'
DO I = 1,NSPECIES
WRITE (UDAILY, *) I, " : " // SPECIESNAMES(I)
END DO
WRITE(UDAILY,990) ' '
ENDIF
WRITE (UDAILY,501)
WRITE (UDAILY,502)
WRITE (UDAILY,503)
WRITE (UDAILY,504)
WRITE (UDAILY,505)
WRITE (UDAILY,506)
WRITE (UDAILY,507)
WRITE (UDAILY,508)
WRITE (UDAILY,509)
WRITE (UDAILY,510)
WRITE (UDAILY,511)
WRITE (UDAILY,512)
WRITE (UDAILY,990) ' '
WRITE (UDAILY,513)
END IF
! Comments to hourly output file (if required).
IF (IOHRLY.gt.0) THEN
WRITE (UHRLY, 991) 'Program: ', VTITLE
WRITE (UHRLY, 991) 'Control: ', CTITLE
WRITE (UHRLY, 991) 'Trees: ', TTITLE
WRITE (UHRLY, 991) 'Structure: ', 'Multispecies' !STITLE
WRITE (UHRLY, 991) 'Physiology: ', 'Multispecies' !PTITLE
WRITE (UHRLY, 991) 'Met data: ', MTITLE
IF(IOWATBAL.EQ.1)WRITE (UHRLY, 991) 'Water bal.: ', WTITLE
WRITE (UHRLY, 990) ' '
IF(NSPECIES.GT.1)THEN
WRITE(UHRLY, *)'Species codes:'
DO I = 1,NSPECIES
WRITE (UHRLY, *) I, " : " // SPECIESNAMES(I)
END DO
WRITE(UHRLY,990) ' '
END IF
WRITE (UHRLY,701)
WRITE (UHRLY,702)
WRITE (UHRLY,703)
WRITE (UHRLY,704)
WRITE (UHRLY,705)
WRITE (UHRLY,706)
WRITE (UHRLY,707)
WRITE (UHRLY,708)
WRITE (UHRLY,709)
WRITE (UHRLY,710)
WRITE (UHRLY,711)
WRITE (UHRLY,712)
WRITE (UHRLY,713)
WRITE (UHRLY,714)
WRITE (UHRLY,715)
WRITE (UHRLY,716)
! WRITE (UHRLY,717)
WRITE (UHRLY,718)
WRITE (UHRLY,719)
WRITE (UHRLY,720)
WRITE (UHRLY,721)
WRITE (UHRLY,722)
WRITE (UHRLY,723)
WRITE (UHRLY,724)
WRITE (UHRLY,726)
WRITE (UHRLY,727)
WRITE (UHRLY, 990) ' '
WRITE (UHRLY,725)
END IF
! Comments to respiration output file (if required).
IF (IORESP.gt.0) THEN
WRITE (URESP, 991) 'Program: ', VTITLE
WRITE (URESP, 991) 'Control: ', CTITLE
WRITE (URESP, 991) 'Trees: ', TTITLE
WRITE (URESP, 991) 'Structure: ', 'Multispecies' !STITLE
WRITE (URESP, 991) 'Physiology: ', 'Multispecies' !PTITLE
WRITE (URESP, 991) 'Met data: ', MTITLE
WRITE (URESP, 990) ' '
WRITE (URESP,601)
WRITE (URESP,602)
WRITE (URESP,603)
WRITE (URESP,604)
WRITE (URESP,605)
WRITE (URESP,606)
WRITE (URESP,607)
WRITE (URESP,608)
WRITE (URESP,609)
WRITE (URESP,610)
WRITE (URESP,611)
WRITE (URESP, 990) ' '
WRITE (URESP,612)
WRITE (URESPHR, 991) 'Program: ', VTITLE
WRITE (URESPHR, 991) 'Control: ', CTITLE
WRITE (URESPHR, 991) 'Trees: ', TTITLE
WRITE (URESPHR, 991) 'Structure: ', 'Multispecies' !STITLE
WRITE (URESPHR, 991) 'Physiology: ', 'Multispecies' !PTITLE
WRITE (URESPHR, 991) 'Met data: ', MTITLE
WRITE (URESPHR, 990) ' '
WRITE (URESPHR,301)
WRITE (URESPHR,302)
WRITE (URESPHR,303)
WRITE (URESPHR,304)
WRITE (URESPHR,305)
WRITE (URESPHR,306)
WRITE (URESPHR, 990) ' '
WRITE (URESPHR,307)
END IF
! Write comments to layer output file (if required)
IF (IOHRLY.GT.1) THEN
WRITE (ULAY, 991) 'Program: ', VTITLE
WRITE (ULAY, 801)
WRITE (ULAY, 802)
WRITE (ULAY, 803)
WRITE (ULAY, 804)
WRITE (ULAY, *)
END IF
! Write comments to water balance output file (if required). (RAD).
IF (ISMAESPA) THEN
WRITE (UWATBAL, 991) 'Program: ', VTITLE
WRITE (UWATBAL, 992) 'Water balance parameters: ', WTITLE
WRITE (UWATBAL, 990) ' '
WRITE (UWATBAL, 401)
WRITE (UWATBAL, 402)
WRITE (UWATBAL, 403)
WRITE (UWATBAL, 404)
WRITE (UWATBAL, 405)
WRITE (UWATBAL, 406)
WRITE (UWATBAL, 407)
WRITE (UWATBAL, 408)
WRITE (UWATBAL, 409)
WRITE (UWATBAL, 410)
WRITE (UWATBAL, 411)
WRITE (UWATBAL, 412)
WRITE (UWATBAL, 413)
WRITE (UWATBAL, 414)
WRITE (UWATBAL, 415)
WRITE (UWATBAL, 416)
WRITE (UWATBAL, 417)
WRITE (UWATBAL, 418)
WRITE (UWATBAL, 419)
WRITE (UWATBAL, 420)
WRITE (UWATBAL, 421)
WRITE (UWATBAL, 422)
WRITE (UWATBAL, 423)
WRITE (UWATBAL, 424)
WRITE (UWATBAL, 425)
WRITE (UWATBAL, 426)
WRITE (UWATBAL, 427)
WRITE (UWATBAL, 428)
WRITE (UWATBAL, 429)
WRITE (UWATBAL, 430)
WRITE (UWATBAL, 432)
WRITE (UWATBAL, 990) ' '
WRITE (UWATBAL, 431)
! Daily water balance output file.
WRITE (UWATDAY, 991) 'Program: ', VTITLE
WRITE (UWATDAY, 992) 'Water balance parameters: ', WTITLE
WRITE (UWATDAY, 990) ' '
WRITE (UWATDAY, 441)
WRITE (UWATDAY, 442)
WRITE (UWATDAY, 443)
WRITE (UWATDAY, 444)
WRITE (UWATDAY, 445)
WRITE (UWATDAY, 446)
WRITE (UWATDAY, 447)
WRITE (UWATDAY, 448)
WRITE (UWATDAY, 449)
WRITE (UWATDAY, 450)
WRITE (UWATDAY, 451)
WRITE (UWATDAY, 452)
WRITE (UWATDAY, 453)
WRITE (UWATDAY, 454)
WRITE (UWATDAY, 455)
WRITE (UWATDAY, 456)
WRITE (UWATDAY, 990) ' '
WRITE (UWATDAY, 457)
END IF
! write headers to a .hdr file, binary out
ELSE IF (IOFORMAT .EQ. 1) THEN
! Write headings to daily flux file
IF (IODAILY.GT.0) THEN
WRITE (UDAYHDR, 991) 'Program: ', VTITLE
WRITE (UDAYHDR, 991) 'Control: ', CTITLE
WRITE (UDAYHDR, 991) 'Trees: ', TTITLE
WRITE (UDAYHDR, 991) 'Structure: ', 'Multispecies' ! STITLE
WRITE (UDAYHDR, 991) 'Physiology: ', 'Multispecies' !PTITLE
WRITE (UDAYHDR, 991) 'Met data: ', MTITLE
IF(IOWATBAL.EQ.1)WRITE (UDAYHDR, 991) 'Water bal.: ', WTITLE
WRITE (UDAYHDR, 990) ' '
IF(NSPECIES.GT.1)THEN
WRITE(UDAYHDR, *)'Species codes:'
DO I = 1,NSPECIES
WRITE (UDAYHDR, *) I, " : " // SPECIESNAMES(I)
END DO
WRITE(UDAYHDR,990) ' '
ENDIF
WRITE (UDAYHDR,501)
WRITE (UDAYHDR,502)
WRITE (UDAYHDR,503)
WRITE (UDAYHDR,504)
WRITE (UDAYHDR,505)
WRITE (UDAYHDR,506)
WRITE (UDAYHDR,507)
WRITE (UDAYHDR,508)
WRITE (UDAYHDR,509)
WRITE (UDAYHDR,510)
WRITE (UDAYHDR,511)
WRITE (UDAYHDR,512)
WRITE (UDAYHDR,990) ' '
WRITE (UDAYHDR,513)
END IF
! Comments to hourly output file (if required).
IF (IOHRLY.gt.0) THEN
WRITE (UHRLYHDR, 991) 'Program: ', VTITLE
WRITE (UHRLYHDR, 991) 'Control: ', CTITLE
WRITE (UHRLYHDR, 991) 'Trees: ', TTITLE
WRITE (UHRLYHDR, 991) 'Structure: ', 'Multispecies' !STITLE
WRITE (UHRLYHDR, 991) 'Physiology: ', 'Multispecies' !PTITLE
WRITE (UHRLYHDR, 991) 'Met data: ', MTITLE
IF(IOWATBAL.EQ.1)WRITE (UHRLYHDR, 991) 'Water bal.: ', WTITLE
WRITE (UHRLYHDR, 990) ' '
IF(NSPECIES.GT.1)THEN
WRITE(UHRLYHDR, *)'Species codes:'
DO I = 1,NSPECIES
WRITE (UHRLYHDR, *) I, " : " // SPECIESNAMES(I)
END DO
WRITE(UHRLYHDR,990) ' '
END IF
WRITE (UHRLYHDR,701)
WRITE (UHRLYHDR,702)
WRITE (UHRLYHDR,703)
WRITE (UHRLYHDR,704)
WRITE (UHRLYHDR,705)
WRITE (UHRLYHDR,706)
WRITE (UHRLYHDR,707)
WRITE (UHRLYHDR,708)
WRITE (UHRLYHDR,709)
WRITE (UHRLYHDR,710)
WRITE (UHRLYHDR,711)
WRITE (UHRLYHDR,712)
WRITE (UHRLYHDR,713)
WRITE (UHRLYHDR,714)
WRITE (UHRLYHDR,715)
WRITE (UHRLYHDR,716)
!WRITE (UHRLYHDR,717)
WRITE (UHRLYHDR,718)
WRITE (UHRLYHDR,719)
WRITE (UHRLYHDR,720)
WRITE (UHRLYHDR,721)
WRITE (UHRLYHDR,722)
WRITE (UHRLYHDR,724)
WRITE (UHRLYHDR, 990) ' '
WRITE (UHRLYHDR,725)
END IF
! Comments to respiration output file (if required).
IF (IORESP.gt.0) THEN
WRITE (URESPHDR, 991) 'Program: ', VTITLE
WRITE (URESPHDR, 991) 'Control: ', CTITLE
WRITE (URESPHDR, 991) 'Trees: ', TTITLE
WRITE (URESPHDR, 991) 'Structure: ', 'Multispecies' !STITLE
WRITE (URESPHDR, 991) 'Physiology: ', 'Multispecies' !PTITLE
WRITE (URESPHDR, 991) 'Met data: ', MTITLE
WRITE (URESPHDR, 990) ' '
WRITE (URESPHDR,601)
WRITE (URESPHDR,602)
WRITE (URESPHDR,603)
WRITE (URESPHDR,604)
WRITE (URESPHDR,605)
WRITE (URESPHDR,606)
WRITE (URESPHDR,607)
WRITE (URESPHDR,608)
WRITE (URESPHDR,609)
WRITE (URESPHDR,610)
WRITE (URESPHDR,611)
WRITE (URESPHDR, 990) ' '
WRITE (URESPHDR,612)
WRITE (URESPHRHDR, 991) 'Program: ', VTITLE
WRITE (URESPHRHDR, 991) 'Control: ', CTITLE
WRITE (URESPHRHDR, 991) 'Trees: ', TTITLE
WRITE (URESPHRHDR, 991) 'Structure: ', 'Multispecies' !STITLE
WRITE (URESPHRHDR, 991) 'Physiology: ', 'Multispecies' !PTITLE
WRITE (URESPHRHDR, 991) 'Met data: ', MTITLE
WRITE (URESPHRHDR, 990) ' '
WRITE (URESPHRHDR,301)
WRITE (URESPHRHDR,302)
WRITE (URESPHRHDR,303)
WRITE (URESPHRHDR,304)
WRITE (URESPHRHDR,305)
WRITE (URESPHRHDR,306)
WRITE (URESPHRHDR, 990) ' '
WRITE (URESPHRHDR,307)
END IF
! Write comments to layer output file (if required)
IF (IOHRLY.GT.1) THEN
WRITE (ULAYHDR, 991) 'Program: ', VTITLE
WRITE (ULAYHDR, 801)
WRITE (ULAYHDR, 802)
WRITE (ULAYHDR, 803)
WRITE (ULAYHDR, 804)
WRITE (ULAYHDR, *)
END IF
! Write comments to water balance output file (if required). (RAD).
IF (ISMAESPA) THEN
WRITE (UWATBALHDR, 991) 'Program: ', VTITLE
WRITE (UWATBALHDR, 992) 'Water balance parameters: ', WTITLE
WRITE (UWATBALHDR, 990) ' '
WRITE (UWATBALHDR, 401)
WRITE (UWATBALHDR, 402)
WRITE (UWATBALHDR, 403)
WRITE (UWATBALHDR, 404)
WRITE (UWATBALHDR, 405)
WRITE (UWATBALHDR, 406)
WRITE (UWATBALHDR, 407)
WRITE (UWATBALHDR, 408)
WRITE (UWATBALHDR, 409)
WRITE (UWATBALHDR, 410)
WRITE (UWATBALHDR, 411)
WRITE (UWATBALHDR, 412)
WRITE (UWATBALHDR, 413)
WRITE (UWATBALHDR, 414)
WRITE (UWATBALHDR, 415)
WRITE (UWATBALHDR, 416)
WRITE (UWATBALHDR, 417)
WRITE (UWATBALHDR, 418)
WRITE (UWATBALHDR, 419)
WRITE (UWATBALHDR, 420)
WRITE (UWATBALHDR, 421)
WRITE (UWATBALHDR, 422)
WRITE (UWATBALHDR, 423)
WRITE (UWATBALHDR, 424)
WRITE (UWATBALHDR, 425)
WRITE (UWATBALHDR, 426)
WRITE (UWATBALHDR, 427)
WRITE (UWATBALHDR, 428)
WRITE (UWATBALHDR, 429)
WRITE (UWATBALHDR, 430)
WRITE (UWATBALHDR, 990) ' '
WRITE (UWATBALHDR, 431)
! Daily water balance output file.
WRITE (UWATDAYHDR, 991) 'Program: ', VTITLE
WRITE (UWATDAYHDR, 992) 'Water balance parameters: ', WTITLE
WRITE (UWATDAYHDR, 990) ' '
WRITE (UWATDAYHDR, 441)
WRITE (UWATDAYHDR, 442)
WRITE (UWATDAYHDR, 443)
WRITE (UWATDAYHDR, 444)
WRITE (UWATDAYHDR, 445)
WRITE (UWATDAYHDR, 446)
WRITE (UWATDAYHDR, 447)
WRITE (UWATDAYHDR, 448)
WRITE (UWATDAYHDR, 449)
WRITE (UWATDAYHDR, 450)
WRITE (UWATDAYHDR, 451)
WRITE (UWATDAYHDR, 452)
WRITE (UWATDAYHDR, 453)
WRITE (UWATDAYHDR, 454)
WRITE (UWATDAYHDR, 455)
WRITE (UWATDAYHDR, 456)
WRITE (UWATDAYHDR, 990) ' '
WRITE (UWATDAYHDR, 457)
END IF
END IF
461 format('DOY Hour Tree IPT SUNLA AREA BEXT FBEAM ZEN ABSRPPAR ABSRPNIR ABSRPTH BFPAR DFPAR BFNIR DFNIR DFTHR SCLOSTPAR SCLOSTNIR SCLOSTTH DOWNTH PARABV NIRABV THRABV') ! Modification Mathias 27/11/12
990 FORMAT (A80)
991 FORMAT (A12,A80) ! For writing comments to output files.
992 FORMAT (A25, A55)
501 FORMAT('DOY: simulation date')
502 FORMAT('Tree: tree number')
503 FORMAT('Spec: tree species number')
504 FORMAT('absPAR: absorbed PAR MJ tree-1 d-1')
505 FORMAT('absNIR: absorbed NIR MJ tree-1 d-1')
506 FORMAT('absTherm: absorbed thermal MJ tree-1 d-1')
507 FORMAT('totPs: gross photosynthesis mol tree-1 d-1')
508 FORMAT('totRf: daily foliar respiration mol tree-1 d-1')
509 FORMAT('netPs: photosyn. net of foliar resp mol tree-1 d-1')
510 FORMAT('totLE1: daily transpiration mol H2O tree-1 d-1')
511 FORMAT('totLE2: daily transpirn (CANOPY calc) mol H2O m-2 d-1')
512 FORMAT('totH: daily sensible heat flux MJ tree-1 d-1')
513 FORMAT('Columns: DOY Tree Spec absPAR absNIR absTherm', &
&' totPs totRf netPs', &
&' totLE1 totLE2 totH')
701 FORMAT('DOY: simulation date')
702 FORMAT('Tree: tree number')
703 FORMAT('Spec: tree species number')
704 FORMAT('Hour: hour of the day')
705 FORMAT('hrPAR: absorbed PAR umol tree-1 s-1')
706 FORMAT('hrNIR: absorbed NIR W tree-1')
707 FORMAT('hrTHM: absorbed thermal W tree-1')
708 FORMAT('hrPS: photosynthesis (net of leaf resp) umol tree-1 s-1')
709 FORMAT('hrRf: hourly leaf respiration umol tree-1 s-1')
710 FORMAT('hrRmW: hourly stem + branch Rm umol tree-1 s-1')
711 FORMAT('hrLE: hourly transpiration mmol tree-1 s-1')
712 FORMAT('LECAN: hourly transpirn: CANOPY calc : mmol H2O m-2 s-1')
713 FORMAT('Gscan: canopy stomatal conductance : mol CO2 tree-1 s-1')
714 FORMAT('Gbhcan: canopy boundary layer conductance to heat : mol tree-1 s-1')
715 FORMAT('hrH: hourly sensible heat flux: MJ tree-1 s-1')
716 FORMAT('TCAN: Average foliage temperature (deg C)')
! 717 FORMAT('ELMAX: Canopy maximum leaf transpiration rate (mmol m-2 s-1)')
718 FORMAT('ALMAX: Canopy maximum leaf photosynthesis rate (umol m-2 s-1)')
719 FORMAT('PSIL: Canopy average leaf water potential (MPa)')
720 FORMAT('PSILMIN: Canopy minimum leaf water potential (MPa)')
721 FORMAT('CI : Canopy average intercellular CO2 conc. (ppm)')
722 FORMAT('TAIR: Air temperature (deg C)')
723 FORMAT('VPD: vapor pressure deficit (kPa)')
724 FORMAT('PAR: Above-canopy incident PAR (umol m-2 s-1)')
726 FORMAT('ZEN: Zenithal angle (rad)') ! mathias mars 2013
727 FORMAT('AZ: Asimutal angle (rad)')
725 FORMAT('Columns: DOY Tree Spec HOUR hrPAR hrNIR hrTHM', &
' hrPs hrRf hrRmW hrLE', &
' LECAN Gscan Gbhcan hrH TCAN ALMAX PSIL PSILMIN CI TAIR VPD PAR ZEN AZ') !10E-3*ECANMAX(ITAR,IHOUR),
801 FORMAT(' Fluxes for each layer on an hourly basis')
802 FORMAT(' Rows: absorbed PAR (umol m-2 leaf s-1) ')
803 FORMAT(' photosynthesis net of Rleaf (umol m-2 leaf s-1) ')
804 FORMAT(' transpiration (umol m-2 leaf s-1) ')
601 FORMAT('Daily maintenance and growth respiration components')
602 FORMAT('Rmf: Foliage maintenance resp. mol m-2 d-1')
603 FORMAT('Rmw: Stem maintenance resp. mol m-2 d-1')
604 FORMAT('RmB: Branch maintenance resp. mol m-2 d-1')
605 FORMAT('Rmcr: Coarse root maintenance resp. mol m-2 d-1')
606 FORMAT('Rmfr: Fine root maintenance resp. mol m-2 d-1')
607 FORMAT('Rgf: Foliage growth resp. mol m-2 d-1')
608 FORMAT('Rgw: Stem growth resp. mol m-2 d-1')
609 FORMAT('Rgb: Branch growth resp. mol m-2 d-1')
610 FORMAT('Rgcr: Coarse root growth resp. mol m-2 d-1')
611 FORMAT('Rgfr: Fine root growth resp. mol m-2 d-1')
612 FORMAT('Columns: DOY Tree Species Rmf Rmw Rmb Rmcr Rmfr Rgf Rgw Rgb Rgcr Rgfr')
301 FORMAT('Hourly maintenance respiration components')
302 FORMAT('Rmf: Foliage maintenance resp. umol m-2 s-1')
303 FORMAT('Rmw: Stem maintenance resp. umol m-2 s-1')
304 FORMAT('RmB: Branch maintenance resp. umol m-2 s-1')
305 FORMAT('Rmcr: Coarse root maintenance resp. umol m-2 s-1')
306 FORMAT('Rmfr: Fine root maintenance resp. umol m-2 s-1')
307 FORMAT('Columns: DOY, Hr, Rmf, Rmw, Rmb, Rmcr, Rmfr')
401 FORMAT('Half-hourly water and heat balance components.')
402 FORMAT('wsoil: total soil water storage mm')
403 FORMAT('wsoilroot: soil water storage in rooted zone mm')
404 FORMAT('ppt : precipitation mm')
405 FORMAT('canopystore : storage of intercepted rain mm')
406 FORMAT('evapstore : evaporation of wet canopy mm')
407 FORMAT('drainstore : drainage of wet canopy mm')
408 FORMAT('tfall : throughfall of rain mm')
409 FORMAT('et : modelled canopy transpiration mm')
410 FORMAT('etmeas: measured ET, if provided in input mm')
411 FORMAT('discharge: drainage at bottom of profile mm')
412 FORMAT('overflow: over-land flow mm')
413 FORMAT('weightedswp: soil water potential weighted by roots MPa')
414 FORMAT('ktot: soil to leaf hydr. cond. mmol m-2 s-1 MPa-1')
415 FORMAT('drythick: thickness of dry surface layer mm')
416 FORMAT('soilevap: soil evaporation mm')
417 FORMAT('soilmoist: measured soil water content (units vary)')
418 FORMAT('fsoil: soil water modifier function (0-1)')
419 FORMAT('qh: sensible heat flux W m-2')
420 FORMAT('qe: latent heat flux W m-2')
421 FORMAT('qn: net radiation W m-2')
422 FORMAT('qc: soil heat transport W m-2')
423 FORMAT('rglobund: net radiation underneath canopy W m-2')
424 FORMAT('rglobabv: net radiation above canopy W m-2')
425 FORMAT('radinterc: total radiation intercepted by canopy W m-2')
426 FORMAT('rnet: net radiation above the canopy W m-2')
427 FORMAT('totlai: leaf area index m2 m-2')
428 FORMAT('tair: air temperature deg C')
429 FORMAT('soilt1, soilt2: soil T in 1st and 2nd layer deg C')
430 FORMAT('fracw1,fracw2: water content 1st and 2nd layer m3 m-3')
431 FORMAT('Columns: day hour wsoil wsoilroot ppt canopystore &
&evapstore drainstore tfall et etmeas discharge overflow &
&weightedswp ktot drythick soilevap &
&soilmoist fsoil qh qe qn qc rglobund &
&rglobabv radinterc rnet totlai tair soilt1 soilt2 &
&fracw1 fracw2 fracaPAR')
432 FORMAT('FracaPAR: fraction of absorbed PAR')
441 FORMAT('Daily water and heat balance components.')
442 FORMAT('wsoil: total soil water storage mm')
443 FORMAT('wsoilroot: soil water storage in rooted zone mm')
444 FORMAT('swp: weighted soil water potential MPa')
445 FORMAT('ppt : precipitation mm')
446 FORMAT('tfall : throughfall of rain mm')
447 FORMAT('et : modelled canopy transpiration mm')
448 FORMAT('etmeas: measured ET, if provided in input mm')
449 FORMAT('discharge: drainage at bottom of profile mm')
450 FORMAT('soilevap: soil evaporation mm')
451 FORMAT('fsoil: soil water modifier function (0-1)')
452 FORMAT('qh: sensible heat flux MJ m-2 day-1')
453 FORMAT('qe: latent heat flux MJ m-2 day-1')
454 FORMAT('qn: net radiation MJ m-2 day-1')
455 FORMAT('qc: soil heat transport MJ m-2 day-1')
456 FORMAT('radinterc: total radiation intercepted MJ m-2 day-1')
457 FORMAT('Columns: day wsoil wsoilroot swp ppt &
&tfall et etmeas discharge soilevap &
&fsoil qh qe qn qc radinterc')
END SUBROUTINE write_header_information
!**********************************************************************
SUBROUTINE CLOSEF()
! This routine closes the open files.
!**********************************************************************
USE switches
USE maestcom
IMPLICIT NONE
CLOSE(USUNLA) ! Mathias 27/11/12
CLOSE(STDIN)
CLOSE(UTREES)
CLOSE(USTR)
CLOSE(UPHY)
CLOSE(UMET)
CLOSE(UTUTD)
CLOSE(UERROR)
CLOSE(UWATPARS) !RAD
IF (IODAILY.GT.0 .AND. IOFORMAT .EQ. 0) THEN
CLOSE(UDAILY)
ELSE IF (IODAILY.GT.0 .AND. IOFORMAT .EQ. 1) THEN
CLOSE(UDAILY)
CLOSE(UDAYHDR)
END IF
IF (IOHRLY.GT.0 .AND. IOFORMAT .EQ. 0) THEN
CLOSE(UHRLY)
ELSE IF (IOHRLY.GT.0 .AND. IOFORMAT .EQ. 1) THEN
CLOSE(UHRLY)
CLOSE(UHRLYHDR)
END IF
IF (IOHRLY.GT.1 .AND. IOFORMAT .EQ. 0) THEN
CLOSE(ULAY)
ELSE IF (IOHRLY.GT.1 .AND. IOFORMAT .EQ. 1) THEN
CLOSE(ULAY)
CLOSE(ULAYHDR)
END IF
IF (IOHIST.EQ.1 .AND. IOFORMAT .EQ. 0) THEN
CLOSE(UHIST)
ELSE IF (IOHIST.EQ.1 .AND. IOFORMAT .EQ. 1) THEN
CLOSE(UHIST)
CLOSE(UHISTHDR)
END IF
IF (IORESP.EQ.1 .AND. IOFORMAT .EQ. 0) THEN
CLOSE(URESP)
ELSE IF (IORESP.EQ.1 .AND. IOFORMAT .EQ. 1) THEN
CLOSE(URESP)
CLOSE(URESPHDR)
END IF
IF (IOWATBAL.EQ.1 .AND. IOFORMAT .EQ. 0) THEN
CLOSE(UWATBAL)
CLOSE(UWATDAY)
CLOSE(UWATLAY)
CLOSE(USWPLAY) ! mathias décembre 2012
CLOSE(USOILT)
CLOSE(UWATUPT)
ELSE IF (IOWATBAL.EQ.1 .AND. IOFORMAT .EQ. 1) THEN
CLOSE(UWATBAL)
CLOSE(UWATBALHDR)
CLOSE(UWATDAY)
CLOSE(UWATDAYHDR)
CLOSE(UWATLAY)
CLOSE(USWPLAY) ! mathias décembre 2012
CLOSE(UWATLAYHDR)
CLOSE(USOILT)
CLOSE(USOILTHDR)
CLOSE(UWATUPT)
CLOSE(UWATUPTHDR)
ENDIF
RETURN
END SUBROUTINE CLOSEF
!**********************************************************************
SUBROUTINE INPUTCON(ISTART, IEND, NSTEP, &
NUMPNT,NOLAY,PPLAY,NZEN,DIFZEN,NAZ, &
MODELGS, MODELJM, MODELRD, MODELSS, MODELRW, ITERMAX, &
IOHIST, BINSIZE, ICC, CO2INC, TINC, &
IOTC, TOTC, WINDOTC, PAROTC, FBEAMOTC, &
IWATFILE, IUSTFILE, ISIMUS, &
NSPECIES, SPECIESNAMES, PHYFILES, STRFILES)
! Read in the information from the control file.
!**********************************************************************
USE maestcom
IMPLICIT NONE
REAL DIFZEN(MAXANG)
INTEGER PPLAY,ISTART,IEND,NSTEP,NUMPNT,NOLAY,PPLY,NZEN,NAZ,MODELGS
INTEGER MODELJM,MODELRD,MODELSS,MODELRW,ITERMAX,NSPECIES
INTEGER ISIMUS,IUSTFILE,IOTC,IOHIST,IWATFILE,ICC
CHARACTER SPECIESNAMES(MAXSP)*30
CHARACTER PHYFILES(MAXSP)*30
CHARACTER STRFILES(MAXSP)*30
!CHARACTER STITLE*60
REAL BINSIZE,CO2INC,TINC,TOTC,WINDOTC,PAROTC,FBEAMOTC
! if reading from the confile.dat
CALL READDATES(UCONTROL, ISTART, IEND, NSTEP)
CALL READSPECIES(UCONTROL, NSPECIES, SPECIESNAMES,PHYFILES, STRFILES)
CALL READZEN(UCONTROL, NUMPNT, NOLAY, PPLAY, NZEN, NAZ, DIFZEN)
CALL READMODEL(UCONTROL, MODELGS, MODELJM, MODELRD,MODELSS, MODELRW, ITERMAX, ISIMUS)
! Don't simulate water balance or understorey if files missing.
IF(IUSTFILE.EQ.0)ISIMUS = 0
CALL READHIST(UCONTROL,IOHIST,BINSIZE)
CALL READCCSCEN(UCONTROL,ICC,CO2INC,TINC)
CALL READOTC(UCONTROL,IOTC,TOTC,WINDOTC,PAROTC,FBEAMOTC)
RETURN
END SUBROUTINE INPUTCON
!**********************************************************************
SUBROUTINE INPUTWATBAL(BPAR, PSIE, KSAT, ROOTRESIST, ROOTRESFRAC, &
ROOTRADTABLE, ROOTDENSTABLE,ROOTMASSTOTTABLE, &
MINROOTWP,MINLEAFWP,PLANTKTABLE, KSCALING, THROUGHFALL, &
REASSIGNRAIN,RUTTERB,RUTTERD,MAXSTORAGE, &
DRAINLIMIT,ROOTXSECAREA,EQUALUPTAKE, &
NLAYER, NROOTLAYER, LAYTHICK, INITWATER, &
FRACROOT, POREFRAC, SOILTEMP, KEEPWET, &
DRYTHICKMIN,TORTPAR,SIMTSOIL,RETFUNCTION, &
FRACORGANIC, EXPINF,WSOILMETHOD,USEMEASET, &
USEMEASSW,SIMSOILEVAP,USESTAND,ALPHARET,WS,WR,NRET,DATESKP,NOKPDATES,DATESROOT,NOROOTDATES)
! Read in water balance parameters
!**********************************************************************
USE maestcom
IMPLICIT NONE
INTEGER NLAYER,NROOTLAYER,REASSIGNRAIN, SIMTSOIL, EQUALUPTAKE
INTEGER WSOILMETHOD,FRACROOTLEN,LASTENTRY,RETFUNCTION
INTEGER USEMEASET,USEMEASSW,KEEPWET,I,SIMSOILEVAP
INTEGER USESTAND
INTEGER NOKPDATES, DATESKP(maxdate), DATESROOT(maxdate), NOROOTDATES
REAL FRACROOT(MAXSOILLAY,maxdate),LAYTHICK(MAXSOILLAY)
REAL INITWATER(MAXSOILLAY),POREFRAC(MAXSOILLAY)
REAL BPAR(MAXSOILLAY), PSIE(MAXSOILLAY), KSAT(MAXSOILLAY)
REAL SOILTEMP(MAXSOILLAY),DRAINLIMIT(MAXSOILLAY)
REAL FRACORGANIC(MAXSOILLAY),FRACSUM
REAL ROOTRESIST,ROOTRADTABLE(maxdate),MINROOTWP,ROOTDENSTABLE(maxdate),ROOTMASSTOTTABLE(maxdate)
REAL MAXSTORAGE,COREWATER,EXPINF,DRYTHICKMIN,RUTTERB,RUTTERD
REAL THROUGHFALL,ROOTRESFRAC,PLANTKTABLE(maxdate),TORTPAR,ROOTXSECAREA
REAL KSCALING,MINLEAFWP,ROOTBETA
REAL ALPHARET(MAXSOILLAY),WS(MAXSOILLAY),WR(MAXSOILLAY),NRET(MAXSOILLAY)
LOGICAL ANYFIX
! Init.
POREFRAC = 0.0
INITWATER = 0.0
BPAR = 0.0
PSIE = 0.0
KSAT = 0.0
SOILTEMP = 0.0
DRAINLIMIT = 0.0