-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadvection.f90
434 lines (364 loc) · 15.4 KB
/
advection.f90
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
!>@author
!>Paul Connolly, The University of Manchester
!>@brief
!>advection routines
module advection
use numerics_type
private
public :: lax_wendroff_sphere, lax_wendroff_ll, dissipation, smagorinsky
contains
!>@author
!>Paul J. Connolly, The University of Manchester
!>@brief
!>advects a scalar field on the sphere
!>@param[in] ip: number of east-west points
!>@param[in] jp: ditto for north-south
!>@param[in] o_halo: halos required for advection scheme
!>@param[in] dt: timestep
!>@param[in] dx,dy: dx,dy
!>@param[in] g: gravity
!>@param[inout] u,v,h: prognostic variables
!>@param[in] hs: surface height
!>@param[in] re: radius of planet
!>@param[in] theta: latitude
!>@param[in] f_cor: Coriolis parameter
!>solves the 1-d advection equation:
!>\f$ \frac{\partial \psi}{\partial t} + \frac{\partial u \psi}{\partial x} = 0 \f$
subroutine lax_wendroff_sphere(ip,jp,o_halo,dt,dx,dy,g,u,v,h,hs,re,theta,f_cor)
use numerics_type
implicit none
integer(i4b), intent(in) :: ip,jp,o_halo
real(wp), intent(in) :: dt, g, re
real(wp), intent(in), dimension(1-o_halo:ip+o_halo,1-o_halo:jp+o_halo) :: &
hs, f_cor, dx, dy
real(wp), dimension(1-o_halo:jp+o_halo), intent(in) :: theta
real(wp), intent(inout), dimension(1-o_halo:ip+o_halo,1-o_halo:jp+o_halo) :: &
h, u, v
! local variables:
real(wp), dimension(1-o_halo:ip+o_halo,1-o_halo:jp+o_halo) :: &
dy1, v1, h1, vh, uh, vh1, Ux, Uy, Vx, Vy, Vy2
real(wp), dimension(1:ip,1:jp) :: &
uh_new, vh_new, h_new
real(wp), dimension(0:ip,1:jp) :: h_mid_xt, uh_mid_xt, Ux_mid_xt, Vx_mid_xt
real(wp), dimension(0:ip,1:jp) :: vh_mid_xt
real(wp), dimension(1:ip,0:jp) :: h_mid_yt, uh_mid_yt, vh_mid_yt, c_mid_yt, &
Uy_mid_yt, Vy_mid_yt, Vy_mid_yt2
integer(i4b) :: j, i
do j=1-o_halo,jp+o_halo
dy1(:,j)=dy(:,j)*cos(theta(j))
v1(:,j)=v(:,j)*cos(theta(j))
h1(:,j)=h(:,j)*cos(theta(j))
enddo
do j=0,jp
c_mid_yt(:,j)=cos(0.5_wp*(theta(j+1)+theta(j)))
enddo
uh=u *h
vh=v*h
vh1=v1*h
! continuity equation (calculate mid-point values at 0.5*dt):
h_mid_xt = 0.5_wp*(h(1:ip+1,1:jp)+h(0:ip,1:jp)) &
-(0.5_wp*dt/(0.5_wp*(dx(1:ip+1,1:jp)+dx(0:ip,1:jp)))) &
*(uh(1:ip+1,1:jp)-uh(0:ip,1:jp))
h_mid_yt = 0.5_wp*(h(1:ip,1:jp+1)+h(1:ip,0:jp)) &
-(0.5_wp*dt/(0.5_wp*(dy1(1:ip,1:jp+1)+dy1(1:ip,0:jp)))) &
*(vh1(1:ip,1:jp+1)-vh1(1:ip,0:jp))
! v-phi, or u momentum equation (calculate mid-point values at 0.5*dt):
Ux = uh*u + g*h**2*(0.5_wp)
Uy = uh*v1
uh_mid_xt(0:ip,:) = 0.5_wp*(uh(1:ip+1,1:jp)+uh(0:ip,1:jp)) &
-(0.5_wp*dt/(0.5_wp*(dx(1:ip+1,1:jp)+dx(0:ip,1:jp))))* &
(Ux(1:ip+1,1:jp)-Ux(0:ip,1:jp)) &
+0.125_wp*dt*(f_cor(1:ip+1,1:jp)+f_cor(0:ip,1:jp))* &
(vh(1:ip+1,1:jp)+vh(0:ip,1:jp))
uh_mid_yt = 0.5_wp*(uh(1:ip,1:jp+1)+uh(1:ip,0:jp)) &
-(0.5_wp*dt/(0.5_wp*(dy1(1:ip,1:jp+1)+dy1(1:ip,0:jp))))* &
(Uy(1:ip,1:jp+1)-Uy(1:ip,0:jp)) &
+0.125_wp*dt*(f_cor(1:ip,1:jp+1)+f_cor(1:ip,0:jp))* &
(vh(1:ip,1:jp+1)+vh(1:ip,0:jp))
! v-theta, or v momentum equation (calculate mid-point values at 0.5*dt):
Vx = uh*v
Vy = vh1*v
Vy2 = 0.5_wp*g*h**2
vh_mid_xt(0:ip,1:jp) = 0.5_wp*(vh(1:ip+1,1:jp)+vh(0:ip,1:jp)) &
-(0.5_wp*dt/(0.5_wp*(dx(1:ip+1,1:jp)+dx(0:ip,1:jp))))*(Vx(1:ip+1,1:jp)-Vx(0:ip,1:jp)) &
-0.125_wp*dt*(f_cor(1:ip+1,1:jp)+f_cor(0:ip,1:jp))*(uh(1:ip+1,1:jp)+uh(0:ip,1:jp))
vh_mid_yt(1:ip,0:jp) = 0.5_wp*(vh(1:ip,1:jp+1)+vh(1:ip,0:jp)) &
-(0.5_wp*dt/(0.5_wp*(dy1(1:ip,1:jp+1)+dy1(1:ip,0:jp))))*(Vy(1:ip,1:jp+1)-Vy(1:ip,0:jp)) &
-(0.5_wp*dt/(dy(1:ip,0:jp)))*(Vy2(1:ip,1:jp+1)-Vy2(1:ip,0:jp)) &
-0.125_wp*dt*(f_cor(1:ip,1:jp+1)+f_cor(1:ip,0:jp))*(uh(1:ip,1:jp+1)+uh(1:ip,0:jp))
! calculate mid-point value of cos (theta)
! c_mid_yt=cos(0.5.*(THETA(:,2:end)+THETA(:,1:end-1)));
!
!
! Now use the mid-point values to predict the values at the next timestep
! continuity:
h_new = h(1:ip,1:jp) &
- (dt/(0.5_wp*(dx(1:ip,1:jp)+dx(0:ip-1,1:jp))))*(uh_mid_xt(1:ip,1:jp)-uh_mid_xt(0:ip-1,1:jp)) &
- (dt/(0.5_wp*(dy1(1:ip,1:jp)+dy1(1:ip,0:jp-1)))) * &
(vh_mid_yt(1:ip,1:jp)*c_mid_yt(1:ip,1:jp)-vh_mid_yt(1:ip,0:jp-1)*c_mid_yt(1:ip,0:jp-1))
! u-momentum equation:
Ux_mid_xt = uh_mid_xt*uh_mid_xt/h_mid_xt + 0.5_wp*g*h_mid_xt**2
Uy_mid_yt = uh_mid_yt*vh_mid_yt/h_mid_yt*c_mid_yt
uh_new = uh(1:ip,1:jp) &
- (dt/(0.5_wp*(dx(1:ip,1:jp)+dx(0:ip-1,1:jp))))* (Ux_mid_xt(1:ip,1:jp)-Ux_mid_xt(0:ip-1,1:jp)) &
- (dt/(0.5_wp*(dy1(1:ip,1:jp)+dy1(1:ip,0:jp-1))))*(Uy_mid_yt(1:ip,1:jp)-Uy_mid_yt(1:ip,0:jp-1))
! v-momentum equation:
Vx_mid_xt = uh_mid_xt*vh_mid_xt/h_mid_xt
Vy_mid_yt = vh_mid_yt*vh_mid_yt/h_mid_yt*c_mid_yt
Vy_mid_yt2 = 0.5_wp*g*h_mid_yt**2
vh_new = vh(1:ip,1:jp) &
- (dt/(0.5_wp*(dx(1:ip,1:jp)+dx(0:ip-1,1:jp))))*(Vx_mid_xt(1:ip,1:jp)-Vx_mid_xt(0:ip-1,1:jp)) &
- (dt/(0.5_wp*(dy1(1:ip,1:jp)+dy1(1:ip,0:jp-1))))*(Vy_mid_yt(1:ip,1:jp)-Vy_mid_yt(1:ip,0:jp-1)) &
- (dt/(dy(1:ip,0:jp-1) ))* &
(Vy_mid_yt2(1:ip,1:jp)-Vy_mid_yt2(1:ip,0:jp-1))
! add on Coriolis and contribution of orography to pressure gradient:
uh_new=uh_new +dt*.5_wp*(f_cor(1:ip,1:jp)*v(1:ip,1:jp) - &
g*(hs(2:ip+1,1:jp)-hs(0:ip-1,1:jp))/(2._wp*dx(1:ip,1:jp)))* &
(h(1:ip,1:jp)+h_new)
vh_new=vh_new -dt*.5_wp*(f_cor(1:ip,1:jp)*u(1:ip,1:jp) + &
g*(hs(1:ip,2:jp+1)-hs(1:ip,0:jp-1))/(2._wp*dy1(1:ip,1:jp)))* &
(h(1:ip,1:jp)+h_new)
! uh_new=uh_new +dt*.5_wp*(f_cor(1:ip,1:jp)*(vh_mid_xt(1:ip,1:jp)+vh_mid_xt(0:ip-1,1:jp)) )
!
! vh_new=vh_new -dt*.5_wp*(f_cor(1:ip,1:jp)*(uh_mid_xt(1:ip,1:jp)+uh_mid_xt(0:ip-1,1:jp)) )
! re-calculate u and v.
u(1:ip,1:jp) = uh_new/(h_new)
v(1:ip,1:jp) = vh_new/h_new
h(1:ip,1:jp) = h_new
! do j=1,jp
! do i=1,ip
!
!
! enddo
! enddo
end subroutine lax_wendroff_sphere
!>@author
!>Paul J. Connolly, The University of Manchester
!>@brief
!>advects a scalar field on a ll grid
!>@param[in] ip: number of east-west points
!>@param[in] jp: ditto for north-south
!>@param[in] o_halo: halos required for advection scheme
!>@param[in] dt: timestep
!>@param[in] g: gravity
!>@param[inout] u,v,h: prognostic variables
!>@param[in] hs: surface height
!>@param[in] re: radius of planet
!>@param[in] theta: latitude
!>@param[in] thetan: latitude - staggered
!>@param[in] dtheta: latitude step
!>@param[in] dthetan: latitude step - staggered
!>@param[in] phi: phi
!>@param[in] phin: phin
!>@param[in] dphi: dphi
!>@param[in] dphin: dphin
!>@param[in] f_cor: Coriolis parameter
!>@param[in] recqdq - for efficiency
!>@param[in] recqdp - for efficiency
!>@param[in] recqdp_s - for efficiency
!>@param[in] recqdq_s - for efficiency
!>@param[in] redq_s - for efficiency
!>@param[in] redq - for efficiency
!>@param[in] cq - for efficiency
!>@param[in] cq_s - for efficiency
!>solves the 1-d advection equation:
!>\f$ \frac{\partial \psi}{\partial t} + \frac{\partial u \psi}{\partial x} = 0 \f$
subroutine lax_wendroff_ll(ip,jp,o_halo,dt,g,u,v,h,hs,re,&
theta,thetan,dtheta,dthetan, phi, phin, dphi, dphin, f_cor, &
recqdq, recqdp, recqdp_s, recqdq_s, redq_s, redq, cq, cq_s)
use numerics_type
implicit none
integer(i4b), intent(in) :: ip,jp,o_halo
real(wp), intent(in) :: dt, g, re
real(wp), intent(in), dimension(1-o_halo:ip+o_halo,1-o_halo:jp+o_halo) :: &
hs, f_cor, &
recqdq, recqdp, recqdp_s, recqdq_s, redq_s, redq, &
cq, cq_s
real(wp), dimension(1-o_halo:jp+o_halo), intent(in) :: &
theta,thetan, dtheta, dthetan
real(wp), dimension(1-o_halo:ip+o_halo), intent(in) :: &
phi, phin, dphi, dphin
real(wp), intent(inout), dimension(1-o_halo:ip+o_halo,1-o_halo:jp+o_halo) :: &
h, u, v
! local variables:
real(wp), dimension(1-o_halo:ip+o_halo,1-o_halo:jp+o_halo) :: &
dy1, v1, h1, vh, uh, vh1, Ux, Uy, Vx, Vy, Vy2
real(wp), dimension(1:ip,1:jp) :: &
uh_new, vh_new, h_new
real(wp), dimension(0:ip,1:jp) :: h_mid_xt, uh_mid_xt, Ux_mid_xt, Vx_mid_xt
real(wp), dimension(0:ip,1:jp) :: vh_mid_xt
real(wp), dimension(1:ip,0:jp) :: h_mid_yt, uh_mid_yt, vh_mid_yt, &
Uy_mid_yt, Vy_mid_yt, Vy_mid_yt2
integer(i4b) :: j, i
v1=v*cq ! cq=cos(theta)
h1=h*cq
uh=u *h
vh=v*h
vh1=v1*h
! continuity equation (calculate mid-point values at 0.5*dt):
h_mid_xt = 0.5_wp*(h(1:ip+1,1:jp)+h(0:ip,1:jp)) &
-(0.5_wp*dt/(recqdp_s(0:ip,1:jp))) &
*(uh(1:ip+1,1:jp)-uh(0:ip,1:jp))
h_mid_yt = 0.5_wp*(h(1:ip,1:jp+1)+h(1:ip,0:jp)) &
-(0.5_wp*dt/(recqdq_s(1:ip,0:jp))) &
*(vh1(1:ip,1:jp+1)-vh1(1:ip,0:jp))
! v-phi, or u momentum equation (calculate mid-point values at 0.5*dt):
Ux = uh*u + g*h**2*(0.5_wp)
Uy = uh*v1
uh_mid_xt(0:ip,:) = 0.5_wp*(uh(1:ip+1,1:jp)+uh(0:ip,1:jp)) &
-(0.5_wp*dt/(recqdp_s(0:ip,1:jp)))* &
(Ux(1:ip+1,1:jp)-Ux(0:ip,1:jp)) &
+0.125_wp*dt*(f_cor(1:ip+1,1:jp)+f_cor(0:ip,1:jp))* &
(vh(1:ip+1,1:jp)+vh(0:ip,1:jp))
uh_mid_yt = 0.5_wp*(uh(1:ip,1:jp+1)+uh(1:ip,0:jp)) &
-(0.5_wp*dt/(recqdq_s(1:ip,0:jp)))* &
(Uy(1:ip,1:jp+1)-Uy(1:ip,0:jp)) &
+0.125_wp*dt*(f_cor(1:ip,1:jp+1)+f_cor(1:ip,0:jp))* &
(vh(1:ip,1:jp+1)+vh(1:ip,0:jp))
! v-theta, or v momentum equation (calculate mid-point values at 0.5*dt):
Vx = uh*v
Vy = vh1*v
Vy2 = 0.5_wp*g*h**2
vh_mid_xt(0:ip,1:jp) = 0.5_wp*(vh(1:ip+1,1:jp)+vh(0:ip,1:jp)) &
-(0.5_wp*dt/(recqdp_s(0:ip,1:jp)))*(Vx(1:ip+1,1:jp)-Vx(0:ip,1:jp)) &
-0.125_wp*dt*(f_cor(1:ip+1,1:jp)+f_cor(0:ip,1:jp))*(uh(1:ip+1,1:jp)+uh(0:ip,1:jp))
vh_mid_yt(1:ip,0:jp) = 0.5_wp*(vh(1:ip,1:jp+1)+vh(1:ip,0:jp)) &
-(0.5_wp*dt/(recqdq_s(1:ip,0:jp)))*(Vy(1:ip,1:jp+1)-Vy(1:ip,0:jp)) &
-(0.5_wp*dt/(redq_s(1:ip,0:jp)))*(Vy2(1:ip,1:jp+1)-Vy2(1:ip,0:jp)) &
-0.125_wp*dt*(f_cor(1:ip,1:jp+1)+f_cor(1:ip,0:jp))*(uh(1:ip,1:jp+1)+uh(1:ip,0:jp))
! calculate mid-point value of cos (theta)
! c_mid_yt=cos(0.5.*(THETA(:,2:end)+THETA(:,1:end-1)));
!
!
! Now use the mid-point values to predict the values at the next timestep
! continuity:
h_new = h(1:ip,1:jp) &
- (dt/(recqdp(0:ip-1,1:jp)))*(uh_mid_xt(1:ip,1:jp)-uh_mid_xt(0:ip-1,1:jp)) &
- (dt/(recqdq(1:ip,0:jp-1))) * &
(vh_mid_yt(1:ip,1:jp)*cq_s(1:ip,1:jp)-vh_mid_yt(1:ip,0:jp-1)*cq_s(1:ip,0:jp-1))
! u-momentum equation:
Ux_mid_xt = uh_mid_xt*uh_mid_xt/h_mid_xt + 0.5_wp*g*h_mid_xt**2
Uy_mid_yt = uh_mid_yt*vh_mid_yt/h_mid_yt*cq_s(1:ip,0:jp)
uh_new = uh(1:ip,1:jp) &
- (dt/(recqdp(0:ip-1,1:jp)))* (Ux_mid_xt(1:ip,1:jp)-Ux_mid_xt(0:ip-1,1:jp)) &
- (dt/(recqdq(1:ip,0:jp-1)))*(Uy_mid_yt(1:ip,1:jp)-Uy_mid_yt(1:ip,0:jp-1))
! v-momentum equation:
Vx_mid_xt = uh_mid_xt*vh_mid_xt/h_mid_xt
Vy_mid_yt = vh_mid_yt*vh_mid_yt/h_mid_yt*cq_s(1:ip,0:jp)
Vy_mid_yt2 = 0.5_wp*g*h_mid_yt**2
vh_new = vh(1:ip,1:jp) &
- (dt/(recqdp(0:ip-1,1:jp)))*(Vx_mid_xt(1:ip,1:jp)-Vx_mid_xt(0:ip-1,1:jp)) &
- (dt/(recqdq(1:ip,0:jp-1)))*(Vy_mid_yt(1:ip,1:jp)-Vy_mid_yt(1:ip,0:jp-1)) &
- (dt/(redq(1:ip,0:jp-1) ))* &
(Vy_mid_yt2(1:ip,1:jp)-Vy_mid_yt2(1:ip,0:jp-1))
! add on Coriolis and contribution of orography to pressure gradient:
uh_new=uh_new +dt*.5_wp*(f_cor(1:ip,1:jp)*v(1:ip,1:jp) - &
g*(hs(2:ip+1,1:jp)-hs(0:ip-1,1:jp))/(recqdp(1:ip,1:jp)+recqdp(0:ip-1,1:jp)))* &
(h(1:ip,1:jp)+h_new)
vh_new=vh_new -dt*.5_wp*(f_cor(1:ip,1:jp)*u(1:ip,1:jp) + &
g*(hs(1:ip,2:jp+1)-hs(1:ip,0:jp-1))/(redq(1:ip,1:jp)+redq(1:ip,0:jp-1)))* &
(h(1:ip,1:jp)+h_new)
! re-calculate u and v.
u(1:ip,1:jp) = uh_new/(h_new)
v(1:ip,1:jp) = vh_new/h_new
h(1:ip,1:jp) = h_new
end subroutine lax_wendroff_ll
!>@author
!>Paul J. Connolly, The University of Manchester
!>@brief
!>calculates del2 of prognostic variable
!>@param[in] ip: number of east-west points
!>@param[in] jp: ditto for north-south
!>@param[in] o_halo: halos required for advection scheme
!>@param[in] dt: timestep
!>@param[in] f: prognostic variable
!>@param[inout] delsq: delsq of f
!>@param[in] re: radius of planet
!>@param[in] theta: latitude
!>@param[in] thetan: latitude - staggered
!>@param[in] dtheta: latitude step
!>@param[in] dthetan: latitude step - staggered
!>@param[in] phi: phi
!>@param[in] phin: phin
!>@param[in] dphi: dphi
!>@param[in] dphin: dphin
!>@param[in] recq: for efficiency
!>@param[in] cq_s: for efficiency
!>@param[in] dp1: for efficiency
!>@param[in] dq: for efficiency
!>calculates del**2:
!>\f$ visterm = \frac{1}{re^2\cos\theta}
!> \frac{\partial }{\partial \theta}
!>\left(\cos\theta\frac{\partial f}{\partial\theta} \right) +
!> \frac{1}{re^2\cos^2\theta}\frac{\partial^2 f}{\partial \phi ^2}\f$
subroutine dissipation(ip,jp,o_halo,dt,f,delsq,re,&
theta,thetan,dtheta,dthetan, phi, phin, dphi, dphin, &
recq, cq_s, dp1, dq)
use numerics_type
implicit none
integer(i4b), intent(in) :: ip,jp,o_halo
real(wp), intent(in) :: dt, re
real(wp), dimension(1-o_halo:jp+o_halo), intent(in) :: &
theta,thetan, dtheta, dthetan
real(wp), dimension(1-o_halo:ip+o_halo), intent(in) :: &
phi, phin, dphi, dphin
real(wp), intent(in), dimension(1-o_halo:ip+o_halo,1-o_halo:jp+o_halo) :: &
f, &
recq, cq_s, dp1, dq
real(wp), intent(inout), dimension(1:ip,1:jp) :: delsq
! local variables:
integer(i4b) :: j, i
! calculate del^2 using 2nd order difference
! (central difference of forward and backward):
delsq(1:ip,1:jp) =1._wp/(re*recq(1:ip,1:jp))* &
( cq_s(1:ip,1:jp)*(f(1:ip,2:jp+1)-f(1:ip,1:jp))/dq(1:ip,1:jp) - &
cq_s(1:ip,0:jp-1)*(f(1:ip,1:jp)-f(1:ip,0:jp-1))/dq(1:ip,0:jp-1) ) / &
dq(1:ip,1:jp)
delsq(1:ip,1:jp) = delsq(1:ip,1:jp) + &
1._wp/(recq(1:ip,1:jp)**2._wp)* &
( (f(2:ip+1,1:jp)-f(1:ip,1:jp))/dp1(1:ip,1:jp) - &
(f(1:ip,1:jp)-f(0:ip-1,1:jp))/dp1(1:ip,0:jp-1) ) / &
dp1(1:ip,1:jp)
end subroutine dissipation
!>@author
!>Paul J. Connolly, The University of Manchester
!>@brief
!>calculates smagorinsky-lilly viscosity
!>@param[in] ip: number of east-west points
!>@param[in] jp: ditto for north-south
!>@param[in] o_halo: halos required for advection scheme
!>@param[in] cvis: coefficient for viscosity
!>@param[in] u,v: u and v winds
!>@param[inout] vis: viscosity
!>@param[in] re: radius of planet
!>@param[in] recq: for efficiency
!>@param[in] dp1: for efficiency
!>@param[in] dq: for efficiency
!>calculates smagorinsky-lilly viscosity:
!>\f$ visco = C_s^2\Delta x\Delta y|S|\f$
subroutine smagorinsky(ip,jp,o_halo,cvis,u,v,vis,re,&
recq, dp1, dq)
use numerics_type
implicit none
integer(i4b), intent(in) :: ip,jp,o_halo
real(wp), intent(in) :: cvis, re
real(wp), intent(in), dimension(1-o_halo:ip+o_halo,1-o_halo:jp+o_halo) :: &
u,v, &
recq, dp1, dq
real(wp), intent(inout), dimension(1:ip,1:jp) :: vis
! local variables:
integer(i4b) :: j, i
! calculate viscosity using centred differences:
vis(1:ip,1:jp) = cvis**2._wp*re*recq(1:ip,1:jp)*dp1(1:ip,1:jp)*dq(1:ip,1:jp)* &
sqrt( ( (u(2:ip+1,1:jp)-u(0:ip-1,1:jp))/ &
(recq(1:ip,1:jp)*(dp1(0:ip-1,1:jp)+dp1(1:ip,1:jp))) )**2._wp + &
( (v(1:ip,2:jp+1)-v(1:ip,0:jp-1))/ &
(re*(dq(1:ip,1:jp)+dq(1:ip,0:jp-1))) )**2._wp + &
0.5_wp*( &
(u(1:ip,2:jp+1)-u(1:ip,0:jp-1))/ &
(re*(dq(1:ip,1:jp)+dq(1:ip,0:jp-1)))+ &
(v(2:ip+1,1:jp)-v(0:ip-1,1:jp))/ &
(recq(1:ip,1:jp)*(dp1(1:ip,1:jp)+dp1(0:ip-1,1:jp))) &
)**2._wp )
end subroutine smagorinsky
end module advection