-
Notifications
You must be signed in to change notification settings - Fork 1
/
CSP_OPGROW.FOR
1209 lines (1043 loc) · 45.5 KB
/
CSP_OPGROW.FOR
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
C=======================================================================
C CSP_OPGROW, Subroutine for CASUPRO sugarcane model, based on
C OPGROW, Subroutine, G. Hoogenboom, J.W. Jones
C-----------------------------------------------------------------------
C Generates output file for daily growth variables
C-----------------------------------------------------------------------
C REVISION HISTORY
C 01/01/1990 GH Written
C 09/21/1998 CHP Split off from OPDAY.FOR file
C 05/11/1999 GH Incorporated in CROPGRO
C 06/19/2001 GH Modified output format
C 11/11/2001 O.H. Daza modified for sugarcane
C 08/20/2002 GH Modified for Y2K
C 07/08/2003 CHP Changed senescence output.
C 08/27/2003 FSR Incorporated in CASUPRO for DSSAT 4.0
C 07/26/2004 CHP Removed variables which were not being used
! 07/24/2007 CHP Removed stalk printout temporarily. GBuild can't
! handle this many columns. Maybe split to
! multiple files?
! 10/20/2008 FSR Redesigned PlantGro.out to match CaneGro output file
! former PlantGro.out will be PlantKg.out
C-----------------------------------------------------------------------
C Called by: CASUPRO
C Calls: None
!=======================================================================
SUBROUTINE CSP_OPGROW(CONTROL, ISWITCH, !Input
& BRDMD, CADLF, CADST, CANHT, CANWH, CMINEA, !Input
& CountStalk, DLAYR, EOS, GROWTH, GRWRES, !Input
& Kill, LeafArea, LeafArealost,LeafNum, LFWTHa, !Input
& LFWT, LFWTHalost, LSWTlost, LSWT, LSWTHa, !Input
& LSWTHalost, LFWTlost, LITOTAL, !Input !Input
& MAINR, MDATE, NFIXN, NLAYR, NSTRES, PSTRES1, PSTRES2, !Input
& PCLSD,PCCSD, PCNL, PCNRT, PCNSD, PCNSH, PCNST, !Input
& PGT, RHOL, RHOS, RLV, RTDEP, !Input
& RTWTHa, SATFAC, SENESCE, SLAREF, Smax, StalkPopul, !Input
& PHTMAX, STKFWTHa, STKFWT, STKWT, STKWTHa, !Input
& STKWTHalost, SumTTD, SumTTG, SWFAC, SUWT, SUWTHa, !Input
& TGRO, TGROAV, TOTWT, TURFAC, WTNCAN, WTNLF, WTNST, !Input
& WTNSD, WTNUP, WTNFX, XLAI, XLAIlost, YRPLT, PhenoStage, !Input
& BADMD) !Output
!-----------------------------------------------------------------------
USE ModuleDefs !Definitions of constructed variable types,
! which contain control information, soil
! parameters, hourly weather data.
IMPLICIT NONE
SAVE
!-----------------------------------------------------------------------
CHARACTER*1 IDETG, ISWPHO
CHARACTER*2 CROP
CHARACTER*10, PARAMETER :: ERRKEY = 'CSP_OPGROW'
! CHARACTER*8 FNAME
CHARACTER*10 SKIP_STR, VLEN_STR, WIDTH_STR
CHARACTER*12 OUTG, OUTPC, OUTPN, OUTKG
CHARACTER*15 GROHEAD(4, 50)
CHARACTER*15 GRO_OUT(50)
CHARACTER*20 FILEIO, OFILE
CHARACTER*100 G_FMT_STR, D_FMT_STR ! Strings for outputting comments
! and daily values
CHARACTER*1024 FMT_STR, T_FMT_STR ! Runtime format strings
INTEGER CountStalk, DAP, DAS, DOY, DYNAMIC, ERRNUM, FROP, I, J, L
INTEGER MDATE, NLAYR, NOUTDG, NOUTKG, NOUTPC, NOUTPN, NUM_OVARS
INTEGER PhenoStage, OpenStatus, RUN, SKIP, Smax, Stalk, TIMDIF
INTEGER VAR_WIDTH, VLEN, YEAR, YRDOY, YRPLT, YRSIM, PSLUN
INTEGER TLEN, FLEN, ENDI ! String lengths
INTEGER, DIMENSION(1:NumOfStalks):: Kill
REAL BADMD, BRDMD, CADLF, CADST, CANHT, CANWH, CMINEA
REAL EOS, PHTMAX, GROWTH, GRWRES, HID, HIF, LAITD, LITOTAL
REAL MAINR, NSTRES, PCLSD, PCCSD, PCNL, PGT
REAL RHOL, RHOS, RTDEP
REAL SLAREF
REAL SATFAC, SMDMD, SMFMD, SUID, SUDMD, SUFMD, SumTTD, SumTTG
REAL SWFAC, TGROAV, TOTWT, TRLV, TURFAC, XLAI, XLAIlost
!TOPWT, VSTAGE
REAL PCCSDP, PCLSDP, PCNLP, PCNRTP, PCNSDP
REAL PCNSHP, PCNSTP, RHOLP, RHOSP, SLAP
REAL DLAYR(NL), RLV(NL)
REAL TGRO(TS)
REAL WTNCAN,WTNLF,WTNST,WTNSD,WTNUP,WTNFX
REAL WTNVEG,PCNVEG,NFIXN
REAL PCNST,PCNRT,PCNSH,PCNSD
REAL CUMSENSURF, CUMSENSOIL !cumul. senesced matter, soil & surf
REAL CUMSENSURFN, CUMSENSOILN !cumul. senes. N soil and surface
REAL, DIMENSION(0:NumOfDays) ::LFWTHa, LSWTHa, LFWTHalost,
& LSWTHalost, RTWTHa, StalkPopul, STKFWTHa,
& STKWTHa, STKWTHalost, SUWTHa
REAL, DIMENSION(0:NumOfDays,NumOfStalks) ::LeafArea,LeafArealost,
& LeafNum, LFWT, LFWTlost, LSWTlost, LSWT,
& STKFWT, STKWT, SUWT
LOGICAL FEXIST, FIRST
! Added for P module
REAL PStres1, PStres2
!-----------------------------------------------------------------------
! Define constructed variable types based on definitions in
! ModuleDefs.for.
! The variable "CONTROL" is of type "ControlType".
TYPE (ControlType) CONTROL
TYPE (SoilType) SOILPROP !CHP not actually used yet
! The variable "ISWITCH" is of type "SwitchType".
TYPE (SwitchType) ISWITCH
TYPE (ResidueType) SENESCE
!----------------------------------------------------------------------
c DATA (for headings)
!----------------------------------------------------------------------
c Headings for output variables:
c ::::::::::::::::::::::::::::::
c Date:
DATA GROHEAD(1, 1) /'!DATE'/
DATA GROHEAD(2, 1) /'! '/
DATA GROHEAD(3, 1) /'!YEAR'/
DATA GROHEAD(4, 1) /'@YEAR'/
c Day of year:
DATA GROHEAD(1, 2) /'Day '/
DATA GROHEAD(2, 2) /'of'/
DATA GROHEAD(3, 2) /'year'/
DATA GROHEAD(4, 2) /'DOY'/
c Days after 'simulation start' (I think)
DATA GROHEAD(1, 3) /'Days'/
DATA GROHEAD(2, 3) /'after'/
DATA GROHEAD(3, 3) /'sim.start'/
DATA GROHEAD(4, 3) /'DAS'/
c Days after 'planting' (/harvest?)
DATA GROHEAD(1, 4) /'Days'/
DATA GROHEAD(2, 4) /'after'/
DATA GROHEAD(3, 4) /'plant'/
DATA GROHEAD(4, 4) /'DAP'/
c Number of leaf tips
DATA GROHEAD(1, 5) /'Primary'/
DATA GROHEAD(2, 5) /'Leaf-tip'/
DATA GROHEAD(3, 5) /'number'/
DATA GROHEAD(4, 5) /'L#S1D'/
c Growth stage
DATA GROHEAD(1, 6) /'Growth'/
DATA GROHEAD(2, 6) /'stage'/
DATA GROHEAD(3, 6) /'number'/
DATA GROHEAD(4, 6) /'GSTD'/
c Leaf area index
DATA GROHEAD(1, 7) /'Leaf'/
DATA GROHEAD(2, 7) /'area'/
DATA GROHEAD(3, 7) /'index'/
DATA GROHEAD(4, 7) /'LAIGD'/
c Dry mass of green leaves + meristem
DATA GROHEAD(1, 8) /'Green'/
DATA GROHEAD(2, 8) /'leaf'/
DATA GROHEAD(3, 8) /'DM (t/ha)'/
DATA GROHEAD(4, 8) /'LGDMD'/
c Dry mass of green leaf sheaths
DATA GROHEAD(1, 9) /'Green'/
DATA GROHEAD(2, 9) /'leaf sheath'/
DATA GROHEAD(3, 9) /'DM (t/ha)'/
DATA GROHEAD(4, 9) /'SGDMD'/
c Stalk fresh mass
DATA GROHEAD(1, 10) /'Stalk'/
DATA GROHEAD(2, 10) /'fresh'/
DATA GROHEAD(3, 10) /'mass (t/ha)'/
DATA GROHEAD(4, 10) /'SMFMD'/
c Stalk dry mass
DATA GROHEAD(1, 11) /'Stalk dry'/
DATA GROHEAD(2, 11) /'mass with'/
DATA GROHEAD(3, 11) /'sucro(t/ha)'/
DATA GROHEAD(4, 11) /'SMDMD'/
c Sucrose dry mass
DATA GROHEAD(1, 12) /'Sucrose'/
DATA GROHEAD(2, 12) /'mass'/
DATA GROHEAD(3, 12) /'(t/ha)'/
DATA GROHEAD(4, 12) /'SUCMD'/
c Root dry mass
DATA GROHEAD(1, 13) /'Root'/
DATA GROHEAD(2, 13) /'Dry mass'/
DATA GROHEAD(3, 13) /'t/ha'/
DATA GROHEAD(4, 13) /'RDMD'/
c Aerial (above-ground) biomass
DATA GROHEAD(1, 14) /'Aboveground'/
DATA GROHEAD(2, 14) /'live + dead'/
DATA GROHEAD(3, 14) /'DM (t/ha)'/
DATA GROHEAD(4, 14) /'BADMD'/
c Stalks per ha
DATA GROHEAD(1, 15) /'Stalks'/
DATA GROHEAD(2, 15) /'per'/
DATA GROHEAD(3, 15) /'m2'/
DATA GROHEAD(4, 15) /'T#AD'/
c Stalks per plant
DATA GROHEAD(1, 16) /'Stalks'/
DATA GROHEAD(2, 16) /'per'/
DATA GROHEAD(3, 16) /'Plant'/
DATA GROHEAD(4, 16) /'T#PD'/
c Harvest index (t sucrose / t above ground biomass)
DATA GROHEAD(1, 17) /'Harvest'/
DATA GROHEAD(2, 17) /'Index'/
DATA GROHEAD(3, 17) /'HI (t/t)'/
DATA GROHEAD(4, 17) /'SUID'/
c Trash dry mass
DATA GROHEAD(1, 18) /'Trash-dead'/
DATA GROHEAD(2, 18) /'leaf+sheath'/
DATA GROHEAD(3, 18) /'DM (t/ha)'/
DATA GROHEAD(4, 18) /'LDDMD'/
c Total (living + dead) leaf area index
DATA GROHEAD(1, 19) /'live'/
DATA GROHEAD(2, 19) /'+ dead leaf'/
DATA GROHEAD(3, 19) /'area index'/
DATA GROHEAD(4, 19) /'LAITD'/
c Water stress affecting photosynthesis
DATA GROHEAD(1, 20) /'Phot.'/
DATA GROHEAD(2, 20) /'water'/
DATA GROHEAD(3, 20) /'Stress(0-1)'/
DATA GROHEAD(4, 20) /'WSPD'/
c Water stress affecting growth
DATA GROHEAD(1, 21) /'Growth'/
DATA GROHEAD(2, 21) /'Water'/
DATA GROHEAD(3, 21) /'stress'/
DATA GROHEAD(4, 21) /'WSGD'/
c Senesced tiller (stalk) dry mass
DATA GROHEAD(1, 22) /'Dead'/
DATA GROHEAD(2, 22) /'Stalk'/
DATA GROHEAD(3, 22) /'DM (t/ha)'/
DATA GROHEAD(4, 22) /'SDDMD'/
c Stalk height (metres)
DATA GROHEAD(1, 23) /'Stalk'/
DATA GROHEAD(2, 23) /'Height'/
DATA GROHEAD(3, 23) /'m'/
DATA GROHEAD(4, 23) /'SHTD'/
c Root depth (m)
DATA GROHEAD(1, 24) /'Root'/
DATA GROHEAD(2, 24) /'Depth'/
DATA GROHEAD(3, 24) /'m'/
DATA GROHEAD(4, 24) /'RDPD'/
c Root length density (cm3/cm3)
c Layer 1
DATA GROHEAD(1, 25) /'Root_Len.'/
DATA GROHEAD(2, 25) /'density(1)'/
DATA GROHEAD(3, 25) /'cm3/cm3'/
DATA GROHEAD(4, 25) /'RL1D'/
c Root length density (cm3/cm3)
c Layer 2
DATA GROHEAD(1, 26) /'Root_Len.'/
DATA GROHEAD(2, 26) /'density(2)'/
DATA GROHEAD(3, 26) /'cm/cm3'/
DATA GROHEAD(4, 26) /'RL2D'/
c Root length density (cm3/cm3)
c Layer 3
DATA GROHEAD(1, 27) /'Root_Len.'/
DATA GROHEAD(2, 27) /'density(3)'/
DATA GROHEAD(3, 27) /'cm/cm3'/
DATA GROHEAD(4, 27) /'RL3D'/
c Root length density (cm3/cm3)
c Layer 4
DATA GROHEAD(1, 28) /'Root_Len.'/
DATA GROHEAD(2, 28) /'density(4)'/
DATA GROHEAD(3, 28) /'cm/cm3'/
DATA GROHEAD(4, 28) /'RL4D'/
c Root length density (cm3/cm3)
c Layer 5
DATA GROHEAD(1, 29) /'Root_Len.'/
DATA GROHEAD(2, 29) /'density(5)'/
DATA GROHEAD(3, 29) /'cm/cm3'/
DATA GROHEAD(4, 29) /'RL5D'/
c Root length density (cm3/cm3)
c Layer 6
DATA GROHEAD(1, 30) /'Root_Len.'/
DATA GROHEAD(2, 30) /'density(6)'/
DATA GROHEAD(3, 30) /'cm/cm3'/
DATA GROHEAD(4, 30) /'RL6D'/
c Root length density (cm3/cm3)
c Layer 7
DATA GROHEAD(1, 31) /'Root_Len.'/
DATA GROHEAD(2, 31) /'density(7)'/
DATA GROHEAD(3, 31) /'cm/cm3'/
DATA GROHEAD(4, 31) /'RL7D'/
c Root length density (cm3/cm3)
c Layer 8
DATA GROHEAD(1, 32) /'Root_Len.'/
DATA GROHEAD(2, 32) /'density(8)'/
DATA GROHEAD(3, 32) /'cm/cm3'/
DATA GROHEAD(4, 32) /'RL8D'/
c Root length density (cm3/cm3)
c Layer 9
DATA GROHEAD(1, 33) /'Root_Len.'/
DATA GROHEAD(2, 33) /'density(9)'/
DATA GROHEAD(3, 33) /'cm/cm3'/
DATA GROHEAD(4, 33) /'RL9D'/
c Root length density (cm3/cm3)
c Layer 10
DATA GROHEAD(1, 34) /'Root_Len.'/
DATA GROHEAD(2, 34) /'density(10)'/
DATA GROHEAD(3, 34) /'cm/cm3'/
DATA GROHEAD(4, 34) /'RL10D'/
c Potential soil evaporation (mm/day)
c This is in here because ET.OUT does not output it...
DATA GROHEAD(1, 35) /'Potential'/
DATA GROHEAD(2, 35) /'soil'/
DATA GROHEAD(3, 35) /'evap(mm)'/
DATA GROHEAD(4, 35) /'EOSA'/
c Total root length density
c This is a fairly meaningless variable that
c assisted with model comparison
DATA GROHEAD(1, 36) /'Total'/
DATA GROHEAD(2, 36) /'Root'/
DATA GROHEAD(3, 36) /'Length'/
DATA GROHEAD(4, 36) /'RTLD'/
c Percent light interception
c 0-100%
DATA GROHEAD(1, 37) /'Percent'/
DATA GROHEAD(2, 37) /'light'/
DATA GROHEAD(3, 37) /'interceptn'/
DATA GROHEAD(4, 37) /'LI%D'/
c Specific leaf area
DATA GROHEAD(1, 38) /'Spec'/
DATA GROHEAD(2, 38) /'Leaf'/
DATA GROHEAD(3, 38) /'Area'/
DATA GROHEAD(4, 38) /'SLAD'/
c Gross photosynthetic rate
c t/ha/day
DATA GROHEAD(1, 39) /'Gross'/
DATA GROHEAD(2, 39) /'photos'/
DATA GROHEAD(3, 39) /'rate(t/ha/d)'/
DATA GROHEAD(4, 39) /'PGRD'/
c Biomass accumulation rate (change per day)
c t/ha/day
DATA GROHEAD(1, 40) /'Biomass'/
DATA GROHEAD(2, 40) /'accum.'/
DATA GROHEAD(3, 40) /'(t/ha/d)'/
DATA GROHEAD(4, 40) /'BRDMD'/
c Water-logging stress
DATA GROHEAD(1, 41) /'Excess'/
DATA GROHEAD(2, 41) /'Soil H2O'/
DATA GROHEAD(3, 41) /'Stress(0-1)'/
DATA GROHEAD(4, 41) /'EWSD'/
c Cumulative thermal time (emergence and new leaves)
DATA GROHEAD(1, 42) /'Heat units'/
DATA GROHEAD(2, 42) /'Emrg & Leaf'/
DATA GROHEAD(3, 42) /'deg C.day'/
DATA GROHEAD(4, 42) /'STTD'/
c Cumulative thermal time (new tillers)
DATA GROHEAD(1, 43) /'Heat units'/
DATA GROHEAD(2, 43) /'New Tillers'/
DATA GROHEAD(3, 43) /'deg C.day'/
DATA GROHEAD(4, 43) /'STTG'/
c Nitrogen stress
DATA GROHEAD(1, 44) /'Nitrogen'/
DATA GROHEAD(2, 44) /''/
DATA GROHEAD(3, 44) /'Stress(0-1)'/
DATA GROHEAD(4, 44) /'NSTD'/
c Sucrose % of dry stalk mass
DATA GROHEAD(1, 45) /'Sucrose %'/
DATA GROHEAD(2, 45) /'dry mass'/
DATA GROHEAD(3, 45) /'t/t * 100'/
DATA GROHEAD(4, 45) /'SU%DMD'/
c Sucrose % of wet/fresh stalk mass
DATA GROHEAD(1, 46) /'Sucrose %'/
DATA GROHEAD(2, 46) /'wet mass'/
DATA GROHEAD(3, 46) /'t/t * 100'/
DATA GROHEAD(4, 46) /'SU%FMD'/
c P stress affecting growth (PSTRES1)
DATA GROHEAD(1, 47) /'Growth'/
DATA GROHEAD(2, 47) /'Phosphorus'/
DATA GROHEAD(3, 47) /'Stress(0-1)'/
DATA GROHEAD(4, 47) /'PS1D'/
c P stress affecting photosynthesis (PSTRES2)
DATA GROHEAD(1, 48) /'Phot.'/
DATA GROHEAD(2, 48) /'Phosphorus'/
DATA GROHEAD(3, 48) /'Stress(0-1)'/
DATA GROHEAD(4, 48) /'PS2D'/
c ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
c Number of output variables (important for output!)
DATA NUM_OVARS /48/
c Width of output columns:
DATA VAR_WIDTH /12/
c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
! No output for fallow crop
CROP = CONTROL % CROP
IDETG = ISWITCH % IDETG
IF (CROP .EQ. 'FA' .OR. IDETG .EQ. 'N') RETURN
! Transfer values from constructed data types into local variables.
DAS = CONTROL % DAS
DYNAMIC = CONTROL % DYNAMIC
FROP = CONTROL % FROP
RUN = CONTROL % RUN
YRDOY = CONTROL % YRDOY
YRSIM = CONTROL % YRSIM
ISWPHO = ISWITCH % ISWPHO
!***********************************************************************
!***********************************************************************
! Run initialization - run once per simulation
!***********************************************************************
IF (DYNAMIC .EQ. RUNINIT) THEN
!-----------------------------------------------------------------------
! IF (IDETG .EQ. 'Y') THEN
OUTG = 'PlantGro.OUT'
CALL GETLUN('OUTG', NOUTDG)
OUTPN = 'PlantN.OUT '
CALL GETLUN('OUTPN', NOUTPN)
OUTPC = 'PlantC.OUT '
CALL GETLUN('OUTPC', NOUTPC)
OUTKG = 'PlantKg.OUT '
CALL GETLUN('OUTKG', NOUTKG)
! ENDIF
!***********************************************************************
!***********************************************************************
! Seasonal initialization - run once per season
!***********************************************************************
ELSEIF (DYNAMIC .EQ. SEASINIT) THEN
!-----------------------------------------------------------------------
! Initialize daily growth output file (tons, CaneGro format)
INQUIRE (FILE = OUTG, EXIST = FEXIST)
IF (FEXIST) THEN
OPEN (UNIT = NOUTDG, FILE = OUTG, STATUS = 'OLD',
& IOSTAT = ERRNUM, POSITION = 'APPEND')
FIRST = .FALSE.
ELSE
OPEN (UNIT = NOUTDG, FILE = OUTG, STATUS = 'NEW',
& IOSTAT = ERRNUM)
WRITE(NOUTDG,'("*GROWTH ASPECTS OUTPUT FILE")')
FIRST = .TRUE.
ENDIF
!Write headers
CALL HEADER(SEASINIT, NOUTDG, RUN)
FMT_STR = '(A5, 1X, A3, '
DO J=3, NUM_OVARS
c Get length of variable name
VLEN = LEN_TRIM(GROHEAD(4, J))
c How many spaces need to be skipped?
SKIP = VAR_WIDTH - VLEN
c Create strings of these:
WRITE(SKIP_STR, '(I3)') SKIP
WRITE(VLEN_STR, '(I3)') VLEN
c WRITE(*, '(A)') SKIP_STR, VLEN_STR
c Add to format statement:
IF (J .EQ. NUM_OVARS) THEN
c If this is format info for the last variable:
T_FMT_STR = TRIM(SKIP_STR) // 'X,'
& // 'A' // TRIM(VLEN_STR)
& // ')'
ELSE
c For any variable
T_FMT_STR = TRIM(SKIP_STR) // 'X,'
& // 'A' // TRIM(VLEN_STR)
& // ','
ENDIF
TLEN = LEN_TRIM(T_FMT_STR) + 1
FLEN = LEN_TRIM(FMT_STR) + 1
ENDI = FLEN + TLEN - 1
c WRITE(*, '(A)') T_FMT_STR
c WRITE(*, '(3(I3, 2H, ))') TLEN, FLEN, ENDI
WRITE(FMT_STR(FLEN:ENDI), '(A)') T_FMT_STR(1:TLEN)
ENDDO
c Output the format string
c Format string for general headings:
WRITE(WIDTH_STR, '(I3)') VAR_WIDTH-1
G_FMT_STR = '(A5,1X,A3,1X,50(1H|, A'
& // TRIM(WIDTH_STR) // '))'
c Loop through each row of GROHEAD, outputting
c each column value per row
DO I=1, 4
DO J=1,NUM_OVARS
GRO_OUT(J) = GROHEAD(I, J)
ENDDO
IF (I .LT. 4) THEN
WRITE (NOUTDG,FMT=G_FMT_STR)
& GRO_OUT(1:NUM_OVARS)
ELSE
c Write right-aligned column headings
WRITE (NOUTDG,FMT=FMT_STR)
& GRO_OUT(1:NUM_OVARS)
ENDIF
ENDDO
c Output format string for daily values
D_FMT_STR = '(1X, I4, 1X, I3, 4(1X, I'
& // TRIM(WIDTH_STR) //
& '), 95(1X, F' //
& TRIM(WIDTH_STR) // '.3))'
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
! Initialize daily growth output file (kg, DSSAT format)
INQUIRE (FILE = OUTKG, EXIST = FEXIST)
IF (FEXIST) THEN
OPEN (UNIT = NOUTKG, FILE = OUTKG, STATUS = 'OLD',
& IOSTAT = ERRNUM, POSITION = 'APPEND')
FIRST = .FALSE.
ELSE
OPEN (UNIT = NOUTKG, FILE = OUTKG, STATUS = 'NEW',
& IOSTAT = ERRNUM)
WRITE(NOUTKG,'("*GROWTH ASPECTS OUTPUT FILE, Kg")')
FIRST = .TRUE.
ENDIF
!Write headers
CALL HEADER(SEASINIT, NOUTKG, RUN)
IF (ISWPHO .EQ. 'N') THEN ! Phosphorus stress is off.
WRITE (NOUTKG,200,ADVANCE="NO")
! WRITE (NOUTKG,200)
200 FORMAT('! |<-Days->| Leaf',30X,'|< T/Ha>',
& '|<---------- kg/Ha ----------->|',10X,'|<-kg/Ha->|',
& ' |<---- Stress (0-1) ---->|',8X,'SLAREF <--Canopy-> ',
& ' Root |',
& '<---------------------- cm[roots]/cm3[soil] ',
& '---------------------->| <-- kg/ha--> |',
& /'! after Growth Num |<---LAI-->|',
& ' |<Stalks per>| |<-------- Dry Weight --------->|',
& ' Fresh Fresh | Senesced Phot Grow Leaf Exces' ,
& ' Leaf Leaf High Wide Depth |',67X,'| Senes Dry |',
& /'!',11X,'Sim Plant Stage Stk#1 live dead Plant M2',
& ' Aerial Leaf Stalk Sucro Root Yield Sucro% Leaf',
& ' Stalk H2O H2O N H2O N % cm2/g',
& ' m m m |',23X,
& ' Root Length Density',24X,'| Surf Soil | ',
& 'Leaf weight each stalk (g[dry matter live leaves])')
DO I = 1, ((Smax*7)-53)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">| Stalk weight each",
& " (g[dry matter live stalks])")',ADVANCE="NO")
DO I = 1, ((Smax*7)-48)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">| Sucrose weight each stalk (g)")',
& ADVANCE="NO")
DO I = 1, ((Smax*7)-32)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">| Nodes on each stalk",
& " (live and senesced leaves)")',ADVANCE="NO")
DO I = 1, ((Smax*7)-49)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">| Leaf area on each stalk",
& " (cm2 [live leaves])")', ADVANCE="NO")
DO I = 1, ((Smax*7)-46)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">|")',ADVANCE="NO")
WRITE (NOUTKG,210,ADVANCE="NO")
210 FORMAT(//'@YEAR DOY DAS DAP',
& ' GSTD L#S1D LAIGD DLAID',
& ' T#PD T#AD BADMD LWAD',
& ' SWAD SUAD',
& ' RWAD HWAH',
& ' SU%FMD LDAD SDAD',
& ' WSPD WSGD NSTD',
& ' EWSD LN%D SLAD',
& ' CHTD CWID',
& ' RDPD RL1D RL2D RL3D RL4D',
& ' RL5D RL6D RL7D RL8D RL9D RL10D',
& ' SNW0C SNW1C ')
ELSE ! Phosphorus stress is on.
WRITE (NOUTKG,220,ADVANCE="NO")
220 FORMAT('! |<-Days->| Leaf',30X,'|< T/Ha>',
& '|<---------- kg/Ha ----------->|',10X,'|<-kg/Ha->|',
& ' |<------------ Stress (0-1)------------>|',8X,'SLAREF',
& ' <--Canopy-> Root |',
& '<---------------------- cm[roots]/cm3[soil] ----------------',
& '------>| <-- kg/ha--> |',
& /,'! after Growth Num |<---LAI-->|',
& ' |<Stalks per>| |<-------- Dry Weight --------->|',
& ' Fresh Fresh |',
& ' Senesced Phot Grow Leaf Parti Phot',
& ' Exces Leaf Leaf High Wide Depth ',
& '|',67X,'| Senes Dry |',
& /,'!',11X,'Sim Plant Stage Stk#1 live dead Plant M2',
& ' Aerial Leaf Stalk Sucro Root Yield Sucro% Leaf',
& ' Stalk H2O H2O N P P H2O N % ',
& ' cm2/g m m m',
& ' |',24X,'Root Length Density',24X,'| Surf Soil | ',
& 'Leaf weight each stalk (g[dry matter live leaves])')
DO I = 1, ((Smax*7)-53)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">| Stalk weight each",
& " (g[dry matter live stalks])")',ADVANCE="NO")
DO I = 1, ((Smax*7)-48)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">| Sucrose weight each stalk (g)")',
& ADVANCE="NO")
DO I = 1, ((Smax*7)-32)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">| Nodes on each stalk",
& " (live and senesced leaves)")',ADVANCE="NO")
DO I = 1, ((Smax*7)-49)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">| Leaf area on each stalk",
& " (cm2 [live leaves])")', ADVANCE="NO")
DO I = 1, ((Smax*7)-46)
WRITE (NOUTKG,'("-")',ADVANCE="NO")
ENDDO
WRITE (NOUTKG,'(">|")')
WRITE (NOUTKG,230,ADVANCE="NO") ! Begin here FSR
230 FORMAT(//'@YEAR DOY DAS DAP',
& ' GSTD L#S1D LAIGD DLAID',
& ' T#PD T#AD BADMD LWAD',
& ' SWAD SUAD',
& ' RWAD HWAH',
& ' SU%FMD LDAD SDAD',
& ' WSPD WSGD NSTD',
& ' PS1D PS2D',
& ' EWSD LN%D SLAD',
& ' CHTD CWID',
& ' RDPD RL1D RL2D RL3D RL4D',
& ' RL5D RL6D RL7D RL8D RL9D RL10D',
& ' SNW0C SNW1C ')
ENDIF ! (ISWPHO .EQ. 'N')
! Header line IF statements to keep column headings same length
! by inserting underscore where stalk number < 10. FSR
IF (Smax <= 9) THEN
DO Stalk = 1,Smax
WRITE(NOUTKG,'(2X"LWD_",I1)',ADVANCE="NO") Stalk
END DO
ELSE
DO Stalk = 1,9
WRITE(NOUTKG,'(2X"LWD_",I1)',ADVANCE="NO") Stalk
END DO
DO Stalk = 10,Smax
WRITE(NOUTKG,'(2X"LWD",I2)',ADVANCE="NO") Stalk
END DO
ENDIF
IF (Smax <= 9) THEN
DO Stalk = 1,Smax
WRITE(NOUTKG,'(2X"SWD_",I1)',ADVANCE="NO") Stalk
END DO
ELSE
DO Stalk = 1,9
WRITE(NOUTKG,'(2X"SWD_",I1)',ADVANCE="NO") Stalk
END DO
DO Stalk = 10,Smax
WRITE(NOUTKG,'(2X"SWD",I2)',ADVANCE="NO") Stalk
END DO
ENDIF
IF (Smax <= 9) THEN
DO Stalk = 1,Smax
WRITE(NOUTKG,'(2X"SUW_",I1)',ADVANCE="NO") Stalk
END DO
ELSE
DO Stalk = 1,9
WRITE(NOUTKG,'(2X"SUW_",I1)',ADVANCE="NO") Stalk
END DO
DO Stalk = 10,Smax
WRITE(NOUTKG,'(2X"SUW",I2)',ADVANCE="NO") Stalk
END DO
ENDIF
IF (Smax <= 9) THEN
DO Stalk = 1,Smax
WRITE(NOUTKG,'(3X"LN_",I1)',ADVANCE="NO") Stalk
END DO
ELSE
DO Stalk = 1,9
WRITE(NOUTKG,'(3X"LN_",I1)',ADVANCE="NO") Stalk
END DO
DO Stalk = 10,Smax
WRITE(NOUTKG,'(3X"LN",I2)',ADVANCE="NO") Stalk
END DO
ENDIF
IF (Smax <= 9) THEN
DO Stalk = 1,Smax
WRITE(NOUTKG,'(2X"LAD_",I1)',ADVANCE="NO") Stalk
END DO
ELSE
DO Stalk = 1,9
WRITE(NOUTKG,'(2X"LAD_",I1)',ADVANCE="NO") Stalk
END DO
DO Stalk = 10,Smax
WRITE(NOUTKG,'(2X"LAD",I2)',ADVANCE="NO") Stalk
END DO
ENDIF
WRITE (NOUTKG,'(/)') ! skip a line before data output
!-----------------------------------------------------------------------
! Initialize daily plant nitrogen output file
INQUIRE (FILE = OUTPN, EXIST = FEXIST)
IF (FEXIST) THEN
OPEN (UNIT = NOUTPN, FILE = OUTPN, STATUS = 'OLD',
& IOSTAT = ERRNUM, POSITION = 'APPEND')
FIRST = .FALSE.
ELSE
OPEN (UNIT = NOUTPN, FILE = OUTPN, STATUS = 'NEW',
& IOSTAT = ERRNUM)
WRITE(NOUTPN,'("*PLANT N OUTPUT FILE")')
FIRST = .TRUE.
ENDIF
!Write headers
CALL HEADER(SEASINIT, NOUTPN, RUN)
WRITE (NOUTPN,240)
240 FORMAT('@YEAR DOY DAS DAP',
& ' CNAD GNAD VNAD GN%D VN%D NFXC NUPC',
& ' LNAD SNAD LN%D SN%D SHND',
& ' RN%D NFXD SNN0C SNN1C')
!-----------------------------------------------------------------------
! Initialize daily plant carbon output file
INQUIRE (FILE = OUTPC, EXIST = FEXIST)
IF (FEXIST) THEN
OPEN (UNIT = NOUTPC, FILE = OUTPC, STATUS = 'OLD',
& IOSTAT = ERRNUM, POSITION = 'APPEND')
FIRST = .FALSE.
ELSE
OPEN (UNIT = NOUTPC, FILE = OUTPC, STATUS = 'NEW',
& IOSTAT = ERRNUM)
WRITE(NOUTPC,'("*PLANT C OUTPUT FILE")')
FIRST = .TRUE.
ENDIF
!Write headers
CALL HEADER(SEASINIT, NOUTPC, RUN)
WRITE (NOUTPC,250)
250 FORMAT('@YEAR DOY DAS DAP TWAD PHAD',
& ' CMAD CGRD GRAD MRAD CHAD CL%D CS%D',
& ' TGNN TGAV GN%D GL%D GC%D')
!-----------------------------------------------------------------------
! Open file to write results for comparison to field experiment data
!CHP OPEN(UNIT = PSLUN, FILE = "PRIMARY_STALK.OUT", STATUS = "UNKNOWN",
CALL GETLUN('PSTALK',PSLUN)
OPEN(UNIT = PSLUN, FILE = "PrimaryStalk.OUT",STATUS = "UNKNOWN",
& ACTION = "WRITE", POSITION = "REWIND", IOSTAT = OpenStatus)
WRITE(PSLUN,'("*PRIMARY STALK OUTPUT FILE")')
!Write headers
CALL HEADER(SEASINIT, PSLUN, RUN)
WRITE (PSLUN,260,ADVANCE="NO")
260 FORMAT('! |<----Days--->| |<Cuml TU>|',
& ' |<Leaf & Sheath Dry Weight (g on stalk)> |',22X,
& '|<--Primary Stalk Weight (g)-->|',
& /,'! after | °C-day | Leaf | Live |',
& ' Senesced | Total | <--Leaf Area cm2--> ',
& '|<-----Dry matter----->| Fresh |',
& /,'!',11X,'Sim Plant TB(1) TB(2) Numbr | Leaf Sheath| Leaf',
& ' Sheath| | Live Dead Total| Stalk Sucrose',
& ' Stk+Suc| stalk |')
WRITE(PSLUN,'(/"@YEAR DOY DAS DAP STTD STTG L#S1D
& LWD_1 LSW_1 DLW_1 DLS_1 TLW_1 LAD_1 DLA_1 TLA_1
& SWD_1 SUW_1 STD_1 SWF_1")')
!-----------------------------------------------------------------------
CUMSENSURF = 0.
CUMSENSOIL = 0.
CUMSENSURFN = 0.
CUMSENSOILN = 0.
BRDMD = 0.
!***********************************************************************
!***********************************************************************
! DAILY OUTPUT
!***********************************************************************
ELSE IF (DYNAMIC .EQ. OUTPUT) THEN
C-----------------------------------------------------------------------
C CHECK FOR OUTPUT FREQUENCY
C-----------------------------------------------------------------------
IF (YRDOY .LT. YRPLT .OR. YRPLT .LT. 0) RETURN
! Accumulate senesced matter for surface and soil.
CUMSENSURF = CUMSENSURF + SENESCE % ResWt(0)
CUMSENSURFN = CUMSENSURFN + SENESCE % ResE(0,1)
TRLV = 0.0
DO L = 1, NLAYR
CUMSENSOIL = CUMSENSOIL + SENESCE % ResWt(L)
CUMSENSOILN = CUMSENSOILN + SENESCE % ResE(L,1)
TRLV = TRLV + RLV(L) * DLAYR(L)
ENDDO
IF ((MOD(DAS,FROP) .EQ. 0) !Daily output every FROP days,
& .OR. (YRDOY .EQ. YRPLT) !on planting date, and
& .OR. (YRDOY .EQ. MDATE)) THEN !at harvest maturity
! Print
DAP = MAX(0,TIMDIF(YRPLT,YRDOY))
CALL YR_DOY(YRDOY, YEAR, DOY)
IF (IDETG .EQ. 'Y') THEN
! IF (DAS .GE. NVEG0) THEN
RHOLP = RHOL * 100.
RHOSP = RHOS * 100.
SLAP = SLAREF
PCNLP = PCNL
PCNSTP = PCNST
PCNRTP = PCNRT
!Hold off on this "IF" statement until GBuild can handle -99 values
! ELSE
! RHOLP = -99.
! RHOSP = -99.
! SLAP = -99.
! PCNLP = -99.
! PCNSTP = -99.
! PCNRTP = -99.
! ENDIF
! IF (SDWT .GT. 0.0001) THEN ! (for -99 values)
PCNSDP = PCNSD
PCLSDP = PCLSD
PCCSDP = PCCSD
PCNSHP = PCNSH
BADMD = LFWTHa(DAS) +LSWTHa(DAS) +STKWTHa(DAS) +SUWTHa(DAS)
& + LFWTHalost(DAS) + LSWTHalost(DAS) + STKWTHalost(DAS)
! Above ground biomass includes senesced leaves and stalks
SMDMD = (SUWTHa(DAS)+STKWTHa(DAS)) ! Millable stalk DM (kg)
SMFMD = STKFWTHa(DAS) ! Fresh millable stalk (kg)
IF (SUWTHa(DAS) .GE. 1E-4) THEN
HID = SUWTHa(DAS)/SMDMD ! Harvest ratio: Sucrose / Millable DM
HIF = SUWTHa(DAS)/SMFMD ! Harvest ratio: Sucrose / Millable FM
SUID = SUWTHa(DAS) / BADMD ! sucrose/aerial biomass DM
ELSE
HID = 0.
HIF = 0.
SUID = 0.
ENDIF
! Continue here calculating derived variables as needed for output:
IF (ISWPHO .EQ. 'N') THEN
WRITE (NOUTKG,310,ADVANCE="NO")YEAR, DOY, DAS, DAP,
& PhenoStage, INT(LeafNum(DAS,1)), XLAI, XLAIlost,
& CountStalk, StalkPopul(DAS),
& BADMD/1000,
& NINT(LFWTHa(DAS)), NINT(STKWTHa(DAS)), NINT(SUWTHa(DAS)),
& NINT(RTWTHa(DAS)), NINT(SMFMD),
& HIF*100, NINT(LFWTHalost(DAS)), NINT(STKWTHalost(DAS)),
! 1X,F6.1, 2(1X,I6),
& (1.-SWFAC), (1.-TURFAC),(1.-NSTRES), !3(1X,F6.3),
& SATFAC, PCNLP, NINT(SLAREF),
& CANHT, CANWH,
& (RTDEP/100.), (RLV(I),I=1,10),
& NINT(CUMSENSURF), NINT(CUMSENSOIL)
310 FORMAT (/1X,I4,1X,I3,2(1X,I5),
& 1X,I6,1X,I6,1X,F6.2,1X,F6.2,
& 1X,I6,1X,F6.1,1X,F6.2,1X,I6, !12
& 2(1X,I6),
& 2(1X,I6),
& 1X,F6.1,2(1X,I6), !19
& 3(1X,F6.3),
& 1X,F6.3, 1X,F6.1,1X,I6,
& 2(1X, F6.2),
& 11(1X,F6.2),
& 2(1X,I6),2X)
ELSE
WRITE (NOUTKG,312,ADVANCE="NO")YEAR, DOY, DAS, DAP,
& PhenoStage, INT(LeafNum(DAS,1)), XLAI, XLAIlost,
& CountStalk, StalkPopul(DAS),
! & (LFWTHa(DAS)+STKWTHa(DAS)+SUWTHa(DAS))/1000,
& BADMD /1000,
& NINT(LFWTHa(DAS)),
& NINT(STKWTHa(DAS)), NINT(SUWTHa(DAS)),
& NINT(RTWTHa(DAS)), NINT(SMFMD),
& HIF*100, NINT(LFWTHalost(DAS)), NINT(STKWTHalost(DAS)),
& (1.-SWFAC), (1.-TURFAC),(1.-NSTRES),
& (1.-PSTRES1), (1.-PSTRES2),
& SATFAC, PCNLP, NINT(SLAREF),
& CANHT, CANWH,
& (RTDEP/100.), (RLV(I),I=1,10),
& NINT(CUMSENSURF), NINT(CUMSENSOIL)
312 FORMAT (/1X,I4,1X,I3,2(1X,I5),
& 1X,I6, !PhenoStage
& 1X,I6,
& 1X,F6.2, !XLAI
& 1X,F6.2, !XLAIlost
& 1X,I6, !CountStalk
& 1X,F6.1, !StalkPopul(DAS)
& 1X,F6.2, !Total above ground
& 1X,I6,
& 2(1X,I6),
& 2(1X,I6),
& 1X,F6.1, !HI*100
& 2(1X,I6),
& 2(1X,F6.3),
& 3(1X,F6.3),
& 1X,F6.3,
& 1X,F6.1,
& 1X,I6,
& 2(1X, F6.2),
& 11(1X,F6.2),
& 2(1X,I6),2X)
ENDIF