/[MITgcm]/MITgcm_contrib/dgoldberg/CPL1/code/ini_masks_etc.F
ViewVC logotype

Annotation of /MITgcm_contrib/dgoldberg/CPL1/code/ini_masks_etc.F

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


Revision 1.1 - (hide annotations) (download)
Wed Jul 6 18:01:25 2016 UTC (9 years ago) by dgoldberg
Branch: MAIN
CVS Tags: HEAD
moving experiment out of shelfice_remeshing to replace with vertical remeshing only

1 dgoldberg 1.1 C $Header: /u/gcmpack/MITgcm_contrib/verification_other/shelfice_remeshing/code/ini_masks_etc.F,v 1.1 2016/04/04 12:53:15 dgoldberg Exp $
2     C $Name: $
3    
4     #include "PACKAGES_CONFIG.h"
5     #include "CPP_OPTIONS.h"
6     #ifdef ALLOW_SHELFICE
7     # include "SHELFICE_OPTIONS.h"
8     #endif /* ALLOW_SHELFICE */
9    
10     CBOP
11     C !ROUTINE: INI_MASKS_ETC
12     C !INTERFACE:
13     SUBROUTINE INI_MASKS_ETC( myThid )
14     C !DESCRIPTION: \bv
15     C *==========================================================*
16     C | SUBROUTINE INI_MASKS_ETC
17     C | o Initialise masks and topography factors
18     C *==========================================================*
19     C | These arrays are used throughout the code and describe
20     C | the topography of the domain through masks (0s and 1s)
21     C | and fractional height factors (0<hFac<1). The latter
22     C | distinguish between the lopped-cell and full-step
23     C | topographic representations.
24     C *==========================================================*
25     C \ev
26    
27     C !USES:
28     IMPLICIT NONE
29     C === Global variables ===
30     #include "SIZE.h"
31     #include "EEPARAMS.h"
32     #include "PARAMS.h"
33     #include "GRID.h"
34     #ifdef NONLIN_FRSURF
35     # include "SURFACE.h"
36     #endif /* NONLIN_FRSURF */
37    
38     C !INPUT/OUTPUT PARAMETERS:
39     C == Routine arguments ==
40     C myThid :: Number of this instance of INI_MASKS_ETC
41     INTEGER myThid
42    
43     C !LOCAL VARIABLES:
44     C == Local variables ==
45     C bi,bj :: tile indices
46     C i,j,k :: Loop counters
47     C tmpfld :: Temporary array used to compute & write Total Depth
48     _RS tmpfld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
49     INTEGER bi, bj
50     INTEGER i, j, k
51     _RL hFacCtmp
52     _RL hFacMnSz
53     CEOP
54    
55     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
56    
57     IF ( selectSigmaCoord.EQ.0 ) THEN
58     C--- r-coordinate with partial-cell or full cell mask
59    
60     C-- Calculate lopping factor hFacC : over-estimate the part inside of the domain
61     C taking into account the lower_R Boundary (Bathymetrie / Top of Atmos)
62     DO bj=myByLo(myThid), myByHi(myThid)
63     DO bi=myBxLo(myThid), myBxHi(myThid)
64     DO k=1, Nr
65     hFacMnSz=max( hFacMin, min(hFacMinDr*recip_drF(k),1. _d 0) )
66     DO j=1-OLy,sNy+OLy
67     DO i=1-OLx,sNx+OLx
68     C o Non-dimensional distance between grid bound. and domain lower_R bound.
69     hFacCtmp = (rF(k)-R_low(i,j,bi,bj))*recip_drF(k)
70     C o Select between, closed, open or partial (0,1,0-1)
71     hFacCtmp=min( max( hFacCtmp, 0. _d 0) , 1. _d 0)
72     C o Impose minimum fraction and/or size (dimensional)
73     IF (hFacCtmp.LT.hFacMnSz) THEN
74     IF (hFacCtmp.LT.hFacMnSz*0.5) THEN
75     hFacC(i,j,k,bi,bj)=0.
76     ELSE
77     hFacC(i,j,k,bi,bj)=hFacMnSz
78     ENDIF
79     ELSE
80     hFacC(i,j,k,bi,bj)=hFacCtmp
81     ENDIF
82     ENDDO
83     ENDDO
84     ENDDO
85    
86     C- Re-calculate lower-R Boundary position, taking into account hFacC
87     DO j=1-OLy,sNy+OLy
88     DO i=1-OLx,sNx+OLx
89     R_low(i,j,bi,bj) = rF(1)
90     ENDDO
91     ENDDO
92     DO k=Nr,1,-1
93     DO j=1-OLy,sNy+OLy
94     DO i=1-OLx,sNx+OLx
95     R_low(i,j,bi,bj) = R_low(i,j,bi,bj)
96     & - drF(k)*hFacC(i,j,k,bi,bj)
97     ENDDO
98     ENDDO
99     ENDDO
100     C- end bi,bj loops.
101     ENDDO
102     ENDDO
103    
104     C-- Calculate lopping factor hFacC : Remove part outside of the domain
105     C taking into account the Reference (=at rest) Surface Position Ro_surf
106     DO bj=myByLo(myThid), myByHi(myThid)
107     DO bi=myBxLo(myThid), myBxHi(myThid)
108     DO k=1, Nr
109     hFacMnSz=max( hFacMin, min(hFacMinDr*recip_drF(k),1. _d 0) )
110     DO j=1-OLy,sNy+OLy
111     DO i=1-OLx,sNx+OLx
112     C o Non-dimensional distance between grid boundary and model surface
113     hFacCtmp = (rF(k)-Ro_surf(i,j,bi,bj))*recip_drF(k)
114     C o Reduce the previous fraction : substract the outside part.
115     hFacCtmp = hFacC(i,j,k,bi,bj) - max( hFacCtmp, 0. _d 0)
116     C o set to zero if empty Column :
117     hFacCtmp = max( hFacCtmp, 0. _d 0)
118     C o Impose minimum fraction and/or size (dimensional)
119     IF (hFacCtmp.LT.hFacMnSz) THEN
120     IF (hFacCtmp.LT.hFacMnSz*0.5) THEN
121     hFacC(i,j,k,bi,bj)=0.
122     ELSE
123     hFacC(i,j,k,bi,bj)=hFacMnSz
124     ENDIF
125     ELSE
126     hFacC(i,j,k,bi,bj)=hFacCtmp
127     ENDIF
128     ENDDO
129     ENDDO
130     ENDDO
131     ENDDO
132     ENDDO
133    
134     #ifdef ALLOW_SHELFICE
135     IF ( useShelfIce ) THEN
136     C-- Modify lopping factor hFacC : Remove part outside of the domain
137     C taking into account the Reference (=at rest) Surface Position Ro_shelfIce
138     CALL SHELFICE_UPDATE_MASKS(
139     I rF, recip_drF,
140     U hFacC,
141     I myThid )
142     ENDIF
143     #endif /* ALLOW_SHELFICE */
144    
145     C- Re-calculate Reference surface position, taking into account hFacC
146     C initialize Total column fluid thickness and surface k index
147     C Note: if no fluid (continent) ==> kSurf = Nr+1
148     DO bj=myByLo(myThid), myByHi(myThid)
149     DO bi=myBxLo(myThid), myBxHi(myThid)
150     DO j=1-OLy,sNy+OLy
151     DO i=1-OLx,sNx+OLx
152     tmpfld(i,j,bi,bj) = 0.
153     kSurfC(i,j,bi,bj) = Nr+1
154     c maskH(i,j,bi,bj) = 0.
155     Ro_surf(i,j,bi,bj) = R_low(i,j,bi,bj)
156     DO k=Nr,1,-1
157     Ro_surf(i,j,bi,bj) = Ro_surf(i,j,bi,bj)
158     & + drF(k)*hFacC(i,j,k,bi,bj)
159     IF (hFacC(i,j,k,bi,bj).NE.0.) THEN
160     kSurfC(i,j,bi,bj) = k
161     c maskH(i,j,bi,bj) = 1.
162     tmpfld(i,j,bi,bj) = tmpfld(i,j,bi,bj) + 1.
163     ENDIF
164     ENDDO
165     kLowC(i,j,bi,bj) = 0
166     DO k= 1, Nr
167     IF (hFacC(i,j,k,bi,bj).NE.0) THEN
168     kLowC(i,j,bi,bj) = k
169     ENDIF
170     ENDDO
171     maskInC(i,j,bi,bj)= 0.
172     IF ( kSurfC(i,j,bi,bj).LE.Nr ) maskInC(i,j,bi,bj)= 1.
173     ENDDO
174     ENDDO
175     C- end bi,bj loops.
176     ENDDO
177     ENDDO
178    
179     #ifdef ALLOW_SHELFICE
180     #ifdef ALLOW_SHELFICE_REMESHING
181     IF ( useShelfIce ) THEN
182     C-- Modify lopping factor hFacC : Remove part outside of the domain
183     C taking into account the Reference (=at rest) Surface Position Ro_shelfIce
184     CALL SHELFICE_DIG_SHELF(
185     I myThid )
186     ENDIF
187     #endif
188     #endif /* ALLOW_SHELFICE */
189    
190    
191    
192     IF ( printDomain ) THEN
193     c CALL PLOT_FIELD_XYRS( tmpfld,
194     c & 'Model Depths K Index' , -1, myThid )
195     CALL PLOT_FIELD_XYRS(R_low,
196     & 'Model R_low (ini_masks_etc)', -1, myThid )
197     CALL PLOT_FIELD_XYRS(Ro_surf,
198     & 'Model Ro_surf (ini_masks_etc)', -1, myThid )
199     ENDIF
200    
201     C-- Calculate quantities derived from XY depth map
202     DO bj = myByLo(myThid), myByHi(myThid)
203     DO bi = myBxLo(myThid), myBxHi(myThid)
204     DO j=1-OLy,sNy+OLy
205     DO i=1-OLx,sNx+OLx
206     C Total fluid column thickness (r_unit) :
207     c Rcolumn(i,j,bi,bj)= Ro_surf(i,j,bi,bj) - R_low(i,j,bi,bj)
208     tmpfld(i,j,bi,bj) = Ro_surf(i,j,bi,bj) - R_low(i,j,bi,bj)
209     C Inverse of fluid column thickness (1/r_unit)
210     IF ( tmpfld(i,j,bi,bj) .LE. 0. ) THEN
211     recip_Rcol(i,j,bi,bj) = 0.
212     ELSE
213     recip_Rcol(i,j,bi,bj) = 1. _d 0 / tmpfld(i,j,bi,bj)
214     ENDIF
215     ENDDO
216     ENDDO
217     ENDDO
218     ENDDO
219    
220     C-- hFacW and hFacS (at U and V points)
221     DO bj=myByLo(myThid), myByHi(myThid)
222     DO bi=myBxLo(myThid), myBxHi(myThid)
223     DO k=1, Nr
224     DO j=1-OLy,sNy+OLy
225     hFacW(1-OLx,j,k,bi,bj)= 0.
226     DO i=2-OLx,sNx+OLx
227     hFacW(i,j,k,bi,bj)=
228     & MIN(hFacC(i,j,k,bi,bj),hFacC(i-1,j,k,bi,bj))
229     ENDDO
230     ENDDO
231     DO i=1-OLx,sNx+OLx
232     hFacS(i,1-OLy,k,bi,bj)= 0.
233     ENDDO
234     DO j=2-OLy,sNy+oly
235     DO i=1-OLx,sNx+OLx
236     hFacS(i,j,k,bi,bj)=
237     & MIN(hFacC(i,j,k,bi,bj),hFacC(i,j-1,k,bi,bj))
238     ENDDO
239     ENDDO
240     ENDDO
241     C rLow & reference rSurf at Western & Southern edges (U and V points)
242     i = 1-OLx
243     DO j=1-OLy,sNy+OLy
244     rLowW (i,j,bi,bj) = 0.
245     rSurfW(i,j,bi,bj) = 0.
246     ENDDO
247     j = 1-OLy
248     DO i=1-OLx,sNx+OLx
249     rLowS (i,j,bi,bj) = 0.
250     rSurfS(i,j,bi,bj) = 0.
251     ENDDO
252     DO j=1-OLy,sNy+OLy
253     DO i=2-OLx,sNx+OLx
254     rLowW(i,j,bi,bj) =
255     & MAX( R_low(i-1,j,bi,bj), R_low(i,j,bi,bj) )
256     rSurfW(i,j,bi,bj) =
257     & MIN( Ro_surf(i-1,j,bi,bj), Ro_surf(i,j,bi,bj) )
258     rSurfW(i,j,bi,bj) =
259     & MAX( rSurfW(i,j,bi,bj), rLowW(i,j,bi,bj) )
260     ENDDO
261     ENDDO
262     DO j=2-OLy,sNy+OLy
263     DO i=1-OLx,sNx+OLx
264     rLowS(i,j,bi,bj) =
265     & MAX( R_low(i,j-1,bi,bj), R_low(i,j,bi,bj) )
266     rSurfS(i,j,bi,bj) =
267     & MIN( Ro_surf(i,j-1,bi,bj), Ro_surf(i,j,bi,bj) )
268     rSurfS(i,j,bi,bj) =
269     & MAX( rSurfS(i,j,bi,bj), rLowS(i,j,bi,bj) )
270     ENDDO
271     ENDDO
272     C- end bi,bj loops.
273     ENDDO
274     ENDDO
275     CALL EXCH_UV_XYZ_RS(hFacW,hFacS,.FALSE.,myThid)
276     CALL EXCH_UV_XY_RS( rSurfW, rSurfS, .FALSE., myThid )
277     CALL EXCH_UV_XY_RS( rLowW, rLowS, .FALSE., myThid )
278    
279     C-- Addtional closing of Western and Southern grid-cell edges: for example,
280     C a) might add some "thin walls" in specific location
281     C-- b) close non-periodic N & S boundaries of lat-lon grid at the N/S poles.
282     CALL ADD_WALLS2MASKS( myThid )
283    
284     C-- Calculate surface k index for interface W & S (U & V points)
285     DO bj=myByLo(myThid), myByHi(myThid)
286     DO bi=myBxLo(myThid), myBxHi(myThid)
287     DO j=1-OLy,sNy+OLy
288     DO i=1-OLx,sNx+OLx
289     kSurfW(i,j,bi,bj) = Nr+1
290     kSurfS(i,j,bi,bj) = Nr+1
291     DO k=Nr,1,-1
292     IF (hFacW(i,j,k,bi,bj).NE.0.) kSurfW(i,j,bi,bj) = k
293     IF (hFacS(i,j,k,bi,bj).NE.0.) kSurfS(i,j,bi,bj) = k
294     ENDDO
295     maskInW(i,j,bi,bj)= 0.
296     IF ( kSurfW(i,j,bi,bj).LE.Nr ) maskInW(i,j,bi,bj)= 1.
297     maskInS(i,j,bi,bj)= 0.
298     IF ( kSurfS(i,j,bi,bj).LE.Nr ) maskInS(i,j,bi,bj)= 1.
299     ENDDO
300     ENDDO
301     ENDDO
302     ENDDO
303    
304     ELSE
305     #ifndef DISABLE_SIGMA_CODE
306     C--- Sigma and Hybrid-Sigma set-up:
307     CALL INI_SIGMA_HFAC( myThid )
308     #endif /* DISABLE_SIGMA_CODE */
309     ENDIF
310    
311     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
312    
313     C-- Write to disk: Total Column Thickness & hFac(C,W,S):
314     C This I/O is now done in write_grid.F
315     c CALL WRITE_FLD_XY_RS( 'Depth',' ',tmpfld,0,myThid)
316     c CALL WRITE_FLD_XYZ_RS( 'hFacC',' ',hFacC,0,myThid)
317     c CALL WRITE_FLD_XYZ_RS( 'hFacW',' ',hFacW,0,myThid)
318     c CALL WRITE_FLD_XYZ_RS( 'hFacS',' ',hFacS,0,myThid)
319    
320     IF ( printDomain ) THEN
321     CALL PLOT_FIELD_XYZRS( hFacC, 'hFacC' , Nr, 0, myThid )
322     CALL PLOT_FIELD_XYZRS( hFacW, 'hFacW' , Nr, 0, myThid )
323     CALL PLOT_FIELD_XYZRS( hFacS, 'hFacS' , Nr, 0, myThid )
324     ENDIF
325    
326     C-- Masks and reciprocals of hFac[CWS]
327     DO bj = myByLo(myThid), myByHi(myThid)
328     DO bi = myBxLo(myThid), myBxHi(myThid)
329     DO k=1,Nr
330     DO j=1-OLy,sNy+OLy
331     DO i=1-OLx,sNx+OLx
332     IF (hFacC(i,j,k,bi,bj) .NE. 0. ) THEN
333     recip_hFacC(i,j,k,bi,bj) = 1. _d 0 / hFacC(i,j,k,bi,bj)
334     maskC(i,j,k,bi,bj) = 1.
335     ELSE
336     recip_hFacC(i,j,k,bi,bj) = 0.
337     maskC(i,j,k,bi,bj) = 0.
338     ENDIF
339     IF (hFacW(i,j,k,bi,bj) .NE. 0. ) THEN
340     recip_hFacW(i,j,k,bi,bj) = 1. _d 0 / hFacW(i,j,k,bi,bj)
341     maskW(i,j,k,bi,bj) = 1.
342     ELSE
343     recip_hFacW(i,j,k,bi,bj) = 0.
344     maskW(i,j,k,bi,bj) = 0.
345     ENDIF
346     IF (hFacS(i,j,k,bi,bj) .NE. 0. ) THEN
347     recip_hFacS(i,j,k,bi,bj) = 1. _d 0 / hFacS(i,j,k,bi,bj)
348     maskS(i,j,k,bi,bj) = 1.
349     ELSE
350     recip_hFacS(i,j,k,bi,bj) = 0.
351     maskS(i,j,k,bi,bj) = 0.
352     ENDIF
353     ENDDO
354     ENDDO
355     ENDDO
356     #ifdef NONLIN_FRSURF
357     C-- Save initial geometrical hFac factor into h0Fac (fixed in time):
358     C Note: In case 1 pkg modifies hFac (from packages_init_fixed, called
359     C later in sequence of calls) this pkg would need also to update h0Fac.
360     DO k=1,Nr
361     DO j=1-OLy,sNy+OLy
362     DO i=1-OLx,sNx+OLx
363     h0FacC(i,j,k,bi,bj) = _hFacC(i,j,k,bi,bj)
364     h0FacW(i,j,k,bi,bj) = _hFacW(i,j,k,bi,bj)
365     h0FacS(i,j,k,bi,bj) = _hFacS(i,j,k,bi,bj)
366     ENDDO
367     ENDDO
368     ENDDO
369     #endif /* NONLIN_FRSURF */
370     C- end bi,bj loops.
371     ENDDO
372     ENDDO
373    
374     c #ifdef ALLOW_NONHYDROSTATIC
375     C-- Calculate "recip_hFacU" = reciprocal hfac distance/volume for W cells
376     C NOTE: not used ; computed locally in CALC_GW
377     c #endif
378    
379     RETURN
380     END

  ViewVC Help
Powered by ViewVC 1.1.22