1 |
jmc |
1.4 |
C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_uv_dgrid_3d_rx.template,v 1.3 2009/06/28 00:57:51 jmc Exp $ |
2 |
jmc |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "CPP_EEOPTIONS.h" |
5 |
|
|
#include "W2_OPTIONS.h" |
6 |
|
|
|
7 |
|
|
CBOP |
8 |
|
|
C !ROUTINE: EXCH2_UV_DGRID_3D_RX |
9 |
|
|
|
10 |
|
|
C !INTERFACE: |
11 |
|
|
SUBROUTINE EXCH2_UV_DGRID_3D_RX( |
12 |
|
|
U uPhi, vPhi, |
13 |
|
|
I withSigns, myNz, myThid ) |
14 |
|
|
|
15 |
|
|
C !DESCRIPTION: |
16 |
|
|
C*=====================================================================* |
17 |
|
|
C Purpose: SUBROUTINE EXCH2_UV_DGRID_3D_RX |
18 |
|
|
C handle exchanges for a 3D vector field on an D-grid. |
19 |
|
|
C |
20 |
|
|
C Input: |
21 |
|
|
C uPhi(lon,lat,levs,bi,bj) :: first component of vector |
22 |
|
|
C vPhi(lon,lat,levs,bi,bj) :: second component of vector |
23 |
|
|
C withSigns (logical) :: true to use sign of components |
24 |
|
|
C myNz :: 3rd dimension of input arrays uPhi,vPhi |
25 |
|
|
C myThid :: my Thread Id number |
26 |
|
|
C |
27 |
|
|
C Output: uPhi and vPhi are updated (halo regions filled) |
28 |
|
|
C |
29 |
|
|
C Calls: EXCH_RX (EXCH2_RX2_CUBE) ignoring sign |
30 |
|
|
C then put back the right signs |
31 |
|
|
C |
32 |
|
|
C*=====================================================================* |
33 |
|
|
|
34 |
|
|
C !USES: |
35 |
|
|
IMPLICIT NONE |
36 |
|
|
|
37 |
|
|
#include "SIZE.h" |
38 |
|
|
#include "EEPARAMS.h" |
39 |
jmc |
1.2 |
#include "W2_EXCH2_SIZE.h" |
40 |
jmc |
1.1 |
#include "W2_EXCH2_TOPOLOGY.h" |
41 |
|
|
|
42 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
43 |
|
|
C == Argument list variables == |
44 |
|
|
INTEGER myNz |
45 |
|
|
_RX uPhi(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNz,nSx,nSy) |
46 |
|
|
_RX vPhi(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNz,nSx,nSy) |
47 |
|
|
LOGICAL withSigns |
48 |
|
|
INTEGER myThid |
49 |
|
|
|
50 |
|
|
C !LOCAL VARIABLES: |
51 |
|
|
C == Local variables == |
52 |
|
|
C i,j,k,bi,bj :: loop indices. |
53 |
|
|
C OL[wens] :: Overlap extents in west, east, north, south. |
54 |
|
|
C exchWidth[XY] :: Extent of regions that will be exchanged. |
55 |
|
|
|
56 |
|
|
INTEGER i,j,k,bi,bj |
57 |
|
|
INTEGER OLw, OLe, OLn, OLs, exchWidthX, exchWidthY |
58 |
|
|
_RX negOne |
59 |
|
|
INTEGER myTile, myFace |
60 |
|
|
CEOP |
61 |
|
|
|
62 |
|
|
OLw = OLx |
63 |
|
|
OLe = OLx |
64 |
|
|
OLn = OLy |
65 |
|
|
OLs = OLy |
66 |
|
|
exchWidthX = OLx |
67 |
|
|
exchWidthY = OLy |
68 |
|
|
negOne = 1. |
69 |
|
|
IF (withSigns) negOne = -1. |
70 |
|
|
|
71 |
|
|
C-- First call the exchanges for the two components, ignoring the Sign |
72 |
|
|
C note the order: vPhi,uPhi on D-grid are co-located with (u,v)_Cgrid |
73 |
|
|
|
74 |
jmc |
1.4 |
c CALL EXCH2_RX2_CUBE( vPhi, uPhi, .FALSE., 'Cg', |
75 |
jmc |
1.1 |
c I OLw, OLe, OLs, OLn, myNz, |
76 |
|
|
c I exchWidthX, exchWidthY, |
77 |
jmc |
1.4 |
c I EXCH_UPDATE_CORNERS, myThid ) |
78 |
|
|
c CALL EXCH2_RX2_CUBE( vPhi, uPhi, .FALSE., 'Cg', |
79 |
jmc |
1.1 |
c I OLw, OLe, OLs, OLn, myNz, |
80 |
|
|
c I exchWidthX, exchWidthY, |
81 |
jmc |
1.4 |
c I EXCH_UPDATE_CORNERS, myThid ) |
82 |
jmc |
1.1 |
|
83 |
|
|
C- note: can substitute the low-level S/R calls above with: |
84 |
|
|
#ifdef W2_USE_R1_ONLY |
85 |
|
|
CALL EXCH2_UV_CGRID_3D_RX( |
86 |
|
|
U vPhi, uPhi, |
87 |
|
|
I .FALSE., myNz, myThid ) |
88 |
|
|
#else |
89 |
|
|
CALL EXCH2_UV_3D_RX( |
90 |
|
|
U vPhi, uPhi, |
91 |
|
|
I .FALSE., myNz, myThid ) |
92 |
|
|
#endif |
93 |
|
|
|
94 |
jmc |
1.3 |
IF ( useCubedSphereExchange ) THEN |
95 |
|
|
C--- using CubedSphereExchange: |
96 |
|
|
|
97 |
jmc |
1.1 |
C-- Then we may need to switch the signs depending on which cube face |
98 |
|
|
C we are located. |
99 |
|
|
|
100 |
|
|
C-- Loops on tile indices: |
101 |
|
|
DO bj = myByLo(myThid), myByHi(myThid) |
102 |
|
|
DO bi = myBxLo(myThid), myBxHi(myThid) |
103 |
|
|
|
104 |
jmc |
1.4 |
C- Choose what to do at each edge of the halo based on which face we are |
105 |
jmc |
1.3 |
myTile = W2_myTileList(bi,bj) |
106 |
jmc |
1.1 |
myFace = exch2_myFace(myTile) |
107 |
|
|
|
108 |
|
|
C-- Loops on level index: |
109 |
|
|
DO k = 1,myNz |
110 |
|
|
|
111 |
|
|
C- odd faces share disposition of all sections of the halo |
112 |
|
|
IF ( MOD(myFace,2).EQ.1 ) THEN |
113 |
|
|
C- North: |
114 |
|
|
IF (exch2_isNedge(myTile).EQ.1) THEN |
115 |
|
|
DO j = 1,exchWidthY |
116 |
|
|
DO i = 1-OLx,sNx+OLx |
117 |
|
|
uPhi(i,sNy+j,k,bi,bj) = uPhi(i,sNy+j,k,bi,bj)*negOne |
118 |
|
|
c vPhi(i,sNy+j,k,bi,bj) = vPhi(i,sNy+j,k,bi,bj) |
119 |
|
|
ENDDO |
120 |
|
|
ENDDO |
121 |
|
|
ENDIF |
122 |
|
|
C- South: (nothing to change) |
123 |
|
|
c IF (exch2_isSedge(myTile).EQ.1) THEN |
124 |
|
|
c DO j = 1,exchWidthY |
125 |
|
|
c DO i = 1-OLx,sNx+OLx |
126 |
|
|
c uPhi(i,1-j,k,bi,bj) = uPhi(i,1-j,k,bi,bj) |
127 |
|
|
c vPhi(i,1-j,k,bi,bj) = vPhi(i,1-j,k,bi,bj) |
128 |
|
|
c ENDDO |
129 |
|
|
c ENDDO |
130 |
|
|
c ENDIF |
131 |
|
|
C- East: (nothing to change) |
132 |
|
|
c IF (exch2_isEedge(myTile).EQ.1) THEN |
133 |
|
|
c DO j = 1-OLy,sNy+OLy |
134 |
|
|
c DO i = 1,exchWidthX |
135 |
|
|
c uPhi(sNx+i,j,k,bi,bj) = uPhi(sNx+i,j,k,bi,bj) |
136 |
|
|
c vPhi(sNx+i,j,k,bi,bj) = vPhi(sNx+i,j,k,bi,bj) |
137 |
|
|
c ENDDO |
138 |
|
|
c ENDDO |
139 |
|
|
c ENDIF |
140 |
|
|
C- West: |
141 |
|
|
IF (exch2_isWedge(myTile).EQ.1) THEN |
142 |
|
|
DO j = 1-OLy,sNy+OLy |
143 |
|
|
DO i = 1,exchWidthX |
144 |
|
|
c uPhi(1-i,j,k,bi,bj) = uPhi(1-i,j,k,bi,bj) |
145 |
|
|
vPhi(1-i,j,k,bi,bj) = vPhi(1-i,j,k,bi,bj)*negOne |
146 |
|
|
ENDDO |
147 |
|
|
ENDDO |
148 |
|
|
ENDIF |
149 |
|
|
|
150 |
|
|
ELSE |
151 |
|
|
C- Now the even faces (share disposition of all sections of the halo) |
152 |
|
|
|
153 |
|
|
C- East: |
154 |
|
|
IF (exch2_isEedge(myTile).EQ.1) THEN |
155 |
|
|
DO j = 1-OLy,sNy+OLy |
156 |
|
|
DO i = 1,exchWidthX |
157 |
|
|
c uPhi(sNx+i,j,k,bi,bj) = uPhi(sNx+i,j,k,bi,bj) |
158 |
|
|
vPhi(sNx+i,j,k,bi,bj) = vPhi(sNx+i,j,k,bi,bj)*negOne |
159 |
|
|
ENDDO |
160 |
|
|
ENDDO |
161 |
|
|
ENDIF |
162 |
|
|
C- West: (nothing to change) |
163 |
|
|
c IF (exch2_isWedge(myTile).EQ.1) THEN |
164 |
|
|
c DO j = 1-OLy,sNy+OLy |
165 |
|
|
c DO i = 1,exchWidthX |
166 |
|
|
c uPhi(1-i,j,k,bi,bj) = uPhi(1-i,j,k,bi,bj) |
167 |
|
|
c vPhi(1-i,j,k,bi,bj) = vPhi(1-i,j,k,bi,bj) |
168 |
|
|
c ENDDO |
169 |
|
|
c ENDDO |
170 |
|
|
c ENDIF |
171 |
|
|
C- North: (nothing to change) |
172 |
|
|
c IF (exch2_isNedge(myTile).EQ.1) THEN |
173 |
|
|
c DO j = 1,exchWidthY |
174 |
|
|
c DO i = 1-OLx,sNx+OLx |
175 |
|
|
c uPhi(i,sNy+j,k,bi,bj) = uPhi(i,sNy+j,k,bi,bj) |
176 |
|
|
c vPhi(i,sNy+j,k,bi,bj) = vPhi(i,sNy+j,k,bi,bj) |
177 |
|
|
c ENDDO |
178 |
|
|
c ENDDO |
179 |
|
|
c ENDIF |
180 |
|
|
C- South: |
181 |
|
|
IF (exch2_isSedge(myTile).EQ.1) THEN |
182 |
|
|
DO j = 1,exchWidthY |
183 |
|
|
DO i = 1-OLx,sNx+OLx |
184 |
|
|
uPhi(i,1-j,k,bi,bj) = uPhi(i,1-j,k,bi,bj)*negOne |
185 |
|
|
c vPhi(i,1-j,k,bi,bj) = vPhi(i,1-j,k,bi,bj) |
186 |
|
|
ENDDO |
187 |
|
|
ENDDO |
188 |
|
|
ENDIF |
189 |
|
|
|
190 |
|
|
C end odd / even faces |
191 |
|
|
ENDIF |
192 |
|
|
|
193 |
|
|
C-- end of Loops on tile and level indices (k,bi,bj). |
194 |
|
|
ENDDO |
195 |
|
|
ENDDO |
196 |
|
|
ENDDO |
197 |
|
|
|
198 |
|
|
C--- using or not using CubedSphereExchange: end |
199 |
|
|
ENDIF |
200 |
|
|
|
201 |
|
|
RETURN |
202 |
|
|
END |
203 |
|
|
|
204 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
205 |
|
|
|
206 |
|
|
CEH3 ;;; Local Variables: *** |
207 |
|
|
CEH3 ;;; mode:fortran *** |
208 |
|
|
CEH3 ;;; End: *** |