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