-
Notifications
You must be signed in to change notification settings - Fork 1
/
INPUT.FOR
1706 lines (1579 loc) · 59.6 KB
/
INPUT.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
* Source file INPUT.FOR ||||||||||||||||||||||||||||||||||||||||||||||||
subroutine BasInf(CosAlf,MaxIt,TolTh,TolH,TopInF,BotInF,ShortO,
! lWat,lChem,SinkF,WLayer,qGWLF,FreeD,SeepF,AtmBC,
! KodTop,KodBot,rTop,rRoot,rBot,hCritS,hCritA,
! GWL0L,Aqh,Bqh,kTOld,kBOld,NUnitD,iUnit,NMat,
! NMatD,NLay,lRoot,lTemp,lWDep,lEquil,lScreen,
! qDrain,zBotDr,BaseGW,rSpacing,iPosDr,rKhTop,
! rKhBot,rKvTop,rKvBot,Entres,WetPer,zInTF,GeoFac,
! lInitW,lVarBC,xConv,tConv,lMeteo,lVapor,iVer,
! lPrint,lCentrif,lSnow,hSeep,lFlux,lActRSU,ierr)
character*72 Hed
character*5 LUnit,TUnit,MUnit
logical TopInF,BotInF,ShortO,lWat,lChem,lTemp,SinkF,WLayer,qGWLF,
! FreeD,SeepF,AtmBC,lRoot,lWDep,lEquil,lScreen,qDrain,
! lInitW,lVarBC,lPrint,lMeteo,lVapor,lCentrif,lSnow,lFlux,
! lActRSU,lDummy
dimension iUnit(NUnitD)
iVer = iGetFileVersion(30,1)
read(30,*,err=901)
read(30,*,err=901)
read(30,'(a)',err=901) Hed
read(30,*,err=901)
read(30,'(a)',err=901) LUnit
read(30,'(a)',err=901) TUnit
read(30,'(a)',err=901) MUnit
call Conversion(LUnit,TUnit,xConv,tConv)
read(30,*,err=901)
read(30,*,err=901) lWat,lChem,lTemp,SinkF,lRoot,ShortO,lWDep,
! lScreen,AtmBC,lEquil
if(iVer.eq.3) then
read(30,*,err=901)
read(30,*,err=901) lSnow,lDummy,lDummy,lDummy
else if(iVer.eq.4) then
read(30,*,err=901)
read(30,*,err=901) lSnow,lDummy,lMeteo,lVapor,lActRSU,lFlux
end if
if(lSnow.and..not.lTemp) lSnow=.false.
read(30,*,err=901)
read(30,*,err=901) NMat,NLay,CosAlf
if(NMat.gt.NMatD.or.NLay.gt.10) then
ierr=4
return
end if
read(30,*,err=902)
read(30,*,err=902)
read(30,*,err=902) MaxIt,TolTh,TolH
read(30,*,err=902)
read(30,*,err=902) TopInF,WLayer,KodTop,lInitW
if(KodTop.eq.0) lVarBC=.true.
read(30,*,err=902)
if(iVer.le.3) then
ii=1
read(30,*,err=904) BotInF,qGWLF,FreeD,SeepF,KodBot,qDrain
ii=0
904 if(ii.eq.1) qDrain=.false.
hSeep=0.
else
read(30,*,err=902) BotInF,qGWLF,FreeD,SeepF,KodBot,qDrain,hSeep
end if
if((.not.TopInF.and.KodTop.eq.-1).or.
! (.not.BotInF.and.KodBot.eq.-1.and.
! .not.qGWLF.and..not.FreeD.and..not.SeepF.and..not.qDrain)) then
read(30,*,err=902)
read(30,*,err=902) rTop,rBot,rRoot !,hCritS,hCritA
else
rTop=0.
rBot=0.
rRoot=0.
end if
if(qGWLF) then
read(30,*,err=902)
read(30,*,err=902) GWL0L,Aqh,Bqh
end if
if(qDrain) then
read(30,*,err=902)
read(30,*,err=902) iPosDr
read(30,*,err=902)
read(30,*,err=902) zBotDr,rSpacing,Entres
zBotDr=-abs(zBotDr)
read(30,*,err=902)
if(iPosDr.eq.1) then
read(30,*,err=902) rKhTop
else if(iPosDr.eq.2) then
read(30,*,err=902) BaseGW,rKhTop,WetPer
else if(iPosDr.eq.3) then
read(30,*,err=902) BaseGW,rKhTop,rKhBot,WetPer
else if(iPosDr.eq.4) then
read(30,*,err=902) BaseGW,rKvTop,rKvBot,rKhBot,WetPer,zInTF
else if(iPosDr.eq.5) then
read(30,*,err=902) BaseGW,rKhTop,rKvTop,rKhBot,WetPer,zInTF,
! GeoFac
end if
BaseGW=-abs(BaseGW)
zInTF=-abs(zInTF)
end if
* Input modifications
rRoot=abs(rRoot)
hCritA=1.e+10
hCritA=-abs(hCritA)
if(TopInF) KodTop=isign(3,KodTop)
if(BotInF) KodBot=isign(3,KodBot)
if(AtmBC.and.KodTop.lt.0) then
hCritS=0
KodTop=-4
end if
if(WLayer) KodTop=-iabs(KodTop)
if(qGWLF) KodBot=-7
if(FreeD) KodBot=-5
if(SeepF) KodBot=-2
kTOld=KodTop
kBOld=KodBot
if(lScreen) then
write(*,*)'----------------------------------------------------'
write(*,*)'| |'
write(*,*)'| HYDRUS |'
write(*,*)'| |'
write(*,*)'| Code for simulating one-dimensional variably |'
write(*,*)'| saturated water flow, heat transport, and |'
write(*,*)'| transport of solutes involved in sequential |'
write(*,*)'| first-order decay reactions |'
write(*,*)'| |'
write(*,*)'| version 4.08 |'
write(*,*)'| |'
write(*,*)'| Last modified: January, 2009 |'
write(*,*)'| |'
write(*,*)'----------------------------------------------------'
write(*,*)
write(*,*) Hed
write(*,*)
c write(*,*) 'Press Enter to continue'
c read(*,*)
end if
ii=1
if(lPrint) ii=NUnitD
do 11 i=1,ii
write(iUnit(i),*,err=903)'******* Program HYDRUS'
write(iUnit(i),*,err=903)'******* ',Hed
call getdat(ii,imonth,iday)
call gettim(ihours,mins,isecs,ii)
write(iUnit(i),100,err=903) iday,imonth,ihours,mins,isecs
write(iUnit(i),*,err=903)'Units: L = ',LUnit,', T = ',TUnit,
! ', M = ',MUnit
11 continue
if(CosAlf.le.1.) lCentrif=.false.
if(lCentrif) then
g=9.80665*xConv/tConv/tConv
CosAlf=CosAlf*CosAlf/g
end if
write(50,*,err=903)
write(50,*,err=903) 'CosAlf,MaxIt,TolTh, TolH'
write(50,110,err=903) CosAlf,MaxIt,TolTh,TolH
write(50,*,err=903)
write(50,*,err=903) 'TopInF,BotInF,AtmBC,SinkF,WLayer,qGWLF,FreeD,
!SeepF,lWat,lChem,lTemp,lRoot,lWDep'
write(50,120,err=903) TopInF,BotInF,AtmBC,SinkF,WLayer,qGWLF,
! FreeD,SeepF,lWat,lChem,lTemp,lRoot,lWDep
return
* Error when reading from an input file
901 ierr=1
return
902 ierr=2
return
* Error when writing into an output file
903 ierr=3
return
100 format(' Date: ',i3,'.',i2,'.',' Time: ',i3,':',i2,':',i2)
110 format(f6.3,i5,f8.3,f8.5)
120 format(13l6)
end
************************************************************************
subroutine Conversion(LUnit,TUnit,xConv,tConv)
* conversions from m and s to Hydrus units
character LUnit*5,TUnit*5
xConv=1.
tConv=1.
if (LUnit.eq."cm ") then
xConv=100.
else if(LUnit.eq."mm ") then
xConv=1000.
end if
if (TUnit.eq."min ") then
tConv=1./60.
else if(TUnit.eq."hours") then
tConv=1./(60.*60.)
else if(TUnit.eq."days") then
tConv=1./(60.*60.*24.)
else if(TUnit.eq."years") then
tConv=1./(60.*60.*24.*365.)
end if
return
end
************************************************************************
subroutine NodInf(NumNPD,NumNP,NObsD,NObs,hTop,hBot,x,hNew,hOld,
! MatNum,hTemp,LayNum,Beta,Ah,AK,ATh,Conc,Sorb,
! TempN,TempO,Node,NSD,NS,xSurf,lChem,lTemp,
! lEquil,lScreen,lBact,Sorb2,ierr,lPrint,lFlux,
! lDualNEq)
character*30 Text1,Text2,Text3
dimension x(NumNPD),hNew(NumNPD),hOld(NumNPD),MatNum(NumNPD),
! hTemp(NumNPD),LayNum(NumNPD),Beta(NumNPD),Ah(NumNPD),
! AK(NumNPD),ATh(NumNPD),Conc(NSD,NumNPD),TempN(NumNPD),
! TempO(NumNPD),Node(NObsD),Sorb(NSD,NumNPD),SConc(5),
! SSorb(5),C(5),S(5),Sorb2(NSD,NumNPD)
logical lChem,lTemp,lEquil,lScreen,lPrint,lBact,lDualNEq,lFlux
if(lScreen) write(*,*) 'reading nodal information'
iVer = iGetFileVersion(32,1)
read(32,*,err=901) n
do 11 i=1,n
read(32,*,err=901)
11 continue
read(32,*,err=901) NumNP,ii,NS
if(NumNP.gt.NumNPD) then
ierr=3
return
end if
if(NS.gt.NSD) then
ierr=5
return
end if
* Read nodal point information
j=NumNP+1
12 continue
j=j-1
if(.not.lChem.and..not.lTemp) then
read(32,*,err=901) n,x1,h,M,L,B,Ax,Bx,Dx
Te=20.
else if(.not.lChem) then
read(32,*,err=901) n,x1,h,M,L,B,Ax,Bx,Dx,Te
else if(lEquil) then
read(32,*,err=901) n,x1,h,M,L,B,Ax,Bx,Dx,Te,(C(ii),ii=1,NS)
else
read(32,*,err=901) n,x1,h,M,L,B,Ax,Bx,Dx,Te,(C(ii),ii=1,NS),
! (S(ii),ii=1,NS)
end if
n=NumNP-n+1
x(n)=x1
hOld(n)=h
MatNum(n)=M
LayNum(n)=L
Beta(n)=B
Ah(n)=Ax
AK(n)=Bx
ATh(n)=Dx
TempO(n)=Te
do 1 ii=1,NS
if(lChem) then
Conc(ii,n)=C(ii)
if(.not.lEquil) Sorb (ii,n)=S(ii)
if(lBact.or.lDualNEq) Sorb2(ii,n)=0.
end if
1 continue
if(j-n) 13,18,14
13 write(*,*)'ERROR in NodInf at node =', n
stop
14 continue
dx=x(nOld)-x(n)
ShOld=(hOld(nOld)-hOld(n))/dx
SBeta=(Beta(nOld)-Beta(n))/dx
SAh=(Ah(nOld)-Ah(n))/dx
SAK=(AK(nOld)-AK(n))/dx
SATh=(ATh(nOld)-ATh(n))/dx
STemp=(TempO(nOld)-TempO(n))/dx
if(lChem) then
do 15 ii=1,NS
SConc(ii)=(Conc(ii,nOld)-Conc(ii,n))/dx
SSorb(ii)=(Sorb(ii,nOld)-Sorb(ii,n))/dx
15 continue
end if
do 17 i=nOld-1,n+1,-1
dx=x(nOld)-x(i)
hOld(i)=hOld(nOld)-ShOld*dx
Beta(i)=Beta(nOld)-SBeta*dx
Ah(i)=Ah(nOld)-SAh*dx
AK(i)=AK(nOld)-SAK*dx
ATh(i)=ATh(nOld)-SATh*dx
TempO(i)=TempO(nOld)-STemp*dx
if(lChem) then
do 16 ii=1,NS
Conc(ii,i)=Conc(ii,nOld)-SConc(ii)*dx
Sorb(ii,i)=Sorb(ii,nOld)-SSorb(ii)*dx
if(lBact.or.lDualNEq)
! Sorb2(ii,i)=Sorb2(ii,nOld)-SSorb(ii)*dx
16 continue
end if
MatNum(i)=MatNum(i+1)
LayNum(i)=LayNum(i+1)
17 continue
j=n
18 continue
nOld=n
if(j.gt.1) goto 12
SBeta=0.
if(Beta(NumNP).gt.0.) SBeta=Beta(NumNP)*(x(NumNP)-x(NumNP-1))/2.
do 19 i=2,NumNP-1
if(Beta(i).gt.0.) SBeta=SBeta+Beta(i)*(x(i+1)-x(i-1))/2.
19 continue
do 20 i=2,NumNP
if(SBeta.gt.0.) then
Beta(i)=Beta(i)/SBeta
else
Beta(i)=0.
end if
20 continue
xSurf=x(NumNP)
* Print nodal information
write(50,110,err=902)
do 21 n=NumNP,1,-1
if(.not.lChem.and..not.lTemp) then
write(50,120,err=902) NumNP-n+1,x(n),hOld(n),MatNum(n),
! LayNum(n),Beta(n),Ah(n),AK(n),ATh(n)
else if(.not.lChem) then
write(50,120,err=902) NumNP-n+1,x(n),hOld(n),MatNum(n),
! LayNum(n),Beta(n),Ah(n),AK(n),ATh(n),
! TempO(n)
else if(lEquil) then
write(50,120,err=902) NumNP-n+1,x(n),hOld(n),MatNum(n),
! LayNum(n),Beta(n),Ah(n),AK(n),ATh(n),
! TempO(n),(Conc(ii,n),ii=1,NS)
else
write(50,120,err=902) NumNP-n+1,x(n),hOld(n),MatNum(n),
! LayNum(n),Beta(n),Ah(n),AK(n),ATh(n),
! TempO(n),(Conc(ii,n),ii=1,NS),
! (Sorb(ii,n),ii=1,NS)
end if
hNew(n) =hOld(n)
hTemp(n)=hOld(n)
TempN(n)=TempO(n)
21 continue
write(50,'(''end'')',err=902)
hBot=hNew(1)
hTop=hNew(NumNP)
write(50,130,err=902) NS
read(32,*,err=901) NObs
if(NObs.gt.NObsD) then
ierr=4
return
end if
if(NObs.gt.0) then
read(32,*,err=901) (Node(i),i=1,NObs)
do 22 i=1,NObs
Node(i)=NumNP-Node(i)+1
22 continue
if(lPrint) then
NObsA=min(10,NObs)
Text3='Node('
Text1=' h theta Temp '
if(lFlux) Text1=' h theta Flux '
Text2=' Conc '
if(.not.lChem) then
write(77,140,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
write(77,200,err=902) (Text1,i=1,NObsA)
else
if(NS.eq.1)
! write(77,150,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.2)
! write(77,160,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.3)
! write(77,170,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.4)
! write(77,180,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.5)
! write(77,190,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.6)
! write(77,260,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.7)
! write(77,261,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.8)
! write(77,262,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.9)
! write(77,263,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.10)
! write(77,264,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.11)
! write(77,265,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.12)
! write(77,266,err=902) (Text3,NumNP-Node(j)+1,j=1,NObsA)
if(NS.eq.1)
! write(77,210,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.2)
! write(77,220,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.3)
! write(77,230,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.4)
! write(77,240,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.5)
! write(77,250,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.6)
! write(77,270,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.7)
! write(77,271,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.8)
! write(77,272,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.9)
! write(77,273,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.10)
! write(77,274,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.11)
! write(77,275,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
if(NS.eq.12)
! write(77,276,err=902) (Text1,(Text2,j=1,NS),i=1,NObsA)
end if
end if
end if
return
* Error when reading from an input file
901 ierr=1
return
* Error when writing into an output file
902 ierr=2
return
110 format (/'Nodal point information'//
!'node x hOld MatN LayN Beta Ah AK ',
!' ATh Temp Conc(1...NS) Sorb(1...NS)'/)
120 format (i4,2f11.3,2i5,f8.3,3f9.3,f8.2,10e12.4,10e12.4)
130 format (/' Number of species in the chain : ',i3)
140 format (///16x,10(15x,a5,i3,')', 7x))
150 format (///16x,10(15x,a5,i3,')',18x))
160 format (///16x,10(15x,a5,i3,')',29x))
170 format (///16x,10(15x,a5,i3,')',40x))
180 format (///16x,10(15x,a5,i3,')',51x))
190 format (///16x,10(15x,a5,i3,')',62x))
260 format (///16x,10(15x,a5,i3,')',73x))
261 format (///14x,10(15x,a5,i3,')',84x))
262 format (///14x,10(15x,a5,i3,')',95x))
263 format (///14x,10(15x,a5,i3,')',106x))
264 format (///14x,10(15x,a5,i3,')',117x))
265 format (///14x,10(15x,a5,i3,')',128x))
266 format (///14x,10(15x,a5,i3,')',139x))
200 format (/' time ',10(a29, 2x))
210 format (/' time ',10(a29, a12,2x))
220 format (/' time ',10(a29,2a12,2x))
230 format (/' time ',10(a29,3a12,2x))
240 format (/' time ',10(a29,4a12,2x))
250 format (/' time ',10(a29,5a12,2x))
270 format (/' time ',10(a29,6a12,2x))
271 format (/' time ',10(a29,7a12,2x))
272 format (/' time ',10(a29,8a12,2x))
273 format (/' time ',10(a29,9a12,2x))
274 format (/' time ',10(a29,10a12,2x))
275 format (/' time ',10(a29,11a12,2x))
276 format (/' time ',10(a29,12a12,2x))
301 format (///16x,10(9x,a5,i3,')', 8x))
302 format (/' time ',10(a23,3x))
end
************************************************************************
subroutine InitW(NumNP,NMat,Matnum,Kappa,hNew,hOld,hTemp,ParD,
! ParW,iModel,hTop,hBot,iDualPor,ThNewIm,ierr)
dimension MatNum(NumNP),Kappa(NumNP),ParD(11,NMat),ParW(11,NMat),
! hNew(NumNP),hOld(NumNP),hTemp(NumNP),ThNewIm(NumNP)
do 11 i=1,NumNP
M=MatNum(i)
ThTotal=hNew(i)
if(iDualPor.gt.0) then
hNew(i)=hNew(i)*ParD(2,M)/(ParD(2,M)+ParD(8,M))
ThMobile=hNew(i)
ThNewIm(i)=ThTotal-ThMobile
end if
if(Kappa(i).eq.-1) then
Qe=min((hNew(i)-ParD(1,M))/(ParD(2,M)-ParD(1,M)),1.)
if(Qe.lt.0.) goto 901
hNew(i)=FH(iModel,Qe,ParD(1,M))
else
Qe=min((hNew(i)-ParW(1,M))/(ParW(2,M)-ParW(1,M)),1.)
if(Qe.lt.0.) goto 901
hNew(i)=FH(iModel,Qe,ParW(1,M))
end if
hOld(i)=hNew(i)
hTemp(i)=hNew(i)
11 continue
hBot=hNew(1)
hTop=hNew(NumNP)
return
901 ierr=1
return
end
************************************************************************
subroutine InitDualPor(NumNP,NMat,MatNum,Par,theta,iDualPor,
! ThNewIm,ThOldIm,SinkIm,hNew,STrans,lInitW)
logical lInitW
dimension MatNum(NumNP),Par(11,NMat),theta(NumNP),ThNewIm(NumNP),
! ThOldIm(NumNP),SinkIm(NumNP),hNew(NumNP),STrans(NumNP)
do 11 i=1,NumNP
M=MatNum(i)
if(iDualPor.eq.0) ThNewIm(i)=0.
if(.not.lInitW) then
if(iDualPor.eq.1) then
Se=(Theta(i)-Par(1,M))/(Par(2,M)-Par(1,M))
ThNewIm(i)=Par(7,M)+Se*(Par(8,M)-Par(7,M))
else if(iDualPor.eq.2) then
ThNewIm(i)=FQ(0,hNew(i),Par(7,M))
end if
end if
ThOldIm(i)=ThNewIm(i)
SinkIm(i)=0.
STrans(i)=0.
11 continue
return
end
************************************************************************
subroutine MatIn(NMat,ParD,ParW,hTab1,hTabN,lScreen,ierr,NumNP,Ah,
! iHyst,AhW,AThW,AKW,MatNum,hNew,Kappa,AThS,ThRR,
! ConR,AKS,KappaO,iModel,xConv,lTable,IKappa,
! nTabMod,iDualPor)
dimension ParD(11,NMat),ParW(11,NMat),Ah(NumNP),AhW(NMat),
! AKW(NMat),AThW(NMat),MatNum(NumNP),hNew(NumNP),
! Kappa(NumNP),AThS(NumNP),ThRR(NumNP),ConR(NumNP),
! AKS(NumNP),KappaO(NumNP),Ae(100)
logical lScreen,lTable
if(lScreen) write(*,*) 'reading material information'
read(30,*,err=901)
read(30,*,err=901) hTab1,hTabN
read(30,*,err=901)
read(30,*,err=901) iModel,iHyst
* iModel = 0: van Genuchten
* 1: modified van Genuchten (Vogel and Cislerova)
* 2: Brooks and Corey
* 3: van Genuchte with air entry value of 2 cm
* 4: log-normal (Kosugi)
* 5: dual-porosity function (Durner)
* 6: dual-porosity system with transfer proportional to water content
* 7: dual-porosity system with transfer proportional to pressure head
* 8: dual-permeability system, not handled by this program
* 9: nTabMod: general tables (nTabMod)
if(iModel.eq.8) then
write(*,*) 'Dual-permeability models are implemented in differen
!t code !!'
write(*,*) 'Press Enter to continue'
read(*,*)
stop
end if
if(iModel.lt.nTabMod) then
hTab1=-amin1(abs(hTab1),abs(hTabN))
hTabN=-amax1(abs(hTab1),abs(hTabN))
lTable=.true.
if((hTab1.gt.-0.00001.and.hTabN.gt.-0.00001).or.hTab1.eq.hTabN)
! then
lTable=.false.
hTab1=-0.0001*xConv
hTabN=-100. *xConv
end if
else
lTable=.true.
end if
if(iHyst.gt.0) then
read(30,*,err=901)
read(30,*,err=901) IKappa
else
IKappa=-1
endif
do 11 i=1,NumNP
Kappa(i)=IKappa
KappaO(i)=IKappa
11 continue
if(iModel.eq.2.or.iModel.eq.4.or.
! (iModel.eq.0.and.iHyst.eq.0)) then
write(50,110,err=902)
else if(iModel.eq.1.or.iModel.eq.3) then
write(50,111,err=902)
else if(iModel.eq.0.and.iHyst.gt.0) then
write(50,112,err=902)
else if (iModel.eq.5) then
write(50,113,err=902)
else if (iModel.eq.6) then
write(50,115,err=902)
else if (iModel.eq.7) then
write(50,116,err=902)
else if (iModel.eq.nTabMod) then
write(50,114,err=902)
end if
read(30,*,err=901)
rHEntry=0.02*xConv
if(iModel.eq.0.or.iModel.eq.2.or.iModel.eq.3.or.iModel.eq.4) then
NPar=6
else if(iModel.eq.1) then
NPar=10
else if(iModel.eq.5) then
NPar=9
else if(iModel.eq.6) then
NPar=9
iModel=0
iDualPor=1
else if(iModel.eq.7) then
NPar=11
iModel=0
iDualPor=2
else if(iModel.eq.nTabMod) then
NPar=3
else
NPar=6
end if
do 12 M=1,NMat
if(iHyst.eq.0) then
read(30,*,err=901) (ParD(i,M),i=1,NPar)
if(iModel.eq.1) then
ParD(7,M)=amax1(ParD(7,M),ParD(2,M))
ParD(8,M)=amin1(ParD(8,M),ParD(1,M))
ParD(9,M)=amin1(ParD(9,M),ParD(2,M))
ParD(10,M)=amin1(ParD(10,M),ParD(5,M))
else if(iModel.eq.3) then
ParD(7,M)=ParD(1,M)+(ParD(2,M)-ParD(1,M))*
! (1.+(ParD(3,M)*rHEntry)**ParD(4,M))**(1.-1./ParD(4,M))
end if
if(iModel.eq.nTabMod) then
write(50,121,err=902) M,(ParD(i,M),i=1,NPar)
else
write(50,120,err=902) M,(ParD(i,M),i=1,NPar)
end if
else ! Hysteresis
read(30,*,err=901) (ParD(i,M),i=1,7),ParW(2,M),ParW(3,M),
! ParW(5,M)
ParD(7,M)=amax1(ParD(7,M),ParD(2,M))
write(50,120,err=902) M,(ParD(i,M),i=1,7),ParW(2,M),
! ParW(3,M),ParW(5,M)
ParW(1,M)=ParD(1,M)
ParW(4,M)=ParD(4,M)
AhW(M)=ParD(3,M)/ParW(3,M)
AThW(M)=(ParW(2,M)-ParW(1,M))/(ParD(2,M)-ParD(1,M))
AKW(M)=1.0
if(iHyst.eq.2) AKW(M)=ParW(5,M)/ParD(5,M)
ParW(7,M)=ParW(1,M)+AThW(M)*(ParD(7,M)-ParD(1,M))
ParD(8,M)=ParD(1,M)
ParD(9,M)=ParD(2,M)
ParD(10,M)=ParD(5,M)
ParW(8,M)=ParW(1,M)
ParW(9,M)=ParW(2,M)
ParW(10,M)=ParW(5,M)
ParW(6,M)=ParD(6,M)
end if
12 continue
* Hysteresis Update for Initial Pressure Head Distributions
do 13 i=1,NumNP
M=MatNum(i)
if(iModel.lt.nTabMod)
! hNew(i)=amax1(hNew(i),Ah(i)*FH(iModel,0.00000001,ParD(1,M)))
AThS(i)=1.
AKS(i)=1.
ThRR(i)=ParD(1,M)
ConR(i)=0.
13 continue
return
* Calculate the air-water interfacial area
iTab=101
Ae(1)=0.
g=9.81*xConv ! Gravitational acceleration from [m/s2] to [L/s2]
Temp=20.
Sigma=75.6-0.1425*Temp-2.38e-4*Temp**2 ! Surface tension [g/s2]
row=1.-7.37e-6*(Temp-4.)**2+3.79e-8*(Temp-4.)**3 ! Density of soil water [g/cm3]
row=row*1.e+06/xConv/xConv/xConv ! to [g/L3]
M=1
write(50,117)
do 14 i=2,iTab
call qromb(1.,1.-(i-1)*0.01,sInt,iModel,ParD)
Ae(i)=sInt*ParD(2,M)*row*g/sigma
write(50,122) 1.-(i-1)*0.01,Ae(i)
14 continue
* Error when reading from an input file
901 ierr=1
return
* Error when writing into an output file
902 ierr=2
return
110 format(//'MatNum, Param. array:'//' Mat Qr Qs ',
!'Alfa n Ks l'/)
111 format(//'MatNum, Param. array:'//' Mat Qr Qs ',
!'Alfa n Ks l Qm Qa Qk Kk
!'/)
112 format(//'MatNum, Param. array:'//' Mat Qr Qs ',
!'Alfa n Ks l Qm QsW AlfaW Ks
!W'/)
113 format(//'MatNum, Param. array:'//' Mat Qr Qs ',
!'Alfa n Ks l W2 Alfa2 n2'
!/)
114 format(//'MatNum, Param. array:'//' Mat Qr Qs Ks'
!/)
115 format(//'MatNum, Param. array:'//' Mat Qr Qs ',
!'Alfa n Ks l QrIm QsIm Omega'/)
116 format(//'MatNum, Param. array:'//' Mat Qr Qs ',
!'Alfa n Ks l QrIm QsIm Alfa2
! n2 Omega'/)
117 format(//' Saturation Air-Water Interfacial Area'/)
120 format(i5,2x,2f7.3,3e12.3,4f7.3,2e12.3)
121 format(i5,2x,2f7.3,3e12.3,2f7.3,3e12.3)
122 format(2f10.5)
end
************************************************************************
subroutine HysterIn(NumNP,NMat,hOld,MatNum,ParD,ParW,ThNew,ThOld,
! Kappa,AThS,ThRR,ConO,ConR,AKS,KappaO,Ah,AK,
! iHyst,iModel,cDataPath)
character cFileName*260,cDataPath*260
dimension MatNum(NumNP),ThOld(NumNP),hOld(NumNP),ParD(11,NMat),
! ThNew(NumNP),Kappa(NumNP),AThS(NumNP),ThRR(NUmNP),
! ConO(NumNP),ConR(NumNP),AKS(NumNP),KappaO(NumNP),
! Ah(NumNP),AK(NumNP),ParW(11,NMat)
iLengthPath = Len_Trim(cDataPath)
cFileName = cDataPath(1:iLengthPath)//'\Hysteresis.in'
open(35,file=cFileName,status='old',err=901)
read(35,*,err=901) ! Input file "Hyster.in"
read(35,*,err=901) ! n,Theta,Kappa
do 11 i=1,NumNP
read(35,*,err=901) n,ThOld(i),KappaO(i)
ThNew(i)=ThOld(i)
Kappa(i)=KappaO(i)
11 continue
call Hyster(NumNP,NMat,hOld,MatNum,ParD,ParW,ThNew,ThOld,
! Kappa,AThS,ThRR,ConO,ConR,AKS,KappaO,Ah,AK,
! iHyst,iModel,-1.)
901 continue
return
end
************************************************************************
subroutine GenMat(NTab,NTabD,NMat,thr,ths,hSat,Par,hTab,ConTab,
! CapTab,ConSat,TheTab,iModel,lScreen,nTabMod,
! ConSMax,xConv,tConv,ierr)
dimension hTab(NTabD,NMat),ConTab(NTabD,NMat),CapTab(NTabD,NMat),
! Par(11,NMat),ConSat(NMat),thr(NMat),hSat(NMat),
! ths(NMat),TheTab(NTabD,NMat),NTab(NMat)
logical lScreen
if(lScreen) write(*,*) 'generating materials'
if(iModel.lt.nTabMod) then
write(50,110,err=901)
write(50,120,err=901)
hTab1=hTab(1,1)
hTabN=hTab(NTab(1),1)
dlh=(alog10(-hTabN)-alog10(-hTab1))/(NTab(1)-1)
do 11 i=1,NTab(1)
alh=alog10(-hTab1)+(i-1)*dlh
hTab(i,1)=-10**alh
11 continue
else
read(36,*,err=901)
read(36,*,err=901) iCap !(=1; input capacity; =0: do not input capacity)
write(50,111,err=901)
write(50,120,err=901)
end if
ConSMax=0.
c ConSMax=1e+30
do 13 M=1,NMat
if(iModel.lt.nTabMod) then
hSat(M) =FH(iModel,1.0,Par(1,M))
ConSat(M)=Par(5,M)
if(ConSat(M).gt.ConSMax) ConSMax=ConSat(M)
c if(ConSat(M).lt.ConSMax) ConSMax=ConSat(M)
thr(M) =Par(1,M)
ths(M) =Par(2,M)
write(50,*,err=901)
do 12 i=1,NTab(1)
ConTab(i,M)=FK(iModel,hTab(i,1),Par(1,M))
CapTab(i,M)=FC(iModel,hTab(i,1),Par(1,M))
TheTab(i,M)=FQ(iModel,hTab(i,1),Par(1,M))
Qe =FS(iModel,hTab(i,1),Par(1,M))
ConV=ConVh(hTab(i,1),TheTab(i,M),ths(M),xConv,tConv)
a10h=alog10(max(-hTab(i,1),1e-30))
a10K=alog10(ConTab(i,M))
write(50,130,err=901) TheTab(i,M),hTab(i,1),a10h,
! CapTab(i,M),ConTab(i,M),a10K,Qe,ConV
12 continue
else if(iModel.eq.nTabMod) then ! Table
read(36,*)
read(36,*) NTab(M)
read(36,*)
hSat(M) =0.0
ConSat(M)=Par(3,M)
thr(M) =Par(1,M)
ths(M) =Par(2,M)
do 15 i=1,NTab(M)
if(iCap.eq.1) then
read(36,*) TheTab(i,M),hTab(i,M),ConTab(i,M),CapTab(i,M)
else
read(36,*) TheTab(i,M),hTab(i,M),ConTab(i,M)
end if
15 continue
write(50,*,err=901)
do 16 i=1,NTab(M)
if(iCap.eq.0) then
if(i.eq.1) then
CapTab(i,M)=(TheTab(2,M)-TheTab(1,M))/
! ( hTab(2,M)- hTab(1,M))
else if(i.eq.NTab(M)) then
CapTab(i,M)=(TheTab(NTab(M),M)-TheTab(NTab(M)-1,M))/
! ( hTab(NTab(M),M)- hTab(NTab(M)-1,M))
else
CapTab(i,M)=(TheTab(i+1,M)-TheTab(i-1,M))/
! ( hTab(i+1,M)- hTab(i-1,M))
end if
end if
Qe =(TheTab(i,M)-Par(1,M))/(Par(2,M)-Par(1,M))
a10h=alog10(max(-hTab(i,M),1e-30))
a10K=alog10(ConTab(i,M))
write(50,130,err=901) TheTab(i,M),hTab(i,M),a10h,
! CapTab(i,M),ConTab(i,M),a10K,Qe
16 continue
end if
write(50,140,err=901)
13 continue
return
* Error when writing into an output file
901 ierr=1
return
110 format(/7x,'Table of Hydraulic Properties which are interpolated i
!n simulation'/7x,65('=')/)
111 format(/7x,'Hydraulic Properties which are interpolated from input
! tables in simulation'/7x,75('=')/)
120 format(' theta h log h C K',
!' log K S Kv')
130 format(f8.4,e12.3,e12.4,e12.4,e12.4,e12.4,f10.4,e12.4)
140 format('end')
end
************************************************************************
subroutine TmIn(tInit,tMax,tAtm,tOld,dt,dtMax,dMul,dMul2,dtMin,
! TPrint,t,dtOpt,TopInF,BotInF,lScreen,ItMin,
! ItMax,MaxAL,hCritS,NPD,AtmBC,iVer,lPrintD,nPrStep,
! tPrintInt,lEnter,lDayVar,lSinPrec,lLAI,rExtinct,
! ierr)
logical TopInF,BotInF,AtmBC,lPrintD,lEnter,lScreen,lDayVar,lLAI,
! lSinPrec
double precision t,tInit,tOld,tMax,tAtm,TPrint,tPrintInt
dimension TPrint(NPD)
if(lScreen) write(*,*) 'reading time information'
read(30,*,err=901)
read(30,*,err=901)
read(30,*,err=901) dt,dtMin,dtMax,dMul,dMul2,ItMin,ItMax,MPL
if(MPL.gt.NPD) then
ierr=2
return
end if
read(30,*,err=901)
read(30,*,err=901) tInit,tMax
if(iVer.gt.2) then
read(30,*,err=901)
read(30,*,err=901) lPrintD,nPrStep,tPrintInt,lEnter
end if
read(30,*,err=901)
read(30,*,err=901) (TPrint(i),i=1,MPL)
dtOpt=dt
if(TopInF.or.BotInF.or.AtmBC) then
iVerA = iGetFileVersion(31,1)
read(31,*,err=901)
read(31,*,err=901)
read(31,*,err=901) MaxAL
if(iVerA.eq.4) then
read(31,*,err=901)
read(31,*,err=901) lDayVar,lSinPrec,lLAI
if(lLAI) then
read(31,*,err=901)
read(31,*,err=901) rExtinct
end if
end if
read(31,*,err=901)
read(31,*,err=901) hCritS
read(31,*,err=901)
else
tAtm=tMax
end if
TPrint(MPL+1)=tMax
tOld=tInit
t=tInit+dt
return
* Error when reading from an input file
901 ierr=1
return
end
************************************************************************
subroutine MeteoIn(Latitude,Altitude,ShortWaveRadA,ShortWaveRadB,
! LongWaveRadA,LongWaveRadB,LongWaveRadA1,
! LongWaveRadB1,WindHeight,TempHeight,iCrop,iLAI,
! CropHeight,Albedo,LAI,xRoot,iInterc,aInterc,
! iGrowth,rGrowth,rExtinct,iRadiation,lEnBal,
! lPrint,iSunSh,iRelHum,CloudF_Ac,CloudF_Bc,
! lHargr,lMetDaily,xConv,ierr)
implicit real(A-H,L-Z)
logical lEnBal,lPrint,lHargr,lMetDaily
dimension rGrowth(1000,5)
* Latitude ! Latitude of the location, [degree, N=+, S=-]
* Altitude ! Altitude of the location above mean see level [m]
* ShortWaveRadA=0.25 ! fraction of extraterrestrial readiation on
* ! overcast days, first Angstrom coefficient, a_s, eq.55
* ShortWaveRadB=0.50 ! Input, fraction of extraterrestrial readiation on
* ! overcast days, second Angstrom coefficient, b_s, eq.55
* LAI ! Leaf area index [-]
* LongWaveRadA=0.90 ! cloudiness factor, a_c, eq. 59
* LongWaveRadB=0.10 ! cloudiness factor, b_c, eq. 59
* LongWaveRadA1=0.34 ! emissivity correlation coefficient, a_l, eq. 60
* LongWaveRadB1=-0.139 ! emissivity correlation coefficient, b_l, eq. 60
* WindHeight=200. ! Measurement hight of wind, [cm]
* TempHeight=190. ! Measurement hight of temperature, [cm]
iVerM = iGetFileVersion(33,1)
read(33,*,err=901)
read(33,*,err=901)
read(33,*,err=901) MaxALMet,iRadiation,lHargr
if(iVerM.ge.4) then
read(33,*,err=901)
read(33,*,err=901) lEnBal,lMetDaily
end if
Altitude=0.
if(iRadiation.ne.2) then
read(33,*,err=901)
read(33,*,err=901) Latitude,Altitude
read(33,*,err=901)
read(33,*,err=901) ShortWaveRadA,ShortWaveRadB
read(33,*,err=901)
read(33,*,err=901) LongWaveRadA,LongWaveRadB
read(33,*,err=901)
read(33,*,err=901) LongWaveRadA1,LongWaveRadB1
end if
read(33,*,err=901)
read(33,*,err=901) WindHeight,TempHeight
read(33,*,err=901)
read(33,*,err=901) iCrop,iSunSh,iRelHum
if(iRadiation.eq.1.and.iSunSh.eq.3) then
read(33,*,err=901)
read(33,*,err=901) CloudF_Ac,CloudF_Bc
end if
if(iCrop.ge.1) then
read(33,*,err=901)
read(33,*,err=901) iLAI,rExtinct
read(33,*,err=901)
read(33,*,err=901) iInterc
if(iCrop.eq.1) then
read(33,*,err=901)
read(33,*,err=901) CropHeight,Albedo,LAI,xRoot
CropHeight=CropHeight*100./xConv ! conversion to cm
else if (iCrop.eq.2) then
read(33,*,err=901)
read(33,*,err=901) iGrowth
if(iGrowth.gt.1000) then
write(*,*) 'Number of crop growth data is larger than 1000'
write(*,*) 'Press Enter to continue'
read(*,*)
stop
end if
read(33,*,err=901)
do 11 i=1,iGrowth
read(33,*,err=901) (rGrowth(i,j),j=1,5)
rGrowth(i,2)=rGrowth(i,2)*100./xConv ! conversion to cm
11 continue