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

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

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


Revision 1.13 - (hide annotations) (download)
Tue Nov 12 20:45:41 2002 UTC (22 years, 8 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint47e_post, checkpoint47c_post, checkpoint47d_pre, checkpoint47a_post, checkpoint47d_post, branch-exfmods-tag, checkpoint47b_post, checkpoint47
Branch point for: branch-exfmods-curt
Changes since 1.12: +21 -2 lines
Merging from release1_p8 branch:
Adding package parameters and hooks for new seaice package.

1 heimbach 1.13 C $Header: /u/gcmpack/MITgcm/pkg/kpp/kpp_calc.F,v 1.9.4.3 2002/11/11 21:59:05 heimbach Exp $
2 adcroft 1.9 C $Name: $
3 adcroft 1.1
4     #include "KPP_OPTIONS.h"
5    
6     subroutine KPP_CALC(
7     I bi, bj, myTime, myThid )
8     C /==========================================================\
9     C | SUBROUTINE KPP_CALC |
10     C | o Compute all KPP fields defined in KPP.h |
11     C |==========================================================|
12     C | This subroutine serves as an interface between MITGCMUV |
13     C | code and NCOM 1-D routines in kpp_routines.F |
14     C \==========================================================/
15     IMPLICIT NONE
16    
17     c=======================================================================
18     c
19     c written by : jan morzel, august 11, 1994
20     c modified by : jan morzel, january 25, 1995 : "dVsq" and 1d code
21     c detlef stammer, august, 1997 : for MIT GCM Classic
22     c d. menemenlis, july, 1998 : for MIT GCM UV
23     c
24     c compute vertical mixing coefficients based on the k-profile
25     c and oceanic planetary boundary layer scheme by large & mcwilliams.
26     c
27     c summary:
28     c - compute interior mixing everywhere:
29     c interior mixing gets computed at all interfaces due to constant
30     c internal wave background activity ("fkpm" and "fkph"), which
31     c is enhanced in places of static instability (local richardson
32     c number < 0).
33     c Additionally, mixing can be enhanced by adding contribution due
34     c to shear instability which is a function of the local richardson
35     c number
36     c - double diffusivity:
37     c interior mixing can be enhanced by double diffusion due to salt
38     c fingering and diffusive convection (ifdef "kmixdd").
39     c - kpp scheme in the boundary layer:
40     c
41     c a.boundary layer depth:
42     c at every gridpoint the depth of the oceanic boundary layer
43     c ("hbl") gets computed by evaluating bulk richardson numbers.
44     c b.boundary layer mixing:
45     c within the boundary layer, above hbl, vertical mixing is
46     c determined by turbulent surface fluxes, and interior mixing at
47     c the lower boundary, i.e. at hbl.
48     c
49     c this subroutine provides the interface between the MIT GCM UV and the
50     c subroutine "kppmix", where boundary layer depth, vertical
51     c viscosity, vertical diffusivity, and counter gradient term (ghat)
52     c are computed slabwise.
53     c note: subroutine "kppmix" uses m-k-s units.
54     c
55     c time level:
56     c input tracer and velocity profiles are evaluated at time level
57     c tau, surface fluxes come from tau or tau-1.
58     c
59     c grid option:
60     c in this "1-grid" implementation, diffusivity and viscosity
61     c profiles are computed on the "t-grid" (by using velocity shear
62     c profiles averaged from the "u,v-grid" onto the "t-grid"; note, that
63     c the averaging includes zero values on coastal and seafloor grid
64     c points). viscosity on the "u,v-grid" is computed by averaging the
65     c "t-grid" viscosity values onto the "u,v-grid".
66     c
67     c vertical grid:
68     c mixing coefficients get evaluated at the bottom of the lowest
69     c layer, i.e., at depth zw(Nr). these values are only useful when
70     c the model ocean domain does not include the entire ocean down to
71     c the seafloor ("upperocean" setup) and allows flux through the
72     c bottom of the domain. for full-depth runs, these mixing
73     c coefficients are being zeroed out before leaving this subroutine.
74     c
75     c-------------------------------------------------------------------------
76    
77     c global parameters updated by kpp_calc
78     c KPPviscAz - KPP eddy viscosity coefficient (m^2/s)
79     c KPPdiffKzT - KPP diffusion coefficient for temperature (m^2/s)
80     c KPPdiffKzS - KPP diffusion coefficient for salt and tracers (m^2/s)
81     c KPPghat - Nonlocal transport coefficient (s/m^2)
82     c KPPhbl - Boundary layer depth on "t-grid" (m)
83     c KPPfrac - Fraction of short-wave flux penetrating mixing layer
84    
85     c-- KPP_CALC computes vertical viscosity and diffusivity for region
86     c (-2:sNx+3,-2:sNy+3) as required by CALC_DIFFUSIVITY and requires
87 heimbach 1.2 c values of uVel, vVel, SurfaceTendencyU, SurfaceTendencyV in the
88     c region (-2:sNx+4,-2:sNy+4).
89 adcroft 1.1 c Hence overlap region needs to be set OLx=4, OLy=4.
90     c When option FRUGAL_KPP is used, computation in overlap regions
91     c is replaced with exchange calls hence reducing overlap requirements
92     c to OLx=1, OLy=1.
93    
94     #include "SIZE.h"
95     #include "EEPARAMS.h"
96     #include "PARAMS.h"
97     #include "DYNVARS.h"
98     #include "KPP.h"
99     #include "KPP_PARAMS.h"
100     #include "FFIELDS.h"
101     #include "GRID.h"
102    
103 heimbach 1.13 #ifdef ALLOW_SEAICE
104     #include "SEAICE_EXTERNAL.h"
105     #endif ALLOW_SEAICE
106    
107 adcroft 1.1 #ifdef ALLOW_AUTODIFF_TAMC
108     #include "tamc.h"
109     #include "tamc_keys.h"
110     #else /* ALLOW_AUTODIFF_TAMC */
111     integer ikey
112     #endif /* ALLOW_AUTODIFF_TAMC */
113    
114     EXTERNAL DIFFERENT_MULTIPLE
115     LOGICAL DIFFERENT_MULTIPLE
116    
117     c Routine arguments
118     c bi, bj - array indices on which to apply calculations
119     c myTime - Current time in simulation
120    
121     INTEGER bi, bj
122     INTEGER myThid
123     _RL myTime
124    
125     #ifdef ALLOW_KPP
126    
127 heimbach 1.4 c Local constants
128     c minusone, p0, p5, p25, p125, p0625
129     c imin, imax, jmin, jmax - array computation indices
130    
131     _RL minusone
132     parameter( minusone=-1.0)
133     _KPP_RL p0 , p5 , p25 , p125 , p0625
134     parameter( p0=0.0, p5=0.5, p25=0.25, p125=0.125, p0625=0.0625 )
135     integer imin , imax , jmin , jmax
136     #ifdef FRUGAL_KPP
137     parameter( imin=1 , imax=sNx , jmin=1 , jmax=sNy )
138     #else
139     parameter( imin=-2 , imax=sNx+3 , jmin=-2 , jmax=sNy+3 )
140     #endif
141    
142 adcroft 1.1 c Local arrays and variables
143     c work? (nx,ny) - horizontal working arrays
144     c ustar (nx,ny) - surface friction velocity (m/s)
145     c bo (nx,ny) - surface turbulent buoyancy forcing (m^2/s^3)
146     c bosol (nx,ny) - surface radiative buoyancy forcing (m^2/s^3)
147     c shsq (nx,ny,Nr) - local velocity shear squared
148     c at interfaces for ri_iwmix (m^2/s^2)
149     c dVsq (nx,ny,Nr) - velocity shear re surface squared
150     c at grid levels for bldepth (m^2/s^2)
151     c dbloc (nx,ny,Nr) - local delta buoyancy at interfaces
152     c for ri_iwmix and bldepth (m/s^2)
153     c Ritop (nx,ny,Nr) - numerator of bulk richardson number
154     c at grid levels for bldepth
155     c vddiff (nx,ny,Nrp2,1)- vertical viscosity on "t-grid" (m^2/s)
156     c vddiff (nx,ny,Nrp2,2)- vert. diff. on next row for temperature (m^2/s)
157     c vddiff (nx,ny,Nrp2,3)- vert. diff. on next row for salt&tracers (m^2/s)
158     c ghat (nx,ny,Nr) - nonlocal transport coefficient (s/m^2)
159     c hbl (nx,ny) - mixing layer depth (m)
160     c kmtj (nx,ny) - maximum number of wet levels in each column
161     c z0 (nx,ny) - Roughness length (m)
162     c zRef (nx,ny) - Reference depth: Hmix * epsilon (m)
163     c uRef (nx,ny) - Reference zonal velocity (m/s)
164     c vRef (nx,ny) - Reference meridional velocity (m/s)
165    
166 heimbach 1.4 _RL worka ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
167     integer work1 ( ibot:itop , jbot:jtop )
168     _KPP_RL work2 ( ibot:itop , jbot:jtop )
169 heimbach 1.11 _KPP_RL work3 ( ibot:itop , jbot:jtop )
170 heimbach 1.4 _KPP_RL ustar ( ibot:itop , jbot:jtop )
171     _KPP_RL bo ( ibot:itop , jbot:jtop )
172     _KPP_RL bosol ( ibot:itop , jbot:jtop )
173     _KPP_RL shsq ( ibot:itop , jbot:jtop , Nr )
174     _KPP_RL dVsq ( ibot:itop , jbot:jtop , Nr )
175     _KPP_RL dbloc ( ibot:itop , jbot:jtop , Nr )
176     _KPP_RL Ritop ( ibot:itop , jbot:jtop , Nr )
177     _KPP_RL vddiff( ibot:itop , jbot:jtop , 0:Nrp1, mdiff )
178     _KPP_RL ghat ( ibot:itop , jbot:jtop , Nr )
179     _KPP_RL hbl ( ibot:itop , jbot:jtop )
180 adcroft 1.1 #ifdef KPP_ESTIMATE_UREF
181 heimbach 1.4 _KPP_RL z0 ( ibot:itop , jbot:jtop )
182     _KPP_RL zRef ( ibot:itop , jbot:jtop )
183     _KPP_RL uRef ( ibot:itop , jbot:jtop )
184     _KPP_RL vRef ( ibot:itop , jbot:jtop )
185 adcroft 1.1 #endif /* KPP_ESTIMATE_UREF */
186    
187 heimbach 1.4 _KPP_RL tempvar1, tempvar2
188 adcroft 1.1 integer i, j, k, kp1, im1, ip1, jm1, jp1
189    
190     #ifdef KPP_ESTIMATE_UREF
191 heimbach 1.4 _KPP_RL dBdz1, dBdz2, ustarX, ustarY
192 adcroft 1.1 #endif
193    
194     c Check to see if new vertical mixing coefficient should be computed now?
195     IF ( DIFFERENT_MULTIPLE(kpp_freq,myTime,myTime-deltaTClock) .OR.
196     1 myTime .EQ. startTime ) THEN
197    
198     c-----------------------------------------------------------------------
199     c prepare input arrays for subroutine "kppmix" to compute
200     c viscosity and diffusivity and ghat.
201     c All input arrays need to be in m-k-s units.
202     c
203     c note: for the computation of the bulk richardson number in the
204     c "bldepth" subroutine, gradients of velocity and buoyancy are
205     c required at every depth. in the case of very fine vertical grids
206     c (thickness of top layer < 2m), the surface reference depth must
207     c be set to zref=epsilon/2*zgrid(k), and the reference value
208     c of velocity and buoyancy must be computed as vertical average
209     c between the surface and 2*zref. in the case of coarse vertical
210     c grids zref is zgrid(1)/2., and the surface reference value is
211     c simply the surface value at zgrid(1).
212     c-----------------------------------------------------------------------
213    
214     c------------------------------------------------------------------------
215     c density related quantities
216     c --------------------------
217     c
218     c work2 - density of surface layer (kg/m^3)
219     c dbloc - local buoyancy gradient at Nr interfaces
220     c g/rho{k+1,k+1} * [ drho{k,k+1}-drho{k+1,k+1} ] (m/s^2)
221     c dbsfc (stored in Ritop to conserve stack memory)
222     c - buoyancy difference with respect to the surface
223     c g * [ drho{1,k}/rho{1,k} - drho{k,k}/rho{k,k} ] (m/s^2)
224     c ttalpha (stored in vddiff(:,:,:,1) to conserve stack memory)
225     c - thermal expansion coefficient without 1/rho factor
226     c d(rho{k,k})/d(T(k)) (kg/m^3/C)
227     c ssbeta (stored in vddiff(:,:,:,2) to conserve stack memory)
228     c - salt expansion coefficient without 1/rho factor
229     c d(rho{k,k})/d(S(k)) (kg/m^3/PSU)
230     c------------------------------------------------------------------------
231    
232     CALL TIMER_START('STATEKPP [KPP_CALC]', myThid)
233     CALL STATEKPP(
234     I bi, bj, myThid
235     O , work2, dbloc, Ritop
236 heimbach 1.4 O , vddiff(ibot,jbot,1,1), vddiff(ibot,jbot,1,2)
237 adcroft 1.1 & )
238     CALL TIMER_STOP ('STATEKPP [KPP_CALC]', myThid)
239    
240     DO k = 1, Nr
241 heimbach 1.4 DO j = jbot, jtop
242     DO i = ibot, itop
243 adcroft 1.1 ghat(i,j,k) = dbloc(i,j,k)
244     ENDDO
245     ENDDO
246     ENDDO
247    
248 heimbach 1.4 #ifdef KPP_SMOOTH_DBLOC
249     c horizontally smooth dbloc with a 121 filter
250     c smooth dbloc stored in ghat to save space
251     c dbloc(k) is buoyancy gradientnote between k and k+1
252     c levels therefore k+1 mask must be used
253    
254     DO k = 1, Nr-1
255     CALL KPP_SMOOTH_HORIZ (
256     I k+1, bi, bj,
257     U ghat (ibot,jbot,k) )
258     ENDDO
259    
260 adcroft 1.1 #endif /* KPP_SMOOTH_DBLOC */
261    
262     #ifdef KPP_SMOOTH_DENS
263     c horizontally smooth density related quantities with 121 filters
264 heimbach 1.4 CALL KPP_SMOOTH_HORIZ (
265     I 1, bi, bj,
266     U work2 )
267 adcroft 1.1 DO k = 1, Nr
268 heimbach 1.4 CALL KPP_SMOOTH_HORIZ (
269     I k+1, bi, bj,
270     U dbloc (ibot,jbot,k) )
271     CALL KPP_SMOOTH_HORIZ (
272 adcroft 1.1 I k, bi, bj,
273 heimbach 1.4 U Ritop (ibot,jbot,k) )
274     CALL KPP_SMOOTH_HORIZ (
275 adcroft 1.1 I k, bi, bj,
276 heimbach 1.4 U vddiff(ibot,jbot,k,1) )
277     CALL KPP_SMOOTH_HORIZ (
278 adcroft 1.1 I k, bi, bj,
279 heimbach 1.4 U vddiff(ibot,jbot,k,2) )
280 adcroft 1.1 ENDDO
281     #endif /* KPP_SMOOTH_DENS */
282    
283     DO k = 1, Nr
284 heimbach 1.4 DO j = jbot, jtop
285     DO i = ibot, itop
286 adcroft 1.1
287     c zero out dbloc over land points (so that the convective
288     c part of the interior mixing can be diagnosed)
289     dbloc(i,j,k) = dbloc(i,j,k) * pMask(i,j,k,bi,bj)
290     ghat(i,j,k) = ghat(i,j,k) * pMask(i,j,k,bi,bj)
291     Ritop(i,j,k) = Ritop(i,j,k) * pMask(i,j,k,bi,bj)
292     if(k.eq.nzmax(i,j,bi,bj)) then
293     dbloc(i,j,k) = p0
294     ghat(i,j,k) = p0
295     Ritop(i,j,k) = p0
296     endif
297    
298     c numerator of bulk richardson number on grid levels
299     c note: land and ocean bottom values need to be set to zero
300     c so that the subroutine "bldepth" works correctly
301     Ritop(i,j,k) = (zgrid(1)-zgrid(k)) * Ritop(i,j,k)
302    
303     END DO
304     END DO
305     END DO
306    
307 heimbach 1.11 cph(
308     cph this avoids a single or double recomp./call of statekpp
309     CADJ store work2 = comlev1_kpp, key = ikey
310     #ifdef ALLOW_AUTODIFF_KPP_EXTENSIVE_STORE
311     CADJ store dbloc, Ritop, ghat = comlev1_kpp, key = ikey
312     CADJ store vddiff = comlev1_kpp, key = ikey
313     #endif
314     cph)
315    
316 adcroft 1.1 c------------------------------------------------------------------------
317     c friction velocity, turbulent and radiative surface buoyancy forcing
318     c -------------------------------------------------------------------
319 jmc 1.10 c taux / rho = SurfaceTendencyU * drF(1) (N/m^2)
320     c tauy / rho = SurfaceTendencyV * drF(1) (N/m^2)
321     c ustar = sqrt( sqrt( taux^2 + tauy^2 ) / rho ) (m/s)
322 heimbach 1.2 c bo = - g * ( alpha*SurfaceTendencyT +
323 jmc 1.10 c beta *SurfaceTendencyS ) * drF(1) / rho (m^2/s^3)
324     c bosol = - g * alpha * Qsw * drF(1) / rho (m^2/s^3)
325 adcroft 1.1 c------------------------------------------------------------------------
326    
327 heimbach 1.4 c initialize arrays to zero
328     DO j = jbot, jtop
329     DO i = ibot, itop
330     ustar(i,j) = p0
331     bo (I,J) = p0
332     bosol(I,J) = p0
333     END DO
334     END DO
335    
336 adcroft 1.1 DO j = jmin, jmax
337 heimbach 1.2 jp1 = j + 1
338     DO i = imin, imax
339     ip1 = i+1
340 heimbach 1.11 work3(i,j) =
341 heimbach 1.2 & (SurfaceTendencyU(i,j,bi,bj) + SurfaceTendencyU(ip1,j,bi,bj)) *
342     & (SurfaceTendencyU(i,j,bi,bj) + SurfaceTendencyU(ip1,j,bi,bj)) +
343     & (SurfaceTendencyV(i,j,bi,bj) + SurfaceTendencyV(i,jp1,bi,bj)) *
344     & (SurfaceTendencyV(i,j,bi,bj) + SurfaceTendencyV(i,jp1,bi,bj))
345 heimbach 1.11 END DO
346     END DO
347     cph(
348     CADJ store work3 = comlev1_kpp, key = ikey
349     cph)
350     DO j = jmin, jmax
351     jp1 = j + 1
352     DO i = imin, imax
353     ip1 = i+1
354 heimbach 1.13
355 heimbach 1.11 if ( work3(i,j) .lt. (phepsi*phepsi) ) then
356 jmc 1.10 ustar(i,j) = SQRT( phepsi * p5 * drF(1) )
357 heimbach 1.2 else
358 heimbach 1.11 tempVar2 = SQRT( work3(i,j) ) * p5 * drF(1)
359 heimbach 1.4 ustar(i,j) = SQRT( tempVar2 )
360 heimbach 1.2 endif
361 heimbach 1.13
362     if ( .NOT. useSEAICE )
363     & bo(I,J) = - gravity *
364 heimbach 1.2 & ( vddiff(I,J,1,1) * SurfaceTendencyT(i,j,bi,bj) +
365     & vddiff(I,J,1,2) * SurfaceTendencyS(i,j,bi,bj)
366     & ) *
367 jmc 1.10 & drF(1) / work2(I,J)
368 heimbach 1.13
369     #ifdef ALLOW_SEAICE
370     if ( useSEAICE )
371     & bo(I,J) = - gravity *
372     & ( vddiff(I,J,1,1) * (SurfaceTendencyT(i,j,bi,bj)+
373     & SurfaceTendencyTice(i,j,bi,bj)) +
374     & vddiff(I,J,1,2) * SurfaceTendencyS(i,j,bi,bj)
375     & ) *
376     & drF(1) / work2(I,J)
377     #endif ALLOW_SEAICE
378    
379 adcroft 1.5 bosol(I,J) = gravity * vddiff(I,J,1,1) * Qsw(i,j,bi,bj) *
380 mlosch 1.12 & recip_Cp*recip_rhoConst*recip_dRf(1) *
381 jmc 1.10 & drF(1) / work2(I,J)
382 heimbach 1.13
383 heimbach 1.2 END DO
384 adcroft 1.1 END DO
385    
386 heimbach 1.11 cph(
387     CADJ store ustar = comlev1_kpp, key = ikey
388     cph)
389    
390 adcroft 1.1 c------------------------------------------------------------------------
391     c velocity shear
392     c --------------
393     c Get velocity shear squared, averaged from "u,v-grid"
394     c onto "t-grid" (in (m/s)**2):
395     c dVsq(k)=(Uref-U(k))**2+(Vref-V(k))**2 at grid levels
396     c shsq(k)=(U(k)-U(k+1))**2+(V(k)-V(k+1))**2 at interfaces
397     c------------------------------------------------------------------------
398    
399 heimbach 1.4 c initialize arrays to zero
400     DO k = 1, Nr
401     DO j = jbot, jtop
402     DO i = ibot, itop
403     shsq(i,j,k) = p0
404     dVsq(i,j,k) = p0
405     END DO
406     END DO
407     END DO
408    
409 adcroft 1.1 c dVsq computation
410    
411     #ifdef KPP_ESTIMATE_UREF
412    
413     c Get rid of vertical resolution dependence of dVsq term by
414     c estimating a surface velocity that is independent of first level
415     c thickness in the model. First determine mixed layer depth hMix.
416     c Second zRef = espilon * hMix. Third determine roughness length
417     c scale z0. Third estimate reference velocity.
418    
419     DO j = jmin, jmax
420     jp1 = j + 1
421     DO i = imin, imax
422     ip1 = i + 1
423    
424     c Determine mixed layer depth hMix as the shallowest depth at which
425     c dB/dz exceeds 5.2e-5 s^-2.
426     work1(i,j) = nzmax(i,j,bi,bj)
427     DO k = 1, Nr
428     IF ( k .LT. nzmax(i,j,bi,bj) .AND.
429     & dbloc(i,j,k) / drC(k+1) .GT. dB_dz )
430     & work1(i,j) = k
431     END DO
432    
433     c Linearly interpolate to find hMix.
434     k = work1(i,j)
435     IF ( k .EQ. 0 .OR. nzmax(i,j,bi,bj) .EQ. 1 ) THEN
436     zRef(i,j) = p0
437     ELSEIF ( k .EQ. 1) THEN
438     dBdz2 = dbloc(i,j,1) / drC(2)
439     zRef(i,j) = drF(1) * dB_dz / dBdz2
440     ELSEIF ( k .LT. nzmax(i,j,bi,bj) ) THEN
441     dBdz1 = dbloc(i,j,k-1) / drC(k )
442     dBdz2 = dbloc(i,j,k ) / drC(k+1)
443     zRef(i,j) = rF(k) + drF(k) * (dB_dz - dBdz1) /
444     & MAX ( phepsi, dBdz2 - dBdz1 )
445     ELSE
446     zRef(i,j) = rF(k+1)
447     ENDIF
448    
449     c Compute roughness length scale z0 subject to 0 < z0
450 heimbach 1.4 tempVar1 = p5 * (
451 adcroft 1.1 & (uVel(i, j, 1,bi,bj)-uVel(i, j, 2,bi,bj)) *
452     & (uVel(i, j, 1,bi,bj)-uVel(i, j, 2,bi,bj)) +
453     & (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, 2,bi,bj)) *
454     & (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, 2,bi,bj)) +
455     & (vVel(i, j, 1,bi,bj)-vVel(i, j, 2,bi,bj)) *
456     & (vVel(i, j, 1,bi,bj)-vVel(i, j, 2,bi,bj)) +
457     & (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,2,bi,bj)) *
458 heimbach 1.2 & (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,2,bi,bj)) )
459 heimbach 1.4 if ( tempVar1 .lt. (epsln*epsln) ) then
460     tempVar2 = epsln
461 heimbach 1.2 else
462 heimbach 1.4 tempVar2 = SQRT ( tempVar1 )
463 heimbach 1.2 endif
464 adcroft 1.1 z0(i,j) = rF(2) *
465     & ( rF(3) * LOG ( rF(3) / rF(2) ) /
466     & ( rF(3) - rF(2) ) -
467 heimbach 1.4 & tempVar2 * vonK /
468 adcroft 1.1 & MAX ( ustar(i,j), phepsi ) )
469     z0(i,j) = MAX ( z0(i,j), phepsi )
470    
471     c zRef is set to 0.1 * hMix subject to z0 <= zRef <= drF(1)
472     zRef(i,j) = MAX ( epsilon * zRef(i,j), z0(i,j) )
473     zRef(i,j) = MIN ( zRef(i,j), drF(1) )
474    
475     c Estimate reference velocity uRef and vRef.
476     uRef(i,j) = p5 *
477     & ( uVel(i,j,1,bi,bj) + uVel(ip1,j,1,bi,bj) )
478     vRef(i,j) = p5 *
479     & ( vVel(i,j,1,bi,bj) + vVel(i,jp1,1,bi,bj) )
480     IF ( zRef(i,j) .LT. drF(1) ) THEN
481 heimbach 1.2 ustarX = ( SurfaceTendencyU(i, j,bi,bj) +
482     & SurfaceTendencyU(ip1,j,bi,bj) ) * p5
483     ustarY = ( SurfaceTendencyV(i,j, bi,bj) +
484     & SurfaceTendencyU(i,jp1,bi,bj) ) * p5
485 heimbach 1.4 tempVar1 = ustarX * ustarX + ustarY * ustarY
486     if ( tempVar1 .lt. (epsln*epsln) ) then
487     tempVar2 = epsln
488 heimbach 1.2 else
489 heimbach 1.4 tempVar2 = SQRT ( tempVar1 )
490 heimbach 1.2 endif
491 heimbach 1.4 tempVar2 = ustar(i,j) *
492 adcroft 1.1 & ( LOG ( zRef(i,j) / rF(2) ) +
493     & z0(i,j) / zRef(i,j) - z0(i,j) / rF(2) ) /
494 heimbach 1.4 & vonK / tempVar2
495     uRef(i,j) = uRef(i,j) + ustarX * tempVar2
496     vRef(i,j) = vRef(i,j) + ustarY * tempVar2
497 adcroft 1.1 ENDIF
498    
499     END DO
500     END DO
501    
502     DO k = 1, Nr
503     DO j = jmin, jmax
504     jm1 = j - 1
505     jp1 = j + 1
506     DO i = imin, imax
507     im1 = i - 1
508     ip1 = i + 1
509     dVsq(i,j,k) = p5 * (
510     $ (uRef(i,j) - uVel(i, j, k,bi,bj)) *
511     $ (uRef(i,j) - uVel(i, j, k,bi,bj)) +
512     $ (uRef(i,j) - uVel(ip1,j, k,bi,bj)) *
513     $ (uRef(i,j) - uVel(ip1,j, k,bi,bj)) +
514     $ (vRef(i,j) - vVel(i, j, k,bi,bj)) *
515     $ (vRef(i,j) - vVel(i, j, k,bi,bj)) +
516     $ (vRef(i,j) - vVel(i, jp1,k,bi,bj)) *
517     $ (vRef(i,j) - vVel(i, jp1,k,bi,bj)) )
518     #ifdef KPP_SMOOTH_DVSQ
519     dVsq(i,j,k) = p5 * dVsq(i,j,k) + p125 * (
520     $ (uRef(i,j) - uVel(i, jm1,k,bi,bj)) *
521     $ (uRef(i,j) - uVel(i, jm1,k,bi,bj)) +
522     $ (uRef(i,j) - uVel(ip1,jm1,k,bi,bj)) *
523     $ (uRef(i,j) - uVel(ip1,jm1,k,bi,bj)) +
524     $ (uRef(i,j) - uVel(i, jp1,k,bi,bj)) *
525     $ (uRef(i,j) - uVel(i, jp1,k,bi,bj)) +
526     $ (uRef(i,j) - uVel(ip1,jp1,k,bi,bj)) *
527     $ (uRef(i,j) - uVel(ip1,jp1,k,bi,bj)) +
528     $ (vRef(i,j) - vVel(im1,j, k,bi,bj)) *
529     $ (vRef(i,j) - vVel(im1,j, k,bi,bj)) +
530     $ (vRef(i,j) - vVel(im1,jp1,k,bi,bj)) *
531     $ (vRef(i,j) - vVel(im1,jp1,k,bi,bj)) +
532     $ (vRef(i,j) - vVel(ip1,j, k,bi,bj)) *
533     $ (vRef(i,j) - vVel(ip1,j, k,bi,bj)) +
534     $ (vRef(i,j) - vVel(ip1,jp1,k,bi,bj)) *
535     $ (vRef(i,j) - vVel(ip1,jp1,k,bi,bj)) )
536     #endif /* KPP_SMOOTH_DVSQ */
537     END DO
538     END DO
539     END DO
540    
541     #else /* KPP_ESTIMATE_UREF */
542    
543     DO k = 1, Nr
544     DO j = jmin, jmax
545     jm1 = j - 1
546     jp1 = j + 1
547     DO i = imin, imax
548     im1 = i - 1
549     ip1 = i + 1
550     dVsq(i,j,k) = p5 * (
551     $ (uVel(i, j, 1,bi,bj)-uVel(i, j, k,bi,bj)) *
552     $ (uVel(i, j, 1,bi,bj)-uVel(i, j, k,bi,bj)) +
553     $ (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, k,bi,bj)) *
554     $ (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, k,bi,bj)) +
555     $ (vVel(i, j, 1,bi,bj)-vVel(i, j, k,bi,bj)) *
556     $ (vVel(i, j, 1,bi,bj)-vVel(i, j, k,bi,bj)) +
557     $ (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,k,bi,bj)) *
558     $ (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,k,bi,bj)) )
559     #ifdef KPP_SMOOTH_DVSQ
560     dVsq(i,j,k) = p5 * dVsq(i,j,k) + p125 * (
561     $ (uVel(i, jm1,1,bi,bj)-uVel(i, jm1,k,bi,bj)) *
562     $ (uVel(i, jm1,1,bi,bj)-uVel(i, jm1,k,bi,bj)) +
563     $ (uVel(ip1,jm1,1,bi,bj)-uVel(ip1,jm1,k,bi,bj)) *
564     $ (uVel(ip1,jm1,1,bi,bj)-uVel(ip1,jm1,k,bi,bj)) +
565     $ (uVel(i, jp1,1,bi,bj)-uVel(i, jp1,k,bi,bj)) *
566     $ (uVel(i, jp1,1,bi,bj)-uVel(i, jp1,k,bi,bj)) +
567     $ (uVel(ip1,jp1,1,bi,bj)-uVel(ip1,jp1,k,bi,bj)) *
568     $ (uVel(ip1,jp1,1,bi,bj)-uVel(ip1,jp1,k,bi,bj)) +
569     $ (vVel(im1,j, 1,bi,bj)-vVel(im1,j, k,bi,bj)) *
570     $ (vVel(im1,j, 1,bi,bj)-vVel(im1,j, k,bi,bj)) +
571     $ (vVel(im1,jp1,1,bi,bj)-vVel(im1,jp1,k,bi,bj)) *
572     $ (vVel(im1,jp1,1,bi,bj)-vVel(im1,jp1,k,bi,bj)) +
573     $ (vVel(ip1,j, 1,bi,bj)-vVel(ip1,j, k,bi,bj)) *
574     $ (vVel(ip1,j, 1,bi,bj)-vVel(ip1,j, k,bi,bj)) +
575     $ (vVel(ip1,jp1,1,bi,bj)-vVel(ip1,jp1,k,bi,bj)) *
576     $ (vVel(ip1,jp1,1,bi,bj)-vVel(ip1,jp1,k,bi,bj)) )
577     #endif /* KPP_SMOOTH_DVSQ */
578     END DO
579     END DO
580     END DO
581    
582     #endif /* KPP_ESTIMATE_UREF */
583    
584     c shsq computation
585     DO k = 1, Nrm1
586     kp1 = k + 1
587     DO j = jmin, jmax
588     jm1 = j - 1
589     jp1 = j + 1
590     DO i = imin, imax
591     im1 = i - 1
592     ip1 = i + 1
593     shsq(i,j,k) = p5 * (
594     $ (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) *
595     $ (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) +
596     $ (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) *
597     $ (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) +
598     $ (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) *
599     $ (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) +
600     $ (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) *
601     $ (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) )
602     #ifdef KPP_SMOOTH_SHSQ
603     shsq(i,j,k) = p5 * shsq(i,j,k) + p125 * (
604     $ (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) *
605     $ (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) +
606     $ (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) *
607     $ (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) +
608     $ (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) *
609     $ (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) +
610     $ (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) *
611     $ (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) +
612     $ (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) *
613     $ (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) +
614     $ (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) *
615     $ (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) +
616     $ (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) *
617     $ (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) +
618     $ (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) *
619     $ (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) )
620     #endif
621     END DO
622     END DO
623     END DO
624    
625 heimbach 1.11 cph(
626     #ifdef ALLOW_AUTODIFF_KPP_EXTENSIVE_STORE
627     CADJ store dvsq, shsq = comlev1_kpp, key = ikey
628     #endif
629     cph)
630    
631 adcroft 1.1 c-----------------------------------------------------------------------
632     c solve for viscosity, diffusivity, ghat, and hbl on "t-grid"
633     c-----------------------------------------------------------------------
634    
635 heimbach 1.4 DO j = jbot, jtop
636     DO i = ibot, itop
637 adcroft 1.1 work1(i,j) = nzmax(i,j,bi,bj)
638     work2(i,j) = Fcori(i,j,bi,bj)
639     END DO
640     END DO
641     CALL TIMER_START('KPPMIX [KPP_CALC]', myThid)
642     CALL KPPMIX (
643 heimbach 1.4 I mytime, mythid
644     I , work1, shsq, dVsq, ustar
645 adcroft 1.1 I , bo, bosol, dbloc, Ritop, work2
646     I , ikey
647     O , vddiff
648     U , ghat
649 heimbach 1.4 O , hbl )
650 adcroft 1.1
651     CALL TIMER_STOP ('KPPMIX [KPP_CALC]', myThid)
652    
653     c-----------------------------------------------------------------------
654 heimbach 1.4 c zero out land values and transfer to global variables
655 adcroft 1.1 c-----------------------------------------------------------------------
656    
657     DO j = jmin, jmax
658 heimbach 1.4 DO i = imin, imax
659     DO k = 1, Nr
660     KPPviscAz(i,j,k,bi,bj) = vddiff(i,j,k-1,1) * pMask(i,j,k,bi,bj)
661     KPPdiffKzS(i,j,k,bi,bj)= vddiff(i,j,k-1,2) * pMask(i,j,k,bi,bj)
662     KPPdiffKzT(i,j,k,bi,bj)= vddiff(i,j,k-1,3) * pMask(i,j,k,bi,bj)
663     KPPghat(i,j,k,bi,bj) = ghat(i,j,k) * pMask(i,j,k,bi,bj)
664     END DO
665     KPPhbl(i,j,bi,bj) = hbl(i,j) * pMask(i,j,1,bi,bj)
666     END DO
667 adcroft 1.1 END DO
668     #ifdef FRUGAL_KPP
669     _EXCH_XYZ_R8(KPPviscAz , myThid )
670     _EXCH_XYZ_R8(KPPdiffKzS , myThid )
671     _EXCH_XYZ_R8(KPPdiffKzT , myThid )
672     _EXCH_XYZ_R8(KPPghat , myThid )
673     _EXCH_XY_R8 (KPPhbl , myThid )
674     #endif
675    
676     #ifdef KPP_SMOOTH_VISC
677     c horizontal smoothing of vertical viscosity
678     DO k = 1, Nr
679 heimbach 1.4 CALL SMOOTH_HORIZ (
680 adcroft 1.1 I k, bi, bj,
681 heimbach 1.4 U KPPviscAz(1-OLx,1-OLy,k,bi,bj) )
682 adcroft 1.1 END DO
683 heimbach 1.4 _EXCH_XYZ_R8(KPPviscAz , myThid )
684 adcroft 1.1 #endif /* KPP_SMOOTH_VISC */
685    
686     #ifdef KPP_SMOOTH_DIFF
687     c horizontal smoothing of vertical diffusivity
688     DO k = 1, Nr
689 heimbach 1.4 CALL SMOOTH_HORIZ (
690 adcroft 1.1 I k, bi, bj,
691 heimbach 1.4 U KPPdiffKzS(1-OLx,1-OLy,k,bi,bj) )
692     CALL SMOOTH_HORIZ (
693 adcroft 1.1 I k, bi, bj,
694 heimbach 1.4 U KPPdiffKzT(1-OLx,1-OLy,k,bi,bj) )
695 adcroft 1.1 END DO
696 heimbach 1.4 _EXCH_XYZ_R8(KPPdiffKzS , myThid )
697     _EXCH_XYZ_R8(KPPdiffKzT , myThid )
698 adcroft 1.1 #endif /* KPP_SMOOTH_DIFF */
699 heimbach 1.11
700     cph(
701     cph crucial: this avoids full recomp./call of kppmix
702     CADJ store KPPhbl = comlev1_kpp, key = ikey
703     cph)
704 adcroft 1.1
705     C Compute fraction of solar short-wave flux penetrating to
706     C the bottom of the mixing layer.
707     DO j=1-OLy,sNy+OLy
708     DO i=1-OLx,sNx+OLx
709     worka(i,j) = KPPhbl(i,j,bi,bj)
710     ENDDO
711     ENDDO
712     CALL SWFRAC(
713 heimbach 1.4 I (sNx+2*OLx)*(sNy+2*OLy), minusone,
714     I mytime, mythid,
715     U worka )
716 adcroft 1.1 DO j=1-OLy,sNy+OLy
717     DO i=1-OLx,sNx+OLx
718 heimbach 1.4 KPPfrac(i,j,bi,bj) = worka(i,j)
719 adcroft 1.1 ENDDO
720     ENDDO
721    
722     ENDIF
723    
724 adcroft 1.9 #endif /* ALLOW_KPP */
725 adcroft 1.1
726 heimbach 1.8 RETURN
727     END
728    
729     subroutine KPP_CALC_DUMMY(
730     I bi, bj, myTime, myThid )
731     C /==========================================================\
732     C | SUBROUTINE KPP_CALC_DUMMY |
733     C | o Compute all KPP fields defined in KPP.h |
734     C | o Dummy routine for TAMC
735     C |==========================================================|
736     C | This subroutine serves as an interface between MITGCMUV |
737     C | code and NCOM 1-D routines in kpp_routines.F |
738     C \==========================================================/
739     IMPLICIT NONE
740    
741     #include "SIZE.h"
742     #include "EEPARAMS.h"
743     #include "PARAMS.h"
744     #include "KPP.h"
745     #include "KPP_PARAMS.h"
746     #include "GRID.h"
747    
748     c Routine arguments
749     c bi, bj - array indices on which to apply calculations
750     c myTime - Current time in simulation
751    
752     INTEGER bi, bj
753     INTEGER myThid
754     _RL myTime
755    
756     #ifdef ALLOW_KPP
757    
758     c Local constants
759     integer i, j, k
760    
761     DO j=1-OLy,sNy+OLy
762     DO i=1-OLx,sNx+OLx
763     KPPhbl (i,j,bi,bj) = 1.0
764     KPPfrac(i,j,bi,bj) = 0.0
765     DO k = 1,Nr
766     KPPghat (i,j,k,bi,bj) = 0.0
767     KPPviscAz (i,j,k,bi,bj) = viscAz
768     KPPdiffKzT(i,j,k,bi,bj) = diffKzT
769     KPPdiffKzS(i,j,k,bi,bj) = diffKzS
770     ENDDO
771     ENDDO
772     ENDDO
773    
774     #endif
775 adcroft 1.1 RETURN
776     END

  ViewVC Help
Powered by ViewVC 1.1.22