1 |
C $Header: /u/gcmpack/MITgcm_contrib/verification_other/shelfice_remeshing/code/ini_masks_remesh.F,v 1.2 2016/05/25 13:10:42 dgoldberg Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
#include "SHELFICE_OPTIONS.h" |
7 |
|
8 |
CBOP |
9 |
C !ROUTINE: INI_MASKS_ETC |
10 |
C !INTERFACE: |
11 |
SUBROUTINE INI_MASKS_REMESH( myThid ) |
12 |
C !DESCRIPTION: \bv |
13 |
C *==========================================================* |
14 |
C | SUBROUTINE INI_MASKS_ETC |
15 |
C | o Initialise masks and topography factors |
16 |
C *==========================================================* |
17 |
C | These arrays are used throughout the code and describe |
18 |
C | the topography of the domain through masks (0s and 1s) |
19 |
C | and fractional height factors (0<hFac<1). The latter |
20 |
C | distinguish between the lopped-cell and full-step |
21 |
C | topographic representations. |
22 |
C *==========================================================* |
23 |
C \ev |
24 |
|
25 |
C !USES: |
26 |
IMPLICIT NONE |
27 |
C === Global variables === |
28 |
#include "SIZE.h" |
29 |
#include "EEPARAMS.h" |
30 |
#include "PARAMS.h" |
31 |
#include "GRID.h" |
32 |
#include "DYNVARS.h" |
33 |
#ifdef NONLIN_FRSURF |
34 |
# include "SURFACE.h" |
35 |
#endif /* NONLIN_FRSURF */ |
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 |
#ifdef ALLOW_SHELFICE |
43 |
#ifdef ALLOW_SHELFICE_REMESHING |
44 |
|
45 |
C !LOCAL VARIABLES: |
46 |
C == Local variables == |
47 |
C bi,bj :: tile indices |
48 |
C i,j,k :: Loop counters |
49 |
C tmpfld :: Temporary array used to compute & write Total Depth |
50 |
_RS tmpfld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
51 |
|
52 |
_RS rsurftmp(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
53 |
|
54 |
INTEGER bi, bj |
55 |
INTEGER i, j, k, ks |
56 |
_RL hFacCtmp |
57 |
_RL hFacMnSz |
58 |
_RS hhm, hhp |
59 |
_RL Rmin_tmp |
60 |
CEOP |
61 |
|
62 |
|
63 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
64 |
|
65 |
IF ( selectSigmaCoord.EQ.0 ) THEN |
66 |
C--- r-coordinate with partial-cell or full cell mask |
67 |
|
68 |
C-- Calculate lopping factor hFacC : over-estimate the part inside of the domain |
69 |
C taking into account the lower_R Boundary (Bathymetrie / Top of Atmos) |
70 |
DO bj=myByLo(myThid), myByHi(myThid) |
71 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
72 |
DO k=1, Nr |
73 |
hFacMnSz=max( hFacMin, min(hFacMinDr*recip_drF(k),1. _d 0) ) |
74 |
DO j=1-OLy,sNy+OLy |
75 |
DO i=1-OLx,sNx+OLx |
76 |
C o Non-dimensional distance between grid bound. and domain lower_R bound. |
77 |
hFacCtmp = (rF(k)-R_low(i,j,bi,bj))*recip_drF(k) |
78 |
C o Select between, closed, open or partial (0,1,0-1) |
79 |
hFacCtmp=min( max( hFacCtmp, 0. _d 0) , 1. _d 0) |
80 |
C o Impose minimum fraction and/or size (dimensional) |
81 |
IF (hFacCtmp.LT.hFacMnSz) THEN |
82 |
IF (hFacCtmp.LT.hFacMnSz*0.5) THEN |
83 |
hFacC(i,j,k,bi,bj)=0. |
84 |
ELSE |
85 |
hFacC(i,j,k,bi,bj)=hFacMnSz |
86 |
ENDIF |
87 |
ELSE |
88 |
hFacC(i,j,k,bi,bj)=hFacCtmp |
89 |
ENDIF |
90 |
ENDDO |
91 |
ENDDO |
92 |
ENDDO |
93 |
|
94 |
C- Re-calculate lower-R Boundary position, taking into account hFacC |
95 |
DO j=1-OLy,sNy+OLy |
96 |
DO i=1-OLx,sNx+OLx |
97 |
R_low(i,j,bi,bj) = rF(1) |
98 |
ENDDO |
99 |
ENDDO |
100 |
DO k=Nr,1,-1 |
101 |
DO j=1-OLy,sNy+OLy |
102 |
DO i=1-OLx,sNx+OLx |
103 |
R_low(i,j,bi,bj) = R_low(i,j,bi,bj) |
104 |
& - drF(k)*hFacC(i,j,k,bi,bj) |
105 |
ENDDO |
106 |
ENDDO |
107 |
ENDDO |
108 |
C- end bi,bj loops. |
109 |
ENDDO |
110 |
ENDDO |
111 |
|
112 |
C-- Calculate lopping factor hFacC : Remove part outside of the domain |
113 |
C taking into account the Reference (=at rest) Surface Position Ro_surf |
114 |
DO bj=myByLo(myThid), myByHi(myThid) |
115 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
116 |
DO k=1, Nr |
117 |
hFacMnSz=max( hFacMin, min(hFacMinDr*recip_drF(k),1. _d 0) ) |
118 |
DO j=1-OLy,sNy+OLy |
119 |
DO i=1-OLx,sNx+OLx |
120 |
C JJ HACK |
121 |
Ro_surf(i,j,bi,bj)=0.0 |
122 |
C o Non-dimensional distance between grid boundary and model surface |
123 |
hFacCtmp = (rF(k)-Ro_surf(i,j,bi,bj))*recip_drF(k) |
124 |
C o Reduce the previous fraction : substract the outside part. |
125 |
hFacCtmp = hFacC(i,j,k,bi,bj) - max( hFacCtmp, 0. _d 0) |
126 |
C o set to zero if empty Column : |
127 |
hFacCtmp = max( hFacCtmp, 0. _d 0) |
128 |
C o Impose minimum fraction and/or size (dimensional) |
129 |
IF (hFacCtmp.LT.hFacMnSz) THEN |
130 |
IF (hFacCtmp.LT.hFacMnSz*0.5) THEN |
131 |
hFacC(i,j,k,bi,bj)=0. |
132 |
ELSE |
133 |
hFacC(i,j,k,bi,bj)=hFacMnSz |
134 |
ENDIF |
135 |
ELSE |
136 |
hFacC(i,j,k,bi,bj)=hFacCtmp |
137 |
ENDIF |
138 |
ENDDO |
139 |
ENDDO |
140 |
ENDDO |
141 |
ENDDO |
142 |
ENDDO |
143 |
|
144 |
#ifdef ALLOW_SHELFICE |
145 |
|
146 |
IF ( useShelfIce ) THEN |
147 |
C-- Modify lopping factor hFacC : Remove part outside of the domain |
148 |
C taking into account the Reference (=at rest) Surface Position Ro_shelfIce |
149 |
CALL SHELFICE_UPDATE_MASKS_REMESH( |
150 |
I rF, recip_drF, drF, kLowc, |
151 |
U hFacC, |
152 |
I myThid ) |
153 |
ENDIF |
154 |
#endif /* ALLOW_SHELFICE */ |
155 |
|
156 |
|
157 |
|
158 |
C- Re-calculate Reference surface position, taking into account hFacC |
159 |
C initialize Total column fluid thickness and surface k index |
160 |
C Note: if no fluid (continent) ==> kSurf = Nr+1 |
161 |
DO bj=myByLo(myThid), myByHi(myThid) |
162 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
163 |
DO j=1-OLy,sNy+OLy |
164 |
DO i=1-OLx,sNx+OLx |
165 |
tmpfld(i,j,bi,bj) = 0. |
166 |
kSurfC(i,j,bi,bj) = Nr+1 |
167 |
c maskH(i,j,bi,bj) = 0. |
168 |
Ro_surf(i,j,bi,bj) = R_low(i,j,bi,bj) |
169 |
DO k=Nr,1,-1 |
170 |
Ro_surf(i,j,bi,bj) = Ro_surf(i,j,bi,bj) |
171 |
& + drF(k)*hFacC(i,j,k,bi,bj) |
172 |
IF (hFacC(i,j,k,bi,bj).NE.0.) THEN |
173 |
kSurfC(i,j,bi,bj) = k |
174 |
c maskH(i,j,bi,bj) = 1. |
175 |
tmpfld(i,j,bi,bj) = tmpfld(i,j,bi,bj) + 1. |
176 |
ENDIF |
177 |
ENDDO |
178 |
kLowC(i,j,bi,bj) = 0 |
179 |
DO k= 1, Nr |
180 |
IF (hFacC(i,j,k,bi,bj).NE.0) THEN |
181 |
kLowC(i,j,bi,bj) = k |
182 |
ENDIF |
183 |
ENDDO |
184 |
maskInC(i,j,bi,bj)= 0. |
185 |
IF ( kSurfC(i,j,bi,bj).LE.Nr ) maskInC(i,j,bi,bj)= 1. |
186 |
ENDDO |
187 |
ENDDO |
188 |
C- end bi,bj loops. |
189 |
ENDDO |
190 |
ENDDO |
191 |
|
192 |
|
193 |
IF ( printDomain ) THEN |
194 |
c CALL PLOT_FIELD_XYRS( tmpfld, |
195 |
c & 'Model Depths K Index' , -1, myThid ) |
196 |
CALL PLOT_FIELD_XYRS(R_low, |
197 |
& 'Model R_low (ini_masks_etc)', -1, myThid ) |
198 |
CALL PLOT_FIELD_XYRS(Ro_surf, |
199 |
& 'Model Ro_surf (ini_masks_etc)', -1, myThid ) |
200 |
ENDIF |
201 |
|
202 |
C-- Calculate quantities derived from XY depth map |
203 |
DO bj = myByLo(myThid), myByHi(myThid) |
204 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
205 |
DO j=1-OLy,sNy+OLy |
206 |
DO i=1-OLx,sNx+OLx |
207 |
C Total fluid column thickness (r_unit) : |
208 |
c Rcolumn(i,j,bi,bj)= Ro_surf(i,j,bi,bj) - R_low(i,j,bi,bj) |
209 |
tmpfld(i,j,bi,bj) = Ro_surf(i,j,bi,bj) - R_low(i,j,bi,bj) |
210 |
C Inverse of fluid column thickness (1/r_unit) |
211 |
IF ( tmpfld(i,j,bi,bj) .LE. 0. ) THEN |
212 |
recip_Rcol(i,j,bi,bj) = 0. |
213 |
ELSE |
214 |
recip_Rcol(i,j,bi,bj) = 1. _d 0 / tmpfld(i,j,bi,bj) |
215 |
ENDIF |
216 |
ENDDO |
217 |
ENDDO |
218 |
ENDDO |
219 |
ENDDO |
220 |
|
221 |
C-- hFacW and hFacS (at U and V points) |
222 |
DO bj=myByLo(myThid), myByHi(myThid) |
223 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
224 |
DO k=1, Nr |
225 |
DO j=1-OLy,sNy+OLy |
226 |
hFacW(1-OLx,j,k,bi,bj)= 0. |
227 |
DO i=2-OLx,sNx+OLx |
228 |
hFacW(i,j,k,bi,bj)= |
229 |
& MIN(hFacC(i,j,k,bi,bj),hFacC(i-1,j,k,bi,bj)) |
230 |
ENDDO |
231 |
ENDDO |
232 |
DO i=1-OLx,sNx+OLx |
233 |
hFacS(i,1-OLy,k,bi,bj)= 0. |
234 |
ENDDO |
235 |
DO j=2-OLy,sNy+oly |
236 |
DO i=1-OLx,sNx+OLx |
237 |
hFacS(i,j,k,bi,bj)= |
238 |
& MIN(hFacC(i,j,k,bi,bj),hFacC(i,j-1,k,bi,bj)) |
239 |
ENDDO |
240 |
ENDDO |
241 |
ENDDO |
242 |
C rLow & reference rSurf at Western & Southern edges (U and V points) |
243 |
i = 1-OLx |
244 |
DO j=1-OLy,sNy+OLy |
245 |
rLowW (i,j,bi,bj) = 0. |
246 |
rSurfW(i,j,bi,bj) = 0. |
247 |
ENDDO |
248 |
j = 1-OLy |
249 |
DO i=1-OLx,sNx+OLx |
250 |
rLowS (i,j,bi,bj) = 0. |
251 |
rSurfS(i,j,bi,bj) = 0. |
252 |
ENDDO |
253 |
DO j=1-OLy,sNy+OLy |
254 |
DO i=2-OLx,sNx+OLx |
255 |
rLowW(i,j,bi,bj) = |
256 |
& MAX( R_low(i-1,j,bi,bj), R_low(i,j,bi,bj) ) |
257 |
rSurfW(i,j,bi,bj) = |
258 |
& MIN( Ro_surf(i-1,j,bi,bj), Ro_surf(i,j,bi,bj) ) |
259 |
rSurfW(i,j,bi,bj) = |
260 |
& MAX( rSurfW(i,j,bi,bj), rLowW(i,j,bi,bj) ) |
261 |
ENDDO |
262 |
ENDDO |
263 |
DO j=2-OLy,sNy+OLy |
264 |
DO i=1-OLx,sNx+OLx |
265 |
rLowS(i,j,bi,bj) = |
266 |
& MAX( R_low(i,j-1,bi,bj), R_low(i,j,bi,bj) ) |
267 |
rSurfS(i,j,bi,bj) = |
268 |
& MIN( Ro_surf(i,j-1,bi,bj), Ro_surf(i,j,bi,bj) ) |
269 |
rSurfS(i,j,bi,bj) = |
270 |
& MAX( rSurfS(i,j,bi,bj), rLowS(i,j,bi,bj) ) |
271 |
ENDDO |
272 |
ENDDO |
273 |
C- end bi,bj loops. |
274 |
ENDDO |
275 |
ENDDO |
276 |
CALL EXCH_UV_XYZ_RS(hFacW,hFacS,.FALSE.,myThid) |
277 |
CALL EXCH_UV_XY_RS( rSurfW, rSurfS, .FALSE., myThid ) |
278 |
CALL EXCH_UV_XY_RS( rLowW, rLowS, .FALSE., myThid ) |
279 |
|
280 |
C-- Addtional closing of Western and Southern grid-cell edges: for example, |
281 |
C a) might add some "thin walls" in specific location |
282 |
C-- b) close non-periodic N & S boundaries of lat-lon grid at the N/S poles. |
283 |
CALL ADD_WALLS2MASKS( myThid ) |
284 |
|
285 |
C-- Calculate surface k index for interface W & S (U & V points) |
286 |
DO bj=myByLo(myThid), myByHi(myThid) |
287 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
288 |
DO j=1-OLy,sNy+OLy |
289 |
DO i=1-OLx,sNx+OLx |
290 |
kSurfW(i,j,bi,bj) = Nr+1 |
291 |
kSurfS(i,j,bi,bj) = Nr+1 |
292 |
DO k=Nr,1,-1 |
293 |
IF (hFacW(i,j,k,bi,bj).NE.0.) kSurfW(i,j,bi,bj) = k |
294 |
IF (hFacS(i,j,k,bi,bj).NE.0.) kSurfS(i,j,bi,bj) = k |
295 |
ENDDO |
296 |
maskInW(i,j,bi,bj)= 0. |
297 |
IF ( kSurfW(i,j,bi,bj).LE.Nr ) maskInW(i,j,bi,bj)= 1. |
298 |
maskInS(i,j,bi,bj)= 0. |
299 |
IF ( kSurfS(i,j,bi,bj).LE.Nr ) maskInS(i,j,bi,bj)= 1. |
300 |
ENDDO |
301 |
ENDDO |
302 |
ENDDO |
303 |
ENDDO |
304 |
|
305 |
ELSE |
306 |
#ifndef DISABLE_SIGMA_CODE |
307 |
C--- Sigma and Hybrid-Sigma set-up: |
308 |
CALL INI_SIGMA_HFAC( myThid ) |
309 |
#endif /* DISABLE_SIGMA_CODE */ |
310 |
ENDIF |
311 |
|
312 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
313 |
|
314 |
C-- Write to disk: Total Column Thickness & hFac(C,W,S): |
315 |
C This I/O is now done in write_grid.F |
316 |
c CALL WRITE_FLD_XY_RS( 'Depth',' ',tmpfld,0,myThid) |
317 |
c CALL WRITE_FLD_XYZ_RS( 'hFacC',' ',hFacC,0,myThid) |
318 |
c CALL WRITE_FLD_XYZ_RS( 'hFacW',' ',hFacW,0,myThid) |
319 |
c CALL WRITE_FLD_XYZ_RS( 'hFacS',' ',hFacS,0,myThid) |
320 |
|
321 |
IF ( printDomain ) THEN |
322 |
CALL PLOT_FIELD_XYZRS( hFacC, 'hFacC' , Nr, 0, myThid ) |
323 |
CALL PLOT_FIELD_XYZRS( hFacW, 'hFacW' , Nr, 0, myThid ) |
324 |
CALL PLOT_FIELD_XYZRS( hFacS, 'hFacS' , Nr, 0, myThid ) |
325 |
ENDIF |
326 |
|
327 |
C-- Masks and reciprocals of hFac[CWS] |
328 |
DO bj = myByLo(myThid), myByHi(myThid) |
329 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
330 |
DO k=1,Nr |
331 |
DO j=1-OLy,sNy+OLy |
332 |
DO i=1-OLx,sNx+OLx |
333 |
IF (hFacC(i,j,k,bi,bj) .NE. 0. ) THEN |
334 |
recip_hFacC(i,j,k,bi,bj) = 1. _d 0 / hFacC(i,j,k,bi,bj) |
335 |
maskC(i,j,k,bi,bj) = 1. |
336 |
ELSE |
337 |
recip_hFacC(i,j,k,bi,bj) = 0. |
338 |
maskC(i,j,k,bi,bj) = 0. |
339 |
ENDIF |
340 |
IF (hFacW(i,j,k,bi,bj) .NE. 0. ) THEN |
341 |
recip_hFacW(i,j,k,bi,bj) = 1. _d 0 / hFacW(i,j,k,bi,bj) |
342 |
maskW(i,j,k,bi,bj) = 1. |
343 |
ELSE |
344 |
recip_hFacW(i,j,k,bi,bj) = 0. |
345 |
maskW(i,j,k,bi,bj) = 0. |
346 |
ENDIF |
347 |
IF (hFacS(i,j,k,bi,bj) .NE. 0. ) THEN |
348 |
recip_hFacS(i,j,k,bi,bj) = 1. _d 0 / hFacS(i,j,k,bi,bj) |
349 |
maskS(i,j,k,bi,bj) = 1. |
350 |
ELSE |
351 |
recip_hFacS(i,j,k,bi,bj) = 0. |
352 |
maskS(i,j,k,bi,bj) = 0. |
353 |
ENDIF |
354 |
ENDDO |
355 |
ENDDO |
356 |
ENDDO |
357 |
#ifdef NONLIN_FRSURF |
358 |
C-- Save initial geometrical hFac factor into h0Fac (fixed in time): |
359 |
C Note: In case 1 pkg modifies hFac (from packages_init_fixed, called |
360 |
C later in sequence of calls) this pkg would need also to update h0Fac. |
361 |
DO k=1,Nr |
362 |
DO j=1-OLy,sNy+OLy |
363 |
DO i=1-OLx,sNx+OLx |
364 |
h0FacC(i,j,k,bi,bj) = _hFacC(i,j,k,bi,bj) |
365 |
h0FacW(i,j,k,bi,bj) = _hFacW(i,j,k,bi,bj) |
366 |
h0FacS(i,j,k,bi,bj) = _hFacS(i,j,k,bi,bj) |
367 |
ENDDO |
368 |
ENDDO |
369 |
ENDDO |
370 |
#endif /* NONLIN_FRSURF */ |
371 |
C- end bi,bj loops. |
372 |
ENDDO |
373 |
ENDDO |
374 |
|
375 |
|
376 |
DO bj = myByLo(myThid), myByHi(myThid) |
377 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
378 |
DO k=1,Nr |
379 |
DO j=1-OLy,sNy+OLy |
380 |
DO i=1-OLx,sNx+OLx |
381 |
uVel(i,j,k,bi,bj)=uVel(i,j,k,bi,bj)*maskW(i,j,k,bi,bj) |
382 |
vVel(i,j,k,bi,bj)=vVel(i,j,k,bi,bj)*maskS(i,j,k,bi,bj) |
383 |
wVel(i,j,k,bi,bj)=0.0 |
384 |
salt(i,j,k,bi,bj)=salt(i,j,k,bi,bj)*maskC(i,j,k,bi,bj) |
385 |
theta(i,j,k,bi,bj)=theta(i,j,k,bi,bj)*maskC(i,j,k,bi,bj) |
386 |
|
387 |
ENDDO |
388 |
ENDDO |
389 |
ENDDO |
390 |
ENDDO |
391 |
ENDDO |
392 |
|
393 |
|
394 |
|
395 |
DO bj = myByLo(myThid), myByHi(myThid) |
396 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
397 |
DO j=1,sNy |
398 |
DO i=1,sNx+1 |
399 |
ks = kSurfW(i,j,bi,bj) |
400 |
IF (ks.LE.Nr) THEN |
401 |
c- allows hFacW to be larger than surrounding hFacC=1 @ edge of a step with |
402 |
C different kSurfC on either side (topo in p-coords, ice-shelf in z-coords) |
403 |
hhm = Ro_surf(i-1,j,bi,bj)+etaN(i-1,j,bi,bj) |
404 |
|
405 |
hhp = Ro_surf(i,j,bi,bj)+etaN(i,j,bi,bj) |
406 |
|
407 |
C- make sure hFacW is not larger than the 2 surrounding hFacC |
408 |
c hhm = rF(ks) |
409 |
c IF(ks.EQ.kSurfC(i-1,j,bi,bj)) hhm = rSurftmp(i-1,j) |
410 |
c hhp = rF(ks) |
411 |
c IF(ks.EQ.kSurfC(i,j,bi,bj)) hhp = rSurftmp(i,j) |
412 |
hFac_surfW(i,j,bi,bj) = h0FacW(i,j,ks,bi,bj) |
413 |
& + ( MIN(hhm,hhp) |
414 |
& - MIN( Ro_surf(i-1,j,bi,bj), Ro_surf(i,j,bi,bj) ) |
415 |
& )*recip_drF(ks)*maskW(i,j,ks,bi,bj) |
416 |
ENDIF |
417 |
ENDDO |
418 |
ENDDO |
419 |
|
420 |
DO j=1,sNy+1 |
421 |
DO i=1,sNx |
422 |
ks = kSurfS(i,j,bi,bj) |
423 |
IF (ks.LE.Nr) THEN |
424 |
C- allows hFacS to be larger than surrounding hFacC=1 @ edge of a step with |
425 |
C different kSurfC on either side (topo in p-coords, ice-shelf in z-coords) |
426 |
hhm = Ro_surf(i,j-1,bi,bj)+etaN(i,j-1,bi,bj) |
427 |
|
428 |
hhp = Ro_surf(i,j,bi,bj)+etaN(i,j,bi,bj) |
429 |
|
430 |
C- make sure hFacS is not larger than the 2 surrounding hFacC |
431 |
c hhm = rF(ks) |
432 |
c IF(ks.EQ.kSurfC(i,j-1,bi,bj)) hhm = rSurftmp(i,j-1) |
433 |
c hhp = rF(ks) |
434 |
c IF(ks.EQ.kSurfC(i,j,bi,bj)) hhp = rSurftmp(i,j) |
435 |
hFac_surfS(i,j,bi,bj) = h0FacS(i,j,ks,bi,bj) |
436 |
& + ( MIN(hhm,hhp) |
437 |
& - MIN( Ro_surf(i,j-1,bi,bj), Ro_surf(i,j,bi,bj) ) |
438 |
& )*recip_drF(ks)*maskS(i,j,ks,bi,bj) |
439 |
ENDIF |
440 |
ENDDO |
441 |
ENDDO |
442 |
ENDDO |
443 |
ENDDO |
444 |
|
445 |
#ifdef NONLIN_FRSURF |
446 |
|
447 |
DO bj=myByLo(myThid), myByHi(myThid) |
448 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
449 |
|
450 |
C-- Compute the mimimum value of r_surf (used for computing hFac_surfC) |
451 |
DO j=1,sNy |
452 |
DO i=1,sNx |
453 |
ks = kSurfC(i,j,bi,bj) |
454 |
IF (ks.LE.Nr) THEN |
455 |
Rmin_tmp = rF(ks+1) |
456 |
IF ( ks.EQ.kSurfW(i,j,bi,bj)) |
457 |
& Rmin_tmp = MAX(Rmin_tmp, R_low(i-1,j,bi,bj)) |
458 |
IF ( ks.EQ.kSurfW(i+1,j,bi,bj)) |
459 |
& Rmin_tmp = MAX(Rmin_tmp, R_low(i+1,j,bi,bj)) |
460 |
IF ( ks.EQ.kSurfS(i,j,bi,bj)) |
461 |
& Rmin_tmp = MAX(Rmin_tmp, R_low(i,j-1,bi,bj)) |
462 |
IF ( ks.EQ.kSurfS(i,j+1,bi,bj)) |
463 |
& Rmin_tmp = MAX(Rmin_tmp, R_low(i,j+1,bi,bj)) |
464 |
|
465 |
Rmin_surf(i,j,bi,bj) = |
466 |
& MAX( MAX(rF(ks+1),R_low(i,j,bi,bj)) + hFacInf*drF(ks), |
467 |
& Rmin_tmp + hFacInf*drF(ks) |
468 |
& ) |
469 |
|
470 |
ENDIF |
471 |
ENDDO |
472 |
ENDDO |
473 |
|
474 |
C- end bi,bj loop. |
475 |
ENDDO |
476 |
ENDDO |
477 |
|
478 |
CALL EXCH_XY_RL( Rmin_surf, myThid ) |
479 |
|
480 |
#endif /* NONLIN_FRSURF */ |
481 |
|
482 |
|
483 |
c #if |
484 |
C-- Calculate "recip_hFacU" = reciprocal hfac distance/volume for W cells |
485 |
C NOTE: not used ; computed locally in CALC_GW |
486 |
c #endif |
487 |
|
488 |
#endif |
489 |
#endif |
490 |
|
491 |
RETURN |
492 |
END |