1 |
C $Header: /u/gcmpack/MITgcm/pkg/flt/flt_runga2.F,v 1.15 2010/06/30 01:51:03 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "FLT_OPTIONS.h" |
5 |
|
6 |
SUBROUTINE FLT_RUNGA2 ( |
7 |
I myTime, myIter, myThid ) |
8 |
|
9 |
C ================================================================== |
10 |
C SUBROUTINE FLT_RUNGA2 |
11 |
C ================================================================== |
12 |
C o This routine steps floats forward with second order Runge-Kutta |
13 |
C |
14 |
C started: Arne Biastoch |
15 |
C |
16 |
C changed: 2004.06.10 Antti Westerlund (antti.westerlund@helsinki.fi) |
17 |
C and Sergio Jaramillo (sju@eos.ubc.ca) |
18 |
C ================================================================== |
19 |
|
20 |
C !USES: |
21 |
IMPLICIT NONE |
22 |
|
23 |
C == global variables == |
24 |
#include "SIZE.h" |
25 |
#include "EEPARAMS.h" |
26 |
#include "PARAMS.h" |
27 |
#include "GRID.h" |
28 |
#include "DYNVARS.h" |
29 |
#include "FLT_SIZE.h" |
30 |
#include "FLT.h" |
31 |
|
32 |
C == routine arguments == |
33 |
_RL myTime |
34 |
INTEGER myIter, myThid |
35 |
|
36 |
C == Functions == |
37 |
c _RL FLT_MAP_R2K |
38 |
c EXTERNAL FLT_MAP_R2K |
39 |
|
40 |
C == local variables == |
41 |
INTEGER bi, bj |
42 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
43 |
INTEGER ip |
44 |
INTEGER ic, jc, kc, iG, jG |
45 |
_RL uu, vv, u1, v1 |
46 |
#ifdef ALLOW_3D_FLT |
47 |
_RL ww, w1, ktz, kz, scalez |
48 |
_RL kzlo, kzhi |
49 |
#endif |
50 |
_RL ix, jy, itx, jty |
51 |
_RL scalex, scaley |
52 |
#ifdef USE_FLT_ALT_NOISE |
53 |
Real*8 PORT_RAND_NORM |
54 |
#else |
55 |
Real*8 PORT_RAND |
56 |
#undef _USE_INTEGERS |
57 |
#ifdef _USE_INTEGERS |
58 |
INTEGER seed |
59 |
seed = -1 |
60 |
#else |
61 |
Real*8 seed |
62 |
seed = -1.d0 |
63 |
#endif |
64 |
#endif |
65 |
|
66 |
C == end of interface == |
67 |
|
68 |
#ifdef ALLOW_3D_FLT |
69 |
kzlo = 0.5 _d 0 |
70 |
kzhi = 0.5 _d 0 + DFLOAT(Nr) |
71 |
#endif |
72 |
|
73 |
DO bj=myByLo(myThid),myByHi(myThid) |
74 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
75 |
DO ip=1,npart_tile(bi,bj) |
76 |
|
77 |
C If float has died move to level 0 |
78 |
IF ( tend(ip,bi,bj).NE.-1. .AND. myTime.GT.tend(ip,bi,bj) |
79 |
& ) THEN |
80 |
kpart(ip,bi,bj) = 0. |
81 |
ELSE |
82 |
C Start integration between tstart and tend (individual for each float) |
83 |
IF ( (tstart(ip,bi,bj).EQ.-1..OR.myTime.GE.tstart(ip,bi,bj)) |
84 |
& .AND.( tend(ip,bi,bj).EQ.-1..OR.myTime.LE. tend(ip,bi,bj)) |
85 |
& .AND.( iup(ip,bi,bj).NE.-3.) |
86 |
& ) THEN |
87 |
|
88 |
ix = ipart(ip,bi,bj) |
89 |
jy = jpart(ip,bi,bj) |
90 |
ic=NINT(ix) |
91 |
jc=NINT(jy) |
92 |
kc=NINT(kpart(ip,bi,bj)) |
93 |
|
94 |
scalex=recip_dxF(ic,jc,bi,bj) |
95 |
scaley=recip_dyF(ic,jc,bi,bj) |
96 |
iG = myXGlobalLo + (bi-1)*sNx + ic-1 |
97 |
jG = myYGlobalLo + (bj-1)*sNy + jc-1 |
98 |
|
99 |
#ifdef ALLOW_3D_FLT |
100 |
IF (iup(ip,bi,bj).EQ.-1.) THEN |
101 |
c kz=global2local_k(kpart(ip,bi,bj),bi,bj,mjtyhid) |
102 |
|
103 |
C recip_drF is in units 1/r (so IF r is in m this is in 1/m) |
104 |
scalez=rkSign*recip_drF(kc) |
105 |
C We should not do any special conversions for kz, since flt_trilinear |
106 |
C expects it to be just a normal kpart type variable. |
107 |
kz=kpart(ip,bi,bj) |
108 |
CALL FLT_TRILINEAR(ix,jy,kz,uu,uVel,1,bi,bj,myThid) |
109 |
CALL FLT_TRILINEAR(ix,jy,kz,vv,vVel,2,bi,bj,myThid) |
110 |
CALL FLT_TRILINEAR(ix,jy,kz,ww,wVel,4,bi,bj,myThid) |
111 |
ELSE |
112 |
#else /* ALLOW_3D_FLT */ |
113 |
IF ( .TRUE. ) THEN |
114 |
#endif /* ALLOW_3D_FLT */ |
115 |
CALL FLT_BILINEAR(ix,jy,uu,uVel,kc,1,bi,bj,myThid) |
116 |
CALL FLT_BILINEAR(ix,jy,vv,vVel,kc,2,bi,bj,myThid) |
117 |
ENDIF |
118 |
|
119 |
C When using this alternative scheme the noise probably should not be added twice. |
120 |
#ifndef USE_FLT_ALT_NOISE |
121 |
IF (iup(ip,bi,bj).NE.-2.) THEN |
122 |
uu = uu + uu*(PORT_RAND(seed)-0.5)*flt_noise |
123 |
vv = vv + vv*(PORT_RAND(seed)-0.5)*flt_noise |
124 |
#ifdef ALLOW_3D_FLT |
125 |
#ifdef ALLOW_FLT_3D_NOISE |
126 |
IF (iup(ip,bi,bj).EQ.-1.) THEN |
127 |
ww = ww + ww*(PORT_RAND(seed)-0.5)*flt_noise |
128 |
ENDIF |
129 |
#endif |
130 |
#endif /* ALLOW_3D_FLT */ |
131 |
ENDIF |
132 |
#endif |
133 |
|
134 |
C ix and itx are in indices. Therefore it is necessary to multiply |
135 |
C with a grid scale factor. |
136 |
|
137 |
itx=ix+0.5*flt_deltaT*uu*scalex |
138 |
jty=jy+0.5*flt_deltaT*vv*scaley |
139 |
|
140 |
C Second step |
141 |
|
142 |
#ifdef ALLOW_3D_FLT |
143 |
IF (iup(ip,bi,bj).EQ.-1.) THEN |
144 |
ktz=kz+0.5*flt_deltaT*ww*scalez |
145 |
CALL FLT_TRILINEAR(itx,jty,ktz,u1,uVel,1,bi,bj,myThid) |
146 |
CALL FLT_TRILINEAR(itx,jty,ktz,v1,vVel,2,bi,bj,myThid) |
147 |
CALL FLT_TRILINEAR(itx,jty,ktz,w1,wVel,4,bi,bj,myThid) |
148 |
ELSE |
149 |
#else /* ALLOW_3D_FLT */ |
150 |
IF ( .TRUE. ) THEN |
151 |
#endif /* ALLOW_3D_FLT */ |
152 |
CALL FLT_BILINEAR(itx,jty,u1,uVel,kc,1,bi,bj,myThid) |
153 |
CALL FLT_BILINEAR(itx,jty,v1,vVel,kc,2,bi,bj,myThid) |
154 |
ENDIF |
155 |
|
156 |
IF (iup(ip,bi,bj).NE.-2.) THEN |
157 |
#ifdef USE_FLT_ALT_NOISE |
158 |
u1 = u1 + port_rand_norm()*flt_noise |
159 |
v1 = v1 + port_rand_norm()*flt_noise |
160 |
#ifdef ALLOW_3D_FLT |
161 |
#ifdef ALLOW_FLT_3D_NOISE |
162 |
IF (iup(ip,bi,bj).EQ.-1.) THEN |
163 |
w1 = w1 + port_rand_norm()*flt_noise |
164 |
ENDIF |
165 |
#endif |
166 |
#endif /* ALLOW_3D_FLT */ |
167 |
|
168 |
#else /* USE_FLT_ALT_NOISE */ |
169 |
u1 = u1 + u1*(PORT_RAND(seed)-0.5)*flt_noise |
170 |
v1 = v1 + v1*(PORT_RAND(seed)-0.5)*flt_noise |
171 |
#ifdef ALLOW_3D_FLT |
172 |
#ifdef ALLOW_FLT_3D_NOISE |
173 |
IF (iup(ip,bi,bj).EQ.-1.) THEN |
174 |
w1 = w1 + w1*(PORT_RAND(seed)-0.5)*flt_noise |
175 |
ENDIF |
176 |
#endif |
177 |
#endif /* ALLOW_3D_FLT */ |
178 |
|
179 |
#endif /* USE_FLT_ALT_NOISE */ |
180 |
ENDIF |
181 |
|
182 |
C ipart is in coordinates. Therefore it is necessary to multiply |
183 |
C with a grid scale factor divided by the number grid points per |
184 |
C geographical coordinate. |
185 |
ipart(ip,bi,bj) = ipart(ip,bi,bj) |
186 |
& + flt_deltaT*u1*scalex |
187 |
jpart(ip,bi,bj) = jpart(ip,bi,bj) |
188 |
& + flt_deltaT*v1*scaley |
189 |
#ifdef ALLOW_3D_FLT |
190 |
IF (iup(ip,bi,bj).EQ.-1.) THEN |
191 |
kpart(ip,bi,bj) = kpart(ip,bi,bj) |
192 |
& + flt_deltaT*w1*scalez |
193 |
ENDIF |
194 |
#endif /* ALLOW_3D_FLT */ |
195 |
|
196 |
C-- new horizontal grid indices |
197 |
ic = MAX( 1-Olx, MIN( NINT(ipart(ip,bi,bj)), sNx+Olx ) ) |
198 |
jc = MAX( 1-Oly, MIN( NINT(jpart(ip,bi,bj)), sNy+Oly ) ) |
199 |
|
200 |
#ifdef ALLOW_3D_FLT |
201 |
C If float is 3D, make sure that it remains in water |
202 |
IF (iup(ip,bi,bj).EQ.-1.) THEN |
203 |
C reflect on surface |
204 |
IF (kpart(ip,bi,bj).LT.kzlo) kpart(ip,bi,bj)=kzlo |
205 |
& +kzlo-kpart(ip,bi,bj) |
206 |
C stop at bottom |
207 |
IF (kpart(ip,bi,bj).GT.kzhi) kpart(ip,bi,bj)=kzhi |
208 |
C-to work also with non flat-bottom set-up: |
209 |
c IF ( kpart(ip,bi,bj).GT.kLowC(ic,jc,bi,bj)+0.5 ) |
210 |
c & kpart(ip,bi,bj) = kLowC(ic,jc,bi,bj)+0.5 |
211 |
ENDIF |
212 |
#endif /* ALLOW_3D_FLT */ |
213 |
|
214 |
#ifdef ALLOW_OBCS |
215 |
IF ( useOBCS ) THEN |
216 |
C-- stop floats which enter the OB region: |
217 |
IF ( maskInC(ic,jc,bi,bj).EQ.0. .AND. |
218 |
& maskC(ic,jc,1,bi,bj).EQ.1. ) THEN |
219 |
C for now, just reset "tend" to myTime-deltaT |
220 |
C (a better way would be to remove this one & re-order the list of floats) |
221 |
tend(ip,bi,bj) = myTime - flt_deltaT |
222 |
ENDIF |
223 |
ENDIF |
224 |
#endif /* ALLOW_OBCS */ |
225 |
|
226 |
ENDIF |
227 |
ENDIF |
228 |
|
229 |
C- end ip loop |
230 |
ENDDO |
231 |
C- end bi,bj loops |
232 |
ENDDO |
233 |
ENDDO |
234 |
|
235 |
RETURN |
236 |
END |