/[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.7 - (show annotations) (download)
Thu Jul 2 14:16:24 1998 UTC (25 years, 10 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint11, checkpoint13, checkpoint12, branch-point-rdot
Branch point for: branch-rdot
Changes since 1.6: +2 -73 lines
Re-arrangment of initialisation:
 o ini_grid is now called first and it sets up *only* the grid and
   coordinate system.
 o ini_depths then reads topography are can set it as a function of xC, yC.
 o ini_masks_etc then derives everything else (masks, lopping factors and
   recipricols).
This tidy-up is in preparation for the rDot transformation...(tense pause)!

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/ini_cartesian_grid.F,v 1.6 1998/06/25 20:43:23 cnh Exp $
2
3 #include "CPP_EEOPTIONS.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
37 C === Global variables ===
38 #include "SIZE.h"
39 #include "EEPARAMS.h"
40 #include "PARAMS.h"
41 #include "GRID.h"
42
43 C == Routine arguments ==
44 C myThid - Number of this instance of INI_CARTESIAN_GRID
45 INTEGER myThid
46 CEndOfInterface
47
48 C == Local variables ==
49 C xG, yG - Global coordinate location.
50 C zG
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 xG, yG, zG
65 _RL phi
66 _RL zUpper(Nz), zLower(Nz)
67 _RL xBase, yBase
68 INTEGER iG, jG
69 INTEGER bi, bj
70 INTEGER I, J, K
71
72 C-- Simple example of inialisation on cartesian grid
73 C-- First set coordinates of cell centers
74 C This operation is only performed at start up so for more
75 C complex configurations it is usually OK to pass iG, jG to a custom
76 C function and have it return xG and yG.
77 C Set up my local grid first
78 xC0 = 0. _d 0
79 yC0 = 0. _d 0
80 DO bj = myByLo(myThid), myByHi(myThid)
81 jG = myYGlobalLo + (bj-1)*sNy
82 DO bi = myBxLo(myThid), myBxHi(myThid)
83 iG = myXGlobalLo + (bi-1)*sNx
84 yBase = 0. _d 0
85 xBase = 0. _d 0
86 DO i=1,iG-1
87 xBase = xBase + delX(i)
88 ENDDO
89 DO j=1,jG-1
90 yBase = yBase + delY(j)
91 ENDDO
92 yG = yBase
93 DO J=1,sNy
94 xG = xBase
95 DO I=1,sNx
96 xc(I,J,bi,bj) = xG + delX(iG+i-1)*0.5 _d 0
97 yc(I,J,bi,bj) = yG + delY(jG+j-1)*0.5 _d 0
98 xG = xG + 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 yG = yG + 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 D0
147 dyC(I,J,bi,bj) = (dyF(I,J,bi,bj)+dyF(I,J-1,bi,bj))*0.5 D0
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 zA(I,J,bi,bj) = dxF(I,J,bi,bj)*dyF(I,J,bi,bj)
160 tanPhiAtU(I,J,bi,bj) = 0. _d 0
161 tanPhiAtV(I,J,bi,bj) = 0. _d 0
162 ENDDO
163 ENDDO
164 ENDDO
165 ENDDO
166 _EXCH_XY_R4 (zA , myThid )
167 _EXCH_XY_R4 (tanPhiAtU , myThid )
168 _EXCH_XY_R4 (tanPhiAtV , myThid )
169
170 C
171 RETURN
172 END

  ViewVC Help
Powered by ViewVC 1.1.22