NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3ft07.f
Go to the documentation of this file.
1C> @file
2C> @brief Transform gridpoint fld by interpolation.
3C> @author McDonell & Howcroft @date 1974-09-01
4
5C> Transforms data contained in a given grid array
6C> by translation, rotation about a common point and dilatation
7C> in order to create a new grid array according to specs.
8C>
9C> ### Program History Log:
10C> Date | Programmer | Comment
11C> -----|------------|--------
12C> 1974-09-01 | J. McDonell, J.Howcroft | Initial.
13C> 1984-06-27 | Ralph Jones | Change to ibm vs fortran
14C> 1989-01-24 | Ralph Jones | Change to microsoft fortran 4.10
15C> 1989-03-31 | Ralph Jones | Change to vax-11 fortran
16C> 1993-03-16 | D. Shimomura | Renamed from w3ft00() to w3ft07()
17C> in order to make minor mods while doing f77. Changes to call sequence;
18C> changes to vrbl names; added comments.
19C>
20C> @param[in] FLDA Real*4 original source grid-point data field
21C> @param[in] IA (Input for FLDA)
22C> @param[in] JA (Input for FLDA)
23C> @param[in] FLDB Real*4 original source grid-point data field
24C> @param[in] IB (Input for FLDB)
25C> @param[in] JB (Input for FLDB)
26C> @param[in] AIPOLE Real*4 common point i-coordinates of the
27C> original field, assuming a right-hand cartesian
28C> coordinate system. the point need not be inside the bounds of either grid
29C> @param[in] AJPOLE Real*4 common point j-coordinates of the
30C> original field, assuming a right-hand cartesian
31C> coordinate system. the point need not be inside the bounds of either grid
32C> and can have fractional values. Common point about which to rotate the gridpoints.
33C> @param[in] BIPOLE - Real*4 common point i-coordinates for
34C> transformed destination grid
35C> @param[in] BJPOLE - Real*4 common point j-coordinates for
36C> transformed destination grid
37C> @param[in] DSCALE - Real*4 scale-change (dilation) expressed as
38C> a ratio of the transformed field to the original field
39C> dscale = grdlenkm(destination) / grdlenkm(source)
40C> @param[in] ANGLE - Real*4 degree measure of the angle required to
41C> rotate the j-row of the original grid into
42C> coincidence with the new grid. (+ counter-
43C> clockwise, - clockwise)
44C> angle = vertlonw(source) - vertlonw(destination)
45C>
46C> @param[in] LINEAR - Logical*4 interpolation-method selection switch:
47C> - .TRUE. Bi-linear interpolation.
48C> - .FALSE. Bi-quadratic interpolation.
49C> @param[in] LDEFQQ - Logical*4 default-value switch:
50C> if .true. then
51C> use default-value for destination point
52C> out-of-bounds of given grid;
53C> else
54C> extrapolate coarsely from nearby bndry point
55C> @param[in] DEFALT - Real*4 the default-value to use if ldefqq = .true.
56C>
57C> @remark List caveats, other helpful hints or information
58C> in general 'FLDA' and 'FLDB' cannot be equivalenced
59C> although there are situations in which it would be safe to do
60C> so. Care should be taken that all of the new grid points lie
61C> within the original grid, no error checks are made.
62C>
63C> @author McDonell & Howcroft @date 1974-09-01
64 SUBROUTINE w3ft07(FLDA,IA,JA,AIPOLE,AJPOLE,BIPOLE,BJPOLE,
65 A DSCALE,ANGLE,LINEAR,LDEFQQ,DEFALT,FLDB,IB,JB)
66C
67 REAL FLDA(IA,JA)
68 REAL AIPOLE,AJPOLE
69 REAL BIPOLE,BJPOLE
70 REAL DSCALE
71 REAL ANGLE
72 REAL DEFALT
73 REAL FLDB(IB,JB)
74 REAL ERAS(4)
75 REAL TINY
76C
77 LOGICAL LINEAR
78 LOGICAL LDEFQQ
79C
80 SAVE
81C
82 DATA tiny / 0.001 /
83C
84C ... WHERE TINY IS IN UNITS OF 1.0 = 1 GRID INTERVAL
85C
86C . . . . . S T A R T . . . . . . . . . . . . . . . . . . .
87C
88 theta = angle * (3.14159/180.)
89 sint = sin(theta)
90 cost = cos(theta)
91C
92C ... WE WILL SCAN ALONG THE J-ROW OF THE DESTINATION GRID ...
93 DO 288 jn = 1,jb
94 brelj = float(jn) - bjpole
95C
96 DO 277 in = 1,ib
97 breli = float(in) - bipole
98 sti = aipole + dscale*(breli*cost - brelj*sint)
99 stj = ajpole + dscale*(breli*sint + brelj*cost)
100 im = sti
101 jm = stj
102C
103C ... THE PT(STI,STJ) IS THE LOCATION OF THE FLDB(IN,JN)
104C ... IN FLDA,S COORDINATE SYSTEM
105C ... IS THIS POINT LOCATED OUTSIDE FLDA?
106C ... ON THE BOUNDARY LINE OF FLDA?
107C ... ON THE FIRST INTERIOR GRIDPOINT OF FLDA?
108C ... GOOD INSIDER, AT LEAST 2 INTERIOR GRIDS INSIDE?
109 ioff = 0
110 joff = 0
111 kquad = 0
112C
113 IF (im .LT. 1) THEN
114C ... LOCATED OUTSIDE OF FLDA, OFF LEFT SIDE ...
115 ii = 1
116 ioff = 1
117 ELSE IF (im .EQ. 1) THEN
118C ... LOCATED ON BOUNDARY OF FLDA, ON LEFT EDGE ...
119 kquad = 5
120 ELSE
121C ...( IM .GT. 1) ... LOCATED TO RIGHT OF LEFT-EDGE ...
122 IF ((ia-im) .LT. 1) THEN
123C ... LOCATED OUTSIDE OF OR EXACTLY ON RIGHT EDGE OF FLDA ..
124 ii = ia
125 ioff = 1
126 ELSE IF ((ia-im) .EQ. 1) THEN
127C ... LOCATED ON FIRST INTERIOR PT WITHIN RIGHT EDGE OF FLDA
128 kquad = 5
129 ELSE
130C ... (IA-IM) IS .GT. 1) ...GOOD INTERIOR, AT LEAST 2 INSIDE
131 ENDIF
132 ENDIF
133C
134C . . . . . . . . . . . . . . .
135C
136 IF (jm .LT. 1) THEN
137C ... LOCATED OUTSIDE OF FLDA, OFF BOTTOM ...
138 jj = 1
139 joff = 1
140 ELSE IF (jm .EQ. 1) THEN
141C ... LOCATED ON BOUNDARY OF FLDA, ON BOTTOM EDGE ...
142 kquad = 5
143 ELSE
144C ...( JM .GT. 1) ... LOCATED ABOVE BOTTOM EDGE ...
145 IF ((ja-jm) .LT. 1) THEN
146C ... LOCATED OUTSIDE OF OR EXACTLY ON TOP EDGE OF FLDA ..
147 jj = ja
148 joff = 1
149 ELSE IF ((ja-jm) .EQ. 1) THEN
150C ... LOCATED ON FIRST INTERIOR PT WITHIN TOP EDGE OF FLDA
151 kquad = 5
152 ELSE
153C ... ((JA-JM) .GT. 1) ...GOOD INTERIOR, AT LEAST 2 INSIDE
154 ENDIF
155 ENDIF
156C
157 IF ((ioff + joff) .EQ. 0) THEN
158 GO TO 244
159 ELSE IF ((ioff + joff) .EQ. 2) THEN
160 GO TO 233
161 ENDIF
162C
163 IF (ioff .EQ. 1) THEN
164 jj = stj
165 ENDIF
166 IF (joff .EQ. 1) THEN
167 ii = sti
168 ENDIF
169 233 CONTINUE
170 IF (ldefqq) THEN
171 fldb(in,jn) = defalt
172 ELSE
173 fldb(in,jn) = flda(ii,jj)
174 ENDIF
175 GO TO 277
176C
177C . . . . . . . . . . . . .
178C
179 244 CONTINUE
180 i = sti
181 j = stj
182 xdeli = sti - float(i)
183 xdelj = stj - float(j)
184C
185 IF ((abs(xdeli) .LT. tiny) .AND. (abs(xdelj) .LT. tiny)) THEN
186C ... THIS POINT IS RIGHT AT A GRIDPOINT. NO INTERP NECESSARY
187 fldb(in,jn) = flda(i,j)
188 GO TO 277
189 ENDIF
190C
191 IF ((kquad .EQ. 5) .OR. (linear)) THEN
192C ... PERFORM BI-LINEAR INTERP ...
193 eras(1) = flda(i,j)
194 eras(4) = flda(i,j+1)
195 eras(2) = eras(1) + xdeli*(flda(i+1,j) - eras(1))
196 eras(3) = eras(4) + xdeli*(flda(i+1,j+1) - eras(4))
197 di = eras(2) + xdelj*(eras(3) - eras(2))
198 GO TO 266
199C
200 ELSE
201C ... PERFORM BI-QUADRATIC INTERP ...
202 xi2tm = xdeli * (xdeli-1.) * 0.25
203 xj2tm = xdelj * (xdelj-1.) * 0.25
204 j1 = j - 1
205 DO 255 k=1,4
206 eras(k)=(flda(i+1,j1)-flda(i,j1))*xdeli+flda(i,j1)+
207 a (flda(i-1,j1)-flda(i,j1)-flda(i+1,j1)+flda(i+2,j1))*xi2tm
208 j1 = j1 + 1
209 255 CONTINUE
210C
211 di = eras(2) + xdelj*(eras(3)-eras(2)) +
212 a xj2tm*(eras(4)-eras(3)-eras(2)+eras(1))
213 GO TO 266
214 ENDIF
215C
216 266 CONTINUE
217 fldb(in,jn) = di
218 277 CONTINUE
219 288 CONTINUE
220C
221 RETURN
222 END
subroutine w3ft07(flda, ia, ja, aipole, ajpole, bipole, bjpole, dscale, angle, linear, ldefqq, defalt, fldb, ib, jb)
Transforms data contained in a given grid array by translation, rotation about a common point and dil...
Definition w3ft07.f:66