1 |
C $Header: /u/gcmpack/MITgcm/model/src/ini_cylinder_grid.F,v 1.7 2011/12/12 19:01:01 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: INI_CYLINDER_GRID |
8 |
C !INTERFACE: |
9 |
SUBROUTINE INI_CYLINDER_GRID( myThid ) |
10 |
|
11 |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
13 |
C | SUBROUTINE INI_CYLINDER_GRID |
14 |
C | o Initialise model coordinate system arrays |
15 |
C *==========================================================* |
16 |
C | These arrays are used throughout the code in evaluating |
17 |
C | gradients, integrals and spatial avarages. This routine |
18 |
C | is called separately by each thread and initialise only |
19 |
C | the region of the domain it is "responsible" for. |
20 |
C | Under the cylindrical grid mode primitive distance |
21 |
C | in X is in degrees and distance in Y is in meters. |
22 |
C | Distance in Z are in m or Pa depending on the vertical |
23 |
C | gridding mode. |
24 |
C *==========================================================* |
25 |
C \ev |
26 |
|
27 |
C !USES: |
28 |
IMPLICIT NONE |
29 |
C === Global variables === |
30 |
#include "SIZE.h" |
31 |
#include "EEPARAMS.h" |
32 |
#include "PARAMS.h" |
33 |
#include "GRID.h" |
34 |
|
35 |
C !INPUT/OUTPUT PARAMETERS: |
36 |
C == Routine arguments == |
37 |
C myThid :: my Thread Id number |
38 |
INTEGER myThid |
39 |
|
40 |
C !LOCAL VARIABLES: |
41 |
C == Local variables == |
42 |
C bi,bj :: tile indices |
43 |
C i, j :: loop counters |
44 |
C lat :: Temporary variables used to hold latitude values. |
45 |
C dlat :: Temporary variables used to hold latitudes increment. |
46 |
C dlon :: Temporary variables used to hold longitude increment. |
47 |
C delXloc :: mesh spacing in X direction |
48 |
C delYloc :: mesh spacing in Y direction |
49 |
C xGloc :: mesh corner-point location (local "Long" real array type) |
50 |
C yGloc :: mesh corner-point location (local "Long" real array type) |
51 |
INTEGER bi, bj |
52 |
INTEGER i, j |
53 |
INTEGER gridNx, gridNy |
54 |
c _RL lat, dlat, dlon |
55 |
c _RL xG0, yG0 |
56 |
_RL dtheta, thisRad |
57 |
C NOTICE the extended range of indices!! |
58 |
_RL delXloc(0-OLx:sNx+OLx) |
59 |
_RL delYloc(0-OLy:sNy+OLy) |
60 |
C NOTICE the extended range of indices!! |
61 |
_RL xGloc(1-OLx:sNx+OLx+1,1-OLy:sNy+OLy+1) |
62 |
_RL yGloc(1-OLx:sNx+OLx+1,1-OLy:sNy+OLy+1) |
63 |
CEOP |
64 |
|
65 |
C-- For each tile ... |
66 |
DO bj = myByLo(myThid), myByHi(myThid) |
67 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
68 |
|
69 |
C-- set tile local mesh (same units as delX,deY) |
70 |
C corresponding to coordinates of cell corners for N+1 grid-lines |
71 |
CALL INI_LOCAL_GRID( |
72 |
O xGloc, yGloc, |
73 |
O delXloc, delYloc, |
74 |
O gridNx, gridNy, |
75 |
I bi, bj, myThid ) |
76 |
|
77 |
C-- Make a permanent copy of [xGloc,yGloc] in [xG,yG] |
78 |
DO j=1-OLy,sNy+OLy |
79 |
DO i=1-OLx,sNx+OLx |
80 |
xG(i,j,bi,bj) = xGloc(i,j) |
81 |
yG(i,j,bi,bj) = yGloc(i,j) |
82 |
ENDDO |
83 |
ENDDO |
84 |
|
85 |
C-- Calculate [xC,yC], coordinates of cell centers |
86 |
DO j=1-OLy,sNy+OLy |
87 |
DO i=1-OLx,sNx+OLx |
88 |
C by averaging |
89 |
xC(i,j,bi,bj) = 0.25 _d 0*( |
90 |
& xGloc(i,j)+xGloc(i+1,j)+xGloc(i,j+1)+xGloc(i+1,j+1) ) |
91 |
yC(i,j,bi,bj) = 0.25 _d 0*( |
92 |
& yGloc(i,j)+yGloc(i+1,j)+yGloc(i,j+1)+yGloc(i+1,j+1) ) |
93 |
ENDDO |
94 |
ENDDO |
95 |
|
96 |
C-- Calculate [dxF,dyF], lengths between cell faces (through center) |
97 |
DO j=1-OLy,sNy+OLy |
98 |
DO i=1-OLx,sNx+OLx |
99 |
thisRad = yC(i,j,bi,bj) |
100 |
dtheta = delXloc(i) |
101 |
dxF(i,j,bi,bj) = thisRad*dtheta*deg2rad |
102 |
dyF(i,j,bi,bj) = delYloc(j) |
103 |
ENDDO |
104 |
ENDDO |
105 |
|
106 |
C-- Calculate [dxG,dyG], lengths along cell boundaries |
107 |
DO j=1-OLy,sNy+OLy |
108 |
DO i=1-OLx,sNx+OLx |
109 |
thisRad = 0.5 _d 0*(yGloc(i,j)+yGloc(i+1,j)) |
110 |
dtheta = delXloc(i) |
111 |
dxG(i,j,bi,bj) = thisRad*dtheta*deg2rad |
112 |
dyG(i,j,bi,bj) = delYloc(j) |
113 |
ENDDO |
114 |
ENDDO |
115 |
|
116 |
C-- The following arrays are not defined in some parts of the halo |
117 |
C region. We set them to zero here for safety. |
118 |
C Note: this is now done earlier in main S/R INI_GRID |
119 |
|
120 |
C-- Calculate [dxC], zonal length between cell centers |
121 |
DO j=1-OLy,sNy+OLy |
122 |
DO i=1-OLx+1,sNx+OLx ! NOTE range |
123 |
C by averaging |
124 |
dxC(i,j,bi,bj) = 0.5 _d 0*(dxF(i,j,bi,bj)+dxF(i-1,j,bi,bj)) |
125 |
ENDDO |
126 |
ENDDO |
127 |
|
128 |
C-- Calculate [dyC], meridional length between cell centers |
129 |
DO j=1-OLy+1,sNy+OLy ! NOTE range |
130 |
DO i=1-OLx,sNx+OLx |
131 |
C by averaging |
132 |
dyC(i,j,bi,bj) = 0.5 _d 0*(dyF(i,j,bi,bj)+dyF(i,j-1,bi,bj)) |
133 |
ENDDO |
134 |
ENDDO |
135 |
|
136 |
C-- Calculate [dxV,dyU], length between velocity points (through corners) |
137 |
DO j=1-OLy+1,sNy+OLy ! NOTE range |
138 |
DO i=1-OLx+1,sNx+OLx ! NOTE range |
139 |
C by averaging (method I) |
140 |
dxV(i,j,bi,bj) = 0.5 _d 0*(dxG(i,j,bi,bj)+dxG(i-1,j,bi,bj)) |
141 |
dyU(i,j,bi,bj) = 0.5 _d 0*(dyG(i,j,bi,bj)+dyG(i,j-1,bi,bj)) |
142 |
ENDDO |
143 |
ENDDO |
144 |
|
145 |
C-- Calculate vertical face area |
146 |
DO j=1-OLy,sNy+OLy |
147 |
DO i=1-OLx,sNx+OLx |
148 |
C- All r(dr)(dtheta) |
149 |
rA (i,j,bi,bj) = dxF(i,j,bi,bj)*dyF(i,j,bi,bj) |
150 |
rAw(i,j,bi,bj) = dxC(i,j,bi,bj)*dyG(i,j,bi,bj) |
151 |
rAs(i,j,bi,bj) = dxG(i,j,bi,bj)*dyC(i,j,bi,bj) |
152 |
rAz(i,j,bi,bj) = dxV(i,j,bi,bj)*dyU(i,j,bi,bj) |
153 |
C-- Set trigonometric terms & grid orientation: |
154 |
C Note: this is now done earlier in main S/R INI_GRID |
155 |
c tanPhiAtU(i,j,bi,bj) = 0. |
156 |
c tanPhiAtV(i,j,bi,bj) = 0. |
157 |
c angleCosC(i,j,bi,bj) = 1. |
158 |
c angleSinC(i,j,bi,bj) = 0. |
159 |
ENDDO |
160 |
ENDDO |
161 |
|
162 |
C-- end bi,bj loops |
163 |
ENDDO |
164 |
ENDDO |
165 |
|
166 |
RETURN |
167 |
END |