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

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

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


Revision 1.14 - (show annotations) (download)
Fri Feb 2 21:04:48 2001 UTC (23 years, 3 months ago) by adcroft
Branch: MAIN
Changes since 1.13: +14 -8 lines
Merged changes from branch "branch-atmos-merge" into MAIN (checkpoint34)
 - substantial modifications to algorithm sequence (dynamics.F)
 - packaged OBCS, Shapiro filter, Zonal filter, Atmospheric Physics

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/ini_cartesian_grid.F,v 1.13.2.1 2001/01/26 16:57:19 jmc Exp $
2
3 #include "CPP_OPTIONS.h"
4
5 CStartOfInterface
6 SUBROUTINE INI_CARTESIAN_GRID( myThid )
7 C /==========================================================\
8 C | SUBROUTINE INI_CARTESIAN_GRID |
9 C | o Initialise model coordinate system |
10 C |==========================================================|
11 C | These arrays are used throughout the code in evaluating |
12 C | gradients, integrals and spatial avarages. This routine |
13 C | is called separately by each thread and initialise only |
14 C | the region of the domain it is "responsible" for. |
15 C | Notes: |
16 C | Two examples are included. One illustrates the |
17 C | initialisation of a cartesian grid. The other shows the |
18 C | inialisation of a spherical polar grid. Other orthonormal|
19 C | grids can be fitted into this design. In this case |
20 C | custom metric terms also need adding to account for the |
21 C | projections of velocity vectors onto these grids. |
22 C | The structure used here also makes it possible to |
23 C | implement less regular grid mappings. In particular |
24 C | o Schemes which leave out blocks of the domain that are |
25 C | all land could be supported. |
26 C | o Multi-level schemes such as icosohedral or cubic |
27 C | grid projections onto a sphere can also be fitted |
28 C | within the strategy we use. |
29 C | Both of the above also require modifying the support |
30 C | routines that map computational blocks to simulation |
31 C | domain blocks. |
32 C | Under the cartesian grid mode primitive distances in X |
33 C | and Y are in metres. Disktance in Z are in m or Pa |
34 C | depending on the vertical gridding mode. |
35 C \==========================================================/
36 IMPLICIT NONE
37
38 C === Global variables ===
39 #include "SIZE.h"
40 #include "EEPARAMS.h"
41 #include "PARAMS.h"
42 #include "GRID.h"
43
44 C == Routine arguments ==
45 C myThid - Number of this instance of INI_CARTESIAN_GRID
46 INTEGER myThid
47 CEndOfInterface
48
49 C == Local variables ==
50 C xG, yG - Global coordinate location.
51 C xBase - South-west corner location for process.
52 C yBase
53 C zUpper - Work arrays for upper and lower
54 C zLower cell-face heights.
55 C phi - Temporary scalar
56 C xBase - Temporaries for lower corner coordinate
57 C yBase
58 C iG, jG - Global coordinate index. Usually used to hold
59 C the south-west global coordinate of a tile.
60 C bi,bj - Loop counters
61 C zUpper - Temporary arrays holding z coordinates of
62 C zLower upper and lower faces.
63 C I,J,K
64 _RL xGloc, yGloc
65 _RL xBase, yBase
66 INTEGER iG, jG
67 INTEGER bi, bj
68 INTEGER I, J
69
70 C-- Simple example of inialisation on cartesian grid
71 C-- First set coordinates of cell centers
72 C This operation is only performed at start up so for more
73 C complex configurations it is usually OK to pass iG, jG to a custom
74 C function and have it return xG and yG.
75 C Set up my local grid first
76 xC0 = 0. _d 0
77 yC0 = 0. _d 0
78 DO bj = myByLo(myThid), myByHi(myThid)
79 jG = myYGlobalLo + (bj-1)*sNy
80 DO bi = myBxLo(myThid), myBxHi(myThid)
81 iG = myXGlobalLo + (bi-1)*sNx
82 yBase = 0. _d 0
83 xBase = 0. _d 0
84 DO i=1,iG-1
85 xBase = xBase + delX(i)
86 ENDDO
87 DO j=1,jG-1
88 yBase = yBase + delY(j)
89 ENDDO
90 yGloc = yBase
91 DO J=1,sNy
92 xGloc = xBase
93 DO I=1,sNx
94 xG(I,J,bi,bj) = xGloc
95 yG(I,J,bi,bj) = yGloc
96 xc(I,J,bi,bj) = xGloc + delX(iG+i-1)*0.5 _d 0
97 yc(I,J,bi,bj) = yGloc + delY(jG+j-1)*0.5 _d 0
98 xGloc = xGloc + delX(iG+I-1)
99 dxF(I,J,bi,bj) = delX(iG+i-1)
100 dyF(I,J,bi,bj) = delY(jG+j-1)
101 ENDDO
102 yGloc = yGloc + delY(jG+J-1)
103 ENDDO
104 ENDDO
105 ENDDO
106 C Now sync. and get edge regions from other threads and/or processes.
107 C Note: We could just set the overlap regions ourselves here but
108 C exchanging edges is safer and is good practice!
109 _EXCH_XY_R4( xc, myThid )
110 _EXCH_XY_R4( yc, myThid )
111 _EXCH_XY_R4(dxF, myThid )
112 _EXCH_XY_R4(dyF, myThid )
113
114 C-- Calculate separation between other points
115 C dxG, dyG are separations between cell corners along cell faces.
116 DO bj = myByLo(myThid), myByHi(myThid)
117 DO bi = myBxLo(myThid), myBxHi(myThid)
118 DO J=1,sNy
119 DO I=1,sNx
120 dxG(I,J,bi,bj) = (dxF(I,J,bi,bj)+dxF(I,J-1,bi,bj))*0.5 _d 0
121 dyG(I,J,bi,bj) = (dyF(I,J,bi,bj)+dyF(I-1,J,bi,bj))*0.5 _d 0
122 ENDDO
123 ENDDO
124 ENDDO
125 ENDDO
126 _EXCH_XY_R4(dxG, myThid )
127 _EXCH_XY_R4(dyG, myThid )
128 C dxV, dyU are separations between velocity points along cell faces.
129 DO bj = myByLo(myThid), myByHi(myThid)
130 DO bi = myBxLo(myThid), myBxHi(myThid)
131 DO J=1,sNy
132 DO I=1,sNx
133 dxV(I,J,bi,bj) = (dxG(I,J,bi,bj)+dxG(I-1,J,bi,bj))*0.5 _d 0
134 dyU(I,J,bi,bj) = (dyG(I,J,bi,bj)+dyG(I,J-1,bi,bj))*0.5 _d 0
135 ENDDO
136 ENDDO
137 ENDDO
138 ENDDO
139 _EXCH_XY_R4(dxV, myThid )
140 _EXCH_XY_R4(dyU, myThid )
141 C dxC, dyC is separation between cell centers
142 DO bj = myByLo(myThid), myByHi(myThid)
143 DO bi = myBxLo(myThid), myBxHi(myThid)
144 DO J=1,sNy
145 DO I=1,sNx
146 dxC(I,J,bi,bj) = (dxF(I,J,bi,bj)+dxF(I-1,J,bi,bj))*0.5 _d 0
147 dyC(I,J,bi,bj) = (dyF(I,J,bi,bj)+dyF(I,J-1,bi,bj))*0.5 _d 0
148 ENDDO
149 ENDDO
150 ENDDO
151 ENDDO
152 _EXCH_XY_R4(dxC, myThid )
153 _EXCH_XY_R4(dyC, myThid )
154 C Calculate vertical face area
155 DO bj = myByLo(myThid), myByHi(myThid)
156 DO bi = myBxLo(myThid), myBxHi(myThid)
157 DO J=1,sNy
158 DO I=1,sNx
159 rA (I,J,bi,bj) = dxF(I,J,bi,bj)*dyF(I,J,bi,bj)
160 rAw(I,J,bi,bj) = dxC(I,J,bi,bj)*dyG(I,J,bi,bj)
161 rAs(I,J,bi,bj) = dxG(I,J,bi,bj)*dyC(I,J,bi,bj)
162 rAz(I,J,bi,bj) = dxV(I,J,bi,bj)*dyU(I,J,bi,bj)
163 tanPhiAtU(I,J,bi,bj) = 0. _d 0
164 tanPhiAtV(I,J,bi,bj) = 0. _d 0
165 ENDDO
166 ENDDO
167 ENDDO
168 ENDDO
169 _EXCH_XY_R4 (rA , myThid )
170 _EXCH_XY_R4 (rAw , myThid )
171 _EXCH_XY_R4 (rAs , myThid )
172 _EXCH_XY_R4 (tanPhiAtU , myThid )
173 _EXCH_XY_R4 (tanPhiAtV , myThid )
174
175 C
176 RETURN
177 END

  ViewVC Help
Powered by ViewVC 1.1.22