1 |
jmc |
1.9 |
C $Header: /u/gcmpack/MITgcm/eesupp/src/exch_uv_agrid_xy_rx.template,v 1.8 2006/08/23 15:20:37 jmc Exp $ |
2 |
jmc |
1.4 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "PACKAGES_CONFIG.h" |
5 |
molod |
1.1 |
#include "CPP_EEOPTIONS.h" |
6 |
jmc |
1.4 |
|
7 |
molod |
1.5 |
SUBROUTINE EXCH_UV_AGRID_XY_RX( component1,component2, withSigns, |
8 |
|
|
. myThid ) |
9 |
jmc |
1.4 |
|
10 |
molod |
1.1 |
implicit none |
11 |
|
|
|
12 |
|
|
C*=====================================================================* |
13 |
jmc |
1.4 |
C Purpose: subroutine exch_uv_agrid_xyz_RX will |
14 |
molod |
1.1 |
C handle exchanges for a 2D vector field on an A-grid. |
15 |
|
|
C |
16 |
|
|
C Input: component1(lon,lat,bi,bj) - first component of vector |
17 |
|
|
C component2(lon,lat,bi,bj) - second component of vector |
18 |
molod |
1.5 |
C withSigns (logical) - true to use signs of components |
19 |
jmc |
1.6 |
C myThid - Thread number |
20 |
molod |
1.1 |
C |
21 |
|
|
C Output: component1 and component2 are updated (halo regions filled) |
22 |
|
|
C |
23 |
|
|
C Calls: exch (either exch_rx_cube or exch_rx) - twice, once |
24 |
|
|
C for the first-component, once for second. |
25 |
|
|
C |
26 |
|
|
C NOTES: 1) This code, as written, only works on ONE PROCESSOR! |
27 |
|
|
C 2) This code assumes that the faces are square (sNx=sNy....) |
28 |
edhill |
1.3 |
C (also - we do not worry about barriers) |
29 |
molod |
1.1 |
C*=====================================================================* |
30 |
|
|
|
31 |
|
|
#include "SIZE.h" |
32 |
|
|
#include "EEPARAMS.h" |
33 |
|
|
#include "EESUPPORT.h" |
34 |
edhill |
1.2 |
#include "EXCH.h" |
35 |
molod |
1.1 |
|
36 |
|
|
C == Argument list variables == |
37 |
|
|
_RX component1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
38 |
|
|
_RX component2(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
39 |
molod |
1.5 |
LOGICAL withSigns |
40 |
molod |
1.1 |
INTEGER myThid |
41 |
|
|
|
42 |
|
|
C == Local variables == |
43 |
jmc |
1.7 |
C i,j,bi,bj are do indices. |
44 |
molod |
1.1 |
C OL[wens] - Overlap extents in west, east, north, south. |
45 |
|
|
C exchWidth[XY] - Extent of regions that will be exchanged. |
46 |
|
|
C dummy[12] - copies of the vector components with haloes filled. |
47 |
|
|
C b[nsew] - indices of the [nswe] neighboring faces for each face. |
48 |
|
|
|
49 |
jmc |
1.7 |
integer i,j,bi,bj |
50 |
molod |
1.1 |
integer OLw, OLe, OLn, OLs, exchWidthX, exchWidthY, myNz |
51 |
jmc |
1.6 |
_RX dummy1(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
52 |
|
|
_RX dummy2(1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
53 |
|
|
_RX negOne |
54 |
molod |
1.1 |
|
55 |
jmc |
1.4 |
#ifdef ALLOW_EXCH2 |
56 |
jmc |
1.8 |
CALL EXCH2_UV_AGRID_3D_RX( |
57 |
jmc |
1.6 |
U component1, component2, |
58 |
jmc |
1.8 |
I withSigns, 1, myThid ) |
59 |
jmc |
1.4 |
RETURN |
60 |
|
|
#endif |
61 |
|
|
|
62 |
molod |
1.1 |
OLw = OLx |
63 |
|
|
OLe = OLx |
64 |
|
|
OLn = OLy |
65 |
|
|
OLs = OLy |
66 |
|
|
exchWidthX = OLx |
67 |
|
|
exchWidthY = OLy |
68 |
|
|
myNz = 1 |
69 |
jmc |
1.6 |
negOne = 1. |
70 |
|
|
IF (withSigns) negOne = -1. |
71 |
molod |
1.1 |
|
72 |
|
|
C First call the exchanges for the two components |
73 |
|
|
|
74 |
|
|
if (useCubedSphereExchange) then |
75 |
|
|
call exch_RX_cube( component1, |
76 |
|
|
. OLw, OLe, OLs, OLn, myNz, |
77 |
|
|
. exchWidthX, exchWidthY, |
78 |
|
|
. FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
79 |
|
|
call exch_RX_cube( component2, |
80 |
|
|
. OLw, OLe, OLs, OLn, myNz, |
81 |
|
|
. exchWidthX, exchWidthY, |
82 |
|
|
. FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
83 |
|
|
else |
84 |
|
|
call exch_RX( component1, |
85 |
|
|
. OLw, OLe, OLs, OLn, myNz, |
86 |
|
|
. exchWidthX, exchWidthY, |
87 |
|
|
. FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
88 |
|
|
call exch_RX( component2, |
89 |
|
|
. OLw, OLe, OLs, OLn, myNz, |
90 |
|
|
. exchWidthX, exchWidthY, |
91 |
|
|
. FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid ) |
92 |
|
|
endif |
93 |
|
|
|
94 |
|
|
C Then if we are on the sphere we may need to switch u and v components |
95 |
|
|
C and/or the signs depending on which cube face we are located. |
96 |
|
|
|
97 |
|
|
if (useCubedSphereExchange) then |
98 |
|
|
|
99 |
|
|
do bj = myByLo(myThid), myByHi(myThid) |
100 |
|
|
do bi = myBxLo(myThid), myBxHi(myThid) |
101 |
|
|
|
102 |
|
|
C First we need to copy the component info into dummy arrays |
103 |
|
|
do j = 1-OLy,sNy+OLy |
104 |
|
|
do i = 1-OLx,sNx+OLx |
105 |
jmc |
1.6 |
dummy1(i,j) = component1(i,j,bi,bj) |
106 |
|
|
dummy2(i,j) = component2(i,j,bi,bj) |
107 |
molod |
1.1 |
enddo |
108 |
|
|
enddo |
109 |
|
|
|
110 |
|
|
C Now choose what to do at each edge of the halo based on which face |
111 |
|
|
C (we assume that bj is always=1) |
112 |
|
|
|
113 |
|
|
C odd faces share disposition of all sections of the halo |
114 |
|
|
if ( mod(bi,2).eq.1 ) then |
115 |
|
|
do j = 1,sNy |
116 |
|
|
do i = 1,exchWidthX |
117 |
|
|
C east |
118 |
jmc |
1.6 |
component1(sNx+i,j,bi,bj) = dummy1(sNx+i,j) |
119 |
|
|
component2(sNx+i,j,bi,bj) = dummy2(sNx+i,j) |
120 |
molod |
1.1 |
C west |
121 |
jmc |
1.6 |
component1(i-OLx,j,bi,bj) = dummy2(i-OLx,j) |
122 |
|
|
component2(i-OLx,j,bi,bj) = negOne*dummy1(i-OLx,j) |
123 |
molod |
1.1 |
C north |
124 |
jmc |
1.6 |
component1(j,sNy+i,bi,bj) = negOne*dummy2(j,sNy+i) |
125 |
|
|
component2(j,sNy+i,bi,bj) = dummy1(j,sNy+i) |
126 |
molod |
1.1 |
C south |
127 |
jmc |
1.6 |
component1(j,i-OLx,bi,bj) = dummy1(j,i-OLx) |
128 |
|
|
component2(j,i-OLx,bi,bj) = dummy2(j,i-OLx) |
129 |
molod |
1.1 |
enddo |
130 |
|
|
enddo |
131 |
|
|
C now the even faces (share disposition of all sections of the halo) |
132 |
|
|
elseif ( mod(bi,2).eq.0 ) then |
133 |
|
|
do j = 1,sNy |
134 |
|
|
do i = 1,exchWidthX |
135 |
|
|
C east |
136 |
jmc |
1.6 |
component1(sNx+i,j,bi,bj) = dummy2(sNx+i,j) |
137 |
|
|
component2(sNx+i,j,bi,bj) = negOne*dummy1(sNx+i,j) |
138 |
molod |
1.1 |
C west |
139 |
jmc |
1.6 |
component1(i-OLx,j,bi,bj) = dummy1(i-OLx,j) |
140 |
|
|
component2(i-OLx,j,bi,bj) = dummy2(i-OLx,j) |
141 |
molod |
1.1 |
C north |
142 |
jmc |
1.6 |
component1(j,sNy+i,bi,bj) = dummy1(j,sNy+i) |
143 |
|
|
component2(j,sNy+i,bi,bj) = dummy2(j,sNy+i) |
144 |
molod |
1.1 |
C south |
145 |
jmc |
1.6 |
component1(j,i-OLy,bi,bj) = negOne*dummy2(j,i-OLy) |
146 |
|
|
component2(j,i-OLy,bi,bj) = dummy1(j,i-OLy) |
147 |
molod |
1.1 |
enddo |
148 |
|
|
enddo |
149 |
|
|
endif |
150 |
|
|
|
151 |
|
|
enddo |
152 |
|
|
enddo |
153 |
|
|
|
154 |
|
|
endif |
155 |
|
|
|
156 |
|
|
RETURN |
157 |
|
|
END |
158 |
jmc |
1.4 |
|
159 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
160 |
|
|
|
161 |
|
|
CEH3 ;;; Local Variables: *** |
162 |
|
|
CEH3 ;;; mode:fortran *** |
163 |
|
|
CEH3 ;;; End: *** |