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