-
Notifications
You must be signed in to change notification settings - Fork 1
/
LINDM.FOR
119 lines (109 loc) · 4.76 KB
/
LINDM.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
C=======================================================================
C LINDM, Subroutine
C----------------------------------------------------------------------
C This subroutine linearly interpolates the between pest observations
C-----------------------------------------------------------------------
C REVISION HISTORY
C 01/01/90 WDB
C 02/25/98 CHP Modified for PEST Module
C 01/12/99 GH Incorporated into CROPGRO
C-----------------------------------------------------------------------
C Called by: PEST
C Calls: None
C=======================================================================
SUBROUTINE LINDM(
& DAP, IDAP, PCN, YPL, !Input
& PL) !Output
C-----------------------------------------------------------------------
IMPLICIT NONE
SAVE
INTEGER, PARAMETER :: MAXPEST = 200
INTEGER DAP, I, PCN
INTEGER ROW(6)
INTEGER IDAP(6,MAXPEST)
REAL RISE, RUNN, SLOPE
REAL PL(6)
REAL YPL(6,MAXPEST)
C-----------------------------------------------------------------------
C Initialize variables
C-----------------------------------------------------------------------
IF (DAP .LE. 1) THEN
DO I = 1, 6
PL(I) = 0
ROW(I) = 1
ENDDO
ENDIF
C-----------------------------------------------------------------------
C Linearly interpolate pest levels daily
C-----------------------------------------------------------------------
DO I = 1, PCN
C-----------------------------------------------------------------------
C Increment Row Counter
C-----------------------------------------------------------------------
450 CONTINUE
IF (IDAP(I,ROW(I)) .LT. 0) THEN
ROW(I) = ROW(I) + 1
GOTO 450
ENDIF
IF (DAP .GT. IDAP(I,ROW(I)) .AND. IDAP(I,ROW(I)) .GT. 0)
& ROW(I) = ROW(I) + 1
C-----------------------------------------------------------------------
C Set beginning of interpolation to zero
C-----------------------------------------------------------------------
IF (DAP .LT. IDAP(I,1) ) THEN
PL(I) = 0
C-----------------------------------------------------------------------
C Set First Interpolated Value if idap(I,1) = 1
C-----------------------------------------------------------------------
ELSEIF (DAP .EQ. IDAP(I,1)) THEN
PL(I) = YPL(I,ROW(I))
ROW(I) = ROW(I) + 1
C-----------------------------------------------------------------------
C Linear Interpolation
! Rewrite logic for Intel compiler -- can't handle composite "IF" clause
! 09/20/2005 CHP, revised 01/04/2006
C-----------------------------------------------------------------------
ELSEIF (ROW(I) .GT. 1) THEN
RISE = YPL(I,ROW(I)) - YPL(I,ROW(I)-1)
RUNN = IDAP(I,ROW(I)) - IDAP(I,ROW(I)-1)
SLOPE = RISE/RUNN
C-----------------------------------------------------------------------
C Set first interpolated value if idap < 0, that is
C there is some pest data before planting date
C-----------------------------------------------------------------------
IF (DAP .LE. 1 .AND. IDAP(I,ROW(I)-1) .LT. 0) THEN
PL(I) = YPL(I,ROW(I)-1) + SLOPE * (DAP - IDAP(I,ROW(I)-1))
ELSEIF(DAP .LE. IDAP(I,ROW(I))) THEN
PL(I) = PL(I) + SLOPE * 1
ENDIF
ENDIF
C-----------------------------------------------------------------------
C Set all damage to zero after last user entered
c value for damage
C-----------------------------------------------------------------------
IF (DAP .GT. IDAP(I,ROW(I))) THEN
PL(I) = 0
ENDIF
ENDDO
RETURN
END SUBROUTINE LINDM
!-----------------------------------------------------------------------
! Variables definitions
!-----------------------------------------------------------------------
! DAP Number of days after planting (d)
! IDAP(I,J) Day of pest damage for pest I, observation J
! (days after planting)
! PCN Number of pests in FILET
! PL(I) Pest level from pest progress file (FILET) for pest I (varies)
! RISE Change in pest damage level between two observations for linear
! interpolation
! ROW(I) Counter which points to current row of data for each pest
! progress curve (I)
! RUNN Change in date between two observations for linear
! interpolation
! SLOPE Slope of pest level curve (RISE/RUNN) between two observations
! YPL(I,J) Array for storage of pest data for pest or damage type I,
! observation J
!-----------------------------------------------------------------------
! End Subroutine LINDM
!-----------------------------------------------------------------------