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