-
Notifications
You must be signed in to change notification settings - Fork 1
/
IPSOIL_Inp.FOR
608 lines (544 loc) · 23.3 KB
/
IPSOIL_Inp.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
C=======================================================================
C IPSOIL_Inp, Subroutine
C
C Soil selection
C-----------------------------------------------------------------------
C Revision history
C
C 06/21/1991 JWJ
C 05/28/1993 PWW Header revision and minor changes
C 12/01/1993 WTB Modified for soil P
C 12/12/2000 GH Modified format
C 07/01/2003 GH Add error checking codes for surface values
! 04/07/2005 CHP Added EXCA, exchangable calcium (cmol/kg)
! 06/13/2005 CHP Free format read for soils parameters. Format is
! defined by location of headers.
! 08/23/2005 CHP Fixed some error checking for soil water parameters.
! 05/18/2006 CHP Modifications for input subroutine module
C-----------------------------------------------------------------------
C INPUT : RNMODE,FILES,PATHSL,ISWWAT
C
C LOCAL :
C
C OUTPUT : NSENS
C-----------------------------------------------------------------------
C Called : SESOIL INPUT
C
C Calls : FIND IGNORE ERROR
C-----------------------------------------------------------------------
C DEFINITIONS
C
C HDLAY :
C=======================================================================
SUBROUTINE IPSOIL_Inp (RNMODE,FILES,PATHSL,NSENS,ISWITCH)
USE ModuleDefs
IMPLICIT NONE
INCLUDE 'COMSOI.BLK'
CHARACTER*1 LINE(80),RNMODE,BLANK,ANS,UPCASE
CHARACTER*5 MH(NL)
CHARACTER*6 ERRKEY
CHARACTER*12 FILES
CHARACTER*78 MSG(25)
CHARACTER*80 PATHSL
CHARACTER*92 FILESS
CHARACTER*255 C255
INTEGER I,J,P1,NLAYRI,LINSOL,ISECT
INTEGER NSENS,NLSOIL,NLOOP,ERR,LUNSL,PATHL, LINSOL_1
! 05/27/2004 CHP Added these variables to COMSOI.BLK
! REAL PTERMA(NL),PTERMB(NL),EXK(NL),EXMG(NL),EXNA(NL),EXTS(NL)
! REAL SLEC(NL),ZLYR(NL),ZZLYR(NL)
REAL ZLYR(NL)
REAL FLAG,SL,SLDP
! Up to MAXCOL headers per line, up to 10 characters long each
INTEGER, PARAMETER :: MAXCOL = 50
CHARACTER*15 HEADER(MAXCOL)
! COL keeps beginning and ending column for each header
INTEGER COL(MAXCOL,2), C1, C2, COUNT, L
TYPE (SwitchType) ISWITCH
PARAMETER (ERRKEY = 'IPSOIL')
PARAMETER (LUNSL = 12)
PARAMETER (BLANK = ' ')
NLSOIL = 0
!-----------------------------------------------------------------------
! No soil file read - default conditions
IF (SLNO(1:3) .EQ. ' ' .OR. SLNO(1:3) .EQ. '-99' .OR.
& SLNO(8:10) .EQ. '-99' .OR. SLNO(8:10) .EQ. ' ') THEN
SLPF = 1.0
NLAYR = 1
! Read soil file
ELSE
LINSOL = 0
PATHL = INDEX(PATHSL,BLANK)
IF (PATHL .LE. 1) THEN
FILESS = FILES
ELSE
FILESS = PATHSL(1:(PATHL-1)) // FILES
ENDIF
OPEN (LUNSL, FILE = FILESS,STATUS = 'OLD',IOSTAT=ERR)
IF (ERR .NE. 0) THEN
CALL ERROR(ERRKEY,ERR,FILES,0)
END IF
!-----------------------------------------------------------------------
! Sensitivity Analysis - soil selection
IF (NSENS .EQ. 1 ) THEN
NLOOP = 0
NLSOIL = 0
DO I = 1, 80
LINE(I) = ' '
END DO
I = 1
IF (INDEX('IE',RNMODE) .GT. 0) THEN
CALL CLEAR
WRITE (*, 5130)
ENDIF
10 CONTINUE
CALL IGNORE(LUNSL, LINSOL, ISECT, C255)
IF ( ISECT .EQ. 0 ) GO TO 111
IF (C255(1:1) .NE. '*') GO TO 10
IF (C255(2:5) .EQ. 'SOIL') GO TO 10
READ (C255,5030,IOSTAT=ERR) PEDON,SLSOUR,SLTXS,
& SLDP,SLDESC
IF (ERR .NE. 0) THEN
CALL ERROR (ERRKEY,ERR,FILES,LINSOL)
ENDIF
DO P1 = 1, 10
PEDON(P1:P1) = UPCASE(PEDON(P1:P1))
SLNO(P1:P1) = UPCASE(SLNO(P1:P1))
END DO
IF (INDEX('IE',RNMODE) .GT. 0) WRITE(*, 5140) I,SLDESC,PEDON
IF (PEDON .EQ. SLNO) NLSOIL = I
C
C Write out pause statement every 15 lines
C
IF ((MOD(I,15) .EQ. 0).AND.(INDEX('IE',RNMODE) .GT. 0)) THEN
WRITE (*,5000)
READ (5,'(A1)') ANS
END IF
I = I + 1
GOTO 10
111 CONTINUE
NLOOP = NLOOP + 1
IF (NLOOP .GT. 25) THEN
CALL ERROR (ERRKEY,1,FILES,LINSOL)
ENDIF
LINE(1) = ' '
IF ((INDEX('IE',RNMODE) .GT. 0) .AND. NLSOIL .EQ. 0) THEN
WRITE (*,950) SLNO, FILESS
ENDIF
IF (INDEX('IE',RNMODE) .GT. 0) WRITE(*, 5160) NLSOIL
READ (5,'(80A1)') LINE
CALL VERIFY (LINE,SL,FLAG)
IF (SL .LE. 0) THEN
SL = NLSOIL
ELSEIF ((FLAG .GT. 0) .OR. (SL .GT. (I-1))) THEN
WRITE (*,5101) (I-1)
GO TO 111
ELSEIF (SL .NE. NINT(SL)) THEN
WRITE (*,5102)
GO TO 111
ELSEIF (SL .GT. 0.) THEN
NLSOIL = NINT(SL)
ELSE
CALL ERROR(ERRKEY,3,FILES,LINSOL)
ENDIF
REWIND (LUNSL)
ENDIF !End of sensitivity selection
!-----------------------------------------------------------------------
! Set default values for soil parameters
SLTXS = '-99 '
SLSOUR = '-99 '
SLDESC = '-99 '
TAXON = '-99 '
SSITE = '-99 '
SCOUNT = '-99 '
SCOM = '-99 '
SMHB = '-99 '
SMPX = '-99 '
SMKE = '-99 '
SGRP = '-99 '
SLAT = -99.
SLONG = -99.
SLDP = -99.
SALB = -99.
SLNF = -99.
SLPF = -99.
CLAY = -99.
SILT = -99.
STONES = -99.
OC = -99.
PH = -99.
BD = -99.
LL = -99.
DUL = -99.
SAT = -99.
SWCN = -99.
PHKCL = -99.
CEC = -99.
U = -99.
SWCON = -99.
CN2 = -99.
SHF = -99.
TOTN = -99.
ADCOEF = 0.
! 2ND TIER
EXTP = -99.
TOTP = -99.
ORGP = -99.
CACO = -99.
EXTAL = -99.
EXTFE = -99.
EXTMN = -99.
TOTBAS = -99.
PTERMA = -99.
PTERMB = -99.
EXK = -99.
EXMG = -99.
EXNA = -99.
EXTS = -99.
SLEC = -99.
EXCA = -99.
! Stable organic C read from soil analysis section only
! Output with 2nd tier soil data to INP file.
SASC = -99.
!-----------------------------------------------------------------------
! Find correct soil within soil file
I = 0
5024 CONTINUE
I = I + 1
5025 CONTINUE
CALL IGNORE (LUNSL,LINSOL,ISECT,C255)
IF ( ISECT .EQ. 0 ) THEN !end of file
CLOSE(LUNSL)
IF (FILES(1:4) .EQ. 'SOIL') THEN
FILES(1:8) = SLNO(1:2)//'.SOL '
PATHL = INDEX(PATHSL,BLANK)
IF (PATHL .LE. 1) THEN
FILESS = FILES
ELSE
FILESS = PATHSL(1:(PATHL-1)) // FILES
ENDIF
OPEN (LUNSL, FILE = FILESS,STATUS = 'OLD',IOSTAT=ERR)
IF (ERR .NE. 0) THEN
CALL ERROR(ERRKEY,ERR,FILES,0)
ENDIF
LINSOL = 0
GO TO 5025
ENDIF
! IF (ISWITCH%ISWWAT .EQ. 'N') THEN
! SLPF = 1.0
! NLAYR = 1
! RETURN
! ELSE
MSG(1) = "Soil profile missing from file."
WRITE(MSG(2),'("Soil ID: ",A)') SLNO
WRITE(MSG(3),'("File: ",A)') FILESS(1:72)
CALL WARNING(3,ERRKEY,MSG)
CALL ERROR (ERRKEY,4,FILES,LINSOL)
! ENDIF
ENDIF
IF (C255(1:1) .NE. '*') GO TO 5025
IF (C255(2:5) .EQ. 'SOIL') GO TO 5025
READ (C255,5030,IOSTAT=ERR) PEDON,SLSOUR,SLTXS,SLDP,SLDESC
IF (ERR .NE. 0) CALL ERROR (ERRKEY,ERR,FILES,LINSOL)
DO P1 = 1, 10
PEDON(P1:P1) = UPCASE(PEDON(P1:P1))
SLNO(P1:P1) = UPCASE(SLNO(P1:P1))
END DO
IF (PEDON .NE. SLNO .AND. NSENS .EQ. 0) GO TO 5024
IF (I .LT. NLSOIL .AND. NSENS .EQ. 1) GO TO 5024
!-----------------------------------------------------------------------
! Found correct soil
!-----------------------------------------------------------------------
! Read general information in fixed format
CALL IGNORE2 (LUNSL, LINSOL, ISECT, C255)
IF (ISECT .EQ. 3) THEN
CALL IGNORE (LUNSL,LINSOL,ISECT,C255)
IF (ISECT .NE. 1) CALL ERROR (ERRKEY,4,FILES,LINSOL)
READ (C255,5035,IOSTAT=ERR) SSITE,SCOUNT,SLAT,SLONG,TAXON
IF (ERR .NE. 0) CALL ERROR (ERRKEY,ERR,FILES,LINSOL)
ENDIF
! Initialize
HEADER = '-99'
NLAYR = 0
! Loop thru soils file
C-KRT*******************************************************************
C-KRT g95 compiler does not have an intrinsic EOF function
C-KRT I believe the EOF check is redundant anyway - KRT (8/29/2008)
C-KRT GoodSoil: DO WHILE (.NOT. EOF(LUNSL))
GoodSoil: DO WHILE (.true.)
C-KRT*******************************************************************
CALL IGNORE2 (LUNSL, LINSOL, ISECT, C255)
SELECT CASE(ISECT)
! ----------------------------------------------
CASE(0,2) !End of file, End of Section
IF (NLAYRI == 0) THEN
IF (ISECT == 0) CALL ERROR(ERRKEY,4,FILES,LINSOL)
IF (ISECT == 2) CALL ERROR(ERRKEY,3,FILES,LINSOL)
ENDIF
EXIT GoodSoil
! ----------------------------------------------
CASE(3) !Header line found ('@' in column 1)
CALL PARSE_HEADERS(C255, MAXCOL, HEADER, COUNT, COL)
IF (COUNT .LT. 1) CALL ERROR (ERRKEY,10,FILES,LINSOL)
L = 0
! ----------------------------------------------
CASE(1) !Data line found
IF (INDEX(HEADER(1),'-99') > 0) THEN
CALL ERROR(ERRKEY,3,FILES,LINSOL)
ENDIF
! Read columns of data
IF (TRIM(HEADER(1)) .NE. 'SLB') THEN
DO I = 1, COUNT
C1 = COL(I,1)
C2 = COL(I,2)
SELECT CASE (TRIM(HEADER(I)))
CASE('SCOM'); READ(C255(C1:C2),*,IOSTAT=ERR) SCOM
CASE('SALB'); READ(C255(C1:C2),*,IOSTAT=ERR) SALB
CASE('SLU1'); READ(C255(C1:C2),*,IOSTAT=ERR) U
CASE('SLDR'); READ(C255(C1:C2),*,IOSTAT=ERR) SWCON
CASE('SLRO'); READ(C255(C1:C2),*,IOSTAT=ERR) CN2
CASE('SLNF'); READ(C255(C1:C2),*,IOSTAT=ERR) SLNF
CASE('SLPF'); READ(C255(C1:C2),*,IOSTAT=ERR) SLPF
CASE('SMHB'); READ(C255(C1:C2),*,IOSTAT=ERR) SMHB
CASE('SMPX'); READ(C255(C1:C2),*,IOSTAT=ERR) SMPX
CASE('SMKE'); READ(C255(C1:C2),*,IOSTAT=ERR) SMKE
CASE('SGRP'); READ(C255(C1:C2),*,IOSTAT=ERR) SGRP
! CASE('SOILLAT'); READ(C255(C1:C2),*,IOSTAT=ERR) SLAT
! CASE('SOILLONG');READ(C255(C1:C2),*,IOSTAT=ERR) SLONG
! CASE('SLTX'); READ(C255(C1:C2),*,IOSTAT=ERR) SLTXS
! CASE('SLDP'); READ(C255(C1:C2),*,IOSTAT=ERR) SLDP
! CASE('SOIL_SCS')
! READ(C255(C1:C2),'(A50)',IOSTAT=ERR) TAXON
! TAXON = ADJUSTL(TAXON)
!
! CASE('SLDN'); READ(C255(C1:C2),*,IOSTAT=ERR) SLDN
! CASE('ETDR'); READ(C255(C1:C2),*,IOSTAT=ERR) ETDR
END SELECT
IF (ERR .NE. 0) CALL ERROR(ERRKEY,ERR,FILES,LINSOL)
ENDDO
ELSE
!Soil layer data
L = L + 1
! LyrLoop: DO L = 1, NL + 1
IF (L .GT. NL) CALL ERROR (ERRKEY,2,FILES,LINSOL)
IF (L == 1) LINSOL_1 = LINSOL
! CALL IGNORE (LUNSL,LINSOL,ISECT,C255)
! IF (C255(1:1) .EQ. '*' .OR. ISECT .NE. 1) EXIT GoodSoil
!First header of layer data must be layer depth
C1 = COL(1,1)
C2 = COL(1,2)
READ(C255(C1:C2),*,IOSTAT=ERR) ZLYR(L)
IF (ERR .NE. 0) CALL ERROR(ERRKEY,ERR,FILES,LINSOL)
!Read subsequent columns of data
ColLoop: DO I = 2, COUNT
C1 = COL(I,1)
C2 = COL(I,2)
SELECT CASE (TRIM(HEADER(I)))
CASE('SLMH'); READ(C255(C1:C2),*,IOSTAT=ERR) MH(L)
CASE('SLLL'); READ(C255(C1:C2),*,IOSTAT=ERR) LL(L)
CASE('SDUL'); READ(C255(C1:C2),*,IOSTAT=ERR) DUL(L)
CASE('SSAT'); READ(C255(C1:C2),*,IOSTAT=ERR) SAT(L)
CASE('SRGF'); READ(C255(C1:C2),*,IOSTAT=ERR) SHF(L)
CASE('SSKS'); READ(C255(C1:C2),*,IOSTAT=ERR) SWCN(L)
CASE('SBDM'); READ(C255(C1:C2),*,IOSTAT=ERR) BD(L)
CASE('SLOC'); READ(C255(C1:C2),*,IOSTAT=ERR) OC(L)
CASE('SLCL'); READ(C255(C1:C2),*,IOSTAT=ERR) CLAY(L)
CASE('SLSI'); READ(C255(C1:C2),*,IOSTAT=ERR) SILT(L)
CASE('SLCF'); READ(C255(C1:C2),*,IOSTAT=ERR)STONES(L)
CASE('SLNI'); READ(C255(C1:C2),*,IOSTAT=ERR) TOTN(L)
CASE('SLHW'); READ(C255(C1:C2),*,IOSTAT=ERR) PH(L)
CASE('SLHB'); READ(C255(C1:C2),*,IOSTAT=ERR) PHKCL(L)
CASE('SCEC'); READ(C255(C1:C2),*,IOSTAT=ERR) CEC(L)
CASE('SADC')
READ(C255(C1:C2),*,IOSTAT=ERR) ADCOEF(L)
IF (ERR .NE. 0) THEN
ADCOEF = -99.; ERR = 0
ENDIF
! 04/20/2005 CHP added 2nd tier data
CASE('SLPX'); READ(C255(C1:C2),*,IOSTAT=ERR) EXTP(L)
CASE('SLPT'); READ(C255(C1:C2),*,IOSTAT=ERR) TOTP(L)
CASE('SLPO'); READ(C255(C1:C2),*,IOSTAT=ERR) ORGP(L)
CASE('CACO3');READ(C255(C1:C2),*,IOSTAT=ERR) CACO(L)
CASE('SLAL'); READ(C255(C1:C2),*,IOSTAT=ERR) EXTAL(L)
CASE('SLFE'); READ(C255(C1:C2),*,IOSTAT=ERR) EXTFE(L)
CASE('SLMN'); READ(C255(C1:C2),*,IOSTAT=ERR) EXTMN(L)
CASE('SLBS'); READ(C255(C1:C2),*,IOSTAT=ERR)TOTBAS(L)
CASE('SLPA'); READ(C255(C1:C2),*,IOSTAT=ERR)PTERMA(L)
CASE('SLPB'); READ(C255(C1:C2),*,IOSTAT=ERR)PTERMB(L)
CASE('SLKE'); READ(C255(C1:C2),*,IOSTAT=ERR) EXK(L)
CASE('SLMG'); READ(C255(C1:C2),*,IOSTAT=ERR) EXMG(L)
CASE('SLNA'); READ(C255(C1:C2),*,IOSTAT=ERR) EXNA(L)
CASE('SLSU'); READ(C255(C1:C2),*,IOSTAT=ERR) EXTS(L)
CASE('SLEC'); READ(C255(C1:C2),*,IOSTAT=ERR) SLEC(L)
CASE('SLCA'); READ(C255(C1:C2),*,IOSTAT=ERR) EXCA(L)
END SELECT
!IF (ERR .NE. 0) THEN
! CALL ERROR(ERRKEY,ERR,FILES,LINSOL)
!ENDIF
ENDDO ColLoop
! !Check for validity of layer data
! IF (SAT(L) .LT. DUL(L)) CALL ERROR(ERRKEY,7,FILES,LINSOL)
! IF (DUL(L) .LT. LL(L)) CALL ERROR(ERRKEY,8,FILES,LINSOL)
! IF (SAT(L) - DUL(L) .LT. 0.01) SAT(L) = DUL(L) + 0.01
! IF (DUL(L) - LL(L) .LT. 0.01) LL(L) = DUL(L) - 0.01
! ENDDO LyrLoop
NLAYRI = L
! CHP 05/21/2004
! Fix for deep layer soils -- set bottom of 20th layer to
! depth of profile
IF (NLAYRI == NL) THEN
DS(NL) = MAX(DS(NL), ZLYR(NLAYRI))
ENDIF
ENDIF !Soil layer data
END SELECT !ISECT
ENDDO GoodSoil
SLNO = PEDON
CLOSE (LUNSL)
! Check validity of soil values
IF (SWCON .LT. 0.0) CALL ERROR (ERRKEY,10,FILES,LINSOL)
IF (CN2 .LE. 0.0) CALL ERROR (ERRKEY,11,FILES,LINSOL)
IF (SALB .LE. 0.0) THEN
! SALB = 0.13
! MSG(1) = "Soil albedo not specified. " //
! & "Default value of 0.13 will be used."
! CALL WARNING(1,ERRKEY,MSG)
CALL ERROR (ERRKEY,12,FILES,LINSOL)
ENDIF
IF (ISWITCH%ISWNIT .NE. 'N') THEN
IF (SLNF > 1.0 .OR. SLNF < 0.0) THEN
SLNF = 1.0
MSG(1) = "Invalid value for SLNF in soil file."
MSG(2) = "Value changed to 1.0."
CALL WARNING(2,ERRKEY,MSG)
ENDIF
ENDIF
IF (ISWITCH%ISWWAT .NE. 'N') THEN
ERR = 0
DO J = 1, NLAYRI
IF ((DUL(J) - SAT(J)) .GT. 1.E-4) THEN
CALL ERROR (ERRKEY,7,FILES,LINSOL_1+J-1)
ENDIF
IF ((LL(J) - DUL(J)) .GT. 1.E-4) THEN
CALL ERROR (ERRKEY,8,FILES,LINSOL_1+J-1)
ENDIF
IF (DUL(J) .LT. 1.E-3) THEN
CALL ERROR (ERRKEY,13,FILES,LINSOL_1+J-1)
ENDIF
IF (ABS(SAT(J) - DUL(J)) .LT. 1.E-2) THEN
SAT(J) = DUL(J) + 0.01
ENDIF
IF (ABS(DUL(J) - LL(J)) .LT. 1.E-2) THEN
LL(J) = DUL(J) - 0.01
ENDIF
IF (SHF(J) .LT. -1.E-6) THEN
WRITE(MSG(1),'(A,A72)') 'File: ',FILESS
WRITE(MSG(2),'(A,I4,2X,A,I2)')
& 'Line number:',LINSOL_1+J-1, 'Soil layer: ',J
MSG(3) = 'Root growth factor is missing. '
MSG(4) = 'Model requires value between 0 and 1.'
MSG(5) = 'Program will stop.'
CALL WARNING(5,ERRKEY,MSG)
CALL ERROR(ERRKEY,14,FILES,LINSOL_1+J-1)
ENDIF
IF (SWCN(J) < 1.E-4) THEN
SWCN(J) = -99.
ERR = ERR + 1
ENDIF
ENDDO
IF (ERR > 0) THEN
MSG(1) = "Saturated hydraulic conductivity equal to " //
& "zero for one or more soil layers."
MSG(2) = "Data will be treated as missing."
CALL WARNING(2,ERRKEY,MSG)
ENDIF
ENDIF
SELECT CASE (ISWITCH % MESOL)
CASE('1'); CALL LYRSET (NLAYRI, ZLYR, NLAYR, DS, DLAYR, DEPMAX)
CASE('3'); CALL LYRSET3(NLAYRI, ZLYR, DS, NLAYR, DLAYR, DEPMAX)
CASE DEFAULT
CALL LYRSET2(NLAYRI, ZLYR, DS, NLAYR, DLAYR, DEPMAX)
END SELECT
! Check for top layer too thick (could happen for MESOL='3')
IF (DLAYR(1) > 5) THEN
MSG(1) = "Soil layer 1 thicker than 5 cm."
MSG(2) = "Soil water algorithms may become unstable."
CALL WARNING(2,ERRKEY,MSG)
ENDIF
! CHP 10/2/2009 No evidence of instabilities with thin layers - remove message
! DO L = 1, NLAYR
! IF (DLAYR(L) < 5.) THEN
! WRITE(MSG(1),
! & '("Soil layer",I3,": thickness =",F4.1," cm")') L, DLAYR(L)
! MSG(2)="Thin layers may result in instabilities."
! MSG(3)="See INFO.OUT for more detail on soil layers."
! CALL WARNING(3,ERRKEY,MSG)
! ENDIF
! ENDDO
!! Print soil layer data to INFO.OUT
! WRITE(MSG(1),'(A,A)') "Soil layer distribution method ",
! & ISWITCH%MESOL
! MSG(2) = " Thick-"
! MSG(3) = " Depth ness"
! MSG(4) = " L (cm) (cm)"
! DO L = 1, NLAYR
! WRITE(MSG(L+4),'(I4,2F7.0)') L, DS(L), DLAYR(L)
! ENDDO
! CALL INFO(NLAYR+4, "LYRSET", MSG)
!
! First tier soils data
CALL LMATCH (NLAYRI, ZLYR, LL, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, DUL, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, SAT, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, SHF, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, SWCN, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, BD, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, OC, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, CLAY, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, SILT, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, STONES,NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, TOTN, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, PH, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, PHKCL, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, CEC, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, ADCOEF,NLAYR, DS)
! Second tier soils data
CALL LMATCH (NLAYRI, ZLYR, EXTP, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, TOTP ,NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, ORGP, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, CACO, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, EXTAL, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, EXTFE, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, EXTMN, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, TOTBAS,NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, PTERMA,NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, PTERMB,NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, EXK, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, EXMG, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, EXNA, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, EXTS, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, SLEC, NLAYR, DS)
CALL LMATCH (NLAYRI, ZLYR, EXCA, NLAYR, DS)
ENDIF
RETURN
C-----------------------------------------------------------------------
C Format Strings
C-----------------------------------------------------------------------
! 950 FORMAT (/,5X,' SOIL ',A10,' is not in the SOIL file SOIL.SOL !')
950 FORMAT (/,5X,' SOIL ',A10,' is not in the SOIL file:',/,A92)
5000 FORMAT (/, ' More.... press < ENTER > key ')
5030 FORMAT (1X,A10, 2X, A11,1X,A5,1X,F5.0,1X,A50)
5035 FORMAT (2(1X,A11),2(1X,F8.3),1X,A50)
! 5040 FORMAT (1X,A5,6(1X,F5.0),4(1X,A5))
! 5040 FORMAT (1X,A5,6(1X,F5.0),4(1X,A5),1X,F5.0)
! 5040 FORMAT (1X,A5,6(1X,F5.0),3(1X,A5),F6.0) !McNair's 5/13/2005
! 5080 FORMAT (1X,F5.0,1X,A5,29(1X,F5.0))
! 5090 FORMAT (1X,F5.0,18(1X,F5.0))
5101 FORMAT (10X,'ERROR! Soil Selection must be between 1 and ',I3,/)
5102 FORMAT (10X,'ERROR! Soil Selection must be an INTEGER value',/)
5130 FORMAT (T25, 'SOILS IN THE DATA BASE', /,T3, 'REF', T25,
& 22('='),/,T3, 'NO.', T7, 'TAXONOMY NAME', T67,
& 'PEDON NUMBER', /T2, 4('-'), 1X, 50('-'), T67, 12('-'))
5140 FORMAT (I4,') ',A50, T67, A10)
5160 FORMAT (/,6X,'SELECTED SOIL TYPE ===>',1X,I3,
& /,6X,'NEW SELECTION ? --->',2X,' ',$)
END SUBROUTINE IPSOIL_Inp