/[MITgcm]/MITgcm/pkg/flt/flt_bilinear.F
ViewVC logotype

Annotation of /MITgcm/pkg/flt/flt_bilinear.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download)
Tue Sep 7 16:19:30 2004 UTC (19 years, 9 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint57m_post, checkpoint57g_pre, checkpoint57s_post, checkpoint58b_post, checkpoint57b_post, checkpoint57g_post, checkpoint56b_post, checkpoint57y_post, checkpoint57r_post, checkpoint57d_post, checkpoint57i_post, checkpoint59, checkpoint58, checkpoint55, checkpoint57, checkpoint56, checkpoint58f_post, checkpoint57n_post, checkpoint58d_post, checkpoint58a_post, checkpoint57z_post, checkpoint54f_post, checkpoint58y_post, checkpoint55a_post, checkpoint58t_post, checkpoint55i_post, checkpoint57h_post, checkpoint57t_post, checkpoint55c_post, checkpoint57v_post, checkpoint57f_post, checkpoint60, checkpoint61, checkpoint57a_post, checkpoint57h_pre, checkpoint57x_post, checkpoint58w_post, checkpoint57y_pre, checkpoint55g_post, checkpoint57l_post, checkpoint58o_post, checkpoint57c_post, checkpoint58p_post, checkpoint58q_post, checkpoint58e_post, checkpoint58m_post, checkpoint55d_pre, checkpoint57c_pre, checkpoint58r_post, checkpoint55j_post, checkpoint55h_post, checkpoint58n_post, checkpoint57e_post, checkpoint55b_post, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint55f_post, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint57p_post, checkpint57u_post, checkpoint57q_post, eckpoint57e_pre, checkpoint58k_post, checkpoint58v_post, checkpoint56a_post, checkpoint58l_post, checkpoint57h_done, checkpoint57j_post, checkpoint57f_pre, checkpoint61f, checkpoint58g_post, checkpoint58x_post, checkpoint59j, checkpoint58h_post, checkpoint56c_post, checkpoint58j_post, checkpoint57a_pre, checkpoint57o_post, checkpoint57k_post, checkpoint57w_post, checkpoint58i_post, checkpoint58c_post, checkpoint58u_post, checkpoint58s_post, checkpoint55e_post, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint55d_post
Changes since 1.1: +161 -4 lines
 o add Antti Westerlund's extensions to make flt work with 3D velocity
   fields

1 edhill 1.2 C $Header: /u/gcmpack/MITgcm/pkg/flt/flt_bilinear.F,v 1.1 2001/09/13 17:43:55 adcroft Exp $
2     C $Name: $
3 adcroft 1.1
4     #include "FLT_CPPOPTIONS.h"
5    
6     subroutine flt_bilinear(
7     I xp,
8     I yp,
9     O uu,
10     I kp,
11     I u,
12     I nu,
13     I bi,
14     I bj
15     & )
16    
17     c ==================================================================
18     c SUBROUTINE flt_bilinear
19     c ==================================================================
20     c
21     c o Bilinear scheme to find u of particle at given xp,yp location
22     c
23     c ==================================================================
24     c SUBROUTINE flt_bilinear
25     c ==================================================================
26    
27     c == global variables ==
28    
29     #include "SIZE.h"
30    
31     c == routine arguments ==
32    
33     _RL xp, yp
34     _RL uu
35     integer nu, kp, bi, bj
36     _RL u (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
37    
38     c == local variables ==
39    
40     INTEGER nnx, nny, nfx, nfy, nfxp, nfyp
41     _RL dx, dy, ddx, ddy
42     integer ip
43     _RL xx, yy, phi, scalex, scaley
44     _RL u11, u12, u22, u21
45    
46     c == end of interface ==
47    
48     nnx = int(xp)
49     nny = int(yp)
50     dx = xp - float(nnx)
51     dy = yp - float(nny)
52     c
53 edhill 1.2 c to choose the u box in which the particle is found
54 adcroft 1.1 c nu=1 for T, S
55     c nu=2 for u
56     c nu=3 for v
57     c nu=4 for w
58     c
59     if (nu.eq.1.or.nu.eq.4) then
60     nfx = nnx
61     nfy = nny
62     ddx = dx
63     ddy = dy
64     endif
65     c
66     if (nu.eq.2) then
67     if (dx.le.0.5) then
68     nfx = nnx
69     ddx = dx + 0.5
70     else
71     nfx = nnx + 1
72     ddx = dx - 0.5
73     endif
74     nfy = nny
75     ddy = dy
76     endif
77     c
78     if (nu.eq.3) then
79     if (dy.le.0.5) then
80     nfy = nny
81     ddy = dy + 0.5
82     else
83     nfy = nny + 1
84     ddy = dy - 0.5
85     endif
86     nfx = nnx
87     ddx = dx
88     endif
89     c
90     c
91     cab change start
92     c was correct only for global?
93     c if(nfx.gt.nx) nfx=nfx-nx
94     if(nfx.gt.nx) nfx=nx
95     cab change end
96     if(nfy.gt.ny) nfy=ny
97     nfxp = nfx + 1
98     nfyp = nfy + 1
99     cab change start
100     c if (nfx.eq.nx) nfxp = 1
101     if (nfx.eq.nx) nfxp = nfx
102     cab change end
103     if (nfy.eq.ny) nfyp = nfy
104    
105     if (nu.lt.4) then
106     u11 = u(nfx,nfy,kp,bi,bj)
107     u21 = u(nfxp,nfy,kp,bi,bj)
108     u22 = u(nfxp,nfyp,kp,bi,bj)
109     u12 = u(nfx,nfyp,kp,bi,bj)
110     endif
111     if (nu.eq.4) then
112 edhill 1.2 caw This may be incorrect.
113 adcroft 1.1 u11 = u(nfx,nfy,kp,bi,bj)+u(nfx,nfy,kp-1,bi,bj)
114     u21 = u(nfxp,nfy,kp,bi,bj)+u(nfxp,nfy,kp-1,bi,bj)
115     u22 = u(nfxp,nfyp,kp,bi,bj)+u(nfxp,nfyp,kp-1,bi,bj)
116     u12 = u(nfx,nfyp,kp,bi,bj)+u(nfx,nfyp,kp-1,bi,bj)
117     endif
118 edhill 1.2
119 adcroft 1.1 c
120     c
121     c bilinear interpolation (from numerical recipes)
122     uu = (1-ddx)*(1-ddy)*u11 + ddx*(1-ddy)*u21 + ddx*ddy*u22
123     . + (1-ddx)*ddy*u12
124     c
125     c
126     return
127     end
128    
129 edhill 1.2 subroutine flt_trilinear(
130     I xp,
131     I yp,
132     I zp,
133     O uu,
134     I u,
135     I nu,
136     I bi,
137     I bj
138     & )
139    
140     c ==================================================================
141     c SUBROUTINE flt_trilinear
142     c ==================================================================
143     c
144     c o Trilinear scheme to find u of particle at a given xp,yp,zp
145     c location. This routine is a straight forward generalization of the
146     c bilinear interpolation scheme.
147     c
148     c started: 2004.05.28 Antti Westerlund (antti.westerlund@fimr.fi)
149     c and Sergio Jaramillo (sju@eos.ubc.ca).
150     c (adopted from subroutine bilinear by Arne Biastoch)
151     c
152     c ==================================================================
153     c SUBROUTINE flt_trilinear
154     c ==================================================================
155    
156     c == global variables ==
157    
158     #include "SIZE.h"
159    
160     c == routine arguments ==
161    
162     _RL xp, yp, zp
163     _RL uu
164     integer nu, bi, bj
165     _RL u (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
166    
167     c == local variables ==
168    
169     INTEGER nnx, nny, nnz, nfx, nfy, nfz, nfxp, nfyp, nfzp
170     _RL dx, dy, dz, ddx, ddy, ddz
171     integer ip
172     _RL xx, yy, zz, phi, scalex, scaley, scalez
173     _RL u111, u121, u221, u211, u112, u122, u222, u212
174    
175     c == end of interface ==
176    
177     c Round xp,yp,zp down to find a grid point.
178     nnx = int(xp)
179     nny = int(yp)
180     nnz = int(zp)
181    
182     c Find out the distance from the gridpoint.
183     dx = xp - float(nnx)
184     dy = yp - float(nny)
185     dz = zp - float(nnz)
186     c
187     c to choose the u box in which the particle is found
188     c nu=1 for T, S
189     c nu=2 for u
190     c nu=3 for v
191     c nu=4 for w
192     c
193     c Velocities are face quantities and must therefore be treated differently
194     c
195     c if the variable is T,S
196     if (nu.eq.1) then
197     nfx = nnx
198     ddx = dx
199     nfy = nny
200     ddy = dy
201     nfz = nnz
202     ddz = dz
203     endif
204     c if the variable is u
205     if (nu.eq.2) then
206     if (dx.le.0.5) then
207     nfx = nnx
208     ddx = dx + 0.5
209     else
210     nfx = nnx + 1
211     ddx = dx - 0.5
212     endif
213     nfy = nny
214     ddy = dy
215     nfz = nnz
216     ddz = dz
217     endif
218     c if the variable is v
219     if (nu.eq.3) then
220     nfx = nnx
221     ddx = dx
222     if (dy.le.0.5) then
223     nfy = nny
224     ddy = dy + 0.5
225     else
226     nfy = nny + 1
227     ddy = dy - 0.5
228     endif
229     nfz = nnz
230     ddz = dz
231     endif
232     c if the variable is w
233     if (nu.eq.4) then
234     nfx = nnx
235     ddx = dx
236     nfy = nny
237     ddy = dy
238     if (dz.le.0.5) then
239     nfz = nnz
240     ddz = dz + 0.5
241     else
242     nfz = nnz + 1
243     ddz = dz - 0.5
244     endif
245     endif
246     c
247     c if we are near or over the edge, limit nfx/y/z
248     if(nfx.gt.nx) nfx=nx
249     if(nfy.gt.ny) nfy=ny
250     if(nfz.gt.nr) nfz=nr
251     if(nfz.le.1) nfz=1
252     c We should possibly check something else too...
253     c
254     c the coordinates for the other grid points
255     nfxp = nfx + 1
256     nfyp = nfy + 1
257     nfzp = nfz + 1
258     c if we are near the edge, also limit nf?p
259     if (nfx.eq.nx) nfxp = nfx
260     if (nfy.eq.ny) nfyp = nfy
261     if (nfz.eq.nr) nfzp = nfz
262    
263     c Values of the field at relevant grid points
264     u111 = u(nfx,nfy,nfz,bi,bj)
265     u211 = u(nfxp,nfy,nfz,bi,bj)
266     u221 = u(nfxp,nfyp,nfz,bi,bj)
267     u121 = u(nfx,nfyp,nfz,bi,bj)
268     u112 = u(nfx,nfy,nfzp,bi,bj)
269     u212 = u(nfxp,nfy,nfzp,bi,bj)
270     u222 = u(nfxp,nfyp,nfzp,bi,bj)
271     u122 = u(nfx,nfyp,nfzp,bi,bj)
272    
273     c Trilinear interpolation, a straight forward generalization
274     c of the bilinear interpolation scheme.
275     uu = (1-ddx)*(1-ddy)*(1-ddz)*u111 + ddx*(1-ddy)*(1-ddz)*u211
276     & + ddx*ddy*(1-ddz)*u221 + (1-ddx)*ddy*(1-ddz)*u121
277     & + (1-ddx)*(1-ddy)*ddz*u112 + ddx*(1-ddy)*ddz*u212
278     & + ddx*ddy*ddz*u222 + (1-ddx)*ddy*ddz*u122
279     c
280     c
281     return
282     end
283 adcroft 1.1
284     subroutine flt_bilinear2d(
285     I xp,
286     I yp,
287     O uu,
288     I u,
289     I nu,
290     I bi,
291     I bj
292     & )
293    
294     c ==================================================================
295     c SUBROUTINE flt_bilinear2d
296     c ==================================================================
297     c
298     c o Bilinear scheme to find u of particle at given xp,yp location
299     c o For 2D fields
300     c
301     c started: Arne Biastoch abiastoch@ucsd.edu 13-Jan-2000
302     c (adopted from subroutine bilinear)
303     c
304     c ==================================================================
305     c SUBROUTINE flt_bilinear2d
306     c ==================================================================
307    
308     c == global variables ==
309    
310     #include "SIZE.h"
311    
312     c == routine arguments ==
313    
314     _RL xp, yp
315     _RL uu
316     integer nu, bi, bj
317     _RL u (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
318    
319     c == local variables ==
320    
321     INTEGER nnx, nny, nfx, nfy, nfxp, nfyp
322     _RL dx, dy, ddx, ddy
323     integer ip
324     _RL xx, yy, phi, scalex, scaley
325     _RL u11, u12, u22, u21
326    
327     c == end of interface ==
328    
329     nnx = int(xp)
330     nny = int(yp)
331     dx = xp - float(nnx)
332     dy = yp - float(nny)
333     c
334 edhill 1.2 c to choose the u box in which the particle is found
335 adcroft 1.1 c nu=1 for T, S
336     c nu=2 for u
337     c nu=3 for v
338     c nu=4 for w
339     c
340     if (nu.eq.1.or.nu.eq.4) then
341     nfx = nnx
342     nfy = nny
343     ddx = dx
344     ddy = dy
345     endif
346     c
347     if (nu.eq.2) then
348     if (dx.le.0.5) then
349     nfx = nnx
350     ddx = dx + 0.5
351     else
352     nfx = nnx + 1
353     ddx = dx - 0.5
354     endif
355     nfy = nny
356     ddy = dy
357     endif
358     c
359     if (nu.eq.3) then
360     if (dy.le.0.5) then
361     nfy = nny
362     ddy = dy + 0.5
363     else
364     nfy = nny + 1
365     ddy = dy - 0.5
366     endif
367     nfx = nnx
368     ddx = dx
369     endif
370     c
371     cab change start
372     c was correct only for global?
373     c if(nfx.gt.nx) nfx=nfx-nx
374     if(nfx.gt.nx) nfx=nx
375     cab change end
376     if(nfy.gt.ny) nfy=ny
377     nfxp = nfx + 1
378     nfyp = nfy + 1
379     cab change start
380     c if (nfx.eq.nx) nfxp = 1
381     if (nfx.eq.nx) nfxp = nfx
382     cab change end
383     if (nfy.eq.ny) nfyp = nfy
384    
385     if (nu.lt.4) then
386     u11 = u(nfx,nfy,bi,bj)
387     u21 = u(nfxp,nfy,bi,bj)
388     u22 = u(nfxp,nfyp,bi,bj)
389     u12 = u(nfx,nfyp,bi,bj)
390     endif
391     if (nu.eq.4) then
392 edhill 1.2 caw This may be incorrect.
393 adcroft 1.1 u11 = u(nfx,nfy,bi,bj)+u(nfx,nfy,bi,bj)
394     u21 = u(nfxp,nfy,bi,bj)+u(nfxp,nfy,bi,bj)
395     u22 = u(nfxp,nfyp,bi,bj)+u(nfxp,nfyp,bi,bj)
396     u12 = u(nfx,nfyp,bi,bj)+u(nfx,nfyp,bi,bj)
397     endif
398     c
399     c
400     c bilinear interpolation (from numerical recipes)
401     uu = (1-ddx)*(1-ddy)*u11 + ddx*(1-ddy)*u21 + ddx*ddy*u22
402     . + (1-ddx)*ddy*u12
403     c
404     c
405     return
406     end
407    

  ViewVC Help
Powered by ViewVC 1.1.22