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

Annotation of /MITgcm/pkg/thsice/thsice_calc_thickn.F

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


Revision 1.18 - (hide annotations) (download)
Tue Oct 12 16:00:19 2010 UTC (13 years, 8 months ago) by mlosch
Branch: MAIN
Changes since 1.17: +718 -550 lines
vectorization leads to major modifications
- main i,j-loops have been split into many smaller loop sections in
order to move k-loop outside of i,j-loops
- a lot of local scalar variables removed and replaced by 2D variables
- inlined thsice_reshape_layers (which has become obsolete, but not
yet removed)
- all CADJ statements are commented out, because they do not mean
anything anymore
- lot's of commented lines remain, I am not sure how many of those we
want to keep.

1 mlosch 1.18 C $Header: /u/gcmpack/MITgcm/pkg/thsice/thsice_calc_thickn.F,v 1.17 2010/03/16 00:23:59 jmc Exp $
2 jmc 1.1 C $Name: $
3    
4     #include "THSICE_OPTIONS.h"
5    
6     CBOP
7     C !ROUTINE: THSICE_CALC_THICKN
8     C !INTERFACE:
9     SUBROUTINE THSICE_CALC_THICKN(
10 jmc 1.6 I bi, bj, siLo, siHi, sjLo, sjHi,
11     I iMin,iMax, jMin,jMax, dBugFlag,
12     I iceMask, tFrz, tOce, v2oc,
13     I snowP, prcAtm, sHeat, flxCnB,
14     U icFrac, hIce, hSnow, tSrf, qIc1, qIc2,
15     U frwAtm, fzMlOc, flx2oc,
16     O frw2oc, fsalt,
17     I myTime, myIter, myThid )
18 jmc 1.1 C !DESCRIPTION: \bv
19     C *==========================================================*
20     C | S/R THSICE_CALC_THICKN
21     C | o Calculate ice & snow thickness changes
22     C *==========================================================*
23     C \ev
24 jmc 1.6 C ADAPTED FROM:
25     C LANL CICE.v2.0.2
26     C-----------------------------------------------------------------------
27     C.. thermodynamics (vertical physics) based on M. Winton 3-layer model
28 jmc 1.17 C.. See Bitz, C. M. and W. H. Lipscomb, 1999: An energy-conserving
29     C.. thermodynamic sea ice model for climate study.
30     C.. J. Geophys. Res., 104, 15669 - 15677.
31 jmc 1.6 C.. Winton, M., 1999: "A reformulated three-layer sea ice model."
32     C.. Submitted to J. Atmos. Ocean. Technol.
33     C.. authors Elizabeth C. Hunke and William Lipscomb
34     C.. Fluid Dynamics Group, Los Alamos National Laboratory
35     C-----------------------------------------------------------------------
36     Cc****subroutine thermo_winton(n,fice,fsnow,dqice,dTsfc)
37     C.. Compute temperature change using Winton model with 2 ice layers, of
38     C.. which only the top layer has a variable heat capacity.
39 jmc 1.1
40 jmc 1.9 C---------------------------------
41     C parameters that control the partitioning between lateral (ice area) and
42     C vertical (ice thickness) ice volume changes.
43 jmc 1.13 C a) surface melting and bottom melting (runtime parameter: fracEnMelt):
44 jmc 1.9 C frace is the fraction of available heat that is used for
45     C lateral melting (and 1-frace reduces the thickness ) when
46 jmc 1.13 C o hi < hThinIce & frac > lowIcFrac2 : frace=1 (lateral melting only)
47     C o hThinIce < hi < hThickIce & frac > lowIcFrac1 : frace=fracEnMelt
48     C o hi > hThickIce or frac < lowIcFrac1 : frace=0 (thinning only)
49 jmc 1.9 C b) ocean freezing (and ice forming):
50 jmc 1.13 C - conductive heat flux (below sea-ice) always increases thickness.
51     C - under sea-ice, freezing potential (x iceFraction) is used to increase ice
52     C thickness or ice fraction (lateral growth), according to:
53     C o hi < hThinIce : use freezing potential to grow ice vertically;
54     C o hThinIce < hi < hThickIce : use partition factor fracEnFreez for lateral growth
55     c and (1-fracEnFreez) to increase thickness.
56     C o hi > hThickIce : use all freezing potential to grow ice laterally
57     C (up to areaMax)
58     C - over open ocean, use freezing potential [x(1-iceFraction)] to grow ice laterally
59     C - lateral growth forms ice of the same or =hNewIceMax thickness, the less of the 2.
60     C - starts to form sea-ice over fraction iceMaskMin, as minimum ice-volume is reached
61 jmc 1.9 C---------------------------------
62 jmc 1.1 C !USES:
63     IMPLICIT NONE
64    
65     C == Global variables ===
66 mlosch 1.18 #include "SIZE.h"
67 jmc 1.4 #include "EEPARAMS.h"
68 jmc 1.1 #include "THSICE_SIZE.h"
69     #include "THSICE_PARAMS.h"
70 heimbach 1.7 #ifdef ALLOW_AUTODIFF_TAMC
71     # include "SIZE.h"
72     # include "tamc.h"
73     # include "tamc_keys.h"
74     #endif
75 jmc 1.1
76     C !INPUT/OUTPUT PARAMETERS:
77     C == Routine Arguments ==
78 jmc 1.6 C siLo,siHi :: size of input/output array: 1rst dim. lower,higher bounds
79     C sjLo,sjHi :: size of input/output array: 2nd dim. lower,higher bounds
80     C bi,bj :: tile indices
81     C iMin,iMax :: computation domain: 1rst index range
82     C jMin,jMax :: computation domain: 2nd index range
83     C dBugFlag :: allow to print debugging stuff (e.g. on 1 grid point).
84     C--- Input:
85     C iceMask :: sea-ice fractional mask [0-1]
86 mlosch 1.18 C tFrz :: sea-water freezing temperature [oC] (function of S)
87     C tOce :: surface level oceanic temperature [oC]
88     C v2oc :: square of ocean surface-level velocity [m2/s2]
89     C snowP :: snow precipitation [kg/m2/s]
90     C prcAtm :: total precip from the atmosphere [kg/m2/s]
91     C sHeat :: surf heating flux left to melt snow or ice (= Atmos-conduction)
92     C flxCnB :: heat flux conducted through the ice to bottom surface
93 jmc 1.6 C--- Modified (input&output):
94 mlosch 1.18 C icFrac :: fraction of grid area covered in ice
95     C hIce :: ice height [m]
96     C hSnow :: snow height [m]
97     C tSrf :: surface (ice or snow) temperature
98 jmc 1.6 C qIc1 (qicen) :: ice enthalpy (J/kg), 1rst level
99     C qIc2 (qicen) :: ice enthalpy (J/kg), 2nd level
100     C frwAtm (evpAtm):: evaporation to the atmosphere [kg/m2/s] (>0 if evaporate)
101 mlosch 1.18 C fzMlOc :: ocean mixed-layer freezing/melting potential [W/m2]
102     C flx2oc :: net heat flux to ocean [W/m2] (> 0 downward)
103 jmc 1.6 C--- Output
104 mlosch 1.18 C frw2oc :: Total fresh water flux to ocean [kg/m2/s] (> 0 downward)
105     C fsalt :: salt flux to ocean [g/m2/s] (> 0 downward)
106 jmc 1.6 C--- Input:
107     C myTime :: current Time of simulation [s]
108     C myIter :: current Iteration number in simulation
109     C myThid :: my Thread Id number
110     INTEGER siLo, siHi, sjLo, sjHi
111     INTEGER bi,bj
112     INTEGER iMin, iMax
113     INTEGER jMin, jMax
114     LOGICAL dBugFlag
115     _RL iceMask(siLo:siHi,sjLo:sjHi)
116     _RL tFrz (siLo:siHi,sjLo:sjHi)
117     _RL tOce (siLo:siHi,sjLo:sjHi)
118     _RL v2oc (siLo:siHi,sjLo:sjHi)
119     _RL snowP (siLo:siHi,sjLo:sjHi)
120     _RL prcAtm (siLo:siHi,sjLo:sjHi)
121     _RL sHeat (siLo:siHi,sjLo:sjHi)
122     _RL flxCnB (siLo:siHi,sjLo:sjHi)
123     _RL icFrac (siLo:siHi,sjLo:sjHi)
124     _RL hIce (siLo:siHi,sjLo:sjHi)
125     _RL hSnow (siLo:siHi,sjLo:sjHi)
126     _RL tSrf (siLo:siHi,sjLo:sjHi)
127     _RL qIc1 (siLo:siHi,sjLo:sjHi)
128     _RL qIc2 (siLo:siHi,sjLo:sjHi)
129     _RL frwAtm (siLo:siHi,sjLo:sjHi)
130     _RL fzMlOc (siLo:siHi,sjLo:sjHi)
131     _RL flx2oc (siLo:siHi,sjLo:sjHi)
132     _RL frw2oc (siLo:siHi,sjLo:sjHi)
133     _RL fsalt (siLo:siHi,sjLo:sjHi)
134     _RL myTime
135     INTEGER myIter
136     INTEGER myThid
137     CEOP
138    
139     #ifdef ALLOW_THSICE
140    
141     C !LOCAL VARIABLES:
142     C--- local copy of input/output argument list variables (see description above)
143 mlosch 1.18 _RL qicen(1-Olx:sNx+Olx,1-Oly:sNy+Oly,nlyr)
144 jmc 1.16
145 jmc 1.1 C == Local Variables ==
146 jmc 1.16 C i,j,k :: loop indices
147     C rec_nlyr :: reciprocal of number of ice layers (real value)
148 mlosch 1.18 C evapLoc :: evaporation over snow/ice [kg/m2/s] (>0 if evaporate)
149 jmc 1.16 C Fbot :: oceanic heat flux used to melt/form ice [W/m2]
150     C etop :: energy for top melting (J m-2)
151     C ebot :: energy for bottom melting (J m-2)
152     C etope :: energy (from top) for lateral melting (J m-2)
153     C ebote :: energy (from bottom) for lateral melting (J m-2)
154     C extend :: total energy for lateral melting (J m-2)
155     C hnew(nlyr) :: new ice layer thickness (m)
156     C hlyr :: individual ice layer thickness (m)
157     C dhi :: change in ice thickness
158     C dhs :: change in snow thickness
159     C rq :: rho * q for a layer
160     C rqh :: rho * q * h for a layer
161     C qbot :: enthalpy for new ice at bottom surf (J/kg)
162     C dt :: timestep
163     C esurp :: surplus energy from melting (J m-2)
164     C mwater0 :: fresh water mass gained/lost (kg/m^2)
165     C msalt0 :: salt gained/lost (kg/m^2)
166     C freshe :: fresh water gain from extension melting
167     C salte :: salt gained from extension melting
168     C lowIcFrac1 :: ice-fraction lower limit above which partial (lowIcFrac1)
169     C lowIcFrac2 :: or full (lowIcFrac2) lateral melting is allowed.
170 mlosch 1.18 C from THSICE_RESHAPE_LAYERS
171     C f1 :: Fraction of upper layer ice in new layer
172     C qh1, qh2 :: qice*h for layers 1 and 2
173     C qhtot :: qh1 + qh2
174     C q2tmp :: Temporary value of qice for layer 2
175 jmc 1.16 INTEGER i,j,k
176 mlosch 1.18 _RL rec_nlyr
177     _RL evapLoc(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
178     _RL Fbot (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
179     _RL etop (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
180     _RL ebot (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
181     _RL etope (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
182     _RL ebote (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
183     _RL esurp (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
184     _RL extend
185     _RL hnew (1-Olx:sNx+Olx,1-Oly:sNy+Oly,nlyr)
186     _RL hlyr
187     _RL dhi
188     _RL dhs
189     _RL rq
190     _RL rqh
191     _RL qbot
192     _RL dt
193     _RL mwater0 (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
194     _RL msalt0 (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
195     _RL freshe
196     _RL salte
197 jmc 1.16 _RL lowIcFrac1, lowIcFrac2
198 mlosch 1.18 _RL f1
199     _RL qh1, qh2
200     _RL qhtot
201     _RL q2tmp
202     #ifdef CHECK_ENERGY_CONSERV
203     _RL qaux(nlyr)
204     #endif /* CHECK_ENERGY_CONSERV */
205 jmc 1.1
206     _RL ustar, cpchr
207 jmc 1.16 _RL chi
208 jmc 1.1 _RL frace, rs, hq
209 jmc 1.14 #ifdef THSICE_FRACEN_POWERLAW
210     INTEGER powerLaw
211     _RL rec_pLaw
212     _RL c1Mlt, c2Mlt, aMlt, hMlt
213     _RL c1Frz, c2Frz, aFrz, hFrz
214 mlosch 1.18 _RL enFrcMlt(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
215     _RL xxMlt, tmpMlt
216     _RL enFrcFrz(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
217     _RL xxFrz, tmpFrz
218 jmc 1.14 #endif
219 jmc 1.6
220     C- define grid-point location where to print debugging values
221     #include "THSICE_DEBUG.h"
222 jmc 1.1
223     1010 FORMAT(A,I3,3F8.3)
224     1020 FORMAT(A,1P4E11.3)
225    
226 jmc 1.6 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
227    
228 mlosch 1.18 CML#ifdef ALLOW_AUTODIFF_TAMC
229     CML act1 = bi - myBxLo(myThid)
230     CML max1 = myBxHi(myThid) - myBxLo(myThid) + 1
231     CML act2 = bj - myByLo(myThid)
232     CML max2 = myByHi(myThid) - myByLo(myThid) + 1
233     CML act3 = myThid - 1
234     CML max3 = nTx*nTy
235     CML act4 = ikey_dynamics - 1
236     CML#endif /* ALLOW_AUTODIFF_TAMC */
237 heimbach 1.7
238 jmc 1.6 rec_nlyr = nlyr
239     rec_nlyr = 1. _d 0 / rec_nlyr
240 jmc 1.1 dt = thSIce_deltaT
241    
242 jmc 1.13 C for now, use hard coded threshold (iceMaskMin +1.% and +10.%)
243     lowIcFrac1 = iceMaskMin*1.01 _d 0
244     lowIcFrac2 = iceMaskMin*1.10 _d 0
245 jmc 1.14 #ifdef THSICE_FRACEN_POWERLAW
246     IF ( powerLawExp2 .GE. 1 ) THEN
247     powerLaw = 1 + 2**powerLawExp2
248     rec_pLaw = powerLaw
249     rec_pLaw = 1. _d 0 / rec_pLaw
250     C- Coef for melting:
251     C lateral-melting energy fraction = fracEnMelt - [ aMlt*(hi-hMlt) ]^powerLaw
252     c1Mlt = fracEnMelt**rec_pLaw
253     c2Mlt = (1. _d 0 - fracEnMelt)**rec_pLaw
254     aMlt = (c1Mlt+c2Mlt)/(hThickIce-hThinIce)
255     hMlt = hThinIce+c2Mlt/aMlt
256     C- Coef for freezing:
257     C thickening energy fraction = fracEnFreez - [ aFrz*(hi-hFrz) ]^powerLaw
258     c1Frz = fracEnFreez**rec_pLaw
259     c2Frz = (1. _d 0 -fracEnFreez)**rec_pLaw
260     aFrz = (c1Frz+c2Frz)/(hThickIce-hThinIce)
261     hFrz = hThinIce+c2Frz/aFrz
262     ELSE
263     C- Linear relation
264     powerLaw = 1
265     aMlt = -1. _d 0 /(hThickIce-hThinIce)
266     hMlt = hThickIce
267     aFrz = -1. _d 0 /(hThickIce-hThinIce)
268     hFrz = hThickIce
269     ENDIF
270     #endif /* THSICE_FRACEN_POWERLAW */
271    
272 jmc 1.13
273 mlosch 1.18 C initialise local arrays
274     DO j=1-Oly,sNy+Oly
275     DO i=1-Olx,sNx+Olx
276     evapLoc(i,j) = 0. _d 0
277     Fbot (i,j) = 0. _d 0
278     etop (i,j) = 0. _d 0
279     ebot (i,j) = 0. _d 0
280     etope (i,j) = 0. _d 0
281     ebote (i,j) = 0. _d 0
282     esurp (i,j) = 0. _d 0
283     mwater0(i,j) = 0. _d 0
284     msalt0 (i,j) = 0. _d 0
285     #ifdef THSICE_FRACEN_POWERLAW
286     enFrcMlt(i,j)= 0. _d 0
287     enFrcFrz(i,j)= 0. _d 0
288     #endif
289     ENDDO
290     ENDDO
291     DO k = 1,nlyr
292     DO j=1-Oly,sNy+Oly
293     DO i=1-Olx,sNx+Olx
294     hnew(i,j,k) = 0. _d 0
295     ENDDO
296     ENDDO
297     ENDDO
298    
299 jmc 1.6 DO j = jMin, jMax
300     DO i = iMin, iMax
301 mlosch 1.18 CML#ifdef ALLOW_AUTODIFF_TAMC
302     CML ikey_1 = i
303     CML & + sNx*(j-1)
304     CML & + sNx*sNy*act1
305     CML & + sNx*sNy*max1*act2
306     CML & + sNx*sNy*max1*max2*act3
307     CML & + sNx*sNy*max1*max2*max3*act4
308     CML#endif /* ALLOW_AUTODIFF_TAMC */
309 heimbach 1.7 C--
310 mlosch 1.18 CML#ifdef ALLOW_AUTODIFF_TAMC
311     CMLCADJ STORE frwatm(i,j) = comlev1_thsice_1, key=ikey_1
312     CMLCADJ STORE fzmloc(i,j) = comlev1_thsice_1, key=ikey_1
313     CMLCADJ STORE hice(i,j) = comlev1_thsice_1, key=ikey_1
314     CMLCADJ STORE hsnow(i,j) = comlev1_thsice_1, key=ikey_1
315     CMLCADJ STORE icfrac(i,j) = comlev1_thsice_1, key=ikey_1
316     CMLCADJ STORE qic1(i,j) = comlev1_thsice_1, key=ikey_1
317     CMLCADJ STORE qic2(i,j) = comlev1_thsice_1, key=ikey_1
318     CML#endif
319 heimbach 1.7
320 jmc 1.6 IF (iceMask(i,j).GT.0. _d 0) THEN
321 mlosch 1.18 qicen(i,j,1)= qIc1(i,j)
322     qicen(i,j,2)= qIc2(i,j)
323 jmc 1.6 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
324 jmc 1.1 C initialize energies
325 mlosch 1.18 esurp(i,j) = 0. _d 0
326 jmc 1.1
327 mlosch 1.18 c make a local copy of evaporation
328     evapLoc(i,j) = frwAtm(i,j)
329 jmc 1.1
330 mlosch 1.18 C------------------------------------------------------------------------
331     C-- Compute growth and/or melting at the top and bottom surfaces
332     C------------------------------------------------------------------------
333 jmc 1.1
334 jmc 1.14 #ifdef THSICE_FRACEN_POWERLAW
335 mlosch 1.18 xxMlt = aMlt*(hIce(i,j)-hMlt)
336     xxFrz = aFrz*(hIce(i,j)-hFrz)
337 jmc 1.14 c--
338     IF ( powerLawExp2 .GE. 1 ) THEN
339 mlosch 1.18 #ifdef TARGET_NEC_SX
340     C avoid the short inner loop that cannot be vectorized
341     xxMlt = xxMlt**powerLaw
342     xxFrz = xxFrz**powerLaw
343     #else
344     tmpMlt = xxMlt
345     tmpFrz = xxFrz
346     DO k=1,powerLawExp2
347     tmpMlt = tmpMlt*tmpMlt
348     tmpFrz = tmpFrz*tmpFrz
349     ENDDO
350     xxMlt = xxMlt*tmpMlt
351     xxFrz = xxFrz*tmpFrz
352     #endif /* TARGET_NEC_SX */
353     xxMlt = fracEnMelt -xxMlt
354     xxFrz = fracEnFreez-xxFrz
355 jmc 1.14 ENDIF
356 mlosch 1.18 enFrcMlt(i,j) = MAX( 0. _d 0, MIN( xxMlt, 1. _d 0 ) )
357     enFrcFrz(i,j) = MAX( 0. _d 0, MIN( xxFrz, 1. _d 0 ) )
358 jmc 1.14 #endif /* THSICE_FRACEN_POWERLAW */
359    
360 mlosch 1.18 IF (fzMlOc(i,j).GE. 0. _d 0) THEN
361 jmc 1.1 C !-----------------------------------------------------------------
362     C ! freezing conditions
363     C !-----------------------------------------------------------------
364 mlosch 1.18 Fbot(i,j) = fzMlOc(i,j)
365     IF ( icFrac(i,j).LT.iceMaskMax ) THEN
366 jmc 1.14 #ifdef THSICE_FRACEN_POWERLAW
367 mlosch 1.18 Fbot(i,j) = enFrcFrz(i,j)*fzMlOc(i,j)
368 jmc 1.14 #else /* THSICE_FRACEN_POWERLAW */
369 mlosch 1.18 IF (hIce(i,j).GT.hThickIce) THEN
370     C if higher than hThickIce, use all fzMlOc energy to grow extra ice
371     Fbot(i,j) = 0. _d 0
372     ELSEIF (hIce(i,j).GE.hThinIce) THEN
373 jmc 1.10 C between hThinIce & hThickIce, use partition factor fracEnFreez
374 mlosch 1.18 Fbot(i,j) = (1. _d 0 - fracEnFreez)*fzMlOc(i,j)
375     ENDIF
376 jmc 1.14 #endif /* THSICE_FRACEN_POWERLAW */
377 mlosch 1.18 ENDIF
378     ELSE
379 jmc 1.1 C !-----------------------------------------------------------------
380     C ! melting conditions
381     C !-----------------------------------------------------------------
382 jmc 1.16 C for no currents:
383 mlosch 1.18 ustar = 5. _d -2
384 jmc 1.1 C frictional velocity between ice and water
385 mlosch 1.18 ustar = SQRT(0.00536 _d 0*v2oc(i,j))
386     ustar=max(5. _d -3,ustar)
387     cpchr =cpWater*rhosw*bMeltCoef
388     Fbot(i,j) = cpchr*(tFrz(i,j)-tOce(i,j))*ustar
389     C fzMlOc < Fbot < 0
390     Fbot(i,j) = max(Fbot(i,j),fzMlOc(i,j))
391     Fbot(i,j) = min(Fbot(i,j),0. _d 0)
392     ENDIF
393 jmc 1.1
394     C mass of fresh water and salt initially present in ice
395 mlosch 1.18 mwater0(i,j) = rhos*hSnow(i,j) + rhoi*hIce(i,j)
396     msalt0 (i,j) = rhoi*hIce(i,j)*saltIce
397 jmc 1.1
398 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
399 mlosch 1.18 IF (dBug(i,j,bi,bj) ) WRITE(6,1020)
400     & 'ThSI_CALC_TH: evpAtm, fzMlOc, Fbot =',
401     & frwAtm(i,j),fzMlOc(i,j),Fbot(i,j)
402 jmc 1.6 #endif
403 mlosch 1.18 C endif iceMask > 0
404     ENDIF
405     C end i/j-loops
406     ENDDO
407     ENDDO
408 jmc 1.1 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
409 mlosch 1.18 DO j = jMin, jMax
410     DO i = iMin, iMax
411     IF (iceMask(i,j).GT.0. _d 0) THEN
412 jmc 1.1
413 mlosch 1.18 C Compute energy available for melting/growth.
414 jmc 1.1
415 jmc 1.14 #ifdef THSICE_FRACEN_POWERLAW
416 mlosch 1.18 IF ( fracEnMelt.EQ.0. _d 0 ) THEN
417     frace = 0. _d 0
418     ELSE
419     frace = (icFrac(i,j) - lowIcFrac1)/(lowIcFrac2-iceMaskMin)
420     frace = MIN( enFrcMlt(i,j), MAX( 0. _d 0, frace ) )
421     ENDIF
422 jmc 1.14 #else /* THSICE_FRACEN_POWERLAW */
423 mlosch 1.18 IF ( hIce(i,j).GT.hThickIce .OR. fracEnMelt.EQ.0. _d 0 ) THEN
424 jmc 1.10 C above certain height (or when no ice fractionation), only melt from top
425 mlosch 1.18 frace = 0. _d 0
426     ELSEIF (hIce(i,j).LT.hThinIce) THEN
427 jmc 1.1 C below a certain height, all energy goes to changing ice extent
428 mlosch 1.18 frace = 1. _d 0
429     ELSE
430     frace = fracEnMelt
431     ENDIF
432 jmc 1.13 C Reduce lateral melting when ice fraction is low : the purpose is to avoid
433     C disappearing of (up to hThinIce thick) sea-ice by over doing lateral melting
434 mlosch 1.18 C (which would bring icFrac below iceMaskMin).
435     IF ( icFrac(i,j).LE.lowIcFrac1 ) THEN
436     frace = 0. _d 0
437     ELSEIF (icFrac(i,j).LE.lowIcFrac2 ) THEN
438     frace = MIN( frace, fracEnMelt )
439     ENDIF
440 jmc 1.14 #endif /* THSICE_FRACEN_POWERLAW */
441 jmc 1.1
442 mlosch 1.18 c IF (tSrf(i,j) .EQ. 0. _d 0 .AND. sHeat(i,j).GT.0. _d 0) THEN
443     IF ( sHeat(i,j).GT.0. _d 0 ) THEN
444     etop(i,j) = (1. _d 0-frace)*sHeat(i,j) * dt
445     etope(i,j) = frace*sHeat(i,j) * dt
446     ELSE
447     etop(i,j) = 0. _d 0
448     etope(i,j) = 0. _d 0
449     C jmc: found few cases where tSrf=0 & sHeat < 0 : add this line to conserv energy:
450     esurp(i,j) = sHeat(i,j) * dt
451     ENDIF
452 jmc 1.6 C-- flux at the base of sea-ice:
453 jmc 1.1 C conduction H.flx= flxCnB (+ =down); oceanic turbulent H.flx= Fbot (+ =down).
454     C- ==> energy available(+ => melt)= (flxCnB-Fbot)*dt
455 mlosch 1.18 c IF (fzMlOc(i,j).LT.0. _d 0) THEN
456     c ebot(i,j) = (1. _d 0-frace)*(flxCnB-Fbot(i,j)) * dt
457     c ebote(i,j) = frace*(flxCnB-Fbot(i,j)) * dt
458 jmc 1.5 c ELSE
459 mlosch 1.18 c ebot(i,j) = (flxCnB-Fbot(i,j)) * dt
460     c ebote(i,j) = 0. _d 0
461 jmc 1.5 c ENDIF
462 jmc 1.1 C- original formulation(above): Loose energy when flxCnB < Fbot < 0
463 mlosch 1.18 ebot(i,j) = (flxCnB(i,j)-Fbot(i,j)) * dt
464     IF (ebot(i,j).GT.0. _d 0) THEN
465     ebote(i,j) = frace*ebot(i,j)
466     ebot(i,j) = ebot(i,j)-ebote(i,j)
467     ELSE
468     ebote(i,j) = 0. _d 0
469     ENDIF
470 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
471 mlosch 1.18 IF (dBug(i,j,bi,bj) ) WRITE(6,1020)
472     & 'ThSI_CALC_TH: etop,etope,ebot,ebote=',
473     & etop(i,j),etope(i,j),ebot(i,j),ebote(i,j)
474 jmc 1.6 #endif
475 mlosch 1.18 C endif iceMask > 0
476     ENDIF
477     C end i/j-loops
478     ENDDO
479     ENDDO
480 jmc 1.1
481 mlosch 1.18 C Initialize layer thicknesses. Divide total thickness equally between
482     C layers
483 jmc 1.5 DO k = 1, nlyr
484 mlosch 1.18 DO j = jMin, jMax
485     DO i = iMin, iMax
486     hnew(i,j,k) = hIce(i,j) * rec_nlyr
487     ENDDO
488     ENDDO
489 jmc 1.5 ENDDO
490 jmc 1.1
491 mlosch 1.18 DO j = jMin, jMax
492     DO i = iMin, iMax
493     CML#ifdef ALLOW_AUTODIFF_TAMC
494     CMLCADJ STORE etop(i,j) = comlev1_thsice_1, key=ikey_1
495     CML#endif
496     IF (iceMask(i,j) .GT. 0. _d 0 .AND.
497     & etop(i,j) .GT. 0. _d 0 .AND.
498     & hSnow(i,j) .GT. 0. _d 0) THEN
499    
500     C Make sure internal ice temperatures do not exceed Tmlt.
501     C If they do, then eliminate the layer. (Dont think this will happen
502     C for reasonable values of i0.)
503     C Top melt: snow, then ice.
504     rq = rhos * qsnow
505     rqh = rq * hSnow(i,j)
506     IF (etop(i,j) .LT. rqh) THEN
507     hSnow(i,j) = hSnow(i,j) - etop(i,j)/rq
508     etop(i,j) = 0. _d 0
509     ELSE
510     etop(i,j) = etop(i,j) - rqh
511     hSnow(i,j) = 0. _d 0
512 jmc 1.5 ENDIF
513 mlosch 1.18 C endif iceMask > 0, etc.
514     ENDIF
515     C end i/j-loops
516     ENDDO
517     ENDDO
518     C two layers of ice
519     DO k = 1, nlyr
520     DO j = jMin, jMax
521     DO i = iMin, iMax
522     IF (iceMask(i,j).GT.0. _d 0) THEN
523     CML#ifdef ALLOW_AUTODIFF_TAMC
524     CML ikey_2 = k
525     CML & + nlyr*(i-1)
526     CML & + nlyr*sNx*(j-1)
527     CML & + nlyr*sNx*sNy*act1
528     CML & + nlyr*sNx*sNy*max1*act2
529     CML & + nlyr*sNx*sNy*max1*max2*act3
530     CML & + nlyr*sNx*sNy*max1*max2*max3*act4
531     CML#endif
532 heimbach 1.7 C--
533 mlosch 1.18 CML#ifdef ALLOW_AUTODIFF_TAMC
534     CMLCADJ STORE etop(i,j) = comlev1_thsice_2, key=ikey_2
535     CMLCADJ STORE hnew(i,j,k) = comlev1_thsice_2, key=ikey_2
536     CML#endif
537     IF (etop(i,j) .GT. 0. _d 0) THEN
538     rq = rhoi * qicen(i,j,k)
539     rqh = rq * hnew(i,j,k)
540     IF (etop(i,j) .LT. rqh) THEN
541     hnew(i,j,k) = hnew(i,j,k) - etop(i,j) / rq
542     etop(i,j) = 0. _d 0
543     ELSE
544     etop(i,j) = etop(i,j) - rqh
545     hnew(i,j,k) = 0. _d 0
546     ENDIF
547     ELSE
548     etop(i,j)=0. _d 0
549     ENDIF
550 jmc 1.1 C If ice is gone and melting energy remains
551 mlosch 1.18 c IF (etop(i,j) .GT. 0. _d 0) THEN
552 jmc 1.5 c WRITE (6,*) 'QQ All ice melts from top ', i,j
553 mlosch 1.18 c hIce(i,j)=0. _d 0
554 jmc 1.1 c go to 200
555 jmc 1.5 c ENDIF
556 jmc 1.1
557 mlosch 1.18 C endif iceMask > 0
558     ENDIF
559     C end i/j-loops
560     ENDDO
561     ENDDO
562     C end k-loop
563     ENDDO
564 jmc 1.1
565 mlosch 1.18 DO j = jMin, jMax
566     DO i = iMin, iMax
567     IF (iceMask(i,j).GT.0. _d 0 .AND. ebot(i,j) .LT. 0. _d 0) THEN
568 jmc 1.6 C Bottom melt/growth.
569 jmc 1.1 C Compute enthalpy of new ice growing at bottom surface.
570 mlosch 1.18 qbot = -cpIce *tFrz(i,j) + Lfresh
571     dhi = -ebot(i,j) / (qbot * rhoi)
572     ebot(i,j) = 0. _d 0
573 heimbach 1.7 cph k = nlyr
574 mlosch 1.18 CML#ifdef ALLOW_AUTODIFF_TAMC
575     CMLCADJ STORE hnew(i,j,:) = comlev1_thsice_1, key=ikey_1
576     CMLCADJ STORE qicen(i,j,:) = comlev1_thsice_1, key=ikey_1
577     CML#endif
578     qicen(i,j,nlyr) =
579     & (hnew(i,j,nlyr)*qicen(i,j,nlyr)+dhi*qbot) /
580     & (hnew(i,j,nlyr)+dhi)
581     hnew(i,j,nlyr) = hnew(i,j,nlyr) + dhi
582    
583     C endif iceMask > 0 and ebot < 0
584     ENDIF
585     C end i/j-loops
586     ENDDO
587     ENDDO
588     C
589     DO k = nlyr, 1, -1
590     CML#ifdef ALLOW_AUTODIFF_TAMC
591     CML ikey_2 = (nlyr-k+1)
592     CML & + nlyr*(i-1)
593     CML & + nlyr*sNx*(j-1)
594     CML & + nlyr*sNx*sNy*act1
595     CML & + nlyr*sNx*sNy*max1*act2
596     CML & + nlyr*sNx*sNy*max1*max2*act3
597     CML & + nlyr*sNx*sNy*max1*max2*max3*act4
598     CML#endif
599     CMLC--
600     CML#ifdef ALLOW_AUTODIFF_TAMC
601     CMLCADJ STORE ebot(i,j) = comlev1_thsice_2, key=ikey_2
602     CMLCADJ STORE hnew(i,j,k) = comlev1_thsice_2, key=ikey_2
603     CMLCADJ STORE qicen(i,j,k) = comlev1_thsice_2, key=ikey_2
604     CML#endif
605     DO j = jMin, jMax
606     DO i = iMin, iMax
607     IF (iceMask(i,j) .GT. 0. _d 0 .AND.
608     & ebot(i,j) .GT. 0. _d 0 .AND.
609     & hnew(i,j,k) .GT. 0. _d 0) THEN
610     rq = rhoi * qicen(i,j,k)
611     rqh = rq * hnew(i,j,k)
612     IF (ebot(i,j) .LT. rqh) THEN
613     hnew(i,j,k) = hnew(i,j,k) - ebot(i,j) / rq
614     ebot(i,j) = 0. _d 0
615     ELSE
616     ebot(i,j) = ebot(i,j) - rqh
617     hnew(i,j,k) = 0. _d 0
618     ENDIF
619     C endif iceMask > 0 etc.
620     ENDIF
621     C end i/j-loops
622     ENDDO
623     ENDDO
624     C end k-loop
625     ENDDO
626     C If ice melts completely and snow is left, remove the snow with
627     C energy from the mixed layer
628     DO j = jMin, jMax
629     DO i = iMin, iMax
630     IF (iceMask(i,j) .GT. 0. _d 0 .AND.
631     & ebot(i,j) .GT. 0. _d 0 .AND.
632     & hSnow(i,j) .GT. 0. _d 0) THEN
633     rq = rhos * qsnow
634     rqh = rq * hSnow(i,j)
635     IF (ebot(i,j) .LT. rqh) THEN
636     hSnow(i,j) = hSnow(i,j) - ebot(i,j) / rq
637     ebot(i,j) = 0. _d 0
638     ELSE
639     ebot(i,j) = ebot(i,j) - rqh
640     hSnow(i,j) = 0. _d 0
641 jmc 1.5 ENDIF
642 mlosch 1.18 c IF (ebot(i,j) .GT. 0. _d 0) THEN
643 jmc 1.1 c IF (dBug) WRITE(6,*) 'All ice (& snow) melts from bottom'
644 mlosch 1.18 c hIce(i,j)=0. _d 0
645 jmc 1.1 c go to 200
646 jmc 1.5 c ENDIF
647 jmc 1.1
648 mlosch 1.18 C endif iceMask > 0, etc.
649     ENDIF
650     C end i/j-loops
651     ENDDO
652     ENDDO
653     DO j = jMin, jMax
654     DO i = iMin, iMax
655     IF (iceMask(i,j).GT.0. _d 0) THEN
656 jmc 1.1 C Compute new total ice thickness.
657 mlosch 1.18 hIce(i,j) = hnew(i,j,1) + hnew(i,j,2)
658 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
659 mlosch 1.18 IF (dBug(i,j,bi,bj) ) WRITE(6,1020)
660     & 'ThSI_CALC_TH: etop, ebot, hIce, hSnow =',
661     & etop(i,j), ebot(i,j), hIce(i,j), hSnow(i,j)
662 jmc 1.6 #endif
663 jmc 1.1
664 mlosch 1.18 C If hIce < hIceMin, melt the ice.
665     IF ( hIce(i,j).LT.hIceMin
666     & .AND. (hIce(i,j)+hSnow(i,j)).GT.0. _d 0 ) THEN
667     esurp(i,j) = esurp(i,j) - rhos*qsnow*hSnow(i,j)
668     & - rhoi*qicen(i,j,1)*hnew(i,j,1)
669     & - rhoi*qicen(i,j,2)*hnew(i,j,2)
670     hIce(i,j) = 0. _d 0
671     hSnow(i,j) = 0. _d 0
672     tSrf(i,j) = 0. _d 0
673     icFrac(i,j) = 0. _d 0
674     qicen(i,j,1) = 0. _d 0
675     qicen(i,j,2) = 0. _d 0
676 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
677 mlosch 1.18 IF (dBug(i,j,bi,bj) ) WRITE(6,1020)
678     & 'ThSI_CALC_TH: -1 : esurp=',esurp(i,j)
679 jmc 1.6 #endif
680 mlosch 1.18 ENDIF
681    
682     C endif iceMask > 0
683     ENDIF
684     C end i/j-loops
685     ENDDO
686     ENDDO
687     DO j = jMin, jMax
688     DO i = iMin, iMax
689     IF (iceMask(i,j).GT.0. _d 0) THEN
690 jmc 1.1
691     C-- do a mass-budget of sea-ice to compute "fresh" = the fresh-water flux
692     C that is returned to the ocean ; needs to be done before snow/evap
693 mlosch 1.18 frw2oc(i,j) = (mwater0(i,j)
694     & - (rhos*hSnow(i,j)+rhoi*hIce(i,j)))/dt
695 jmc 1.1
696 mlosch 1.18 IF ( hIce(i,j) .LE. 0. _d 0 ) THEN
697 jmc 1.5 C- return snow to the ocean (account for Latent heat of freezing)
698 mlosch 1.18 frw2oc(i,j) = frw2oc(i,j) + snowP(i,j)
699     flx2oc(i,j) = flx2oc(i,j) - snowP(i,j)*Lfresh
700     ENDIF
701    
702     C endif iceMask > 0
703     ENDIF
704     C end i/j-loops
705     ENDDO
706     ENDDO
707     C- else: hIce > 0
708     DO j = jMin, jMax
709     DO i = iMin, iMax
710     IF (iceMask(i,j).GT.0. _d 0) THEN
711 jmc 1.1
712 mlosch 1.18 IF ( hIce(i,j) .GT. 0. _d 0 ) THEN
713 jmc 1.1 C Let it snow
714 mlosch 1.18 hSnow(i,j) = hSnow(i,j) + dt*snowP(i,j)/rhos
715 jmc 1.1 C If ice evap is used to sublimate surface snow/ice or
716     C if no ice pass on to ocean
717 mlosch 1.18 CML#ifdef ALLOW_AUTODIFF_TAMC
718     CMLCADJ STORE evapLoc(i,j) = comlev1_thsice_1, key=ikey_1
719     CMLCADJ STORE hSnow(i,j) = comlev1_thsice_1, key=ikey_1
720     CML#endif
721     IF (hSnow(i,j).GT.0. _d 0) THEN
722     IF (evapLoc(i,j)/rhos *dt.GT.hSnow(i,j)) THEN
723     evapLoc(i,j)=evapLoc(i,j)-hSnow(i,j)*rhos/dt
724     hSnow(i,j)=0. _d 0
725     ELSE
726     hSnow(i,j) = hSnow(i,j) - evapLoc(i,j)/rhos *dt
727     evapLoc(i,j)=0. _d 0
728     ENDIF
729     ENDIF
730     C endif hice > 0
731 jmc 1.5 ENDIF
732 mlosch 1.18 C endif iceMask > 0
733     ENDIF
734     C end i/j-loops
735     ENDDO
736     ENDDO
737     C- else: hIce > 0
738     DO k = 1, nlyr
739     DO j = jMin, jMax
740     DO i = iMin, iMax
741     IF (iceMask(i,j).GT.0. _d 0 ) THEN
742    
743     CML#ifdef ALLOW_AUTODIFF_TAMC
744     CMLCADJ STORE evapLoc(i,j) = comlev1_thsice_1, key=ikey_1
745     CMLCADJ STORE hIce(i,j) = comlev1_thsice_1, key=ikey_1
746     CMLCADJ STORE hnew(i,j,:) = comlev1_thsice_1, key=ikey_1
747     CMLCADJ STORE qicen(i,j,:) = comlev1_thsice_1, key=ikey_1
748     CML#endif
749     IF (hIce(i,j).GT.0. _d 0.AND.evapLoc(i,j).GT.0. _d 0) THEN
750     CML#ifdef ALLOW_AUTODIFF_TAMC
751     CML ikey_2 = k
752     CML & + nlyr*(i-1)
753     CML & + nlyr*sNx*(j-1)
754     CML & + nlyr*sNx*sNy*act1
755     CML & + nlyr*sNx*sNy*max1*act2
756     CML & + nlyr*sNx*sNy*max1*max2*act3
757     CML & + nlyr*sNx*sNy*max1*max2*max3*act4
758     CML#endif
759     CMLC--
760     CML#ifdef ALLOW_AUTODIFF_TAMC
761     CMLCADJ STORE evapLoc(i,j) = comlev1_thsice_2, key=ikey_2
762     CMLCADJ STORE hnew(i,j,k) = comlev1_thsice_2, key=ikey_2
763     CMLCADJ STORE qicen(i,j,k) = comlev1_thsice_2, key=ikey_2
764     CML#endif
765     C IF (evapLoc(i,j) .GT. 0. _d 0) THEN
766 jmc 1.1 C-- original scheme, does not care about ice temp.
767     C- this can produce small error (< 1.W/m2) in the Energy budget
768 mlosch 1.18 c IF (evapLoc(i,j)/rhoi *dt.GT.hnew(i,j,k)) THEN
769     c evapLoc(i,j)=evapLoc(i,j)-hnew(i,j,k)*rhoi/dt
770     c hnew(i,j,k)=0. _d 0
771 jmc 1.5 c ELSE
772 mlosch 1.18 c hnew(i,j,k) = hnew(i,j,k) - evapLoc(i,j)/rhoi *dt
773     c evapLoc(i,j)=0. _d 0
774 jmc 1.5 c ENDIF
775 jmc 1.1 C-- modified scheme. taking into account Ice enthalpy
776 mlosch 1.18 dhi = evapLoc(i,j)/rhoi*dt
777     IF (dhi.GE.hnew(i,j,k)) THEN
778     evapLoc(i,j)=evapLoc(i,j)-hnew(i,j,k)*rhoi/dt
779     esurp(i,j) = esurp(i,j)
780     & - hnew(i,j,k)*rhoi*(qicen(i,j,k)-Lfresh)
781     hnew(i,j,k)=0. _d 0
782     ELSE
783     CML#ifdef ALLOW_AUTODIFF_TAMC
784     CMLCADJ STORE hnew(i,j,k) = comlev1_thsice_2, key=ikey_2
785     CML#endif
786     hq = hnew(i,j,k)*qicen(i,j,k)-dhi*Lfresh
787     hnew(i,j,k) = hnew(i,j,1) - dhi
788     qicen(i,j,k)=hq/hnew(i,j,k)
789     evapLoc(i,j)=0. _d 0
790     ENDIF
791 jmc 1.1 C-------
792 mlosch 1.18 c IF (evapLoc(i,j) .GT. 0. _d 0) THEN
793 jmc 1.5 c WRITE (6,*) 'BB All ice sublimates', i,j
794 mlosch 1.18 c hIce(i,j)=0. _d 0
795 jmc 1.1 c go to 200
796 jmc 1.5 c ENDIF
797 mlosch 1.18 C endif hice > 0 and evaploc > 0
798     ENDIF
799     C endif iceMask > 0
800     ENDIF
801     C end i/j-loops
802     ENDDO
803     ENDDO
804     C end k-loop
805     ENDDO
806     C still else: hice > 0
807     DO j = jMin, jMax
808     DO i = iMin, iMax
809     IF (iceMask(i,j).GT.0. _d 0) THEN
810     IF (hIce(i,j) .GT. 0. _d 0) THEN
811 jmc 1.1 C Compute new total ice thickness.
812 mlosch 1.18 hIce(i,j) = hnew(i,j,1) + hnew(i,j,2)
813     C If hIce < hIceMin, melt the ice.
814     IF ( hIce(i,j).GT.0. _d 0 .AND. hIce(i,j).LT.hIceMin ) THEN
815     frw2oc(i,j) = frw2oc(i,j)
816     & + (rhos*hSnow(i,j) + rhoi*hIce(i,j))/dt
817     esurp(i,j) = esurp(i,j) - rhos*qsnow*hSnow(i,j)
818     & - rhoi*qicen(i,j,1)*hnew(i,j,1)
819     & - rhoi*qicen(i,j,2)*hnew(i,j,2)
820     hIce(i,j) = 0. _d 0
821     hSnow(i,j) = 0. _d 0
822     tSrf(i,j) = 0. _d 0
823     icFrac(i,j) = 0. _d 0
824     qicen(i,j,1) = 0. _d 0
825     qicen(i,j,2) = 0. _d 0
826 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
827 mlosch 1.18 IF (dBug(i,j,bi,bj) ) WRITE(6,1020)
828     & 'ThSI_CALC_TH: -2 : esurp,frw2oc=',
829     & esurp(i,j), frw2oc(i,j)
830 jmc 1.6 #endif
831 mlosch 1.18 ENDIF
832 jmc 1.5
833 mlosch 1.18 C-- else hIce > 0: end
834     ENDIF
835    
836     C endif iceMask > 0
837     ENDIF
838     C end i/j-loops
839     ENDDO
840     ENDDO
841     DO j = jMin, jMax
842     DO i = iMin, iMax
843     IF (iceMask(i,j).GT.0. _d 0) THEN
844 jmc 1.5
845 mlosch 1.18 IF ( hIce(i,j) .GT. 0. _d 0 ) THEN
846 jmc 1.1
847 jmc 1.6 C If there is enough snow to lower the ice/snow interface below
848     C freeboard, convert enough snow to ice to bring the interface back
849 dfer 1.15 C to sea-level OR if snow height is larger than hsMax, snow is
850 mlosch 1.18 C converted to ice to bring hSnow down to hsMax. Largest change is
851 dfer 1.15 C applied and enthalpy of top ice layer adjusted accordingly.
852 jmc 1.1
853 mlosch 1.18 CML#ifdef ALLOW_AUTODIFF_TAMC
854     CMLCADJ STORE hIce(i,j) = comlev1_thsice_1, key=ikey_1
855     CMLCADJ STORE hSnow(i,j) = comlev1_thsice_1, key=ikey_1
856     CMLCADJ STORE hnew(i,j,:) = comlev1_thsice_1, key=ikey_1
857     CMLCADJ STORE qicen(i,j,:) = comlev1_thsice_1, key=ikey_1
858     CML#endif
859     IF ( hSnow(i,j) .GT. hIce(i,j)*floodFac
860     & .OR. hSnow(i,j) .GT. hsMax ) THEN
861 jmc 1.5 cBB WRITE (6,*) 'Freeboard adjusts'
862 mlosch 1.18 c dhi = (hSnow(i,j) * rhos - hIce(i,j) * rhoiw) / rhosw
863     c dhs = dhi * rhoi / rhos
864     dhs = (hSnow(i,j) - hIce(i,j)*floodFac) * rhoi / rhosw
865     dhs = MAX( hSnow(i,j) - hsMax, dhs )
866     dhi = dhs * rhos / rhoi
867     CML#ifdef ALLOW_AUTODIFF_TAMC
868     CMLCADJ STORE hnew(i,j,:) = comlev1_thsice_1, key=ikey_1
869     CML#endif
870     rqh = rhoi*qicen(i,j,1)*hnew(i,j,1) + rhos*qsnow*dhs
871     hnew(i,j,1) = hnew(i,j,1) + dhi
872     qicen(i,j,1) = rqh / (rhoi*hnew(i,j,1))
873     hIce(i,j) = hIce(i,j) + dhi
874     hSnow(i,j) = hSnow(i,j) - dhs
875     ENDIF
876 jmc 1.1
877    
878     C limit ice height
879     C- NOTE: this part does not conserve Energy ;
880     C but surplus of fresh water and salt are taken into account.
881 mlosch 1.18 IF (hIce(i,j).GT.hiMax) THEN
882     cBB print*,'BBerr, hIce>hiMax',i,j,hIce(i,j)
883     chi=hIce(i,j)-hiMax
884     hnew(i,j,1)=hnew(i,j,1)-chi/2. _d 0
885     hnew(i,j,2)=hnew(i,j,2)-chi/2. _d 0
886     frw2oc(i,j) = frw2oc(i,j) + chi*rhoi/dt
887     ENDIF
888     c IF (hSnow(i,j).GT.hsMax) THEN
889     cc print*,'BBerr, hSnow>hsMax',i,j,hSnow(i,j)
890     c chs=hSnow(i,j)-hsMax
891     c hSnow(i,j)=hsMax
892     c frw2oc(i,j) = frw2oc(i,j) + chs*rhos/dt
893 dfer 1.15 c ENDIF
894 jmc 1.1
895     C Compute new total ice thickness.
896 mlosch 1.18 hIce(i,j) = hnew(i,j,1) + hnew(i,j,2)
897 jmc 1.1
898 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
899 mlosch 1.18 IF (dBug(i,j,bi,bj) ) WRITE(6,1020)
900     & 'ThSI_CALC_TH: b-Winton: hnew, qice =',
901     & hnew(i,j,:), qicen(i,j,:)
902 jmc 1.6 #endif
903    
904 mlosch 1.18 hlyr = hIce(i,j) * rec_nlyr
905     CML CALL THSICE_RESHAPE_LAYERS(
906     CML U qicen(i,j,:),
907     CML I hlyr, hnew(i,j,:), myThid )
908     C inlined version of S/R THSICE_RESHAPE_LAYERS
909     C | Repartition into equal-thickness layers, conserving energy.
910     C *==========================================================*
911     C | This is the 2-layer version (formerly "NEW_LAYERS_WINTON")
912     C | from M. Winton 1999, JAOT, sea-ice model.
913     if (hnew(i,j,1).gt.hnew(i,j,2)) then
914     C-- Layer 1 gives ice to layer 2
915     f1 = (hnew(i,j,1)-hlyr)/hlyr
916     q2tmp = f1*qicen(i,j,1) + (1. _d 0-f1)*qicen(i,j,2)
917     if (q2tmp.gt.Lfresh) then
918     qicen(i,j,2) = q2tmp
919     else
920     C- Keep q2 fixed to avoid q2<Lfresh and T2>0
921     qh2 = hlyr*qicen(i,j,2)
922     qhtot = hnew(i,j,1)*qicen(i,j,1) + hnew(i,j,2)*qicen(i,j,2)
923     qh1 = qhtot - qh2
924     qicen(i,j,1) = qh1/hlyr
925     endif
926     else
927     C- Layer 2 gives ice to layer 1
928     f1 = hnew(i,j,1)/hlyr
929     qicen(i,j,1) = f1*qicen(i,j,1) + (1. _d 0-f1)*qicen(i,j,2)
930     endif
931     C end of inlined S/R THSICE_RESHAPE_LAYERS
932 jmc 1.1
933 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
934 mlosch 1.18 IF (dBug(i,j,bi,bj) ) WRITE(6,1020)
935     & 'ThSI_CALC_TH: icFrac,hIce, qtot, hSnow =',
936     & icFrac(i,j),hIce(i,j), (qicen(i,j,1)+qicen(i,j,2))*0.5,
937     & hSnow(i,j)
938 jmc 1.6 #endif
939 jmc 1.1
940 mlosch 1.18 C- if hIce > 0 : end
941     ENDIF
942     200 CONTINUE
943 jmc 1.1
944 mlosch 1.18 C endif iceMask > 0
945     ENDIF
946     C end i/j-loops
947     ENDDO
948     ENDDO
949     DO j = jMin, jMax
950     DO i = iMin, iMax
951     IF (iceMask(i,j).GT.0. _d 0) THEN
952 jmc 1.1 C- Compute surplus energy left over from melting.
953    
954 mlosch 1.18 IF (hIce(i,j).LE.0. _d 0) icFrac(i,j)=0. _d 0
955 jmc 1.1
956     C.. heat fluxes left over for ocean
957 mlosch 1.18 flx2oc(i,j) = flx2oc(i,j)
958     & + (Fbot(i,j)+(esurp(i,j)+etop(i,j)+ebot(i,j))/dt)
959 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
960 mlosch 1.18 IF (dBug(i,j,bi,bj) ) WRITE(6,1020)
961     & 'ThSI_CALC_TH: [esurp,etop+ebot]/dt =',
962     & esurp(i,j)/dt,etop(i,j)/dt,ebot(i,j)/dt
963 jmc 1.6 #endif
964 jmc 1.1
965 mlosch 1.18 C-- Evaporation left to the ocean :
966     frw2oc(i,j) = frw2oc(i,j) - evapLoc(i,j)
967     C-- Correct Atmos. fluxes for this different latent heat:
968     C evap was computed over freezing surf.(tSrf<0), latent heat = Lvap+Lfresh
969     C but should be Lvap only for the fraction "evap" that is left to the ocean.
970     flx2oc(i,j) = flx2oc(i,j) + evapLoc(i,j)*Lfresh
971 jmc 1.1
972     C fresh and salt fluxes
973 mlosch 1.18 c frw2oc(i,j) = (mwater0(i,j) - (rhos*(hSnow(i,j))
974     c & + rhoi*(hIce(i,j))))/dt-evapLoc(i,j)
975     c fsalt = (msalt0(i,j) - rhoi*hIce(i,j)*saltIce)/35. _d 0/dt ! for same units as frw2oc
976     C note (jmc): frw2oc is computed from a sea-ice mass budget that already
977     C contains, at this point, snow & evaporation (of snow & ice)
978     C but are not meant to be part of ice/ocean fresh-water flux.
979     C fix: a) like below or b) by making the budget before snow/evap is added
980     c frw2oc(i,j) = (mwater0(i,j) - (rhos*(hSnow(i,j)) + rhoi*(hIce(i,j))))/dt
981 jmc 1.6 c & + snow(i,j,bi,bj)*rhos - frwAtm
982 mlosch 1.18 fsalt(i,j) = (msalt0(i,j) - rhoi*hIce(i,j)*saltIce)/dt
983 jmc 1.1
984 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
985 mlosch 1.18 IF (dBug(i,j,bi,bj) ) THEN
986     WRITE(6,1020)'ThSI_CALC_TH:dH2O,Ev[kg],frw2oc,fsalt',
987     & (mwater0(i,j)-(rhos*hSnow(i,j)+rhoi*hIce(i,j)))/dt,
988     & evapLoc(i,j),frw2oc(i,j),fsalt(i,j)
989     WRITE(6,1020)'ThSI_CALC_TH: flx2oc,Fbot,extend/dt =',
990     & flx2oc(I,J),Fbot(i,j),(etope(i,j)+ebote(i,j))/dt
991     ENDIF
992 jmc 1.6 #endif
993 jmc 1.1
994 mlosch 1.18 C-- add remaining liquid Precip (rain+RunOff) directly to ocean:
995     frw2oc(i,j) = frw2oc(i,j) + (prcAtm(i,j)-snowP(i,j))
996 jmc 1.6
997 mlosch 1.18 C endif iceMask > 0
998     ENDIF
999     C end i/j-loops
1000     ENDDO
1001     ENDDO
1002     DO j = jMin, jMax
1003     DO i = iMin, iMax
1004     IF (iceMask(i,j).GT.0. _d 0) THEN
1005     C-- note: at this point, icFrac has not been changed (unless reset to zero)
1006     C and it can only be reduced by lateral melting in the following part:
1007 jmc 1.1
1008 mlosch 1.18 C calculate extent changes
1009     extend=etope(i,j)+ebote(i,j)
1010     IF (icFrac(i,j).GT.0. _d 0.AND.extend.GT.0. _d 0) THEN
1011     rq = rhoi * 0.5 _d 0*(qicen(i,j,1)+qicen(i,j,2))
1012     rs = rhos * qsnow
1013     rqh = rq * hIce(i,j) + rs * hSnow(i,j)
1014     freshe=(rhos*hSnow(i,j)+rhoi*hIce(i,j))/dt
1015     salte=(rhoi*hIce(i,j)*saltIce)/dt
1016     IF ( extend.LT.rqh ) THEN
1017     icFrac(i,j)=(1. _d 0-extend/rqh)*icFrac(i,j)
1018     ENDIF
1019     IF ( extend.LT.rqh .AND. icFrac(i,j).GE.iceMaskMin ) THEN
1020     frw2oc(i,j)=frw2oc(i,j)+extend/rqh*freshe
1021 jmc 1.6 fsalt(i,j)=fsalt(i,j)+extend/rqh*salte
1022 mlosch 1.18 ELSE
1023     icFrac(i,j)=0. _d 0
1024     hIce(i,j) =0. _d 0
1025     hSnow(i,j) =0. _d 0
1026     flx2oc(i,j)=flx2oc(i,j)+(extend-rqh)/dt
1027     frw2oc(i,j)=frw2oc(i,j)+freshe
1028 jmc 1.6 fsalt(i,j)=fsalt(i,j)+salte
1029 mlosch 1.18 ENDIF
1030     ELSEIF (extend.GT.0. _d 0) THEN
1031     flx2oc(i,j)=flx2oc(i,j)+extend/dt
1032 jmc 1.5 ENDIF
1033 mlosch 1.18 C endif iceMask > 0
1034     ENDIF
1035     C end i/j-loops
1036     ENDDO
1037     ENDDO
1038     DO j = jMin, jMax
1039     DO i = iMin, iMax
1040     IF (iceMask(i,j).GT.0. _d 0) THEN
1041 jmc 1.6 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
1042 mlosch 1.18 C-- Update output variables :
1043 jmc 1.6
1044 mlosch 1.18 C-- Diagnostic of Atmos. fresh water flux (E-P) over sea-ice :
1045 jmc 1.6 C substract precip from Evap (<- stored in frwAtm array)
1046 mlosch 1.18 frwAtm(i,j) = frwAtm(i,j) - prcAtm(i,j)
1047 jmc 1.6
1048 mlosch 1.18 C-- update Mixed-Layer Freezing potential heat flux by substracting the
1049     C part which has already been accounted for (Fbot):
1050     fzMlOc(i,j) = fzMlOc(i,j) - Fbot(i,j)*iceMask(i,j)
1051 jmc 1.6
1052 mlosch 1.18 C-- Update Sea-Ice state output:
1053     qIc1(i,j) = qicen(i,j,1)
1054     qIc2(i,j) = qicen(i,j,2)
1055 jmc 1.6 #ifdef ALLOW_DBUG_THSICE
1056 mlosch 1.18 IF (dBug(i,j,bi,bj) ) WRITE(6,1020)
1057     & 'ThSI_CALC_TH: icFrac,flx2oc,fsalt,frw2oc=',
1058     & icFrac(i,j), flx2oc(i,j), fsalt(i,j), frw2oc(i,j)
1059 jmc 1.6 #endif
1060 mlosch 1.18 C endif iceMask > 0
1061     ENDIF
1062     ENDDO
1063     ENDDO
1064 jmc 1.6 #ifdef CHECK_ENERGY_CONSERV
1065     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
1066 mlosch 1.18 DO j = jMin, jMax
1067     DO i = iMin, iMax
1068     IF (iceMask(i,j).GT.0. _d 0) THEN
1069     qaux(1)=qIc1(i,j)
1070     qaux(2)=qIc2(i,j)
1071     CALL THSICE_CHECK_CONSERV( dBugFlag, i, j, bi, bj, 0,
1072     I iceMask(i,j), icFrac(i,j), hIce(i,j), hSnow(i,j),
1073     I qaux,
1074     I flx2oc(i,j), frw2oc(i,j), fsalt,
1075     I myTime, myIter, myThid )
1076     C endif iceMask > 0
1077 jmc 1.6 ENDIF
1078 mlosch 1.18 C end i/j-loops
1079 jmc 1.6 ENDDO
1080     ENDDO
1081 mlosch 1.18 #endif /* CHECK_ENERGY_CONSERV */
1082    
1083 jmc 1.1 #endif /* ALLOW_THSICE */
1084    
1085     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
1086    
1087     RETURN
1088     END

  ViewVC Help
Powered by ViewVC 1.1.22