/[MITgcm]/MITgcm/pkg/kpp/kpp_calc.F
ViewVC logotype

Contents of /MITgcm/pkg/kpp/kpp_calc.F

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


Revision 1.47 - (show annotations) (download)
Thu Dec 27 21:26:49 2007 UTC (17 years, 6 months ago) by dimitri
Branch: MAIN
CVS Tags: checkpoint60, checkpoint61, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59m, checkpoint59o, checkpoint59n, checkpoint61e, checkpoint61d, checkpoint61b, checkpoint61c, checkpoint61a
Changes since 1.46: +4 -3 lines
bug fixes for threaded version of salt_plume + kpp

1 C $Header: /u/gcmpack/MITgcm/pkg/kpp/kpp_calc.F,v 1.46 2007/12/21 02:54:34 atn Exp $
2 C $Name: $
3
4 #include "KPP_OPTIONS.h"
5
6 CBOP
7 C !ROUTINE: KPP_CALC
8
9 C !INTERFACE: ==========================================================
10 SUBROUTINE KPP_CALC(
11 I bi, bj, myTime, myIter, myThid )
12
13 C !DESCRIPTION: \bv
14 C *==========================================================*
15 C | SUBROUTINE KPP_CALC |
16 C | o Compute all KPP fields defined in KPP.h |
17 C *==========================================================*
18 C | This subroutine serves as an interface between MITGCMUV |
19 C | code and NCOM 1-D routines in kpp_routines.F |
20 C *==========================================================*
21 IMPLICIT NONE
22
23 c=======================================================================
24 c
25 c written by : jan morzel, august 11, 1994
26 c modified by : jan morzel, january 25, 1995 : "dVsq" and 1d code
27 c detlef stammer, august, 1997 : for MIT GCM Classic
28 c d. menemenlis, july, 1998 : for MIT GCM UV
29 c
30 c compute vertical mixing coefficients based on the k-profile
31 c and oceanic planetary boundary layer scheme by large & mcwilliams.
32 c
33 c summary:
34 c - compute interior mixing everywhere:
35 c interior mixing gets computed at all interfaces due to constant
36 c internal wave background activity ("fkpm" and "fkph"), which
37 c is enhanced in places of static instability (local richardson
38 c number < 0).
39 c Additionally, mixing can be enhanced by adding contribution due
40 c to shear instability which is a function of the local richardson
41 c number
42 c - double diffusivity:
43 c interior mixing can be enhanced by double diffusion due to salt
44 c fingering and diffusive convection (ifdef "kmixdd").
45 c - kpp scheme in the boundary layer:
46 c
47 c a.boundary layer depth:
48 c at every gridpoint the depth of the oceanic boundary layer
49 c ("hbl") gets computed by evaluating bulk richardson numbers.
50 c b.boundary layer mixing:
51 c within the boundary layer, above hbl, vertical mixing is
52 c determined by turbulent surface fluxes, and interior mixing at
53 c the lower boundary, i.e. at hbl.
54 c
55 c this subroutine provides the interface between the MITGCM and
56 c the routine "kppmix", where boundary layer depth, vertical
57 c viscosity, vertical diffusivity, and counter gradient term (ghat)
58 c are computed slabwise.
59 c note: subroutine "kppmix" uses m-k-s units.
60 c
61 c time level:
62 c input tracer and velocity profiles are evaluated at time level
63 c tau, surface fluxes come from tau or tau-1.
64 c
65 c grid option:
66 c in this "1-grid" implementation, diffusivity and viscosity
67 c profiles are computed on the "t-grid" (by using velocity shear
68 c profiles averaged from the "u,v-grid" onto the "t-grid"; note, that
69 c the averaging includes zero values on coastal and seafloor grid
70 c points). viscosity on the "u,v-grid" is computed by averaging the
71 c "t-grid" viscosity values onto the "u,v-grid".
72 c
73 c vertical grid:
74 c mixing coefficients get evaluated at the bottom of the lowest
75 c layer, i.e., at depth zw(Nr). these values are only useful when
76 c the model ocean domain does not include the entire ocean down to
77 c the seafloor ("upperocean" setup) and allows flux through the
78 c bottom of the domain. for full-depth runs, these mixing
79 c coefficients are being zeroed out before leaving this subroutine.
80 c
81 c-------------------------------------------------------------------------
82
83 c global parameters updated by kpp_calc
84 c KPPviscAz - KPP eddy viscosity coefficient (m^2/s)
85 c KPPdiffKzT - KPP diffusion coefficient for temperature (m^2/s)
86 c KPPdiffKzS - KPP diffusion coefficient for salt and tracers (m^2/s)
87 c KPPghat - Nonlocal transport coefficient (s/m^2)
88 c KPPhbl - Boundary layer depth on "t-grid" (m)
89 c KPPfrac - Fraction of short-wave flux penetrating mixing layer
90 c KPPplumefrac- Fraction of saltplume (flux) penetrating mixing layer
91
92 c-- KPP_CALC computes vertical viscosity and diffusivity for region
93 c (-2:sNx+3,-2:sNy+3) as required by CALC_DIFFUSIVITY and requires
94 c values of uVel, vVel, surfaceForcingU, surfaceForcingV in the
95 c region (-2:sNx+4,-2:sNy+4).
96 c Hence overlap region needs to be set OLx=4, OLy=4.
97 c \ev
98
99 C !USES: ===============================================================
100 #include "SIZE.h"
101 #include "EEPARAMS.h"
102 #include "PARAMS.h"
103 #include "DYNVARS.h"
104 #include "KPP.h"
105 #include "KPP_PARAMS.h"
106 #include "FFIELDS.h"
107 #include "GRID.h"
108 #include "GAD.h"
109 #ifdef ALLOW_SALT_PLUME
110 # include "SALT_PLUME.h"
111 #endif /* ALLOW_SALT_PLUME */
112 #ifdef ALLOW_SHELFICE
113 # include "SHELFICE.h"
114 #endif /* ALLOW_SHELFICE */
115 #ifdef ALLOW_AUTODIFF_TAMC
116 # include "tamc.h"
117 # include "tamc_keys.h"
118 #else /* ALLOW_AUTODIFF_TAMC */
119 integer ikppkey
120 #endif /* ALLOW_AUTODIFF_TAMC */
121
122 EXTERNAL DIFFERENT_MULTIPLE
123 LOGICAL DIFFERENT_MULTIPLE
124
125 C !INPUT PARAMETERS: ===================================================
126 c Routine arguments
127 c bi, bj :: Current tile indices
128 c myTime :: Current time in simulation
129 c myIter :: Current iteration number in simulation
130 c myThid :: My Thread Id. number
131
132 INTEGER bi, bj
133 _RL myTime
134 INTEGER myIter
135 INTEGER myThid
136
137 #ifdef ALLOW_KPP
138
139 C !LOCAL VARIABLES: ====================================================
140 c Local constants
141 c minusone, p0, p5, p25, p125, p0625
142 c imin, imax, jmin, jmax - array computation indices
143
144 _RL minusone
145 parameter( minusone=-1.0)
146 _RL p0 , p5 , p25 , p125 , p0625
147 parameter( p0=0.0, p5=0.5, p25=0.25, p125=0.125, p0625=0.0625 )
148 integer imin ,imax ,jmin ,jmax
149 parameter(imin=2-OLx,imax=sNx+OLx-1,jmin=2-OLy,jmax=sNy+OLy-1)
150
151 c Local arrays and variables
152 c work? (nx,ny) - horizontal working arrays
153 c ustar (nx,ny) - surface friction velocity (m/s)
154 c bo (nx,ny) - surface turbulent buoyancy forcing (m^2/s^3)
155 c bosol (nx,ny) - surface radiative buoyancy forcing (m^2/s^3)
156 c boplume(nx,ny) - surface haline buoyancy forcing (m^2/s^3)
157 c shsq (nx,ny,Nr) - local velocity shear squared
158 c at interfaces for ri_iwmix (m^2/s^2)
159 c dVsq (nx,ny,Nr) - velocity shear re surface squared
160 c at grid levels for bldepth (m^2/s^2)
161 c dbloc (nx,ny,Nr) - local delta buoyancy at interfaces
162 c for ri_iwmix and bldepth (m/s^2)
163 c Ritop (nx,ny,Nr) - numerator of bulk richardson number
164 c at grid levels for bldepth
165 c vddiff (nx,ny,Nrp2,1)- vertical viscosity on "t-grid" (m^2/s)
166 c vddiff (nx,ny,Nrp2,2)- vert. diff. on next row for salt&tracers (m^2/s)
167 c vddiff (nx,ny,Nrp2,3)- vert. diff. on next row for temperature (m^2/s)
168 c ghat (nx,ny,Nr) - nonlocal transport coefficient (s/m^2)
169 c hbl (nx,ny) - mixing layer depth (m)
170 c kmtj (nx,ny) - maximum number of wet levels in each column
171 c z0 (nx,ny) - Roughness length (m)
172 c zRef (nx,ny) - Reference depth: Hmix * epsilon (m)
173 c uRef (nx,ny) - Reference zonal velocity (m/s)
174 c vRef (nx,ny) - Reference meridional velocity (m/s)
175
176 integer work1 ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
177 _RL worka ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
178 _RL work2 ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
179 _RL work3 ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
180 _RL ustar ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
181 _RL bo ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
182 _RL bosol ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
183 #ifdef ALLOW_SALT_PLUME
184 _RL boplume ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
185 #endif /* ALLOW_SALT_PLUME */
186 _RL shsq ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
187 _RL dVsq ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
188 _RL dbloc ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
189 _RL Ritop ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
190 _RL vddiff( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, 0:Nrp1, mdiff )
191 _RL ghat ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
192 _RL hbl ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
193 cph(
194 _RL TTALPHA( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nrp1 )
195 _RL SSBETA ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nrp1 )
196 cph)
197 #ifdef KPP_ESTIMATE_UREF
198 _RL z0 ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
199 _RL zRef ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
200 _RL uRef ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
201 _RL vRef ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
202 #endif /* KPP_ESTIMATE_UREF */
203
204 _RL tempvar2
205 integer i, j, k, kp1, km1, im1, ip1, jm1, jp1
206
207 #ifdef KPP_ESTIMATE_UREF
208 _RL tempvar1, dBdz1, dBdz2, ustarX, ustarY
209 #endif
210
211 #ifdef ALLOW_AUTODIFF_TAMC
212 act1 = bi - myBxLo(myThid)
213 max1 = myBxHi(myThid) - myBxLo(myThid) + 1
214 act2 = bj - myByLo(myThid)
215 max2 = myByHi(myThid) - myByLo(myThid) + 1
216 act3 = myThid - 1
217 max3 = nTx*nTy
218 act4 = ikey_dynamics - 1
219 ikppkey = (act1 + 1) + act2*max1
220 & + act3*max1*max2
221 & + act4*max1*max2*max3
222 #endif /* ALLOW_AUTODIFF_TAMC */
223 CEOP
224
225 c Check to see if new vertical mixing coefficient should be computed now?
226 IF ( DIFFERENT_MULTIPLE(kpp_freq,myTime,deltaTClock)
227 1 .OR. myTime .EQ. startTime ) THEN
228
229 c-----------------------------------------------------------------------
230 c prepare input arrays for subroutine "kppmix" to compute
231 c viscosity and diffusivity and ghat.
232 c All input arrays need to be in m-k-s units.
233 c
234 c note: for the computation of the bulk richardson number in the
235 c "bldepth" subroutine, gradients of velocity and buoyancy are
236 c required at every depth. in the case of very fine vertical grids
237 c (thickness of top layer < 2m), the surface reference depth must
238 c be set to zref=epsilon/2*zgrid(k), and the reference value
239 c of velocity and buoyancy must be computed as vertical average
240 c between the surface and 2*zref. in the case of coarse vertical
241 c grids zref is zgrid(1)/2., and the surface reference value is
242 c simply the surface value at zgrid(1).
243 c-----------------------------------------------------------------------
244
245 c------------------------------------------------------------------------
246 c density related quantities
247 c --------------------------
248 c
249 c work2 - density of surface layer (kg/m^3)
250 c dbloc - local buoyancy gradient at Nr interfaces
251 c g/rho{k+1,k+1} * [ drho{k,k+1}-drho{k+1,k+1} ] (m/s^2)
252 c dbsfc (stored in Ritop to conserve stack memory)
253 c - buoyancy difference with respect to the surface
254 c g * [ drho{1,k}/rho{1,k} - drho{k,k}/rho{k,k} ] (m/s^2)
255 c ttalpha (stored in vddiff(:,:,:,1) to conserve stack memory)
256 c - thermal expansion coefficient without 1/rho factor
257 c d(rho{k,k})/d(T(k)) (kg/m^3/C)
258 c ssbeta (stored in vddiff(:,:,:,2) to conserve stack memory)
259 c - salt expansion coefficient without 1/rho factor
260 c d(rho{k,k})/d(S(k)) (kg/m^3/PSU)
261 c------------------------------------------------------------------------
262
263 CALL TIMER_START('STATEKPP [KPP_CALC]', myThid)
264 CALL STATEKPP(
265 O work2, dbloc, Ritop,
266 O TTALPHA, SSBETA,
267 I ikppkey, bi, bj, myThid )
268 CALL TIMER_STOP ('STATEKPP [KPP_CALC]', myThid)
269
270 DO k = 1, Nr
271 DO j = 1-OLy, sNy+OLy
272 DO i = 1-OLx, sNx+OLx
273 ghat(i,j,k) = dbloc(i,j,k)
274 ENDDO
275 ENDDO
276 ENDDO
277
278 #ifdef KPP_SMOOTH_DBLOC
279 c horizontally smooth dbloc with a 121 filter
280 c smooth dbloc stored in ghat to save space
281 c dbloc(k) is buoyancy gradientnote between k and k+1
282 c levels therefore k+1 mask must be used
283
284 DO k = 1, Nr-1
285 CALL SMOOTH_HORIZ (
286 I k+1, bi, bj,
287 U ghat (1-OLx,1-OLy,k),
288 I myThid )
289 ENDDO
290
291 #endif /* KPP_SMOOTH_DBLOC */
292
293 #ifdef KPP_SMOOTH_DENS
294 c horizontally smooth density related quantities with 121 filters
295 CALL SMOOTH_HORIZ (
296 I 1, bi, bj,
297 U work2,
298 I myThid )
299 DO k = 1, Nr
300 CALL SMOOTH_HORIZ (
301 I k+1, bi, bj,
302 U dbloc (1-OLx,1-OLy,k),
303 I myThid )
304 CALL SMOOTH_HORIZ (
305 I k, bi, bj,
306 U Ritop (1-OLx,1-OLy,k),
307 I myThid )
308 CALL SMOOTH_HORIZ (
309 I k, bi, bj,
310 U TTALPHA(1-OLx,1-OLy,k),
311 I myThid )
312 CALL SMOOTH_HORIZ (
313 I k, bi, bj,
314 U SSBETA(1-OLx,1-OLy,k),
315 I myThid )
316 ENDDO
317 #endif /* KPP_SMOOTH_DENS */
318
319 DO k = 1, Nr
320 km1 = max(1,k-1)
321 DO j = 1-OLy, sNy+OLy
322 DO i = 1-OLx, sNx+OLx
323
324 c zero out dbloc over land points (so that the convective
325 c part of the interior mixing can be diagnosed)
326 dbloc(i,j,k) = dbloc(i,j,k) * maskC(i,j,k,bi,bj)
327 & * maskC(i,j,km1,bi,bj)
328 ghat(i,j,k) = ghat(i,j,k) * maskC(i,j,k,bi,bj)
329 & * maskC(i,j,km1,bi,bj)
330 Ritop(i,j,k) = Ritop(i,j,k) * maskC(i,j,k,bi,bj)
331 & * maskC(i,j,km1,bi,bj)
332 if(k.eq.nzmax(i,j,bi,bj)) then
333 dbloc(i,j,k) = p0
334 ghat(i,j,k) = p0
335 Ritop(i,j,k) = p0
336 endif
337
338 c numerator of bulk richardson number on grid levels
339 c note: land and ocean bottom values need to be set to zero
340 c so that the subroutine "bldepth" works correctly
341 Ritop(i,j,k) = (zgrid(1)-zgrid(k)) * Ritop(i,j,k)
342
343 ENDDO
344 ENDDO
345 ENDDO
346
347 cph(
348 cph this avoids a single or double recomp./call of statekpp
349 CADJ store work2 = comlev1_kpp, key = ikppkey
350 #ifdef KPP_AUTODIFF_EXCESSIVE_STORE
351 CADJ store dbloc, Ritop, ghat = comlev1_kpp, key = ikppkey
352 CADJ store vddiff = comlev1_kpp, key = ikppkey
353 CADJ store TTALPHA, SSBETA = comlev1_kpp, key = ikppkey
354 #endif
355 cph)
356
357 CML#ifdef ALLOW_SHELFICE
358 CMLC For the pbl parameterisation to work underneath the ice shelves
359 CMLC it needs to know the surface (ice-ocean) fluxes. However, masking
360 CMLC and indexing problems make this part of the code not work
361 CMLC underneath the ice shelves and the following lines are only here
362 CMLC to remind me that this still needs to be sorted out.
363 CML shelfIceFac = 0. _d 0
364 CML IF ( useShelfIce ) selfIceFac = 1. _d 0
365 CML DO j = jmin, jmax
366 CML DO i = imin, imax
367 CML surfForcT = surfaceForcingT(i,j,bi,bj)
368 CML & + shelficeForcingT(i,j,bi,bj) * shelfIceFac
369 CML surfForcS = surfaceForcingS(i,j,bi,bj)
370 CML & + shelficeForcingS(i,j,bi,bj) * shelfIceFac
371 CML ENDDO
372 CML ENDDO
373 CML#endif /* ALLOW_SHELFICE */
374
375 c------------------------------------------------------------------------
376 c friction velocity, turbulent and radiative surface buoyancy forcing
377 c -------------------------------------------------------------------
378 c taux / rho = surfaceForcingU (N/m^2)
379 c tauy / rho = surfaceForcingV (N/m^2)
380 c ustar = sqrt( sqrt( taux^2 + tauy^2 ) / rho ) (m/s)
381 c bo = - g * ( alpha*surfaceForcingT +
382 c beta *surfaceForcingS ) / rho (m^2/s^3)
383 c bosol = - g * alpha * Qsw * drF(1) / rho (m^2/s^3)
384 c boplume = g * (beta * saltPlumeFlux/rhoConst ) /rho (m^2/s^3)
385 c------------------------------------------------------------------------
386 c velocity shear
387 c --------------
388 c Get velocity shear squared, averaged from "u,v-grid"
389 c onto "t-grid" (in (m/s)**2):
390 c dVsq(k)=(Uref-U(k))**2+(Vref-V(k))**2 at grid levels
391 c shsq(k)=(U(k)-U(k+1))**2+(V(k)-V(k+1))**2 at interfaces
392 c
393 c note: Vref can depend on the surface fluxes that is why we compute
394 c dVsq in the subroutine that does the surface related stuff
395 c (admittedly this is a bit messy)
396 c------------------------------------------------------------------------
397
398 CALL KPP_FORCING_SURF(
399 I work2, surfaceForcingU, surfaceForcingV,
400 I surfaceForcingT, surfaceForcingS, surfaceForcingTice,
401 I Qsw,
402 #ifdef ALLOW_SALT_PLUME
403 I saltPlumeFlux,
404 #endif /* ALLOW_SALT_PLUME */
405 I ttalpha, ssbeta,
406 O ustar, bo, bosol,
407 #ifdef ALLOW_SALT_PLUME
408 O boplume,
409 #endif /* ALLOW_SALT_PLUME */
410 O dVsq,
411 I ikppkey, iMin, iMax, jMin, jMax, bi, bj, myTime, myThid )
412
413 CMLcph(
414 CMLCADJ store ustar = comlev1_kpp, key = ikppkey
415 CMLcph)
416
417 c initialize arrays to zero
418 DO k = 1, Nr
419 DO j = 1-OLy, sNy+OLy
420 DO i = 1-OLx, sNx+OLx
421 shsq(i,j,k) = p0
422 ENDDO
423 ENDDO
424 ENDDO
425
426 c shsq computation
427 DO k = 1, Nrm1
428 kp1 = k + 1
429 DO j = jmin, jmax
430 jm1 = j - 1
431 jp1 = j + 1
432 DO i = imin, imax
433 im1 = i - 1
434 ip1 = i + 1
435 shsq(i,j,k) = p5 * (
436 & (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) *
437 & (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) +
438 & (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) *
439 & (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) +
440 & (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) *
441 & (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) +
442 & (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) *
443 & (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) )
444 #ifdef KPP_SMOOTH_SHSQ
445 shsq(i,j,k) = p5 * shsq(i,j,k) + p125 * (
446 & (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) *
447 & (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) +
448 & (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) *
449 & (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) +
450 & (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) *
451 & (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) +
452 & (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) *
453 & (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) +
454 & (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) *
455 & (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) +
456 & (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) *
457 & (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) +
458 & (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) *
459 & (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) +
460 & (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) *
461 & (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) )
462 #endif
463 ENDDO
464 ENDDO
465 ENDDO
466
467 cph(
468 #ifdef KPP_AUTODIFF_EXCESSIVE_STORE
469 CADJ store dvsq, shsq = comlev1_kpp, key = ikppkey
470 #endif
471 cph)
472
473 c-----------------------------------------------------------------------
474 c solve for viscosity, diffusivity, ghat, and hbl on "t-grid"
475 c-----------------------------------------------------------------------
476
477 c precompute background vertical diffusivities, which are needed for
478 c matching diffusivities at bottom of KPP PBL
479 CALL CALC_3D_DIFFUSIVITY(
480 I bi,bj,1-Olx,sNx+OLx,1-Oly,sNy+OLy,
481 I GAD_SALINITY, .FALSE., .FALSE.,
482 O KPPdiffKzS(1-Olx,1-Oly,1,bi,bj),
483 I myThid)
484 CALL CALC_3D_DIFFUSIVITY(
485 I bi,bj,1-Olx,sNx+OLx,1-Oly,sNy+OLy,
486 I GAD_TEMPERATURE, .FALSE., .FALSE.,
487 O KPPdiffKzT(1-Olx,1-Oly,1,bi,bj),
488 I myThid)
489
490 DO j = 1-OLy, sNy+OLy
491 DO i = 1-OLx, sNx+OLx
492 work1(i,j) = nzmax(i,j,bi,bj)
493 work2(i,j) = Fcori(i,j,bi,bj)
494 ENDDO
495 ENDDO
496 CALL TIMER_START('KPPMIX [KPP_CALC]', myThid)
497 CALL KPPMIX (
498 I work1, shsq, dVsq, ustar
499 I , maskC(1-Olx,1-Oly,1,bi,bj)
500 I , bo, bosol
501 #ifdef ALLOW_SALT_PLUME
502 I , boplume, SaltPlumeDepth(1-Olx,1-Oly,bi,bj)
503 #endif /* ALLOW_SALT_PLUME */
504 I , dbloc, Ritop, work2
505 I , KPPdiffKzS(1-Olx,1-Oly,1,bi,bj)
506 I , KPPdiffKzT(1-Olx,1-Oly,1,bi,bj)
507 I , ikppkey
508 O , vddiff
509 U , ghat
510 O , hbl
511 I , mytime, myIter, mythid )
512 CALL TIMER_STOP ('KPPMIX [KPP_CALC]', myThid)
513
514 c-----------------------------------------------------------------------
515 c zero out land values and transfer to global variables
516 c-----------------------------------------------------------------------
517
518 DO j = jmin, jmax
519 DO i = imin, imax
520 DO k = 1, Nr
521 km1 = max(1,k-1)
522 KPPviscAz(i,j,k,bi,bj) = vddiff(i,j,k-1,1) * maskC(i,j,k,bi,bj)
523 & * maskC(i,j,km1,bi,bj)
524 KPPdiffKzS(i,j,k,bi,bj)= vddiff(i,j,k-1,2) * maskC(i,j,k,bi,bj)
525 & * maskC(i,j,km1,bi,bj)
526 KPPdiffKzT(i,j,k,bi,bj)= vddiff(i,j,k-1,3) * maskC(i,j,k,bi,bj)
527 & * maskC(i,j,km1,bi,bj)
528 KPPghat(i,j,k,bi,bj) = ghat(i,j,k) * maskC(i,j,k,bi,bj)
529 & * maskC(i,j,km1,bi,bj)
530 ENDDO
531 k = 1
532 #ifdef ALLOW_SHELFICE
533 if ( useShelfIce ) k = kTopC(i,j,bi,bj)
534 #endif /* ALLOW_SHELFICE */
535 KPPhbl(i,j,bi,bj) = hbl(i,j) * maskC(i,j,k,bi,bj)
536
537 ENDDO
538 ENDDO
539
540 #ifdef KPP_SMOOTH_VISC
541 c horizontal smoothing of vertical viscosity
542 DO k = 1, Nr
543 CALL SMOOTH_HORIZ (
544 I k, bi, bj,
545 U KPPviscAz(1-OLx,1-OLy,k,bi,bj),
546 I myThid )
547 ENDDO
548 C jmc: No EXCH inside bi,bj loop !!!
549 c _EXCH_XYZ_R8(KPPviscAz , myThid )
550 #endif /* KPP_SMOOTH_VISC */
551
552 #ifdef KPP_SMOOTH_DIFF
553 c horizontal smoothing of vertical diffusivity
554 DO k = 1, Nr
555 CALL SMOOTH_HORIZ (
556 I k, bi, bj,
557 U KPPdiffKzS(1-OLx,1-OLy,k,bi,bj),
558 I myThid )
559 CALL SMOOTH_HORIZ (
560 I k, bi, bj,
561 U KPPdiffKzT(1-OLx,1-OLy,k,bi,bj),
562 I myThid )
563 ENDDO
564 #endif /* KPP_SMOOTH_DIFF */
565
566 cph(
567 cph crucial: this avoids full recomp./call of kppmix
568 CADJ store KPPhbl = comlev1_kpp, key = ikppkey
569 cph)
570
571 C Compute fraction of solar short-wave flux penetrating to
572 C the bottom of the mixing layer.
573 DO j=1-OLy,sNy+OLy
574 DO i=1-OLx,sNx+OLx
575 worka(i,j) = KPPhbl(i,j,bi,bj)
576 ENDDO
577 ENDDO
578 CALL SWFRAC(
579 I (sNx+2*OLx)*(sNy+2*OLy), minusone,
580 U worka,
581 I myTime, myIter, myThid )
582 DO j=1-OLy,sNy+OLy
583 DO i=1-OLx,sNx+OLx
584 KPPfrac(i,j,bi,bj) = worka(i,j)
585 ENDDO
586 ENDDO
587
588 #ifdef ALLOW_SALT_PLUME
589 C Compute fraction of saltplume (flux) penetrating to
590 C the bottom of the mixing layer.
591 IF ( useSALT_PLUME ) THEN
592 DO j=1-OLy,sNy+OLy
593 DO i=1-OLx,sNx+OLx
594 work2(i,j) = SaltPlumeDepth(i,j,bi,bj)
595 worka(i,j) = KPPhbl(i,j,bi,bj)
596 ENDDO
597 ENDDO
598 CALL SALT_PLUME_FRAC(
599 I (sNx+2*OLx)*(sNy+2*OLy), minusone, work2,
600 U worka,
601 I myTime, myIter, myThid )
602 DO j=1-OLy,sNy+OLy
603 DO i=1-OLx,sNx+OLx
604 KPPplumefrac(i,j,bi,bj) = worka(i,j)
605 ENDDO
606 ENDDO
607 ENDIF
608 #endif /* ALLOW_SALT_PLUME */
609
610 ENDIF
611
612 #endif /* ALLOW_KPP */
613
614 RETURN
615 END
616
617 SUBROUTINE KPP_CALC_DUMMY(
618 I bi, bj, myTime, myIter, myThid )
619 C *==========================================================*
620 C | SUBROUTINE KPP_CALC_DUMMY |
621 C | o Compute all KPP fields defined in KPP.h |
622 C | o Dummy routine for TAMC
623 C *==========================================================*
624 C | This subroutine serves as an interface between MITGCMUV |
625 C | code and NCOM 1-D routines in kpp_routines.F |
626 C *==========================================================*
627 IMPLICIT NONE
628
629 #include "SIZE.h"
630 #include "EEPARAMS.h"
631 #include "PARAMS.h"
632 #include "KPP.h"
633 #include "KPP_PARAMS.h"
634 #include "GRID.h"
635 #include "GAD.h"
636
637 c Routine arguments
638 c bi, bj :: Current tile indices
639 c myTime :: Current time in simulation
640 c myIter :: Current iteration number in simulation
641 c myThid :: My Thread Id. number
642
643 INTEGER bi, bj
644 _RL myTime
645 INTEGER myIter
646 INTEGER myThid
647
648 #ifdef ALLOW_KPP
649
650 c Local constants
651 integer i, j, k
652
653 DO j=1-OLy,sNy+OLy
654 DO i=1-OLx,sNx+OLx
655 KPPhbl (i,j,bi,bj) = 1.0
656 KPPfrac(i,j,bi,bj) = 0.0
657 #ifdef ALLOW_SALT_PLUME
658 KPPplumefrac(i,j,bi,bj) = 0.0
659 #endif /* ALLOW_SALT_PLUME */
660 DO k = 1,Nr
661 KPPghat (i,j,k,bi,bj) = 0.0
662 KPPviscAz (i,j,k,bi,bj) = viscAr
663 ENDDO
664 ENDDO
665 ENDDO
666
667 CALL CALC_3D_DIFFUSIVITY(
668 I bi,bj,1-Olx,sNx+OLx,1-Oly,sNy+OLy,
669 I GAD_SALINITY, .FALSE., .FALSE.,
670 O KPPdiffKzS(1-Olx,1-Oly,1,bi,bj),
671 I myThid)
672 CALL CALC_3D_DIFFUSIVITY(
673 I bi,bj,1-Olx,sNx+OLx,1-Oly,sNy+OLy,
674 I GAD_TEMPERATURE, .FALSE., .FALSE.,
675 O KPPdiffKzT(1-Olx,1-Oly,1,bi,bj),
676 I myThid)
677
678 #endif
679 RETURN
680 END

  ViewVC Help
Powered by ViewVC 1.1.22