/[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.38 - (show annotations) (download)
Fri Sep 12 07:26:42 2008 UTC (15 years, 8 months ago) by mlosch
Branch: MAIN
CVS Tags: checkpoint61f, checkpoint61e, checkpoint61g, checkpoint61d, checkpoint61h, checkpoint61i
Changes since 1.37: +2 -5 lines
clean up the mess:
remove an unnecessary #include "SHELIFICE.h"

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

  ViewVC Help
Powered by ViewVC 1.1.22