/[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.10 - (hide annotations) (download)
Thu Mar 7 14:27:47 2002 UTC (22 years, 3 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint45d_post, checkpoint44h_pre, checkpoint45a_post, checkpoint45b_post, checkpoint45c_post, checkpoint44h_post, checkpoint45
Changes since 1.9: +10 -10 lines
o vertical grid : use model standard arrays (drF,drC,rF,rC) instead of delZ.
  kpp is now compatible with new options (delR,delRc in file "data").
  This does not change the results nor the possibility to specify delZ in
  file "data";

1 jmc 1.10 C $Header: /u/gcmpack/MITgcm/pkg/kpp/kpp_calc.F,v 1.9 2001/09/27 18:08:57 adcroft 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     #ifdef ALLOW_AUTODIFF_TAMC
104     #include "tamc.h"
105     #include "tamc_keys.h"
106     #else /* ALLOW_AUTODIFF_TAMC */
107     integer ikey
108     #endif /* ALLOW_AUTODIFF_TAMC */
109    
110     EXTERNAL DIFFERENT_MULTIPLE
111     LOGICAL DIFFERENT_MULTIPLE
112    
113     c Routine arguments
114     c bi, bj - array indices on which to apply calculations
115     c myTime - Current time in simulation
116    
117     INTEGER bi, bj
118     INTEGER myThid
119     _RL myTime
120    
121     #ifdef ALLOW_KPP
122    
123 heimbach 1.4 c Local constants
124     c minusone, p0, p5, p25, p125, p0625
125     c imin, imax, jmin, jmax - array computation indices
126    
127     _RL minusone
128     parameter( minusone=-1.0)
129     _KPP_RL p0 , p5 , p25 , p125 , p0625
130     parameter( p0=0.0, p5=0.5, p25=0.25, p125=0.125, p0625=0.0625 )
131     integer imin , imax , jmin , jmax
132     #ifdef FRUGAL_KPP
133     parameter( imin=1 , imax=sNx , jmin=1 , jmax=sNy )
134     #else
135     parameter( imin=-2 , imax=sNx+3 , jmin=-2 , jmax=sNy+3 )
136     #endif
137    
138 adcroft 1.1 c Local arrays and variables
139     c work? (nx,ny) - horizontal working arrays
140     c ustar (nx,ny) - surface friction velocity (m/s)
141     c bo (nx,ny) - surface turbulent buoyancy forcing (m^2/s^3)
142     c bosol (nx,ny) - surface radiative buoyancy forcing (m^2/s^3)
143     c shsq (nx,ny,Nr) - local velocity shear squared
144     c at interfaces for ri_iwmix (m^2/s^2)
145     c dVsq (nx,ny,Nr) - velocity shear re surface squared
146     c at grid levels for bldepth (m^2/s^2)
147     c dbloc (nx,ny,Nr) - local delta buoyancy at interfaces
148     c for ri_iwmix and bldepth (m/s^2)
149     c Ritop (nx,ny,Nr) - numerator of bulk richardson number
150     c at grid levels for bldepth
151     c vddiff (nx,ny,Nrp2,1)- vertical viscosity on "t-grid" (m^2/s)
152     c vddiff (nx,ny,Nrp2,2)- vert. diff. on next row for temperature (m^2/s)
153     c vddiff (nx,ny,Nrp2,3)- vert. diff. on next row for salt&tracers (m^2/s)
154     c ghat (nx,ny,Nr) - nonlocal transport coefficient (s/m^2)
155     c hbl (nx,ny) - mixing layer depth (m)
156     c kmtj (nx,ny) - maximum number of wet levels in each column
157     c z0 (nx,ny) - Roughness length (m)
158     c zRef (nx,ny) - Reference depth: Hmix * epsilon (m)
159     c uRef (nx,ny) - Reference zonal velocity (m/s)
160     c vRef (nx,ny) - Reference meridional velocity (m/s)
161    
162 heimbach 1.4 _RL worka ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
163     integer work1 ( ibot:itop , jbot:jtop )
164     _KPP_RL work2 ( ibot:itop , jbot:jtop )
165     _KPP_RL ustar ( ibot:itop , jbot:jtop )
166     _KPP_RL bo ( ibot:itop , jbot:jtop )
167     _KPP_RL bosol ( ibot:itop , jbot:jtop )
168     _KPP_RL shsq ( ibot:itop , jbot:jtop , Nr )
169     _KPP_RL dVsq ( ibot:itop , jbot:jtop , Nr )
170     _KPP_RL dbloc ( ibot:itop , jbot:jtop , Nr )
171     _KPP_RL Ritop ( ibot:itop , jbot:jtop , Nr )
172     _KPP_RL vddiff( ibot:itop , jbot:jtop , 0:Nrp1, mdiff )
173     _KPP_RL ghat ( ibot:itop , jbot:jtop , Nr )
174     _KPP_RL hbl ( ibot:itop , jbot:jtop )
175 adcroft 1.1 #ifdef KPP_ESTIMATE_UREF
176 heimbach 1.4 _KPP_RL z0 ( ibot:itop , jbot:jtop )
177     _KPP_RL zRef ( ibot:itop , jbot:jtop )
178     _KPP_RL uRef ( ibot:itop , jbot:jtop )
179     _KPP_RL vRef ( ibot:itop , jbot:jtop )
180 adcroft 1.1 #endif /* KPP_ESTIMATE_UREF */
181    
182 heimbach 1.4 _KPP_RL tempvar1, tempvar2
183 adcroft 1.1 integer i, j, k, kp1, im1, ip1, jm1, jp1
184    
185     #ifdef KPP_ESTIMATE_UREF
186 heimbach 1.4 _KPP_RL dBdz1, dBdz2, ustarX, ustarY
187 adcroft 1.1 #endif
188    
189     c Check to see if new vertical mixing coefficient should be computed now?
190     IF ( DIFFERENT_MULTIPLE(kpp_freq,myTime,myTime-deltaTClock) .OR.
191     1 myTime .EQ. startTime ) THEN
192    
193     c-----------------------------------------------------------------------
194     c prepare input arrays for subroutine "kppmix" to compute
195     c viscosity and diffusivity and ghat.
196     c All input arrays need to be in m-k-s units.
197     c
198     c note: for the computation of the bulk richardson number in the
199     c "bldepth" subroutine, gradients of velocity and buoyancy are
200     c required at every depth. in the case of very fine vertical grids
201     c (thickness of top layer < 2m), the surface reference depth must
202     c be set to zref=epsilon/2*zgrid(k), and the reference value
203     c of velocity and buoyancy must be computed as vertical average
204     c between the surface and 2*zref. in the case of coarse vertical
205     c grids zref is zgrid(1)/2., and the surface reference value is
206     c simply the surface value at zgrid(1).
207     c-----------------------------------------------------------------------
208    
209     c------------------------------------------------------------------------
210     c density related quantities
211     c --------------------------
212     c
213     c work2 - density of surface layer (kg/m^3)
214     c dbloc - local buoyancy gradient at Nr interfaces
215     c g/rho{k+1,k+1} * [ drho{k,k+1}-drho{k+1,k+1} ] (m/s^2)
216     c dbsfc (stored in Ritop to conserve stack memory)
217     c - buoyancy difference with respect to the surface
218     c g * [ drho{1,k}/rho{1,k} - drho{k,k}/rho{k,k} ] (m/s^2)
219     c ttalpha (stored in vddiff(:,:,:,1) to conserve stack memory)
220     c - thermal expansion coefficient without 1/rho factor
221     c d(rho{k,k})/d(T(k)) (kg/m^3/C)
222     c ssbeta (stored in vddiff(:,:,:,2) to conserve stack memory)
223     c - salt expansion coefficient without 1/rho factor
224     c d(rho{k,k})/d(S(k)) (kg/m^3/PSU)
225     c------------------------------------------------------------------------
226    
227     CALL TIMER_START('STATEKPP [KPP_CALC]', myThid)
228     CALL STATEKPP(
229     I bi, bj, myThid
230     O , work2, dbloc, Ritop
231 heimbach 1.4 O , vddiff(ibot,jbot,1,1), vddiff(ibot,jbot,1,2)
232 adcroft 1.1 & )
233     CALL TIMER_STOP ('STATEKPP [KPP_CALC]', myThid)
234    
235     DO k = 1, Nr
236 heimbach 1.4 DO j = jbot, jtop
237     DO i = ibot, itop
238 adcroft 1.1 ghat(i,j,k) = dbloc(i,j,k)
239     ENDDO
240     ENDDO
241     ENDDO
242    
243 heimbach 1.4 #ifdef KPP_SMOOTH_DBLOC
244     c horizontally smooth dbloc with a 121 filter
245     c smooth dbloc stored in ghat to save space
246     c dbloc(k) is buoyancy gradientnote between k and k+1
247     c levels therefore k+1 mask must be used
248    
249     DO k = 1, Nr-1
250     CALL KPP_SMOOTH_HORIZ (
251     I k+1, bi, bj,
252     U ghat (ibot,jbot,k) )
253     ENDDO
254    
255 adcroft 1.1 #endif /* KPP_SMOOTH_DBLOC */
256    
257     #ifdef KPP_SMOOTH_DENS
258     c horizontally smooth density related quantities with 121 filters
259 heimbach 1.4 CALL KPP_SMOOTH_HORIZ (
260     I 1, bi, bj,
261     U work2 )
262 adcroft 1.1 DO k = 1, Nr
263 heimbach 1.4 CALL KPP_SMOOTH_HORIZ (
264     I k+1, bi, bj,
265     U dbloc (ibot,jbot,k) )
266     CALL KPP_SMOOTH_HORIZ (
267 adcroft 1.1 I k, bi, bj,
268 heimbach 1.4 U Ritop (ibot,jbot,k) )
269     CALL KPP_SMOOTH_HORIZ (
270 adcroft 1.1 I k, bi, bj,
271 heimbach 1.4 U vddiff(ibot,jbot,k,1) )
272     CALL KPP_SMOOTH_HORIZ (
273 adcroft 1.1 I k, bi, bj,
274 heimbach 1.4 U vddiff(ibot,jbot,k,2) )
275 adcroft 1.1 ENDDO
276     #endif /* KPP_SMOOTH_DENS */
277    
278     DO k = 1, Nr
279 heimbach 1.4 DO j = jbot, jtop
280     DO i = ibot, itop
281 adcroft 1.1
282     c zero out dbloc over land points (so that the convective
283     c part of the interior mixing can be diagnosed)
284     dbloc(i,j,k) = dbloc(i,j,k) * pMask(i,j,k,bi,bj)
285     ghat(i,j,k) = ghat(i,j,k) * pMask(i,j,k,bi,bj)
286     Ritop(i,j,k) = Ritop(i,j,k) * pMask(i,j,k,bi,bj)
287     if(k.eq.nzmax(i,j,bi,bj)) then
288     dbloc(i,j,k) = p0
289     ghat(i,j,k) = p0
290     Ritop(i,j,k) = p0
291     endif
292    
293     c numerator of bulk richardson number on grid levels
294     c note: land and ocean bottom values need to be set to zero
295     c so that the subroutine "bldepth" works correctly
296     Ritop(i,j,k) = (zgrid(1)-zgrid(k)) * Ritop(i,j,k)
297    
298     END DO
299     END DO
300     END DO
301    
302     c------------------------------------------------------------------------
303     c friction velocity, turbulent and radiative surface buoyancy forcing
304     c -------------------------------------------------------------------
305 jmc 1.10 c taux / rho = SurfaceTendencyU * drF(1) (N/m^2)
306     c tauy / rho = SurfaceTendencyV * drF(1) (N/m^2)
307     c ustar = sqrt( sqrt( taux^2 + tauy^2 ) / rho ) (m/s)
308 heimbach 1.2 c bo = - g * ( alpha*SurfaceTendencyT +
309 jmc 1.10 c beta *SurfaceTendencyS ) * drF(1) / rho (m^2/s^3)
310     c bosol = - g * alpha * Qsw * drF(1) / rho (m^2/s^3)
311 adcroft 1.1 c------------------------------------------------------------------------
312    
313 heimbach 1.4 c initialize arrays to zero
314     DO j = jbot, jtop
315     DO i = ibot, itop
316     ustar(i,j) = p0
317     bo (I,J) = p0
318     bosol(I,J) = p0
319     END DO
320     END DO
321    
322 adcroft 1.1 DO j = jmin, jmax
323 heimbach 1.2 jp1 = j + 1
324     DO i = imin, imax
325     ip1 = i+1
326 heimbach 1.4 tempVar1 =
327 heimbach 1.2 & (SurfaceTendencyU(i,j,bi,bj) + SurfaceTendencyU(ip1,j,bi,bj)) *
328     & (SurfaceTendencyU(i,j,bi,bj) + SurfaceTendencyU(ip1,j,bi,bj)) +
329     & (SurfaceTendencyV(i,j,bi,bj) + SurfaceTendencyV(i,jp1,bi,bj)) *
330     & (SurfaceTendencyV(i,j,bi,bj) + SurfaceTendencyV(i,jp1,bi,bj))
331 heimbach 1.4 if ( tempVar1 .lt. (phepsi*phepsi) ) then
332 jmc 1.10 ustar(i,j) = SQRT( phepsi * p5 * drF(1) )
333 heimbach 1.2 else
334 jmc 1.10 tempVar2 = SQRT( tempVar1 ) * p5 * drF(1)
335 heimbach 1.4 ustar(i,j) = SQRT( tempVar2 )
336 heimbach 1.2 endif
337     bo(I,J) = - gravity *
338     & ( vddiff(I,J,1,1) * SurfaceTendencyT(i,j,bi,bj) +
339     & vddiff(I,J,1,2) * SurfaceTendencyS(i,j,bi,bj)
340     & ) *
341 jmc 1.10 & drF(1) / work2(I,J)
342 adcroft 1.5 bosol(I,J) = gravity * vddiff(I,J,1,1) * Qsw(i,j,bi,bj) *
343     & recip_Cp*recip_rhoNil*recip_dRf(1) *
344 jmc 1.10 & drF(1) / work2(I,J)
345 heimbach 1.2 END DO
346 adcroft 1.1 END DO
347    
348     c------------------------------------------------------------------------
349     c velocity shear
350     c --------------
351     c Get velocity shear squared, averaged from "u,v-grid"
352     c onto "t-grid" (in (m/s)**2):
353     c dVsq(k)=(Uref-U(k))**2+(Vref-V(k))**2 at grid levels
354     c shsq(k)=(U(k)-U(k+1))**2+(V(k)-V(k+1))**2 at interfaces
355     c------------------------------------------------------------------------
356    
357 heimbach 1.4 c initialize arrays to zero
358     DO k = 1, Nr
359     DO j = jbot, jtop
360     DO i = ibot, itop
361     shsq(i,j,k) = p0
362     dVsq(i,j,k) = p0
363     END DO
364     END DO
365     END DO
366    
367 adcroft 1.1 c dVsq computation
368    
369     #ifdef KPP_ESTIMATE_UREF
370    
371     c Get rid of vertical resolution dependence of dVsq term by
372     c estimating a surface velocity that is independent of first level
373     c thickness in the model. First determine mixed layer depth hMix.
374     c Second zRef = espilon * hMix. Third determine roughness length
375     c scale z0. Third estimate reference velocity.
376    
377     DO j = jmin, jmax
378     jp1 = j + 1
379     DO i = imin, imax
380     ip1 = i + 1
381    
382     c Determine mixed layer depth hMix as the shallowest depth at which
383     c dB/dz exceeds 5.2e-5 s^-2.
384     work1(i,j) = nzmax(i,j,bi,bj)
385     DO k = 1, Nr
386     IF ( k .LT. nzmax(i,j,bi,bj) .AND.
387     & dbloc(i,j,k) / drC(k+1) .GT. dB_dz )
388     & work1(i,j) = k
389     END DO
390    
391     c Linearly interpolate to find hMix.
392     k = work1(i,j)
393     IF ( k .EQ. 0 .OR. nzmax(i,j,bi,bj) .EQ. 1 ) THEN
394     zRef(i,j) = p0
395     ELSEIF ( k .EQ. 1) THEN
396     dBdz2 = dbloc(i,j,1) / drC(2)
397     zRef(i,j) = drF(1) * dB_dz / dBdz2
398     ELSEIF ( k .LT. nzmax(i,j,bi,bj) ) THEN
399     dBdz1 = dbloc(i,j,k-1) / drC(k )
400     dBdz2 = dbloc(i,j,k ) / drC(k+1)
401     zRef(i,j) = rF(k) + drF(k) * (dB_dz - dBdz1) /
402     & MAX ( phepsi, dBdz2 - dBdz1 )
403     ELSE
404     zRef(i,j) = rF(k+1)
405     ENDIF
406    
407     c Compute roughness length scale z0 subject to 0 < z0
408 heimbach 1.4 tempVar1 = p5 * (
409 adcroft 1.1 & (uVel(i, j, 1,bi,bj)-uVel(i, j, 2,bi,bj)) *
410     & (uVel(i, j, 1,bi,bj)-uVel(i, j, 2,bi,bj)) +
411     & (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, 2,bi,bj)) *
412     & (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, 2,bi,bj)) +
413     & (vVel(i, j, 1,bi,bj)-vVel(i, j, 2,bi,bj)) *
414     & (vVel(i, j, 1,bi,bj)-vVel(i, j, 2,bi,bj)) +
415     & (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,2,bi,bj)) *
416 heimbach 1.2 & (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,2,bi,bj)) )
417 heimbach 1.4 if ( tempVar1 .lt. (epsln*epsln) ) then
418     tempVar2 = epsln
419 heimbach 1.2 else
420 heimbach 1.4 tempVar2 = SQRT ( tempVar1 )
421 heimbach 1.2 endif
422 adcroft 1.1 z0(i,j) = rF(2) *
423     & ( rF(3) * LOG ( rF(3) / rF(2) ) /
424     & ( rF(3) - rF(2) ) -
425 heimbach 1.4 & tempVar2 * vonK /
426 adcroft 1.1 & MAX ( ustar(i,j), phepsi ) )
427     z0(i,j) = MAX ( z0(i,j), phepsi )
428    
429     c zRef is set to 0.1 * hMix subject to z0 <= zRef <= drF(1)
430     zRef(i,j) = MAX ( epsilon * zRef(i,j), z0(i,j) )
431     zRef(i,j) = MIN ( zRef(i,j), drF(1) )
432    
433     c Estimate reference velocity uRef and vRef.
434     uRef(i,j) = p5 *
435     & ( uVel(i,j,1,bi,bj) + uVel(ip1,j,1,bi,bj) )
436     vRef(i,j) = p5 *
437     & ( vVel(i,j,1,bi,bj) + vVel(i,jp1,1,bi,bj) )
438     IF ( zRef(i,j) .LT. drF(1) ) THEN
439 heimbach 1.2 ustarX = ( SurfaceTendencyU(i, j,bi,bj) +
440     & SurfaceTendencyU(ip1,j,bi,bj) ) * p5
441     ustarY = ( SurfaceTendencyV(i,j, bi,bj) +
442     & SurfaceTendencyU(i,jp1,bi,bj) ) * p5
443 heimbach 1.4 tempVar1 = ustarX * ustarX + ustarY * ustarY
444     if ( tempVar1 .lt. (epsln*epsln) ) then
445     tempVar2 = epsln
446 heimbach 1.2 else
447 heimbach 1.4 tempVar2 = SQRT ( tempVar1 )
448 heimbach 1.2 endif
449 heimbach 1.4 tempVar2 = ustar(i,j) *
450 adcroft 1.1 & ( LOG ( zRef(i,j) / rF(2) ) +
451     & z0(i,j) / zRef(i,j) - z0(i,j) / rF(2) ) /
452 heimbach 1.4 & vonK / tempVar2
453     uRef(i,j) = uRef(i,j) + ustarX * tempVar2
454     vRef(i,j) = vRef(i,j) + ustarY * tempVar2
455 adcroft 1.1 ENDIF
456    
457     END DO
458     END DO
459    
460     DO k = 1, Nr
461     DO j = jmin, jmax
462     jm1 = j - 1
463     jp1 = j + 1
464     DO i = imin, imax
465     im1 = i - 1
466     ip1 = i + 1
467     dVsq(i,j,k) = p5 * (
468     $ (uRef(i,j) - uVel(i, j, k,bi,bj)) *
469     $ (uRef(i,j) - uVel(i, j, k,bi,bj)) +
470     $ (uRef(i,j) - uVel(ip1,j, k,bi,bj)) *
471     $ (uRef(i,j) - uVel(ip1,j, k,bi,bj)) +
472     $ (vRef(i,j) - vVel(i, j, k,bi,bj)) *
473     $ (vRef(i,j) - vVel(i, j, k,bi,bj)) +
474     $ (vRef(i,j) - vVel(i, jp1,k,bi,bj)) *
475     $ (vRef(i,j) - vVel(i, jp1,k,bi,bj)) )
476     #ifdef KPP_SMOOTH_DVSQ
477     dVsq(i,j,k) = p5 * dVsq(i,j,k) + p125 * (
478     $ (uRef(i,j) - uVel(i, jm1,k,bi,bj)) *
479     $ (uRef(i,j) - uVel(i, jm1,k,bi,bj)) +
480     $ (uRef(i,j) - uVel(ip1,jm1,k,bi,bj)) *
481     $ (uRef(i,j) - uVel(ip1,jm1,k,bi,bj)) +
482     $ (uRef(i,j) - uVel(i, jp1,k,bi,bj)) *
483     $ (uRef(i,j) - uVel(i, jp1,k,bi,bj)) +
484     $ (uRef(i,j) - uVel(ip1,jp1,k,bi,bj)) *
485     $ (uRef(i,j) - uVel(ip1,jp1,k,bi,bj)) +
486     $ (vRef(i,j) - vVel(im1,j, k,bi,bj)) *
487     $ (vRef(i,j) - vVel(im1,j, k,bi,bj)) +
488     $ (vRef(i,j) - vVel(im1,jp1,k,bi,bj)) *
489     $ (vRef(i,j) - vVel(im1,jp1,k,bi,bj)) +
490     $ (vRef(i,j) - vVel(ip1,j, k,bi,bj)) *
491     $ (vRef(i,j) - vVel(ip1,j, k,bi,bj)) +
492     $ (vRef(i,j) - vVel(ip1,jp1,k,bi,bj)) *
493     $ (vRef(i,j) - vVel(ip1,jp1,k,bi,bj)) )
494     #endif /* KPP_SMOOTH_DVSQ */
495     END DO
496     END DO
497     END DO
498    
499     #else /* KPP_ESTIMATE_UREF */
500    
501     DO k = 1, Nr
502     DO j = jmin, jmax
503     jm1 = j - 1
504     jp1 = j + 1
505     DO i = imin, imax
506     im1 = i - 1
507     ip1 = i + 1
508     dVsq(i,j,k) = p5 * (
509     $ (uVel(i, j, 1,bi,bj)-uVel(i, j, k,bi,bj)) *
510     $ (uVel(i, j, 1,bi,bj)-uVel(i, j, k,bi,bj)) +
511     $ (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, k,bi,bj)) *
512     $ (uVel(ip1,j, 1,bi,bj)-uVel(ip1,j, k,bi,bj)) +
513     $ (vVel(i, j, 1,bi,bj)-vVel(i, j, k,bi,bj)) *
514     $ (vVel(i, j, 1,bi,bj)-vVel(i, j, k,bi,bj)) +
515     $ (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,k,bi,bj)) *
516     $ (vVel(i, jp1,1,bi,bj)-vVel(i, jp1,k,bi,bj)) )
517     #ifdef KPP_SMOOTH_DVSQ
518     dVsq(i,j,k) = p5 * dVsq(i,j,k) + p125 * (
519     $ (uVel(i, jm1,1,bi,bj)-uVel(i, jm1,k,bi,bj)) *
520     $ (uVel(i, jm1,1,bi,bj)-uVel(i, jm1,k,bi,bj)) +
521     $ (uVel(ip1,jm1,1,bi,bj)-uVel(ip1,jm1,k,bi,bj)) *
522     $ (uVel(ip1,jm1,1,bi,bj)-uVel(ip1,jm1,k,bi,bj)) +
523     $ (uVel(i, jp1,1,bi,bj)-uVel(i, jp1,k,bi,bj)) *
524     $ (uVel(i, jp1,1,bi,bj)-uVel(i, jp1,k,bi,bj)) +
525     $ (uVel(ip1,jp1,1,bi,bj)-uVel(ip1,jp1,k,bi,bj)) *
526     $ (uVel(ip1,jp1,1,bi,bj)-uVel(ip1,jp1,k,bi,bj)) +
527     $ (vVel(im1,j, 1,bi,bj)-vVel(im1,j, k,bi,bj)) *
528     $ (vVel(im1,j, 1,bi,bj)-vVel(im1,j, k,bi,bj)) +
529     $ (vVel(im1,jp1,1,bi,bj)-vVel(im1,jp1,k,bi,bj)) *
530     $ (vVel(im1,jp1,1,bi,bj)-vVel(im1,jp1,k,bi,bj)) +
531     $ (vVel(ip1,j, 1,bi,bj)-vVel(ip1,j, k,bi,bj)) *
532     $ (vVel(ip1,j, 1,bi,bj)-vVel(ip1,j, k,bi,bj)) +
533     $ (vVel(ip1,jp1,1,bi,bj)-vVel(ip1,jp1,k,bi,bj)) *
534     $ (vVel(ip1,jp1,1,bi,bj)-vVel(ip1,jp1,k,bi,bj)) )
535     #endif /* KPP_SMOOTH_DVSQ */
536     END DO
537     END DO
538     END DO
539    
540     #endif /* KPP_ESTIMATE_UREF */
541    
542     c shsq computation
543     DO k = 1, Nrm1
544     kp1 = k + 1
545     DO j = jmin, jmax
546     jm1 = j - 1
547     jp1 = j + 1
548     DO i = imin, imax
549     im1 = i - 1
550     ip1 = i + 1
551     shsq(i,j,k) = p5 * (
552     $ (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) *
553     $ (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) +
554     $ (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) *
555     $ (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) +
556     $ (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) *
557     $ (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) +
558     $ (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) *
559     $ (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) )
560     #ifdef KPP_SMOOTH_SHSQ
561     shsq(i,j,k) = p5 * shsq(i,j,k) + p125 * (
562     $ (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) *
563     $ (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) +
564     $ (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) *
565     $ (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) +
566     $ (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) *
567     $ (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) +
568     $ (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) *
569     $ (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) +
570     $ (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) *
571     $ (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) +
572     $ (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) *
573     $ (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) +
574     $ (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) *
575     $ (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) +
576     $ (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) *
577     $ (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) )
578     #endif
579     END DO
580     END DO
581     END DO
582    
583     c-----------------------------------------------------------------------
584     c solve for viscosity, diffusivity, ghat, and hbl on "t-grid"
585     c-----------------------------------------------------------------------
586    
587 heimbach 1.4 DO j = jbot, jtop
588     DO i = ibot, itop
589 adcroft 1.1 work1(i,j) = nzmax(i,j,bi,bj)
590     work2(i,j) = Fcori(i,j,bi,bj)
591     END DO
592     END DO
593     CALL TIMER_START('KPPMIX [KPP_CALC]', myThid)
594     CALL KPPMIX (
595 heimbach 1.4 I mytime, mythid
596     I , work1, shsq, dVsq, ustar
597 adcroft 1.1 I , bo, bosol, dbloc, Ritop, work2
598     I , ikey
599     O , vddiff
600     U , ghat
601 heimbach 1.4 O , hbl )
602 adcroft 1.1
603     CALL TIMER_STOP ('KPPMIX [KPP_CALC]', myThid)
604    
605 heimbach 1.2 #ifdef ALLOW_AUTODIFF_TAMC
606 heimbach 1.4 cph( storing not necessary
607     cphCADJ STORE vddiff, ghat = comlev1_kpp, key = ikey
608     cph)
609 heimbach 1.2 #endif /* ALLOW_AUTODIFF_TAMC */
610 adcroft 1.1
611     c-----------------------------------------------------------------------
612 heimbach 1.4 c zero out land values and transfer to global variables
613 adcroft 1.1 c-----------------------------------------------------------------------
614    
615     DO j = jmin, jmax
616 heimbach 1.4 DO i = imin, imax
617     DO k = 1, Nr
618     KPPviscAz(i,j,k,bi,bj) = vddiff(i,j,k-1,1) * pMask(i,j,k,bi,bj)
619     KPPdiffKzS(i,j,k,bi,bj)= vddiff(i,j,k-1,2) * pMask(i,j,k,bi,bj)
620     KPPdiffKzT(i,j,k,bi,bj)= vddiff(i,j,k-1,3) * pMask(i,j,k,bi,bj)
621     KPPghat(i,j,k,bi,bj) = ghat(i,j,k) * pMask(i,j,k,bi,bj)
622     END DO
623     KPPhbl(i,j,bi,bj) = hbl(i,j) * pMask(i,j,1,bi,bj)
624     END DO
625 adcroft 1.1 END DO
626     #ifdef FRUGAL_KPP
627     _EXCH_XYZ_R8(KPPviscAz , myThid )
628     _EXCH_XYZ_R8(KPPdiffKzS , myThid )
629     _EXCH_XYZ_R8(KPPdiffKzT , myThid )
630     _EXCH_XYZ_R8(KPPghat , myThid )
631     _EXCH_XY_R8 (KPPhbl , myThid )
632     #endif
633    
634     #ifdef KPP_SMOOTH_VISC
635     c horizontal smoothing of vertical viscosity
636     DO k = 1, Nr
637 heimbach 1.4 CALL SMOOTH_HORIZ (
638 adcroft 1.1 I k, bi, bj,
639 heimbach 1.4 U KPPviscAz(1-OLx,1-OLy,k,bi,bj) )
640 adcroft 1.1 END DO
641 heimbach 1.4 _EXCH_XYZ_R8(KPPviscAz , myThid )
642 adcroft 1.1 #endif /* KPP_SMOOTH_VISC */
643    
644     #ifdef KPP_SMOOTH_DIFF
645     c horizontal smoothing of vertical diffusivity
646     DO k = 1, Nr
647 heimbach 1.4 CALL SMOOTH_HORIZ (
648 adcroft 1.1 I k, bi, bj,
649 heimbach 1.4 U KPPdiffKzS(1-OLx,1-OLy,k,bi,bj) )
650     CALL SMOOTH_HORIZ (
651 adcroft 1.1 I k, bi, bj,
652 heimbach 1.4 U KPPdiffKzT(1-OLx,1-OLy,k,bi,bj) )
653 adcroft 1.1 END DO
654 heimbach 1.4 _EXCH_XYZ_R8(KPPdiffKzS , myThid )
655     _EXCH_XYZ_R8(KPPdiffKzT , myThid )
656 adcroft 1.1 #endif /* KPP_SMOOTH_DIFF */
657    
658     C Compute fraction of solar short-wave flux penetrating to
659     C the bottom of the mixing layer.
660     DO j=1-OLy,sNy+OLy
661     DO i=1-OLx,sNx+OLx
662     worka(i,j) = KPPhbl(i,j,bi,bj)
663     ENDDO
664     ENDDO
665     CALL SWFRAC(
666 heimbach 1.4 I (sNx+2*OLx)*(sNy+2*OLy), minusone,
667     I mytime, mythid,
668     U worka )
669 adcroft 1.1 DO j=1-OLy,sNy+OLy
670     DO i=1-OLx,sNx+OLx
671 heimbach 1.4 KPPfrac(i,j,bi,bj) = worka(i,j)
672 adcroft 1.1 ENDDO
673     ENDDO
674    
675     ENDIF
676    
677 adcroft 1.9 #endif /* ALLOW_KPP */
678 adcroft 1.1
679 heimbach 1.8 RETURN
680     END
681    
682     subroutine KPP_CALC_DUMMY(
683     I bi, bj, myTime, myThid )
684     C /==========================================================\
685     C | SUBROUTINE KPP_CALC_DUMMY |
686     C | o Compute all KPP fields defined in KPP.h |
687     C | o Dummy routine for TAMC
688     C |==========================================================|
689     C | This subroutine serves as an interface between MITGCMUV |
690     C | code and NCOM 1-D routines in kpp_routines.F |
691     C \==========================================================/
692     IMPLICIT NONE
693    
694     #include "SIZE.h"
695     #include "EEPARAMS.h"
696     #include "PARAMS.h"
697     #include "KPP.h"
698     #include "KPP_PARAMS.h"
699     #include "GRID.h"
700    
701     c Routine arguments
702     c bi, bj - array indices on which to apply calculations
703     c myTime - Current time in simulation
704    
705     INTEGER bi, bj
706     INTEGER myThid
707     _RL myTime
708    
709     #ifdef ALLOW_KPP
710    
711     c Local constants
712     integer i, j, k
713    
714     DO j=1-OLy,sNy+OLy
715     DO i=1-OLx,sNx+OLx
716     KPPhbl (i,j,bi,bj) = 1.0
717     KPPfrac(i,j,bi,bj) = 0.0
718     DO k = 1,Nr
719     KPPghat (i,j,k,bi,bj) = 0.0
720     KPPviscAz (i,j,k,bi,bj) = viscAz
721     KPPdiffKzT(i,j,k,bi,bj) = diffKzT
722     KPPdiffKzS(i,j,k,bi,bj) = diffKzS
723     ENDDO
724     ENDDO
725     ENDDO
726    
727     #endif
728 adcroft 1.1 RETURN
729     END

  ViewVC Help
Powered by ViewVC 1.1.22