/[MITgcm]/MITgcm/model/src/ini_local_grid.F
ViewVC logotype

Contents of /MITgcm/model/src/ini_local_grid.F

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


Revision 1.1 - (show annotations) (download)
Mon Dec 12 19:01:01 2011 UTC (12 years, 5 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64o, checkpoint64a, checkpoint63r, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint64n, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint64b, checkpoint63h, checkpoint63m, checkpoint64e, checkpoint63i, checkpoint63q, checkpoint64d, checkpoint64c, checkpoint64g, checkpoint64f, checkpoint63j, checkpoint63l, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint63n, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint63k, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint64i, checkpoint63o, checkpoint63p, checkpoint64h, checkpoint63s, checkpoint64k, checkpoint64, checkpoint65, checkpoint64j, checkpoint64m, checkpoint63g, checkpoint64l, HEAD
new S/R INI_LOCAL_GRID to define model tile-local grid (using same units
as delX,delY) and called from S/R INI_CARTESIAN_GRID, INI_CYLINDER_GRID
and INI_SPHERICAL_POLAR_GRID.

1 C $Header: /u/gcmpack/MITgcm/model/src/ini_spherical_polar_grid.F,v 1.27 2010/04/17 18:25:12 jmc Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "CPP_OPTIONS.h"
6 #ifdef ALLOW_EXCH2
7 # include "W2_OPTIONS.h"
8 #endif /* ALLOW_EXCH2 */
9
10 CBOP
11 C !ROUTINE: INI_LOCAL_GRID
12 C !INTERFACE:
13 SUBROUTINE INI_LOCAL_GRID(
14 O xGloc, yGloc,
15 O delXloc, delYloc,
16 O gridNx, gridNy,
17 I bi, bj, myThid )
18
19 C !DESCRIPTION: \bv
20 C *==========================================================*
21 C | SUBROUTINE INI_LOCAL_GRID
22 C | o Initialise model tile-local horizontal grid
23 C *==========================================================*
24 C | Set local grid-point location (xGloc & yGloc) and
25 C | local grid-point spacing (delXloc,delYloc) keeping the
26 C | same units as grid-spacing input parameter (delX,delY
27 C | and xgOrigin,ygOrigin).
28 C | This tile-local mesh setting will be used to build
29 C | the horizontal model grid, according to the selected
30 C | grid option (cartesian, spherical_polar or cylindrical)
31 C *==========================================================*
32 C \ev
33
34 C !USES:
35 IMPLICIT NONE
36 C === Global variables ===
37 #include "SIZE.h"
38 #include "EEPARAMS.h"
39 #include "PARAMS.h"
40 #ifdef ALLOW_EXCH2
41 # include "W2_EXCH2_SIZE.h"
42 # include "W2_EXCH2_TOPOLOGY.h"
43 #endif /* ALLOW_EXCH2 */
44 #include "SET_GRID.h"
45
46 C !INPUT/OUTPUT PARAMETERS:
47 C == Routine arguments ==
48 C xGloc :: mesh corner-point location (local "Long" real array type)
49 C yGloc :: mesh corner-point location (local "Long" real array type)
50 C delXloc :: mesh spacing in X direction
51 C delYloc :: mesh spacing in Y direction
52 C gridNx :: mesh total grid-point number in X direction
53 C gridNy :: mesh total grid-point number in Y direction
54 C bi, bj :: tile indices
55 C myThid :: my Thread Id Number
56
57 C NOTICE the extended range of indices!!
58 _RL xGloc(1-OLx:sNx+OLx+1,1-OLy:sNy+OLy+1)
59 _RL yGloc(1-OLx:sNx+OLx+1,1-OLy:sNy+OLy+1)
60 C NOTICE the extended range of indices!!
61 _RL delXloc(0-OLx:sNx+OLx)
62 _RL delYloc(0-OLy:sNy+OLy)
63 INTEGER gridNx, gridNy
64 INTEGER bi, bj
65 INTEGER myThid
66
67 C !LOCAL VARIABLES:
68 C == Local variables ==
69 C xG0,yG0 :: coordinate of South-West tile-corner
70 C iG0,jG0 :: Tile base X and Y indices within global index space
71 C i, j :: loop counters
72 INTEGER iG0, jG0
73 INTEGER i, j
74 _RL xG0, yG0
75 #ifdef ALLOW_EXCH2
76 INTEGER tN
77 #endif /* ALLOW_EXCH2 */
78
79 C The functions iGl, jGl return the "global" index with valid values beyond
80 C halo regions
81 C cnh wrote:
82 C > I dont understand why we would ever have to multiply the
83 C > overlap by the total domain size e.g
84 C > OLx*Nx, OLy*Ny.
85 C > Can anybody explain? Lines are in ini_spherical_polar_grid.F.
86 C > Surprised the code works if its wrong, so I am puzzled.
87 C jmc replied:
88 C Yes, I can explain this since I put this modification to work
89 C with small domain (where OLy > Ny, as for instance, zonal-average
90 C case):
91 C This has no effect on the acuracy of the evaluation of iGl(I,bi)
92 C and jGl(j,bj) since we take mod(a+OLx*Nx,Nx) and mod(b+OLy*Ny,Ny).
93 C But in case a or b is negative, then the FORTRAN function "mod"
94 C does not return the matematical value of the "modulus" function,
95 C and this is not good for your purpose.
96 C This is why I add +OLx*Nx and +OLy*Ny to be sure that the 1rst
97 C argument of the mod function is positive.
98 c INTEGER iGl,jGl
99 c iGl(i,bi) = 1+MOD(iG0+i-1+OLx*gridNx,gridNx)
100 c jGl(j,bj) = 1+MOD(jG0+j-1+OLy*gridNy,gridNy)
101 CEOP
102
103 #ifdef ALLOW_EXCH2
104 gridNx = exch2_mydNx(1)
105 gridNy = exch2_mydNy(1)
106 #else /* ALLOW_EXCH2 */
107 gridNx = Nx
108 gridNy = Ny
109 #endif /* ALLOW_EXCH2 */
110
111 c DO bj = myByLo(myThid), myByHi(myThid)
112 c DO bi = myBxLo(myThid), myBxHi(myThid)
113 C For this tile ...
114
115 C-- Set current tile base X and base Y indices within global index space
116 C e.g., local indices of tile south-west corner grid point are (1,1)
117 C and global indices are 1+iG0, 1+jG0
118 #ifdef ALLOW_EXCH2
119 tN = W2_myTileList(bi,bj)
120 iG0 = exch2_tBasex(tN)
121 jG0 = exch2_tBasey(tN)
122 #else /* ALLOW_EXCH2 */
123 iG0 = myXGlobalLo - 1 + (bi-1)*sNx
124 jG0 = myYGlobalLo - 1 + (bj-1)*sNy
125 #endif /* ALLOW_EXCH2 */
126
127 C-- First find coordinate of tile corner (meaning outer corner of halo)
128 xG0 = xgOrigin
129 C Find the X-coordinate of the outer grid-line of the "real" tile
130 DO i=1, iG0
131 xG0 = xG0 + delX(i)
132 ENDDO
133 C Back-step to the outer grid-line of the "halo" region
134 DO i=1, OLx
135 xG0 = xG0 - delX( 1+MOD(iG0-i+OLx*gridNx,gridNx) )
136 ENDDO
137 C Find the Y-coordinate of the outer grid-line of the "real" tile
138 yG0 = ygOrigin
139 DO j=1, jG0
140 yG0 = yG0 + delY(j)
141 ENDDO
142 C Back-step to the outer grid-line of the "halo" region
143 DO j=1, OLy
144 yG0 = yG0 - delY( 1+MOD(jG0-j+OLy*gridNy,gridNy) )
145 ENDDO
146
147 C-- Make a local copy of current-tile grid-spacing
148 DO i=0-OLx,sNx+OLx
149 delXloc(i) = delX( 1+MOD(iG0+i-1+OLx*gridNx,gridNx) )
150 ENDDO
151 DO j=0-OLy,sNy+OLy
152 delYloc(j) = delY( 1+MOD(jG0+j-1+OLy*gridNy,gridNy) )
153 ENDDO
154
155 C-- Calculate coordinates of cell corners for N+1 grid-lines
156 DO j=1-OLy,sNy+OLy +1
157 xGloc(1-OLx,j) = xG0
158 DO i=1-OLx,sNx+OLx
159 xGloc(i+1,j) = xGloc(i,j) + delXloc(i)
160 ENDDO
161 ENDDO
162 DO i=1-OLx,sNx+OLx +1
163 yGloc(i,1-OLy) = yG0
164 DO j=1-OLy,sNy+OLy
165 yGloc(i,j+1) = yGloc(i,j) + delYloc(j)
166 ENDDO
167 ENDDO
168
169 C-- end bi,bj loops
170 c ENDDO
171 c ENDDO
172
173 RETURN
174 END

  ViewVC Help
Powered by ViewVC 1.1.22