1 |
C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_get_send_bounds.F,v 1.3 2007/10/09 00:03:33 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_EEOPTIONS.h" |
5 |
|
6 |
CBOP 0 |
7 |
C !ROUTINE: EXCH2_GET_SCAL_BOUNDS |
8 |
|
9 |
C !INTERFACE: |
10 |
SUBROUTINE EXCH2_GET_SCAL_BOUNDS( |
11 |
I fCode, eWdth, updateCorners, |
12 |
I tgTile, tgNb, |
13 |
O tIlo, tIhi, tJlo, tJhi, |
14 |
O tiStride, tjStride, |
15 |
I myThid ) |
16 |
|
17 |
C !DESCRIPTION: |
18 |
C Return the index range & step of the part of the array (overlap-region) |
19 |
C which is going to be updated by the exchange with 1 neighbour. |
20 |
C Scalar field version (as opposed to 2-components vector field). |
21 |
C Note: presently only coded for grid-centered (mass point) scalar. |
22 |
C needs to extend it to grid-corner (vorticity point) scalar. |
23 |
|
24 |
C !USES: |
25 |
IMPLICIT NONE |
26 |
|
27 |
#include "SIZE.h" |
28 |
#include "W2_EXCH2_SIZE.h" |
29 |
#include "W2_EXCH2_TOPOLOGY.h" |
30 |
|
31 |
C !INPUT/OUTPUT PARAMETERS: |
32 |
C fCode :: field code (position on staggered grid) |
33 |
C eWdth :: width of data region to exchange |
34 |
C updateCorners :: flag, do update corner halo region if true |
35 |
C tgTile :: target tile |
36 |
C tgNb :: target Neighbour entry |
37 |
C tIlo, tIhi :: index range in I that will be filled in target array |
38 |
C tJlo, tJhi :: index range in J that will be filled in target array |
39 |
C tiStride :: index step in I that will be filled in target array |
40 |
C tjStride :: index step in J that will be filled in target array |
41 |
C myThid :: my Thread Id. number |
42 |
|
43 |
CHARACTER*2 fCode |
44 |
INTEGER eWdth |
45 |
LOGICAL updateCorners |
46 |
INTEGER tgTile, tgNb |
47 |
INTEGER tIlo, tIhi, tJlo, tJhi |
48 |
INTEGER tiStride, tjStride |
49 |
INTEGER myThid |
50 |
|
51 |
C !LOCAL VARIABLES: |
52 |
CEOP |
53 |
|
54 |
C--- Initialise index range from Topology values: |
55 |
tIlo = exch2_iLo(tgNb,tgTile) |
56 |
tIhi = exch2_iHi(tgNb,tgTile) |
57 |
tJlo = exch2_jLo(tgNb,tgTile) |
58 |
tJhi = exch2_jHi(tgNb,tgTile) |
59 |
|
60 |
C--- Expand index range according to exchange-Width "eWdth" |
61 |
IF ( tIlo .EQ. tIhi .AND. tIlo .EQ. 0 ) THEN |
62 |
C Filling a west edge overlap |
63 |
tIlo = 1-eWdth |
64 |
tiStride = 1 |
65 |
IF ( tJlo .LE. tJhi ) THEN |
66 |
tjStride = 1 |
67 |
ELSE |
68 |
tjStride =-1 |
69 |
ENDIF |
70 |
IF ( updateCorners ) THEN |
71 |
tJlo = tJlo-tjStride*(eWdth-1) |
72 |
tJhi = tJhi+tjStride*(eWdth-1) |
73 |
ELSE |
74 |
tJlo = tJlo+tjStride |
75 |
tJhi = tJhi-tjStride |
76 |
ENDIF |
77 |
ENDIF |
78 |
IF ( tIlo .EQ. tIhi .AND. tIlo .GT. 1 ) THEN |
79 |
C Filling an east edge overlap |
80 |
tIhi = tIhi+eWdth-1 |
81 |
tiStride = 1 |
82 |
IF ( tJlo .LE. tJhi ) THEN |
83 |
tjStride = 1 |
84 |
ELSE |
85 |
tjStride =-1 |
86 |
ENDIF |
87 |
IF ( updateCorners ) THEN |
88 |
tJlo = tJlo-tjStride*(eWdth-1) |
89 |
tJhi = tJhi+tjStride*(eWdth-1) |
90 |
ELSE |
91 |
tJlo = tJlo+tjStride |
92 |
tJhi = tJhi-tjStride |
93 |
ENDIF |
94 |
ENDIF |
95 |
IF ( tJlo .EQ. tJhi .AND. tJlo .EQ. 0 ) THEN |
96 |
C Filling a south edge overlap |
97 |
tJlo = 1-eWdth |
98 |
tjStride = 1 |
99 |
IF ( tIlo .LE. tIhi ) THEN |
100 |
tiStride = 1 |
101 |
ELSE |
102 |
tiStride =-1 |
103 |
ENDIF |
104 |
IF ( updateCorners ) THEN |
105 |
tIlo = tIlo-tiStride*(eWdth-1) |
106 |
tIhi = tIhi+tiStride*(eWdth-1) |
107 |
ELSE |
108 |
tIlo = tIlo+tiStride |
109 |
tIhi = tIhi-tiStride |
110 |
ENDIF |
111 |
ENDIF |
112 |
IF ( tJlo .EQ. tJhi .AND. tJlo .GT. 1 ) THEN |
113 |
C Filling a north edge overlap |
114 |
tJhi = tJhi+eWdth-1 |
115 |
tjStride = 1 |
116 |
IF ( tIlo .LE. tIhi ) THEN |
117 |
tiStride = 1 |
118 |
ELSE |
119 |
tiStride =-1 |
120 |
ENDIF |
121 |
IF ( updateCorners ) THEN |
122 |
tIlo = tIlo-tiStride*(eWdth-1) |
123 |
tIhi = tIhi+tiStride*(eWdth-1) |
124 |
ELSE |
125 |
tIlo = tIlo+tiStride |
126 |
tIhi = tIhi-tiStride |
127 |
ENDIF |
128 |
ENDIF |
129 |
|
130 |
RETURN |
131 |
END |