1 |
C $Header: /u/gcmpack/MITgcm/model/src/ini_masks_etc.F,v 1.31 2006/02/07 11:47:48 mlosch Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: INI_MASKS_ETC |
9 |
C !INTERFACE: |
10 |
SUBROUTINE INI_MASKS_ETC( myThid ) |
11 |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
13 |
C | SUBROUTINE INI_MASKS_ETC |
14 |
C | o Initialise masks and topography factors |
15 |
C *==========================================================* |
16 |
C | These arrays are used throughout the code and describe |
17 |
C | the topography of the domain through masks (0s and 1s) |
18 |
C | and fractional height factors (0<hFac<1). The latter |
19 |
C | distinguish between the lopped-cell and full-step |
20 |
C | topographic representations. |
21 |
C *==========================================================* |
22 |
C \ev |
23 |
|
24 |
C !USES: |
25 |
IMPLICIT NONE |
26 |
C === Global variables === |
27 |
#include "SIZE.h" |
28 |
#include "EEPARAMS.h" |
29 |
#include "PARAMS.h" |
30 |
#include "GRID.h" |
31 |
#include "SURFACE.h" |
32 |
#ifdef ALLOW_SHELFICE |
33 |
# include "SHELFICE.h" |
34 |
#endif /* ALLOW_SHELFICE */ |
35 |
|
36 |
C !INPUT/OUTPUT PARAMETERS: |
37 |
C == Routine arguments == |
38 |
C myThid :: Number of this instance of INI_MASKS_ETC |
39 |
INTEGER myThid |
40 |
|
41 |
C !LOCAL VARIABLES: |
42 |
C == Local variables == |
43 |
C bi,bj :: tile indices |
44 |
C I,J,K :: Loop counters |
45 |
C tmpfld :: Temporary array used to compute & write Total Depth |
46 |
_RS tmpfld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
47 |
INTEGER bi, bj |
48 |
INTEGER I, J, K |
49 |
_RL hFacCtmp |
50 |
_RL hFacMnSz |
51 |
_RL tileArea |
52 |
CEOP |
53 |
|
54 |
C- Calculate lopping factor hFacC : over-estimate the part inside of the domain |
55 |
C taking into account the lower_R Boundary (Bathymetrie / Top of Atmos) |
56 |
DO bj=myByLo(myThid), myByHi(myThid) |
57 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
58 |
DO K=1, Nr |
59 |
hFacMnSz=max( hFacMin, min(hFacMinDr*recip_drF(k),1. _d 0) ) |
60 |
DO J=1-Oly,sNy+Oly |
61 |
DO I=1-Olx,sNx+Olx |
62 |
C o Non-dimensional distance between grid bound. and domain lower_R bound. |
63 |
hFacCtmp = (rF(K)-R_low(I,J,bi,bj))*recip_drF(K) |
64 |
C o Select between, closed, open or partial (0,1,0-1) |
65 |
hFacCtmp=min( max( hFacCtmp, 0. _d 0) , 1. _d 0) |
66 |
C o Impose minimum fraction and/or size (dimensional) |
67 |
IF (hFacCtmp.LT.hFacMnSz) THEN |
68 |
IF (hFacCtmp.LT.hFacMnSz*0.5) THEN |
69 |
hFacC(I,J,K,bi,bj)=0. |
70 |
ELSE |
71 |
hFacC(I,J,K,bi,bj)=hFacMnSz |
72 |
ENDIF |
73 |
ELSE |
74 |
hFacC(I,J,K,bi,bj)=hFacCtmp |
75 |
ENDIF |
76 |
ENDDO |
77 |
ENDDO |
78 |
ENDDO |
79 |
|
80 |
C- Re-calculate lower-R Boundary position, taking into account hFacC |
81 |
DO J=1-Oly,sNy+Oly |
82 |
DO I=1-Olx,sNx+Olx |
83 |
R_low(I,J,bi,bj) = rF(1) |
84 |
DO K=Nr,1,-1 |
85 |
R_low(I,J,bi,bj) = R_low(I,J,bi,bj) |
86 |
& - drF(k)*hFacC(I,J,K,bi,bj) |
87 |
ENDDO |
88 |
ENDDO |
89 |
ENDDO |
90 |
C - end bi,bj loops. |
91 |
ENDDO |
92 |
ENDDO |
93 |
|
94 |
C- Calculate lopping factor hFacC : Remove part outside of the domain |
95 |
C taking into account the Reference (=at rest) Surface Position Ro_surf |
96 |
DO bj=myByLo(myThid), myByHi(myThid) |
97 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
98 |
DO K=1, Nr |
99 |
hFacMnSz=max( hFacMin, min(hFacMinDr*recip_drF(k),1. _d 0) ) |
100 |
DO J=1-Oly,sNy+Oly |
101 |
DO I=1-Olx,sNx+Olx |
102 |
C o Non-dimensional distance between grid boundary and model surface |
103 |
hFacCtmp = (rF(k)-Ro_surf(I,J,bi,bj))*recip_drF(K) |
104 |
C o Reduce the previous fraction : substract the outside part. |
105 |
hFacCtmp = hFacC(I,J,K,bi,bj) - max( hFacCtmp, 0. _d 0) |
106 |
C o set to zero if empty Column : |
107 |
hFacCtmp = max( hFacCtmp, 0. _d 0) |
108 |
C o Impose minimum fraction and/or size (dimensional) |
109 |
IF (hFacCtmp.LT.hFacMnSz) THEN |
110 |
IF (hFacCtmp.LT.hFacMnSz*0.5) THEN |
111 |
hFacC(I,J,K,bi,bj)=0. |
112 |
ELSE |
113 |
hFacC(I,J,K,bi,bj)=hFacMnSz |
114 |
ENDIF |
115 |
ELSE |
116 |
hFacC(I,J,K,bi,bj)=hFacCtmp |
117 |
ENDIF |
118 |
ENDDO |
119 |
ENDDO |
120 |
ENDDO |
121 |
|
122 |
#ifdef ALLOW_SHELFICE |
123 |
C-- compute contributions of shelf ice to looping factors |
124 |
IF ( useShelfIce ) THEN |
125 |
DO K=1, Nr |
126 |
hFacMnSz=max( hFacMin, min(hFacMinDr*recip_drF(k),1. _d 0) ) |
127 |
DO J=1-Oly,sNy+Oly |
128 |
DO I=1-Olx,sNx+Olx |
129 |
C o Non-dimensional distance between grid boundary and model surface |
130 |
hFacCtmp = (rF(k)-R_shelfIce(I,J,bi,bj))*recip_drF(K) |
131 |
C o Reduce the previous fraction : substract the outside part. |
132 |
hFacCtmp = hFacC(I,J,K,bi,bj) - max( hFacCtmp, 0. _d 0) |
133 |
C o set to zero if empty Column : |
134 |
hFacCtmp = max( hFacCtmp, 0. _d 0) |
135 |
C o Impose minimum fraction and/or size (dimensional) |
136 |
IF (hFacCtmp.LT.hFacMnSz) THEN |
137 |
IF (hFacCtmp.LT.hFacMnSz*0.5) THEN |
138 |
hFacC(I,J,K,bi,bj)=0. |
139 |
ELSE |
140 |
hFacC(I,J,K,bi,bj)=hFacMnSz |
141 |
ENDIF |
142 |
ELSE |
143 |
hFacC(I,J,K,bi,bj)=hFacCtmp |
144 |
ENDIF |
145 |
ENDDO |
146 |
ENDDO |
147 |
ENDDO |
148 |
ENDIF |
149 |
#endif /* ALLOW_SHELFICE */ |
150 |
|
151 |
C- Re-calculate Reference surface position, taking into account hFacC |
152 |
C initialize Total column fluid thickness and surface k index |
153 |
C Note: if no fluid (continent) ==> ksurf = Nr+1 |
154 |
DO J=1-Oly,sNy+Oly |
155 |
DO I=1-Olx,sNx+Olx |
156 |
tmpfld(I,J,bi,bj) = 0. |
157 |
ksurfC(I,J,bi,bj) = Nr+1 |
158 |
maskH(I,J,bi,bj) = 0. |
159 |
Ro_surf(I,J,bi,bj) = R_low(I,J,bi,bj) |
160 |
DO K=Nr,1,-1 |
161 |
Ro_surf(I,J,bi,bj) = Ro_surf(I,J,bi,bj) |
162 |
& + drF(k)*hFacC(I,J,K,bi,bj) |
163 |
IF (hFacC(I,J,K,bi,bj).NE.0.) THEN |
164 |
ksurfC(I,J,bi,bj) = k |
165 |
maskH(I,J,bi,bj) = 1. |
166 |
tmpfld(I,J,bi,bj) = tmpfld(I,J,bi,bj) + 1. |
167 |
ENDIF |
168 |
ENDDO |
169 |
kLowC(I,J,bi,bj) = 0 |
170 |
DO K= 1, Nr |
171 |
IF (hFacC(I,J,K,bi,bj).NE.0) THEN |
172 |
kLowC(I,J,bi,bj) = K |
173 |
ENDIF |
174 |
ENDDO |
175 |
ENDDO |
176 |
ENDDO |
177 |
C - end bi,bj loops. |
178 |
ENDDO |
179 |
ENDDO |
180 |
|
181 |
C CALL PLOT_FIELD_XYRS( tmpfld, |
182 |
C & 'Model Depths K Index' , 1, myThid ) |
183 |
CALL PLOT_FIELD_XYRS(R_low, |
184 |
& 'Model R_low (ini_masks_etc)', 1, myThid) |
185 |
CALL PLOT_FIELD_XYRS(Ro_surf, |
186 |
& 'Model Ro_surf (ini_masks_etc)', 1, myThid) |
187 |
|
188 |
C Calculate quantities derived from XY depth map |
189 |
globalArea = 0. _d 0 |
190 |
DO bj = myByLo(myThid), myByHi(myThid) |
191 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
192 |
DO j=1-Oly,sNy+Oly |
193 |
DO i=1-Olx,sNx+Olx |
194 |
C Total fluid column thickness (r_unit) : |
195 |
c Rcolumn(i,j,bi,bj)= Ro_surf(i,j,bi,bj) - R_low(i,j,bi,bj) |
196 |
tmpfld(i,j,bi,bj) = Ro_surf(i,j,bi,bj) - R_low(i,j,bi,bj) |
197 |
C Inverse of fluid column thickness (1/r_unit) |
198 |
IF ( tmpfld(i,j,bi,bj) .LE. 0. ) THEN |
199 |
recip_Rcol(i,j,bi,bj) = 0. |
200 |
ELSE |
201 |
recip_Rcol(i,j,bi,bj) = 1. _d 0 / tmpfld(i,j,bi,bj) |
202 |
ENDIF |
203 |
ENDDO |
204 |
ENDDO |
205 |
C- Compute the domain Area: |
206 |
tileArea = 0. _d 0 |
207 |
DO j=1,sNy |
208 |
DO i=1,sNx |
209 |
tileArea = tileArea + rA(i,j,bi,bj)*maskH(i,j,bi,bj) |
210 |
ENDDO |
211 |
ENDDO |
212 |
globalArea = globalArea + tileArea |
213 |
ENDDO |
214 |
ENDDO |
215 |
C _EXCH_XY_R4( recip_Rcol, myThid ) |
216 |
_GLOBAL_SUM_R8( globalArea, myThid ) |
217 |
|
218 |
C hFacW and hFacS (at U and V points) |
219 |
DO bj=myByLo(myThid), myByHi(myThid) |
220 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
221 |
DO K=1, Nr |
222 |
DO J=1-Oly,sNy+Oly |
223 |
DO I=2-Olx,sNx+Olx |
224 |
hFacW(I,J,K,bi,bj)= |
225 |
& MIN(hFacC(I,J,K,bi,bj),hFacC(I-1,J,K,bi,bj)) |
226 |
ENDDO |
227 |
ENDDO |
228 |
DO J=2-Oly,sNy+oly |
229 |
DO I=1-Olx,sNx+Olx |
230 |
hFacS(I,J,K,bi,bj)= |
231 |
& MIN(hFacC(I,J,K,bi,bj),hFacC(I,J-1,K,bi,bj)) |
232 |
ENDDO |
233 |
ENDDO |
234 |
ENDDO |
235 |
ENDDO |
236 |
ENDDO |
237 |
CALL EXCH_UV_XYZ_RS(hFacW,hFacS,.FALSE.,myThid) |
238 |
C The following block allows thin walls representation of non-periodic |
239 |
C boundaries such as happen on the lat-lon grid at the N/S poles. |
240 |
C We should really supply a flag for doing this. |
241 |
DO bj=myByLo(myThid), myByHi(myThid) |
242 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
243 |
DO K=1, Nr |
244 |
DO J=1-Oly,sNy+Oly |
245 |
DO I=1-Olx,sNx+Olx |
246 |
IF (DYG(I,J,bi,bj).EQ.0.) hFacW(I,J,K,bi,bj)=0. |
247 |
IF (DXG(I,J,bi,bj).EQ.0.) hFacS(I,J,K,bi,bj)=0. |
248 |
ENDDO |
249 |
ENDDO |
250 |
ENDDO |
251 |
ENDDO |
252 |
ENDDO |
253 |
|
254 |
C- Write to disk: Total Column Thickness & hFac(C,W,S): |
255 |
_BARRIER |
256 |
c _BEGIN_MASTER( myThid ) |
257 |
C This I/O is now done in write_grid.F |
258 |
C CALL MDSWRITEFIELD( 'Depth', writeBinaryPrec, .TRUE., |
259 |
C & 'RS', 1, tmpfld, 1, -1, myThid ) |
260 |
c CALL WRITE_FLD_XY_RS( 'Depth',' ',tmpfld,0,myThid) |
261 |
c CALL WRITE_FLD_XYZ_RS( 'hFacC',' ',hFacC,0,myThid) |
262 |
c CALL WRITE_FLD_XYZ_RS( 'hFacW',' ',hFacW,0,myThid) |
263 |
c CALL WRITE_FLD_XYZ_RS( 'hFacS',' ',hFacS,0,myThid) |
264 |
c _END_MASTER(myThid) |
265 |
|
266 |
CALL PLOT_FIELD_XYZRS( hFacC, 'hFacC' , Nr, 1, myThid ) |
267 |
CALL PLOT_FIELD_XYZRS( hFacW, 'hFacW' , Nr, 1, myThid ) |
268 |
CALL PLOT_FIELD_XYZRS( hFacS, 'hFacS' , Nr, 1, myThid ) |
269 |
|
270 |
C Masks and reciprocals of hFac[CWS] |
271 |
DO bj = myByLo(myThid), myByHi(myThid) |
272 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
273 |
DO K=1,Nr |
274 |
DO J=1-Oly,sNy+Oly |
275 |
DO I=1-Olx,sNx+Olx |
276 |
IF (hFacC(I,J,K,bi,bj) .NE. 0. ) THEN |
277 |
recip_hFacC(I,J,K,bi,bj) = 1. _d 0 / hFacC(I,J,K,bi,bj) |
278 |
maskC(I,J,K,bi,bj) = 1. |
279 |
ELSE |
280 |
recip_hFacC(I,J,K,bi,bj) = 0. |
281 |
maskC(I,J,K,bi,bj) = 0. |
282 |
ENDIF |
283 |
IF (hFacW(I,J,K,bi,bj) .NE. 0. ) THEN |
284 |
recip_hFacW(I,J,K,bi,bj) = 1. _d 0 / hFacW(I,J,K,bi,bj) |
285 |
maskW(I,J,K,bi,bj) = 1. |
286 |
ELSE |
287 |
recip_hFacW(I,J,K,bi,bj) = 0. |
288 |
maskW(I,J,K,bi,bj) = 0. |
289 |
ENDIF |
290 |
IF (hFacS(I,J,K,bi,bj) .NE. 0. ) THEN |
291 |
recip_hFacS(I,J,K,bi,bj) = 1. _d 0 / hFacS(I,J,K,bi,bj) |
292 |
maskS(I,J,K,bi,bj) = 1. |
293 |
ELSE |
294 |
recip_hFacS(I,J,K,bi,bj) = 0. |
295 |
maskS(I,J,K,bi,bj) = 0. |
296 |
ENDIF |
297 |
ENDDO |
298 |
ENDDO |
299 |
ENDDO |
300 |
C- Calculate surface k index for interface W & S (U & V points) |
301 |
DO J=1-Oly,sNy+Oly |
302 |
DO I=1-Olx,sNx+Olx |
303 |
ksurfW(I,J,bi,bj) = Nr+1 |
304 |
ksurfS(I,J,bi,bj) = Nr+1 |
305 |
DO k=Nr,1,-1 |
306 |
IF (hFacW(I,J,K,bi,bj).NE.0.) ksurfW(I,J,bi,bj) = k |
307 |
IF (hFacS(I,J,K,bi,bj).NE.0.) ksurfS(I,J,bi,bj) = k |
308 |
ENDDO |
309 |
ENDDO |
310 |
ENDDO |
311 |
C - end bi,bj loops. |
312 |
ENDDO |
313 |
ENDDO |
314 |
|
315 |
C Calculate recipricols grid lengths |
316 |
DO bj = myByLo(myThid), myByHi(myThid) |
317 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
318 |
DO J=1-Oly,sNy+Oly |
319 |
DO I=1-Olx,sNx+Olx |
320 |
IF ( dxG(I,J,bi,bj) .NE. 0. ) |
321 |
& recip_dxG(I,J,bi,bj)=1. _d 0/dxG(I,J,bi,bj) |
322 |
IF ( dyG(I,J,bi,bj) .NE. 0. ) |
323 |
& recip_dyG(I,J,bi,bj)=1. _d 0/dyG(I,J,bi,bj) |
324 |
IF ( dxC(I,J,bi,bj) .NE. 0. ) |
325 |
& recip_dxC(I,J,bi,bj)=1. _d 0/dxC(I,J,bi,bj) |
326 |
IF ( dyC(I,J,bi,bj) .NE. 0. ) |
327 |
& recip_dyC(I,J,bi,bj)=1. _d 0/dyC(I,J,bi,bj) |
328 |
IF ( dxF(I,J,bi,bj) .NE. 0. ) |
329 |
& recip_dxF(I,J,bi,bj)=1. _d 0/dxF(I,J,bi,bj) |
330 |
IF ( dyF(I,J,bi,bj) .NE. 0. ) |
331 |
& recip_dyF(I,J,bi,bj)=1. _d 0/dyF(I,J,bi,bj) |
332 |
IF ( dxV(I,J,bi,bj) .NE. 0. ) |
333 |
& recip_dxV(I,J,bi,bj)=1. _d 0/dxV(I,J,bi,bj) |
334 |
IF ( dyU(I,J,bi,bj) .NE. 0. ) |
335 |
& recip_dyU(I,J,bi,bj)=1. _d 0/dyU(I,J,bi,bj) |
336 |
IF ( rA(I,J,bi,bj) .NE. 0. ) |
337 |
& recip_rA(I,J,bi,bj)=1. _d 0/rA(I,J,bi,bj) |
338 |
IF ( rAs(I,J,bi,bj) .NE. 0. ) |
339 |
& recip_rAs(I,J,bi,bj)=1. _d 0/rAs(I,J,bi,bj) |
340 |
IF ( rAw(I,J,bi,bj) .NE. 0. ) |
341 |
& recip_rAw(I,J,bi,bj)=1. _d 0/rAw(I,J,bi,bj) |
342 |
IF ( rAz(I,J,bi,bj) .NE. 0. ) |
343 |
& recip_rAz(I,J,bi,bj)=1. _d 0/rAz(I,J,bi,bj) |
344 |
ENDDO |
345 |
ENDDO |
346 |
ENDDO |
347 |
ENDDO |
348 |
|
349 |
c #ifdef ALLOW_NONHYDROSTATIC |
350 |
C-- Calculate "recip_hFacU" = reciprocal hfac distance/volume for W cells |
351 |
C not used ; computed locally in CALC_GW |
352 |
c #endif |
353 |
|
354 |
RETURN |
355 |
END |