7 |
C !ROUTINE: INI_CARTESIAN_GRID |
C !ROUTINE: INI_CARTESIAN_GRID |
8 |
C !INTERFACE: |
C !INTERFACE: |
9 |
SUBROUTINE INI_CARTESIAN_GRID( myThid ) |
SUBROUTINE INI_CARTESIAN_GRID( myThid ) |
10 |
|
|
11 |
C !DESCRIPTION: \bv |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
C *==========================================================* |
13 |
C | SUBROUTINE INI_CARTESIAN_GRID |
C | SUBROUTINE INI_CARTESIAN_GRID |
14 |
C | o Initialise model coordinate system |
C | o Initialise model coordinate system |
15 |
C *==========================================================* |
C *==========================================================* |
16 |
C | The grid arrays, initialised here, are used throughout |
C | The grid arrays, initialised here, are used throughout |
17 |
C | the code in evaluating gradients, integrals and spatial |
C | the code in evaluating gradients, integrals and spatial |
18 |
C | avarages. This routine |
C | avarages. This routine is called separately by each |
19 |
C | is called separately by each thread and initialises only |
C | thread and initialises only the region of the domain |
20 |
C | the region of the domain it is "responsible" for. |
C | it is "responsible" for. |
21 |
C | Notes: |
C | Under the cartesian grid mode primitive distances |
22 |
C | Two examples are included. One illustrates the |
C | in X and Y are in metres. Distance in Z are in m or Pa |
23 |
C | initialisation of a cartesian grid (this routine). |
C | depending on the vertical gridding mode. |
|
C | The other shows the |
|
|
C | inialisation of a spherical polar grid. Other orthonormal |
|
|
C | grids can be fitted into this design. In this case |
|
|
C | custom metric terms also need adding to account for the |
|
|
C | projections of velocity vectors onto these grids. |
|
|
C | The structure used here also makes it possible to |
|
|
C | implement less regular grid mappings. In particular |
|
|
C | o Schemes which leave out blocks of the domain that are |
|
|
C | all land could be supported. |
|
|
C | o Multi-level schemes such as icosohedral or cubic |
|
|
C | grid projections onto a sphere can also be fitted |
|
|
C | within the strategy we use. |
|
|
C | Both of the above also require modifying the support |
|
|
C | routines that map computational blocks to simulation |
|
|
C | domain blocks. |
|
|
C | Under the cartesian grid mode primitive distances in X |
|
|
C | and Y are in metres. Disktance in Z are in m or Pa |
|
|
C | depending on the vertical gridding mode. |
|
24 |
C *==========================================================* |
C *==========================================================* |
25 |
C \ev |
C \ev |
26 |
|
|
34 |
|
|
35 |
C !INPUT/OUTPUT PARAMETERS: |
C !INPUT/OUTPUT PARAMETERS: |
36 |
C == Routine arguments == |
C == Routine arguments == |
37 |
C myThid - Number of this instance of INI_CARTESIAN_GRID |
C myThid :: my Thread Id Number |
38 |
INTEGER myThid |
INTEGER myThid |
39 |
|
|
40 |
C !LOCAL VARIABLES: |
C !LOCAL VARIABLES: |
41 |
C == Local variables == |
C == Local variables == |
42 |
INTEGER iG, jG, bi, bj, I, J |
C bi,bj :: tile indices |
43 |
_RL xG0, yG0 |
C i, j :: loop counters |
44 |
C "Long" real for temporary coordinate calculation |
C delXloc :: mesh spacing in X direction |
45 |
C NOTICE the extended range of indices!! |
C delYloc :: mesh spacing in Y direction |
46 |
_RL xGloc(1-Olx:sNx+Olx+1,1-Oly:sNy+Oly+1) |
C xGloc :: mesh corner-point location (local "Long" real array type) |
47 |
_RL yGloc(1-Olx:sNx+Olx+1,1-Oly:sNy+Oly+1) |
C yGloc :: mesh corner-point location (local "Long" real array type) |
48 |
C These functions return the "global" index with valid values beyond |
INTEGER bi, bj |
49 |
C halo regions |
INTEGER i, j |
50 |
INTEGER iGl,jGl |
INTEGER gridNx, gridNy |
51 |
iGl(I,bi) = 1+mod(myXGlobalLo-1+(bi-1)*sNx+I+Olx*Nx-1,Nx) |
C NOTICE the extended range of indices!! |
52 |
jGl(J,bj) = 1+mod(myYGlobalLo-1+(bj-1)*sNy+J+Oly*Ny-1,Ny) |
_RL delXloc(0-OLx:sNx+OLx) |
53 |
|
_RL delYloc(0-OLy:sNy+OLy) |
54 |
|
C NOTICE the extended range of indices!! |
55 |
|
_RL xGloc(1-OLx:sNx+OLx+1,1-OLy:sNy+OLy+1) |
56 |
|
_RL yGloc(1-OLx:sNx+OLx+1,1-OLy:sNy+OLy+1) |
57 |
CEOP |
CEOP |
58 |
|
|
59 |
C For each tile ... |
C-- For each tile ... |
60 |
DO bj = myByLo(myThid), myByHi(myThid) |
DO bj = myByLo(myThid), myByHi(myThid) |
61 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
DO bi = myBxLo(myThid), myBxHi(myThid) |
62 |
|
|
63 |
C-- "Global" index (place holder) |
C-- set tile local mesh (same units as delX,deY) |
64 |
jG = myYGlobalLo + (bj-1)*sNy |
C corresponding to coordinates of cell corners for N+1 grid-lines |
65 |
iG = myXGlobalLo + (bi-1)*sNx |
|
66 |
|
CALL INI_LOCAL_GRID( |
67 |
C-- First find coordinate of tile corner (meaning outer corner of halo) |
O xGloc, yGloc, |
68 |
xG0 = 0. |
O delXloc, delYloc, |
69 |
C Find the X-coordinate of the outer grid-line of the "real" tile |
O gridNx, gridNy, |
70 |
DO i=1, iG-1 |
I bi, bj, myThid ) |
|
xG0 = xG0 + delX(i) |
|
|
ENDDO |
|
|
C Back-step to the outer grid-line of the "halo" region |
|
|
DO i=1, Olx |
|
|
xG0 = xG0 - delX( 1+mod(Olx*Nx-1+iG-i,Nx) ) |
|
|
ENDDO |
|
|
C Find the Y-coordinate of the outer grid-line of the "real" tile |
|
|
yG0 = 0. |
|
|
DO j=1, jG-1 |
|
|
yG0 = yG0 + delY(j) |
|
|
ENDDO |
|
|
C Back-step to the outer grid-line of the "halo" region |
|
|
DO j=1, Oly |
|
|
yG0 = yG0 - delY( 1+mod(Oly*Ny-1+jG-j,Ny) ) |
|
|
ENDDO |
|
|
|
|
|
C-- Calculate coordinates of cell corners for N+1 grid-lines |
|
|
DO J=1-Oly,sNy+Oly +1 |
|
|
xGloc(1-Olx,J) = xG0 |
|
|
DO I=1-Olx,sNx+Olx |
|
|
c xGloc(I+1,J) = xGloc(I,J) + delX(1+mod(Nx-1+iG-1+i,Nx)) |
|
|
xGloc(I+1,J) = xGloc(I,J) + delX( iGl(I,bi) ) |
|
|
ENDDO |
|
|
ENDDO |
|
|
DO I=1-Olx,sNx+Olx +1 |
|
|
yGloc(I,1-Oly) = yG0 |
|
|
DO J=1-Oly,sNy+Oly |
|
|
c yGloc(I,J+1) = yGloc(I,J) + delY(1+mod(Ny-1+jG-1+j,Ny)) |
|
|
yGloc(I,J+1) = yGloc(I,J) + delY( jGl(J,bj) ) |
|
|
ENDDO |
|
|
ENDDO |
|
71 |
|
|
72 |
C-- Make a permanent copy of [xGloc,yGloc] in [xG,yG] |
C-- Make a permanent copy of [xGloc,yGloc] in [xG,yG] |
73 |
DO J=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
74 |
DO I=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
75 |
xG(I,J,bi,bj) = xGloc(I,J) |
xG(i,j,bi,bj) = xGloc(i,j) |
76 |
yG(I,J,bi,bj) = yGloc(I,J) |
yG(i,j,bi,bj) = yGloc(i,j) |
77 |
ENDDO |
ENDDO |
78 |
ENDDO |
ENDDO |
79 |
|
|
80 |
C-- Calculate [xC,yC], coordinates of cell centers |
C-- Calculate [xC,yC], coordinates of cell centers |
81 |
DO J=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
82 |
DO I=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
83 |
C by averaging |
C by averaging |
84 |
xC(I,J,bi,bj) = 0.25*( |
xC(i,j,bi,bj) = 0.25 _d 0*( |
85 |
& xGloc(I,J)+xGloc(I+1,J)+xGloc(I,J+1)+xGloc(I+1,J+1) ) |
& xGloc(i,j)+xGloc(i+1,j)+xGloc(i,j+1)+xGloc(i+1,j+1) ) |
86 |
yC(I,J,bi,bj) = 0.25*( |
yC(i,j,bi,bj) = 0.25 _d 0*( |
87 |
& yGloc(I,J)+yGloc(I+1,J)+yGloc(I,J+1)+yGloc(I+1,J+1) ) |
& yGloc(i,j)+yGloc(i+1,j)+yGloc(i,j+1)+yGloc(i+1,j+1) ) |
88 |
ENDDO |
ENDDO |
89 |
ENDDO |
ENDDO |
90 |
|
|
91 |
C-- Calculate [dxF,dyF], lengths between cell faces (through center) |
C-- Calculate [dxF,dyF], lengths between cell faces (through center) |
92 |
DO J=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
93 |
DO I=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
94 |
dXF(I,J,bi,bj) = delX( iGl(I,bi) ) |
dxF(i,j,bi,bj) = delXloc(i) |
95 |
dYF(I,J,bi,bj) = delY( jGl(J,bj) ) |
dyF(i,j,bi,bj) = delYloc(j) |
96 |
ENDDO |
ENDDO |
97 |
ENDDO |
ENDDO |
98 |
|
|
99 |
C-- Calculate [dxG,dyG], lengths along cell boundaries |
C-- Calculate [dxG,dyG], lengths along cell boundaries |
100 |
DO J=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
101 |
DO I=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
102 |
dXG(I,J,bi,bj) = delX( iGl(I,bi) ) |
dxG(i,j,bi,bj) = delXloc(i) |
103 |
dYG(I,J,bi,bj) = delY( jGl(J,bj) ) |
dyG(i,j,bi,bj) = delYloc(j) |
104 |
ENDDO |
ENDDO |
105 |
ENDDO |
ENDDO |
106 |
|
|
107 |
C-- The following arrays are not defined in some parts of the halo |
C-- The following arrays are not defined in some parts of the halo |
108 |
C region. We set them to zero here for safety. If they are ever |
C region. We set them to zero here for safety. |
109 |
C referred to, especially in the denominator then it is a mistake! |
C Note: this is now done earlier in main S/R INI_GRID |
|
DO J=1-Oly,sNy+Oly |
|
|
DO I=1-Olx,sNx+Olx |
|
|
dXC(I,J,bi,bj) = 0. |
|
|
dYC(I,J,bi,bj) = 0. |
|
|
dXV(I,J,bi,bj) = 0. |
|
|
dYU(I,J,bi,bj) = 0. |
|
|
rAw(I,J,bi,bj) = 0. |
|
|
rAs(I,J,bi,bj) = 0. |
|
|
ENDDO |
|
|
ENDDO |
|
110 |
|
|
111 |
C-- Calculate [dxC], zonal length between cell centers |
C-- Calculate [dxC], zonal length between cell centers |
112 |
DO J=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
113 |
DO I=1-Olx+1,sNx+Olx ! NOTE range |
DO i=1-OLx+1,sNx+OLx ! NOTE range |
114 |
dXC(I,J,bi,bj) = 0.5D0*(dXF(I,J,bi,bj)+dXF(I-1,J,bi,bj)) |
dxC(i,j,bi,bj) = 0.5 _d 0*(dxF(i,j,bi,bj)+dxF(i-1,j,bi,bj)) |
115 |
ENDDO |
ENDDO |
116 |
ENDDO |
ENDDO |
117 |
|
|
118 |
C-- Calculate [dyC], meridional length between cell centers |
C-- Calculate [dyC], meridional length between cell centers |
119 |
DO J=1-Oly+1,sNy+Oly ! NOTE range |
DO j=1-OLy+1,sNy+OLy ! NOTE range |
120 |
DO I=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
121 |
dYC(I,J,bi,bj) = 0.5*(dYF(I,J,bi,bj)+dYF(I,J-1,bi,bj)) |
dyC(i,j,bi,bj) = 0.5 _d 0*(dyF(i,j,bi,bj)+dyF(i,j-1,bi,bj)) |
122 |
ENDDO |
ENDDO |
123 |
ENDDO |
ENDDO |
124 |
|
|
125 |
C-- Calculate [dxV,dyU], length between velocity points (through corners) |
C-- Calculate [dxV,dyU], length between velocity points (through corners) |
126 |
DO J=1-Oly+1,sNy+Oly ! NOTE range |
DO j=1-OLy+1,sNy+OLy ! NOTE range |
127 |
DO I=1-Olx+1,sNx+Olx ! NOTE range |
DO i=1-OLx+1,sNx+OLx ! NOTE range |
128 |
C by averaging (method I) |
C by averaging (method I) |
129 |
dXV(I,J,bi,bj) = 0.5*(dXG(I,J,bi,bj)+dXG(I-1,J,bi,bj)) |
dxV(i,j,bi,bj) = 0.5 _d 0*(dxG(i,j,bi,bj)+dxG(i-1,j,bi,bj)) |
130 |
dYU(I,J,bi,bj) = 0.5*(dYG(I,J,bi,bj)+dYG(I,J-1,bi,bj)) |
dyU(i,j,bi,bj) = 0.5 _d 0*(dyG(i,j,bi,bj)+dyG(i,j-1,bi,bj)) |
131 |
C by averaging (method II) |
C by averaging (method II) |
132 |
c dXV(I,J,bi,bj) = 0.5*(dXG(I,J,bi,bj)+dXG(I-1,J,bi,bj)) |
c dxV(i,j,bi,bj) = 0.5*(dxG(i,j,bi,bj)+dxG(i-1,j,bi,bj)) |
133 |
c dYU(I,J,bi,bj) = 0.5*(dYC(I,J,bi,bj)+dYC(I-1,J,bi,bj)) |
c dyU(i,j,bi,bj) = 0.5*(dyC(i,j,bi,bj)+dyC(i-1,j,bi,bj)) |
134 |
ENDDO |
ENDDO |
135 |
ENDDO |
ENDDO |
136 |
|
|
137 |
C Calculate vertical face area |
C-- Calculate vertical face area |
138 |
DO J=1-Oly,sNy+Oly |
DO j=1-OLy,sNy+OLy |
139 |
DO I=1-Olx,sNx+Olx |
DO i=1-OLx,sNx+OLx |
140 |
rA (I,J,bi,bj) = dxF(I,J,bi,bj)*dyF(I,J,bi,bj) |
rA (i,j,bi,bj) = dxF(i,j,bi,bj)*dyF(i,j,bi,bj) |
141 |
rAw(I,J,bi,bj) = dxC(I,J,bi,bj)*dyG(I,J,bi,bj) |
rAw(i,j,bi,bj) = dxC(i,j,bi,bj)*dyG(i,j,bi,bj) |
142 |
rAs(I,J,bi,bj) = dxG(I,J,bi,bj)*dyC(I,J,bi,bj) |
rAs(i,j,bi,bj) = dxG(i,j,bi,bj)*dyC(i,j,bi,bj) |
143 |
rAz(I,J,bi,bj) = dxV(I,J,bi,bj)*dyU(I,J,bi,bj) |
rAz(i,j,bi,bj) = dxV(i,j,bi,bj)*dyU(i,j,bi,bj) |
144 |
tanPhiAtU(I,J,bi,bj) = 0. |
C-- Set trigonometric terms & grid orientation: |
145 |
tanPhiAtV(I,J,bi,bj) = 0. |
C Note: this is now done earlier in main S/R INI_GRID |
146 |
|
c tanPhiAtU(i,j,bi,bj) = 0. |
147 |
|
c tanPhiAtV(i,j,bi,bj) = 0. |
148 |
|
c angleCosC(i,j,bi,bj) = 1. |
149 |
|
c angleSinC(i,j,bi,bj) = 0. |
150 |
ENDDO |
ENDDO |
151 |
ENDDO |
ENDDO |
152 |
|
|
153 |
C-- Cosine(lat) scaling |
C-- end bi,bj loops |
154 |
DO J=1-OLy,sNy+OLy |
ENDDO |
155 |
cosFacU(J,bi,bj)=1. |
ENDDO |
|
cosFacV(J,bi,bj)=1. |
|
|
sqcosFacU(J,bi,bj)=1. |
|
|
sqcosFacV(J,bi,bj)=1. |
|
|
ENDDO |
|
|
|
|
|
ENDDO ! bi |
|
|
ENDDO ! bj |
|
156 |
|
|
157 |
RETURN |
RETURN |
158 |
END |
END |