1 |
jmc |
1.1 |
C $Header: /u/gcmpack/MITgcm/eesupp/src/exch_z_rx_cube.template,v 1.5 2010/05/04 00:39:52 jmc Exp $ |
2 |
|
|
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "CPP_EEOPTIONS.h" |
5 |
|
|
|
6 |
|
|
CBOP |
7 |
|
|
|
8 |
|
|
C !ROUTINE: EXCH1_Z_RX_CUBE |
9 |
|
|
|
10 |
|
|
C !INTERFACE: |
11 |
|
|
SUBROUTINE EXCH1_Z_RX_CUBE( |
12 |
|
|
U array, |
13 |
|
|
I withSigns, |
14 |
|
|
I myOLw, myOLe, myOLs, myOLn, myNz, |
15 |
|
|
I exchWidthX, exchWidthY, |
16 |
|
|
I cornerMode, myThid ) |
17 |
|
|
|
18 |
|
|
C !DESCRIPTION: |
19 |
|
|
C *==========================================================* |
20 |
|
|
C | SUBROUTINE EXCH1_Z_RX_CUBE |
21 |
|
|
C | o Forward-mode edge exchanges for RX array on CS config: |
22 |
|
|
C | Fill overlap region through tile exchanges, |
23 |
|
|
C | according to CS topology, |
24 |
|
|
C | for a Zeta-located, scalar field RX arrays. |
25 |
|
|
C *==========================================================* |
26 |
|
|
C | Controlling routine for exchange of XY edges of an array |
27 |
|
|
C | distributed in X and Y. The routine interfaces to |
28 |
|
|
C | communication routines that can use messages passing |
29 |
|
|
C | exchanges, put type exchanges or get type exchanges. |
30 |
|
|
C | This allows anything from MPI to raw memory channel to |
31 |
|
|
C | memmap segments to be used as a inter-process and/or |
32 |
|
|
C | inter-thread communiation and synchronisation |
33 |
|
|
C | mechanism. |
34 |
|
|
C | Notes -- |
35 |
|
|
C | 1. Some low-level mechanisms such as raw memory-channel |
36 |
|
|
C | or SGI/CRAY shmem put do not have direct Fortran bindings |
37 |
|
|
C | and are invoked through C stub routines. |
38 |
|
|
C | 2. Although this routine is fairly general but it does |
39 |
|
|
C | require nSx and nSy are the same for all innvocations. |
40 |
|
|
C | There are many common data structures ( myByLo, |
41 |
|
|
C | westCommunicationMode, mpiIdW etc... ) tied in with |
42 |
|
|
C | (nSx,nSy). To support arbitray nSx and nSy would require |
43 |
|
|
C | general forms of these. |
44 |
|
|
C | 3. zeta coord exchange operation for cube sphere grid |
45 |
|
|
C *==========================================================* |
46 |
|
|
|
47 |
|
|
C !USES: |
48 |
|
|
IMPLICIT NONE |
49 |
|
|
|
50 |
|
|
C == Global data == |
51 |
|
|
#include "SIZE.h" |
52 |
|
|
#include "EEPARAMS.h" |
53 |
|
|
|
54 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
55 |
|
|
C == Routine arguments == |
56 |
|
|
C array :: Array with edges to exchange. |
57 |
|
|
C withSigns :: Flag controlling whether field sign depends on orientation |
58 |
|
|
C :: (signOption not yet implemented but needed for SM exch) |
59 |
|
|
C myOLw,myOLe :: West and East overlap region sizes. |
60 |
|
|
C myOLs,myOLn :: South and North overlap region sizes. |
61 |
|
|
C exchWidthX :: Width of data region exchanged in X. |
62 |
|
|
C exchWidthY :: Width of data region exchanged in Y. |
63 |
|
|
C Note -- |
64 |
|
|
C 1. In theory one could have a send width and |
65 |
|
|
C a receive width for each face of each tile. The only |
66 |
|
|
C restriction would be that the send width of one |
67 |
|
|
C face should equal the receive width of the sent to |
68 |
|
|
C tile face. Dont know if this would be useful. I |
69 |
|
|
C have left it out for now as it requires additional |
70 |
|
|
C bookeeping. |
71 |
|
|
C cornerMode :: Flag indicating whether corner updates are needed. |
72 |
|
|
C myThid :: my Thread Id number |
73 |
|
|
|
74 |
|
|
INTEGER myOLw, myOLe, myOLs, myOLn, myNz |
75 |
|
|
_RX array( 1-myOLw:sNx+myOLe, |
76 |
|
|
& 1-myOLs:sNy+myOLn, |
77 |
|
|
& myNz, nSx, nSy ) |
78 |
|
|
LOGICAL withSigns |
79 |
|
|
INTEGER exchWidthX |
80 |
|
|
INTEGER exchWidthY |
81 |
|
|
INTEGER cornerMode |
82 |
|
|
INTEGER myThid |
83 |
|
|
|
84 |
|
|
C !LOCAL VARIABLES: |
85 |
|
|
C == Local variables == |
86 |
|
|
C theSimulationMode :: Holds working copy of simulation mode |
87 |
|
|
C theCornerMode :: Holds working copy of corner mode |
88 |
|
|
C I,J,K,repeat :: Loop counters and index |
89 |
|
|
C bl,bt,bn,bs,be,bw :: tile indices |
90 |
|
|
c INTEGER theSimulationMode |
91 |
|
|
c INTEGER theCornerMode |
92 |
|
|
INTEGER I,J,K,repeat |
93 |
|
|
INTEGER bl,bt,bn,bs,be,bw |
94 |
|
|
CHARACTER*(MAX_LEN_MBUF) msgBuf |
95 |
|
|
|
96 |
|
|
C == Statement function == |
97 |
|
|
INTEGER tilemod |
98 |
|
|
tilemod(I)=1+mod(I-1+6,6) |
99 |
|
|
CEOP |
100 |
|
|
|
101 |
|
|
c theSimulationMode = FORWARD_SIMULATION |
102 |
|
|
c theCornerMode = cornerMode |
103 |
|
|
|
104 |
|
|
c IF ( simulationMode.EQ.REVERSE_SIMULATION ) THEN |
105 |
|
|
c WRITE(msgBuf,'(A)')'EXCH1_Z_RX_CUBE: AD mode not implemented' |
106 |
|
|
c CALL PRINT_ERROR( msgBuf, myThid ) |
107 |
|
|
c STOP 'ABNORMAL END: EXCH1_Z_RX_CUBE: no AD code' |
108 |
|
|
c ENDIF |
109 |
|
|
IF ( sNx.NE.sNy .OR. |
110 |
|
|
& nSx.NE.6 .OR. nSy.NE.1 .OR. |
111 |
|
|
& nPx.NE.1 .OR. nPy.NE.1 ) THEN |
112 |
|
|
WRITE(msgBuf,'(2A)') 'EXCH1_Z_RX_CUBE: Wrong Tiling' |
113 |
|
|
CALL PRINT_ERROR( msgBuf, myThid ) |
114 |
|
|
WRITE(msgBuf,'(2A)') 'EXCH1_Z_RX_CUBE: ', |
115 |
|
|
& 'works only with sNx=sNy & nSx=6 & nSy=nPx=nPy=1' |
116 |
|
|
CALL PRINT_ERROR( msgBuf, myThid ) |
117 |
|
|
STOP 'ABNORMAL END: EXCH1_Z_RX_CUBE: Wrong Tiling' |
118 |
|
|
ENDIF |
119 |
|
|
|
120 |
|
|
C For now tile<->tile exchanges are sequentialised through |
121 |
|
|
C thread 1. This is a temporary feature for preliminary testing until |
122 |
|
|
C general tile decomposistion is in place (CNH April 11, 2001) |
123 |
|
|
CALL BAR2( myThid ) |
124 |
|
|
IF ( myThid .EQ. 1 ) THEN |
125 |
|
|
|
126 |
|
|
DO repeat=1,2 |
127 |
|
|
|
128 |
|
|
DO bl = 1, 5, 2 |
129 |
|
|
|
130 |
|
|
bt = bl |
131 |
|
|
bn=tilemod(bt+2) |
132 |
|
|
bs=tilemod(bt-1) |
133 |
|
|
be=tilemod(bt+1) |
134 |
|
|
bw=tilemod(bt-2) |
135 |
|
|
|
136 |
|
|
DO K = 1, myNz |
137 |
|
|
DO J = 1, sNy+1 |
138 |
|
|
DO I = 0, exchWidthX-1 |
139 |
|
|
|
140 |
|
|
C Tile Odd:Odd+2 [get] [North<-West] |
141 |
|
|
array(J,sNy+I+1,K,bt,1) = array(I+1,sNy+2-J,K,bn,1) |
142 |
|
|
C Tile Odd:Odd+1 [get] [East<-West] |
143 |
|
|
array(sNx+I+1,J,K,bt,1) = array(I+1,J,K,be,1) |
144 |
|
|
|
145 |
|
|
cs- these above loop should really have the same range the lower one |
146 |
|
|
ENDDO |
147 |
|
|
DO I = 1, exchWidthX-0 |
148 |
|
|
cs- but this replaces the missing I/O routines for now |
149 |
|
|
|
150 |
|
|
C Tile Odd:Odd-1 [get] [South<-North] |
151 |
|
|
array(J,1-I,K,bt,1) = array(J,sNy+1-I,K,bs,1) |
152 |
|
|
C Tile Odd:Odd-2 [get] [West<-North] |
153 |
|
|
array(1-I,J,K,bt,1) = array(sNx+2-J,sNy+1-I,K,bw,1) |
154 |
|
|
|
155 |
|
|
ENDDO |
156 |
|
|
ENDDO |
157 |
|
|
ENDDO |
158 |
|
|
|
159 |
|
|
bt = bl+1 |
160 |
|
|
bn=tilemod(bt+1) |
161 |
|
|
bs=tilemod(bt-2) |
162 |
|
|
be=tilemod(bt+2) |
163 |
|
|
bw=tilemod(bt-1) |
164 |
|
|
|
165 |
|
|
DO K = 1, myNz |
166 |
|
|
DO J = 1, sNy+1 |
167 |
|
|
DO I = 0, exchWidthX-1 |
168 |
|
|
|
169 |
|
|
C Tile Even:Even+1 [get] [North<-South] |
170 |
|
|
array(J,sNy+I+1,K,bt,1) = array(J,I+1,K,bn,1) |
171 |
|
|
C Tile Even:Even+2 [get] [East<-South] |
172 |
|
|
array(sNx+I+1,J,K,bt,1) = array(sNx+2-J,I+1,K,be,1) |
173 |
|
|
|
174 |
|
|
cs- these above loop should really have the same range the lower one |
175 |
|
|
ENDDO |
176 |
|
|
DO I = 1, exchWidthX-0 |
177 |
|
|
cs- but this replaces the missing I/O routines for now |
178 |
|
|
|
179 |
|
|
C Tile Even:Even-2 [get] [South<-East] |
180 |
|
|
array(J,1-I,K,bt,1) = array(sNx+1-I,sNy+2-J,K,bs,1) |
181 |
|
|
C Tile Even:Even-1 [get] [West<-East] |
182 |
|
|
array(1-I,J,K,bt,1) = array(sNx+1-I,J,K,bw,1) |
183 |
|
|
|
184 |
|
|
ENDDO |
185 |
|
|
ENDDO |
186 |
|
|
ENDDO |
187 |
|
|
|
188 |
|
|
ENDDO |
189 |
|
|
|
190 |
|
|
ENDDO |
191 |
|
|
|
192 |
|
|
ENDIF |
193 |
|
|
CALL BAR2(myThid) |
194 |
|
|
|
195 |
|
|
RETURN |
196 |
|
|
END |