/[MITgcm]/MITgcm/eesupp/src/exch_rx.template
ViewVC logotype

Contents of /MITgcm/eesupp/src/exch_rx.template

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download)
Mon Nov 7 18:21:11 2005 UTC (18 years, 7 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint58b_post, checkpoint57y_post, checkpoint62c, checkpoint59, checkpoint58, checkpoint58f_post, checkpoint58d_post, checkpoint58a_post, checkpoint57z_post, checkpoint62a, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint58y_post, checkpoint58t_post, checkpoint60, checkpoint61, checkpoint62, checkpoint57x_post, checkpoint58w_post, checkpoint57y_pre, checkpoint58o_post, checkpoint58p_post, checkpoint58q_post, checkpoint58e_post, mitgcm_mapl_00, checkpoint58m_post, checkpoint58r_post, checkpoint58n_post, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint58k_post, checkpoint62b, checkpoint58v_post, checkpoint58l_post, checkpoint61f, checkpoint58g_post, checkpoint58x_post, checkpoint61n, checkpoint59j, checkpoint58h_post, checkpoint58j_post, checkpoint61q, checkpoint61z, checkpoint61e, checkpoint58i_post, checkpoint58c_post, checkpoint58u_post, checkpoint58s_post, checkpoint61g, checkpoint61d, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61x, checkpoint61y
Changes since 1.4: +3 -1 lines
Added barrier that is needed for multi-threaded runs

1 C $Header: /u/gcmpack/MITgcm/eesupp/src/exch_rx.template,v 1.4 2002/04/30 22:48:20 jmc Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5
6 CBOP
7
8 C !ROUTINE: EXCH_RX
9
10 C !INTERFACE:
11 SUBROUTINE EXCH_RX(
12 U array,
13 I myOLw, myOLe, myOLs, myOLn, myNz,
14 I exchWidthX, exchWidthY,
15 I simulationMode, cornerMode, myThid )
16 IMPLICIT NONE
17
18 C !DESCRIPTION:
19 C *==========================================================*
20 C | SUBROUTINE EXCH_RX
21 C | o Control edge exchanges for RX array.
22 C *==========================================================*
23 C |
24 C | Controlling routine for exchange of XY edges of an array
25 C | distributed in X and Y. The routine interfaces to
26 C | communication routines that can use messages passing
27 C | exchanges, put type exchanges or get type exchanges.
28 C | This allows anything from MPI to raw memory channel to
29 C | memmap segments to be used as a inter-process and/or
30 C | inter-thread communiation and synchronisation
31 C | mechanism.
32 C | Notes --
33 C | 1. Some low-level mechanisms such as raw memory-channel
34 C | or SGI/CRAY shmem put do not have direct Fortran bindings
35 C | and are invoked through C stub routines.
36 C | 2. Although this routine is fairly general but it does
37 C | require nSx and nSy are the same for all innvocations.
38 C | There are many common data structures ( myByLo,
39 C | westCommunicationMode, mpiIdW etc... ) tied in with
40 C | (nSx,nSy). To support arbitray nSx and nSy would require
41 C | general forms of these.
42 C | 3. RX arrays are used to generate code for both _RL and
43 C | _RS forms.
44 C *==========================================================*
45
46 C !USES:
47 C == Global data ==
48 #include "SIZE.h"
49 #include "EEPARAMS.h"
50 #include "EESUPPORT.h"
51 #include "EXCH.h"
52
53 C !INPUT/OUTPUT PARAMETERS:
54 C == Routine arguments ==
55 C array :: Array with edges to exchange.
56 C myOLw :: West, East, North and South overlap region sizes.
57 C myOLe
58 C myOLn
59 C myOLs
60 C exchWidthX :: Width of data region exchanged in X.
61 C exchWidthY :: Width of data region exchanged in Y.
62 C Note --
63 C 1. In theory one could have a send width and
64 C a receive width for each face of each tile. The only
65 C restriction woul be that the send width of one
66 C face should equal the receive width of the sent to
67 C tile face. Dont know if this would be useful. I
68 C have left it out for now as it requires additional
69 C bookeeping.
70 C simulationMode :: Forward or reverse mode exchange ( provides
71 C support for adjoint integration of code. )
72 C cornerMode :: Flag indicating whether corner updates are
73 C needed.
74 C myThid :: Thread number of this instance of S/R EXCH...
75 INTEGER myOLw
76 INTEGER myOLe
77 INTEGER myOLs
78 INTEGER myOLn
79 INTEGER myNz
80 INTEGER exchWidthX
81 INTEGER exchWidthY
82 INTEGER simulationMode
83 INTEGER cornerMode
84 INTEGER myThid
85 _RX array(1-myOLw:sNx+myOLe,
86 & 1-myOLs:sNy+myOLn,
87 & myNZ, nSx, nSy)
88
89 C !LOCAL VARIABLES:
90 C == Local variables ==
91 C theSimulationMode :: Holds working copy of simulation mode
92 C theCornerMode :: Holds working copy of corner mode
93 C I,J,K,bi,bj :: Loop counters
94 INTEGER theSimulationMode
95 INTEGER theCornerMode
96 INTEGER I,J,K,bi,bj
97 CEOP
98
99 _BARRIER
100
101 theSimulationMode = simulationMode
102 theCornerMode = cornerMode
103
104 C-- Error checks
105 IF ( exchWidthX .GT. myOLw )
106 & STOP ' S/R EXCH_RX: exchWidthX .GT. myOLw'
107 IF ( exchWidthX .GT. myOLe )
108 & STOP ' S/R EXCH_RX: exchWidthX .GT. myOLe'
109 IF ( exchWidthY .GT. myOLs )
110 & STOP ' S/R EXCH_RX: exchWidthY .GT. myOLs'
111 IF ( exchWidthY .GT. myOLn )
112 & STOP ' S/R EXCH_RX: exchWidthY .GT. myOLn'
113 IF ( myOLw .GT. MAX_OLX_EXCH )
114 & STOP ' S/R EXCH_RX: myOLw .GT. MAX_OLX_EXCH'
115 IF ( myOLe .GT. MAX_OLX_EXCH )
116 & STOP ' S/R EXCH_RX: myOLe .GT. MAX_OLX_EXCH'
117 IF ( myOLn .GT. MAX_OLX_EXCH )
118 & STOP ' S/R EXCH_RX: myOLn .GT. MAX_OLY_EXCH'
119 IF ( myOLs .GT. MAX_OLY_EXCH )
120 & STOP ' S/R EXCH_RX: myOLs .GT. MAX_OLY_EXCH'
121 IF ( myNZ .GT. MAX_NR_EXCH )
122 & STOP ' S/R EXCH_RX: myNZ .GT. MAX_NR_EXCH '
123 IF ( theSimulationMode .NE. FORWARD_SIMULATION
124 & .AND. theSimulationMode .NE. REVERSE_SIMULATION
125 & ) STOP ' S/R EXCH_RX: Unrecognised simulationMode '
126 IF ( theCornerMode .NE. EXCH_IGNORE_CORNERS
127 & .AND. theCornerMode .NE. EXCH_UPDATE_CORNERS
128 & ) STOP ' S/R EXCH_RX: Unrecognised cornerMode '
129
130 C-- Cycle edge buffer level
131 CALL EXCH_CYCLE_EBL( myThid )
132
133 IF ( theSimulationMode .EQ. FORWARD_SIMULATION ) THEN
134 C-- "Put" east and west edges.
135 CALL EXCH_RX_SEND_PUT_X( array,
136 I myOLw, myOLe, myOLs, myOLn, myNz,
137 I exchWidthX, exchWidthY,
138 I theSimulationMode, theCornerMode, myThid )
139 C-- If corners are important then sync and update east and west edges
140 C-- before doing north and south exchanges.
141 IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS ) THEN
142 CALL EXCH_RX_RECV_GET_X( array,
143 I myOLw, myOLe, myOLs, myOLn, myNz,
144 I exchWidthX, exchWidthY,
145 I theSimulationMode, theCornerMode, myThid )
146 ENDIF
147 C "Put" north and south edges.
148 CALL EXCH_RX_SEND_PUT_Y( array,
149 I myOLw, myOLe, myOLs, myOLn, myNz,
150 I exchWidthX, exchWidthY,
151 I theSimulationMode, theCornerMode, myThid )
152 C-- Sync and update north, south (and east, west if corner updating
153 C-- not active).
154 IF ( theCornerMode .NE. EXCH_UPDATE_CORNERS ) THEN
155 CALL EXCH_RX_RECV_GET_X( array,
156 I myOLw, myOLe, myOLs, myOLn, myNz,
157 I exchWidthX, exchWidthY,
158 I theSimulationMode, theCornerMode, myThid )
159 ENDIF
160 CALL EXCH_RX_RECV_GET_Y( array,
161 I myOLw, myOLe, myOLs, myOLn, myNz,
162 I exchWidthX, exchWidthY,
163 I theSimulationMode, theCornerMode, myThid )
164 ENDIF
165
166 IF ( theSimulationMode .EQ. REVERSE_SIMULATION ) THEN
167 C "Put" north and south edges.
168 CALL EXCH_RX_SEND_PUT_Y( array,
169 I myOLw, myOLe, myOLs, myOLn, myNz,
170 I exchWidthX, exchWidthY,
171 I theSimulationMode, theCornerMode, myThid )
172 C-- If corners are important then sync and update east and west edges
173 C-- before doing north and south exchanges.
174 IF ( theCornerMode .EQ. EXCH_UPDATE_CORNERS ) THEN
175 CALL EXCH_RX_RECV_GET_Y( array,
176 I myOLw, myOLe, myOLs, myOLn, myNz,
177 I exchWidthX, exchWidthY,
178 I theSimulationMode, theCornerMode, myThid )
179 ENDIF
180 C-- "Put" east and west edges.
181 CALL EXCH_RX_SEND_PUT_X( array,
182 I myOLw, myOLe, myOLs, myOLn, myNz,
183 I exchWidthX, exchWidthY,
184 I theSimulationMode, theCornerMode, myThid )
185 C-- Sync and update east, west (and north, south if corner updating
186 C-- not active).
187 IF ( theCornerMode .NE. EXCH_UPDATE_CORNERS ) THEN
188 CALL EXCH_RX_RECV_GET_Y( array,
189 I myOLw, myOLe, myOLs, myOLn, myNz,
190 I exchWidthX, exchWidthY,
191 I theSimulationMode, theCornerMode, myThid )
192 ENDIF
193 CALL EXCH_RX_RECV_GET_X( array,
194 I myOLw, myOLe, myOLs, myOLn, myNz,
195 I exchWidthX, exchWidthY,
196 I theSimulationMode, theCornerMode, myThid )
197 ENDIF
198 C Special case for zonal average model i.e. case where Nx == 1
199 C In this case a forward mode exchange simply sets array to
200 C the i=1 value for all i.
201 IF ( Nx .EQ. 1 ) THEN
202 DO bj=myByLo(myThid),myByHi(myThid)
203 DO bi=myBxLo(myThid),myBxHi(myThid)
204 DO K = 1,myNz
205 DO J = 1-myOLs,sNy+myOLn
206 DO I = 1-myOLw,sNx+myOLe
207 array(I,J,K,bi,bj) = array(1,J,K,bi,bj)
208 ENDDO
209 ENDDO
210 ENDDO
211 ENDDO
212 ENDDO
213 ENDIF
214 C Special case for X-slice domain i.e. case where Ny == 1
215 C In this case a forward mode exchange simply sets array to
216 C the j=1 value for all j.
217 IF ( Ny .EQ. 1 ) THEN
218 DO bj=myByLo(myThid),myByHi(myThid)
219 DO bi=myBxLo(myThid),myBxHi(myThid)
220 DO K = 1,myNz
221 DO J = 1-myOLs,sNy+myOLn
222 DO I = 1-myOLw,sNx+myOLe
223 array(I,J,K,bi,bj) = array(I,1,K,bi,bj)
224 ENDDO
225 ENDDO
226 ENDDO
227 ENDDO
228 ENDDO
229 ENDIF
230
231 RETURN
232 END

  ViewVC Help
Powered by ViewVC 1.1.22