/[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.41 - (hide annotations) (download)
Thu May 3 14:51:05 2007 UTC (18 years, 2 months ago) by mlosch
Branch: MAIN
Changes since 1.40: +71 -312 lines
 - move computation of surface related input fields to KPP into a new
   subroutine kpp_forcing_surf.F

1 mlosch 1.41 C $Header: /u/gcmpack/MITgcm/pkg/kpp/kpp_calc.F,v 1.40 2007/05/01 04:09:25 mlosch Exp $
2 adcroft 1.9 C $Name: $
3 adcroft 1.1
4     #include "KPP_OPTIONS.h"
5    
6 dimitri 1.25 CBOP
7     C !ROUTINE: KPP_CALC
8    
9     C !INTERFACE: ==========================================================
10 adcroft 1.1 subroutine KPP_CALC(
11     I bi, bj, myTime, myThid )
12 dimitri 1.25
13     C !DESCRIPTION: \bv
14 adcroft 1.1 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 MIT GCM UV and the
56     c subroutine "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    
91     c-- KPP_CALC computes vertical viscosity and diffusivity for region
92     c (-2:sNx+3,-2:sNy+3) as required by CALC_DIFFUSIVITY and requires
93 jmc 1.28 c values of uVel, vVel, surfaceForcingU, surfaceForcingV in the
94 heimbach 1.2 c region (-2:sNx+4,-2:sNy+4).
95 adcroft 1.1 c Hence overlap region needs to be set OLx=4, OLy=4.
96 dimitri 1.25 c \ev
97 adcroft 1.1
98 dimitri 1.25 C !USES: ===============================================================
99 adcroft 1.1 #include "SIZE.h"
100     #include "EEPARAMS.h"
101     #include "PARAMS.h"
102     #include "DYNVARS.h"
103     #include "KPP.h"
104     #include "KPP_PARAMS.h"
105     #include "FFIELDS.h"
106     #include "GRID.h"
107 dimitri 1.36 #include "GAD.h"
108 mlosch 1.35 #ifdef ALLOW_SHELFICE
109     # include "SHELFICE.h"
110     #endif /* ALLOW_SHELFICE */
111 adcroft 1.1 #ifdef ALLOW_AUTODIFF_TAMC
112     #include "tamc.h"
113     #include "tamc_keys.h"
114     #else /* ALLOW_AUTODIFF_TAMC */
115 heimbach 1.16 integer ikppkey
116 adcroft 1.1 #endif /* ALLOW_AUTODIFF_TAMC */
117    
118 jmc 1.32 EXTERNAL DIFFERENT_MULTIPLE
119     LOGICAL DIFFERENT_MULTIPLE
120 adcroft 1.1
121 dimitri 1.25 C !INPUT PARAMETERS: ===================================================
122 adcroft 1.1 c Routine arguments
123     c bi, bj - array indices on which to apply calculations
124     c myTime - Current time in simulation
125    
126     INTEGER bi, bj
127     INTEGER myThid
128     _RL myTime
129    
130     #ifdef ALLOW_KPP
131    
132 dimitri 1.25 C !LOCAL VARIABLES: ====================================================
133 heimbach 1.4 c Local constants
134     c minusone, p0, p5, p25, p125, p0625
135     c imin, imax, jmin, jmax - array computation indices
136    
137     _RL minusone
138     parameter( minusone=-1.0)
139 dimitri 1.37 _RL p0 , p5 , p25 , p125 , p0625
140 heimbach 1.4 parameter( p0=0.0, p5=0.5, p25=0.25, p125=0.125, p0625=0.0625 )
141 dimitri 1.17 integer imin ,imax ,jmin ,jmax
142 heimbach 1.15 parameter(imin=2-OLx,imax=sNx+OLx-1,jmin=2-OLy,jmax=sNy+OLy-1)
143 heimbach 1.4
144 adcroft 1.1 c Local arrays and variables
145     c work? (nx,ny) - horizontal working arrays
146     c ustar (nx,ny) - surface friction velocity (m/s)
147     c bo (nx,ny) - surface turbulent buoyancy forcing (m^2/s^3)
148     c bosol (nx,ny) - surface radiative buoyancy forcing (m^2/s^3)
149     c shsq (nx,ny,Nr) - local velocity shear squared
150     c at interfaces for ri_iwmix (m^2/s^2)
151     c dVsq (nx,ny,Nr) - velocity shear re surface squared
152     c at grid levels for bldepth (m^2/s^2)
153     c dbloc (nx,ny,Nr) - local delta buoyancy at interfaces
154     c for ri_iwmix and bldepth (m/s^2)
155     c Ritop (nx,ny,Nr) - numerator of bulk richardson number
156     c at grid levels for bldepth
157     c vddiff (nx,ny,Nrp2,1)- vertical viscosity on "t-grid" (m^2/s)
158 dimitri 1.24 c vddiff (nx,ny,Nrp2,2)- vert. diff. on next row for salt&tracers (m^2/s)
159     c vddiff (nx,ny,Nrp2,3)- vert. diff. on next row for temperature (m^2/s)
160 adcroft 1.1 c ghat (nx,ny,Nr) - nonlocal transport coefficient (s/m^2)
161     c hbl (nx,ny) - mixing layer depth (m)
162     c kmtj (nx,ny) - maximum number of wet levels in each column
163     c z0 (nx,ny) - Roughness length (m)
164     c zRef (nx,ny) - Reference depth: Hmix * epsilon (m)
165     c uRef (nx,ny) - Reference zonal velocity (m/s)
166     c vRef (nx,ny) - Reference meridional velocity (m/s)
167    
168 dimitri 1.37 integer work1 ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
169     _RL worka ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
170     _RL work2 ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
171     _RL work3 ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
172     _RL ustar ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
173     _RL bo ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
174     _RL bosol ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
175     _RL shsq ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
176     _RL dVsq ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
177     _RL dbloc ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
178     _RL Ritop ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
179     _RL vddiff( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, 0:Nrp1, mdiff )
180     _RL ghat ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nr )
181     _RL hbl ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
182 heimbach 1.33 cph(
183 dimitri 1.37 _RL TTALPHA( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nrp1 )
184     _RL SSBETA ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy, Nrp1 )
185 heimbach 1.33 cph)
186 adcroft 1.1 #ifdef KPP_ESTIMATE_UREF
187 dimitri 1.37 _RL z0 ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
188     _RL zRef ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
189     _RL uRef ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
190     _RL vRef ( 1-OLx:sNx+OLx, 1-OLy:sNy+OLy )
191 adcroft 1.1 #endif /* KPP_ESTIMATE_UREF */
192    
193 dimitri 1.37 _RL tempvar2
194 mlosch 1.35 integer i, j, k, kp1, km1, im1, ip1, jm1, jp1
195 adcroft 1.1
196     #ifdef KPP_ESTIMATE_UREF
197 dimitri 1.37 _RL tempvar1, dBdz1, dBdz2, ustarX, ustarY
198 adcroft 1.1 #endif
199    
200 heimbach 1.16 #ifdef ALLOW_AUTODIFF_TAMC
201     act1 = bi - myBxLo(myThid)
202     max1 = myBxHi(myThid) - myBxLo(myThid) + 1
203     act2 = bj - myByLo(myThid)
204     max2 = myByHi(myThid) - myByLo(myThid) + 1
205     act3 = myThid - 1
206     max3 = nTx*nTy
207     act4 = ikey_dynamics - 1
208     ikppkey = (act1 + 1) + act2*max1
209     & + act3*max1*max2
210     & + act4*max1*max2*max3
211     #endif /* ALLOW_AUTODIFF_TAMC */
212 dimitri 1.25 CEOP
213 heimbach 1.16
214 adcroft 1.1 c Check to see if new vertical mixing coefficient should be computed now?
215 jmc 1.32 IF ( DIFFERENT_MULTIPLE(kpp_freq,myTime,deltaTClock)
216 jmc 1.31 1 .OR. myTime .EQ. startTime ) THEN
217 adcroft 1.1
218     c-----------------------------------------------------------------------
219     c prepare input arrays for subroutine "kppmix" to compute
220     c viscosity and diffusivity and ghat.
221     c All input arrays need to be in m-k-s units.
222     c
223     c note: for the computation of the bulk richardson number in the
224     c "bldepth" subroutine, gradients of velocity and buoyancy are
225     c required at every depth. in the case of very fine vertical grids
226     c (thickness of top layer < 2m), the surface reference depth must
227     c be set to zref=epsilon/2*zgrid(k), and the reference value
228     c of velocity and buoyancy must be computed as vertical average
229     c between the surface and 2*zref. in the case of coarse vertical
230     c grids zref is zgrid(1)/2., and the surface reference value is
231     c simply the surface value at zgrid(1).
232     c-----------------------------------------------------------------------
233    
234     c------------------------------------------------------------------------
235     c density related quantities
236     c --------------------------
237     c
238     c work2 - density of surface layer (kg/m^3)
239     c dbloc - local buoyancy gradient at Nr interfaces
240     c g/rho{k+1,k+1} * [ drho{k,k+1}-drho{k+1,k+1} ] (m/s^2)
241     c dbsfc (stored in Ritop to conserve stack memory)
242     c - buoyancy difference with respect to the surface
243     c g * [ drho{1,k}/rho{1,k} - drho{k,k}/rho{k,k} ] (m/s^2)
244     c ttalpha (stored in vddiff(:,:,:,1) to conserve stack memory)
245     c - thermal expansion coefficient without 1/rho factor
246     c d(rho{k,k})/d(T(k)) (kg/m^3/C)
247     c ssbeta (stored in vddiff(:,:,:,2) to conserve stack memory)
248     c - salt expansion coefficient without 1/rho factor
249     c d(rho{k,k})/d(S(k)) (kg/m^3/PSU)
250     c------------------------------------------------------------------------
251    
252     CALL TIMER_START('STATEKPP [KPP_CALC]', myThid)
253     CALL STATEKPP(
254 mlosch 1.40 O work2, dbloc, Ritop,
255     O TTALPHA, SSBETA,
256     I ikppkey, bi, bj, myThid )
257 adcroft 1.1 CALL TIMER_STOP ('STATEKPP [KPP_CALC]', myThid)
258    
259     DO k = 1, Nr
260 dimitri 1.34 DO j = 1-OLy, sNy+OLy
261     DO i = 1-OLx, sNx+OLx
262 adcroft 1.1 ghat(i,j,k) = dbloc(i,j,k)
263     ENDDO
264     ENDDO
265     ENDDO
266    
267 heimbach 1.4 #ifdef KPP_SMOOTH_DBLOC
268     c horizontally smooth dbloc with a 121 filter
269     c smooth dbloc stored in ghat to save space
270     c dbloc(k) is buoyancy gradientnote between k and k+1
271     c levels therefore k+1 mask must be used
272    
273     DO k = 1, Nr-1
274 dimitri 1.37 CALL SMOOTH_HORIZ (
275 heimbach 1.4 I k+1, bi, bj,
276 mlosch 1.40 U ghat (1-OLx,1-OLy,k),
277     I myThid )
278 heimbach 1.4 ENDDO
279    
280 adcroft 1.1 #endif /* KPP_SMOOTH_DBLOC */
281    
282     #ifdef KPP_SMOOTH_DENS
283     c horizontally smooth density related quantities with 121 filters
284 dimitri 1.37 CALL SMOOTH_HORIZ (
285 heimbach 1.4 I 1, bi, bj,
286 mlosch 1.40 U work2,
287     I myThid )
288 adcroft 1.1 DO k = 1, Nr
289 dimitri 1.37 CALL SMOOTH_HORIZ (
290 heimbach 1.4 I k+1, bi, bj,
291 mlosch 1.40 U dbloc (1-OLx,1-OLy,k),
292     I myThid )
293 dimitri 1.37 CALL SMOOTH_HORIZ (
294 adcroft 1.1 I k, bi, bj,
295 mlosch 1.40 U Ritop (1-OLx,1-OLy,k),
296     I myThid )
297 dimitri 1.37 CALL SMOOTH_HORIZ (
298 adcroft 1.1 I k, bi, bj,
299 mlosch 1.40 U TTALPHA(1-OLx,1-OLy,k),
300     I myThid )
301 dimitri 1.37 CALL SMOOTH_HORIZ (
302 adcroft 1.1 I k, bi, bj,
303 mlosch 1.40 U SSBETA(1-OLx,1-OLy,k),
304     I myThid )
305 adcroft 1.1 ENDDO
306     #endif /* KPP_SMOOTH_DENS */
307    
308     DO k = 1, Nr
309 mlosch 1.35 km1 = max(1,k-1)
310 dimitri 1.34 DO j = 1-OLy, sNy+OLy
311     DO i = 1-OLx, sNx+OLx
312 adcroft 1.1
313     c zero out dbloc over land points (so that the convective
314     c part of the interior mixing can be diagnosed)
315 jmc 1.28 dbloc(i,j,k) = dbloc(i,j,k) * maskC(i,j,k,bi,bj)
316 mlosch 1.35 & * maskC(i,j,km1,bi,bj)
317 jmc 1.28 ghat(i,j,k) = ghat(i,j,k) * maskC(i,j,k,bi,bj)
318 mlosch 1.35 & * maskC(i,j,km1,bi,bj)
319 jmc 1.28 Ritop(i,j,k) = Ritop(i,j,k) * maskC(i,j,k,bi,bj)
320 mlosch 1.35 & * maskC(i,j,km1,bi,bj)
321 adcroft 1.1 if(k.eq.nzmax(i,j,bi,bj)) then
322     dbloc(i,j,k) = p0
323     ghat(i,j,k) = p0
324     Ritop(i,j,k) = p0
325     endif
326    
327     c numerator of bulk richardson number on grid levels
328     c note: land and ocean bottom values need to be set to zero
329     c so that the subroutine "bldepth" works correctly
330     Ritop(i,j,k) = (zgrid(1)-zgrid(k)) * Ritop(i,j,k)
331    
332     END DO
333     END DO
334     END DO
335    
336 heimbach 1.11 cph(
337     cph this avoids a single or double recomp./call of statekpp
338 heimbach 1.16 CADJ store work2 = comlev1_kpp, key = ikppkey
339 heimbach 1.27 #ifdef KPP_AUTODIFF_EXCESSIVE_STORE
340 heimbach 1.16 CADJ store dbloc, Ritop, ghat = comlev1_kpp, key = ikppkey
341     CADJ store vddiff = comlev1_kpp, key = ikppkey
342 heimbach 1.33 CADJ store TTALPHA, SSBETA = comlev1_kpp, key = ikppkey
343 heimbach 1.11 #endif
344     cph)
345    
346 mlosch 1.35 CML#ifdef ALLOW_SHELFICE
347     CMLC For the pbl parameterisation to work underneath the ice shelves
348     CMLC it needs to know the surface (ice-ocean) fluxes. However, masking
349     CMLC and indexing problems make this part of the code not work
350     CMLC underneath the ice shelves and the following lines are only here
351     CMLC to remind me that this still needs to be sorted out.
352 mlosch 1.41 CML shelfIceFac = 0. _d 0
353     CML IF ( useShelfIce ) selfIceFac = 1. _d 0
354 mlosch 1.35 CML DO j = jmin, jmax
355     CML DO i = imin, imax
356 mlosch 1.41 CML surfForcT = surfaceForcingT(i,j,bi,bj)
357     CML & + shelficeForcingT(i,j,bi,bj) * shelfIceFac
358     CML surfForcS = surfaceForcingS(i,j,bi,bj)
359     CML & + shelficeForcingS(i,j,bi,bj) * shelfIceFac
360 mlosch 1.35 CML END DO
361     CML END DO
362     CML#endif /* ALLOW_SHELFICE */
363 heimbach 1.11
364 mlosch 1.41 c------------------------------------------------------------------------
365     c friction velocity, turbulent and radiative surface buoyancy forcing
366     c -------------------------------------------------------------------
367     c taux / rho = surfaceForcingU (N/m^2)
368     c tauy / rho = surfaceForcingV (N/m^2)
369     c ustar = sqrt( sqrt( taux^2 + tauy^2 ) / rho ) (m/s)
370     c bo = - g * ( alpha*surfaceForcingT +
371     c beta *surfaceForcingS ) / rho (m^2/s^3)
372     c bosol = - g * alpha * Qsw * drF(1) / rho (m^2/s^3)
373 adcroft 1.1 c------------------------------------------------------------------------
374     c velocity shear
375     c --------------
376     c Get velocity shear squared, averaged from "u,v-grid"
377     c onto "t-grid" (in (m/s)**2):
378     c dVsq(k)=(Uref-U(k))**2+(Vref-V(k))**2 at grid levels
379     c shsq(k)=(U(k)-U(k+1))**2+(V(k)-V(k+1))**2 at interfaces
380 mlosch 1.41 c
381     c note: Vref can depend on the surface fluxes that is why we compute
382     c dVsq in the subroutine that does the surface related stuff
383     c (admittedly this is a bit messy)
384 adcroft 1.1 c------------------------------------------------------------------------
385 mlosch 1.41
386     CALL KPP_FORCING_SURF(
387     I work2, surfaceForcingU, surfaceForcingV,
388     I surfaceForcingT, surfaceForcingS, surfaceForcingTice,
389     I Qsw, ttalpha, ssbeta,
390     O ustar, bo, bosol, dVsq,
391     I ikppkey, iMin, iMax, jMin, jMax, bi, bj, myTime, myThid )
392    
393     CMLcph(
394     CMLCADJ store ustar = comlev1_kpp, key = ikppkey
395     CMLcph)
396 adcroft 1.1
397 heimbach 1.4 c initialize arrays to zero
398     DO k = 1, Nr
399 mlosch 1.41 DO j = 1-OLy, sNy+OLy
400     DO i = 1-OLx, sNx+OLx
401     shsq(i,j,k) = p0
402     END DO
403     END DO
404 adcroft 1.1 END DO
405    
406     c shsq computation
407     DO k = 1, Nrm1
408 mlosch 1.41 kp1 = k + 1
409     DO j = jmin, jmax
410     jm1 = j - 1
411     jp1 = j + 1
412     DO i = imin, imax
413     im1 = i - 1
414     ip1 = i + 1
415     shsq(i,j,k) = p5 * (
416     $ (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) *
417     $ (uVel(i, j, k,bi,bj)-uVel(i, j, kp1,bi,bj)) +
418     $ (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) *
419     $ (uVel(ip1,j, k,bi,bj)-uVel(ip1,j, kp1,bi,bj)) +
420     $ (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) *
421     $ (vVel(i, j, k,bi,bj)-vVel(i, j, kp1,bi,bj)) +
422     $ (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) *
423     $ (vVel(i, jp1,k,bi,bj)-vVel(i, jp1,kp1,bi,bj)) )
424 adcroft 1.1 #ifdef KPP_SMOOTH_SHSQ
425 mlosch 1.41 shsq(i,j,k) = p5 * shsq(i,j,k) + p125 * (
426     $ (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) *
427     $ (uVel(i, jm1,k,bi,bj)-uVel(i, jm1,kp1,bi,bj)) +
428     $ (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) *
429     $ (uVel(ip1,jm1,k,bi,bj)-uVel(ip1,jm1,kp1,bi,bj)) +
430     $ (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) *
431     $ (uVel(i, jp1,k,bi,bj)-uVel(i, jp1,kp1,bi,bj)) +
432     $ (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) *
433     $ (uVel(ip1,jp1,k,bi,bj)-uVel(ip1,jp1,kp1,bi,bj)) +
434     $ (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) *
435     $ (vVel(im1,j, k,bi,bj)-vVel(im1,j, kp1,bi,bj)) +
436     $ (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) *
437     $ (vVel(im1,jp1,k,bi,bj)-vVel(im1,jp1,kp1,bi,bj)) +
438     $ (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) *
439     $ (vVel(ip1,j, k,bi,bj)-vVel(ip1,j, kp1,bi,bj)) +
440     $ (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) *
441     $ (vVel(ip1,jp1,k,bi,bj)-vVel(ip1,jp1,kp1,bi,bj)) )
442 adcroft 1.1 #endif
443 mlosch 1.41 END DO
444     END DO
445 adcroft 1.1 END DO
446    
447 heimbach 1.11 cph(
448 heimbach 1.27 #ifdef KPP_AUTODIFF_EXCESSIVE_STORE
449 heimbach 1.16 CADJ store dvsq, shsq = comlev1_kpp, key = ikppkey
450 heimbach 1.11 #endif
451     cph)
452    
453 adcroft 1.1 c-----------------------------------------------------------------------
454     c solve for viscosity, diffusivity, ghat, and hbl on "t-grid"
455     c-----------------------------------------------------------------------
456    
457 dimitri 1.36 c precompute background vertical diffusivities, which are needed for
458     c matching diffusivities at bottom of KPP PBL
459     CALL CALC_3D_DIFFUSIVITY(
460     I bi,bj,1-Olx,sNx+OLx,1-Oly,sNy+OLy,
461     I GAD_SALINITY, .FALSE., .FALSE.,
462     O KPPdiffKzS(1-Olx,1-Oly,1,bi,bj),
463     I myThid)
464     CALL CALC_3D_DIFFUSIVITY(
465     I bi,bj,1-Olx,sNx+OLx,1-Oly,sNy+OLy,
466     I GAD_TEMPERATURE, .FALSE., .FALSE.,
467     O KPPdiffKzT(1-Olx,1-Oly,1,bi,bj),
468     I myThid)
469    
470 dimitri 1.34 DO j = 1-OLy, sNy+OLy
471     DO i = 1-OLx, sNx+OLx
472 adcroft 1.1 work1(i,j) = nzmax(i,j,bi,bj)
473     work2(i,j) = Fcori(i,j,bi,bj)
474     END DO
475     END DO
476     CALL TIMER_START('KPPMIX [KPP_CALC]', myThid)
477     CALL KPPMIX (
478 mlosch 1.40 I work1, shsq, dVsq, ustar
479     I , maskC(1-Olx,1-Oly,1,bi,bj)
480 adcroft 1.1 I , bo, bosol, dbloc, Ritop, work2
481 dimitri 1.36 I , KPPdiffKzS(1-Olx,1-Oly,1,bi,bj)
482     I , KPPdiffKzT(1-Olx,1-Oly,1,bi,bj)
483 heimbach 1.16 I , ikppkey
484 adcroft 1.1 O , vddiff
485     U , ghat
486 mlosch 1.40 O , hbl
487     I , mytime, mythid )
488 adcroft 1.1 CALL TIMER_STOP ('KPPMIX [KPP_CALC]', myThid)
489    
490     c-----------------------------------------------------------------------
491 heimbach 1.4 c zero out land values and transfer to global variables
492 adcroft 1.1 c-----------------------------------------------------------------------
493    
494     DO j = jmin, jmax
495 heimbach 1.4 DO i = imin, imax
496     DO k = 1, Nr
497 mlosch 1.35 km1 = max(1,k-1)
498 jmc 1.28 KPPviscAz(i,j,k,bi,bj) = vddiff(i,j,k-1,1) * maskC(i,j,k,bi,bj)
499 mlosch 1.35 & * maskC(i,j,km1,bi,bj)
500 jmc 1.28 KPPdiffKzS(i,j,k,bi,bj)= vddiff(i,j,k-1,2) * maskC(i,j,k,bi,bj)
501 mlosch 1.35 & * maskC(i,j,km1,bi,bj)
502 jmc 1.28 KPPdiffKzT(i,j,k,bi,bj)= vddiff(i,j,k-1,3) * maskC(i,j,k,bi,bj)
503 mlosch 1.35 & * maskC(i,j,km1,bi,bj)
504 jmc 1.28 KPPghat(i,j,k,bi,bj) = ghat(i,j,k) * maskC(i,j,k,bi,bj)
505 mlosch 1.35 & * maskC(i,j,km1,bi,bj)
506 heimbach 1.4 END DO
507 mlosch 1.35 k = 1
508     #ifdef ALLOW_SHELFICE
509     if ( useShelfIce ) k = kTopC(i,j,bi,bj)
510     #endif /* ALLOW_SHELFICE */
511     KPPhbl(i,j,bi,bj) = hbl(i,j) * maskC(i,j,k,bi,bj)
512    
513 heimbach 1.4 END DO
514 adcroft 1.1 END DO
515    
516     #ifdef KPP_SMOOTH_VISC
517     c horizontal smoothing of vertical viscosity
518     DO k = 1, Nr
519 heimbach 1.4 CALL SMOOTH_HORIZ (
520 adcroft 1.1 I k, bi, bj,
521 mlosch 1.40 U KPPviscAz(1-OLx,1-OLy,k,bi,bj),
522     I myThid )
523 adcroft 1.1 END DO
524 heimbach 1.4 _EXCH_XYZ_R8(KPPviscAz , myThid )
525 adcroft 1.1 #endif /* KPP_SMOOTH_VISC */
526    
527     #ifdef KPP_SMOOTH_DIFF
528     c horizontal smoothing of vertical diffusivity
529     DO k = 1, Nr
530 heimbach 1.4 CALL SMOOTH_HORIZ (
531 adcroft 1.1 I k, bi, bj,
532 mlosch 1.40 U KPPdiffKzS(1-OLx,1-OLy,k,bi,bj),
533     I myThid )
534 heimbach 1.4 CALL SMOOTH_HORIZ (
535 adcroft 1.1 I k, bi, bj,
536 mlosch 1.40 U KPPdiffKzT(1-OLx,1-OLy,k,bi,bj),
537     I myThid )
538 adcroft 1.1 END DO
539 heimbach 1.4 _EXCH_XYZ_R8(KPPdiffKzS , myThid )
540     _EXCH_XYZ_R8(KPPdiffKzT , myThid )
541 adcroft 1.1 #endif /* KPP_SMOOTH_DIFF */
542 heimbach 1.11
543     cph(
544     cph crucial: this avoids full recomp./call of kppmix
545 heimbach 1.16 CADJ store KPPhbl = comlev1_kpp, key = ikppkey
546 heimbach 1.11 cph)
547 adcroft 1.1
548     C Compute fraction of solar short-wave flux penetrating to
549     C the bottom of the mixing layer.
550     DO j=1-OLy,sNy+OLy
551     DO i=1-OLx,sNx+OLx
552     worka(i,j) = KPPhbl(i,j,bi,bj)
553     ENDDO
554     ENDDO
555     CALL SWFRAC(
556 heimbach 1.4 I (sNx+2*OLx)*(sNy+2*OLy), minusone,
557     I mytime, mythid,
558     U worka )
559 adcroft 1.1 DO j=1-OLy,sNy+OLy
560     DO i=1-OLx,sNx+OLx
561 heimbach 1.4 KPPfrac(i,j,bi,bj) = worka(i,j)
562 adcroft 1.1 ENDDO
563     ENDDO
564    
565     ENDIF
566    
567 adcroft 1.9 #endif /* ALLOW_KPP */
568 adcroft 1.1
569 heimbach 1.8 RETURN
570     END
571    
572     subroutine KPP_CALC_DUMMY(
573     I bi, bj, myTime, myThid )
574     C /==========================================================\
575     C | SUBROUTINE KPP_CALC_DUMMY |
576     C | o Compute all KPP fields defined in KPP.h |
577     C | o Dummy routine for TAMC
578     C |==========================================================|
579     C | This subroutine serves as an interface between MITGCMUV |
580     C | code and NCOM 1-D routines in kpp_routines.F |
581     C \==========================================================/
582     IMPLICIT NONE
583    
584     #include "SIZE.h"
585     #include "EEPARAMS.h"
586     #include "PARAMS.h"
587     #include "KPP.h"
588     #include "KPP_PARAMS.h"
589     #include "GRID.h"
590 dimitri 1.36 #include "GAD.h"
591 heimbach 1.8
592     c Routine arguments
593     c bi, bj - array indices on which to apply calculations
594     c myTime - Current time in simulation
595    
596     INTEGER bi, bj
597     INTEGER myThid
598     _RL myTime
599    
600     #ifdef ALLOW_KPP
601    
602     c Local constants
603     integer i, j, k
604    
605     DO j=1-OLy,sNy+OLy
606     DO i=1-OLx,sNx+OLx
607     KPPhbl (i,j,bi,bj) = 1.0
608     KPPfrac(i,j,bi,bj) = 0.0
609     DO k = 1,Nr
610     KPPghat (i,j,k,bi,bj) = 0.0
611 jmc 1.21 KPPviscAz (i,j,k,bi,bj) = viscAr
612 heimbach 1.8 ENDDO
613     ENDDO
614     ENDDO
615 dimitri 1.36
616     CALL CALC_3D_DIFFUSIVITY(
617     I bi,bj,1-Olx,sNx+OLx,1-Oly,sNy+OLy,
618     I GAD_SALINITY, .FALSE., .FALSE.,
619     O KPPdiffKzS(1-Olx,1-Oly,1,bi,bj),
620     I myThid)
621     CALL CALC_3D_DIFFUSIVITY(
622     I bi,bj,1-Olx,sNx+OLx,1-Oly,sNy+OLy,
623     I GAD_TEMPERATURE, .FALSE., .FALSE.,
624     O KPPdiffKzT(1-Olx,1-Oly,1,bi,bj),
625     I myThid)
626    
627 heimbach 1.8 #endif
628 adcroft 1.1 RETURN
629     END

  ViewVC Help
Powered by ViewVC 1.1.22