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

Diff of /MITgcm/eesupp/src/exch_rx_cube.template

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

revision 1.1 by adcroft, Wed Mar 28 19:48:51 2001 UTC revision 1.2 by adcroft, Tue May 29 14:01:36 2001 UTC
# Line 0  Line 1 
1    C $Header$
2    C $Name$
3    
4    #include "CPP_EEOPTIONS.h"
5    
6          SUBROUTINE EXCH_RX_CUBE(
7         U            array,
8         I            myOLw, myOLe, myOLn, myOLs, myNz,
9         I            exchWidthX, exchWidthY,
10         I            simulationMode, cornerMode, myThid )
11    C     /==========================================================\
12    C     | SUBROUTINE EXCH_RX_CUBE                                  |
13    C     | o Control edge exchanges for RX array.                   |
14    C     |==========================================================|
15    C     |                                                          |
16    C     | Controlling routine for exchange of XY edges of an array |
17    C     | distributed in X and Y. The routine interfaces to        |
18    C     | communication routines that can use messages passing     |
19    C     | exchanges, put type exchanges or get type exchanges.     |
20    C     |  This allows anything from MPI to raw memory channel to  |
21    C     | memmap segments to be used as a inter-process and/or     |
22    C     | inter-thread communiation and synchronisation            |
23    C     | mechanism.                                               |
24    C     | Notes --                                                 |
25    C     | 1. Some low-level mechanisms such as raw memory-channel  |
26    C     | or SGI/CRAY shmem put do not have direct Fortran bindings|
27    C     | and are invoked through C stub routines.                 |
28    C     | 2. Although this routine is fairly general but it does   |
29    C     | require nSx and nSy are the same for all innvocations.   |
30    C     | There are many common data structures ( myByLo,          |
31    C     | westCommunicationMode, mpiIdW etc... ) tied in with      |
32    C     | (nSx,nSy). To support arbitray nSx and nSy would require |
33    C     | general forms of these.                                  |
34    C     |                                                          |
35    C     \==========================================================/
36          IMPLICIT NONE
37    
38    C     == Global data ==
39    #include "SIZE.h"
40    #include "EEPARAMS.h"
41    #include "EESUPPORT.h"
42    #include "EXCH.h"
43    
44    C     == Routine arguments ==
45    C     array - Array with edges to exchange.
46    C     myOLw - West, East, North and South overlap region sizes.
47    C     myOLe
48    C     myOLn
49    C     myOLs
50    C     exchWidthX - Width of data region exchanged in X.
51    C     exchWidthY - Width of data region exchanged in Y.
52    C                  Note --
53    C                  1. In theory one could have a send width and
54    C                  a receive width for each face of each tile. The only
55    C                  restriction woul be that the send width of one
56    C                  face should equal the receive width of the sent to
57    C                  tile face. Dont know if this would be useful. I
58    C                  have left it out for now as it requires additional
59    C                  bookeeping.
60    C     simulationMode - Forward or reverse mode exchange ( provides
61    C                      support for adjoint integration of code. )
62    C     cornerMode     - Flag indicating whether corner updates are
63    C                      needed.
64    C     myThid         - Thread number of this instance of S/R EXCH...
65          INTEGER myOLw
66          INTEGER myOLe
67          INTEGER myOLs
68          INTEGER myOLn
69          INTEGER myNz
70          INTEGER exchWidthX
71          INTEGER exchWidthY
72          INTEGER simulationMode
73          INTEGER cornerMode
74          INTEGER myThid
75          _RX array(1-myOLw:sNx+myOLe,
76         &          1-myOLs:sNy+myOLn,
77         &          myNZ, nSx, nSy)
78    
79    C     == Local variables ==
80    C     theSimulationMode - Holds working copy of simulation mode
81    C     theCornerMode     - Holds working copy of corner mode
82          INTEGER theSimulationMode
83          INTEGER theCornerMode
84          INTEGER I,J,K
85          INTEGER bl,bt,bn,bs,be,bw
86    
87    C     == Statement function ==
88    C     tilemod - Permutes indices to return neighboring tile index on
89    C               six face cube.
90          INTEGER tilemod
91          tilemod(I)=1+mod(I-1+6,6)
92    
93          theSimulationMode = simulationMode
94          theCornerMode     = cornerMode
95    
96    C     For now tile<->tile exchanges are sequentialised through
97    C     thread 1. This is a temporary feature for preliminary testing until
98    C     general tile decomposistion is in place (CNH April 11, 2001)
99          CALL BAR2( myThid )
100          IF ( myThid .EQ. 1 ) THEN
101    
102           DO bl = 1, 5, 2
103    
104            bt = bl
105            bn=tilemod(bt+2)
106            bs=tilemod(bt-1)
107            be=tilemod(bt+1)
108            bw=tilemod(bt-2)
109    
110            DO K = 1, myNz
111             DO J = 1, sNy
112              DO I = 1, exchWidthX
113    
114    C          Tile Odd:Odd+2 [get] [North<-West]
115               array(J,sNy+I,K,bt,1) = array(I,sNy+1-J,K,bn,1)
116    C          Tile Odd:Odd-1 [get] [South<-North]
117               array(J,1-I,K,bt,1) = array(J,sNy+1-I,K,bs,1)
118    C          Tile Odd:Odd+1 [get] [East<-West]
119               array(sNx+I,J,K,bt,1) = array(I,J,K,be,1)
120    C          Tile Odd:Odd-2 [get] [West<-North]
121               array(1-I,J,K,bt,1) = array(sNx+1-J,sNy+1-I,K,bw,1)
122    
123              ENDDO
124             ENDDO
125            ENDDO
126    
127            bt = bl+1
128            bn=tilemod(bt+1)
129            bs=tilemod(bt-2)
130            be=tilemod(bt+2)
131            bw=tilemod(bt-1)
132    
133            DO K = 1, myNz
134             DO J = 1, sNy
135              DO I = 1, exchWidthX
136    
137    C          Tile Even:Even+1 [get] [North<-South]
138               array(J,sNy+I,K,bt,1) = array(J,I,K,bn,1)
139    C          Tile Even:Even-2 [get] [South<-East]
140               array(J,1-I,K,bt,1) = array(sNx+1-I,sNy+1-J,K,bs,1)
141    C          Tile Even:Even+2 [get] [East<-South]
142               array(sNx+I,J,K,bt,1) = array(sNx+1-J,I,K,be,1)
143    C          Tile Even:Even-1 [get] [West<-East]
144               array(1-I,J,K,bt,1) = array(sNx+1-I,J,K,bw,1)
145    
146              ENDDO
147             ENDDO
148            ENDDO
149    
150           ENDDO
151    
152          ENDIF
153          CALL BAR2(myThid)
154      
155          RETURN
156          END

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.22