-
Notifications
You must be signed in to change notification settings - Fork 1
/
IPTILL.FOR
110 lines (91 loc) · 3.33 KB
/
IPTILL.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
C=======================================================================
C IPTILL, Subroutine
C
C Determines tillage operations for a simulation
C-----------------------------------------------------------------------
C Revision history
C
C 07/18/1995 GPF Written
C 04/01/1996 GH Modified and included in DSSAT v3.1
C 08/19/2002 GH Modified for Y2K
C 08/23/2002 GH Expanded array tillage applications to 200
C 02/03/2005 GH Corrected error checking for missing levels
C-----------------------------------------------------------------------
C INPUT : LUNEXP,FILEX,LNCHE,CDATE,CHCOD,CHAMT,CHMET,CHDEP,CHT
C YRSIM,ISWWAT,NCHEM,FOLFR,SOLFR
C
C LOCAL : ERRKEY,CHARTEST,ISECT,LINEXP,ERRNUM,J,IFIND,LN
C
C OUTPUT :
C-----------------------------------------------------------------------
C Called : IPEXP
C
C Calls : FIND IGNORE ERROR
C-----------------------------------------------------------------------
C DEFINITIONS
C=======================================================================
SUBROUTINE IPTILL (LUNEXP,FILEX,LNTIL,YRSIM,ISWTIL,NTIL,TDATE,
& TIMPL,TDEP,LNSIM)
USE ModuleDefs
IMPLICIT NONE
CHARACTER*5 TIMPL(NAPPL)
CHARACTER*6 ERRKEY,FINDCH
CHARACTER*12 FILEX
CHARACTER*1 ISWTIL
CHARACTER*80 CHARTEST
INTEGER LNTIL,LUNEXP,ISECT,LINEXP,TDATE(NAPPL),NTIL
INTEGER ERRNUM,J,IFIND,LN,YRSIM,LNSIM
REAL TDEP(NAPPL)
PARAMETER (ERRKEY ='IPTILL')
FINDCH ='*TILLA'
DO J = 1, NAPPL
TIMPL(J) = ' '
TDATE(J) = 0
TDEP(J) = 0.0
END DO
NTIL = 0
IF (LNTIL .GT. 0) THEN
IF (ISWTIL .EQ. 'N' .AND. LNSIM .EQ. 0) THEN
ISWTIL = 'Y'
ENDIF
NTIL = 1
CALL FIND (LUNEXP,FINDCH,LINEXP,IFIND)
IF (IFIND .EQ. 0) CALL ERROR (ERRKEY,1,FILEX,LINEXP)
50 CALL IGNORE (LUNEXP,LINEXP,ISECT,CHARTEST)
IF (ISECT .EQ. 1) THEN
READ (CHARTEST,60,IOSTAT=ERRNUM) LN
IF (ERRNUM .NE. 0) CALL ERROR (ERRKEY,ERRNUM,FILEX,LINEXP)
IF (LN .NE. LNTIL) GO TO 50
C
C Read tillage operations
C
READ (CHARTEST,60,IOSTAT=ERRNUM) LN,TDATE(NTIL),
& TIMPL(NTIL),TDEP(NTIL)
IF (ERRNUM .NE. 0) CALL ERROR (ERRKEY,ERRNUM,FILEX,LINEXP)
IF ((TDATE(NTIL) .LT. 1) .OR.
& (MOD(TDATE(NTIL),1000) .GT. 366)) THEN
CALL ERROR (ERRKEY,10,FILEX,LINEXP)
ENDIF
CALL Y2K_DOY(TDATE(NTIL))
IF (TDATE(NTIL) .LT. YRSIM) THEN
CALL ERROR (ERRKEY,3,FILEX,LINEXP)
ENDIF
IF (TDEP(NTIL) .LT. 0) CALL ERROR (ERRKEY,11,FILEX,LINEXP)
NTIL = NTIL + 1
IF (NTIL .GT. NAPPL) GO TO 120
ELSE
IF (NTIL .EQ. 1) THEN
CALL ERROR (ERRKEY,2,FILEX,LINEXP)
ENDIF
GO TO 120
ENDIF
GO TO 50
ENDIF
120 REWIND (LUNEXP)
NTIL = MAX((NTIL-1),0)
RETURN
C-----------------------------------------------------------------------
C Format Strings
C-----------------------------------------------------------------------
60 FORMAT (I3,I5,1X,A5,1X,F5.0)
END SUBROUTINE IPTILL