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

Annotation of /MITgcm/eesupp/src/exch_uv_agrid_3d_rx.template

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


Revision 1.1 - (hide annotations) (download)
Wed Aug 23 15:18:47 2006 UTC (17 years, 8 months ago) by jmc
Branch: MAIN
add _3D_ EXCH interface (=3.D version with 3rd dim in argument list)

1 jmc 1.1 C $Header: /u/gcmpack/MITgcm/eesupp/src/exch_uv_agrid_xyz_rx.template,v 1.6 2004/11/19 02:32:05 jmc Exp $
2     C $Name: $
3    
4     #include "PACKAGES_CONFIG.h"
5     #include "CPP_EEOPTIONS.h"
6    
7     CBOP
8     C !ROUTINE: EXCH_UV_AGRID_3D_RX
9    
10     C !INTERFACE:
11     SUBROUTINE EXCH_UV_AGRID_3D_RX(
12     U Uphi, Vphi,
13     I withSigns, myNz, myThid )
14    
15     C !DESCRIPTION:
16     C*=====================================================================*
17     C Purpose: SUBROUTINE EXCH_UV_AGRID_3D_RX
18     C handle exchanges for a 3D vector field on an A-grid.
19     C
20     C Input:
21     C Uphi(lon,lat,levs,bi,bj) :: first component of vector
22     C Vphi(lon,lat,levs,bi,bj) :: second component of vector
23     C withSigns (logical) :: true to use signs of components
24     C myNz :: 3rd dimension of input arrays Uphi,Vphi
25     C myThid :: my Thread Id number
26     C
27     C Output: Uphi and Vphi are updated (halo regions filled)
28     C
29     C Calls: exch (either exch_rx_cube or exch_rx) - twice, once
30     C for the first-component, once for second.
31     C
32     C NOTES: 1) If using CubedSphereExchange, only works on ONE PROCESSOR!
33     C*=====================================================================*
34    
35     C !USES:
36     IMPLICIT NONE
37    
38     #include "SIZE.h"
39     #include "EEPARAMS.h"
40     #include "EESUPPORT.h"
41     #include "EXCH.h"
42    
43     C !INPUT/OUTPUT PARAMETERS:
44     C == Argument list variables ==
45     INTEGER myNz
46     _RX Uphi(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNz,nSx,nSy)
47     _RX Vphi(1-OLx:sNx+OLx,1-OLy:sNy+OLy,myNz,nSx,nSy)
48     LOGICAL withSigns
49     INTEGER myThid
50    
51     C !LOCAL VARIABLES:
52     C == Local variables ==
53     C i,j,k,bi,bj :: are DO indices.
54     C OL[wens] :: Overlap extents in west, east, north, south.
55     C exchWidth[XY] :: Extent of regions that will be exchanged.
56     C dummy[12] :: copies of the vector components with haloes filled.
57    
58     INTEGER i,j,k,bi,bj
59     INTEGER OLw, OLe, OLn, OLs, exchWidthX, exchWidthY
60     _RX dummy1(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
61     _RX dummy2(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
62     _RX negOne
63    
64     #ifdef ALLOW_EXCH2
65     CALL EXCH2_UV_AGRID_3D_RX(
66     U Uphi, Vphi,
67     I withSigns, Nr, myThid )
68     RETURN
69     #endif
70    
71     OLw = OLx
72     OLe = OLx
73     OLn = OLy
74     OLs = OLy
75     exchWidthX = OLx
76     exchWidthY = OLy
77     negOne = 1.
78     IF (withSigns) negOne = -1.
79    
80    
81     IF (useCubedSphereExchange) THEN
82     C--- using CubedSphereExchange:
83    
84     C First call the exchanges for the two components
85    
86     CALL EXCH_RX_CUBE( Uphi,
87     I OLw, OLe, OLs, OLn, myNz,
88     I exchWidthX, exchWidthY,
89     I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid )
90     CALL EXCH_RX_CUBE( Vphi,
91     I OLw, OLe, OLs, OLn, myNz,
92     I exchWidthX, exchWidthY,
93     I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid )
94    
95     C Then if we are on the sphere we may need to switch u and v components
96     C and/or the signs depending on which cube face we are located.
97    
98     C-- Loops on tile and level indices:
99     DO bj = myByLo(myThid), myByHi(myThid)
100     DO bi = myBxLo(myThid), myBxHi(myThid)
101     DO k = 1,Nr
102    
103     C First we need to copy the component info into dummy arrays
104     DO j = 1-OLy,sNy+OLy
105     DO i = 1-OLx,sNx+OLx
106     dummy1(i,j) = Uphi(i,j,k,bi,bj)
107     dummy2(i,j) = Vphi(i,j,k,bi,bj)
108     ENDDO
109     ENDDO
110    
111     C Now choose what to do at each edge of the halo based on which face
112     C (we assume that bj is always=1)
113    
114     C odd faces share disposition of all sections of the halo
115     IF ( MOD(bi,2).EQ.1 ) THEN
116     DO j = 1,sNy
117     DO i = 1,exchWidthX
118     C east (nothing to change)
119     c Uphi(sNx+i,j,k,bi,bj) = dummy1(sNx+i,j)
120     c Vphi(sNx+i,j,k,bi,bj) = dummy2(sNx+i,j)
121     C west
122     Uphi(1-i,j,k,bi,bj) = dummy2(1-i,j)
123     Vphi(1-i,j,k,bi,bj) = dummy1(1-i,j)*negOne
124     ENDDO
125     ENDDO
126     DO j = 1,exchWidthY
127     DO i = 1,sNx
128     C north
129     Uphi(i,sNy+j,k,bi,bj) = dummy2(i,sNy+j)*negOne
130     Vphi(i,sNy+j,k,bi,bj) = dummy1(i,sNy+j)
131     C south (nothing to change)
132     c Uphi(i,1-j,k,bi,bj) = dummy1(i,1-j)
133     c Vphi(i,1-j,k,bi,bj) = dummy2(i,1-j)
134     ENDDO
135     ENDDO
136    
137     ELSE
138     C now the even faces (share disposition of all sections of the halo)
139    
140     DO j = 1,sNy
141     DO i = 1,exchWidthX
142     C east
143     Uphi(sNx+i,j,k,bi,bj) = dummy2(sNx+i,j)
144     Vphi(sNx+i,j,k,bi,bj) = dummy1(sNx+i,j)*negOne
145     C west (nothing to change)
146     c Uphi(1-i,j,k,bi,bj) = dummy1(1-i,j)
147     c Vphi(1-i,j,k,bi,bj) = dummy2(1-i,j)
148     ENDDO
149     ENDDO
150     DO j = 1,exchWidthY
151     DO i = 1,sNx
152     C north (nothing to change)
153     c Uphi(i,sNy+j,k,bi,bj) = dummy1(i,sNy+j)
154     c Vphi(i,sNy+j,k,bi,bj) = dummy2(i,sNy+j)
155     C south
156     Uphi(i,1-j,k,bi,bj) = dummy2(i,1-j)*negOne
157     Vphi(i,1-j,k,bi,bj) = dummy1(i,1-j)
158    
159     ENDDO
160     ENDDO
161    
162     C end odd / even faces
163     ENDIF
164    
165     C-- end of Loops on tile and level indices (k,bi,bj).
166     ENDDO
167     ENDDO
168     ENDDO
169    
170     ELSE
171     C--- not using CubedSphereExchange:
172    
173     CALL EXCH_RX( Uphi,
174     I OLw, OLe, OLs, OLn, myNz,
175     I exchWidthX, exchWidthY,
176     I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid )
177     CALL EXCH_RX( Vphi,
178     I OLw, OLe, OLs, OLn, myNz,
179     I exchWidthX, exchWidthY,
180     I FORWARD_SIMULATION, EXCH_UPDATE_CORNERS, myThid )
181    
182     C--- using or not using CubedSphereExchange: end
183     ENDIF
184    
185    
186     RETURN
187     END
188    
189     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
190    
191     CEH3 ;;; Local Variables: ***
192     CEH3 ;;; mode:fortran ***
193     CEH3 ;;; End: ***

  ViewVC Help
Powered by ViewVC 1.1.22