/[MITgcm]/MITgcm/model/src/ini_masks_etc.F
ViewVC logotype

Contents of /MITgcm/model/src/ini_masks_etc.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.33 - (show annotations) (download)
Wed Jul 26 22:01:57 2006 UTC (17 years, 9 months ago) by jmc
Branch: MAIN
Changes since 1.32: +6 -2 lines
set hFacW & hFacS everywhere (in case EXCH does not fill corner-halo region)

1 C $Header: /u/gcmpack/MITgcm/model/src/ini_masks_etc.F,v 1.32 2006/07/23 23:32:33 jmc 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 hFacW(1-OLx,J,K,bi,bj)= 0.
224 DO I=2-Olx,sNx+Olx
225 hFacW(I,J,K,bi,bj)=
226 & MIN(hFacC(I,J,K,bi,bj),hFacC(I-1,J,K,bi,bj))
227 ENDDO
228 ENDDO
229 DO I=1-Olx,sNx+Olx
230 hFacS(I,1-OLy,K,bi,bj)= 0.
231 ENDDO
232 DO J=2-Oly,sNy+oly
233 DO I=1-Olx,sNx+Olx
234 hFacS(I,J,K,bi,bj)=
235 & MIN(hFacC(I,J,K,bi,bj),hFacC(I,J-1,K,bi,bj))
236 ENDDO
237 ENDDO
238 ENDDO
239 ENDDO
240 ENDDO
241 CALL EXCH_UV_XYZ_RS(hFacW,hFacS,.FALSE.,myThid)
242 C The following block allows thin walls representation of non-periodic
243 C boundaries such as happen on the lat-lon grid at the N/S poles.
244 C We should really supply a flag for doing this.
245 DO bj=myByLo(myThid), myByHi(myThid)
246 DO bi=myBxLo(myThid), myBxHi(myThid)
247 DO K=1, Nr
248 DO J=1-Oly,sNy+Oly
249 DO I=1-Olx,sNx+Olx
250 IF (DYG(I,J,bi,bj).EQ.0.) hFacW(I,J,K,bi,bj)=0.
251 IF (DXG(I,J,bi,bj).EQ.0.) hFacS(I,J,K,bi,bj)=0.
252 ENDDO
253 ENDDO
254 ENDDO
255 ENDDO
256 ENDDO
257
258 C- Write to disk: Total Column Thickness & hFac(C,W,S):
259 _BARRIER
260 c _BEGIN_MASTER( myThid )
261 C This I/O is now done in write_grid.F
262 C CALL MDSWRITEFIELD( 'Depth', writeBinaryPrec, .TRUE.,
263 C & 'RS', 1, tmpfld, 1, -1, myThid )
264 c CALL WRITE_FLD_XY_RS( 'Depth',' ',tmpfld,0,myThid)
265 c CALL WRITE_FLD_XYZ_RS( 'hFacC',' ',hFacC,0,myThid)
266 c CALL WRITE_FLD_XYZ_RS( 'hFacW',' ',hFacW,0,myThid)
267 c CALL WRITE_FLD_XYZ_RS( 'hFacS',' ',hFacS,0,myThid)
268 c _END_MASTER(myThid)
269
270 CALL PLOT_FIELD_XYZRS( hFacC, 'hFacC' , Nr, 1, myThid )
271 CALL PLOT_FIELD_XYZRS( hFacW, 'hFacW' , Nr, 1, myThid )
272 CALL PLOT_FIELD_XYZRS( hFacS, 'hFacS' , Nr, 1, myThid )
273
274 C Masks and reciprocals of hFac[CWS]
275 DO bj = myByLo(myThid), myByHi(myThid)
276 DO bi = myBxLo(myThid), myBxHi(myThid)
277 DO K=1,Nr
278 DO J=1-Oly,sNy+Oly
279 DO I=1-Olx,sNx+Olx
280 IF (hFacC(I,J,K,bi,bj) .NE. 0. ) THEN
281 recip_hFacC(I,J,K,bi,bj) = 1. _d 0 / hFacC(I,J,K,bi,bj)
282 maskC(I,J,K,bi,bj) = 1.
283 ELSE
284 recip_hFacC(I,J,K,bi,bj) = 0.
285 maskC(I,J,K,bi,bj) = 0.
286 ENDIF
287 IF (hFacW(I,J,K,bi,bj) .NE. 0. ) THEN
288 recip_hFacW(I,J,K,bi,bj) = 1. _d 0 / hFacW(I,J,K,bi,bj)
289 maskW(I,J,K,bi,bj) = 1.
290 ELSE
291 recip_hFacW(I,J,K,bi,bj) = 0.
292 maskW(I,J,K,bi,bj) = 0.
293 ENDIF
294 IF (hFacS(I,J,K,bi,bj) .NE. 0. ) THEN
295 recip_hFacS(I,J,K,bi,bj) = 1. _d 0 / hFacS(I,J,K,bi,bj)
296 maskS(I,J,K,bi,bj) = 1.
297 ELSE
298 recip_hFacS(I,J,K,bi,bj) = 0.
299 maskS(I,J,K,bi,bj) = 0.
300 ENDIF
301 ENDDO
302 ENDDO
303 ENDDO
304 C- Calculate surface k index for interface W & S (U & V points)
305 DO J=1-Oly,sNy+Oly
306 DO I=1-Olx,sNx+Olx
307 ksurfW(I,J,bi,bj) = Nr+1
308 ksurfS(I,J,bi,bj) = Nr+1
309 DO k=Nr,1,-1
310 IF (hFacW(I,J,K,bi,bj).NE.0.) ksurfW(I,J,bi,bj) = k
311 IF (hFacS(I,J,K,bi,bj).NE.0.) ksurfS(I,J,bi,bj) = k
312 ENDDO
313 ENDDO
314 ENDDO
315 C - end bi,bj loops.
316 ENDDO
317 ENDDO
318
319 C Calculate recipricols grid lengths
320 DO bj = myByLo(myThid), myByHi(myThid)
321 DO bi = myBxLo(myThid), myBxHi(myThid)
322 DO J=1-Oly,sNy+Oly
323 DO I=1-Olx,sNx+Olx
324 IF ( dxG(I,J,bi,bj) .NE. 0. )
325 & recip_dxG(I,J,bi,bj)=1. _d 0/dxG(I,J,bi,bj)
326 IF ( dyG(I,J,bi,bj) .NE. 0. )
327 & recip_dyG(I,J,bi,bj)=1. _d 0/dyG(I,J,bi,bj)
328 IF ( dxC(I,J,bi,bj) .NE. 0. )
329 & recip_dxC(I,J,bi,bj)=1. _d 0/dxC(I,J,bi,bj)
330 IF ( dyC(I,J,bi,bj) .NE. 0. )
331 & recip_dyC(I,J,bi,bj)=1. _d 0/dyC(I,J,bi,bj)
332 IF ( dxF(I,J,bi,bj) .NE. 0. )
333 & recip_dxF(I,J,bi,bj)=1. _d 0/dxF(I,J,bi,bj)
334 IF ( dyF(I,J,bi,bj) .NE. 0. )
335 & recip_dyF(I,J,bi,bj)=1. _d 0/dyF(I,J,bi,bj)
336 IF ( dxV(I,J,bi,bj) .NE. 0. )
337 & recip_dxV(I,J,bi,bj)=1. _d 0/dxV(I,J,bi,bj)
338 IF ( dyU(I,J,bi,bj) .NE. 0. )
339 & recip_dyU(I,J,bi,bj)=1. _d 0/dyU(I,J,bi,bj)
340 IF ( rA(I,J,bi,bj) .NE. 0. )
341 & recip_rA(I,J,bi,bj)=1. _d 0/rA(I,J,bi,bj)
342 IF ( rAs(I,J,bi,bj) .NE. 0. )
343 & recip_rAs(I,J,bi,bj)=1. _d 0/rAs(I,J,bi,bj)
344 IF ( rAw(I,J,bi,bj) .NE. 0. )
345 & recip_rAw(I,J,bi,bj)=1. _d 0/rAw(I,J,bi,bj)
346 IF ( rAz(I,J,bi,bj) .NE. 0. )
347 & recip_rAz(I,J,bi,bj)=1. _d 0/rAz(I,J,bi,bj)
348 ENDDO
349 ENDDO
350 ENDDO
351 ENDDO
352
353 c #ifdef ALLOW_NONHYDROSTATIC
354 C-- Calculate "recip_hFacU" = reciprocal hfac distance/volume for W cells
355 C NOTE: not used ; computed locally in CALC_GW
356 c #endif
357
358 RETURN
359 END

  ViewVC Help
Powered by ViewVC 1.1.22