/[MITgcm]/MITgcm/pkg/thsice/thsice_solve4temp.F
ViewVC logotype

Contents of /MITgcm/pkg/thsice/thsice_solve4temp.F

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


Revision 1.12 - (show annotations) (download)
Tue Jun 20 21:33:51 2006 UTC (17 years, 11 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint58l_post, mitgcm_mapl_00, checkpoint58u_post, checkpoint58w_post, checkpoint58r_post, checkpoint58n_post, checkpoint58x_post, checkpoint58t_post, checkpoint58q_post, checkpoint58o_post, checkpoint58k_post, checkpoint58v_post, checkpoint58s_post, checkpoint58p_post, checkpoint58m_post
Changes since 1.11: +13 -11 lines
improve error messages

1 C $Header: /u/gcmpack/MITgcm/pkg/thsice/thsice_solve4temp.F,v 1.11 2006/06/06 22:10:52 jmc Exp $
2 C $Name: $
3
4 #include "THSICE_OPTIONS.h"
5
6 CBOP
7 C !ROUTINE: THSICE_SOLVE4TEMP
8 C !INTERFACE:
9 SUBROUTINE THSICE_SOLVE4TEMP(
10 I bi, bj, siLo, siHi, sjLo, sjHi,
11 I iMin,iMax, jMin,jMax, dBugFlag,
12 I useBulkForce, useEXF,
13 I iceMask, hIce, hSnow, tFrz, flxExSW,
14 U flxSW, tSrf, qIc1, qIc2,
15 O tIc1, tIc2, dTsrf,
16 O sHeat, flxCnB, flxAtm, evpAtm,
17 I myTime, myIter, myThid )
18 C !DESCRIPTION: \bv
19 C *==========================================================*
20 C | S/R THSICE_SOLVE4TEMP
21 C *==========================================================*
22 C | Solve (implicitly) for sea-ice and surface temperature
23 C *==========================================================*
24 C \ev
25
26 C ADAPTED FROM:
27 C LANL CICE.v2.0.2
28 C-----------------------------------------------------------------------
29 C.. thermodynamics (vertical physics) based on M. Winton 3-layer model
30 C.. See Bitz, C. M. and W. H. Lipscomb, 1999: "An energy-conserving
31 C.. thermodynamic sea ice model for climate study." J. Geophys.
32 C.. Res., 104, 15669 - 15677.
33 C.. Winton, M., 1999: "A reformulated three-layer sea ice model."
34 C.. Submitted to J. Atmos. Ocean. Technol.
35 C.. authors Elizabeth C. Hunke and William Lipscomb
36 C.. Fluid Dynamics Group, Los Alamos National Laboratory
37 C-----------------------------------------------------------------------
38 Cc****subroutine thermo_winton(n,fice,fsnow,dqice,dTsfc)
39 C.. Compute temperature change using Winton model with 2 ice layers, of
40 C.. which only the top layer has a variable heat capacity.
41
42 C !USES:
43 IMPLICIT NONE
44
45 C == Global variables ===
46 #include "EEPARAMS.h"
47 #include "THSICE_SIZE.h"
48 #include "THSICE_PARAMS.h"
49
50 C !INPUT/OUTPUT PARAMETERS:
51 C == Routine Arguments ==
52 C siLo,siHi :: size of input/output array: 1rst dim. lower,higher bounds
53 C sjLo,sjHi :: size of input/output array: 2nd dim. lower,higher bounds
54 C bi,bj :: tile indices
55 C iMin,iMax :: computation domain: 1rst index range
56 C jMin,jMax :: computation domain: 2nd index range
57 C dBugFlag :: allow to print debugging stuff (e.g. on 1 grid point).
58 C useBulkForce:: use surf. fluxes from bulk-forcing external S/R
59 C useEXF :: use surf. fluxes from exf external S/R
60 C--- Input:
61 C iceMask :: sea-ice fractional mask [0-1]
62 C hIce (hi) :: ice height [m]
63 C hSnow (hs) :: snow height [m]
64 C tFrz (Tf) :: sea-water freezing temperature [oC] (function of S)
65 C flxExSW (=) :: surf. heat flux (+=down) except SW, function of surf. temp Ts:
66 C 0: Flx(Ts=0) ; 1: Flx(Ts=Ts^n) ; 2: d.Flx/dTs(Ts=Ts^n)
67 C--- Modified (input&output):
68 C flxSW (netSW) :: net Short-Wave flux (+=down) [W/m2]: input= at surface
69 C (=) :: output= below sea-ice, into the ocean
70 C tSrf (Tsf) :: surface (ice or snow) temperature
71 C qIc1 (qicen) :: ice enthalpy (J/kg), 1rst level
72 C qIc2 (qicen) :: ice enthalpy (J/kg), 2nd level
73 C--- Output
74 C tIc1 (Tice) :: temperature of ice layer 1 [oC]
75 C tIc2 (Tice) :: temperature of ice layer 2 [oC]
76 C dTsrf (dTsf) :: surf. temp adjusment: Ts^n+1 - Ts^n
77 C sHeat(sHeating):: surf heating flux left to melt snow or ice (= Atmos-conduction)
78 C flxCnB (=) :: heat flux conducted through the ice to bottom surface
79 C flxAtm (=) :: net flux of energy from the atmosphere [W/m2] (+=down)
80 C without snow precip. (energy=0 for liquid water at 0.oC)
81 C evpAtm (=) :: evaporation to the atmosphere [kg/m2/s] (>0 if evaporate)
82 C--- Input:
83 C myTime :: current Time of simulation [s]
84 C myIter :: current Iteration number in simulation
85 C myThid :: my Thread Id number
86 INTEGER siLo, siHi, sjLo, sjHi
87 INTEGER bi,bj
88 INTEGER iMin, iMax
89 INTEGER jMin, jMax
90 LOGICAL dBugFlag
91 LOGICAL useBulkForce
92 LOGICAL useEXF
93 _RL iceMask(siLo:siHi,sjLo:sjHi)
94 _RL hIce (siLo:siHi,sjLo:sjHi)
95 _RL hSnow (siLo:siHi,sjLo:sjHi)
96 _RL tFrz (siLo:siHi,sjLo:sjHi)
97 _RL flxExSW(iMin:iMax,jMin:jMax,0:2)
98 _RL flxSW (siLo:siHi,sjLo:sjHi)
99 _RL tSrf (siLo:siHi,sjLo:sjHi)
100 _RL qIc1 (siLo:siHi,sjLo:sjHi)
101 _RL qIc2 (siLo:siHi,sjLo:sjHi)
102 _RL tIc1 (siLo:siHi,sjLo:sjHi)
103 _RL tIc2 (siLo:siHi,sjLo:sjHi)
104 c _RL dTsrf (siLo:siHi,sjLo:sjHi)
105 _RL dTsrf (iMin:iMax,jMin:jMax)
106 _RL sHeat (siLo:siHi,sjLo:sjHi)
107 _RL flxCnB (siLo:siHi,sjLo:sjHi)
108 _RL flxAtm (siLo:siHi,sjLo:sjHi)
109 _RL evpAtm (siLo:siHi,sjLo:sjHi)
110 _RL myTime
111 INTEGER myIter
112 INTEGER myThid
113 CEOP
114
115 #ifdef ALLOW_THSICE
116 C !LOCAL VARIABLES:
117 C--- local copy of input/output argument list variables (see description above)
118 c _RL flxExcSw(0:2)
119 _RL Tf
120 _RL hi
121 _RL hs
122 _RL netSW
123 _RL Tsf
124 _RL qicen(nlyr)
125 _RL Tice (nlyr)
126 c _RL sHeating
127 c _RL flxCnB
128 _RL dTsf
129 c _RL flxAtm
130 c _RL evpAtm
131
132 C == Local Variables ==
133 INTEGER i,j
134 INTEGER k, iterMax
135
136 _RL frsnow ! fractional snow cover
137 _RL fswpen ! SW penetrating beneath surface (W m-2)
138 _RL fswdn ! SW absorbed at surface (W m-2)
139 _RL fswint ! SW absorbed in ice (W m-2)
140 _RL fswocn ! SW passed through ice to ocean (W m-2)
141 _RL flxExceptSw ! net surface heat flux, except short-wave (W/m2)
142 C evap :: evaporation over snow/ice [kg/m2/s] (>0 if evaporate)
143 C dEvdT :: derivative of evap. with respect to Tsf [kg/m2/s/K]
144 _RL evap, dEvdT
145 _RL flx0 ! net surf heat flux, from Atmos. to sea-ice (W m-2)
146 _RL fct ! heat conducted to top surface
147 _RL df0dT ! deriv of flx0 wrt Tsf (W m-2 deg-1)
148 _RL k12, k32 ! thermal conductivity terms
149 _RL a10, b10 ! coefficients in quadratic eqn for T1
150 _RL a1, b1, c1 ! coefficients in quadratic eqn for T1
151 c _RL Tsf_start ! old value of Tsf
152 _RL dt ! timestep
153 INTEGER iceornot
154 LOGICAL useBlkFlx
155
156 C- define grid-point location where to print debugging values
157 #include "THSICE_DEBUG.h"
158
159 1010 FORMAT(A,I3,3F11.6)
160 1020 FORMAT(A,1P4E14.6)
161
162 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
163
164 useBlkFlx = useEXF .OR. useBulkForce
165
166 dt = thSIce_deltaT
167 DO j = jMin, jMax
168 DO i = iMin, iMax
169 IF ( iceMask(i,j).GT.0. _d 0) THEN
170 hi = hIce(i,j)
171 hs = hSnow(i,j)
172 Tf = tFrz(i,j)
173 netSW = flxSW(i,j)
174 Tsf = tSrf(i,j)
175 qicen(1)= qIc1(i,j)
176 qicen(2)= qIc2(i,j)
177 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
178 #ifdef ALLOW_DBUG_THSICE
179 IF ( dBug(i,j,bi,bj) ) WRITE(6,'(A,2I4,2I2)')
180 & 'ThSI_SOLVE4T: i,j=',i,j,bi,bj
181 #endif
182 IF ( hi.LT.himin ) THEN
183 C If hi < himin, melt the ice.
184 STOP 'THSICE_SOLVE4TEMP: should not enter if hi<himin'
185 ENDIF
186
187 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
188
189 C fractional snow cover
190 frsnow = 0. _d 0
191 IF (hs .GT. 0. _d 0) frsnow = 1. _d 0
192
193 C Compute SW flux absorbed at surface and penetrating to layer 1.
194 fswpen = netSW * (1. _d 0 - frsnow) * i0
195 fswocn = fswpen * exp(-ksolar*hi)
196 fswint = fswpen - fswocn
197
198 fswdn = netSW - fswpen
199
200 C Compute conductivity terms at layer interfaces.
201
202 k12 = 4. _d 0*kice*ksnow / (ksnow*hi + 4. _d 0*kice*hs)
203 k32 = 2. _d 0*kice / hi
204
205 C compute ice temperatures
206 a1 = cpice
207 b1 = qicen(1) + (cpwater-cpice )*Tmlt1 - Lfresh
208 c1 = Lfresh * Tmlt1
209 Tice(1) = 0.5 _d 0 *(-b1 - SQRT(b1*b1-4. _d 0*a1*c1))/a1
210 Tice(2) = (Lfresh-qicen(2)) / cpice
211
212 IF (Tice(1).GT.0. _d 0 ) THEN
213 WRITE (standardMessageUnit,'(A,I12,1PE14.6)')
214 & ' BBerr: Tice(1) > 0 ; it=', myIter, qicen(1)
215 WRITE (standardMessageUnit,'(A,4I5,2F11.4)')
216 & ' BBerr: i,j,bi,bj,Tice = ',i,j,bi,bj,Tice
217 ENDIF
218 IF ( Tice(2).GT.0. _d 0) THEN
219 WRITE (standardMessageUnit,'(A,I12,1PE14.6)')
220 & ' BBerr: Tice(2) > 0 ; it=', myIter, qicen(2)
221 WRITE (standardMessageUnit,'(A,4I5,2F11.4)')
222 & ' BBerr: i,j,bi,bj,Tice = ',i,j,bi,bj,Tice
223 ENDIF
224 #ifdef ALLOW_DBUG_THSICE
225 IF ( dBug(i,j,bi,bj) ) WRITE(6,1010)
226 & 'ThSI_SOLVE4T: k, Ts, Tice=',0,Tsf,Tice
227 #endif
228
229 C Compute coefficients used in quadratic formula.
230
231 a10 = rhoi*cpice *hi/(2. _d 0*dt) +
232 & k32 * (4. _d 0*dt*k32 + rhoi*cpice *hi)
233 & / (6. _d 0*dt*k32 + rhoi*cpice *hi)
234 b10 = -hi*
235 & (rhoi*cpice*Tice(1)+rhoi*Lfresh*Tmlt1/Tice(1))
236 & /(2. _d 0*dt)
237 & - k32 * (4. _d 0*dt*k32*Tf+rhoi*cpice *hi*Tice(2))
238 & / (6. _d 0*dt*k32 + rhoi*cpice *hi) - fswint
239 c1 = rhoi*Lfresh*hi*Tmlt1 / (2. _d 0*dt)
240
241 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
242 C Compute new surface and internal temperatures; iterate until
243 C Tsfc converges.
244
245 IF ( useBlkFlx ) THEN
246 iterMax = nitMaxTsf
247 ELSE
248 iterMax = 1
249 ENDIF
250 dTsf = Terrmax
251
252 C ----- begin iteration -----
253 DO k = 1,iterMax
254 IF ( ABS(dTsf).GE.Terrmax ) THEN
255
256 C Save temperatures at start of iteration.
257 c Tsf_start = Tsf
258
259 IF ( useBlkFlx ) THEN
260 C Compute top surface flux.
261 IF (hs.GT.3. _d -1) THEN
262 iceornot=2
263 ELSE
264 iceornot=1
265 ENDIF
266 IF ( useBulkForce ) THEN
267 CALL THSICE_GET_BULKF(
268 I iceornot, Tsf,
269 O flxExceptSw, df0dT, evap, dEvdT,
270 I i,j,bi,bj,myThid )
271 ELSEIF ( useEXF ) THEN
272 CALL THSICE_GET_EXF (
273 I iceornot, Tsf,
274 O flxExceptSw, df0dT, evap, dEvdT,
275 I i,j,bi,bj,myThid )
276 ENDIF
277 ELSE
278 flxExceptSw = flxExSW(i,j,1)
279 df0dT = flxExSW(i,j,2)
280 ENDIF
281 flx0 = fswdn + flxExceptSw
282 #ifdef ALLOW_DBUG_THSICE
283 IF ( dBug(i,j,bi,bj) ) WRITE(6,1020)
284 & 'ThSI_SOLVE4T: flx0,df0dT,k12,D=', flx0,df0dT,k12,k12-df0dT
285 #endif
286
287 C Compute new top layer and surface temperatures.
288 C If Tsfc is computed to be > 0 C, fix Tsfc = 0 and recompute T1
289 C with different coefficients.
290
291 a1 = a10 - k12*df0dT / (k12-df0dT)
292 b1 = b10 - k12*(flx0-df0dT*Tsf) / (k12-df0dT)
293 Tice(1) = -(b1 + SQRT(b1*b1-4. _d 0*a1*c1))/(2. _d 0*a1)
294 dTsf = (flx0 + k12*(Tice(1)-Tsf)) / (k12-df0dT)
295 Tsf = Tsf + dTsf
296 IF (Tsf .GT. 0. _d 0) THEN
297 #ifdef ALLOW_DBUG_THSICE
298 IF ( dBug(i,j,bi,bj) ) WRITE(6,1010)
299 & 'ThSI_SOLVE4T: k,ts,t1,dTs=', k,Tsf,Tice(1),dTsf
300 #endif
301 a1 = a10 + k12
302 b1 = b10 ! note b1 = b10 - k12*Tf0
303 Tice(1) = (-b1 - SQRT(b1*b1-4. _d 0*a1*c1))/(2. _d 0*a1)
304 Tsf = 0. _d 0
305 IF ( useBlkFlx ) THEN
306 IF (hs.GT.3. _d -1) THEN
307 iceornot=2
308 ELSE
309 iceornot=1
310 ENDIF
311 IF ( useBulkForce ) THEN
312 CALL THSICE_GET_BULKF(
313 I iceornot, Tsf,
314 O flxExceptSw, df0dT, evap, dEvdT,
315 I i,j,bi,bj,myThid )
316 ELSEIF ( useEXF ) THEN
317 CALL THSICE_GET_EXF (
318 I iceornot, Tsf,
319 O flxExceptSw, df0dT, evap, dEvdT,
320 I i,j,bi,bj,myThid )
321 ENDIF
322 dTsf = 0. _d 0
323 ELSE
324 flxExceptSw = flxExSW(i,j,0)
325 dTsf = 1000.
326 df0dT = 0.
327 ENDIF
328 flx0 = fswdn + flxExceptSw
329 ENDIF
330
331 C Check for convergence. If no convergence, then repeat.
332 C
333 C Convergence test: Make sure Tsfc has converged, within prescribed error.
334 C (Energy conservation is guaranteed within machine roundoff, even
335 C if Tsfc has not converged.)
336 C If no convergence, then repeat.
337
338 #ifdef ALLOW_DBUG_THSICE
339 IF ( dBug(i,j,bi,bj) ) WRITE(6,1010)
340 & 'ThSI_SOLVE4T: k,ts,t1,dTs=', k,Tsf,Tice(1),dTsf
341 #endif
342 IF ( useBlkFlx .AND. k.EQ.nitMaxTsf
343 & .AND. ABS(dTsf).GE.Terrmax ) THEN
344 WRITE (6,'(A,4I4,I12,F15.9)')
345 & ' BB: not converge: i,j,it,hi=',i,j,bi,bj,
346 & myIter,hi
347 WRITE (6,*) 'BB: not converge: Tsf, dTsf=', Tsf,dTsf
348 WRITE (6,*) 'BB: not converge: flx0,dfdT=',flx0,df0dT
349 IF (Tsf.LT.-70. _d 0) STOP
350 ENDIF
351
352 ENDIF
353 ENDDO
354 C ------ end iteration ------------
355
356 C Compute new bottom layer temperature.
357
358 Tice(2) = (2. _d 0*dt*k32*(Tice(1)+2. _d 0*Tf)
359 & + rhoi*cpice *hi*Tice(2))
360 & /(6. _d 0*dt*k32 + rhoi*cpice *hi)
361 #ifdef ALLOW_DBUG_THSICE
362 IF ( dBug(i,j,bi,bj) ) WRITE(6,1010)
363 & 'ThSI_SOLVE4T: k, Ts, Tice=',k,Tsf,Tice
364 #endif
365
366 C Compute final flux values at surfaces.
367
368 fct = k12*(Tsf-Tice(1))
369 flxCnB(i,j) = 4. _d 0*kice *(Tice(2)-Tf)/hi
370 flx0 = flx0 + df0dT*dTsf
371 IF ( useBlkFlx ) THEN
372 C-- needs to update also Evap (Tsf changes) since Latent heat has been updated
373 evpAtm(i,j) = evap + dEvdT*dTsf
374 ELSE
375 C- WARNING: Evap & +Evap*Lfresh are missing ! (but only affects Diagnostics)
376 evpAtm(i,j) = 0.
377 ENDIF
378 C- energy flux to Atmos: use net short-wave flux at surf. and
379 C use latent heat = Lvap (energy=0 for liq. water at 0.oC)
380 flxAtm(i,j) = netSW + flxExceptSw
381 & + df0dT*dTsf + evpAtm(i,j)*Lfresh
382 C- excess of energy @ surface (used for surface melting):
383 sHeat(i,j) = flx0 - fct
384
385 C- SW flux at sea-ice base left to the ocean
386 flxSW(i,j) = fswocn
387
388 #ifdef ALLOW_DBUG_THSICE
389 IF ( dBug(i,j,bi,bj) ) WRITE(6,1020)
390 & 'ThSI_SOLVE4T: flx0,fct,Dif,flxCnB=',
391 & flx0,fct,flx0-fct,flxCnB(i,j)
392 #endif
393
394 C Compute new enthalpy for each layer.
395
396 qicen(1) = -cpwater*Tmlt1 + cpice *(Tmlt1-Tice(1))
397 & + Lfresh*(1. _d 0-Tmlt1/Tice(1))
398 qicen(2) = -cpice *Tice(2) + Lfresh
399
400 C Make sure internal ice temperatures do not exceed Tmlt.
401 C (This should not happen for reasonable values of i0.)
402
403 IF (Tice(1) .GE. Tmlt1) THEN
404 WRITE (6,'(A,2I4,2I3,1P2E14.6)')
405 & ' BBerr - Bug: IceT(1) > Tmlt',i,j,bi,bj,Tice(1),Tmlt1
406 ENDIF
407 IF (Tice(2) .GE. 0. _d 0) THEN
408 WRITE (6,'(A,2I4,2I3,1P2E14.6)')
409 & ' BBerr - Bug: IceT(2) > 0',i,j,bi,bj,Tice(2)
410 ENDIF
411
412 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
413 C-- Update Sea-Ice state :
414 tSrf(i,j) = Tsf
415 tIc1(i,j) = Tice(1)
416 tic2(i,j) = Tice(2)
417 qIc1(i,j) = qicen(1)
418 qIc2(i,j) = qicen(2)
419 c dTsrf(i,j) = dTsf
420 IF ( .NOT.useBlkFlx ) dTsrf(i,j) = dTsf
421 c sHeat(i,j) = sHeating
422 c flxCnB(i,j)= flxCnB
423 c flxAtm(i,j)= flxAtm
424 c evpAtm(i,j)= evpAtm
425 #ifdef ALLOW_DBUG_THSICE
426 IF ( dBug(i,j,bi,bj) ) THEN
427 WRITE(6,1020) 'ThSI_SOLV_4T: Tsf, Tice(1,2), dTsurf=',
428 & Tsf, Tice, dTsf
429 WRITE(6,1020) 'ThSI_SOLV_4T: sHeat, flxCndBt, Qice =',
430 & sHeat(i,j), flxCnB(i,j), qicen
431 WRITE(6,1020) 'ThSI_SOLV_4T: flxA, evpA, fxSW_bf,af=',
432 & flxAtm(i,j), evpAtm(i,j), netSW, flxSW(i,j)
433 ENDIF
434 #endif
435 ELSE
436 IF ( .NOT.useBlkFlx ) dTsrf(i,j) = 0. _d 0
437 ENDIF
438 ENDDO
439 ENDDO
440 #endif /* ALLOW_THSICE */
441
442 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
443
444 RETURN
445 END

  ViewVC Help
Powered by ViewVC 1.1.22