1 | ! |
---|
2 | !====================================================================== |
---|
3 | ! ROMS_AGRIF is a branch of ROMS developped at IRD and INRIA, in France |
---|
4 | ! The two other branches from UCLA (Shchepetkin et al) |
---|
5 | ! and Rutgers University (Arango et al) are under MIT/X style license. |
---|
6 | ! ROMS_AGRIF specific routines (nesting) are under CeCILL-C license. |
---|
7 | ! |
---|
8 | ! ROMS_AGRIF website : http://roms.mpl.ird.fr |
---|
9 | !====================================================================== |
---|
10 | ! |
---|
11 | #include "cppdefs.h" |
---|
12 | ! Setting up curvilinear |
---|
13 | subroutine setup_grid1 (tile) ! grid: Compute various |
---|
14 | implicit none ! combinations of metric |
---|
15 | integer tile, trd ! terms. |
---|
16 | #include "param.h" |
---|
17 | C$ integer omp_get_thread_num |
---|
18 | #include "compute_tile_bounds.h" |
---|
19 | call setup_grid1_tile (Istr,Iend,Jstr,Jend) |
---|
20 | return |
---|
21 | end |
---|
22 | |
---|
23 | subroutine setup_grid1_tile (Istr,Iend,Jstr,Jend) |
---|
24 | implicit none |
---|
25 | integer Istr,Iend,Jstr,Jend, i,j |
---|
26 | #include "param.h" |
---|
27 | #include "scalars.h" |
---|
28 | #include "grid.h" |
---|
29 | ! |
---|
30 | #include "compute_extended_bounds.h" |
---|
31 | ! |
---|
32 | ! Set f/mn,at horizontal RHO-points. |
---|
33 | ! |
---|
34 | |
---|
35 | do j=JstrR,JendR ! This array |
---|
36 | do i=IstrR,IendR ! is NOT to be |
---|
37 | fomn(i,j)=f(i,j)/(pm(i,j)*pn(i,j)) ! communicated |
---|
38 | enddo ! in MPI code; |
---|
39 | enddo ! others are... |
---|
40 | |
---|
41 | #ifdef EW_PERIODIC |
---|
42 | # define IR_RANGE IstrR,IendR |
---|
43 | # define IU_RANGE Istr,IendR |
---|
44 | #else |
---|
45 | # define IR_RANGE IstrR,IendR |
---|
46 | # define IU_RANGE Istr,IendR |
---|
47 | # ifdef MPI |
---|
48 | ! Ghost points along |
---|
49 | if (WEST_INTER) IstrR=Istr ! computational boundary |
---|
50 | if (EAST_INTER) IendR=Iend ! are filled during |
---|
51 | ! subsequent communication; |
---|
52 | ! see also below... |
---|
53 | # endif |
---|
54 | #endif |
---|
55 | #ifdef NS_PERIODIC |
---|
56 | # define JR_RANGE Jstr,Jend |
---|
57 | # define JV_RANGE Jstr,Jend |
---|
58 | #else |
---|
59 | # define JR_RANGE JstrR,JendR |
---|
60 | # define JV_RANGE Jstr,JendR |
---|
61 | # ifdef MPI |
---|
62 | if (SOUTH_INTER) JstrR=Jstr ! same as above. |
---|
63 | if (NORTH_INTER) JendR=Jend ! |
---|
64 | # endif |
---|
65 | #endif |
---|
66 | ! |
---|
67 | ! Compute 1/n, 1/m, n/m and m/n all at horizontal RHO-points. |
---|
68 | ! |
---|
69 | do j=JR_RANGE |
---|
70 | do i=IR_RANGE |
---|
71 | om_r(i,j)=1./pm(i,j) |
---|
72 | on_r(i,j)=1./pn(i,j) |
---|
73 | pnom_r(i,j)=pn(i,j)/pm(i,j) |
---|
74 | pmon_r(i,j)=pm(i,j)/pn(i,j) |
---|
75 | enddo |
---|
76 | enddo |
---|
77 | |
---|
78 | #if (defined CURVGRID && defined UV_ADV) |
---|
79 | ! |
---|
80 | ! Compute d(1/n)/d(xi) and d(1/m)/d(eta) tems, both at RHO-points. |
---|
81 | ! |
---|
82 | do j=Jstr,Jend |
---|
83 | do i=Istr,Iend |
---|
84 | dndx(i,j)=0.5/pn(i+1,j)-0.5/pn(i-1,j) |
---|
85 | dmde(i,j)=0.5/pm(i,j+1)-0.5/pm(i,j-1) |
---|
86 | enddo |
---|
87 | enddo |
---|
88 | |
---|
89 | #endif |
---|
90 | ! |
---|
91 | ! Compute m/n at horizontal U-points. |
---|
92 | ! |
---|
93 | do j=JR_RANGE |
---|
94 | do i=IU_RANGE |
---|
95 | pmon_u(i,j)=(pm(i,j)+pm(i-1,j)) |
---|
96 | & /(pn(i,j)+pn(i-1,j)) |
---|
97 | om_u(i,j)=2./(pm(i,j)+pm(i-1,j)) |
---|
98 | on_u(i,j)=2./(pn(i,j)+pn(i-1,j)) |
---|
99 | pn_u(i,j)=0.5*(pn(i,j)+pn(i-1,j)) |
---|
100 | pm_u(i,j)=0.5*(pm(i,j)+pm(i-1,j)) |
---|
101 | #ifdef MASKING |
---|
102 | umask(i,j)=rmask(i,j)*rmask(i-1,j) |
---|
103 | #endif |
---|
104 | enddo |
---|
105 | enddo |
---|
106 | ! |
---|
107 | ! Compute n/m at horizontal V-points. |
---|
108 | ! |
---|
109 | do j=JV_RANGE |
---|
110 | do i=IR_RANGE |
---|
111 | pnom_v(i,j)=(pn(i,j)+pn(i,j-1)) |
---|
112 | & /(pm(i,j)+pm(i,j-1)) |
---|
113 | om_v(i,j)=2./(pm(i,j)+pm(i,j-1)) |
---|
114 | on_v(i,j)=2./(pn(i,j)+pn(i,j-1)) |
---|
115 | pm_v(i,j)=0.5*(pm(i,j)+pm(i,j-1)) |
---|
116 | pn_v(i,j)=0.5*(pn(i,j)+pn(i,j-1)) |
---|
117 | #ifdef MASKING |
---|
118 | vmask(i,j)=rmask(i,j)*rmask(i,j-1) |
---|
119 | #endif |
---|
120 | enddo |
---|
121 | enddo |
---|
122 | ! |
---|
123 | ! Compute n/m and m/n at horizontal PSI-points. |
---|
124 | ! Set mask according to slipperness parameter gamma. |
---|
125 | ! |
---|
126 | do j=JV_RANGE |
---|
127 | do i=IU_RANGE |
---|
128 | pnom_p(i,j)=(pn(i,j)+pn(i,j-1)+pn(i-1,j)+pn(i-1,j-1)) |
---|
129 | & /(pm(i,j)+pm(i,j-1)+pm(i-1,j)+pm(i-1,j-1)) |
---|
130 | pmon_p(i,j)=(pm(i,j)+pm(i,j-1)+pm(i-1,j)+pm(i-1,j-1)) |
---|
131 | & /(pn(i,j)+pn(i,j-1)+pn(i-1,j)+pn(i-1,j-1)) |
---|
132 | om_p(i,j)=4./(pm(i-1,j-1)+pm(i-1,j)+pm(i,j-1)+pm(i,j)) |
---|
133 | on_p(i,j)=4./(pn(i-1,j-1)+pn(i-1,j)+pn(i,j-1)+pn(i,j)) |
---|
134 | #ifdef MASKING |
---|
135 | pmask(i,j)=rmask(i,j)*rmask(i-1,j)*rmask(i,j-1) |
---|
136 | & *rmask(i-1,j-1) |
---|
137 | if (gamma2.lt.0.) pmask(i,j)=2.-pmask(i,j) |
---|
138 | #endif |
---|
139 | enddo |
---|
140 | enddo |
---|
141 | |
---|
142 | #undef IR_RANGE |
---|
143 | #undef IU_RANGE |
---|
144 | #undef JR_RANGE |
---|
145 | #undef JV_RANGE |
---|
146 | |
---|
147 | #if defined EW_PERIODIC || defined NS_PERIODIC || defined MPI |
---|
148 | call exchange_r2d_tile (Istr,Iend,Jstr,Jend, om_r) |
---|
149 | call exchange_r2d_tile (Istr,Iend,Jstr,Jend, on_r) |
---|
150 | call exchange_r2d_tile (Istr,Iend,Jstr,Jend, pnom_r) |
---|
151 | call exchange_r2d_tile (Istr,Iend,Jstr,Jend, pmon_r) |
---|
152 | # if defined CURVGRID && defined UV_ADV |
---|
153 | call exchange_r2d_tile (Istr,Iend,Jstr,Jend, dndx) |
---|
154 | call exchange_r2d_tile (Istr,Iend,Jstr,Jend, dmde) |
---|
155 | # endif |
---|
156 | call exchange_u2d_tile (Istr,Iend,Jstr,Jend, pmon_u) |
---|
157 | call exchange_u2d_tile (Istr,Iend,Jstr,Jend, om_u) |
---|
158 | call exchange_u2d_tile (Istr,Iend,Jstr,Jend, on_u) |
---|
159 | call exchange_u2d_tile (Istr,Iend,Jstr,Jend, pn_u) |
---|
160 | call exchange_u2d_tile (Istr,Iend,Jstr,Jend, pm_u) |
---|
161 | |
---|
162 | call exchange_v2d_tile (Istr,Iend,Jstr,Jend, pnom_v) |
---|
163 | call exchange_v2d_tile (Istr,Iend,Jstr,Jend, om_v) |
---|
164 | call exchange_v2d_tile (Istr,Iend,Jstr,Jend, on_v) |
---|
165 | call exchange_v2d_tile (Istr,Iend,Jstr,Jend, pm_v) |
---|
166 | call exchange_v2d_tile (Istr,Iend,Jstr,Jend, pn_v) |
---|
167 | |
---|
168 | call exchange_p2d_tile (Istr,Iend,Jstr,Jend, pnom_p) |
---|
169 | call exchange_p2d_tile (Istr,Iend,Jstr,Jend, pmon_p) |
---|
170 | call exchange_p2d_tile (Istr,Iend,Jstr,Jend, om_p) |
---|
171 | call exchange_p2d_tile (Istr,Iend,Jstr,Jend, on_p) |
---|
172 | # ifdef MASKING |
---|
173 | call exchange_r2d_tile (Istr,Iend,Jstr,Jend, rmask) |
---|
174 | call exchange_u2d_tile (Istr,Iend,Jstr,Jend, umask) |
---|
175 | call exchange_v2d_tile (Istr,Iend,Jstr,Jend, vmask) |
---|
176 | call exchange_p2d_tile (Istr,Iend,Jstr,Jend, pmask) |
---|
177 | # endif |
---|
178 | #endif |
---|
179 | return |
---|
180 | end |
---|
181 | |
---|