1 |
jmc |
1.1 |
C $Header: $ |
2 |
|
|
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "MOM_FLUXFORM_OPTIONS.h" |
5 |
|
|
|
6 |
|
|
CBOP |
7 |
|
|
C !ROUTINE: MOM_UV_BOUNDARY |
8 |
|
|
|
9 |
|
|
C !INTERFACE: ========================================================== |
10 |
|
|
SUBROUTINE MOM_UV_BOUNDARY ( |
11 |
|
|
I bi,bj,k, |
12 |
|
|
I uFld, vFld, |
13 |
|
|
O uBnd, vBnd, |
14 |
|
|
I myTime, myIter, myThid ) |
15 |
|
|
|
16 |
|
|
C !DESCRIPTION: |
17 |
|
|
C Set velocity at a boundary for a momentum conserving advection |
18 |
|
|
C Note: really conserve momentum when "steps" (vertical plane) |
19 |
|
|
C or coastline (horizontal plane) are only 1 grid-point wide. |
20 |
|
|
|
21 |
|
|
C !USES: =============================================================== |
22 |
|
|
C == Global variables == |
23 |
|
|
IMPLICIT NONE |
24 |
|
|
#include "SIZE.h" |
25 |
|
|
#include "EEPARAMS.h" |
26 |
|
|
#include "PARAMS.h" |
27 |
|
|
#include "GRID.h" |
28 |
|
|
|
29 |
|
|
C !INPUT PARAMETERS: =================================================== |
30 |
|
|
C bi,bj :: tile indices |
31 |
|
|
C k :: vertical level |
32 |
|
|
C uFld :: zonal velocity |
33 |
|
|
C vFld :: meridional velocity |
34 |
|
|
C myTime :: current time |
35 |
|
|
C myIter :: current iteration number |
36 |
|
|
C myThid :: My Thread Id. number |
37 |
|
|
INTEGER bi,bj |
38 |
|
|
INTEGER k |
39 |
|
|
_RL uFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
40 |
|
|
_RL vFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
41 |
|
|
_RL myTime |
42 |
|
|
INTEGER myIter |
43 |
|
|
INTEGER myThid |
44 |
|
|
|
45 |
|
|
C !OUTPUT PARAMETERS: ================================================== |
46 |
|
|
C uBnd :: zonal velocity extended to boundaries |
47 |
|
|
C vBnd :: meridional velocity extended to boundaries |
48 |
|
|
_RL uBnd(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
49 |
|
|
_RL vBnd(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
50 |
|
|
|
51 |
|
|
#ifdef MOM_BOUNDARY_CONSERVE |
52 |
|
|
C !LOCAL VARIABLES: ==================================================== |
53 |
|
|
C i,j :: loop indices |
54 |
|
|
INTEGER i,j |
55 |
|
|
INTEGER km1,kp1 |
56 |
|
|
_RL maskM1, maskP1 |
57 |
|
|
_RL uTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
58 |
|
|
_RL vTrans(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
59 |
|
|
_RL aBndU(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
60 |
|
|
_RL aBndV(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
61 |
|
|
_RL aBndW(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
62 |
|
|
_RL tmpVar |
63 |
|
|
LOGICAL useMomBndConserve |
64 |
|
|
PARAMETER ( useMomBndConserve = .TRUE. ) |
65 |
|
|
CEOP |
66 |
|
|
|
67 |
|
|
C Initialise output array |
68 |
|
|
DO j=1-OLy,sNy+OLy |
69 |
|
|
DO i=1-OLx,sNx+OLx |
70 |
|
|
uBnd(i,j) = uFld(i,j,k,bi,bj) |
71 |
|
|
vBnd(i,j) = vFld(i,j,k,bi,bj) |
72 |
|
|
ENDDO |
73 |
|
|
ENDDO |
74 |
|
|
|
75 |
|
|
IF ( useMomBndConserve ) THEN |
76 |
|
|
|
77 |
|
|
C- Initialise intermediate arrays: |
78 |
|
|
km1 = MAX( k-1, 1 ) |
79 |
|
|
kp1 = MIN( k+1, Nr ) |
80 |
|
|
maskM1 = 1. |
81 |
|
|
maskP1 = 1. |
82 |
|
|
IF ( k.EQ.1 ) maskM1 = 0. |
83 |
|
|
IF ( k.EQ.Nr ) maskP1 = 0. |
84 |
|
|
DO j=1-OLy,sNy+OLy |
85 |
|
|
DO i=1-OLx,sNx+OLx |
86 |
|
|
aBndU(i,j) = 0. |
87 |
|
|
aBndV(i,j) = 0. |
88 |
|
|
aBndW(i,j) = 0. |
89 |
|
|
ENDDO |
90 |
|
|
ENDDO |
91 |
|
|
|
92 |
|
|
C- Calculate Divergence in 3 directions: |
93 |
|
|
DO j=1-OLy,sNy+OLy |
94 |
|
|
DO i=1-OLx,sNx+OLx |
95 |
|
|
uTrans(i,j) = uFld(i,j,k,bi,bj) |
96 |
|
|
& * dyG(i,j,bi,bj)*deepFacC(k) |
97 |
|
|
& * drF(k)*hFacW(i,j,k,bi,bj)*rhoFacC(k) |
98 |
|
|
vTrans(i,j) = vFld(i,j,k,bi,bj) |
99 |
|
|
& * dxG(i,j,bi,bj)*deepFacC(k) |
100 |
|
|
& * drF(k)*hFacS(i,j,k,bi,bj)*rhoFacC(k) |
101 |
|
|
ENDDO |
102 |
|
|
ENDDO |
103 |
|
|
DO j=1-OLy,sNy+OLy-1 |
104 |
|
|
DO i=1-OLx,sNx+OLx-1 |
105 |
|
|
aBndU(i,j) = uTrans(i+1,j)-uTrans(i,j) |
106 |
|
|
aBndV(i,j) = vTrans(i,j+1)-vTrans(i,j) |
107 |
|
|
aBndW(i,j) = ABS(aBndU(i,j)+aBndV(i,j)) |
108 |
|
|
aBndU(i,j) = ABS(aBndU(i,j)) |
109 |
|
|
aBndV(i,j) = ABS(aBndV(i,j)) |
110 |
|
|
ENDDO |
111 |
|
|
ENDDO |
112 |
|
|
C- Normalise by the sum: |
113 |
|
|
DO j=1-OLy,sNy+OLy-1 |
114 |
|
|
DO i=1-OLx,sNx+OLx-1 |
115 |
|
|
tmpVar = aBndU(i,j)+aBndV(i,j)+aBndW(i,j) |
116 |
|
|
IF ( tmpVar.GT.0. ) THEN |
117 |
|
|
tmpVar = 1. _d 0 / tmpVar |
118 |
|
|
aBndU(i,j) = aBndU(i,j)*tmpVar |
119 |
|
|
aBndV(i,j) = aBndV(i,j)*tmpVar |
120 |
|
|
aBndW(i,j) = aBndW(i,j)*tmpVar |
121 |
|
|
ENDIF |
122 |
|
|
ENDDO |
123 |
|
|
ENDDO |
124 |
|
|
|
125 |
|
|
C- At a boundary, replace uFld,vFld by a weighted average |
126 |
|
|
C Note: multiply by 2 to cancel the 1/2 factor in advections S/R |
127 |
|
|
DO j=1-OLy+1,sNy+OLy-1 |
128 |
|
|
DO i=1-OLx+1,sNx+OLx-1 |
129 |
|
|
IF (maskW(i,j,k,bi,bj).EQ.0.) THEN |
130 |
|
|
C Note: only 1 set of aBnd_U,V,W is non-zero (either i-1 or i) |
131 |
|
|
C and only 1 uFld is non-zero (either i-1 or i+1) |
132 |
|
|
C and only 1 uFld is non-zero (either k-1 or k+1) |
133 |
|
|
uBnd(i,j) = ( |
134 |
|
|
& (aBndU(i-1,j)+aBndU(i,j)) |
135 |
|
|
& *(uFld(i-1,j,k,bi,bj)+uFld(i+1,j,k,bi,bj)) |
136 |
|
|
& +(aBndV(i-1,j)+aBndV(i,j)) |
137 |
|
|
& *(uFld(i,j-1,k,bi,bj)+uFld(i,j+1,k,bi,bj)) |
138 |
|
|
& +(aBndW(i-1,j)+aBndW(i,j)) |
139 |
|
|
& *(uFld(i,j,km1,bi,bj)*maskM1 |
140 |
|
|
& +uFld(i,j,kp1,bi,bj)*maskP1) |
141 |
|
|
& )*2. _d 0 |
142 |
|
|
ENDIF |
143 |
|
|
IF (maskS(i,j,k,bi,bj).EQ.0.) THEN |
144 |
|
|
C Note: only 1 set of aBnd_U,V,W is non-zero (either j-1 or j) |
145 |
|
|
C and only 1 vFld is non-zero (either j-1 or j+1) |
146 |
|
|
C and only 1 vFld is non-zero (either k-1 or k+1) |
147 |
|
|
vBnd(i,j) = ( |
148 |
|
|
& (aBndU(i,j-1)+aBndU(i,j)) |
149 |
|
|
& *(vFld(i-1,j,k,bi,bj)+vFld(i+1,j,k,bi,bj)) |
150 |
|
|
& +(aBndV(i,j-1)+aBndV(i,j)) |
151 |
|
|
& *(vFld(i,j-1,k,bi,bj)+vFld(i,j+1,k,bi,bj)) |
152 |
|
|
& +(aBndW(i,j-1)+aBndW(i,j)) |
153 |
|
|
& *(vFld(i,j,km1,bi,bj)*maskM1 |
154 |
|
|
& +vFld(i,j,kp1,bi,bj)*maskP1) |
155 |
|
|
& )*2. _d 0 |
156 |
|
|
ENDIF |
157 |
|
|
ENDDO |
158 |
|
|
ENDDO |
159 |
|
|
ENDIF |
160 |
|
|
#endif /* MOM_BOUNDARY_CONSERVE */ |
161 |
|
|
|
162 |
|
|
RETURN |
163 |
|
|
END |