/[MITgcm]/MITgcm_contrib/verification_other/shelfice_remeshing/code/shelfice_thermodynamics.F
ViewVC logotype

Annotation of /MITgcm_contrib/verification_other/shelfice_remeshing/code/shelfice_thermodynamics.F

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


Revision 1.1 - (hide annotations) (download)
Fri Dec 11 19:48:32 2015 UTC (9 years, 7 months ago) by dgoldberg
Branch: MAIN
CVS Tags: checkpoint65r
shelfice_remeshing verification

1 dgoldberg 1.1 C $Header: /u/gcmpack/MITgcm_contrib/shelfice_remeshing/CLEAN/code/shelfice_thermodynamics.F,v 1.2 2015/12/07 22:05:50 dgoldberg Exp $
2     C $Name: $
3    
4     #include "SHELFICE_OPTIONS.h"
5     #ifdef ALLOW_AUTODIFF
6     # include "AUTODIFF_OPTIONS.h"
7     #endif
8     #ifdef ALLOW_CTRL
9     # include "CTRL_OPTIONS.h"
10     #endif
11    
12     CBOP
13     C !ROUTINE: SHELFICE_THERMODYNAMICS
14     C !INTERFACE:
15     SUBROUTINE SHELFICE_THERMODYNAMICS(
16     I myTime, myIter, myThid )
17     C !DESCRIPTION: \bv
18     C *=============================================================*
19     C | S/R SHELFICE_THERMODYNAMICS
20     C | o shelf-ice main routine.
21     C | compute temperature and (virtual) salt flux at the
22     C | shelf-ice ocean interface
23     C |
24     C | stresses at the ice/water interface are computed in separate
25     C | routines that are called from mom_fluxform/mom_vecinv
26     C *=============================================================*
27     C \ev
28    
29     C !USES:
30     IMPLICIT NONE
31    
32     C === Global variables ===
33     #include "SIZE.h"
34     #include "EEPARAMS.h"
35     #include "PARAMS.h"
36     #include "GRID.h"
37     #include "DYNVARS.h"
38     #include "FFIELDS.h"
39     #include "SHELFICE.h"
40     #include "SHELFICE_COST.h"
41     #ifdef ALLOW_AUTODIFF
42     # include "CTRL_SIZE.h"
43     # include "ctrl.h"
44     # include "ctrl_dummy.h"
45     #endif /* ALLOW_AUTODIFF */
46     #ifdef ALLOW_AUTODIFF_TAMC
47     # ifdef SHI_ALLOW_GAMMAFRICT
48     # include "tamc.h"
49     # include "tamc_keys.h"
50     # endif /* SHI_ALLOW_GAMMAFRICT */
51     #endif /* ALLOW_AUTODIFF_TAMC */
52     #ifdef ALLOW_STREAMICE
53     # include "STREAMICE.h"
54     #endif /* ALLOW_STREAMICE */
55    
56     C !INPUT/OUTPUT PARAMETERS:
57     C === Routine arguments ===
58     C myIter :: iteration counter for this thread
59     C myTime :: time counter for this thread
60     C myThid :: thread number for this instance of the routine.
61     _RL myTime
62     INTEGER myIter
63     INTEGER myThid
64    
65     #ifdef ALLOW_SHELFICE
66     C !LOCAL VARIABLES :
67     C === Local variables ===
68     C I,J,K,Kp1,bi,bj :: loop counters
69     C tLoc, sLoc, pLoc :: local in-situ temperature, salinity, pressure
70     C theta/saltFreeze :: temperature and salinity of water at the
71     C ice-ocean interface (at the freezing point)
72     C freshWaterFlux :: local variable for fresh water melt flux due
73     C to melting in kg/m^2/s
74     C (negative density x melt rate)
75     C convertFW2SaltLoc:: local copy of convertFW2Salt
76     C cFac :: 1 for conservative form, 0, otherwise
77     C rFac :: realFreshWaterFlux factor
78     C dFac :: 0 for diffusive heat flux (Holland and Jenkins, 1999,
79     C eq21)
80     C 1 for advective and diffusive heat flux (eq22, 26, 31)
81     C fwflxFac :: only effective for dFac=1, 1 if we expect a melting
82     C fresh water flux, 0 otherwise
83     C auxiliary variables and abbreviations:
84     C a0, a1, a2, b, c0
85     C eps1, eps2, eps3, eps3a, eps4, eps5, eps6, eps7, eps8
86     C aqe, bqe, cqe, discrim, recip_aqe
87     C drKp1, recip_drLoc
88     INTEGER I,J,K,Kp1,kp2
89     INTEGER bi,bj
90     _RL tLoc(1:sNx,1:sNy)
91     _RL sLoc(1:sNx,1:sNy)
92     _RL pLoc(1:sNx,1:sNy)
93     _RL uLoc(1:sNx,1:sNy)
94     _RL vLoc(1:sNx,1:sNy)
95     _RL u_topdr(1:sNx+1,1:sNy+1,nSx,nSy)
96     _RL v_topdr(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
97     _RL thetaFreeze, saltFreeze, recip_Cp
98     _RL freshWaterFlux, convertFW2SaltLoc
99     _RL a0, a1, a2, b, c0
100     _RL eps1, eps2, eps3, eps3a, eps4, eps5, eps6, eps7, eps8
101     _RL cFac, rFac, dFac, fwflxFac, realfwFac
102     _RL aqe, bqe, cqe, discrim, recip_aqe
103     _RL drKp1, drKp2, recip_drLoc
104     _RL recip_latentHeat
105     _RL tmpFac
106     _RL SHICEHAF
107     _RL SHC,SHW,SHA,FACTOR1,FACTOR2,FACTOR3
108     #ifdef SHI_ALLOW_GAMMAFRICT
109     _RL shiPr, shiSc, shiLo, recip_shiKarman, shiTwoThirds
110     _RL gammaTmoleT, gammaTmoleS, gammaTurb, gammaTurbConst
111     _RL ustar, ustarSq, etastar
112     PARAMETER ( shiTwoThirds = 0.66666666666666666666666666667D0 )
113     #ifdef ALLOW_DIAGNOSTICS
114     _RL uStarDiag(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
115     #endif /* ALLOW_DIAGNOSTICS */
116     #endif
117    
118     #ifndef ALLOW_OPENAD
119     _RL SW_TEMP
120     EXTERNAL SW_TEMP
121     #endif
122    
123     #ifdef ALLOW_SHIFWFLX_CONTROL
124     _RL xx_shifwflx_loc(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy)
125     #endif
126     CEOP
127     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
128    
129     #ifdef SHI_ALLOW_GAMMAFRICT
130     #ifdef ALLOW_AUTODIFF
131     C re-initialize here again, curtesy to TAF
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     shiTransCoeffT(i,j,bi,bj) = SHELFICEheatTransCoeff
137     shiTransCoeffS(i,j,bi,bj) = SHELFICEsaltTransCoeff
138     ENDDO
139     ENDDO
140     ENDDO
141     ENDDO
142     #endif /* ALLOW_AUTODIFF */
143     IF ( SHELFICEuseGammaFrict ) THEN
144     C Implement friction velocity-dependent transfer coefficient
145     C of Holland and Jenkins, JPO, 1999
146     recip_shiKarman= 1. _d 0 / 0.4 _d 0
147     shiLo = 0. _d 0
148     shiPr = shiPrandtl**shiTwoThirds
149     shiSc = shiSchmidt**shiTwoThirds
150     cph shiPr = (viscArNr(1)/diffKrNrT(1))**shiTwoThirds
151     cph shiSc = (viscArNr(1)/diffKrNrS(1))**shiTwoThirds
152     gammaTmoleT = 12.5 _d 0 * shiPr - 6. _d 0
153     gammaTmoleS = 12.5 _d 0 * shiSc - 6. _d 0
154     C instead of etastar = sqrt(1+zetaN*ustar./(f*Lo*Rc))
155     etastar = 1. _d 0
156     gammaTurbConst = 1. _d 0 / (2. _d 0 * shiZetaN*etastar)
157     & - recip_shiKarman
158     #ifdef ALLOW_AUTODIFF
159     DO bj = myByLo(myThid), myByHi(myThid)
160     DO bi = myBxLo(myThid), myBxHi(myThid)
161     DO J = 1-OLy,sNy+OLy
162     DO I = 1-OLx,sNx+OLx
163     shiTransCoeffT(i,j,bi,bj) = 0. _d 0
164     shiTransCoeffS(i,j,bi,bj) = 0. _d 0
165     ENDDO
166     ENDDO
167     ENDDO
168     ENDDO
169     #endif /* ALLOW_AUTODIFF */
170     ENDIF
171     #endif /* SHI_ALLOW_GAMMAFRICT */
172    
173     recip_latentHeat = 0. _d 0
174     IF ( SHELFICElatentHeat .NE. 0. _d 0 )
175     & recip_latentHeat = 1. _d 0/SHELFICElatentHeat
176     C are we doing the conservative form of Jenkins et al. (2001)?
177     recip_Cp = 1. _d 0 / HeatCapacity_Cp
178     cFac = 0. _d 0
179     IF ( SHELFICEconserve ) cFac = 1. _d 0
180    
181     realFWfac = 0. _d 0
182     IF ( SHELFICErealFWflux ) realFWfac = 1. _d 0
183     C with "real fresh water flux" (affecting ETAN),
184     C there is more to modify
185     rFac = 1. _d 0
186     IF ( SHELFICEconserve .AND. useRealFreshWaterFlux ) rFac = 0. _d 0
187     C heat flux into the ice shelf, default is diffusive flux
188     C (Holland and Jenkins, 1999, eq.21)
189     dFac = 0. _d 0
190     IF ( SHELFICEadvDiffHeatFlux ) dFac = 1. _d 0
191     fwflxFac = 0. _d 0
192     C linear dependence of freezing point on salinity
193     a0 = -0.0575 _d 0
194     a1 = 0.0 _d -0
195     a2 = 0.0 _d -0
196     c0 = 0.0901 _d 0
197     b = -7.61 _d -4
198     #ifdef ALLOW_ISOMIP_TD
199     IF ( useISOMIPTD ) THEN
200     C non-linear dependence of freezing point on salinity
201     a0 = -0.0575 _d 0
202     a1 = 1.710523 _d -3
203     a2 = -2.154996 _d -4
204     b = -7.53 _d -4
205     c0 = 0. _d 0
206     ENDIF
207     convertFW2SaltLoc = convertFW2Salt
208     C hardcoding this value here is OK because it only applies to ISOMIP
209     C where this value is part of the protocol
210     IF ( convertFW2SaltLoc .EQ. -1. ) convertFW2SaltLoc = 33.4 _d 0
211     #endif /* ALLOW_ISOMIP_TD */
212    
213     DO bj = myByLo(myThid), myByHi(myThid)
214     DO bi = myBxLo(myThid), myBxHi(myThid)
215     DO J = 1-OLy,sNy+OLy
216     DO I = 1-OLx,sNx+OLx
217     shelfIceHeatFlux (I,J,bi,bj) = 0. _d 0
218     shelfIceFreshWaterFlux(I,J,bi,bj) = 0. _d 0
219     shelficeForcingT (I,J,bi,bj) = 0. _d 0
220     shelficeForcingS (I,J,bi,bj) = 0. _d 0
221     #if (defined SHI_ALLOW_GAMMAFRICT && defined ALLOW_DIAGNOSTICS)
222     uStarDiag (I,J,bi,bj) = 0. _d 0
223     #endif /* SHI_ALLOW_GAMMAFRICT and ALLOW_DIAGNOSTICS */
224     ENDDO
225     ENDDO
226     ENDDO
227     ENDDO
228     #ifdef ALLOW_SHIFWFLX_CONTROL
229     DO bj = myByLo(myThid), myByHi(myThid)
230     DO bi = myBxLo(myThid), myBxHi(myThid)
231     DO J = 1-OLy,sNy+OLy
232     DO I = 1-OLx,sNx+OLx
233     xx_shifwflx_loc(I,J,bi,bj) = 0. _d 0
234     ENDDO
235     ENDDO
236     ENDDO
237     ENDDO
238     #ifdef ALLOW_CTRL
239     if (useCTRL) CALL CTRL_GET_GEN (
240     & xx_shifwflx_file, xx_shifwflxstartdate, xx_shifwflxperiod,
241     & maskSHI, xx_shifwflx_loc, xx_shifwflx0, xx_shifwflx1,
242     & xx_shifwflx_dummy,
243     & xx_shifwflx_remo_intercept, xx_shifwflx_remo_slope,
244     & wshifwflx,
245     & myTime, myIter, myThid )
246     #endif
247     #endif /* ALLOW_SHIFWFLX_CONTROL */
248     DO bj = myByLo(myThid), myByHi(myThid)
249     DO bi = myBxLo(myThid), myBxHi(myThid)
250    
251     IF ( SHELFICEBoundaryLayer ) THEN
252     C-- average over boundary layer width
253     DO J = 1, sNy+1
254     DO I = 1, sNx+1
255     u_topdr(I,J,bi,bj) = 0.0
256     v_topdr(I,J,bi,bj) = 0.0
257     ENDDO
258     ENDDO
259     ENDIF
260    
261     #ifdef ALLOW_AUTODIFF_TAMC
262     # ifdef SHI_ALLOW_GAMMAFRICT
263     act1 = bi - myBxLo(myThid)
264     max1 = myBxHi(myThid) - myBxLo(myThid) + 1
265     act2 = bj - myByLo(myThid)
266     max2 = myByHi(myThid) - myByLo(myThid) + 1
267     act3 = myThid - 1
268     max3 = nTx*nTy
269     act4 = ikey_dynamics - 1
270     ikey = (act1 + 1) + act2*max1
271     & + act3*max1*max2
272     & + act4*max1*max2*max3
273     # endif /* SHI_ALLOW_GAMMAFRICT */
274     #endif /* ALLOW_AUTODIFF_TAMC */
275     DO J = 1, sNy
276     DO I = 1, sNx
277     C-- make local copies of temperature, salinity and depth (pressure in deci-bar)
278     C-- underneath the ice
279     K = MAX(1,kTopC(I,J,bi,bj))
280     pLoc(I,J) = ABS(R_shelfIce(I,J,bi,bj))
281     c pLoc(I,J) = shelficeMass(I,J,bi,bj)*gravity*1. _d -4
282     tLoc(I,J) = theta(I,J,K,bi,bj)
283     sLoc(I,J) = MAX(salt(I,J,K,bi,bj), zeroRL)
284     IF ( .not.SHELFICEBoundaryLayer ) THEN
285     uLoc(I,J) = recip_hFacC(I,J,K,bi,bj) *
286     & ( uVel(I, J,K,bi,bj) * _hFacW(I, J,K,bi,bj)
287     & + uVel(I+1,J,K,bi,bj) * _hFacW(I+1,J,K,bi,bj) )
288     vLoc(I,J) = recip_hFacC(I,J,K,bi,bj) *
289     & ( vVel(I, J,K,bi,bj) * _hFacS(I, J,K,bi,bj)
290     & + vVel(I,J+1,K,bi,bj) * _hFacS(I,J+1,K,bi,bj) )
291     ENDIF
292     ENDDO
293     ENDDO
294    
295     ! IF ( SHELFICEBoundaryLayer ) THEN
296     ! DO J = 1, sNy+1
297     ! DO I = 1, sNx+1
298     !
299     ! K = ksurfW(I,J,bi,bj)
300     ! Kp1 = K+1
301     ! Kp2 = K+2
302     !
303     ! IF (ShelficeThickBoundaryLayer .and.
304     ! & (K.ne.0.and.K.LT.Nr-1)) THEN
305     !
306     ! drKp1 = drF(K)*( 1.5 - _hFacW(I,J,K,bi,bj) )
307     ! drKp2 = drKp1 - drF(kp1)*_hFacW(I,J,kp1,bi,bj)
308     ! drKp2 = MAX( drKp2, 0. _d 0)
309     ! drKp2 = MIN( drKp2,
310     ! & drF(kp2)*_hFacW(I,J,kp2,bi,bj))
311     ! drKp1 = drKp1 - drKp2
312     ! drKp1 = MAX( drKp1, 0. _d 0)
313     ! recip_drLoc = 1. _d 0 /
314     ! & (drF(K)*_hFacW(I,J,K,bi,bj)+drKp1+drKp2)
315     ! u_topdr(I,J,bi,bj) =
316     ! & (drF(K)*_hFacW(I,J,K,bi,bj)*uVel(I,J,K,bi,bj) +
317     ! & drKp1*uVel(I,J,Kp1,bi,bj)) * recip_drLoc
318     ! u_topdr(I,J,bi,bj) = u_topdr(I,J,bi,bj) +
319     ! & drKp2 * uVel(I,J,Kp2,bi,bj) * recip_drLoc
320     !
321     ! ELSEIF ( (K .NE. 0 .AND. K.EQ.Nr-1) .OR.
322     ! & (.not.SHELFICEthickboundarylayer.AND.
323     ! & (K .NE. 0 .AND. K .LT. Nr) ) ) THEN
324     !
325     ! drKp1 = drF(K)*(1. _d 0-_hFacW(I,J,K,bi,bj))
326     ! drKp1 = max (drKp1, 0. _d 0)
327     ! recip_drLoc = 1.0 /
328     ! & (drF(K)*_hFacW(I,J,K,bi,bj)+drKp1)
329     ! u_topdr(I,J,bi,bj) =
330     ! & (drF(K)*_hFacW(I,J,K,bi,bj)*uVel(I,J,K,bi,bj) +
331     ! & drKp1*uVel(I,J,Kp1,bi,bj))
332     ! & * recip_drLoc
333     !
334     ! ELSE
335     !
336     ! u_topdr(I,J,bi,bj) = 0. _d 0
337     !
338     ! ENDIF
339     !
340     ! K = ksurfS(I,J,bi,bj)
341     ! Kp1 = K+1
342     ! Kp2 = K+2
343     !
344     ! IF (ShelficeThickBoundaryLayer .and.
345     ! & (K.ne.0.and.K.LT.Nr-1)) THEN
346     !
347     ! drKp1 = drF(K)*( 1.5 - _hFacS(I,J,K,bi,bj) )
348     ! drKp2 = drKp1 - drF(kp1)*_hFacS(I,J,kp1,bi,bj)
349     ! drKp2 = MAX( drKp2, 0. _d 0)
350     ! drKp2 = MIN( drKp2,
351     ! & drF(kp2)*_hFacS(I,J,kp2,bi,bj))
352     ! drKp1 = drKp1 - drKp2
353     ! drKp1 = MAX( drKp1, 0. _d 0)
354     ! recip_drLoc = 1. _d 0 /
355     ! & (drF(K)*_hFacS(I,J,K,bi,bj)+drKp1+drKp2)
356     ! v_topdr(I,J,bi,bj) =
357     ! & (drF(K)*_hFacS(I,J,K,bi,bj)*vVel(I,J,K,bi,bj) +
358     ! & drKp1*vVel(I,J,Kp1,bi,bj)) * recip_drLoc
359     ! v_topdr(I,J,bi,bj) = v_topdr(I,J,bi,bj) +
360     ! & drKp2 * vVel(I,J,Kp2,bi,bj) * recip_drLoc
361     !
362     ! ELSEIF ( (K .NE. 0 .AND. K.EQ.Nr-1) .OR.
363     ! & ((.NOT.SHELFICEthickboundarylayer).AND.
364     ! & (K .NE. 0 .AND. K .LT. Nr) ) ) THEN
365     !
366     ! drKp1 = drF(K)*(1. _d 0-_hFacS(I,J,K,bi,bj))
367     ! drKp1 = max (drKp1, 0. _d 0)
368     ! recip_drLoc = 1.0 /
369     ! & (drF(K)*_hFacS(I,J,K,bi,bj)+drKp1)
370     ! v_topdr(I,J,bi,bj) =
371     ! & (drF(K)*_hFacS(I,J,K,bi,bj)*vVel(I,J,K,bi,bj) +
372     ! & drKp1*vVel(I,J,Kp1,bi,bj))
373     ! & * recip_drLoc
374     !
375     ! ELSE
376     !
377     ! v_topdr(I,J,bi,bj) = 0. _d 0
378     !
379     ! ENDIF
380     !
381     ! ENDDO
382     ! ENDDO
383     ! ENDIF
384    
385     IF ( SHELFICEBoundaryLayer ) THEN
386     DO J = 1, sNy+1
387     DO I = 1, sNx+1
388     K = ksurfW(I,J,bi,bj)
389     Kp1 = K+1
390     IF (K.lt.Nr) then
391     drKp1 = drF(K)*(1. _d 0-_hFacW(I,J,K,bi,bj))
392     drKp1 = max (drKp1, 0. _d 0)
393     recip_drLoc = 1.0 /
394     & (drF(K)*_hFacW(I,J,K,bi,bj)+drKp1)
395     u_topdr(I,J,bi,bj) =
396     & (drF(K)*_hFacW(I,J,K,bi,bj)*uVel(I,J,K,bi,bj) +
397     & drKp1*uVel(I,J,Kp1,bi,bj))
398     & * recip_drLoc
399     ELSE
400     u_topdr(I,J,bi,bj) = 0. _d 0
401     ENDIF
402    
403     K = ksurfS(I,J,bi,bj)
404     Kp1 = K+1
405     IF (K.lt.Nr) then
406     drKp1 = drF(K)*(1. _d 0-_hFacS(I,J,K,bi,bj))
407     drKp1 = max (drKp1, 0. _d 0)
408     recip_drLoc = 1.0 /
409     & (drF(K)*_hFacS(I,J,K,bi,bj)+drKp1)
410     v_topdr(I,J,bi,bj) =
411     & (drF(K)*_hFacS(I,J,K,bi,bj)*vVel(I,J,K,bi,bj) +
412     & drKp1*vVel(I,J,Kp1,bi,bj))
413     & * recip_drLoc
414     ELSE
415     v_topdr(I,J,bi,bj) = 0. _d 0
416     ENDIF
417    
418     ENDDO
419     ENDDO
420     ENDIF
421    
422     IF ( SHELFICEBoundaryLayer ) THEN
423     C-- average over boundary layer width
424     DO J = 1, sNy
425     DO I = 1, sNx
426     K = kTopC(I,J,bi,bj)
427     IF ( K .NE. 0 .AND. K .LT. Nr ) THEN
428     Kp1 = MIN(Nr,K+1)
429     C-- overlap into lower cell
430     drKp1 = drF(K)*( 1. _d 0 - _hFacC(I,J,K,bi,bj) )
431     C-- Dans fix
432     drKp1 = MAX(drKp1, 0.)
433     C-- lower cell may not be as thick as required
434     drKp1 = MIN( drKp1, drF(Kp1) * _hFacC(I,J,Kp1,bi,bj) )
435     recip_drLoc = 1. _d 0 /
436     & ( drF(K)*_hFacC(I,J,K,bi,bj) + drKp1 )
437     tLoc(I,J) = ( tLoc(I,J) * drF(K)*_hFacC(I,J,K,bi,bj)
438     & + theta(I,J,Kp1,bi,bj) *drKp1 )
439     & * recip_drLoc
440     sLoc(I,J) = ( sLoc(I,J) * drF(K)*_hFacC(I,J,K,bi,bj)
441     & + MAX(salt(I,J,Kp1,bi,bj), zeroRL) * drKp1 )
442     & * recip_drLoc
443    
444     ! uLoc(I,J) = ( uLoc(I,J) * drF(K)*_hFacC(I,J,K,bi,bj)
445     ! & + drKp1 * recip_hFacC(I,J,Kp1,bi,bj) *
446     ! & ( uVel(I, J,Kp1,bi,bj) * _hFacW(I, J,Kp1,bi,bj)
447     ! & + uVel(I+1,J,Kp1,bi,bj) * _hFacW(I+1,J,Kp1,bi,bj) )
448     ! & ) * recip_drLoc
449     ! vLoc(I,J) = ( vLoc(I,J) * drF(K)*_hFacC(I,J,K,bi,bj)
450     ! & + drKp1 * recip_hFacC(I,J,Kp1,bi,bj) *
451     ! & ( vVel(I,J, Kp1,bi,bj) * _hFacS(I,J, Kp1,bi,bj)
452     ! & + vVel(I,J+1,Kp1,bi,bj) * _hFacS(I,J+1,Kp1,bi,bj) )
453     ! & ) * recip_drLoc
454     ENDIF
455     ENDDO
456     ENDDO
457     ENDIF
458    
459    
460     IF ( SHELFICEBoundaryLayer ) THEN
461     DO J = 1, sNy
462     DO I = 1, sNx
463     uLoc(I,J) =
464     & u_topdr(I,J,bi,bj) + u_topdr(I+1,J,bi,bj)
465     vLoc(I,J) =
466     & v_topdr(I,J,bi,bj) + v_topdr(I,J+1,bi,bj)
467     ENDDO
468     ENDDO
469     ENDIF
470    
471     C-- turn potential temperature into in-situ temperature relative
472     C-- to the surface
473     DO J = 1, sNy
474     DO I = 1, sNx
475     #ifndef ALLOW_OPENAD
476     tLoc(I,J) = SW_TEMP(sLoc(I,J),tLoc(I,J),pLoc(I,J),zeroRL)
477     #else
478     CALL SW_TEMP(sLoc(I,J),tLoc(I,J),pLoc(I,J),zeroRL,tLoc(I,J))
479     #endif
480     ENDDO
481     ENDDO
482    
483     #ifdef SHI_ALLOW_GAMMAFRICT
484     IF ( SHELFICEuseGammaFrict ) THEN
485     DO J = 1, sNy
486     DO I = 1, sNx
487     K = kTopC(I,J,bi,bj)
488     IF ( K .NE. 0 .AND. pLoc(I,J) .GT. 0. _d 0 ) THEN
489     ustarSq = shiCdrag * MAX( 1.D-6,
490     & 0.25 _d 0 *(uLoc(I,J)*uLoc(I,J)+vLoc(I,J)*vLoc(I,J)) )
491     ustar = SQRT(ustarSq)
492     #ifdef ALLOW_DIAGNOSTICS
493     uStarDiag(I,J,bi,bj) = ustar
494     #endif /* ALLOW_DIAGNOSTICS */
495     C instead of etastar = sqrt(1+zetaN*ustar./(f*Lo*Rc))
496     C etastar = 1. _d 0
497     C gammaTurbConst = 1. _d 0 / (2. _d 0 * shiZetaN*etastar)
498     C & - recip_shiKarman
499     IF ( fCori(I,J,bi,bj) .NE. 0. _d 0 ) THEN
500     gammaTurb = LOG( ustarSq * shiZetaN * etastar**2
501     & / ABS(fCori(I,J,bi,bj) * 5.0 _d 0 * shiKinVisc))
502     & * recip_shiKarman
503     & + gammaTurbConst
504     C Do we need to catch the unlikely case of very small ustar
505     C that can lead to negative gammaTurb?
506     C gammaTurb = MAX(0.D0, gammaTurb)
507     ELSE
508     gammaTurb = gammaTurbConst
509     ENDIF
510     shiTransCoeffT(i,j,bi,bj) = MAX( zeroRL,
511     & ustar/(gammaTurb + gammaTmoleT) )
512     shiTransCoeffS(i,j,bi,bj) = MAX( zeroRL,
513     & ustar/(gammaTurb + gammaTmoleS) )
514     ENDIF
515     ENDDO
516     ENDDO
517     ENDIF
518     #endif /* SHI_ALLOW_GAMMAFRICT */
519    
520    
521    
522     c DO bj = myByLo(myThid), myByHi(myThid)
523     c DO bi = myBxLo(myThid), myBxHi(myThid)
524     DO j=1-OLy,sNy+OLy
525     DO i=1-OLx,sNx+OLx
526     IF (R_shelfice(i,j,bi,bj) .EQ. R_Grounding(i,j,bi,bj))THEN
527     shiTransCoeffT(i,j,bi,bj)=0
528     shiTransCoeffS (i,j,bi,bj)=0
529     ENDIF
530     ENDDO
531     ENDDO
532     c ENDDO
533     c ENDDO
534    
535    
536    
537     #ifdef ALLOW_AUTODIFF_TAMC
538     # ifdef SHI_ALLOW_GAMMAFRICT
539     CADJ STORE shiTransCoeffS(:,:,bi,bj) = comlev1_bibj,
540     CADJ & key=ikey, byte=isbyte
541     CADJ STORE shiTransCoeffT(:,:,bi,bj) = comlev1_bibj,
542     CADJ & key=ikey, byte=isbyte
543     # endif /* SHI_ALLOW_GAMMAFRICT */
544     #endif /* ALLOW_AUTODIFF_TAMC */
545     #ifdef ALLOW_ISOMIP_TD
546     IF ( useISOMIPTD ) THEN
547     DO J = 1, sNy
548     DO I = 1, sNx
549     K = kTopC(I,J,bi,bj)
550     IF ( K .NE. 0 .AND. pLoc(I,J) .GT. 0. _d 0 ) THEN
551     C-- Calculate freezing temperature as a function of salinity and pressure
552     thetaFreeze =
553     & sLoc(I,J) * ( a0 + a1*sqrt(sLoc(I,J)) + a2*sLoc(I,J) )
554     & + b*pLoc(I,J) + c0
555     C-- Calculate the upward heat and fresh water fluxes
556     shelfIceHeatFlux(I,J,bi,bj) = maskC(I,J,K,bi,bj)
557     & * shiTransCoeffT(i,j,bi,bj)
558     & * ( tLoc(I,J) - thetaFreeze )
559     & * HeatCapacity_Cp*rUnit2mass
560     #ifdef ALLOW_SHIFWFLX_CONTROL
561     & - xx_shifwflx_loc(I,J,bi,bj)*SHELFICElatentHeat
562     #endif /* ALLOW_SHIFWFLX_CONTROL */
563     C upward heat flux into the shelf-ice implies basal melting,
564     C thus a downward (negative upward) fresh water flux (as a mass flux),
565     C and vice versa
566     shelfIceFreshWaterFlux(I,J,bi,bj) =
567     & - shelfIceHeatFlux(I,J,bi,bj)
568     & *recip_latentHeat
569     C-- compute surface tendencies
570     shelficeForcingT(i,j,bi,bj) =
571     & - shelfIceHeatFlux(I,J,bi,bj)
572     & *recip_Cp*mass2rUnit
573     & - cFac * shelfIceFreshWaterFlux(I,J,bi,bj)*mass2rUnit
574     & * ( thetaFreeze - tLoc(I,J) )
575     shelficeForcingS(i,j,bi,bj) =
576     & shelfIceFreshWaterFlux(I,J,bi,bj) * mass2rUnit
577     & * ( cFac*sLoc(I,J) + (1. _d 0-cFac)*convertFW2SaltLoc )
578     C-- stress at the ice/water interface is computed in separate
579     C routines that are called from mom_fluxform/mom_vecinv
580     ELSE
581     shelfIceHeatFlux (I,J,bi,bj) = 0. _d 0
582     shelfIceFreshWaterFlux(I,J,bi,bj) = 0. _d 0
583     shelficeForcingT (I,J,bi,bj) = 0. _d 0
584     shelficeForcingS (I,J,bi,bj) = 0. _d 0
585     ENDIF
586     ENDDO
587     ENDDO
588     ELSE
589     #else
590     IF ( .TRUE. ) THEN
591     #endif /* ALLOW_ISOMIP_TD */
592     C use BRIOS thermodynamics, following Hellmers PhD thesis:
593     C Hellmer, H., 1989, A two-dimensional model for the thermohaline
594     C circulation under an ice shelf, Reports on Polar Research, No. 60
595     C (in German).
596    
597     DO J = 1, sNy
598     DO I = 1, sNx
599     K = kTopC(I,J,bi,bj)
600     IF ( K .NE. 0 .AND. pLoc(I,J) .GT. 0. _d 0 ) THEN
601     C heat flux into the ice shelf, default is diffusive flux
602     C (Holland and Jenkins, 1999, eq.21)
603     thetaFreeze = a0*sLoc(I,J)+c0+b*pLoc(I,J)
604     fwflxFac = 0. _d 0
605     IF ( tLoc(I,J) .GT. thetaFreeze ) fwflxFac = dFac
606     C a few abbreviations
607     eps1 = rUnit2mass*HeatCapacity_Cp
608     & *shiTransCoeffT(i,j,bi,bj)
609     eps2 = rUnit2mass*SHELFICElatentHeat
610     & *shiTransCoeffS(i,j,bi,bj)
611     eps5 = rUnit2mass*HeatCapacity_Cp
612     & *shiTransCoeffS(i,j,bi,bj)
613    
614     C solve quadratic equation for salinity at shelfice-ocean interface
615     C note: this part of the code is not very intuitive as it involves
616     C many arbitrary abbreviations that were introduced to derive the
617     C correct form of the quadratic equation for salinity. The abbreviations
618     C only make sense in connection with my notes on this (M.Losch)
619     C
620     C eps3a was introduced as a constant variant of eps3 to avoid AD of
621     C code of typ (pLoc-const)/pLoc
622     eps3a = rhoShelfIce*SHELFICEheatCapacity_Cp
623     & * SHELFICEkappa * ( 1. _d 0 - dFac )
624     eps3 = eps3a/pLoc(I,J)
625     eps4 = b*pLoc(I,J) + c0
626     eps6 = eps4 - tLoc(I,J)
627     eps7 = eps4 - SHELFICEthetaSurface
628     eps8 = rUnit2mass*SHELFICEheatCapacity_Cp
629     & *shiTransCoeffS(i,j,bi,bj) * fwflxFac
630     aqe = a0 *(eps1+eps3-eps8)
631     recip_aqe = 0. _d 0
632     IF ( aqe .NE. 0. _d 0 ) recip_aqe = 0.5 _d 0/aqe
633     c bqe = eps1*eps6 + eps3*eps7 - eps2
634     bqe = eps1*eps6
635     & + eps3a*( b
636     & + ( c0 - SHELFICEthetaSurface )/pLoc(I,J) )
637     & - eps2
638     & + eps8*( a0*sLoc(I,J) - eps7 )
639     cqe = ( eps2 + eps8*eps7 )*sLoc(I,J)
640     discrim = bqe*bqe - 4. _d 0*aqe*cqe
641     #undef ALLOW_SHELFICE_DEBUG
642     #ifdef ALLOW_SHELFICE_DEBUG
643     IF ( discrim .LT. 0. _d 0 ) THEN
644     print *, 'ml-shelfice: discrim = ', discrim,aqe,bqe,cqe
645     print *, 'ml-shelfice: pLoc = ', pLoc(I,J)
646     print *, 'ml-shelfice: tLoc = ', tLoc(I,J)
647     print *, 'ml-shelfice: sLoc = ', sLoc(I,J)
648     print *, 'ml-shelfice: tsurface= ',
649     & SHELFICEthetaSurface
650     print *, 'ml-shelfice: eps1 = ', eps1
651     print *, 'ml-shelfice: eps2 = ', eps2
652     print *, 'ml-shelfice: eps3 = ', eps3
653     print *, 'ml-shelfice: eps4 = ', eps4
654     print *, 'ml-shelfice: eps5 = ', eps5
655     print *, 'ml-shelfice: eps6 = ', eps6
656     print *, 'ml-shelfice: eps7 = ', eps7
657     print *, 'ml-shelfice: eps8 = ', eps8
658     print *, 'ml-shelfice: rU2mass = ', rUnit2mass
659     print *, 'ml-shelfice: rhoIce = ', rhoShelfIce
660     print *, 'ml-shelfice: cFac = ', cFac
661     print *, 'ml-shelfice: Cp_W = ', HeatCapacity_Cp
662     print *, 'ml-shelfice: Cp_I = ',
663     & SHELFICEHeatCapacity_Cp
664     print *, 'ml-shelfice: gammaT = ',
665     & SHELFICEheatTransCoeff
666     print *, 'ml-shelfice: gammaS = ',
667     & SHELFICEsaltTransCoeff
668     print *, 'ml-shelfice: lat.heat= ',
669     & SHELFICElatentHeat
670     STOP 'ABNORMAL END in S/R SHELFICE_THERMODYNAMICS'
671     ENDIF
672     #endif /* ALLOW_SHELFICE_DEBUG */
673     saltFreeze = (- bqe - SQRT(discrim))*recip_aqe
674     IF ( saltFreeze .LT. 0. _d 0 )
675     & saltFreeze = (- bqe + SQRT(discrim))*recip_aqe
676     thetaFreeze = a0*saltFreeze + eps4
677     C-- upward fresh water flux due to melting (in kg/m^2/s)
678     cph change to identical form
679     cph freshWaterFlux = rUnit2mass
680     cph & * shiTransCoeffS(i,j,bi,bj)
681     cph & * ( saltFreeze - sLoc(I,J) ) / saltFreeze
682     freshWaterFlux = rUnit2mass
683     & * shiTransCoeffS(i,j,bi,bj)
684     & * ( 1. _d 0 - sLoc(I,J) / saltFreeze )
685     #ifdef ALLOW_SHIFWFLX_CONTROL
686     & + xx_shifwflx_loc(I,J,bi,bj)
687     #endif /* ALLOW_SHIFWFLX_CONTROL */
688     C-- Calculate the upward heat and fresh water fluxes;
689     C-- MITgcm sign conventions: downward (negative) fresh water flux
690     C-- implies melting and due to upward (positive) heat flux
691     shelfIceHeatFlux(I,J,bi,bj) =
692     & ( eps3
693     & - freshWaterFlux*SHELFICEheatCapacity_Cp*fwflxFac )
694     & * ( thetaFreeze - SHELFICEthetaSurface )
695     & - cFac*freshWaterFlux*( SHELFICElatentHeat
696     & - HeatCapacity_Cp*( thetaFreeze - rFac*tLoc(I,J) ) )
697     shelfIceFreshWaterFlux(I,J,bi,bj) = freshWaterFlux
698     C-- compute surface tendencies
699     shelficeForcingT(i,j,bi,bj) =
700     & ( shiTransCoeffT(i,j,bi,bj)
701     & - cFac*shelfIceFreshWaterFlux(I,J,bi,bj)*mass2rUnit )
702     & * ( thetaFreeze - tLoc(I,J) )
703     & - realFWfac*shelfIceFreshWaterFlux(I,J,bi,bj)*
704     & mass2rUnit*
705     & ( tLoc(I,J) - theta(I,J,K,bi,bj) )
706     shelficeForcingS(i,j,bi,bj) =
707     & ( shiTransCoeffS(i,j,bi,bj)
708     & - cFac*shelfIceFreshWaterFlux(I,J,bi,bj)*mass2rUnit )
709     & * ( saltFreeze - sLoc(I,J) )
710     & - realFWfac*shelfIceFreshWaterFlux(I,J,bi,bj)*
711     & mass2rUnit*
712     & ( sLoc(I,J) - salt(I,J,K,bi,bj) )
713     ELSE
714     shelfIceHeatFlux (I,J,bi,bj) = 0. _d 0
715     shelfIceFreshWaterFlux(I,J,bi,bj) = 0. _d 0
716     shelficeForcingT (I,J,bi,bj) = 0. _d 0
717     shelficeForcingS (I,J,bi,bj) = 0. _d 0
718     ENDIF
719     ENDDO
720     ENDDO
721     ENDIF
722     C endif (not) useISOMIPTD
723     ENDDO
724     ENDDO
725    
726     IF (SHELFICEMassStepping) THEN
727     CALL SHELFICE_STEP_ICEMASS( myTime, myIter, myThid )
728     ENDIF
729    
730     C-- Calculate new loading anomaly (in case the ice-shelf mass was updated)
731     #ifndef ALLOW_AUTODIFF
732     c IF ( SHELFICEloadAnomalyFile .EQ. ' ' ) THEN
733    
734     c print *, 'JJBEF',gravity*(shelficemass(2,30,1,1)
735     c & +rhoconst*ro_surf(2,30,1,1))
736     c print *, 'JJBEF',gravity*(shelficemass(2,230,1,1)
737     c & +rhoconst*ro_surf(2,230,1,1))
738    
739     c print *, 'JJBEF',gravity*(shelficemass(2,330,1,1)
740     c & +rhoconst*ro_surf(2,330,1,1))
741    
742    
743    
744    
745    
746     c DO bj = myByLo(myThid), myByHi(myThid)
747     c DO bi = myBxLo(myThid), myBxHi(myThid)
748     c DO j = 1-OLy, sNy+OLy
749     c DO i = 1-OLx, sNx+OLx
750     c shelficeLoadAnomaly(i,j,bi,bj) = gravity
751     c & *( shelficeMass(i,j,bi,bj) + rhoConst*Ro_surf(i,j,bi,bj) )
752     c#ifdef ALLOW_STREAMICE
753     c IF ( R_shelfice(i,j,bi,bj) .EQ. R_grounding(i,j,bi,bj) ) THEN
754     c
755     c if(i==1) then
756     c print * ,'JRJ1',i,j,shelficeloadanomaly(i,j,bi,bj),
757     c & FACTOR1,FACTOR2,FACTOR3
758     c endif
759    
760     c SHICEHAF=H_streamice(i,j,bi,bj)+R_low(i,j,bi,bj)
761     c & *(streamice_density_ocean_avg/streamice_density)
762    
763     ! SHICEHAF=SHICEHAF-((990*streamice_density_ocean_avg/
764     ! & streamice_density)-990)
765    
766     c
767     c SHA=SHELFICEGroundC/
768     c & SQRT(.01+shelficeLoadAnomaly(i,j,bi,bj)**2)
769     c
770     c FACTOR1 = (1-SHA)/2.
771     c FACTOR2 = (1+SHA)/2.
772     c FACTOR3 = tanh(SHELFICEGroundW/2.-
773     c & 8*SHICEHAF/SHELFICEGroundW)
774     c
775     c shelficeLoadAnomaly(i,j,bi,bj)=
776     c & (FACTOR1*FACTOR3 + FACTOR2)*
777     c & shelficeLoadAnomaly(i,j,bi,bj)
778     c
779     c if(i==1) then
780     c print * ,'JRJ2',i,j,shelficeloadanomaly(i,j,bi,bj),
781     c & FACTOR1,FACTOR2,FACTOR3
782     c endif
783    
784     c ENDIF
785     c#endif /* ALLOW_STREAMICE */
786     c
787     cc ENDDO
788     c c ENDDO
789     c c ENDDO
790     c ENDDO
791     c ENDIF
792    
793     c print *, 'JJHAF', (H_streamice(2,30,1,1)+R_low(2,30,1,1))
794     c & *(streamice_density_ocean_avg/streamice_density)
795    
796    
797    
798     c print *, 'JJSLA',shelficeloadanomaly(2,30,1,1)
799     c print *, 'JJSLA',shelficeloadanomaly(2,230,1,1)
800     c print *, 'JJSLA',shelficeloadanomaly(2,330,1,1)
801     c print *, 'JJETAN', etaN(2,30,1,1)
802    
803    
804    
805    
806     #endif /* ndef ALLOW_AUTODIFF */
807    
808     #ifdef ALLOW_DIAGNOSTICS
809     IF ( useDiagnostics ) THEN
810     CALL DIAGNOSTICS_FILL_RS(shelfIceFreshWaterFlux,'SHIfwFlx',
811     & 0,1,0,1,1,myThid)
812     CALL DIAGNOSTICS_FILL_RS(shelfIceHeatFlux, 'SHIhtFlx',
813     & 0,1,0,1,1,myThid)
814     C SHIForcT (Ice shelf forcing for theta [W/m2], >0 increases theta)
815     tmpFac = HeatCapacity_Cp*rUnit2mass
816     CALL DIAGNOSTICS_SCALE_FILL(shelficeForcingT,tmpFac,1,
817     & 'SHIForcT',0,1,0,1,1,myThid)
818     C SHIForcS (Ice shelf forcing for salt [g/m2/s], >0 increases salt)
819     tmpFac = rUnit2mass
820     CALL DIAGNOSTICS_SCALE_FILL(shelficeForcingS,tmpFac,1,
821     & 'SHIForcS',0,1,0,1,1,myThid)
822     C Transfer coefficients
823     CALL DIAGNOSTICS_FILL(shiTransCoeffT,'SHIgammT',
824     & 0,1,0,1,1,myThid)
825     CALL DIAGNOSTICS_FILL(shiTransCoeffS,'SHIgammS',
826     & 0,1,0,1,1,myThid)
827     C Friction velocity
828     #ifdef SHI_ALLOW_GAMMAFRICT
829     IF ( SHELFICEuseGammaFrict )
830     & CALL DIAGNOSTICS_FILL(uStarDiag,'SHIuStar',0,1,0,1,1,myThid)
831     #endif /* SHI_ALLOW_GAMMAFRICT */
832     ENDIF
833     CALL DIAGNOSTICS_FILL(R_shelfice,'SHI_Rshelfice',
834     & 0,1,0,1,1,myThid)
835    
836    
837     #endif /* ALLOW_DIAGNOSTICS */
838    
839     #endif /* ALLOW_SHELFICE */
840     RETURN
841     END

  ViewVC Help
Powered by ViewVC 1.1.22