-
Notifications
You must be signed in to change notification settings - Fork 1
/
mafes.f90
9159 lines (7718 loc) · 282 KB
/
mafes.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
!MS$IF DEFINED (WINDOWS)
! note that windows is defined as a preprocessor directive
! program with windowing capabilities
integer function WinMain(hInstance, hPrevInstance, &
lpszCmdLine, nCmdShow)
!MS$ATTRIBUTES STDCALL, ALIAS:'_WinMain@16'::WinMain
USE MSFLIB
USE MSFWIN
INTEGER, intent(IN) :: hInstance, hPrevInstance
INTEGER, intent(IN) :: lpszCmdLine
INTEGER, intent(IN) :: nCmdShow
INTEGER retval
LOGICAL retlog
! FIND GUICS WINDOW
iWndMain = FindWindow(NULL,"GUICS"C)
IF(iWndMain.EQ.0)THEN
retval = MessageBox(NULL,"Interface is needed!"C, &
'Error in GOSSYM'C,IOR(MB_OK,MB_ICONSTOP))
WinMain = -1
RETURN
ENDIF
CALL ModelMain()
! *** 1028 is code for END-OF-WORK message
! *** INFO1 = 0 and INFO2 = 0 may be some data to hand to interface
retlog = PostMessage(iWndMain,1028,0,0)
WinMain = 0
END
SUBROUTINE ModelMain()
!MS$ELSE
PROGRAM MAFES
!MS$ENDIF
USE MSFLIB
USE MSFWIN
!*****************************************************************************
!
! MAFES Version 2004
!
! ********************* WARNING **********************
!Temperatures must be between 13 and 37oC--will not extrapolate beyond limits
! ********************* WARNING **********************
!
! This is the application version of MAFES for GUICS
!
!*****************************************************************************
use common_block
CHARACTER XFILE*150,DUMBO*1
1020 FORMAT(/// ' THE FOLLOWING MESSAGES ARE FOR PROFILE ',A15)
iDanoflg = 0
ipdays = 0
co2 = 0
runmode = 'gossym'
opsys = ' '
errfle = 'runtime.err'
binfle = 'runtime.g00'
xfile = 'run.dat'
insfle = ''
fngfle = ''
OPEN(1,FILE=xfile,STATUS='OLD',err=200)
READ(1,"(a)",END=200) actwth
READ(1,"(a)",END=200) furwth
READ(1,"(a)",END=200) profile
READ(1,"(a)",END=200) irrfrt
READ(1,"(a)",END=200) solhyd
READ(1,"(a)",END=200) solimpd
READ(1,"(a)",END=200) intsol
READ(1,"(a)",END=200) variety
READ(1,"(a)",END=200) pgrhrb
READ(1,"(a)",END=200) pmafil
READ(1,"(a)",END=200) plotfle
READ(1,"(a)",END=200) listfle
READ(1,"(a)",END=200) sumryfle
loc0 = index(plotfle,'.g01')
plotfle2 = plotfle(1:loc0) // 'g02'
OPEN(24,FILE='plot.tmp', status='unknown')
! loc0 = (index(profile,'\', BACK=.true.)+1)
! profle = profile(loc0:)
! loc1 = index(actwth,'\', BACK=.true.)+1
! actwea = actwth(loc1:)
! loc2 = index(furwth,'\', BACK=.true.)+1
! furwea = furwth(loc2:)
! loc3 = index(irrfrt,'\', BACK=.true.)+1
! irrfle = irrfrt(loc3:)
! loc4 = index(solhyd,'\', BACK=.true.)+1
! hydfle = solhyd(loc4:)
! loc5 = index(intsol,'\', BACK=.true.)+1
! intfle = intsol(loc5:)
! loc6 = index(pgrhrb,'\', BACK=.true.)+1
! pgrfle = pgrhrb(loc6:)
! loc7 = index(pmafil,'\', BACK=.true.)+1
! pmafle = pmafil(loc7:)
profle = profile((index(profile,'\', BACK=.true.)+1):)
actwea = actwth((index(actwth,'\', BACK=.true.)+1):)
furwea = furwth((index(furwth,'\', BACK=.true.)+1):)
irrfle = irrfrt((index(irrfrt,'\', BACK=.true.)+1):)
hydfle = solhyd((index(solhyd,'\', BACK=.true.)+1):)
intfle = intsol((index(intsol,'\', BACK=.true.)+1):)
pgrfle = pgrhrb((index(pgrhrb,'\', BACK=.true.)+1):)
pmafle = pmafil((index(pmafil,'\', BACK=.true.)+1):)
OPEN(21,FILE=binfle,FORM='UNFORMATTED',STATUS='unknown')
OPEN(23,FILE=ERRFLE,STATUS='UNKNOWN')
open(77,file=plotfle,status='unknown')
open(88,file=plotfle2,status='unknown')
!MS$IF DEFINED (ALONE)
Write(23,*) 'not a windows program'
!MS$ENDIF
140 CONTINUE
READ(23,*,END=160,ERR=160) DUMBO
GO TO 140
160 CONTINUE
backspace(23)
WRITE(23,1020) profle
CALL GOSSYM
CALL GOSLOOP
CALL PrintOut
200 CONTINUE
close(1)
close(21,status='delete')
close(22)
close(23)
close(75)
close(77)
close(88)
close(LSTNG)
!MS$IF DEFINED(WINDOWS)
return
!MS$ENDIF
end
SUBROUTINE MEMPLANT
use common_block
PMAFIL='IAMDONE'
ABEND=.TRUE.
RETURN
END
SUBROUTINE PHLPLT(PROFLE)
CHARACTER*13 PROFLE
PROFLE=PROFLE
RETURN
END
FUNCTION CKUSER(I)
INTEGER*2 CKUSER,I
JDUM=I
CKUSER=0
RETURN
END
SUBROUTINE GOSLOOP
use common_block
300 CONTINUE
IF(SEND.OR.ABEND) THEN
RETURN
ELSE
CALL DAILY
ENDIF
GO TO 300
END
SUBROUTINE GOSSYM
use common_block
CALL GBLOCK
IF(.NOT.ABEND) CALL PROFILES
IF(.NOT.ABEND) CALL WEATHER
IF(.NOT.ABEND) CALL SOILHYDR
IF(.NOT.ABEND) CALL SOILIMPD
IF(.NOT.ABEND) CALL INITSOIL
IF(.NOT.ABEND) CALL AGINPUTS
! IF(.NOT.ABEND) CALL INSECTCDE
! IF(.NOT.ABEND) CALL FUNGICDE
IF(.NOT.ABEND) CALL PGRHRBCDE
IF(.NOT.ABEND) CALL PLANTMAPS
IF(.NOT.ABEND) CALL INITIALIZE
RETURN
END
SUBROUTINE DAILY
use common_block
INTEGER*2 IDUM,CKUSER
IDAY=IDAY+1
CALL CLYMAT
KDAY=DAYNUM-EMERGE+1
IF(KDAY.LT.0) KDAY=0
dae = kday
if((iniFertDate.lt.emerge).and.(kday.eq.0)) then
CALL SOIL
else
CALL SOIL
IF(DAYNUM.GE.EMERGE) THEN
IF((PIXDAY(1).GT.0).AND.(DAYNUM.GE.PIXDAY(1))) CALL PIX
IF((DEFBGN.GT.0).AND.(DAYNUM.GE.DEFBGN)) call defoliat
CALL PNET
CALL GROWTH
CALL PLTMAPS
CALL ABCISE
DO 320 I=1,15
IPLTNO=I
IF(DAYNUM.EQ.MSADTE(I)) CALL MDSEA(IPLTNO)
320 CONTINUE
CALL MATBAL
ENDIF
endif
CALL OUTPUT
IDUM = 0
IF(CKUSER(IDUM).GT.0) THEN
ABEND=.TRUE.
ELSEIF(DAYNUM.GE.JDSTPS) THEN
SEND=.TRUE.
ELSEIF(DAYNUM.GE.JDAYLW) THEN
SEND=.TRUE.
ENDIF
RETURN
END
SUBROUTINE PROFILES
use common_block
INTEGER*2 ISKWTH,IROWSP,NACRES
CHARACTER EMERG*10,STRSIM*10,STPSIM*10,PRFNAM*13
1000 FORMAT('1',28X,'MAFES-GOSSYM (TM)', / &
29X,'COPYRIGHT (C) 2003' / &
12X,'Mississippi Agriculture & Forestry Experiment Station' / &
16X,'Contact: Dr. K.R. Reddy and David W. Brand' / &
32X,'(662) 325-9462'/ &
29X,'Version - ',A8 /)
1020 FORMAT(A80)
1040 FORMAT(// 29X,'Profile Name: ',A13 / 7X,'Description: ',A51)
1060 FORMAT(/ &
4X,'Variety............ ',A17,2X,'Latitude........... ',I11 / &
4X,'Start Simulation... ',I3,'/',I2,'/',I4, &
8X,'Stop Simulation.... ',I3,'/',I2,'/',I4/ &
4X,'Emergence.......... ',I3,'/',I2,'/',I4, &
8X,'Season Length...... ',I11 / &
4X,'Row Spacing (in)... ',f11.2,8X,'Plants Per Row-Ft.. ',F11.2/ &
4X,'Skip Width (in).... ',f11.2,8X,'Plants Per Acre.... ',I11)
1080 FORMAT(/ &
4X,'Actual Weather..... ',A15,6X,'Future Weather..... ',A15 / &
4X,'Predicted Weather.. ',A15,6X,'Cultural Inputs.... ',A15 / &
4X,'Soil Hydrology..... ',A15,6X,'Initial Soil....... ',A15 / &
4X,'PGR & Herbicides... ',A15,6X,'Insecticides....... ',A15 / &
4X,'Fungicides......... ',A15,6X,'Plant Maps......... ',A15/)
OPEN(11,FILE=profile,FORM=FILFRM,STATUS='OLD',ERR=570)
READ(11,*,ERR=580,END=600) PRFNAM,PDESCP,rundate,EMERG,STRSIM,STPSIM, &
LATUDE,PLTPFT,ISKWTH,IROWSP,NACRES, &
iDanoflg,(ioutfg(i),i=1,6), CO2
! Added CO2 as an input from profile, 6/1/06, SK
! See "initialize" for CO2 correction routines
CLOSE(11)
ivarty = 0
LSTNG=7
OPEN(LSTNG,FILE=listfle,STATUS='UNKNOWN')
WRITE(LSTNG,1000) VERSION
WRITE(LSTNG,1040) profle,PDESCP
!cdt
OPEN(99,file='debug.dat')
CALL CALTOJULAN(EMERG,IDUM1,IDUM2,IYEAR,EMERGE)
CALL CALTOJULAN(STRSIM,IDUM1,IDUM2,IDUM3,JDSTRS)
CALL CALTOJULAN(STPSIM,IDUM1,IDUM2,IDUM3,JDSTPS)
! *** Routine to vary the start and end of simulation kit 6/20/01
if(ipdays.ne.0) then
! *** reset emergence, start and stop dates
emerge = emerge + ipdays
! jdstrs = emerge - 1
jdstrs = jdstrs + ipdays
jdstps = jdstps + ipdays
endif
! *** end of planting date routine
IF((JDSTRS.LE.0).OR.(JDSTPS.LE.0)) THEN
PRINTBUF=' error on reading date in profile'
CALL WRITERR
ABEND=.TRUE.
RETURN
ELSE
IF((JDSTRS.GT.EMERGE).AND.(EMERGE.GT.0)) THEN
JDSTRS=EMERGE
STRSIM=EMERG
ELSEIF(EMERGE.LE.0) THEN
EMERGE = 366
ENDIF
IVARTY = IVARTY+1
SKIPWD = ISKWTH*2.54
ROWSP = IROWSP*2.54
ROWSAVE = ROWSP
IF(SKIPWD.GT.1.0) ROWSP = (ROWSP+SKIPWD)/2.0
POPPLT = PLTPFT/ROWSP*1327709.
IF(.NOT.ABEND) CALL VARIETYS
J0=POPPLT+.5
J1=JDSTPS-JDSTRS+1
! *** get the emergence,start and stop dates
CALL JULANTOCAL(MO,DAZE,IYEAR,emerge)
IMoemg = MO
IDyemg= DAZE
iyremg= iyear
CALL JULANTOCAL(MO,DAZE,IYEAR,jdstrs)
IMostr = MO
IDystr = DAZE
iyrstr = iyear
CALL JULANTOCAL(MO,DAZE,IYEAR,jdstps)
IMostp = MO
IDystp = DAZE
iyrstp = iyear
WRITE(LSTNG,1060) VARITY(IVARTY),LATUDE,imostr,idystr,iyrstr, &
imostp,idystp,iyrstp,imoemg,idyemg,iyremg, &
J1,ROWSP/2.54,PLTPFT,SKIPWD/2.54,J0
WRITE(LSTNG,1080) actwea,furwea,furwea,irrfle,hydfle,intfle, &
pgrfle,insfle,fngfle,pmafle
ENDIF
RETURN
570 CONTINUE
PRINTBUF=' error on open of profile file'
CALL WRITERR
ABEND=.TRUE.
RETURN
580 CONTINUE
PRINTBUF=' error on read in profile'
CALL WRITERR
ABEND=.TRUE.
CLOSE(11)
RETURN
600 CONTINUE
PRINTBUF=' end-of-file while reading profile'
CALL WRITERR
ABEND=.TRUE.
CLOSE(11)
RETURN
END
SUBROUTINE WEATHER
! W E A T H E R
! ************************************************************
! * SUBROUTINE TO READ IN WEATHER, FERTILIZATION, AND *
! * IRRIGATION *
! ************************************************************
use common_block
DIMENSION C13(7)
CHARACTER A00*5,A01*1,A02*6
1000 FORMAT(4X,'Last Actual Weather ',I2.2,'/',I2.2,'/',I4.4, &
13X,'Last Future Weather ',I2.2,'/',I2.2)
1020 FORMAT(A1)
1040 FORMAT(' Error, missing data in actual weather on day ',A5)
1060 FORMAT(' Error, missing data in final weather on day ',I5)
1080 FORMAT(' Error, final weather is missing day ',I5)
1100 FORMAT(A80)
1120 FORMAT(' Error Opening ',A6,' Weather File.')
1140 FORMAT(' Error Reading ',A6,' Weather File on day ',A5)
OPEN(23,FILE=ERRFLE,STATUS='UNKNOWN')
100 CONTINUE
READ(23,*,END=120,ERR=100) A01
GO TO 100
120 CONTINUE
BACKSPACE(23)
! *** READ FUTURE WEATHER FILE
OPEN(11,FILE=furwth,FORM='FORMATTED',STATUS='OLD',ERR=220)
C13(4)=0
C13(7)=1
200 CONTINUE
READ(11,1020,END=240,ERR=230) A01
IF(A01.EQ.'#') THEN
GO TO 200
ELSE
BACKSPACE(11)
READ(11,*,END=240,ERR=230) C13(7),A00,(C13(I),I=1,3), &
C13(5),C13(6)
J=C13(7)
IF(C13(6).LE.0.) C13(6)=88.
IF(J.GT.0) THEN
DO 210 IC=1,7
CLIMAT(J,IC) = C13(IC)
210 CONTINUE
ENDIF
ENDIF
GO TO 200
220 CONTINUE
A02 = 'FUTURE'
WRITE(PRINTBUF,1120) A02
WRITE(23,1100) PRINTBUF
ABEND=.TRUE.
CLOSE(23)
RETURN
230 CONTINUE
A02 = 'FUTURE'
WRITE(PRINTBUF,1140) A02,A00
WRITE(23,1100) PRINTBUF
240 CONTINUE
LDAYFW = C13(7)
C13(7) = 1
JDAYLW = LDAYFW
CLOSE(11)
! *** READ IN CURRENT WEATHER FILE ON TOP OF FUTURE WEATHER
OPEN(11,FILE=actwth,FORM='FORMATTED',STATUS='OLD',ERR=330)
iFirstday = 0
300 CONTINUE
READ(11,1020,END=360,ERR=340) A01
IF(A01.EQ.'#') THEN
GO TO 300
ELSE
BACKSPACE(11)
READ(11,*,END=360,ERR=340) C13(7),A00,(C13(I),I=1,3), &
C13(5),C13(6)
! *** variable to store the date of first available actual weather data
iFirstday = iFirstday + 1
if(iFirstday.eq.1) iFDayAW = C13(7)
IF((C13(7).GE.iFDayAW).AND.(C13(7).LE.JDSTPS)) THEN
! IF((C13(7).GE.JDSTRS).AND.(C13(7).LE.JDSTPS)) THEN
! *** kit 06/24/2003
DO 310 I=1,6
IF(ABS(ABS(C13(I))-6999.0).LT..01) THEN
WRITE(PRINTBUF,1040) A00
WRITE(23,1100) PRINTBUF
GO TO 300
ELSEIF(ABS(ABS(C13(I))-9111.0).LT..01) THEN
WRITE(PRINTBUF,1040) A00
WRITE(23,1100) PRINTBUF
GO TO 300
ENDIF
310 CONTINUE
! J=C13(7)-JDSTRS+1
J=C13(7)
IF(C13(6).LE.0.) C13(6)=88.
DO 320 IC=1,7
CLIMAT(J,IC) = C13(IC)
320 CONTINUE
ENDIF
ENDIF
GO TO 300
330 CONTINUE
A02 = 'ACTUAL'
WRITE(PRINTBUF,1120) A02
WRITE(23,1100) PRINTBUF
ABEND=.TRUE.
CLOSE(23)
RETURN
340 CONTINUE
A02 = 'ACTUAL'
WRITE(PRINTBUF,1140) A02,A00
WRITE(23,1100) PRINTBUF
360 CONTINUE
CLOSE(11)
LDAYAW = C13(7)
IF(LDAYAW.GT.JDAYLW) JDAYLW=LDAYAW
CALL JULANTOCAL(I0,I1,IYEAR,LDAYAW)
CALL JULANTOCAL(I2,I3,IYEAR,LDAYFW)
WRITE(lstng,1000) I0,I1,IYEAR,I2,I3
DO 400 K=JDSTRS,JDSTPS
DO 380 J=1,6
IF((ABS(CLIMAT(K,J))-6999..LT..01).AND. &
(ABS(CLIMAT(K,J))-6999..GT.-.01)) THEN
WRITE(PRINTBUF,1060) CLIMAT(K,7)
WRITE(23,1100) PRINTBUF
ABEND=.TRUE.
ELSEIF((ABS(CLIMAT(K,J))-9111..LT..01).AND. &
(ABS(CLIMAT(K,J))-9111..GT.-.01)) THEN
WRITE(PRINTBUF,1060) CLIMAT(K,7)
WRITE(23,1100) PRINTBUF
ABEND=.TRUE.
ENDIF
380 CONTINUE
IF(CLIMAT(K,7).LT.0.01) THEN
WRITE(PRINTBUF,1080) K
WRITE(23,1100) PRINTBUF
ABEND=.TRUE.
ENDIF
400 CONTINUE
CLOSE(23)
RETURN
END
SUBROUTINE SOILHYDR
use common_block
INTEGER*4 POINTR
CHARACTER FILNAM*13,DSCRIP*51,XDUM1*3,XDUM2*3
1220 FORMAT(// &
7X,'NUMBER OF SOIL LAYERS ... ',I1, &
10X,'WATER TABLE DEPTH (IN) .. ',F4.0, // &
16X,'LAYER NO. LAYER DEPTH % SAND % CLAY' / &
16X,' (IN)')
1240 FORMAT(18X,I3,10X,F6.0,7X,I4,6X,I4)
1260 FORMAT(/ 8X, 'Rainfall Runoff: ',A3,18X,'Irrigation Runoff: ',A3)
OPEN(11,FILE=solhyd,FORM=FILFRM,STATUS='OLD',ERR=200)
READ(11,*,ERR=200,END=300) FILNAM,DSCRIP,LYRSOL,DIFF0C,THTA0C, &
BETAC,THTASC,FCINIC,THTARC,AIRDRC,BDC,DIFF0W,THTA0W, &
BETAW,THTASW,FCININW,THTARW,AIRDRW,BDW,TD,THETAI, &
BDSLOP,BDRATO,PSISFC,WATTBL,POINTR
DO 120 I=1,LYRSOL
READ(11,*,ERR=200,END=300) LDEPTH(I),DIFF0(I),THETA0(I), &
BETA(I),THETAS(I),FCININ(I),THETAR(I),AIRDR(I),BD(I), &
IPSAND(I),IPCLAY(I),POINTR
120 CONTINUE
READ(11,*,ERR=150,END=150) IFGRAIN,IFGIRR
150 CONTINUE
CLOSE(11)
IF(WATTBL.LT.1) WATTBL=200
IF(PSISFC.GT.0.) PSISFC=-PSISFC
WRITE(lstng,1220) LYRSOL,WATTBL/2.54
DO 170 I=1,LYRSOL
WRITE(lstng,1240) I,LDEPTH(I)/2.54,IPSAND(I),IPCLAY(I)
170 CONTINUE
XDUM1='ON '
XDUM2='ON '
IF(IFGRAIN.GT.0) XDUM1='OFF'
IF(IFGIRR.GT.0) XDUM2='OFF'
WRITE(lstng,1260) XDUM1,XDUM2
RETURN
200 CONTINUE
PRINTBUF=' error on read in soilhydr'
CALL WRITERR
CLOSE(11)
ABEND = .TRUE.
RETURN
300 CONTINUE
PRINTBUF=' end-of-file while reading soilhydr'
CALL WRITERR
CLOSE(11)
ABEND = .TRUE.
RETURN
END
SUBROUTINE SOILIMPD
use common_block
OPEN(11,FILE=solimpd,FORM=FILFRM,STATUS='OLD',ERR=200)
READ(11,*,ERR=200,END=300) SNAME
READ(11,*,ERR=200,END=300) NCURVE
DO 180 I=1,NCURVE
READ(11,*,ERR=200,END=300) INRIM,GH2OC(I)
DO 160 J=1,INRIM
READ(11,*,ERR=200,END=300) TSTBD(I,J),TSTIMP(I,J)
160 CONTINUE
180 CONTINUE
CLOSE(11)
RETURN
200 CONTINUE
PRINTBUF=' error on read in soilimpd'
CALL WRITERR
ABEND = .TRUE.
CLOSE(11)
RETURN
300 CONTINUE
PRINTBUF=' end-of-file while reading soilimpd'
CALL WRITERR
ABEND = .TRUE.
CLOSE(11)
RETURN
END
SUBROUTINE INITSOIL
use common_block
INTEGER*2 ISOILW(12)
CHARACTER FILNAM*13,DSCRIP*51
1200 FORMAT(// &
' DEPTH RESIDUAL N (LB/ACRE) ORGANIC H2O CONTENT' / &
' (IN) NITRATE AMMONIA MATTER (%) % FIELD CAP'/ &
' 1- 6',2(4X,F7.1),8X,F6.2,8X,F7.0 / &
' 7-12',2(4X,F7.1),8X,F6.2,8X,F7.0 / &
' 13-18',2(4X,F7.1),8X,F6.2,8X,F7.0 / &
' 19-24',2(4X,F7.1),8X,F6.2,8X,F7.0 / &
' 25-30',2(4X,F7.1),8X,F6.2,8X,F7.0 / &
' 31-36',2(4X,F7.1),8X,F6.2,8X,F7.0)
OPEN(11,FILE=intsol,FORM=FILFRM,STATUS='OLD',ERR=200)
DO 60 I=1,12
ISOILW(I)=100
60 CONTINUE
READ(11,*,ERR=200,END=80) FILNAM,DSCRIP,(RNNH4(I),RNNO3(I), &
OMA(I),ISOILW(I),I=1,12)
80 CONTINUE
DO 100 I=1,12
H2OINT(I) = ISOILW(I)
100 CONTINUE
WRITE(lstng,1200) (RNNO3(I),RNNH4(I),OMA(I),H2OINT(I),I=1,6)
CLOSE(11)
RETURN
200 CONTINUE
PRINTBUF=' error on read in initsoil'
CALL WRITERR
ABEND = .TRUE.
CLOSE(11)
RETURN
END
SUBROUTINE AGINPUTS
use common_block
REAL CSTIRR,AMTAMM,AMTNIT,AMTURA,CSTFRT
INTEGER*2 MTHFRT,ISDHRZ,ISDDPH
CHARACTER FILNAM*13,DSCRIP*51,CDATE*10,DBDATE*8
1000 FORMAT( 'TABLE:', / &
' ------IRRIGATION------ ----------------FERTILIZER', &
'-----------------' / &
' DATE AMOUNT METHOD COST NH4 NO3 UREA COST ', &
' METHOD LOCATION' / &
' (in) ($/a) ----(lb N / a)---- ($/a)', &
' dpth side' /)
1020 FORMAT(1X,A10,1X,F5.2,1X,A6,1X,F7.2,F7.1,2F6.1,2X,F6.2,2X,A6,2I4)
1040 FORMAT( // &
' ------DRIP IRRIGATION------ ----------------', &
'DRIP FERTILIZER---------------' / &
' START STOP AMOUNT COST NH4 NO3 UREA COST ', &
' METHOD LOCATION' / &
' DATE DATE ($/a) ----(lb N / a)--- ($/a)', &
' side dpth' /)
1060 FORMAT(1X,A10,1X,A10,2X,F5.2,1X,F7.2,3F7.1,2X,F6.2,2X,A6,2I5)
1080 FORMAT(I2.2,'/',I2.2,'/',I4.4)
1800 FORMAT(' ')
IF(IRRFRT.NE.' ') THEN
OPEN(11,FILE=irrfrt,FORM=FILFRM,STATUS='OLD',ERR=300)
IDRIP = 0
IDUM = 0
READ(11,*,END=300,ERR=300) FILNAM,DSCRIP
IF(IDUM.EQ.0) THEN
WRITE(lstng,1800)
WRITE(lstng,1800)
WRITE(lstng,1000)
IDUM=1
ENDIF
200 CONTINUE
id = 1
READ(11,*,END=300,ERR=300) CDATE,H2OAMT,MTHIRR(ID), &
AMTAMM,AMTNIT,AMTURA, &
MTHFRT,ISDHRZ,ISDDPH
CALL CALTOJULAN(CDATE,IDUM1,IDUM2,IDUM3,I)
! *** Check to see if fertilizer application is before start
! *** of simulation. If desired, set fertilizer application
! *** date to start date of simulation. Kit 9/1/99
! if(i.lt.jdstrs) i = jdstrs
if(i.le.iFDayAW) i = iFDayAW
if(i.le.jdstrs) then
jdstrs = i
iniFertDate = jdstrs
endif
! *** Reset fertilizer application date when planting dates are changed
if(ipdays.ne.0) i = jdstrs
IF(I.LT.1) I=1
MTHIRR(I) = MTHIRR(ID)
IF((MTHIRR(I).EQ.2).OR.(MTHIRR(I).EQ.4)) THEN
IF(H2OAMT.GT.0.0) THEN
IF(IDRIP.LT.1) IDRPBDT = I
MTHDRP = MTHIRR(I)
DRPH2O = H2OAMT
IDRPFRT = MTHFRT
DRPAMM = AMTAMM
DRPNIT = AMTNIT
DRPURA = AMTURA
IDRPHRZ = ISDHRZ
IDRPDPH = ISDDPH
IDRIP = 1
ELSE
WRITE(lstng,1040)
CALL JULANTOCAL(IDUM1,IDUM2,IYEAR,IDRPBDT)
WRITE(DBDATE,1080) IDUM1,IDUM2,IYEAR
WRITE(lstng,1060) DBDATE,CDATE,DRPH2O,0.0,DRPAMM,DRPNIT, &
DRPURA,0.0,FMTHOD(2),IDRPHRZ,IDRPDPH
IF((I.GT.IDRPBDT).AND.(IDRIP.GT.0)) THEN
IF(IDRPFRT.NE.4) IDRPFRT = 1
DO J=IDRPBDT,I-1
AMTIRR(J) = AMTIRR(J)+DRPH2O
MTHIRR(J) = MTHDRP
NFERT(J,1) = 0
NFERT(J,2) = NFERT(J,2)+DRPAMM+.5
NFERT(J,3) = NFERT(J,3)+DRPNIT+.5
NFERT(J,4) = NFERT(J,4)+DRPURA+.5
NFERT(J,5) = IDRPFRT
NFERT(J,6) = IDRPHRZ
NFERT(J,7) = IDRPDPH
ENDDO
ENDIF
IDRIP = 0
ENDIF
ELSE
IDUM1=6
IF(H2OAMT.GT.0.) THEN
IDUM1=MTHIRR(I)+1
AMTIRR(I)=AMTIRR(I)+H2OAMT
ENDIF
IDUM2=6
IF((AMTAMM.GT..01).OR.(AMTNIT.GT..01).OR. &
(AMTURA.GT..01)) THEN
IDUM2=MTHFRT+1
NFERT(I,1) = 0
NFERT(I,2) = NFERT(I,2)+AMTAMM+.5
NFERT(I,3) = NFERT(I,3)+AMTNIT+.5
NFERT(I,4) = NFERT(I,4)+AMTURA+.5
NFERT(I,5) = MTHFRT
NFERT(I,6) = ISDHRZ
NFERT(I,7) = ISDDPH
ENDIF
CSTIRR = 0.00
CSTFRT = 0.00
WRITE(lstng,1020) CDATE,AMTIRR(I),IMTHOD(IDUM1), &
CSTIRR,AMTAMM,AMTNIT,AMTURA,CSTFRT,FMTHOD(IDUM2), &
ISDDPH,ISDHRZ
ENDIF
GO TO 200
ENDIF
300 CONTINUE
CLOSE(11)
650 CONTINUE
RETURN
END
SUBROUTINE INSECTCDE
use common_block
INTEGER*2 INSMTH(10),INSBDW(10),INUNIT(10)
INTEGER*4 IPOINT
REAL CSTINS(10),RTEINS(10)
CHARACTER INSBRD(10)*14,INSNAM*13,DESCRP*51,INSDTE*10
IF(INSCDE.NE.' ') THEN
OPEN(11,FILE=INSCDE,FORM=FILFRM,STATUS='OLD',ERR=320)
I=0
100 CONTINUE
I=I+1
READ(11,*,ERR=200,END=300) INSNAM,DESCRP,INSDTE
DO 160 J=1,10
READ(11,*,ERR=200,END=200) INSBRD(J),INSMTH(J), &
INSBDW(J),CSTINS(J),RTEINS(J),INUNIT(J)
160 CONTINUE
READ(11,*,ERR=200,END=200) IPOINT
GO TO 100
200 CONTINUE
PRINTBUF=' error on read in insecticide file'
CALL WRITERR
300 CONTINUE
CLOSE(11)
ENDIF
320 CONTINUE
RETURN
END
SUBROUTINE FUNGICDE
use common_block
INTEGER*2 FNGMTH(10),FNGBDW(10),FGUNIT(10)
INTEGER*4 IPOINT
REAL CSTFNG(10),RTEFNG(10)
CHARACTER FNGBRD(10)*14,FNGNAM*13,DESCRP*51,FNGDTE*10
IF(FNGCDE.NE.' ') THEN
OPEN(11,FILE=FNGCDE,FORM=FILFRM,STATUS='OLD',ERR=320)
I=0
100 CONTINUE
I=I+1
READ(11,*,ERR=200,END=300) FNGNAM,DESCRP,FNGDTE
DO 160 J=1,10
READ(11,*,ERR=200,END=200) FNGBRD(J),FNGMTH(J), &
FNGBDW(J),CSTFNG(J),RTEFNG(J),FGUNIT(J)
160 CONTINUE
READ(11,*,ERR=200,END=200) IPOINT
GO TO 100
200 CONTINUE
PRINTBUF=' error on read in fungicide file'
CALL WRITERR
300 CONTINUE
CLOSE(11)
ENDIF
320 CONTINUE
RETURN
END
SUBROUTINE PGRHRBCDE
use common_block
INTEGER*2 PGRMTH,PGRBDW,PGUNIT
REAL RTEPGR
CHARACTER PGRBRD*14,PGRNAM*13,DESCRP*51,PGRDTE*10
1000 FORMAT(/// &
' DATE BRAND METHOD BAND WTH COST ', &
' RATE UNITS' / &
' NAME (in) ($/a)' /)
1020 FORMAT(1X,A10,2X,A8,4X,A6,5X,I5,6X,F7.2,2X,F7.2,5X,A6)
1040 FORMAT(13X, A8,4X,A6,5X,I5,6X,F7.2,2X,F7.2,5X,A6)
IF(PGRHRB.NE.' ') THEN
OPEN(11,FILE=PGRHRB,FORM=FILFRM,STATUS='OLD',ERR=380)
IPX = 0
IPRP = 0
IDEF = 0
I = 0
IF((OPSYS.EQ.'dos').OR.(OPSYS.EQ.'DOS')) THEN
READ(11,ERR=200,END=300) PGRNAM,DESCRP
ELSE
READ(11,*,ERR=200,END=300) PGRNAM,DESCRP
ENDIF
I=I+1
100 CONTINUE
j = 1
IF((OPSYS.EQ.'dos').OR.(OPSYS.EQ.'DOS')) THEN
READ(11,ERR=200,END=300) PGRDTE,PGRBRD,PGRMTH, &
PGRBDW,RTEPGR,PGUNIT
ELSE
READ(11,*,ERR=200,END=300) PGRDTE,PGRBRD,PGRMTH, &
PGRBDW,RTEPGR,PGUNIT
ENDIF
CALL CALTOJULAN(PGRDTE,IDUM1,IDUM2,IDUM3,jdpgr)
if((jdpgr.ge.JDSTRS).and.(jdpgr.le.JDSTPS))then
IF(I.EQ.1) THEN
WRITE(lstng,1000)
i = 0
ENDIF
CSTPGR = 0.0
L=2
120 CONTINUE
IF((PGRBRD(L:L).NE.'.').AND.(PGRBRD(L:L).NE.' ') &
.AND.(PGRBRD(L:L).NE.CHAR(0)).AND.(L.LT.14)) THEN
L=L+1
GO TO 120
ENDIF
DO 140 K=L,14
PGRBRD(K:K)=' '
140 CONTINUE
IF(((PGRBRD(1:3).EQ.'pix').OR.(PGRBRD(1:3).EQ.'PIX')) &
.AND.(RTEPGR.GT.0.01)) THEN
IPX=IPX+1
CALL CALTOJULAN(PGRDTE,IDUM1,IDUM2,IDUM3,PIXDAY(IPX))
DUMRTE=RTEPGR
IF(PGUNIT.EQ.1) DUMRTE=RTEPGR*8
IF(PGUNIT.EQ.2) DUMRTE=RTEPGR/16.
IF(PGUNIT.EQ.4) DUMRTE=1./RTEPGR
IF(PGUNIT.EQ.5) DUMRTE=8./RTEPGR
PIXPPA(IPX)=DUMRTE
PIXMTH(IPX)=PGRMTH
ELSEIF(((PGRBRD(1:4).EQ.'prep').OR. &
(PGRBRD(1:4).EQ.'PREP')).AND.(RTEPGR.GT.0.01)) THEN
IPRP = IPRP + 1
CALL CALTOJULAN(PGRDTE,IDUM1,IDUM2,IDUM3,PRPDATE(IPRP))
DUMRTE=RTEPGR
IF(PGUNIT.EQ.1) DUMRTE=RTEPGR*8
IF(PGUNIT.EQ.2) DUMRTE=RTEPGR/16.
IF(PGUNIT.EQ.4) DUMRTE=1./RTEPGR
IF(PGUNIT.EQ.5) DUMRTE=8./RTEPGR
PRPPPA(IPRP) = DUMRTE
PRPMTH(IPRP) = PGRMTH
ELSEIF(((PGRBRD(1:3).EQ.'DEF').OR. &
(PGRBRD(1:5).EQ.'DROPP').OR. &
(PGRBRD(1:7).EQ.'HARVADE').OR. &
(PGRBRD(1:8).EQ.'GRAMOXON').OR. &
(PGRBRD(1:3).EQ.'def').OR. &
(PGRBRD(1:5).EQ.'dropp').OR. &
(PGRBRD(1:7).EQ.'harvade').OR. &
(PGRBRD(1:8).EQ.'gramoxon')).AND. &
(RTEPGR.GT.0.01)) THEN
IDEF = IDEF + 1
CALL CALTOJULAN(PGRDTE,IDUM1,IDUM2,IDUM3,DEFDATE(IDEF))
DUMRTE=RTEPGR
IF(PGUNIT.EQ.1) DUMRTE=RTEPGR*8
IF(PGUNIT.EQ.2) DUMRTE=RTEPGR/16.
IF(PGUNIT.EQ.4) DUMRTE=1./RTEPGR
IF(PGUNIT.EQ.5) DUMRTE=8./RTEPGR
DEFPPA(IDEF)=DUMRTE
DEFMTH(IDEF)=PGRMTH
ENDIF
IF(PGRBRD(1:1).NE.CHAR(0)) THEN
K=PGRMTH+1
L=PGUNIT+1
IF(J.EQ.1) THEN
WRITE(lstng,1020) PGRDTE,PGRBRD(1:8),HMTHOD(K), &
PGRBDW,CSTPGR,RTEPGR,PGRUNT(L)
ELSE
WRITE(lstng,1040) PGRBRD(1:8),HMTHOD(K), &
PGRBDW,CSTPGR,RTEPGR,PGRUNT(L)
ENDIF
ENDIF
endif
GO TO 100
200 CONTINUE
PRINTBUF=' error on read in PGR & Herbicide file'
CALL WRITERR
CLOSE(11)
RETURN
300 CONTINUE
CLOSE(11)
IF(IDEF.GT.0) THEN
IF((DEFDATE(1).LT.DEFBGN).OR.(DEFBGN.LE.0)) &
DEFBGN = DEFDATE(1)
DEFDAY = DEFDATE(1)
ENDIF
IF(IPRP.GT.0) THEN
IF((PRPDATE(1).LT.DEFBGN).OR.(DEFBGN.LE.0)) &
DEFBGN = PRPDATE(1)
PRPDAY = PRPDATE(1)
ENDIF
ENDIF
380 CONTINUE
RETURN
END