1 |
C $Header: /u/gcmpack/MITgcm/pkg/mom_vecinv/mom_vi_v_vertshear.F,v 1.7 2005/06/22 00:33:14 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "MOM_VECINV_OPTIONS.h" |
5 |
|
6 |
SUBROUTINE MOM_VI_V_VERTSHEAR( |
7 |
I bi,bj,K, |
8 |
I vFld,wFld, |
9 |
U vShearTerm, |
10 |
I myThid) |
11 |
IMPLICIT NONE |
12 |
C *==========================================================* |
13 |
C | S/R MOM_V_VERTSHEAR |
14 |
C *==========================================================* |
15 |
C *==========================================================* |
16 |
|
17 |
C == Global variables == |
18 |
#include "SIZE.h" |
19 |
#include "EEPARAMS.h" |
20 |
#include "GRID.h" |
21 |
#include "PARAMS.h" |
22 |
|
23 |
C == Routine arguments == |
24 |
INTEGER bi,bj,K |
25 |
_RL vFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
26 |
_RL wFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
27 |
_RL vShearTerm(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
28 |
INTEGER myThid |
29 |
|
30 |
C == Local variables == |
31 |
INTEGER I,J,Kp1,Km1 |
32 |
_RL mask_Kp1,mask_Km1,wBarYm,wBarYp |
33 |
_RL vZm,vZp |
34 |
LOGICAL rAdvAreaWeight |
35 |
PARAMETER( rAdvAreaWeight =.TRUE.) |
36 |
c _RL vmask_Kp1,vmask_K,vmask_Km1 |
37 |
c LOGICAL freeslipK,noslipK |
38 |
c PARAMETER(freeslipK=.TRUE.) |
39 |
c PARAMETER(noslipK=.NOT.freeslipK) |
40 |
c LOGICAL freeslip1,noslip1 |
41 |
c PARAMETER(freeslip1=.TRUE.) |
42 |
c PARAMETER(noslip1=.NOT.freeslip1) |
43 |
c1 _RL wBarYZ,vZbarZ |
44 |
|
45 |
Kp1=min(K+1,Nr) |
46 |
mask_Kp1=1. |
47 |
IF (K.EQ.Nr) mask_Kp1=0. |
48 |
Km1=max(K-1,1) |
49 |
mask_Km1=1. |
50 |
IF (K.EQ.1) mask_Km1=0. |
51 |
|
52 |
DO J=2-Oly,sNy+Oly |
53 |
DO I=1-Olx,sNx+Olx |
54 |
|
55 |
c vmask_K=_maskS(i,j,k,bi,bj) |
56 |
|
57 |
C barZ( barY( W ) ) |
58 |
c wBarYm=0.5*(wFld(I,J,K,bi,bj)+wFld(I,J-1,K,bi,bj)) |
59 |
c wBarYp=0.5*(wFld(I,J,Kp1,bi,bj)+wFld(I,J-1,Kp1,bi,bj)) |
60 |
c & *mask_Kp1 |
61 |
|
62 |
IF ( rAdvAreaWeight ) THEN |
63 |
C Transport at interface k : Area weighted average |
64 |
wBarYm=0.5*( |
65 |
& wFld(I,J,K,bi,bj)*rA(i,j,bi,bj)*maskC(i,j,Km1,bi,bj) |
66 |
& +wFld(I,J-1,K,bi,bj)*rA(i,j-1,bi,bj)*maskC(i,j-1,Km1,bi,bj) |
67 |
& )*mask_Km1 |
68 |
& *recip_rAs(i,j,bi,bj) |
69 |
|
70 |
C Transport at interface k+1 (here wFld is already masked) |
71 |
wBarYp=0.5*( |
72 |
& wFld(I,J,Kp1,bi,bj)*rA(i,j,bi,bj) |
73 |
& +wFld(I,J-1,Kp1,bi,bj)*rA(i,j-1,bi,bj) |
74 |
& )*mask_Kp1 |
75 |
& *recip_rAs(i,j,bi,bj) |
76 |
ELSE |
77 |
C Transport at interface k : simple average |
78 |
wBarYm=0.5*( |
79 |
& wFld(I,J,K,bi,bj)*maskC(i,j,Km1,bi,bj) |
80 |
& +wFld(I,J-1,K,bi,bj)*maskC(i,j-1,Km1,bi,bj) |
81 |
& )*mask_Km1 |
82 |
|
83 |
C Transport at interface k+1 (here wFld is already masked) |
84 |
wBarYp=0.5*( |
85 |
& wFld(I,J,Kp1,bi,bj) |
86 |
& +wFld(I,J-1,Kp1,bi,bj) |
87 |
& )*mask_Kp1 |
88 |
ENDIF |
89 |
|
90 |
C delta_Z( V ) @ interface k |
91 |
c vmask_Km1=mask_Km1*maskS(i,j,Km1,bi,bj) |
92 |
vZm=(vFld(I,J,K,bi,bj)-mask_Km1*vFld(I,J,Km1,bi,bj))*rkSign |
93 |
c2 & *recip_dRC(K) |
94 |
c IF (freeslip1) vZm=vZm*vmask_Km1 |
95 |
c IF (noslip1.AND.vmask_Km1.EQ.0.) vZm=vZm*2. |
96 |
|
97 |
C delta_Z( V ) @ interface k+1 |
98 |
c vmask_Kp1=mask_Kp1*maskS(i,j,Kp1,bi,bj) |
99 |
vZp=(mask_Kp1*vFld(I,J,Kp1,bi,bj)-vFld(I,J,K,bi,bj))*rkSign |
100 |
c2 & *recip_dRC(Kp1) |
101 |
c IF (freeslipK) vZp=vZp*vmask_Kp1 |
102 |
c IF (noslipK.AND.vmask_Kp1.EQ.0.) vZp=vZp*2. |
103 |
|
104 |
c1 IF (upwindShear) THEN |
105 |
c1 wBarYZ=0.5*( wBarXm + wBarXp ) |
106 |
c1 IF (wBarYZ.GT.0.) THEN |
107 |
c1 vZbarZ=vZp |
108 |
c1 ELSE |
109 |
c1 vZbarZ=vZm |
110 |
c1 ENDIF |
111 |
c1 ELSE |
112 |
c1 vZbarZ=0.5*(vZm+vZp) |
113 |
c1 ENDIF |
114 |
c1 vShearTerm(I,J)=-wBarYZ*vZbarZ*_maskS(I,J,K,bi,bj) |
115 |
|
116 |
c2 vShearTerm(I,J)=-0.5*(wBarYp*vZp+wBarYm*vZm) |
117 |
c2 & *_maskS(I,J,K,bi,bj) |
118 |
IF (upwindShear) THEN |
119 |
vShearTerm(I,J)=-0.5* |
120 |
& ( (wBarYp*vZp+wBarYm*vZm) |
121 |
& +(ABS(wBarYp)*vZp-ABS(wBarYm)*vZm) |
122 |
& )*recip_hFacS(i,j,k,bi,bj) |
123 |
& *recip_drF(K) |
124 |
c3 & *recip_rAs(i,j,bi,bj) |
125 |
ELSE |
126 |
vShearTerm(I,J)=-0.5*(wBarYp*vZp+wBarYm*vZm) |
127 |
& *recip_hFacS(i,j,k,bi,bj) |
128 |
& *recip_drF(K) |
129 |
c3 & *recip_rAs(i,j,bi,bj) |
130 |
ENDIF |
131 |
ENDDO |
132 |
ENDDO |
133 |
|
134 |
RETURN |
135 |
END |