1 |
C $Header: /u/gcmpack/MITgcm/pkg/my82/my82_ri_number.F,v 1.4 2008/08/11 22:28:06 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "MY82_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: MY82_RI_NUMBER |
8 |
|
9 |
C !INTERFACE: ========================================================== |
10 |
subroutine MY82_RI_NUMBER( |
11 |
I bi, bj, K, iMin, iMax, jMin, jMax, |
12 |
O RiNumber, buoyFreq, vertShear, |
13 |
I myTime, myThid ) |
14 |
|
15 |
C !DESCRIPTION: \bv |
16 |
C /==========================================================\ |
17 |
C | SUBROUTINE MY82_RI_NUMBER | |
18 |
C | o Compute gradient Richardson number for Mellor and | |
19 |
C | Yamada (1981) turbulence model | |
20 |
C \==========================================================/ |
21 |
IMPLICIT NONE |
22 |
c |
23 |
c------------------------------------------------------------------------- |
24 |
|
25 |
c \ev |
26 |
|
27 |
C !USES: =============================================================== |
28 |
#include "SIZE.h" |
29 |
#include "EEPARAMS.h" |
30 |
#include "PARAMS.h" |
31 |
#include "DYNVARS.h" |
32 |
#include "MY82.h" |
33 |
#include "GRID.h" |
34 |
|
35 |
C !INPUT PARAMETERS: =================================================== |
36 |
C Routine arguments |
37 |
C bi, bj - array indices on which to apply calculations |
38 |
C iMin, iMax, jMin, jMax |
39 |
C - array boundaries |
40 |
C k - depth level |
41 |
C myTime - Current time in simulation |
42 |
C RiNumber - (output) Richardson number |
43 |
C buoyFreq - (output) (neg.) buoyancy frequency -N^2 |
44 |
C vertShear - (output) vertical shear of velocity |
45 |
INTEGER bi, bj, iMin, iMax, jMin, jMax, k |
46 |
INTEGER myThid |
47 |
_RL myTime |
48 |
_RL RiNumber (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
49 |
_RL buoyFreq (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
50 |
_RL vertShear (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
51 |
|
52 |
#ifdef ALLOW_MY82 |
53 |
|
54 |
C !LOCAL VARIABLES: ==================================================== |
55 |
C I,J,kUp - loop indices |
56 |
C p0-125 - averaging coefficients |
57 |
C tempu, tempv - temporary variables |
58 |
C rhoK, rhoKm1 - Density below and above current interface |
59 |
C epsilon - small number |
60 |
INTEGER I,J,Km1 |
61 |
_RL p5 , p125 |
62 |
PARAMETER( p5=0.5D0, p125=0.125D0 ) |
63 |
_RL tempu, tempv |
64 |
_RL epsilon |
65 |
PARAMETER ( epsilon = 1.D-10 ) |
66 |
_RL rhoKm1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
67 |
_RL rhoK (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
68 |
#ifdef MY82_SMOOTH_RI |
69 |
_RL RiTmp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
70 |
#endif /* MY82_SMOOTH_RI */ |
71 |
CEOP |
72 |
|
73 |
Km1 = MAX(1,K-1) |
74 |
C Not sure what is correct for pressure coordinates: |
75 |
C RiFlux is always correct because it quadratic |
76 |
C buoyFreq should also be correct in pressure coordinates: |
77 |
C N^2=g^2drho/dp and K=1 at the bottom leads to the correct sign |
78 |
C So the following is wrong: |
79 |
CML IF ( buoyancyRelation .EQ. 'OCEANIC') THEN |
80 |
CML kUp = MAX(1,K-1) |
81 |
CML kDown = K |
82 |
CML ELSEIF ( buoyancyRelation .EQ. 'OCEANIP') THEN |
83 |
CML kUp = K |
84 |
CML kDown = MAX(1,K-1) |
85 |
CML ELSE |
86 |
CML STOP 'MY82_RI_NUMBER: We should never reach this point' |
87 |
CML ENDIF |
88 |
C preparation: find density a kth and k-1st level |
89 |
CALL FIND_RHO_2D( |
90 |
I iMin, iMax, jMin, jMax, K, |
91 |
I theta(1-OLx,1-OLy,Km1,bi,bj), salt(1-OLx,1-OLy,Km1,bi,bj), |
92 |
O rhoKm1, |
93 |
I Km1, bi, bj, myThid ) |
94 |
CALL FIND_RHO_2D( |
95 |
I iMin, iMax, jMin, jMax, K, |
96 |
I theta(1-OLx,1-OLy,K,bi,bj), salt(1-OLx,1-OLy,K,bi,bj), |
97 |
O rhoK, |
98 |
I K, bi, bj, myThid ) |
99 |
|
100 |
C first step: calculate flux Richardson number. |
101 |
C calculate (du/dz)^2 + (dv/dz)^2 on W (between T) points. |
102 |
DO J= jMin, jMax |
103 |
DO I = iMin, iMax |
104 |
tempu= .5 _d 0*( uVel(I,J,Km1,bi,bj)+uVel(I+1,J,Km1,bi,bj) |
105 |
& - (uVel(I,J,K ,bi,bj)+uVel(I+1,J,K ,bi,bj)) ) |
106 |
& *recip_drC(K) |
107 |
tempv= .5 _d 0*( vVel(I,J,Km1,bi,bj)+vVel(I,J+1,Km1,bi,bj) |
108 |
& - (vVel(I,J,K ,bi,bj)+vVel(I,J+1,K ,bi,bj)) ) |
109 |
& *recip_drC(K) |
110 |
vertShear(I,J) = tempu*tempu+tempv*tempv |
111 |
|
112 |
C |
113 |
C calculate g*(drho/dz)/rho0= -N^2 . |
114 |
C |
115 |
buoyFreq(I,J) = gravity*mass2rUnit * |
116 |
& (rhoKm1(I,J) - rhoK(I,J))*recip_drC(K) |
117 |
C |
118 |
C calculates gradient Richardson number, bounded by |
119 |
C a very large negative value. |
120 |
C |
121 |
RiNumber(I,J) = -buoyFreq(I,J)/max(vertShear(I,J),epsilon) |
122 |
|
123 |
ENDDO |
124 |
ENDDO |
125 |
|
126 |
#ifdef MY82_SMOOTH_RI |
127 |
C average Richardson number horizontally |
128 |
DO J=jMin,jMax |
129 |
DO I=iMin,iMax |
130 |
RiTmp(I,J) = RiNumber(I,J) |
131 |
ENDDO |
132 |
ENDDO |
133 |
DO J=1-Oly+1,sNy+Oly-1 |
134 |
DO I=1-Olx+1,sNx+Olx-1 |
135 |
RiNumber(I,J) = p5*RiTmp(I,J) |
136 |
& + p125*RiTmp(I-1,J) + p125*RiTmp(I+1,J) |
137 |
& + p125*RiTmp(I,J-1) + p125*RiTmp(I,J+1) |
138 |
ENDDO |
139 |
ENDDO |
140 |
#endif /* MY82_SMOOTH_RI */ |
141 |
|
142 |
#endif /* ALLOW_MY82 */ |
143 |
|
144 |
RETURN |
145 |
END |