1 |
C $Header: $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: UPDATE_MASKS_ETC |
8 |
C !INTERFACE: |
9 |
SUBROUTINE UPDATE_MASKS_ETC( myThid ) |
10 |
C !DESCRIPTION: \bv |
11 |
C *==========================================================* |
12 |
C | SUBROUTINE UPDATE_MASKS_ETC |
13 |
C | o Re-initialise masks and topography factors after a new |
14 |
C | hFacC has been calculated by the minimizer |
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 | code taken from ini_masks_etc.F |
23 |
C *==========================================================* |
24 |
C \ev |
25 |
|
26 |
C !USES: |
27 |
IMPLICIT NONE |
28 |
C === Global variables === |
29 |
#include "SIZE.h" |
30 |
#include "EEPARAMS.h" |
31 |
#include "PARAMS.h" |
32 |
#include "GRID.h" |
33 |
#include "SURFACE.h" |
34 |
Cml we need optimcycle for storing the new hFaC(C/W/S) and depth |
35 |
#ifdef ALLOW_AUTODIFF_TAMC |
36 |
# include "optim.h" |
37 |
#endif |
38 |
|
39 |
C !INPUT/OUTPUT PARAMETERS: |
40 |
C == Routine arguments == |
41 |
C myThid - Number of this instance of INI_MASKS_ETC |
42 |
INTEGER myThid |
43 |
|
44 |
#ifdef ALLOW_DEPTH_CONTROL |
45 |
C !LOCAL VARIABLES: |
46 |
C == Local variables in common == |
47 |
C tmpfld - Temporary array used to compute & write Total Depth |
48 |
C has to be in common for multi threading |
49 |
COMMON / LOCAL_INI_MASKS_ETC / tmpfld |
50 |
_RS tmpfld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
51 |
C == Local variables == |
52 |
C bi,bj - Loop counters |
53 |
C I,J,K |
54 |
INTEGER bi, bj |
55 |
INTEGER I, J, K |
56 |
#ifdef ALLOW_NONHYDROSTATIC |
57 |
INTEGER Km1 |
58 |
_RL hFacUpper,hFacLower |
59 |
#endif |
60 |
#ifdef ALLOW_NONHYDROSTATIC |
61 |
CML new auxilliary variable |
62 |
_RL recip_hFacU_tmp |
63 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
64 |
#endif |
65 |
CHARACTER*(MAX_LEN_MBUF) suff |
66 |
Cml( |
67 |
INTEGER Im1, Jm1 |
68 |
_RL hFacCtmp, hFacCtmp2 |
69 |
_RL hFacMnSz |
70 |
_RS smoothMin_R4 |
71 |
EXTERNAL smoothMin_R4 |
72 |
Cml) |
73 |
CEOP |
74 |
|
75 |
C- Calculate lopping factor hFacC : over-estimate the part inside of the domain |
76 |
C taking into account the lower_R Boundary (Bathymetrie / Top of Atmos) |
77 |
DO bj=myByLo(myThid), myByHi(myThid) |
78 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
79 |
DO K=1, Nr |
80 |
hFacMnSz=max( hFacMin, min(hFacMinDr*recip_drF(k),1. _d 0) ) |
81 |
DO J=1-Oly,sNy+Oly |
82 |
DO I=1-Olx,sNx+Olx |
83 |
C o Non-dimensional distance between grid bound. and domain lower_R bound. |
84 |
#ifdef ALLOW_DEPTH_CONTROL |
85 |
hFacCtmp = (rF(K)-xx_r_low(I,J,bi,bj))*recip_drF(K) |
86 |
#else |
87 |
hFacCtmp = (rF(K)-R_low(I,J,bi,bj))*recip_drF(K) |
88 |
#endif /* ALLOW_DEPTH_CONTROL */ |
89 |
Cml IF ( hFacCtmp .le. 0. _d 0 ) THEN |
90 |
CmlC IF ( hFacCtmp .lt. 0.5*hfacMnSz ) THEN |
91 |
Cml hFacCtmp2 = 0. _d 0 |
92 |
Cml ELSE |
93 |
Cml hFacCtmp2 = hFacCtmp + hFacMnSz*( |
94 |
Cml & EXP(-hFacCtmp/hFacMnSz)-EXP(-1./hFacMnSz) ) |
95 |
Cml ENDIF |
96 |
Cml call limit_hfacc_to_one( hFacCtmp2 ) |
97 |
Cml hFacC(I,J,K,bi,bj) = hFacCtmp2 |
98 |
IF ( hFacCtmp .le. 0. _d 0 ) THEN |
99 |
C IF ( hFacCtmp .lt. 0.5*hfacMnSz ) THEN |
100 |
hFacC(I,J,K,bi,bj) = 0. _d 0 |
101 |
ELSEIF ( hFacCtmp .gt. 1. _d 0 ) THEN |
102 |
hFacC(I,J,K,bi,bj) = 1. _d 0 |
103 |
ELSE |
104 |
hFacC(I,J,K,bi,bj) = hFacCtmp + hFacMnSz*( |
105 |
& EXP(-hFacCtmp/hFacMnSz)-EXP(-1./hFacMnSz) ) |
106 |
ENDIF |
107 |
Cml print '(A,3I5,F20.16)', 'ml-hfac:', I,J,K,hFacC(I,J,K,bi,bj) |
108 |
CmlC o Select between, closed, open or partial (0,1,0-1) |
109 |
Cml hFacCtmp=min( max( hFacCtmp, 0. _d 0) , 1. _d 0) |
110 |
CmlC o Impose minimum fraction and/or size (dimensional) |
111 |
Cml IF (hFacCtmp.LT.hFacMnSz) THEN |
112 |
Cml IF (hFacCtmp.LT.hFacMnSz*0.5) THEN |
113 |
Cml hFacC(I,J,K,bi,bj)=0. |
114 |
Cml ELSE |
115 |
Cml hFacC(I,J,K,bi,bj)=hFacMnSz |
116 |
Cml ENDIF |
117 |
Cml ELSE |
118 |
Cml hFacC(I,J,K,bi,bj)=hFacCtmp |
119 |
Cml ENDIF |
120 |
Cml ENDIF |
121 |
Cml print '(A,F15.4,F20.16)', 'ml-hfac:', R_low(i,j,bi,bj),hFacC(I,J,K,bi,bj) |
122 |
ENDDO |
123 |
ENDDO |
124 |
ENDDO |
125 |
C - end bi,bj loops. |
126 |
ENDDO |
127 |
ENDDO |
128 |
C |
129 |
C _EXCH_XYZ_R4(hFacC,myThid) |
130 |
C |
131 |
C- Re-calculate lower-R Boundary position, taking into account hFacC |
132 |
DO bj=myByLo(myThid), myByHi(myThid) |
133 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
134 |
DO J=1-Oly,sNy+Oly |
135 |
DO I=1-Olx,sNx+Olx |
136 |
R_low(I,J,bi,bj) = rF(1) |
137 |
DO K=Nr,1,-1 |
138 |
R_low(I,J,bi,bj) = R_low(I,J,bi,bj) |
139 |
& - drF(k)*hFacC(I,J,K,bi,bj) |
140 |
ENDDO |
141 |
ENDDO |
142 |
ENDDO |
143 |
C - end bi,bj loops. |
144 |
ENDDO |
145 |
ENDDO |
146 |
C |
147 |
|
148 |
Cml DO bj=myByLo(myThid), myByHi(myThid) |
149 |
Cml DO bi=myBxLo(myThid), myBxHi(myThid) |
150 |
CmlC- Re-calculate Reference surface position, taking into account hFacC |
151 |
CmlC initialize Total column fluid thickness and surface k index |
152 |
CmlC Note: if no fluid (continent) ==> ksurf = Nr+1 |
153 |
Cml DO J=1-Oly,sNy+Oly |
154 |
Cml DO I=1-Olx,sNx+Olx |
155 |
Cml tmpfld(I,J,bi,bj) = 0. |
156 |
Cml ksurfC(I,J,bi,bj) = Nr+1 |
157 |
Cml Ro_surf(I,J,bi,bj) = R_low(I,J,bi,bj) |
158 |
Cml DO K=Nr,1,-1 |
159 |
Cml Ro_surf(I,J,bi,bj) = Ro_surf(I,J,bi,bj) |
160 |
Cml & + drF(k)*hFacC(I,J,K,bi,bj) |
161 |
Cml IF (maskC(I,J,K,bi,bj).NE.0.) THEN |
162 |
Cml ksurfC(I,J,bi,bj) = k |
163 |
Cml tmpfld(i,j,bi,bj) = tmpfld(i,j,bi,bj) + 1. |
164 |
Cml ENDIF |
165 |
Cml ENDDO |
166 |
Cml ENDDO |
167 |
Cml ENDDO |
168 |
CmlC - end bi,bj loops. |
169 |
Cml ENDDO |
170 |
Cml ENDDO |
171 |
|
172 |
C CALL PLOT_FIELD_XYRS( tmpfld, |
173 |
C & 'Model Depths K Index' , 1, myThid ) |
174 |
CML I assume that R_low is not changed anywhere else in the code |
175 |
CML and since it is not changed in this routine, we don't need to |
176 |
CML print it again. |
177 |
CML CALL PLOT_FIELD_XYRS(R_low, |
178 |
CML & 'Model R_low (ini_masks_etc)', 1, myThid) |
179 |
CALL PLOT_FIELD_XYRS(Ro_surf, |
180 |
& 'Model Ro_surf (update_masks_etc)', 1, myThid) |
181 |
|
182 |
C Calculate quantities derived from XY depth map |
183 |
DO bj = myByLo(myThid), myByHi(myThid) |
184 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
185 |
DO j=1-Oly,sNy+Oly |
186 |
DO i=1-Olx,sNx+Olx |
187 |
C Total fluid column thickness (r_unit) : |
188 |
tmpfld(i,j,bi,bj) = Ro_surf(i,j,bi,bj) - R_low(i,j,bi,bj) |
189 |
C Inverse of fluid column thickness (1/r_unit) |
190 |
IF ( tmpfld(i,j,bi,bj) .LE. 0. ) THEN |
191 |
recip_Rcol(i,j,bi,bj) = 0. |
192 |
ELSE |
193 |
recip_Rcol(i,j,bi,bj) = 1. / tmpfld(i,j,bi,bj) |
194 |
ENDIF |
195 |
ENDDO |
196 |
ENDDO |
197 |
ENDDO |
198 |
ENDDO |
199 |
C _EXCH_XY_R4( recip_Rcol, myThid ) |
200 |
|
201 |
C hFacW and hFacS (at U and V points) |
202 |
CML This will be the crucial part of the code, because here the minimum |
203 |
CML function MIN is involved which does not have a continuous derivative |
204 |
CML for MIN(x,y) at y=x. |
205 |
CML The thin walls representation has been moved into this loop, that is |
206 |
CML before the call to EXCH_UV_XVY_RS, because TAMC will prefer it this |
207 |
CML way. On the other hand, this might cause difficulties in some |
208 |
CML configurations. |
209 |
DO bj=myByLo(myThid), myByHi(myThid) |
210 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
211 |
DO K=1, Nr |
212 |
CML DO J=1-Oly+1,sNy+Oly |
213 |
CML DO I=1-Olx+1,sNx+Olx |
214 |
CML DO J=1,sNy+1 |
215 |
CML DO I=1,sNx+1 |
216 |
DO J=1-Oly,sNy+Oly |
217 |
DO I=1-Olx,sNx+Olx |
218 |
Im1=MAX(I-1,1-OLx) |
219 |
Jm1=MAX(J-1,1-OLy) |
220 |
IF (DYG(I,J,bi,bj).EQ.0.) THEN |
221 |
C thin walls representation of non-periodic |
222 |
C boundaries such as happen on the lat-lon grid at the N/S poles. |
223 |
C We should really supply a flag for doing this. |
224 |
hFacW(I,J,K,bi,bj)=0. |
225 |
ELSE |
226 |
Cml hFacW(I,J,K,bi,bj)= |
227 |
hFacW(I,J,K,bi,bj)=maskW(I,J,K,bi,bj)* |
228 |
#ifdef USE_SMOOTH_MIN |
229 |
& smoothMin_R4(hFacC(I,J,K,bi,bj),hFacC(Im1,J,K,bi,bj)) |
230 |
#else |
231 |
& MIN(hFacC(I,J,K,bi,bj),hFacC(Im1,J,K,bi,bj)) |
232 |
#endif /* USE_SMOOTH_MIN */ |
233 |
ENDIF |
234 |
IF (DXG(I,J,bi,bj).EQ.0.) THEN |
235 |
hFacS(I,J,K,bi,bj)=0. |
236 |
ELSE |
237 |
Cml hFacS(I,J,K,bi,bj)= |
238 |
hFacS(I,J,K,bi,bj)=maskS(I,J,K,bi,bj)* |
239 |
#ifdef USE_SMOOTH_MIN |
240 |
& smoothMin_R4(hFacC(I,J,K,bi,bj),hFacC(I,Jm1,K,bi,bj)) |
241 |
#else |
242 |
& MIN(hFacC(I,J,K,bi,bj),hFacC(I,Jm1,K,bi,bj)) |
243 |
#endif /* USE_SMOOTH_MIN */ |
244 |
ENDIF |
245 |
ENDDO |
246 |
ENDDO |
247 |
ENDDO |
248 |
ENDDO |
249 |
ENDDO |
250 |
#if (defined (ALLOW_AUTODIFF_TAMC) && \ |
251 |
defined (ALLOW_AUTODIFF_MONITOR) && \ |
252 |
defined (ALLOW_DEPTH_CONTROL)) |
253 |
C Include call to a dummy routine. Its adjoint will be |
254 |
C called at the proper place in the adjoint code. |
255 |
C The adjoint routine will print out adjoint values |
256 |
C if requested. The location of the call is important, |
257 |
C it has to be after the adjoint of the exchanges |
258 |
C (DO_GTERM_BLOCKING_EXCHANGES). |
259 |
Cml CALL DUMMY_IN_HFAC( 'W', 0, myThid ) |
260 |
Cml CALL DUMMY_IN_HFAC( 'S', 0, myThid ) |
261 |
#endif |
262 |
Cml CALL EXCH_UV_XYZ_RL(hFacW,hFacS,.FALSE.,myThid) |
263 |
CALL EXCH_UV_XYZ_RS(hFacW,hFacS,.FALSE.,myThid) |
264 |
#if (defined (ALLOW_AUTODIFF_TAMC) && \ |
265 |
defined (ALLOW_AUTODIFF_MONITOR) && \ |
266 |
defined (ALLOW_DEPTH_CONTROL)) |
267 |
C Include call to a dummy routine. Its adjoint will be |
268 |
C called at the proper place in the adjoint code. |
269 |
C The adjoint routine will print out adjoint values |
270 |
C if requested. The location of the call is important, |
271 |
C it has to be after the adjoint of the exchanges |
272 |
C (DO_GTERM_BLOCKING_EXCHANGES). |
273 |
Cml CALL DUMMY_IN_HFAC( 'W', 1, myThid ) |
274 |
Cml CALL DUMMY_IN_HFAC( 'S', 1, myThid ) |
275 |
#endif |
276 |
|
277 |
C- Write to disk: Total Column Thickness & hFac(C,W,S): |
278 |
_BARRIER |
279 |
_BEGIN_MASTER( myThid ) |
280 |
WRITE(suff,'(I10.10)') optimcycle |
281 |
CALL WRITE_FLD_XY_RS( 'Depth.',suff,tmpfld,optimcycle,myThid) |
282 |
CALL WRITE_FLD_XYZ_RS( 'hFacC.',suff,hFacC,optimcycle,myThid) |
283 |
CALL WRITE_FLD_XYZ_RS( 'hFacW.',suff,hFacW,optimcycle,myThid) |
284 |
CALL WRITE_FLD_XYZ_RS( 'hFacS.',suff,hFacS,optimcycle,myThid) |
285 |
_END_MASTER(myThid) |
286 |
|
287 |
C-- Write to monitor file (standard output) |
288 |
CALL PLOT_FIELD_XYZRS( hFacC, 'hFacC' , Nr, 1, myThid ) |
289 |
CALL PLOT_FIELD_XYZRS( hFacW, 'hFacW' , Nr, 1, myThid ) |
290 |
CALL PLOT_FIELD_XYZRS( hFacS, 'hFacS' , Nr, 1, myThid ) |
291 |
|
292 |
C Masks and reciprocals of hFac[CWS] |
293 |
Cml The masks should stay constant, so they are not recomputed at this time |
294 |
Cml implicitly implying that no cell that is wet in the begin will ever dry |
295 |
Cml up! This is a strong constraint and should be implementent as a hard |
296 |
Cml inequality contraint when performing optimization (m1qn3 cannot do that) |
297 |
Cml Also, I am assuming here that the new hFac's never become zero during |
298 |
Cml optimization! |
299 |
DO bj = myByLo(myThid), myByHi(myThid) |
300 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
301 |
DO K=1,Nr |
302 |
DO J=1-Oly,sNy+Oly |
303 |
DO I=1-Olx,sNx+Olx |
304 |
IF (hFacC(I,J,K,bi,bj) .NE. 0. ) THEN |
305 |
Cml IF (maskC(I,J,K,bi,bj) .NE. 0. ) THEN |
306 |
recip_hFacC(I,J,K,bi,bj) = 1. / hFacC(I,J,K,bi,bj) |
307 |
Cml maskC(I,J,K,bi,bj) = 1. |
308 |
ELSE |
309 |
recip_hFacC(I,J,K,bi,bj) = 0. |
310 |
Cml maskC(I,J,K,bi,bj) = 0. |
311 |
ENDIF |
312 |
IF (hFacW(I,J,K,bi,bj) .NE. 0. ) THEN |
313 |
Cml IF (maskW(I,J,K,bi,bj) .NE. 0. ) THEN |
314 |
recip_hFacW(I,J,K,bi,bj) = 1. / Hfacw(I,J,K,bi,bj) |
315 |
Cml maskW(I,J,K,bi,bj) = 1. |
316 |
ELSE |
317 |
recip_hFacW(I,J,K,bi,bj) = 0. |
318 |
Cml maskW(I,J,K,bi,bj) = 0. |
319 |
ENDIF |
320 |
IF (hFacS(I,J,K,bi,bj) .NE. 0. ) THEN |
321 |
Cml IF (maskS(I,J,K,bi,bj) .NE. 0. ) THEN |
322 |
recip_hFacS(I,J,K,bi,bj) = 1. / hFacS(I,J,K,bi,bj) |
323 |
Cml maskS(I,J,K,bi,bj) = 1. |
324 |
ELSE |
325 |
recip_hFacS(I,J,K,bi,bj) = 0. |
326 |
Cml maskS(I,J,K,bi,bj) = 0. |
327 |
ENDIF |
328 |
ENDDO |
329 |
ENDDO |
330 |
ENDDO |
331 |
CmlCml( |
332 |
Cml ENDDO |
333 |
Cml ENDDO |
334 |
Cml _EXCH_XYZ_R4(recip_hFacC , myThid ) |
335 |
Cml _EXCH_XYZ_R4(recip_hFacW , myThid ) |
336 |
Cml _EXCH_XYZ_R4(recip_hFacS , myThid ) |
337 |
Cml _EXCH_XYZ_R4(maskC , myThid ) |
338 |
Cml _EXCH_XYZ_R4(maskW , myThid ) |
339 |
Cml _EXCH_XYZ_R4(maskS , myThid ) |
340 |
Cml DO bj = myByLo(myThid), myByHi(myThid) |
341 |
Cml DO bi = myBxLo(myThid), myBxHi(myThid) |
342 |
CmlCml) |
343 |
C- Calculate surface k index for interface W & S (U & V points) |
344 |
DO J=1-Oly,sNy+Oly |
345 |
DO I=1-Olx,sNx+Olx |
346 |
ksurfW(I,J,bi,bj) = Nr+1 |
347 |
ksurfS(I,J,bi,bj) = Nr+1 |
348 |
DO k=Nr,1,-1 |
349 |
Cml IF (hFacW(I,J,K,bi,bj).NE.0.) THEN |
350 |
IF (maskW(I,J,K,bi,bj).NE.0.) THEN |
351 |
ksurfW(I,J,bi,bj) = k |
352 |
ENDIF |
353 |
Cml IF (hFacS(I,J,K,bi,bj).NE.0.) THEN |
354 |
IF (maskS(I,J,K,bi,bj).NE.0.) THEN |
355 |
ksurfS(I,J,bi,bj) = k |
356 |
|
357 |
ENDIF |
358 |
ENDDO |
359 |
ENDDO |
360 |
ENDDO |
361 |
C - end bi,bj loops. |
362 |
ENDDO |
363 |
ENDDO |
364 |
C _EXCH_XYZ_R4(recip_hFacC , myThid ) |
365 |
C _EXCH_XYZ_R4(recip_hFacW , myThid ) |
366 |
C _EXCH_XYZ_R4(recip_hFacS , myThid ) |
367 |
C _EXCH_XYZ_R4(maskW , myThid ) |
368 |
C _EXCH_XYZ_R4(maskS , myThid ) |
369 |
|
370 |
#ifdef ALLOW_NONHYDROSTATIC |
371 |
C-- Calculate the reciprocal hfac distance/volume for W cells |
372 |
DO bj = myByLo(myThid), myByHi(myThid) |
373 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
374 |
DO K=1,Nr |
375 |
Km1=max(K-1,1) |
376 |
CML Changed if-statement |
377 |
IF (Km1.EQ.K) THEN |
378 |
hFacUpper=0. |
379 |
ELSE |
380 |
hFacUpper=drF(Km1)/(drF(Km1)+drF(K)) |
381 |
ENDIF |
382 |
hFacLower=drF(K)/(drF(Km1)+drF(K)) |
383 |
DO J=1-Oly,sNy+Oly |
384 |
DO I=1-Olx,sNx+Olx |
385 |
recip_hFacU_tmp = 0. |
386 |
IF (hFacC(I,J,K,bi,bj).EQ.0.) THEN |
387 |
recip_hFacU_tmp=0. |
388 |
ELSEIF(hFacC(I,J,K,bi,bj).GT.0. |
389 |
& .AND. hFacC(I,J,K,bi,bj).LE.0.5) THEN |
390 |
recip_hFacU_tmp= |
391 |
& hFacUpper+hFacLower*hFacC(I,J,K,bi,bj) |
392 |
ELSEIF (hFacC(I,J,K,bi,bj).GT.0.5) THEN |
393 |
recip_hFacU_tmp=1. |
394 |
ELSE |
395 |
WRITE(msgBuf,'(A,3I4)') 'negative hFacC at ',I,J,K |
396 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
397 |
& SQUEEZE_RIGHT , 1) |
398 |
ENDIF |
399 |
IF (recip_hFacU_tmp.NE.0.) THEN |
400 |
recip_hFacU(I,J,K,bi,bj)=1./recip_hFacU_tmp |
401 |
ELSE |
402 |
recip_hFacU(I,J,K,bi,bj)=0. |
403 |
ENDIF |
404 |
ENDDO |
405 |
ENDDO |
406 |
ENDDO |
407 |
ENDDO |
408 |
ENDDO |
409 |
C _EXCH_XY_R4(recip_hFacU, myThid ) |
410 |
#endif |
411 |
C |
412 |
#endif /* ALLOW_DEPTH_CONTROL */ |
413 |
RETURN |
414 |
END |
415 |
|
416 |
#ifdef USE_SMOOTH_MIN |
417 |
_RS function smoothMin_R4( a, b ) |
418 |
|
419 |
implicit none |
420 |
|
421 |
_RS a, b |
422 |
|
423 |
_RS smoothAbs_R4 |
424 |
external smoothAbs_R4 |
425 |
|
426 |
Cml smoothMin_R4 = .5*(a+b) |
427 |
smoothMin_R4 = .5*( a+b - smoothAbs_R4(a-b) ) |
428 |
CML smoothMin_R4 = MIN(a,b) |
429 |
|
430 |
return |
431 |
end |
432 |
|
433 |
_RL function smoothMin_R8( a, b ) |
434 |
|
435 |
implicit none |
436 |
|
437 |
_RL a, b |
438 |
|
439 |
_RL smoothAbs_R8 |
440 |
external smoothAbs_R8 |
441 |
|
442 |
Cml smoothMin_R8 = .5*(a+b) |
443 |
smoothMin_R8 = .5*( a+b - smoothAbs_R8(a-b) ) |
444 |
Cml smoothMin_R8 = MIN(a,b) |
445 |
|
446 |
return |
447 |
end |
448 |
|
449 |
_RS function smoothAbs_R4( x ) |
450 |
|
451 |
implicit none |
452 |
C === Global variables === |
453 |
#include "SIZE.h" |
454 |
#include "EEPARAMS.h" |
455 |
#include "PARAMS.h" |
456 |
C input parameter |
457 |
_RS x |
458 |
c local variable |
459 |
_RS sf, rsf |
460 |
|
461 |
if ( smoothAbsFuncRange .lt. 0.0 ) then |
462 |
c limit of smoothMin(a,b) = .5*(a+b) |
463 |
smoothAbs_R4 = 0. |
464 |
else |
465 |
if ( smoothAbsFuncRange .ne. 0.0 ) then |
466 |
sf = 10.0/smoothAbsFuncRange |
467 |
rsf = 1./sf |
468 |
else |
469 |
c limit of smoothMin(a,b) = min(a,b) |
470 |
sf = 0. |
471 |
rsf = 0. |
472 |
end if |
473 |
c |
474 |
if ( x .gt. smoothAbsFuncRange ) then |
475 |
smoothAbs_R4 = x |
476 |
else if ( x .lt. -smoothAbsFuncRange ) then |
477 |
smoothAbs_R4 = -x |
478 |
else |
479 |
smoothAbs_R4 = log(.5*(exp(x*sf)+exp(-x*sf)))*rsf |
480 |
end if |
481 |
end if |
482 |
|
483 |
return |
484 |
end |
485 |
|
486 |
_RL function smoothAbs_R8( x ) |
487 |
|
488 |
implicit none |
489 |
C === Global variables === |
490 |
#include "SIZE.h" |
491 |
#include "EEPARAMS.h" |
492 |
#include "PARAMS.h" |
493 |
C input parameter |
494 |
_RL x |
495 |
c local variable |
496 |
_RL sf, rsf |
497 |
|
498 |
if ( smoothAbsFuncRange .lt. 0.0 ) then |
499 |
c limit of smoothMin(a,b) = .5*(a+b) |
500 |
smoothAbs_R8 = 0. |
501 |
else |
502 |
if ( smoothAbsFuncRange .ne. 0.0 ) then |
503 |
sf = 10.0D0/smoothAbsFuncRange |
504 |
rsf = 1.D0/sf |
505 |
else |
506 |
c limit of smoothMin(a,b) = min(a,b) |
507 |
sf = 0.D0 |
508 |
rsf = 0.D0 |
509 |
end if |
510 |
c |
511 |
if ( x .ge. smoothAbsFuncRange ) then |
512 |
smoothAbs_R8 = x |
513 |
else if ( x .le. -smoothAbsFuncRange ) then |
514 |
smoothAbs_R8 = -x |
515 |
else |
516 |
smoothAbs_R8 = log(.5*(exp(x*sf)+exp(-x*sf)))*rsf |
517 |
end if |
518 |
end if |
519 |
|
520 |
return |
521 |
end |
522 |
#endif /* USE_SMOOTH_MIN */ |
523 |
|
524 |
Cml#ifdef ALLOW_DEPTH_CONTROL |
525 |
Cmlcadj SUBROUTINE limit_hfacc_to_one INPUT = 1 |
526 |
Cmlcadj SUBROUTINE limit_hfacc_to_one OUTPUT = 1 |
527 |
Cmlcadj SUBROUTINE limit_hfacc_to_one ACTIVE = 1 |
528 |
Cmlcadj SUBROUTINE limit_hfacc_to_one DEPEND = 1 |
529 |
Cmlcadj SUBROUTINE limit_hfacc_to_one REQUIRED |
530 |
Cmlcadj SUBROUTINE limit_hfacc_to_one ADNAME = adlimit_hfacc_to_one |
531 |
Cml#endif /* ALLOW_DEPTH_CONTROL */ |
532 |
Cml subroutine limit_hfacc_to_one( hf ) |
533 |
Cml |
534 |
Cml _RL hf |
535 |
Cml |
536 |
Cml if ( hf .gt. 1. _d 0 ) then |
537 |
Cml hf = 1. _d 0 |
538 |
Cml endif |
539 |
Cml |
540 |
Cml return |
541 |
Cml end |
542 |
Cml |
543 |
Cml subroutine adlimit_hfacc_to_one( hf, adhf ) |
544 |
Cml |
545 |
Cml _RL hf, adhf |
546 |
Cml |
547 |
Cml return |
548 |
Cml end |
549 |
|
550 |
#ifdef ALLOW_DEPTH_CONTROL |
551 |
cadj SUBROUTINE dummy_in_hfac INPUT = 1, 2, 3 |
552 |
cadj SUBROUTINE dummy_in_hfac OUTPUT = |
553 |
cadj SUBROUTINE dummy_in_hfac ACTIVE = |
554 |
cadj SUBROUTINE dummy_in_hfac DEPEND = 1, 2, 3 |
555 |
cadj SUBROUTINE dummy_in_hfac REQUIRED |
556 |
cadj SUBROUTINE dummy_in_hfac INFLUENCED |
557 |
cadj SUBROUTINE dummy_in_hfac ADNAME = addummy_in_hfac |
558 |
cadj SUBROUTINE dummy_in_hfac FTLNAME = g_dummy_in_hfac |
559 |
#endif /* ALLOW_DEPTH_CONTROL */ |
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|