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