/[MITgcm]/MITgcm_contrib/torge/itd/code/seaice_growth.F
ViewVC logotype

Diff of /MITgcm_contrib/torge/itd/code/seaice_growth.F

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

revision 1.4 by torge, Fri Sep 28 19:01:17 2012 UTC revision 1.10 by torge, Mon Oct 22 21:12:47 2012 UTC
# Line 58  C     !FUNCTIONS: Line 58  C     !FUNCTIONS:
58    
59  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
60  C     === Local variables ===  C     === Local variables ===
61    #ifdef SEAICE_DEBUG
62  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
63  C     msgBuf      :: Informational/error message buffer  C     msgBuf      :: Informational/error message buffer
64        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
65  c ToM>>>  c ToM>>>
66    #endif
67  C  C
68  C unit/sign convention:  C unit/sign convention:
69  C    Within the thermodynamic computation all stocks, except HSNOW,  C    Within the thermodynamic computation all stocks, except HSNOW,
# Line 95  C     i,j,bi,bj :: Loop counters Line 97  C     i,j,bi,bj :: Loop counters
97        INTEGER i, j, bi, bj        INTEGER i, j, bi, bj
98  C     number of surface interface layer  C     number of surface interface layer
99        INTEGER kSurface        INTEGER kSurface
100    C     IT :: ice thickness category index (MULTICATEGORIES and ITD code)
101          INTEGER IT
102          _RL pFac
103  C     constants  C     constants
104        _RL tempFrz, ICE2SNOW, SNOW2ICE        _RL tempFrz, ICE2SNOW, SNOW2ICE
105        _RL QI, QS, recip_QI        _RL QI, QS, recip_QI
106          _RL lhSublim
 C--   TmixLoc        :: ocean surface/mixed-layer temperature (in K)  
       _RL TmixLoc       (1:sNx,1:sNy)  
   
 C     a_QbyATM_cover :: available heat (in W/m^2) due to the interaction of  
 C             the atmosphere and the ocean surface - for ice covered water  
 C     a_QbyATM_open  :: same but for open water  
 C     r_QbyATM_cover :: residual of a_QbyATM_cover after freezing/melting processes  
 C     r_QbyATM_open  :: same but for open water  
       _RL a_QbyATM_cover      (1:sNx,1:sNy)  
       _RL a_QbyATM_open       (1:sNx,1:sNy)  
       _RL r_QbyATM_cover      (1:sNx,1:sNy)  
       _RL r_QbyATM_open       (1:sNx,1:sNy)  
 C     a_QSWbyATM_open   - short wave heat flux over ocean in W/m^2  
 C     a_QSWbyATM_cover  - short wave heat flux under ice in W/m^2  
       _RL a_QSWbyATM_open     (1:sNx,1:sNy)  
       _RL a_QSWbyATM_cover    (1:sNx,1:sNy)  
 C     a_QbyOCN :: available heat (in in W/m^2) due to the  
 C             interaction of the ice pack and the ocean surface  
 C     r_QbyOCN :: residual of a_QbyOCN after freezing/melting  
 C             processes have been accounted for  
       _RL a_QbyOCN            (1:sNx,1:sNy)  
       _RL r_QbyOCN            (1:sNx,1:sNy)  
107    
108  C conversion factors to go from Q (W/m2) to HEFF (ice meters)  C conversion factors to go from Q (W/m2) to HEFF (ice meters)
109        _RL convertQ2HI, convertHI2Q        _RL convertQ2HI, convertHI2Q
110  C conversion factors to go from precip (m/s) unit to HEFF (ice meters)  C conversion factors to go from precip (m/s) unit to HEFF (ice meters)
111        _RL convertPRECIP2HI, convertHI2PRECIP        _RL convertPRECIP2HI, convertHI2PRECIP
112    C     Factor by which we increase the upper ocean friction velocity (u*) when
113    C     ice is absent in a grid cell  (dimensionless)
114          _RL MixedLayerTurbulenceFactor
115    
116  #ifdef ALLOW_DIAGNOSTICS  C     wind speed square
117  C ICE/SNOW stocks tendencies associated with the various melt/freeze processes        _RL SPEED_SQ
       _RL d_AREAbyATM         (1:sNx,1:sNy)  
       _RL d_AREAbyOCN         (1:sNx,1:sNy)  
       _RL d_AREAbyICE         (1:sNx,1:sNy)  
 #endif  
   
 #ifdef SEAICE_ALLOW_AREA_RELAXATION  
 C     ICE/SNOW stocks tendency associated with relaxation towards observation  
       _RL d_AREAbyRLX         (1:sNx,1:sNy)  
 c     The change of mean ice thickness due to relaxation  
       _RL d_HEFFbyRLX         (1:sNx,1:sNy)  
 #endif  
   
 #ifdef SEAICE_ITD  
 c     The change of mean ice area due to out-of-bounds values following  
 c     sea ice dynamics  
       _RL d_AREAbyNEG         (1:sNx,1:sNy)  
 #endif  
 c     The change of mean ice thickness due to out-of-bounds values following  
 c     sea ice dynamics  
       _RL d_HEFFbyNEG         (1:sNx,1:sNy)  
   
 c     The change of mean ice thickness due to turbulent ocean-sea ice heat fluxes  
       _RL d_HEFFbyOCNonICE    (1:sNx,1:sNy)  
   
 c     The sum of mean ice thickness increments due to atmospheric fluxes over the open water  
 c     fraction and ice-covered fractions of the grid cell  
       _RL d_HEFFbyATMonOCN    (1:sNx,1:sNy)  
 c     The change of mean ice thickness due to flooding by snow  
       _RL d_HEFFbyFLOODING    (1:sNx,1:sNy)  
118    
119  c     The mean ice thickness increments due to atmospheric fluxes over the open water  C     Regularization values squared
120  c     fraction and ice-covered fractions of the grid cell, respectively        _RL area_reg_sq, hice_reg_sq
121        _RL d_HEFFbyATMonOCN_open(1:sNx,1:sNy)  C     pathological cases thresholds
122        _RL d_HEFFbyATMonOCN_cover(1:sNx,1:sNy)        _RL heffTooHeavy
123    
124        _RL d_HSNWbyNEG         (1:sNx,1:sNy)  C     Helper variables: reciprocal of some constants
125        _RL d_HSNWbyATMonSNW    (1:sNx,1:sNy)        _RL recip_multDim
126        _RL d_HSNWbyOCNonSNW    (1:sNx,1:sNy)        _RL recip_deltaTtherm
127        _RL d_HSNWbyRAIN        (1:sNx,1:sNy)        _RL recip_rhoIce
128    C     local value (=1/HO or 1/HO_south)
129          _RL recip_HO
130    C     local value (=1/ice thickness)
131          _RL recip_HH
132    C     facilitate multi-category snow implementation
133          _RL pFacSnow
134    
135        _RL d_HFRWbyRAIN        (1:sNx,1:sNy)  C     temporary variables available for the various computations
136  C        _RL tmpscal0, tmpscal1, tmpscal2, tmpscal3, tmpscal4
 C     a_FWbySublim :: fresh water flux implied by latent heat of  
 C                     sublimation to atmosphere, same sign convention  
 C                     as EVAP (positive upward)  
       _RL a_FWbySublim        (1:sNx,1:sNy)  
       _RL r_FWbySublim        (1:sNx,1:sNy)  
       _RL d_HEFFbySublim      (1:sNx,1:sNy)  
       _RL d_HSNWbySublim      (1:sNx,1:sNy)  
137    
138  #if (defined(SEAICE_CAP_SUBLIM) || defined(SEAICE_ITD))  #ifdef ALLOW_SITRACER
139  C     The latent heat flux which will sublimate all snow and ice        INTEGER iTr
140  C     over one time step  #ifdef ALLOW_DIAGNOSTICS
141        _RL latentHeatFluxMax   (1:sNx,1:sNy)        CHARACTER*8   diagName
       _RL latentHeatFluxMaxMult  (1:sNx,1:sNy,MULTDIM)  
142  #endif  #endif
143    #endif /* ALLOW_SITRACER */
144    #ifdef ALLOW_AUTODIFF_TAMC
145          INTEGER ilockey
146    #endif
147    
148    C==   local arrays ==
149    C--   TmixLoc        :: ocean surface/mixed-layer temperature (in K)
150          _RL TmixLoc       (1:sNx,1:sNy)
151    
152  C     actual ice thickness (with upper and lower limit)  C     actual ice thickness (with upper and lower limit)
153        _RL heffActual          (1:sNx,1:sNy)        _RL heffActual          (1:sNx,1:sNy)
# Line 192  C     actual snow thickness Line 155  C     actual snow thickness
155        _RL hsnowActual         (1:sNx,1:sNy)        _RL hsnowActual         (1:sNx,1:sNy)
156  C     actual ice thickness (with lower limit only) Reciprocal  C     actual ice thickness (with lower limit only) Reciprocal
157        _RL recip_heffActual    (1:sNx,1:sNy)        _RL recip_heffActual    (1:sNx,1:sNy)
 C     local value (=1/HO or 1/HO_south)  
       _RL recip_HO  
 C     local value (=1/ice thickness)  
       _RL recip_HH  
158    
159  C     AREA_PRE :: hold sea-ice fraction field before any seaice-thermo update  C     AREA_PRE :: hold sea-ice fraction field before any seaice-thermo update
160        _RL AREApreTH           (1:sNx,1:sNy)        _RL AREApreTH           (1:sNx,1:sNy)
# Line 206  C     AREA_PRE :: hold sea-ice fraction Line 165  C     AREA_PRE :: hold sea-ice fraction
165        _RL HEFFITDpreTH        (1:sNx,1:sNy,1:nITD)        _RL HEFFITDpreTH        (1:sNx,1:sNy,1:nITD)
166        _RL HSNWITDpreTH        (1:sNx,1:sNy,1:nITD)        _RL HSNWITDpreTH        (1:sNx,1:sNy,1:nITD)
167        _RL areaFracFactor      (1:sNx,1:sNy,1:nITD)        _RL areaFracFactor      (1:sNx,1:sNy,1:nITD)
168        _RL heffFracFactor      (1:sNx,1:sNy,1:nITD)        _RL leadIceThickMin
169  #endif  #endif
170    
171  C     wind speed  C     wind speed
172        _RL UG                  (1:sNx,1:sNy)        _RL UG                  (1:sNx,1:sNy)
 #ifdef ALLOW_ATM_WIND  
       _RL SPEED_SQ  
 #endif  
   
 C     Regularization values squared  
       _RL area_reg_sq, hice_reg_sq  
   
 C     pathological cases thresholds  
       _RL heffTooHeavy  
   
       _RL lhSublim  
173    
174  C temporary variables available for the various computations  C     temporary variables available for the various computations
       _RL tmpscal0, tmpscal1, tmpscal2, tmpscal3, tmpscal4  
175        _RL tmparr1             (1:sNx,1:sNy)        _RL tmparr1             (1:sNx,1:sNy)
   
176  #ifdef SEAICE_VARIABLE_SALINITY  #ifdef SEAICE_VARIABLE_SALINITY
177        _RL saltFluxAdjust      (1:sNx,1:sNy)        _RL saltFluxAdjust      (1:sNx,1:sNy)
178  #endif  #endif
179    
       INTEGER ilockey  
       INTEGER it  
 #ifdef SEAICE_ITD  
       INTEGER K  
 #endif  
       _RL pFac  
180        _RL ticeInMult          (1:sNx,1:sNy,MULTDIM)        _RL ticeInMult          (1:sNx,1:sNy,MULTDIM)
181        _RL ticeOutMult         (1:sNx,1:sNy,MULTDIM)        _RL ticeOutMult         (1:sNx,1:sNy,MULTDIM)
182        _RL heffActualMult      (1:sNx,1:sNy,MULTDIM)        _RL heffActualMult      (1:sNx,1:sNy,MULTDIM)
 #ifdef SEAICE_ITD  
183        _RL hsnowActualMult     (1:sNx,1:sNy,MULTDIM)        _RL hsnowActualMult     (1:sNx,1:sNy,MULTDIM)
184    #ifdef SEAICE_ITD
185        _RL recip_heffActualMult(1:sNx,1:sNy,MULTDIM)        _RL recip_heffActualMult(1:sNx,1:sNy,MULTDIM)
186  #endif  #endif
187        _RL a_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)        _RL a_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)
# Line 251  C temporary variables available for the Line 191  C temporary variables available for the
191        _RL r_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)        _RL r_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)
192        _RL r_FWbySublimMult    (1:sNx,1:sNy,MULTDIM)        _RL r_FWbySublimMult    (1:sNx,1:sNy,MULTDIM)
193  #endif  #endif
 C     Helper variables: reciprocal of some constants  
       _RL recip_multDim  
       _RL recip_deltaTtherm  
       _RL recip_rhoIce  
194    
195  C     Factor by which we increase the upper ocean friction velocity (u*) when  C     a_QbyATM_cover :: available heat (in W/m^2) due to the interaction of
196  C     ice is absent in a grid cell  (dimensionless)  C             the atmosphere and the ocean surface - for ice covered water
197        _RL MixedLayerTurbulenceFactor  C     a_QbyATM_open  :: same but for open water
198    C     r_QbyATM_cover :: residual of a_QbyATM_cover after freezing/melting processes
199    C     r_QbyATM_open  :: same but for open water
200          _RL a_QbyATM_cover      (1:sNx,1:sNy)
201          _RL a_QbyATM_open       (1:sNx,1:sNy)
202          _RL r_QbyATM_cover      (1:sNx,1:sNy)
203          _RL r_QbyATM_open       (1:sNx,1:sNy)
204    C     a_QSWbyATM_open   - short wave heat flux over ocean in W/m^2
205    C     a_QSWbyATM_cover  - short wave heat flux under ice in W/m^2
206          _RL a_QSWbyATM_open     (1:sNx,1:sNy)
207          _RL a_QSWbyATM_cover    (1:sNx,1:sNy)
208    C     a_QbyOCN :: available heat (in W/m^2) due to the
209    C             interaction of the ice pack and the ocean surface
210    C     r_QbyOCN :: residual of a_QbyOCN after freezing/melting
211    C             processes have been accounted for
212          _RL a_QbyOCN            (1:sNx,1:sNy)
213          _RL r_QbyOCN            (1:sNx,1:sNy)
214    
215  #ifdef ALLOW_SITRACER  C     The change of mean ice thickness due to out-of-bounds values following
216        INTEGER iTr  C     sea ice dyhnamics
217        CHARACTER*8   diagName        _RL d_HEFFbyNEG         (1:sNx,1:sNy)
218    
219    C     The change of mean ice thickness due to turbulent ocean-sea ice heat fluxes
220          _RL d_HEFFbyOCNonICE    (1:sNx,1:sNy)
221    
222    C     The sum of mean ice thickness increments due to atmospheric fluxes over
223    C     the open water fraction and ice-covered fractions of the grid cell
224          _RL d_HEFFbyATMonOCN    (1:sNx,1:sNy)
225    C     The change of mean ice thickness due to flooding by snow
226          _RL d_HEFFbyFLOODING    (1:sNx,1:sNy)
227    
228    C     The mean ice thickness increments due to atmospheric fluxes over the open
229    C     water fraction and ice-covered fractions of the grid cell, respectively
230          _RL d_HEFFbyATMonOCN_open(1:sNx,1:sNy)
231          _RL d_HEFFbyATMonOCN_cover(1:sNx,1:sNy)
232    
233          _RL d_HSNWbyNEG         (1:sNx,1:sNy)
234          _RL d_HSNWbyATMonSNW    (1:sNx,1:sNy)
235          _RL d_HSNWbyOCNonSNW    (1:sNx,1:sNy)
236          _RL d_HSNWbyRAIN        (1:sNx,1:sNy)
237    
238          _RL d_HFRWbyRAIN        (1:sNx,1:sNy)
239    
240    C     a_FWbySublim :: fresh water flux implied by latent heat of
241    C                     sublimation to atmosphere, same sign convention
242    C                     as EVAP (positive upward)
243          _RL a_FWbySublim        (1:sNx,1:sNy)
244          _RL r_FWbySublim        (1:sNx,1:sNy)
245          _RL d_HEFFbySublim      (1:sNx,1:sNy)
246          _RL d_HSNWbySublim      (1:sNx,1:sNy)
247    
248    #ifdef SEAICE_CAP_SUBLIM
249    C     The latent heat flux which will sublimate all snow and ice
250    C     over one time step
251          _RL latentHeatFluxMax   (1:sNx,1:sNy)
252          _RL latentHeatFluxMaxMult(1:sNx,1:sNy,MULTDIM)
253  #endif  #endif
254    
255    #ifdef EXF_ALLOW_SEAICE_RELAX
256    C     ICE/SNOW stocks tendency associated with relaxation towards observation
257          _RL d_AREAbyRLX         (1:sNx,1:sNy)
258    C     The change of mean ice thickness due to relaxation
259          _RL d_HEFFbyRLX         (1:sNx,1:sNy)
260    #endif
261    
262  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
263  c     Helper variables for diagnostics  C ICE/SNOW stocks tendencies associated with the various melt/freeze processes
264          _RL d_AREAbyATM         (1:sNx,1:sNy)
265          _RL d_AREAbyOCN         (1:sNx,1:sNy)
266          _RL d_AREAbyICE         (1:sNx,1:sNy)
267    C     Helper variables for diagnostics
268        _RL DIAGarrayA    (1:sNx,1:sNy)        _RL DIAGarrayA    (1:sNx,1:sNy)
269        _RL DIAGarrayB    (1:sNx,1:sNy)        _RL DIAGarrayB    (1:sNx,1:sNy)
270        _RL DIAGarrayC    (1:sNx,1:sNy)        _RL DIAGarrayC    (1:sNx,1:sNy)
271        _RL DIAGarrayD    (1:sNx,1:sNy)        _RL DIAGarrayD    (1:sNx,1:sNy)
272  #endif  #endif /* ALLOW_DIAGNOSTICS */
273    
274          _RL SItflux     (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
275          _RL SIatmQnt    (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
276          _RL SIatmFW     (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
277    #ifdef ALLOW_BALANCE_FLUXES
278          _RL FWFsiTile(nSx,nSy)
279          _RL FWFsiGlob
280          _RL HFsiTile(nSx,nSy)
281          _RL HFsiGlob
282          _RL FWF2HFsiTile(nSx,nSy)
283          _RL FWF2HFsiGlob
284          CHARACTER*(max_len_mbuf) msgbuf
285    #endif
286    
287  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
288    
# Line 286  C ====================================== Line 297  C ======================================
297        ENDIF        ENDIF
298    
299  C     avoid unnecessary divisions in loops  C     avoid unnecessary divisions in loops
300  #ifdef SEAICE_ITD  c#ifdef SEAICE_ITD
301  CToM  SEAICE_multDim = nITD (see SEAICE_SIZE.h and seaice_readparms.F)  CToM this is now set by MULTDIM = nITD in SEAICE_SIZE.h
302  #endif  C    (see SEAICE_SIZE.h and seaice_readparms.F)
303    c     SEAICE_multDim = nITD
304    c#endif
305        recip_multDim        = SEAICE_multDim        recip_multDim        = SEAICE_multDim
306        recip_multDim        = ONE / recip_multDim        recip_multDim        = ONE / recip_multDim
307  C     above/below: double/single precision calculation of recip_multDim  C     above/below: double/single precision calculation of recip_multDim
# Line 339  C conversion factors to go from precip ( Line 352  C conversion factors to go from precip (
352       &                       + act4*max1*max2*max3       &                       + act4*max1*max2*max3
353  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
354    
   
355  C array initializations  C array initializations
356  C =====================  C =====================
357    
# Line 362  C ===================== Line 374  C =====================
374            d_AREAbyOCN(I,J)           = 0.0 _d 0            d_AREAbyOCN(I,J)           = 0.0 _d 0
375  #endif  #endif
376    
377  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
378            d_AREAbyRLX(I,J)           = 0.0 _d 0            d_AREAbyRLX(I,J)           = 0.0 _d 0
379            d_HEFFbyRLX(I,J)           = 0.0 _d 0            d_HEFFbyRLX(I,J)           = 0.0 _d 0
380  #endif  #endif
381    
 #ifdef SEAICE_ITD  
           d_AREAbyNEG(I,J)           = 0.0 _d 0  
 #endif  
382            d_HEFFbyNEG(I,J)           = 0.0 _d 0            d_HEFFbyNEG(I,J)           = 0.0 _d 0
383            d_HEFFbyOCNonICE(I,J)      = 0.0 _d 0            d_HEFFbyOCNonICE(I,J)      = 0.0 _d 0
384            d_HEFFbyATMonOCN(I,J)      = 0.0 _d 0            d_HEFFbyATMonOCN(I,J)      = 0.0 _d 0
# Line 389  C ===================== Line 398  C =====================
398  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
399            latentHeatFluxMax(I,J)     = 0.0 _d 0            latentHeatFluxMax(I,J)     = 0.0 _d 0
400  #endif  #endif
 c  
401            d_HFRWbyRAIN(I,J)          = 0.0 _d 0            d_HFRWbyRAIN(I,J)          = 0.0 _d 0
   
402            tmparr1(I,J)               = 0.0 _d 0            tmparr1(I,J)               = 0.0 _d 0
   
403  #ifdef SEAICE_VARIABLE_SALINITY  #ifdef SEAICE_VARIABLE_SALINITY
404            saltFluxAdjust(I,J)        = 0.0 _d 0            saltFluxAdjust(I,J)        = 0.0 _d 0
405  #endif  #endif
# Line 403  c Line 409  c
409              a_QbyATMmult_cover(I,J,IT)    = 0.0 _d 0              a_QbyATMmult_cover(I,J,IT)    = 0.0 _d 0
410              a_QSWbyATMmult_cover(I,J,IT)  = 0.0 _d 0              a_QSWbyATMmult_cover(I,J,IT)  = 0.0 _d 0
411              a_FWbySublimMult(I,J,IT)      = 0.0 _d 0              a_FWbySublimMult(I,J,IT)      = 0.0 _d 0
412    #ifdef SEAICE_CAP_SUBLIM
413                latentHeatFluxMaxMult(I,J,IT) = 0.0 _d 0
414    #endif
415  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
416              r_QbyATMmult_cover (I,J,IT)   = 0.0 _d 0              r_QbyATMmult_cover (I,J,IT)   = 0.0 _d 0
417              r_FWbySublimMult(I,J,IT)      = 0.0 _d 0              r_FWbySublimMult(I,J,IT)      = 0.0 _d 0
418  #endif  #endif
 #if (defined(SEAICE_CAP_SUBLIM) || defined(SEAICE_ITD))  
             latentHeatFluxMaxMult(I,J,IT) = 0.0 _d 0  
 #endif  
419            ENDDO            ENDDO
420           ENDDO           ENDDO
421          ENDDO          ENDDO
# Line 421  c Line 427  c
427          ENDDO          ENDDO
428  #endif  #endif
429    
   
430  C =====================================================================  C =====================================================================
431  C ===========PART 1: treat pathological cases (post advdiff)===========  C ===========PART 1: treat pathological cases (post advdiff)===========
432  C =====================================================================  C =====================================================================
# Line 444  C ====================================== Line 449  C ======================================
449           ENDDO           ENDDO
450          ENDDO          ENDDO
451  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
452          DO K=1,nITD          DO IT=1,nITD
453           DO J=1,sNy           DO J=1,sNy
454            DO I=1,sNx            DO I=1,sNx
455             HEFFITDpreTH(I,J,K)=HEFFITD(I,J,K,bi,bj)             HEFFITDpreTH(I,J,IT)=HEFFITD(I,J,IT,bi,bj)
456             HSNWITDpreTH(I,J,K)=HSNOWITD(I,J,K,bi,bj)             HSNWITDpreTH(I,J,IT)=HSNOWITD(I,J,IT,bi,bj)
457             AREAITDpreTH(I,J,K)=AREAITD(I,J,K,bi,bj)             AREAITDpreTH(I,J,IT)=AREAITD(I,J,IT,bi,bj)
458            ENDDO            ENDDO
459           ENDDO           ENDDO
460          ENDDO          ENDDO
# Line 462  Cgf no dependency through pathological c Line 467  Cgf no dependency through pathological c
467          IF ( SEAICEadjMODE.EQ.0 ) THEN          IF ( SEAICEadjMODE.EQ.0 ) THEN
468  #endif  #endif
469    
470  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
471  CADJ STORE heff(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE heff(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte
472  CADJ STORE area(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE area(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte
473  C 0) relax sea ice concentration towards observation  C 0) relax sea ice concentration towards observation
# Line 492  C           d_HEFFbyRLX(i,j) = 1. _d 1 * Line 497  C           d_HEFFbyRLX(i,j) = 1. _d 1 *
497           ENDDO           ENDDO
498          ENDDO          ENDDO
499          ENDIF          ENDIF
500  #endif /* SEAICE_ALLOW_AREA_RELAXATION */  #endif /* EXF_ALLOW_SEAICE_RELAX */
501    
502  C 1) treat the case of negative values:  C 1) treat the case of negative values:
503    
# Line 504  CADJ STORE area(:,:,bi,bj) = comlev1_bib Line 509  CADJ STORE area(:,:,bi,bj) = comlev1_bib
509          DO J=1,sNy          DO J=1,sNy
510           DO I=1,sNx           DO I=1,sNx
511  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
512            DO K=1,nITD            DO IT=1,nITD
            tmpscal1=0. _d 0  
513             tmpscal2=0. _d 0             tmpscal2=0. _d 0
514             tmpscal3=0. _d 0             tmpscal3=0. _d 0
515             tmpscal2=MAX(-HEFFITD(I,J,K,bi,bj),0. _d 0)             tmpscal2=MAX(-HEFFITD(I,J,IT,bi,bj),0. _d 0)
516             HEFFITD(I,J,K,bi,bj)=HEFFITD(I,J,K,bi,bj)+tmpscal2             HEFFITD(I,J,IT,bi,bj)=HEFFITD(I,J,IT,bi,bj)+tmpscal2
517             d_HEFFbyNEG(I,J)=d_HEFFbyNEG(I,J)+tmpscal2             d_HEFFbyNEG(I,J)=d_HEFFbyNEG(I,J)+tmpscal2
518             tmpscal3=MAX(-HSNOWITD(I,J,K,bi,bj),0. _d 0)             tmpscal3=MAX(-HSNOWITD(I,J,IT,bi,bj),0. _d 0)
519             HSNOWITD(I,J,K,bi,bj)=HSNOWITD(I,J,K,bi,bj)+tmpscal3             HSNOWITD(I,J,IT,bi,bj)=HSNOWITD(I,J,IT,bi,bj)+tmpscal3
520             d_HSNWbyNEG(I,J)=d_HSNWbyNEG(I,J)+tmpscal3             d_HSNWbyNEG(I,J)=d_HSNWbyNEG(I,J)+tmpscal3
521             tmpscal1=MAX(-AREAITD(I,J,K,bi,bj),0. _d 0)             AREAITD(I,J,IT,bi,bj)=MAX(AREAITD(I,J,IT,bi,bj),0. _d 0)
            AREAITD(I,J,K,bi,bj)=AREAITD(I,J,K,bi,bj)+tmpscal1  
            d_AREAbyNEG(I,J)=d_AREAbyNEG(I,J)+tmpscal1  
522            ENDDO            ENDDO
523  CToM      AREA, HEFF, and HSNOW will be updated at end of PART 1  CToM      AREA, HEFF, and HSNOW will be updated at end of PART 1
524  C         by calling SEAICE_ITD_SUM  C         by calling SEAICE_ITD_SUM
525  #else  #else
526            d_HEFFbyNEG(I,J)=MAX(-HEFF(I,J,bi,bj),0. _d 0)            d_HEFFbyNEG(I,J)=MAX(-HEFF(I,J,bi,bj),0. _d 0)
           d_HSNWbyNEG(I,J)=MAX(-HSNOW(I,J,bi,bj),0. _d 0)  
           AREA(I,J,bi,bj)=MAX(AREA(I,J,bi,bj),0. _d 0)  
527            HEFF(I,J,bi,bj)=HEFF(I,J,bi,bj)+d_HEFFbyNEG(I,J)            HEFF(I,J,bi,bj)=HEFF(I,J,bi,bj)+d_HEFFbyNEG(I,J)
528              d_HSNWbyNEG(I,J)=MAX(-HSNOW(I,J,bi,bj),0. _d 0)
529            HSNOW(I,J,bi,bj)=HSNOW(I,J,bi,bj)+d_HSNWbyNEG(I,J)            HSNOW(I,J,bi,bj)=HSNOW(I,J,bi,bj)+d_HSNWbyNEG(I,J)
530              AREA(I,J,bi,bj)=MAX(AREA(I,J,bi,bj),0. _d 0)
531  #endif  #endif
532           ENDDO           ENDDO
533          ENDDO          ENDDO
# Line 538  CADJ STORE heff(:,:,bi,bj)  = comlev1_bi Line 540  CADJ STORE heff(:,:,bi,bj)  = comlev1_bi
540          DO J=1,sNy          DO J=1,sNy
541           DO I=1,sNx           DO I=1,sNx
542  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
543            DO K=1,nITD            DO IT=1,nITD
544  #endif  #endif
545            tmpscal2=0. _d 0            tmpscal2=0. _d 0
546            tmpscal3=0. _d 0            tmpscal3=0. _d 0
547  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
548             IF (HEFFITD(I,J,K,bi,bj).LE.siEps) THEN             IF (HEFFITD(I,J,IT,bi,bj).LE.siEps) THEN
549              tmpscal2=-HEFFITD(I,J,K,bi,bj)              tmpscal2=-HEFFITD(I,J,IT,bi,bj)
550              tmpscal3=-HSNOWITD(I,J,K,bi,bj)              tmpscal3=-HSNOWITD(I,J,IT,bi,bj)
551              TICES(I,J,K,bi,bj)=celsius2K              TICES(I,J,IT,bi,bj)=celsius2K
552  CToM        TICE will be updated at end of Part 1 together with AREA and HEFF  CToM        TICE will be updated at end of Part 1 together with AREA and HEFF
553             ENDIF             ENDIF
554             HEFFITD(I,J,K,bi,bj) =HEFFITD(I,J,K,bi,bj) +tmpscal2             HEFFITD(I,J,IT,bi,bj) =HEFFITD(I,J,IT,bi,bj) +tmpscal2
555             HSNOWITD(I,J,K,bi,bj)=HSNOWITD(I,J,K,bi,bj)+tmpscal3             HSNOWITD(I,J,IT,bi,bj)=HSNOWITD(I,J,IT,bi,bj)+tmpscal3
556  #else  #else
557            IF (HEFF(I,J,bi,bj).LE.siEps) THEN            IF (HEFF(I,J,bi,bj).LE.siEps) THEN
558             tmpscal2=-HEFF(I,J,bi,bj)             tmpscal2=-HEFF(I,J,bi,bj)
# Line 580  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 582  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
582          DO J=1,sNy          DO J=1,sNy
583           DO I=1,sNx           DO I=1,sNx
584  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
585            DO K=1,nITD            DO IT=1,nITD
586             IF ((HEFFITD(i,j,k,bi,bj).EQ.0. _d 0).AND.             IF ((HEFFITD(I,J,IT,bi,bj).EQ.0. _d 0).AND.
587       &         (HSNOWITD(i,j,k,bi,bj).EQ.0. _d 0))       &         (HSNOWITD(I,J,IT,bi,bj).EQ.0. _d 0))
588       &      AREAITD(I,J,K,bi,bj)=0. _d 0       &      AREAITD(I,J,IT,bi,bj)=0. _d 0
589            ENDDO            ENDDO
590  #else  #else
591            IF ((HEFF(i,j,bi,bj).EQ.0. _d 0).AND.            IF ((HEFF(i,j,bi,bj).EQ.0. _d 0).AND.
# Line 601  CADJ STORE area(:,:,bi,bj)  = comlev1_bi Line 603  CADJ STORE area(:,:,bi,bj)  = comlev1_bi
603          DO J=1,sNy          DO J=1,sNy
604           DO I=1,sNx           DO I=1,sNx
605  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
606            DO K=1,nITD            DO IT=1,nITD
607             IF ((HEFFITD(i,j,k,bi,bj).GT.0).OR.             IF ((HEFFITD(I,J,IT,bi,bj).GT.0).OR.
608       &         (HSNOWITD(i,j,k,bi,bj).GT.0)) THEN       &         (HSNOWITD(I,J,IT,bi,bj).GT.0)) THEN
609  CToM        SEAICE_area_floor*nITD cannot be allowed to exceed 1  CToM        SEAICE_area_floor*nITD cannot be allowed to exceed 1
610  C           hence use SEAICE_area_floor devided by nITD  C           hence use SEAICE_area_floor devided by nITD
611  C           (or install a warning in e.g. seaice_readparms.F)  C           (or install a warning in e.g. seaice_readparms.F)
612              AREAITD(I,J,K,bi,bj)=              AREAITD(I,J,IT,bi,bj)=
613       &         MAX(AREAITD(I,J,K,bi,bj),SEAICE_area_floor/float(nITD))       &         MAX(AREAITD(I,J,IT,bi,bj),SEAICE_area_floor/float(nITD))
614             ENDIF             ENDIF
615            ENDDO            ENDDO
616  #else  #else
# Line 639  CADJ STORE area(:,:,bi,bj)  = comlev1_bi Line 641  CADJ STORE area(:,:,bi,bj)  = comlev1_bi
641            AREA(I,J,bi,bj)=MIN(AREA(I,J,bi,bj),SEAICE_area_max)            AREA(I,J,bi,bj)=MIN(AREA(I,J,bi,bj),SEAICE_area_max)
642           ENDDO           ENDDO
643          ENDDO          ENDDO
644  #endif /* SEAICE_ITD */  #endif /* notSEAICE_ITD */
645    
646  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
647  CToM catch up with items 1.25 and 2.5 involving category sums AREA and HEFF  CToM catch up with items 1.25 and 2.5 involving category sums AREA and HEFF
 C    first, update AREA and HEFF:  
         CALL SEAICE_ITD_SUM(bi, bj, myTime, myIter, myThid)  
 C  
648          DO J=1,sNy          DO J=1,sNy
649           DO I=1,sNx           DO I=1,sNx
650  C    TICES was changed above (item 1.25), now update TICE as ice volume  C    TICES was changed above (item 1.25), now update TICE as ice volume
651  C     weighted average of TICES  C     weighted average of TICES
652    C    also compute total of AREAITD (needed for finishing item 2.5, see below)
653            tmpscal1 = 0. _d 0            tmpscal1 = 0. _d 0
654            tmpscal2 = 0. _d 0            tmpscal2 = 0. _d 0
655            DO K=1,nITD            tmpscal3 = 0. _d 0
656             tmpscal1=tmpscal1 + TICES(I,J,K,bi,bj)*HEFFITD(I,J,K,bi,bj)            DO IT=1,nITD
657             tmpscal2=tmpscal2 + HEFFITD(I,J,K,bi,bj)             tmpscal1=tmpscal1 + TICES(I,J,IT,bi,bj)*HEFFITD(I,J,IT,bi,bj)
658               tmpscal2=tmpscal2 + HEFFITD(I,J,IT,bi,bj)
659               tmpscal3=tmpscal3 + AREAITD(I,J,IT,bi,bj)
660            ENDDO            ENDDO
661            TICE(I,J,bi,bj)=tmpscal1/tmpscal2            TICE(I,J,bi,bj)=tmpscal1/tmpscal2
662  C    lines of item 2.5 that were omitted:  C    lines of item 2.5 that were omitted:
# Line 662  C    in 2.5 these lines are executed bef Line 664  C    in 2.5 these lines are executed bef
664  C    hence we execute them here before SEAICE_ITD_REDIST is called  C    hence we execute them here before SEAICE_ITD_REDIST is called
665  C    although this means that AREA has not been completely regularized  C    although this means that AREA has not been completely regularized
666  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
667            DIAGarrayA(I,J) = AREA(I,J,bi,bj)            DIAGarrayA(I,J) = tmpscal3
668  #endif  #endif
669  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
670            SItrAREA(I,J,bi,bj,1)=AREA(I,J,bi,bj)            SItrAREA(I,J,bi,bj,1)=tmpscal3
671  #endif  #endif
672           ENDDO           ENDDO
673          ENDDO          ENDDO
# Line 676  C    and update AREA, HEFF, and HSNOW Line 678  C    and update AREA, HEFF, and HSNOW
678          CALL SEAICE_ITD_REDIST(bi, bj, myTime, myIter, myThid)          CALL SEAICE_ITD_REDIST(bi, bj, myTime, myIter, myThid)
679          CALL SEAICE_ITD_SUM(bi, bj, myTime, myIter, myThid)          CALL SEAICE_ITD_SUM(bi, bj, myTime, myIter, myThid)
680    
681    #ifdef SEAICE_DEBUG
682    c ToM<<< debug seaice_growth
683            WRITE(msgBuf,'(A,7F8.4)')
684         &    ' SEAICE_GROWTH: Heff increments 0, HEFFITD = ',
685         &     HEFFITD(1,1,:,bi,bj)
686            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
687         &    SQUEEZE_RIGHT , myThid)
688            WRITE(msgBuf,'(A,7F8.4)')
689         &    ' SEAICE_GROWTH: Area increments 0, AREAITD = ',
690         &     AREAITD(1,1,:,bi,bj)
691            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
692         &    SQUEEZE_RIGHT , myThid)
693  #endif  #endif
694    #else
695    #ifdef SEAICE_DEBUG
696            WRITE(msgBuf,'(A,7F8.4)')
697         &    ' SEAICE_GROWTH: Heff increments 0, HEFF = ',
698         &     HEFF(1,1,bi,bj)
699            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
700         &    SQUEEZE_RIGHT , myThid)
701            WRITE(msgBuf,'(A,7F8.4)')
702         &    ' SEAICE_GROWTH: Area increments 0, AREA = ',
703         &     AREA(1,1,bi,bj)
704            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
705         &    SQUEEZE_RIGHT , myThid)
706    c ToM>>>
707    #endif
708    #endif /* SEAICE_ITD */
709  #if (defined ALLOW_AUTODIFF_TAMC && defined SEAICE_MODIFY_GROWTH_ADJ)  #if (defined ALLOW_AUTODIFF_TAMC && defined SEAICE_MODIFY_GROWTH_ADJ)
710  C        ENDIF SEAICEadjMODE.EQ.0  C        end SEAICEadjMODE.EQ.0 statement:
711          ENDIF          ENDIF
712  #endif  #endif
713    
# Line 700  C 3) store regularized values of heff, h Line 729  C 3) store regularized values of heff, h
729           ENDDO           ENDDO
730          ENDDO          ENDDO
731  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
732          DO K=1,nITD          DO IT=1,nITD
733           DO J=1,sNy           DO J=1,sNy
734            DO I=1,sNx            DO I=1,sNx
735             HEFFITDpreTH(I,J,K)=HEFFITD(I,J,K,bi,bj)             HEFFITDpreTH(I,J,IT)=HEFFITD(I,J,IT,bi,bj)
736             HSNWITDpreTH(I,J,K)=HSNOWITD(I,J,K,bi,bj)             HSNWITDpreTH(I,J,IT)=HSNOWITD(I,J,IT,bi,bj)
737             AREAITDpreTH(I,J,K)=AREAITD(I,J,K,bi,bj)             AREAITDpreTH(I,J,IT)=AREAITD(I,J,IT,bi,bj)
738    
739  C memorize areal and volume fraction of each ITD category  C memorize areal and volume fraction of each ITD category
740             IF (AREA(I,J,bi,bj).GT.0) THEN             IF (AREA(I,J,bi,bj) .GT. ZERO) THEN
741              areaFracFactor(I,J,K)=AREAITD(I,J,K,bi,bj)/AREA(I,J,bi,bj)              areaFracFactor(I,J,IT)=AREAITD(I,J,IT,bi,bj)/AREA(I,J,bi,bj)
            ELSE  
             areaFracFactor(I,J,K)=ZERO  
            ENDIF  
            IF (HEFF(I,J,bi,bj).GT.0) THEN  
             heffFracFactor(I,J,K)=HEFFITD(I,J,K,bi,bj)/HEFF(I,J,bi,bj)  
742             ELSE             ELSE
743              heffFracFactor(I,J,K)=ZERO  C           if there's no ice, potential growth starts in 1st category
744                IF (IT .EQ. 1) THEN
745                 areaFracFactor(I,J,IT)=ONE
746                ELSE
747                 areaFracFactor(I,J,IT)=ZERO
748                ENDIF
749             ENDIF             ENDIF
750            ENDDO            ENDDO
751           ENDDO           ENDDO
752          ENDDO          ENDDO
753  C prepare SItrHEFF to be computed as cumulative sum  C prepare SItrHEFF to be computed as cumulative sum
754          DO K=2,5          DO iTr=2,5
755           DO J=1,sNy           DO J=1,sNy
756            DO I=1,sNx            DO I=1,sNx
757             SItrHEFF(I,J,bi,bj,K)=ZERO             SItrHEFF(I,J,bi,bj,iTr)=ZERO
758            ENDDO            ENDDO
759           ENDDO           ENDDO
760          ENDDO          ENDDO
# Line 791  Cgf no additional dependency of air-sea Line 820  Cgf no additional dependency of air-sea
820            ENDDO            ENDDO
821           ENDDO           ENDDO
822  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
823           DO K=1,nITD           DO IT=1,nITD
824            DO J=1,sNy            DO J=1,sNy
825             DO I=1,sNx             DO I=1,sNx
826              HEFFITDpreTH(I,J,K) = 0. _d 0              HEFFITDpreTH(I,J,IT) = 0. _d 0
827              HSNWITDpreTH(I,J,K) = 0. _d 0              HSNWITDpreTH(I,J,IT) = 0. _d 0
828              AREAITDpreTH(I,J,K) = 0. _d 0              AREAITDpreTH(I,J,IT) = 0. _d 0
829             ENDDO             ENDDO
830            ENDDO            ENDDO
831           ENDDO           ENDDO
# Line 821  CADJ STORE HEFFpreTH = comlev1_bibj, key Line 850  CADJ STORE HEFFpreTH = comlev1_bibj, key
850  CADJ STORE HSNWpreTH = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE HSNWpreTH = comlev1_bibj, key = iicekey, byte = isbyte
851  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
852  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
853          DO K=1,nITD          DO IT=1,nITD
854  #endif  #endif
855          DO J=1,sNy          DO J=1,sNy
856           DO I=1,sNx           DO I=1,sNx
857    
858  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
859            IF (HEFFITDpreTH(I,J,K) .GT. ZERO) THEN            IF (HEFFITDpreTH(I,J,IT) .GT. ZERO) THEN
860  #ifdef SEAICE_GROWTH_LEGACY  #ifdef SEAICE_GROWTH_LEGACY
861              tmpscal1          = MAX(SEAICE_area_reg/float(nITD),              tmpscal1          = MAX(SEAICE_area_reg/float(nITD),
862       &                              AREAITDpreTH(I,J,K))       &                              AREAITDpreTH(I,J,IT))
863              hsnowActualMult(I,J,K) = HSNWITDpreTH(I,J,K)/tmpscal1              hsnowActualMult(I,J,IT) = HSNWITDpreTH(I,J,IT)/tmpscal1
864              tmpscal2               = HEFFITDpreTH(I,J,K)/tmpscal1              tmpscal2               = HEFFITDpreTH(I,J,IT)/tmpscal1
865              heffActualMult(I,J,K)  = MAX(tmpscal2,SEAICE_hice_reg)              heffActualMult(I,J,IT)  = MAX(tmpscal2,SEAICE_hice_reg)
866  #else /* SEAICE_GROWTH_LEGACY */  #else /* SEAICE_GROWTH_LEGACY */
867  cif        regularize AREA with SEAICE_area_reg  cif        regularize AREA with SEAICE_area_reg
868             tmpscal1 = SQRT(AREAITDpreTH(I,J,K) * AREAITDpreTH(I,J,K)             tmpscal1 = SQRT(AREAITDpreTH(I,J,IT) * AREAITDpreTH(I,J,IT)
869       &                     + area_reg_sq)       &                     + area_reg_sq)
870  cif        heffActual calculated with the regularized AREA  cif        heffActual calculated with the regularized AREA
871             tmpscal2 = HEFFITDpreTH(I,J,K) / tmpscal1             tmpscal2 = HEFFITDpreTH(I,J,IT) / tmpscal1
872  cif        regularize heffActual with SEAICE_hice_reg (add lower bound)  cif        regularize heffActual with SEAICE_hice_reg (add lower bound)
873             heffActualMult(I,J,K) = SQRT(tmpscal2 * tmpscal2             heffActualMult(I,J,IT) = SQRT(tmpscal2 * tmpscal2
874       &                                  + hice_reg_sq)       &                                  + hice_reg_sq)
875  cif        hsnowActual calculated with the regularized AREA  cif        hsnowActual calculated with the regularized AREA
876             hsnowActualMult(I,J,K) = HSNWITDpreTH(I,J,K) / tmpscal1             hsnowActualMult(I,J,IT) = HSNWITDpreTH(I,J,IT) / tmpscal1
877  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
878  cif        regularize the inverse of heffActual by hice_reg  cif        regularize the inverse of heffActual by hice_reg
879             recip_heffActualMult(I,J,K)  = AREAITDpreTH(I,J,K) /             recip_heffActualMult(I,J,IT)  = AREAITDpreTH(I,J,IT) /
880       &                 sqrt(HEFFITDpreTH(I,J,K) * HEFFITDpreTH(I,J,K)       &                 sqrt(HEFFITDpreTH(I,J,IT) * HEFFITDpreTH(I,J,IT)
881       &                      + hice_reg_sq)       &                      + hice_reg_sq)
882  cif       Do not regularize when HEFFpreTH = 0  cif       Do not regularize when HEFFpreTH = 0
883            ELSE            ELSE
884              heffActualMult(I,J,K) = ZERO              heffActualMult(I,J,IT) = ZERO
885              hsnowActualMult(I,J,K) = ZERO              hsnowActualMult(I,J,IT) = ZERO
886              recip_heffActualMult(I,J,K)  = ZERO              recip_heffActualMult(I,J,IT)  = ZERO
887            ENDIF            ENDIF
888  #else /* SEAICE_ITD */  #else /* SEAICE_ITD */
889            IF (HEFFpreTH(I,J) .GT. ZERO) THEN            IF (HEFFpreTH(I,J) .GT. ZERO) THEN
# Line 864  cif       Do not regularize when HEFFpre Line 893  cif       Do not regularize when HEFFpre
893              tmpscal2         = HEFFpreTH(I,J)/tmpscal1              tmpscal2         = HEFFpreTH(I,J)/tmpscal1
894              heffActual(I,J)  = MAX(tmpscal2,SEAICE_hice_reg)              heffActual(I,J)  = MAX(tmpscal2,SEAICE_hice_reg)
895  #else /* SEAICE_GROWTH_LEGACY */  #else /* SEAICE_GROWTH_LEGACY */
896  cif        regularize AREA with SEAICE_area_reg  Cif        regularize AREA with SEAICE_area_reg
897             tmpscal1 = SQRT(AREApreTH(I,J)* AREApreTH(I,J) + area_reg_sq)             tmpscal1 = SQRT(AREApreTH(I,J)* AREApreTH(I,J) + area_reg_sq)
898  cif        heffActual calculated with the regularized AREA  Cif        heffActual calculated with the regularized AREA
899             tmpscal2 = HEFFpreTH(I,J) / tmpscal1             tmpscal2 = HEFFpreTH(I,J) / tmpscal1
900  cif        regularize heffActual with SEAICE_hice_reg (add lower bound)  Cif        regularize heffActual with SEAICE_hice_reg (add lower bound)
901             heffActual(I,J) = SQRT(tmpscal2 * tmpscal2 + hice_reg_sq)             heffActual(I,J) = SQRT(tmpscal2 * tmpscal2 + hice_reg_sq)
902  cif        hsnowActual calculated with the regularized AREA  Cif        hsnowActual calculated with the regularized AREA
903             hsnowActual(I,J) = HSNWpreTH(I,J) / tmpscal1             hsnowActual(I,J) = HSNWpreTH(I,J) / tmpscal1
904  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
905  cif        regularize the inverse of heffActual by hice_reg  Cif        regularize the inverse of heffActual by hice_reg
906             recip_heffActual(I,J)  = AREApreTH(I,J) /             recip_heffActual(I,J)  = AREApreTH(I,J) /
907       &                 sqrt(HEFFpreTH(I,J)*HEFFpreTH(I,J) + hice_reg_sq)       &                 sqrt(HEFFpreTH(I,J)*HEFFpreTH(I,J) + hice_reg_sq)
908  cif       Do not regularize when HEFFpreTH = 0  Cif       Do not regularize when HEFFpreTH = 0
909            ELSE            ELSE
910              heffActual(I,J) = ZERO              heffActual(I,J) = ZERO
911              hsnowActual(I,J) = ZERO              hsnowActual(I,J) = ZERO
# Line 900  cif       Do not regularize when HEFFpre Line 929  cif       Do not regularize when HEFFpre
929  C 5) COMPUTE MAXIMUM LATENT HEAT FLUXES FOR THE CURRENT ICE  C 5) COMPUTE MAXIMUM LATENT HEAT FLUXES FOR THE CURRENT ICE
930  C    AND SNOW THICKNESS  C    AND SNOW THICKNESS
931  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
932          DO K=1,nITD          DO IT=1,nITD
933  #endif  #endif
934          DO J=1,sNy          DO J=1,sNy
935           DO I=1,sNx           DO I=1,sNx
936  c        The latent heat flux over the sea ice which  C        The latent heat flux over the sea ice which
937  c        will sublimate all of the snow and ice over one time  C        will sublimate all of the snow and ice over one time
938  c        step (W/m^2)  C        step (W/m^2)
939  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
940            IF (HEFFITDpreTH(I,J,K) .GT. ZERO) THEN            IF (HEFFITDpreTH(I,J,IT) .GT. ZERO) THEN
941              latentHeatFluxMaxMult(I,J,K) = lhSublim*recip_deltaTtherm *              latentHeatFluxMaxMult(I,J,IT) = lhSublim*recip_deltaTtherm *
942       &         (HEFFITDpreTH(I,J,K)*SEAICE_rhoIce +       &         (HEFFITDpreTH(I,J,IT)*SEAICE_rhoIce +
943       &          HSNWITDpreTH(I,J,K)*SEAICE_rhoSnow)/AREAITDpreTH(I,J,K)       &          HSNWITDpreTH(I,J,IT)*SEAICE_rhoSnow)
944         &         /AREAITDpreTH(I,J,IT)
945            ELSE            ELSE
946              latentHeatFluxMaxMult(I,J,K) = ZERO              latentHeatFluxMaxMult(I,J,IT) = ZERO
947            ENDIF            ENDIF
948  #else  #else
949            IF (HEFFpreTH(I,J) .GT. ZERO) THEN            IF (HEFFpreTH(I,J) .GT. ZERO) THEN
# Line 963  cCADJ STORE TmixLoc = comlev1_bibj, key Line 993  cCADJ STORE TmixLoc = comlev1_bibj, key
993  C determine available heat due to the atmosphere -- for ice covered water  C determine available heat due to the atmosphere -- for ice covered water
994  C =======================================================================  C =======================================================================
995    
996  #ifdef ALLOW_ATM_WIND          IF (useRelativeWind.AND.useAtmWind) THEN
         IF (useRelativeWind) THEN  
997  C     Compute relative wind speed over sea ice.  C     Compute relative wind speed over sea ice.
998           DO J=1,sNy           DO J=1,sNy
999            DO I=1,sNx            DO I=1,sNx
# Line 985  C     Compute relative wind speed over s Line 1014  C     Compute relative wind speed over s
1014            ENDDO            ENDDO
1015           ENDDO           ENDDO
1016          ENDIF          ENDIF
 #endif /* ALLOW_ATM_WIND */  
1017    
1018  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
1019  CADJ STORE tice(:,:,bi,bj)  CADJ STORE tice(:,:,bi,bj)
# Line 1004  C--   Start loop over multi-categories Line 1032  C--   Start loop over multi-categories
1032  CToM  SEAICE_multDim = nITD (see SEAICE_SIZE.h and seaice_readparms.F)  CToM  SEAICE_multDim = nITD (see SEAICE_SIZE.h and seaice_readparms.F)
1033  #endif  #endif
1034          DO IT=1,SEAICE_multDim          DO IT=1,SEAICE_multDim
1035  c        homogeneous distribution between 0 and 2 x heffActual  C        homogeneous distribution between 0 and 2 x heffActual
1036  #ifndef SEAICE_ITD  #ifndef SEAICE_ITD
1037           pFac = (2.0 _d 0*real(IT)-1.0 _d 0)*recip_multDim           pFac = (2.0 _d 0*IT - 1.0 _d 0)*recip_multDim
1038             pFacSnow = 1. _d 0
1039             IF ( SEAICE_useMultDimSnow ) pFacSnow=pFac
1040  #endif  #endif
1041           DO J=1,sNy           DO J=1,sNy
1042            DO I=1,sNx            DO I=1,sNx
# Line 1014  c        homogeneous distribution betwee Line 1044  c        homogeneous distribution betwee
1044  CToM for SEAICE_ITD heffActualMult and latentHeatFluxMaxMult are calculated above  CToM for SEAICE_ITD heffActualMult and latentHeatFluxMaxMult are calculated above
1045  C    (instead of heffActual and latentHeatFluxMax)  C    (instead of heffActual and latentHeatFluxMax)
1046             heffActualMult(I,J,IT)= heffActual(I,J)*pFac             heffActualMult(I,J,IT)= heffActual(I,J)*pFac
1047               hsnowActualMult(I,J,IT)=hsnowActual(I,J)*pFacSnow
1048  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
1049             latentHeatFluxMaxMult(I,J,IT) = latentHeatFluxMax(I,J)*pFac             latentHeatFluxMaxMult(I,J,IT) = latentHeatFluxMax(I,J)*pFac
1050  #endif  #endif
# Line 1028  C    (instead of heffActual and latentHe Line 1059  C    (instead of heffActual and latentHe
1059    
1060  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
1061  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte
1062    CADJ STORE hsnowActualMult= comlev1_bibj, key = iicekey, byte = isbyte
1063  CADJ STORE ticeInMult     = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE ticeInMult     = comlev1_bibj, key = iicekey, byte = isbyte
1064  # ifdef SEAICE_CAP_SUBLIM  # ifdef SEAICE_CAP_SUBLIM
1065  CADJ STORE latentHeatFluxMaxMult  CADJ STORE latentHeatFluxMaxMult
# Line 1043  CADJ &     comlev1_bibj, key = iicekey, Line 1075  CADJ &     comlev1_bibj, key = iicekey,
1075    
1076          DO IT=1,SEAICE_multDim          DO IT=1,SEAICE_multDim
1077           CALL SEAICE_SOLVE4TEMP(           CALL SEAICE_SOLVE4TEMP(
 #ifdef SEAICE_ITD  
1078       I        UG, heffActualMult(1,1,IT), hsnowActualMult(1,1,IT),       I        UG, heffActualMult(1,1,IT), hsnowActualMult(1,1,IT),
 #else  
      I        UG, heffActualMult(1,1,IT), hsnowActual,  
 #endif  
1079  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
1080       I        latentHeatFluxMaxMult(1,1,IT),       I        latentHeatFluxMaxMult(1,1,IT),
1081  #endif  #endif
1082       U        ticeInMult(1,1,IT), ticeOutMult(1,1,IT),       U        ticeInMult(1,1,IT), ticeOutMult(1,1,IT),
1083       O        a_QbyATMmult_cover(1,1,IT), a_QSWbyATMmult_cover(1,1,IT),       O        a_QbyATMmult_cover(1,1,IT),
1084         O        a_QSWbyATMmult_cover(1,1,IT),
1085       O        a_FWbySublimMult(1,1,IT),       O        a_FWbySublimMult(1,1,IT),
1086       I        bi, bj, myTime, myIter, myThid )       I        bi, bj, myTime, myIter, myThid )
1087          ENDDO          ENDDO
1088    
1089  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
1090  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte
1091    CADJ STORE hsnowActualMult= comlev1_bibj, key = iicekey, byte = isbyte
1092  CADJ STORE ticeOutMult    = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE ticeOutMult    = comlev1_bibj, key = iicekey, byte = isbyte
1093  # ifdef SEAICE_CAP_SUBLIM  # ifdef SEAICE_CAP_SUBLIM
1094  CADJ STORE latentHeatFluxMaxMult  CADJ STORE latentHeatFluxMaxMult
# Line 1079  C     update TICE & TICES Line 1109  C     update TICE & TICES
1109  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1110  C     calculate area weighted mean  C     calculate area weighted mean
1111  C     (although the ice's temperature relates to its energy content  C     (although the ice's temperature relates to its energy content
1112  C      and hence should be averaged weighted by ice volume [heffFracFactor],  C      and hence should be averaged weighted by ice volume,
1113  C      the temperature here is a result of the fluxes through the ice surface  C      the temperature here is a result of the fluxes through the ice surface
1114  C      computed individually for each single category in SEAICE_SOLVE4TEMP  C      computed individually for each single category in SEAICE_SOLVE4TEMP
1115  C      and hence is averaged area weighted [areaFracFactor])  C      and hence is averaged area weighted [areaFracFactor])
1116             TICE(I,J,bi,bj) = TICE(I,J,bi,bj)             TICE(I,J,bi,bj) = TICE(I,J,bi,bj)
1117       &          +  ticeOutMult(I,J,IT)*areaFracFactor(I,J,K)       &          +  ticeOutMult(I,J,IT)*areaFracFactor(I,J,IT)
1118  #else  #else
1119             TICE(I,J,bi,bj) = TICE(I,J,bi,bj)             TICE(I,J,bi,bj) = TICE(I,J,bi,bj)
1120       &          +  ticeOutMult(I,J,IT)*recip_multDim       &          +  ticeOutMult(I,J,IT)*recip_multDim
# Line 1095  C     average over categories Line 1125  C     average over categories
1125  C     calculate area weighted mean  C     calculate area weighted mean
1126  C     (fluxes are per unit (ice surface) area and are thus area weighted)  C     (fluxes are per unit (ice surface) area and are thus area weighted)
1127             a_QbyATM_cover   (I,J) = a_QbyATM_cover(I,J)             a_QbyATM_cover   (I,J) = a_QbyATM_cover(I,J)
1128       &          + a_QbyATMmult_cover(I,J,IT)*areaFracFactor(I,J,K)       &          + a_QbyATMmult_cover(I,J,IT)*areaFracFactor(I,J,IT)
1129             a_QSWbyATM_cover (I,J) = a_QSWbyATM_cover(I,J)             a_QSWbyATM_cover (I,J) = a_QSWbyATM_cover(I,J)
1130       &          + a_QSWbyATMmult_cover(I,J,IT)*areaFracFactor(I,J,K)       &          + a_QSWbyATMmult_cover(I,J,IT)*areaFracFactor(I,J,IT)
1131             a_FWbySublim     (I,J) = a_FWbySublim(I,J)             a_FWbySublim     (I,J) = a_FWbySublim(I,J)
1132       &          + a_FWbySublimMult(I,J,IT)*areaFracFactor(I,J,K)       &          + a_FWbySublimMult(I,J,IT)*areaFracFactor(I,J,IT)
1133  #else  #else
1134             a_QbyATM_cover   (I,J) = a_QbyATM_cover(I,J)             a_QbyATM_cover   (I,J) = a_QbyATM_cover(I,J)
1135       &          + a_QbyATMmult_cover(I,J,IT)*recip_multDim       &          + a_QbyATMmult_cover(I,J,IT)*recip_multDim
# Line 1116  C     (fluxes are per unit (ice surface) Line 1146  C     (fluxes are per unit (ice surface)
1146  # ifdef ALLOW_DIAGNOSTICS  # ifdef ALLOW_DIAGNOSTICS
1147          DO J=1,sNy          DO J=1,sNy
1148           DO I=1,sNx           DO I=1,sNx
1149  c          The actual latent heat flux realized by SOLVE4TEMP  C          The actual latent heat flux realized by SOLVE4TEMP
1150             DIAGarrayA(I,J) = a_FWbySublim(I,J) * lhSublim             DIAGarrayA(I,J) = a_FWbySublim(I,J) * lhSublim
1151           ENDDO           ENDDO
1152          ENDDO          ENDDO
1153  cif     The actual vs. maximum latent heat flux  Cif     The actual vs. maximum latent heat flux
1154          IF ( useDiagnostics ) THEN          IF ( useDiagnostics ) THEN
1155            CALL DIAGNOSTICS_FILL(DIAGarrayA,            CALL DIAGNOSTICS_FILL(DIAGarrayA,
1156       &     'SIactLHF',0,1,3,bi,bj,myThid)       &     'SIactLHF',0,1,3,bi,bj,myThid)
# Line 1141  CADJ STORE a_FWbySublim    = comlev1_bib Line 1171  CADJ STORE a_FWbySublim    = comlev1_bib
1171    
1172  C switch heat fluxes from W/m2 to 'effective' ice meters  C switch heat fluxes from W/m2 to 'effective' ice meters
1173  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1174          DO K=1,nITD          DO IT=1,nITD
1175           DO J=1,sNy           DO J=1,sNy
1176            DO I=1,sNx            DO I=1,sNx
1177             a_QbyATMmult_cover(I,J,K)   = a_QbyATMmult_cover(I,J,K)             a_QbyATMmult_cover(I,J,IT)   = a_QbyATMmult_cover(I,J,IT)
1178       &          * convertQ2HI * AREAITDpreTH(I,J,K)       &          * convertQ2HI * AREAITDpreTH(I,J,IT)
1179             a_QSWbyATMmult_cover(I,J,K) = a_QSWbyATMmult_cover(I,J,K)             a_QSWbyATMmult_cover(I,J,IT) = a_QSWbyATMmult_cover(I,J,IT)
1180       &          * convertQ2HI * AREAITDpreTH(I,J,K)       &          * convertQ2HI * AREAITDpreTH(I,J,IT)
1181  C and initialize r_QbyATM_cover  C and initialize r_QbyATMmult_cover
1182             r_QbyATMmult_cover(I,J,K)=a_QbyATMmult_cover(I,J,K)             r_QbyATMmult_cover(I,J,IT)=a_QbyATMmult_cover(I,J,IT)
1183  C     Convert fresh water flux by sublimation to 'effective' ice meters.  C     Convert fresh water flux by sublimation to 'effective' ice meters.
1184  C     Negative sublimation is resublimation and will be added as snow.  C     Negative sublimation is resublimation and will be added as snow.
1185  #ifdef SEAICE_DISABLE_SUBLIM  #ifdef SEAICE_DISABLE_SUBLIM
1186             a_FWbySublimMult(I,J,K) = ZERO             a_FWbySublimMult(I,J,IT) = ZERO
1187  #endif  #endif
1188             a_FWbySublimMult(I,J,K) = SEAICE_deltaTtherm*recip_rhoIce             a_FWbySublimMult(I,J,IT) = SEAICE_deltaTtherm*recip_rhoIce
1189       &            * a_FWbySublimMult(I,J,K)*AREAITDpreTH(I,J,K)       &            * a_FWbySublimMult(I,J,IT)*AREAITDpreTH(I,J,IT)
1190             r_FWbySublimMult(I,J,K)=a_FWbySublimMult(I,J,K)             r_FWbySublimMult(I,J,IT)=a_FWbySublimMult(I,J,IT)
1191            ENDDO            ENDDO
1192           ENDDO           ENDDO
1193          ENDDO          ENDDO
# Line 1188  C and initialize r_QbyATM_cover/r_QbyATM Line 1218  C and initialize r_QbyATM_cover/r_QbyATM
1218  C     Convert fresh water flux by sublimation to 'effective' ice meters.  C     Convert fresh water flux by sublimation to 'effective' ice meters.
1219  C     Negative sublimation is resublimation and will be added as snow.  C     Negative sublimation is resublimation and will be added as snow.
1220  #ifdef SEAICE_DISABLE_SUBLIM  #ifdef SEAICE_DISABLE_SUBLIM
1221  cgf just for those who may need to omit this term to reproduce old results  Cgf just for those who may need to omit this term to reproduce old results
1222            a_FWbySublim(I,J) = ZERO            a_FWbySublim(I,J) = ZERO
1223  #endif  #endif /* SEAICE_DISABLE_SUBLIM */
1224            a_FWbySublim(I,J) = SEAICE_deltaTtherm*recip_rhoIce            a_FWbySublim(I,J) = SEAICE_deltaTtherm*recip_rhoIce
1225       &           * a_FWbySublim(I,J)*AREApreTH(I,J)       &           * a_FWbySublim(I,J)*AREApreTH(I,J)
1226            r_FWbySublim(I,J)=a_FWbySublim(I,J)            r_FWbySublim(I,J)=a_FWbySublim(I,J)
# Line 1214  CADJ STORE r_FWbySublim    = comlev1_bib Line 1244  CADJ STORE r_FWbySublim    = comlev1_bib
1244  Cgf no additional dependency through ice cover  Cgf no additional dependency through ice cover
1245          IF ( SEAICEadjMODE.GE.3 ) THEN          IF ( SEAICEadjMODE.GE.3 ) THEN
1246  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1247           DO K=1,nITD           DO IT=1,nITD
1248            DO J=1,sNy            DO J=1,sNy
1249             DO I=1,sNx             DO I=1,sNx
1250              a_QbyATMmult_cover(I,J,K)   = 0. _d 0              a_QbyATMmult_cover(I,J,IT)   = 0. _d 0
1251              r_QbyATMmult_cover(I,J,K)   = 0. _d 0              r_QbyATMmult_cover(I,J,IT)   = 0. _d 0
1252              a_QSWbyATMmult_cover(I,J,K) = 0. _d 0              a_QSWbyATMmult_cover(I,J,IT) = 0. _d 0
1253             ENDDO             ENDDO
1254            ENDDO            ENDDO
1255           ENDDO           ENDDO
# Line 1248  CADJ &                       key = iicek Line 1278  CADJ &                       key = iicek
1278    
1279          DO J=1,sNy          DO J=1,sNy
1280           DO I=1,sNx           DO I=1,sNx
1281  c         FREEZING TEMP. OF SEA WATER (deg C)  C         FREEZING TEMP. OF SEA WATER (deg C)
1282            tempFrz = SEAICE_tempFrz0 +            tempFrz = SEAICE_tempFrz0 +
1283       &              SEAICE_dTempFrz_dS *salt(I,J,kSurface,bi,bj)       &              SEAICE_dTempFrz_dS *salt(I,J,kSurface,bi,bj)
1284  c efficiency of turbulent fluxes : dependency to sign of THETA-TBC  C efficiency of turbulent fluxes : dependency to sign of THETA-TBC
1285            IF ( theta(I,J,kSurface,bi,bj) .GE. tempFrz ) THEN            IF ( theta(I,J,kSurface,bi,bj) .GE. tempFrz ) THEN
1286             tmpscal1 = SEAICE_mcPheePiston             tmpscal1 = SEAICE_mcPheePiston
1287            ELSE            ELSE
1288             tmpscal1 =SEAICE_frazilFrac*drF(kSurface)/SEAICE_deltaTtherm             tmpscal1 =SEAICE_frazilFrac*drF(kSurface)/SEAICE_deltaTtherm
1289            ENDIF            ENDIF
1290  c efficiency of turbulent fluxes : dependency to AREA (McPhee cases)  C efficiency of turbulent fluxes : dependency to AREA (McPhee cases)
1291            IF ( (AREApreTH(I,J) .GT. 0. _d 0).AND.            IF ( (AREApreTH(I,J) .GT. 0. _d 0).AND.
1292       &         (.NOT.SEAICE_mcPheeStepFunc) ) THEN       &         (.NOT.SEAICE_mcPheeStepFunc) ) THEN
1293             MixedLayerTurbulenceFactor = ONE -             MixedLayerTurbulenceFactor = ONE -
# Line 1268  c efficiency of turbulent fluxes : depen Line 1298  c efficiency of turbulent fluxes : depen
1298            ELSE            ELSE
1299             MixedLayerTurbulenceFactor = ONE             MixedLayerTurbulenceFactor = ONE
1300            ENDIF            ENDIF
1301  c maximum turbulent flux, in ice meters  C maximum turbulent flux, in ice meters
1302            tmpscal2= - (HeatCapacity_Cp*rhoConst * recip_QI)            tmpscal2= - (HeatCapacity_Cp*rhoConst * recip_QI)
1303       &         * (theta(I,J,kSurface,bi,bj)-tempFrz)       &         * (theta(I,J,kSurface,bi,bj)-tempFrz)
1304       &         * SEAICE_deltaTtherm * maskC(i,j,kSurface,bi,bj)       &         * SEAICE_deltaTtherm * maskC(i,j,kSurface,bi,bj)
1305  c available turbulent flux  C available turbulent flux
1306            a_QbyOCN(i,j) =            a_QbyOCN(i,j) =
1307       &         tmpscal1 * tmpscal2 * MixedLayerTurbulenceFactor       &         tmpscal1 * tmpscal2 * MixedLayerTurbulenceFactor
1308            r_QbyOCN(i,j) = a_QbyOCN(i,j)            r_QbyOCN(i,j) = a_QbyOCN(i,j)
# Line 1283  c available turbulent flux Line 1313  c available turbulent flux
1313          CALL ZERO_ADJ_1D( sNx*sNy, r_QbyOCN, myThid)          CALL ZERO_ADJ_1D( sNx*sNy, r_QbyOCN, myThid)
1314  #endif  #endif
1315    
   
1316  C ===================================================================  C ===================================================================
1317  C =========PART 3: determine effective thicknesses increments========  C =========PART 3: determine effective thicknesses increments========
1318  C ===================================================================  C ===================================================================
# Line 1296  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 1325  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
1325  CADJ STORE r_FWbySublim     = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE r_FWbySublim     = comlev1_bibj,key=iicekey,byte=isbyte
1326  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
1327  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1328          DO K=1,nITD          DO IT=1,nITD
1329  #endif  #endif
1330          DO J=1,sNy          DO J=1,sNy
1331           DO I=1,sNx           DO I=1,sNx
1332  C     First sublimate/deposite snow  C     First sublimate/deposite snow
1333            tmpscal2 =            tmpscal2 =
1334  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1335       &     MAX(MIN(r_FWbySublimMult(I,J,K),HSNOWITD(I,J,K,bi,bj)       &     MAX(MIN(r_FWbySublimMult(I,J,IT),HSNOWITD(I,J,IT,bi,bj)
1336       &             *SNOW2ICE),ZERO)       &             *SNOW2ICE),ZERO)
1337  C         accumulate change over ITD categories  C         accumulate change over ITD categories
1338            d_HSNWbySublim(I,J)     = d_HSNWbySublim(I,J)     - tmpscal2            d_HSNWbySublim(I,J)     = d_HSNWbySublim(I,J)      - tmpscal2
1339       &                                                       *ICE2SNOW       &                                                       *ICE2SNOW
1340            HSNOWITD(I,J,K,bi,bj)   = HSNOWITD(I,J,K,bi,bj)   - tmpscal2            HSNOWITD(I,J,IT,bi,bj)  = HSNOWITD(I,J,IT,bi,bj)   - tmpscal2
1341       &                                                       *ICE2SNOW       &                                                       *ICE2SNOW
1342            r_FWbySublimMult(I,J,K) = r_FWbySublimMult(I,J,K) - tmpscal2            r_FWbySublimMult(I,J,IT)= r_FWbySublimMult(I,J,IT) - tmpscal2
 C         keep total up to date, too  
           r_FWbySublim(I,J)       = r_FWbySublim(I,J)       - tmpscal2  
1343  #else  #else
1344       &     MAX(MIN(r_FWbySublim(I,J),HSNOW(I,J,bi,bj)*SNOW2ICE),ZERO)       &     MAX(MIN(r_FWbySublim(I,J),HSNOW(I,J,bi,bj)*SNOW2ICE),ZERO)
1345            d_HSNWbySublim(I,J) = - tmpscal2 * ICE2SNOW            d_HSNWbySublim(I,J) = - tmpscal2 * ICE2SNOW
# Line 1330  CADJ STORE r_FWbySublim    = comlev1_bib Line 1357  CADJ STORE r_FWbySublim    = comlev1_bib
1357  C     If anything is left, sublimate ice  C     If anything is left, sublimate ice
1358            tmpscal2 =            tmpscal2 =
1359  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1360       &     MAX(MIN(r_FWbySublimMult(I,J,K),HEFFITD(I,J,K,bi,bj)),ZERO)       &     MAX(MIN(r_FWbySublimMult(I,J,IT),HEFFITD(I,J,IT,bi,bj)),ZERO)
1361  C         accumulate change over ITD categories  C         accumulate change over ITD categories
1362            d_HSNWbySublim(I,J)     = d_HSNWbySublim(I,J)     - tmpscal2            d_HSNWbySublim(I,J)      = d_HSNWbySublim(I,J)      - tmpscal2
1363            HEFFITD(I,J,K,bi,bj)    = HEFFITD(I,J,K,bi,bj)    - tmpscal2            HEFFITD(I,J,IT,bi,bj)    = HEFFITD(I,J,IT,bi,bj)    - tmpscal2
1364            r_FWbySublimMult(I,J,K) = r_FWbySublimMult(I,J,K) - tmpscal2            r_FWbySublimMult(I,J,IT) = r_FWbySublimMult(I,J,IT) - tmpscal2
 C         keep total up to date, too  
           r_FWbySublim(I,J)       = r_FWbySublim(I,J)       - tmpscal2  
1365  #else  #else
1366       &     MAX(MIN(r_FWbySublim(I,J),HEFF(I,J,bi,bj)),ZERO)       &     MAX(MIN(r_FWbySublim(I,J),HEFF(I,J,bi,bj)),ZERO)
1367            d_HEFFbySublim(I,J) = - tmpscal2            d_HEFFbySublim(I,J) = - tmpscal2
# Line 1351  C     If anything is left, it will be ev Line 1376  C     If anything is left, it will be ev
1376  C     Since a_QbyATM_cover was computed for sublimation, not simple evaporation, we need to  C     Since a_QbyATM_cover was computed for sublimation, not simple evaporation, we need to
1377  C     remove the fusion part for the residual (that happens to be precisely r_FWbySublim).  C     remove the fusion part for the residual (that happens to be precisely r_FWbySublim).
1378  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1379            a_QbyATMmult_cover(I,J,K) = a_QbyATMmult_cover(I,J,K)            a_QbyATMmult_cover(I,J,IT) = a_QbyATMmult_cover(I,J,IT)
1380       &                              - r_FWbySublimMult(I,J,K)       &                               - r_FWbySublimMult(I,J,IT)
1381            r_QbyATMmult_cover(I,J,K) = r_QbyATMmult_cover(I,J,K)            r_QbyATMmult_cover(I,J,IT) = r_QbyATMmult_cover(I,J,IT)
1382       &                              - r_FWbySublimMult(I,J,K)       &                               - r_FWbySublimMult(I,J,IT)
1383           ENDDO  #else
         ENDDO  
 C       end K loop  
         ENDDO  
 C       then update totals        
         DO J=1,sNy  
          DO I=1,sNx  
 #endif  
1384            a_QbyATM_cover(I,J) = a_QbyATM_cover(I,J)-r_FWbySublim(I,J)            a_QbyATM_cover(I,J) = a_QbyATM_cover(I,J)-r_FWbySublim(I,J)
1385            r_QbyATM_cover(I,J) = r_QbyATM_cover(I,J)-r_FWbySublim(I,J)            r_QbyATM_cover(I,J) = r_QbyATM_cover(I,J)-r_FWbySublim(I,J)
1386    #endif
1387           ENDDO           ENDDO
1388          ENDDO          ENDDO
1389    #ifdef SEAICE_ITD
1390    C       end IT loop
1391            ENDDO
1392    #endif
1393    #ifdef SEAICE_DEBUG
1394  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1395          WRITE(msgBuf,'(A,7F6.2)')          WRITE(msgBuf,'(A,7F8.4)')
1396  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1397       &    ' SEAICE_GROWTH: Heff increments 1, HEFFITD = ',       &    ' SEAICE_GROWTH: Heff increments 1, HEFFITD = ',
1398       &     HEFFITD(20,20,:,bi,bj)       &     HEFFITD(1,1,:,bi,bj)
1399            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1400         &    SQUEEZE_RIGHT , myThid)
1401            WRITE(msgBuf,'(A,7F8.4)')
1402         &    ' SEAICE_GROWTH: Area increments 1, AREAITD = ',
1403         &     AREAITD(1,1,:,bi,bj)
1404  #else  #else
1405       &    ' SEAICE_GROWTH: Heff increments 1, HEFF = ',       &    ' SEAICE_GROWTH: Heff increments 1, HEFF = ',
1406       &     HEFF(20,20,bi,bj)       &     HEFF(1,1,bi,bj)
1407  #endif  #endif
1408          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1409       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1410  c ToM>>>  c ToM>>>
1411    #endif
1412    
1413  C compute ice thickness tendency due to ice-ocean interaction  C compute ice thickness tendency due to ice-ocean interaction
1414  C ===========================================================  C ===========================================================
# Line 1389  CADJ STORE r_QbyOCN = comlev1_bibj,key=i Line 1419  CADJ STORE r_QbyOCN = comlev1_bibj,key=i
1419  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
1420    
1421  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1422          DO K=1,nITD          DO IT=1,nITD
1423           DO J=1,sNy           DO J=1,sNy
1424            DO I=1,sNx            DO I=1,sNx
1425  C          ice growth/melt due to ocean heat is equally distributed under the ice  C          ice growth/melt due to ocean heat r_QbyOCN (W/m^2) is
1426  C          and hence weighted by fractional area of each thickness category  C          equally distributed under the ice and hence weighted by
1427             tmpscal1=MAX(r_QbyOCN(i,j)*areaFracFactor(I,J,K),  C          fractional area of each thickness category
1428       &                               -HEFFITD(I,J,K,bi,bj))             tmpscal1=MAX(r_QbyOCN(i,j)*areaFracFactor(I,J,IT),
1429             d_HEFFbyOCNonICE(I,J)= d_HEFFbyOCNonICE(I,J) + tmpscal1       &                               -HEFFITD(I,J,IT,bi,bj))
1430             r_QbyOCN(I,J)        = r_QbyOCN(I,J)         - tmpscal1             d_HEFFbyOCNonICE(I,J) = d_HEFFbyOCNonICE(I,J) + tmpscal1
1431             HEFFITD(I,J,K,bi,bj) = HEFFITD(I,J,K,bi,bj)  + tmpscal1             HEFFITD(I,J,IT,bi,bj) = HEFFITD(I,J,IT,bi,bj) + tmpscal1
1432  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
1433             SItrHEFF(I,J,bi,bj,2) = SItrHEFF(I,J,bi,bj,2)             SItrHEFF(I,J,bi,bj,2) = SItrHEFF(I,J,bi,bj,2)
1434       &                           + HEFFITD(I,J,K,bi,bj)       &                           + HEFFITD(I,J,IT,bi,bj)
1435  #endif  #endif
1436            ENDDO            ENDDO
1437           ENDDO           ENDDO
1438          ENDDO          ENDDO
1439            DO J=1,sNy
1440             DO I=1,sNx
1441              r_QbyOCN(I,J)=r_QbyOCN(I,J)-d_HEFFbyOCNonICE(I,J)
1442             ENDDO
1443            ENDDO
1444  #else /* SEAICE_ITD */  #else /* SEAICE_ITD */
1445          DO J=1,sNy          DO J=1,sNy
1446           DO I=1,sNx           DO I=1,sNx
# Line 1418  C          and hence weighted by fractio Line 1453  C          and hence weighted by fractio
1453           ENDDO           ENDDO
1454          ENDDO          ENDDO
1455  #endif /* SEAICE_ITD */  #endif /* SEAICE_ITD */
1456    #ifdef SEAICE_DEBUG
1457  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1458          WRITE(msgBuf,'(A,7F6.2)')          WRITE(msgBuf,'(A,7F8.4)')
1459  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1460       &    ' SEAICE_GROWTH: Heff increments 2, HEFFITD = ',       &    ' SEAICE_GROWTH: Heff increments 2, HEFFITD = ',
1461       &     HEFFITD(20,20,:,bi,bj)       &     HEFFITD(1,1,:,bi,bj)
1462            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1463         &    SQUEEZE_RIGHT , myThid)
1464            WRITE(msgBuf,'(A,7F8.4)')
1465         &    ' SEAICE_GROWTH: Area increments 2, AREAITD = ',
1466         &     AREAITD(1,1,:,bi,bj)
1467  #else  #else
1468       &    ' SEAICE_GROWTH: Heff increments 2, HEFF = ',       &    ' SEAICE_GROWTH: Heff increments 2, HEFF = ',
1469       &     HEFF(20,20,bi,bj)       &     HEFF(1,1,bi,bj)
1470  #endif  #endif
1471          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1472       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1473  c ToM>>>  c ToM>>>
1474    #endif
1475    
1476  C compute snow melt tendency due to snow-atmosphere interaction  C compute snow melt tendency due to snow-atmosphere interaction
1477  C ==================================================================  C ==================================================================
# Line 1440  CADJ STORE r_QbyATM_cover = comlev1_bibj Line 1482  CADJ STORE r_QbyATM_cover = comlev1_bibj
1482  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
1483    
1484  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1485          DO K=1,nITD          DO IT=1,nITD
1486           DO J=1,sNy           DO J=1,sNy
1487            DO I=1,sNx            DO I=1,sNx
1488  C     Convert to standard units (meters of ice) rather than to meters  C     Convert to standard units (meters of ice) rather than to meters
1489  C     of snow. This appears to be more robust.  C     of snow. This appears to be more robust.
1490            tmpscal1=MAX(r_QbyATMmult_cover(I,J,K),-HSNOWITD(I,J,K,bi,bj)             tmpscal1=MAX(r_QbyATMmult_cover(I,J,IT),
1491       &                                           *SNOW2ICE)       &                  -HSNOWITD(I,J,IT,bi,bj)*SNOW2ICE)
1492            tmpscal2=MIN(tmpscal1,0. _d 0)             tmpscal2=MIN(tmpscal1,0. _d 0)
1493  #ifdef SEAICE_MODIFY_GROWTH_ADJ  #ifdef SEAICE_MODIFY_GROWTH_ADJ
1494  Cgf no additional dependency through snow  Cgf no additional dependency through snow
1495            IF ( SEAICEadjMODE.GE.2 ) tmpscal2 = 0. _d 0             IF ( SEAICEadjMODE.GE.2 ) tmpscal2 = 0. _d 0
1496  #endif  #endif
1497            d_HSNWbyATMonSNW(I,J)=d_HSNWbyATMonSNW(I,J)+tmpscal2*ICE2SNOW             d_HSNWbyATMonSNW(I,J) = d_HSNWbyATMonSNW(I,J)
1498            HSNOWITD(I,J,K,bi,bj)=HSNOWITD(I,J,K,bi,bj)+tmpscal2*ICE2SNOW       &                           + tmpscal2*ICE2SNOW
1499            r_QbyATMmult_cover(I,J,K)=r_QbyATMmult_cover(I,J,K) - tmpscal2             HSNOWITD(I,J,IT,bi,bj)= HSNOWITD(I,J,IT,bi,bj)
1500  C         keep the total up to date, too       &                           + tmpscal2*ICE2SNOW
1501            r_QbyATM_cover(I,J)=r_QbyATM_cover(I,J) - tmpscal2             r_QbyATMmult_cover(I,J,IT)=r_QbyATMmult_cover(I,J,IT)
1502         &                           - tmpscal2
1503            ENDDO            ENDDO
1504           ENDDO           ENDDO
1505          ENDDO          ENDDO
# Line 1477  Cgf no additional dependency through sno Line 1520  Cgf no additional dependency through sno
1520           ENDDO           ENDDO
1521          ENDDO          ENDDO
1522  #endif /* SEAICE_ITD */  #endif /* SEAICE_ITD */
1523    #ifdef SEAICE_DEBUG
1524  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1525          WRITE(msgBuf,'(A,7F6.2)')          WRITE(msgBuf,'(A,7F8.4)')
1526  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1527       &    ' SEAICE_GROWTH: Heff increments 3, HEFFITD = ',       &    ' SEAICE_GROWTH: Heff increments 3, HEFFITD = ',
1528       &     HEFFITD(20,20,:,bi,bj)       &     HEFFITD(1,1,:,bi,bj)
1529            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1530         &    SQUEEZE_RIGHT , myThid)
1531            WRITE(msgBuf,'(A,7F8.4)')
1532         &    ' SEAICE_GROWTH: Area increments 3, AREAITD = ',
1533         &     AREAITD(1,1,:,bi,bj)
1534  #else  #else
1535       &    ' SEAICE_GROWTH: Heff increments 3, HEFF = ',       &    ' SEAICE_GROWTH: Heff increments 3, HEFF = ',
1536       &     HEFF(20,20,bi,bj)       &     HEFF(1,1,bi,bj)
1537  #endif  #endif
1538          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1539       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1540  c ToM>>>  c ToM>>>
1541    #endif
1542    
1543  C compute ice thickness tendency due to the atmosphere  C compute ice thickness tendency due to the atmosphere
1544  C ====================================================  C ====================================================
# Line 1504  Cgf the v1.81=>v1.82 revision would chan Line 1554  Cgf the v1.81=>v1.82 revision would chan
1554  Cgf warming conditions, the lab_sea results were not changed.  Cgf warming conditions, the lab_sea results were not changed.
1555    
1556  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1557          DO K=1,nITD          DO IT=1,nITD
1558           DO J=1,sNy           DO J=1,sNy
1559            DO I=1,sNx            DO I=1,sNx
1560  #ifdef SEAICE_GROWTH_LEGACY  #ifdef SEAICE_GROWTH_LEGACY
1561             tmpscal2 =MAX(-HEFFITD(I,J,K,bi,bj),r_QbyATMmult_cover(I,J,K))             tmpscal2 = MAX(-HEFFITD(I,J,IT,bi,bj),
1562         &                     r_QbyATMmult_cover(I,J,IT))
1563  #else  #else
1564             tmpscal2 =MAX(-HEFFITD(I,J,K,bi,bj),r_QbyATMmult_cover(I,J,K)             tmpscal2 = MAX(-HEFFITD(I,J,IT,bi,bj),
1565         &                     r_QbyATMmult_cover(I,J,IT)
1566  c         Limit ice growth by potential melt by ocean  c         Limit ice growth by potential melt by ocean
1567       &     + AREAITDpreTH(I,J,K) * r_QbyOCN(I,J))       &              + AREAITDpreTH(I,J,IT) * r_QbyOCN(I,J))
1568  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
1569             d_HEFFbyATMonOCN_cover(I,J) = d_HEFFbyATMonOCN_cover(I,J)             d_HEFFbyATMonOCN_cover(I,J) = d_HEFFbyATMonOCN_cover(I,J)
1570       &                                 + tmpscal2       &                                 + tmpscal2
1571             d_HEFFbyATMonOCN(I,J)       = d_HEFFbyATMonOCN(I,J)             d_HEFFbyATMonOCN(I,J)       = d_HEFFbyATMonOCN(I,J)
1572       &                                 + tmpscal2       &                                 + tmpscal2
1573             r_QbyATM_cover(I,J)         = r_QbyATM_cover(I,J)             r_QbyATMmult_cover(I,J,IT)  = r_QbyATMmult_cover(I,J,IT)
1574       &                                 - tmpscal2       &                                 - tmpscal2
1575             HEFFITD(I,J,K,bi,bj) = HEFFITD(I,J,K,bi,bj) + tmpscal2             HEFFITD(I,J,IT,bi,bj) = HEFFITD(I,J,IT,bi,bj) + tmpscal2
1576    
1577  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
1578             SItrHEFF(I,J,bi,bj,3) = SItrHEFF(I,J,bi,bj,3)             SItrHEFF(I,J,bi,bj,3) = SItrHEFF(I,J,bi,bj,3)
1579       &                           + HEFFITD(I,J,K,bi,bj)       &                           + HEFFITD(I,J,IT,bi,bj)
1580  #endif  #endif
1581            ENDDO            ENDDO
1582           ENDDO           ENDDO
# Line 1537  c         Limit ice growth by potential Line 1589  c         Limit ice growth by potential
1589            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J))            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J))
1590  #else  #else
1591            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J)+            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J)+
1592  c         Limit ice growth by potential melt by ocean  C         Limit ice growth by potential melt by ocean
1593       &        AREApreTH(I,J) * r_QbyOCN(I,J))       &        AREApreTH(I,J) * r_QbyOCN(I,J))
1594  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
1595    
# Line 1549  c         Limit ice growth by potential Line 1601  c         Limit ice growth by potential
1601  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
1602            SItrHEFF(I,J,bi,bj,3)=HEFF(I,J,bi,bj)            SItrHEFF(I,J,bi,bj,3)=HEFF(I,J,bi,bj)
1603  #endif  #endif
1604           ENDDO           ENDDO
1605          ENDDO          ENDDO
1606  #endif /* SEAICE_ITD */  #endif /* SEAICE_ITD */
1607    #ifdef SEAICE_DEBUG
1608  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1609          WRITE(msgBuf,'(A,7F6.2)')          WRITE(msgBuf,'(A,7F8.4)')
1610  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1611       &    ' SEAICE_GROWTH: Heff increments 4, HEFFITD = ',       &    ' SEAICE_GROWTH: Heff increments 4, HEFFITD = ',
1612       &     HEFFITD(20,20,:,bi,bj)       &     HEFFITD(1,1,:,bi,bj)
1613            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1614         &    SQUEEZE_RIGHT , myThid)
1615            WRITE(msgBuf,'(A,7F8.4)')
1616         &    ' SEAICE_GROWTH: Area increments 4, AREAITD = ',
1617         &     AREAITD(1,1,:,bi,bj)
1618  #else  #else
1619       &    ' SEAICE_GROWTH: Heff increments 4, HEFF = ',       &    ' SEAICE_GROWTH: Heff increments 4, HEFF = ',
1620       &     HEFF(20,20,bi,bj)       &     HEFF(1,1,bi,bj)
1621  #endif  #endif
1622          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1623       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1624  c ToM>>>  c ToM>>>
1625    #endif
1626    
1627  C attribute precip to fresh water or snow stock,  C add snow precipitation to HSNOW.
 C depending on atmospheric conditions.  
1628  C =================================================  C =================================================
1629  #ifdef ALLOW_ATM_TEMP  #ifdef ALLOW_ATM_TEMP
1630  #ifdef ALLOW_AUTODIFF_TAMC  # ifdef ALLOW_AUTODIFF_TAMC
1631  CADJ STORE a_QbyATM_cover = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE a_QbyATM_cover = comlev1_bibj,key=iicekey,byte=isbyte
1632  CADJ STORE PRECIP(:,:,bi,bj) = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE PRECIP(:,:,bi,bj) = comlev1_bibj,key=iicekey,byte=isbyte
1633  CADJ STORE AREApreTH = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE AREApreTH = comlev1_bibj,key=iicekey,byte=isbyte
1634  #endif /* ALLOW_AUTODIFF_TAMC */  # endif /* ALLOW_AUTODIFF_TAMC */
1635          DO J=1,sNy          IF ( snowPrecipFile .NE. ' ' ) THEN
1636           DO I=1,sNx  C add snowPrecip to HSNOW
1637             DO J=1,sNy
1638              DO I=1,sNx
1639               d_HSNWbyRAIN(I,J) = convertPRECIP2HI * ICE2SNOW *
1640         &          snowPrecip(i,j,bi,bj) * AREApreTH(I,J)
1641               d_HFRWbyRAIN(I,J) = -convertPRECIP2HI *
1642         &          ( PRECIP(I,J,bi,bj) - snowPrecip(I,J,bi,bj) ) *
1643         &          AREApreTH(I,J)
1644               HSNOW(I,J,bi,bj) = HSNOW(I,J,bi,bj) + d_HSNWbyRAIN(I,J)
1645              ENDDO
1646             ENDDO
1647            ELSE
1648    C attribute precip to fresh water or snow stock,
1649    C depending on atmospheric conditions.
1650             DO J=1,sNy
1651              DO I=1,sNx
1652  C possible alternatives to the a_QbyATM_cover criterium  C possible alternatives to the a_QbyATM_cover criterium
1653  c          IF (TICE(I,J,bi,bj) .LT. TMIX) THEN  c          IF (TICE(I,J,bi,bj) .LT. TMIX) THEN
1654  c          IF (atemp(I,J,bi,bj) .LT. celsius2K) THEN  c          IF (atemp(I,J,bi,bj) .LT. celsius2K) THEN
1655            IF ( a_QbyATM_cover(I,J).GE. 0. _d 0 ) THEN             IF ( a_QbyATM_cover(I,J).GE. 0. _d 0 ) THEN
1656  C           add precip as snow  C           add precip as snow
1657              d_HFRWbyRAIN(I,J)=0. _d 0              d_HFRWbyRAIN(I,J)=0. _d 0
1658              d_HSNWbyRAIN(I,J)=convertPRECIP2HI*ICE2SNOW*              d_HSNWbyRAIN(I,J)=convertPRECIP2HI*ICE2SNOW*
1659       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)
1660            ELSE             ELSE
1661  C           add precip to the fresh water bucket  C           add precip to the fresh water bucket
1662              d_HFRWbyRAIN(I,J)=-convertPRECIP2HI*              d_HFRWbyRAIN(I,J)=-convertPRECIP2HI*
1663       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)
1664              d_HSNWbyRAIN(I,J)=0. _d 0              d_HSNWbyRAIN(I,J)=0. _d 0
1665            ENDIF             ENDIF
1666           ENDDO           ENDDO
1667          ENDDO          ENDDO
1668  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1669          DO K=1,nITD          DO IT=1,nITD
1670           DO J=1,sNy           DO J=1,sNy
1671            DO I=1,sNx            DO I=1,sNx
1672             HSNOWITD(I,J,K,bi,bj) = HSNOWITD(I,J,K,bi,bj)             HSNOWITD(I,J,IT,bi,bj) = HSNOWITD(I,J,IT,bi,bj)
1673       &     + d_HSNWbyRAIN(I,J)*areaFracFactor(I,J,K)       &     + d_HSNWbyRAIN(I,J)*areaFracFactor(I,J,IT)
1674            ENDDO            ENDDO
1675           ENDDO           ENDDO
1676          ENDDO          ENDDO
# Line 1611  C           add precip to the fresh wate Line 1684  C           add precip to the fresh wate
1684  Cgf note: this does not affect air-sea heat flux,  Cgf note: this does not affect air-sea heat flux,
1685  Cgf since the implied air heat gain to turn  Cgf since the implied air heat gain to turn
1686  Cgf rain to snow is not a surface process.  Cgf rain to snow is not a surface process.
1687    C end of IF statement snowPrecipFile:
1688            ENDIF
1689  #endif /* ALLOW_ATM_TEMP */  #endif /* ALLOW_ATM_TEMP */
1690    #ifdef SEAICE_DEBUG
1691  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1692          WRITE(msgBuf,'(A,7F6.2)')          WRITE(msgBuf,'(A,7F8.4)')
1693  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1694       &    ' SEAICE_GROWTH: Heff increments 5, HEFFITD = ',       &    ' SEAICE_GROWTH: Heff increments 5, HEFFITD = ',
1695       &     HEFFITD(20,20,:,bi,bj)       &     HEFFITD(1,1,:,bi,bj)
1696            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1697         &    SQUEEZE_RIGHT , myThid)
1698            WRITE(msgBuf,'(A,7F8.4)')
1699         &    ' SEAICE_GROWTH: Area increments 5, AREAITD = ',
1700         &     AREAITD(1,1,:,bi,bj)
1701  #else  #else
1702       &    ' SEAICE_GROWTH: Heff increments 5, HEFF = ',       &    ' SEAICE_GROWTH: Heff increments 5, HEFF = ',
1703       &     HEFF(20,20,bi,bj)       &     HEFF(1,1,bi,bj)
1704  #endif  #endif
1705          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1706       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1707  c ToM>>>  c ToM>>>
1708    #endif
1709    
1710  C compute snow melt due to heat available from ocean.  C compute snow melt due to heat available from ocean.
1711  C =================================================================  C =================================================================
# Line 1637  CADJ STORE r_QbyOCN = comlev1_bibj,key=i Line 1719  CADJ STORE r_QbyOCN = comlev1_bibj,key=i
1719  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
1720    
1721  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1722          DO K=1,nITD          DO IT=1,nITD
1723           DO J=1,sNy           DO J=1,sNy
1724            DO I=1,sNx            DO I=1,sNx
1725             tmpscal1=MAX(r_QbyOCN(i,j)*ICE2SNOW*areaFracFactor(I,J,K),             tmpscal1=MAX(r_QbyOCN(i,j)*ICE2SNOW*areaFracFactor(I,J,IT),
1726       &                  -HSNOWITD(I,J,K,bi,bj))       &                  -HSNOWITD(I,J,IT,bi,bj))
1727             tmpscal2=MIN(tmpscal1,0. _d 0)             tmpscal2=MIN(tmpscal1,0. _d 0)
1728  #ifdef SEAICE_MODIFY_GROWTH_ADJ  #ifdef SEAICE_MODIFY_GROWTH_ADJ
1729  Cgf no additional dependency through snow  Cgf no additional dependency through snow
# Line 1649  Cgf no additional dependency through sno Line 1731  Cgf no additional dependency through sno
1731  #endif  #endif
1732             d_HSNWbyOCNonSNW(I,J) = d_HSNWbyOCNonSNW(I,J) + tmpscal2             d_HSNWbyOCNonSNW(I,J) = d_HSNWbyOCNonSNW(I,J) + tmpscal2
1733             r_QbyOCN(I,J)=r_QbyOCN(I,J) - tmpscal2*SNOW2ICE             r_QbyOCN(I,J)=r_QbyOCN(I,J) - tmpscal2*SNOW2ICE
1734             HSNOWITD(I,J,K,bi,bj) = HSNOWITD(I,J,K,bi,bj) + tmpscal2             HSNOWITD(I,J,IT,bi,bj) = HSNOWITD(I,J,IT,bi,bj) + tmpscal2
1735            ENDDO            ENDDO
1736           ENDDO           ENDDO
1737          ENDDO          ENDDO
# Line 1671  Cgf no additional dependency through sno Line 1753  Cgf no additional dependency through sno
1753  #endif /* SEAICE_ITD */  #endif /* SEAICE_ITD */
1754  #endif /* SEAICE_EXCLUDE_FOR_EXACT_AD_TESTING */  #endif /* SEAICE_EXCLUDE_FOR_EXACT_AD_TESTING */
1755  Cph)  Cph)
1756    #ifdef SEAICE_DEBUG
1757  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1758          WRITE(msgBuf,'(A,7F6.2)')          WRITE(msgBuf,'(A,7F8.4)')
1759  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1760       &    ' SEAICE_GROWTH: Heff increments 6, HEFFITD = ',       &    ' SEAICE_GROWTH: Heff increments 6, HEFFITD = ',
1761       &     HEFFITD(20,20,:,bi,bj)       &     HEFFITD(1,1,:,bi,bj)
1762            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1763         &    SQUEEZE_RIGHT , myThid)
1764            WRITE(msgBuf,'(A,7F8.4)')
1765         &    ' SEAICE_GROWTH: Area increments 6, AREAITD = ',
1766         &     AREAITD(1,1,:,bi,bj)
1767  #else  #else
1768       &    ' SEAICE_GROWTH: Heff increments 6, HEFF = ',       &    ' SEAICE_GROWTH: Heff increments 6, HEFF = ',
1769       &     HEFF(20,20,bi,bj)       &     HEFF(1,1,bi,bj)
1770  #endif  #endif
1771          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1772       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1773  c ToM>>>  c ToM>>>
1774    #endif
1775    
1776  C gain of new ice over open water  C gain of new ice over open water
1777  C ===============================  C ===============================
# Line 1696  CADJ STORE a_QSWbyATM_open = comlev1_bib Line 1785  CADJ STORE a_QSWbyATM_open = comlev1_bib
1785    
1786          DO J=1,sNy          DO J=1,sNy
1787           DO I=1,sNx           DO I=1,sNx
1788  c           Initial ice growth is triggered by open water  C           Initial ice growth is triggered by open water
1789  c           heat flux overcoming potential melt by ocean  C           heat flux overcoming potential melt by ocean
1790              tmpscal1=r_QbyATM_open(I,J)+r_QbyOCN(i,j) *              tmpscal1=r_QbyATM_open(I,J)+r_QbyOCN(i,j) *
1791       &            (1.0 _d 0 - AREApreTH(I,J))       &            (1.0 _d 0 - AREApreTH(I,J))
1792  c           Penetrative shortwave flux beyond first layer  C           Penetrative shortwave flux beyond first layer
1793  c           that is therefore not available to ice growth/melt  C           that is therefore not available to ice growth/melt
1794              tmpscal2=SWFracB * a_QSWbyATM_open(I,J)              tmpscal2=SWFracB * a_QSWbyATM_open(I,J)
1795  C           impose -HEFF as the maxmum melting if SEAICE_doOpenWaterMelt  C           impose -HEFF as the maxmum melting if SEAICE_doOpenWaterMelt
1796  C           or 0. otherwise (no melting if not SEAICE_doOpenWaterMelt)  C           or 0. otherwise (no melting if not SEAICE_doOpenWaterMelt)
# Line 1714  C           or 0. otherwise (no melting Line 1803  C           or 0. otherwise (no melting
1803  C         open water area fraction  C         open water area fraction
1804            tmpscal0 = ONE-AREApreTH(I,J)            tmpscal0 = ONE-AREApreTH(I,J)
1805  C         determine thickness of new ice  C         determine thickness of new ice
1806  C         considering the entire open water area to refreeze  ctomC         considering the entire open water area to refreeze
1807            tmpscal1 = tmpscal3/tmpscal0  ctom          tmpscal1 = tmpscal3/tmpscal0
1808    C         considering a minimum lead ice thickness of 10 cm
1809    C         WATCH that leadIceThickMin is smaller that Hlimit(1)!
1810              leadIceThickMin = 0.1
1811              tmpscal1 = MAX(leadIceThickMin,tmpscal3/tmpscal0)
1812    C         adjust ice area fraction covered by new ice
1813              tmpscal0 = tmpscal3/tmpscal1
1814  C         then add new ice volume to appropriate thickness category  C         then add new ice volume to appropriate thickness category
1815            DO K=1,nITD            DO IT=1,nITD
1816             IF (tmpscal1.LT.Hlimit(K)) THEN             IF (tmpscal1.LT.Hlimit(IT)) THEN
1817              HEFFITD(I,J,K,bi,bj) = HEFFITD(I,J,K,bi,bj) + tmpscal3              HEFFITD(I,J,IT,bi,bj) = HEFFITD(I,J,IT,bi,bj) + tmpscal3
1818              tmpscal3=ZERO              tmpscal3=ZERO
1819  C not sure if AREAITD should be changed here since AREA is incremented  C not sure if AREAITD should be changed here since AREA is incremented
1820  C   in PART 4 below in non-itd code  C   in PART 4 below in non-itd code
1821  C in this scenario all open water is covered by new ice instantaneously,  C in this scenario all open water is covered by new ice instantaneously,
1822  C   i.e. no delayed lead closing is concidered such as is associated with  C   i.e. no delayed lead closing is concidered such as is associated with
1823  C   Hibler's h_0 parameter  C   Hibler's h_0 parameter
1824              AREAITD(I,J,K,bi,bj) = AREAITD(I,J,K,bi,bj)              AREAITD(I,J,IT,bi,bj) = AREAITD(I,J,IT,bi,bj)
1825       &                           + tmpscal0       &                           + tmpscal0
1826              tmpscal0=ZERO              tmpscal0=ZERO
1827             ENDIF             ENDIF
# Line 1739  C   Hibler's h_0 parameter Line 1834  C   Hibler's h_0 parameter
1834    
1835  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
1836  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1837          DO K=1,nITD          DO IT=1,nITD
1838           DO J=1,sNy           DO J=1,sNy
1839            DO I=1,sNx            DO I=1,sNx
1840  c needs to be here to allow use also with LEGACY branch  c needs to be here to allow use also with LEGACY branch
1841             SItrHEFF(I,J,bi,bj,4) = SItrHEFF(I,J,bi,bj,4)             SItrHEFF(I,J,bi,bj,4) = SItrHEFF(I,J,bi,bj,4)
1842       &                           + HEFFITD(I,J,K,bi,bj)       &                           + HEFFITD(I,J,IT,bi,bj)
1843            ENDDO            ENDDO
1844           ENDDO           ENDDO
1845          ENDDO          ENDDO
1846  #else  #else
1847          DO J=1,sNy          DO J=1,sNy
1848           DO I=1,sNx           DO I=1,sNx
1849  c needs to be here to allow use also with LEGACY branch  C needs to be here to allow use also with LEGACY branch
1850            SItrHEFF(I,J,bi,bj,4)=HEFF(I,J,bi,bj)            SItrHEFF(I,J,bi,bj,4)=HEFF(I,J,bi,bj)
1851           ENDDO           ENDDO
1852          ENDDO          ENDDO
1853  #endif  #endif
1854  #endif /* ALLOW_SITRACER */  #endif /* ALLOW_SITRACER */
1855    #ifdef SEAICE_DEBUG
1856  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1857          WRITE(msgBuf,'(A,7F6.2)')          WRITE(msgBuf,'(A,7F8.4)')
1858  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1859       &    ' SEAICE_GROWTH: Heff increments 7, HEFFITD = ',       &    ' SEAICE_GROWTH: Heff increments 7, HEFFITD = ',
1860       &     HEFFITD(20,20,:,bi,bj)       &     HEFFITD(1,1,:,bi,bj)
1861            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1862         &    SQUEEZE_RIGHT , myThid)
1863            WRITE(msgBuf,'(A,7F8.4)')
1864         &    ' SEAICE_GROWTH: Area increments 7, AREAITD = ',
1865         &     AREAITD(1,1,:,bi,bj)
1866  #else  #else
1867       &    ' SEAICE_GROWTH: Heff increments 7, HEFF = ',       &    ' SEAICE_GROWTH: Heff increments 7, HEFF = ',
1868       &     HEFF(20,20,bi,bj)       &     HEFF(1,1,bi,bj)
1869            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1870         &    SQUEEZE_RIGHT , myThid)
1871            WRITE(msgBuf,'(A,7F8.4)')
1872         &    ' SEAICE_GROWTH: Area increments 7, AREA = ',
1873         &     AREA(1,1,bi,bj)
1874  #endif  #endif
1875          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1876       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1877  c ToM>>>  c ToM>>>
1878    #endif
1879    
1880  C convert snow to ice if submerged.  C convert snow to ice if submerged.
1881  C =================================  C =================================
# Line 1781  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 1888  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
1888  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
1889          IF ( SEAICEuseFlooding ) THEN          IF ( SEAICEuseFlooding ) THEN
1890  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1891           DO K=1,nITD           DO IT=1,nITD
1892            DO J=1,sNy            DO J=1,sNy
1893             DO I=1,sNx             DO I=1,sNx
1894              tmpscal0 = (HSNOWITD(I,J,K,bi,bj)*SEAICE_rhoSnow              tmpscal0 = (HSNOWITD(I,J,IT,bi,bj)*SEAICE_rhoSnow
1895       &               +HEFFITD(I,J,K,bi,bj)*SEAICE_rhoIce)*recip_rhoConst       &               +  HEFFITD(I,J,IT,bi,bj) *SEAICE_rhoIce)
1896              tmpscal1 = MAX( 0. _d 0, tmpscal0 - HEFFITD(I,J,K,bi,bj))       &                                        *recip_rhoConst
1897              d_HEFFbyFLOODING(I,J) = d_HEFFbyFLOODING(I,J) + tmpscal1              tmpscal1 = MAX( 0. _d 0, tmpscal0 - HEFFITD(I,J,IT,bi,bj))
1898              HEFFITD(I,J,K,bi,bj)  = HEFFITD(I,J,K,bi,bj)  + tmpscal1              d_HEFFbyFLOODING(I,J) = d_HEFFbyFLOODING(I,J)  + tmpscal1
1899              HSNOWITD(I,J,K,bi,bj) = HSNOWITD(I,J,K,bi,bj) - tmpscal1              HEFFITD(I,J,IT,bi,bj) = HEFFITD(I,J,IT,bi,bj)  + tmpscal1
1900                HSNOWITD(I,J,IT,bi,bj)= HSNOWITD(I,J,IT,bi,bj) - tmpscal1
1901       &                            * ICE2SNOW       &                            * ICE2SNOW
1902             ENDDO             ENDDO
1903            ENDDO            ENDDO
# Line 1804  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 1912  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
1912             HEFF(I,J,bi,bj) = HEFF(I,J,bi,bj)+d_HEFFbyFLOODING(I,J)             HEFF(I,J,bi,bj) = HEFF(I,J,bi,bj)+d_HEFFbyFLOODING(I,J)
1913             HSNOW(I,J,bi,bj) = HSNOW(I,J,bi,bj)-             HSNOW(I,J,bi,bj) = HSNOW(I,J,bi,bj)-
1914       &                           d_HEFFbyFLOODING(I,J)*ICE2SNOW       &                           d_HEFFbyFLOODING(I,J)*ICE2SNOW
1915            ENDDO            ENDDO
1916           ENDDO           ENDDO
1917  #endif  #endif
1918          ENDIF          ENDIF
1919  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
1920    #ifdef SEAICE_DEBUG
1921  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1922          WRITE(msgBuf,'(A,7F6.2)')          WRITE(msgBuf,'(A,7F8.4)')
1923  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1924       &    ' SEAICE_GROWTH: Heff increments 8, HEFFITD = ',       &    ' SEAICE_GROWTH: Heff increments 8, HEFFITD = ',
1925       &     HEFFITD(20,20,:,bi,bj)       &     HEFFITD(1,1,:,bi,bj)
1926            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1927         &    SQUEEZE_RIGHT , myThid)
1928            WRITE(msgBuf,'(A,7F8.4)')
1929         &    ' SEAICE_GROWTH: Area increments 8, AREAITD = ',
1930         &     AREAITD(1,1,:,bi,bj)
1931  #else  #else
1932       &    ' SEAICE_GROWTH: Heff increments 8, HEFF = ',       &    ' SEAICE_GROWTH: Heff increments 8, HEFF = ',
1933       &     HEFF(20,20,bi,bj)       &     HEFF(1,1,bi,bj)
1934            CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1935         &    SQUEEZE_RIGHT , myThid)
1936            WRITE(msgBuf,'(A,7F8.4)')
1937         &    ' SEAICE_GROWTH: Area increments 8, AREA = ',
1938         &     AREA(1,1,bi,bj)
1939  #endif  #endif
1940          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1941       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1942  c ToM>>>  c ToM>>>
1943    #endif
1944    
1945  C ===================================================================  C ===================================================================
1946  C ==========PART 4: determine ice cover fraction increments=========-  C ==========PART 4: determine ice cover fraction increments=========-
# Line 1851  C       replaces Hibler '79 scheme and l Line 1971  C       replaces Hibler '79 scheme and l
1971  C       because ITD accounts explicitly for lead openings and  C       because ITD accounts explicitly for lead openings and
1972  C       different melt rates due to varying ice thickness  C       different melt rates due to varying ice thickness
1973  C  C
1974  C       only consider ice area loss due to total ice thickness loss  C       only consider ice area loss due to total ice thickness loss;
1975  C       ice area gain due to freezing of open water as handled above  C       ice area gain due to freezing of open water is handled above
1976  C       under "gain of new ice over open water"  C       under "gain of new ice over open water"
1977  C  C
1978  C       does not account for lateral melt of ice floes  C       does not account for lateral melt of ice floes
1979  C  C
1980  C        AREAITD is incremented in section "gain of new ice over open water" above  C        AREAITD is incremented in section "gain of new ice over open water" above
1981  C  C
1982          DO K=1,nITD          DO IT=1,nITD
1983           DO J=1,sNy           DO J=1,sNy
1984            DO I=1,sNx           DO I=1,sNx
1985             IF (HEFFITD(I,J,K,bi,bj).LE.ZERO) THEN             IF (HEFFITD(I,J,IT,bi,bj).LE.ZERO) THEN
1986              AREAITD(I,J,K,bi,bj)=ZERO              AREAITD(I,J,IT,bi,bj)=ZERO
1987             ENDIF             ENDIF
1988  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
1989             SItrAREA(I,J,bi,bj,3) = SItrAREA(I,J,bi,bj,3)             SItrAREA(I,J,bi,bj,3) = SItrAREA(I,J,bi,bj,3)
1990       &                           + AREAITD(I,J,K,bi,bj)       &                           + AREAITD(I,J,IT,bi,bj)
1991  #endif /* ALLOW_SITRACER */  #endif /* ALLOW_SITRACER */
1992            ENDDO            ENDDO
1993           ENDDO           ENDDO
# Line 1948  C apply tendency Line 2068  C apply tendency
2068  Cgf 'bulk' linearization of area=f(HEFF)  Cgf 'bulk' linearization of area=f(HEFF)
2069          IF ( SEAICEadjMODE.GE.1 ) THEN          IF ( SEAICEadjMODE.GE.1 ) THEN
2070  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
2071           DO K=1,nITD           DO IT=1,nITD
2072            DO J=1,sNy            DO J=1,sNy
2073             DO I=1,sNx             DO I=1,sNx
2074              AREAITD(I,J,K,bi,bj) = AREAITDpreTH(I,J,K) + 0.1 _d 0 *              AREAITD(I,J,IT,bi,bj) = AREAITDpreTH(I,J,IT) + 0.1 _d 0 *
2075       &               ( HEFFITD(I,J,K,bi,bj) - HEFFITDpreTH(I,J,K) )       &               ( HEFFITD(I,J,IT,bi,bj) - HEFFITDpreTH(I,J,IT) )
2076             ENDDO             ENDDO
2077            ENDDO            ENDDO
2078           ENDDO           ENDDO
# Line 1995  CADJ &                       key = iicek Line 2115  CADJ &                       key = iicek
2115            tmpscal1 = d_HEFFbyNEG(I,J) + d_HEFFbyOCNonICE(I,J) +            tmpscal1 = d_HEFFbyNEG(I,J) + d_HEFFbyOCNonICE(I,J) +
2116       &               d_HEFFbyATMonOCN(I,J) + d_HEFFbyFLOODING(I,J)       &               d_HEFFbyATMonOCN(I,J) + d_HEFFbyFLOODING(I,J)
2117       &             + d_HEFFbySublim(I,J)       &             + d_HEFFbySublim(I,J)
2118  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
2119                     + d_HEFFbyRLX(I,J)       &             + d_HEFFbyRLX(I,J)
2120  #endif  #endif
2121            tmpscal2 = tmpscal1 * SEAICE_salt0 * HEFFM(I,J,bi,bj)            tmpscal2 = tmpscal1 * SEAICE_salt0 * HEFFM(I,J,bi,bj)
2122       &            * recip_deltaTtherm * SEAICE_rhoIce       &            * recip_deltaTtherm * SEAICE_rhoIce
# Line 2090  C set HSALT = 0 if HEFF = 0 and compute Line 2210  C set HSALT = 0 if HEFF = 0 and compute
2210          ENDDO          ENDDO
2211  #endif /* SEAICE_VARIABLE_SALINITY */  #endif /* SEAICE_VARIABLE_SALINITY */
2212    
   
2213  C =======================================================================  C =======================================================================
2214  C ==LEGACY PART 6 (LEGACY) treat pathological cases, then do flooding ===  C ==LEGACY PART 6 (LEGACY) treat pathological cases, then do flooding ===
2215  C =======================================================================  C =======================================================================
# Line 2173  C ================================= Line 2292  C =================================
2292  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
2293          DO J=1,sNy          DO J=1,sNy
2294           DO I=1,sNx           DO I=1,sNx
2295  c needs to be here to allow use also with LEGACY branch  C needs to be here to allow use also with LEGACY branch
2296            SItrHEFF(I,J,bi,bj,5)=HEFF(I,J,bi,bj)            SItrHEFF(I,J,bi,bj,5)=HEFF(I,J,bi,bj)
2297           ENDDO           ENDDO
2298          ENDDO          ENDDO
# Line 2187  C compute net heat flux leaving/entering Line 2306  C compute net heat flux leaving/entering
2306  C accounting for the part used in melt/freeze processes  C accounting for the part used in melt/freeze processes
2307  C =====================================================  C =====================================================
2308    
2309    #ifdef SEAICE_ITD
2310    C compute total of "mult" fluxes for ocean forcing
2311            DO J=1,sNy
2312             DO I=1,sNx
2313              a_QbyATM_cover(I,J)   = 0.0 _d 0
2314              r_QbyATM_cover(I,J)   = 0.0 _d 0
2315              a_QSWbyATM_cover(I,J) = 0.0 _d 0
2316              r_FWbySublim(I,J)     = 0.0 _d 0
2317             ENDDO
2318            ENDDO
2319            DO IT=1,nITD
2320             DO J=1,sNy
2321              DO I=1,sNx
2322    cToM if fluxes in W/m^2 then
2323    c           a_QbyATM_cover(I,J)=a_QbyATM_cover(I,J)
2324    c     &      + a_QbyATMmult_cover(I,J,IT) * areaFracFactor(I,J,IT)
2325    c           r_QbyATM_cover(I,J)=r_QbyATM_cover(I,J)
2326    c     &      + r_QbyATMmult_cover(I,J,IT) * areaFracFactor(I,J,IT)
2327    c           a_QSWbyATM_cover(I,J)=a_QSWbyATM_cover(I,J)
2328    c     &      + a_QSWbyATMmult_cover(I,J,IT) * areaFracFactor(I,J,IT)
2329    c           r_FWbySublim(I,J)=r_FWbySublim(I,J)
2330    c     &      + r_FWbySublimMult(I,J,IT) * areaFracFactor(I,J,IT)
2331    cToM if fluxes in effective ice meters, i.e. ice volume per area, then
2332               a_QbyATM_cover(I,J)=a_QbyATM_cover(I,J)
2333         &      + a_QbyATMmult_cover(I,J,IT)
2334               r_QbyATM_cover(I,J)=r_QbyATM_cover(I,J)
2335         &      + r_QbyATMmult_cover(I,J,IT)
2336               a_QSWbyATM_cover(I,J)=a_QSWbyATM_cover(I,J)
2337         &      + a_QSWbyATMmult_cover(I,J,IT)
2338               r_FWbySublim(I,J)=r_FWbySublim(I,J)
2339         &      + r_FWbySublimMult(I,J,IT)
2340              ENDDO
2341             ENDDO
2342            ENDDO
2343    #endif
2344    
2345  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
2346  CADJ STORE d_hsnwbyneg = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE d_hsnwbyneg = comlev1_bibj,key=iicekey,byte=isbyte
2347  CADJ STORE d_hsnwbyocnonsnw = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE d_hsnwbyocnonsnw = comlev1_bibj,key=iicekey,byte=isbyte
# Line 2200  C in principle a_QSWbyATM_cover should a Line 2355  C in principle a_QSWbyATM_cover should a
2355  C for backward compatibility it is left out of the LEGACY branch  C for backward compatibility it is left out of the LEGACY branch
2356       &         +   a_QSWbyATM_cover(I,J)       &         +   a_QSWbyATM_cover(I,J)
2357  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
2358       &         - ( d_HEFFbyOCNonICE(I,J) +       &         - ( d_HEFFbyOCNonICE(I,J)
2359       &             d_HSNWbyOCNonSNW(I,J)*SNOW2ICE +       &           + d_HSNWbyOCNonSNW(I,J)*SNOW2ICE
2360       &             d_HEFFbyNEG(I,J) +       &           + d_HEFFbyNEG(I,J)
2361  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
2362       &             d_HEFFbyRLX(I,J) +       &           + d_HEFFbyRLX(I,J)
2363  #endif  #endif
2364       &             d_HSNWbyNEG(I,J)*SNOW2ICE )       &           + d_HSNWbyNEG(I,J)*SNOW2ICE
2365       &         * maskC(I,J,kSurface,bi,bj)       &           - convertPRECIP2HI *
2366         &             snowPrecip(i,j,bi,bj) * (ONE-AREApreTH(I,J))
2367         &           ) * maskC(I,J,kSurface,bi,bj)
2368             ENDDO
2369            ENDDO
2370            DO J=1,sNy
2371             DO I=1,sNx
2372            QSW(I,J,bi,bj)  = a_QSWbyATM_cover(I,J) + a_QSWbyATM_open(I,J)            QSW(I,J,bi,bj)  = a_QSWbyATM_cover(I,J) + a_QSWbyATM_open(I,J)
2373           ENDDO           ENDDO
2374          ENDDO          ENDDO
# Line 2235  CADJ STORE d_HSNWbyATMonSNW = comlev1_bi Line 2396  CADJ STORE d_HSNWbyATMonSNW = comlev1_bi
2396  CADJ STORE theta(:,:,kSurface,bi,bj) = comlev1_bibj,  CADJ STORE theta(:,:,kSurface,bi,bj) = comlev1_bibj,
2397  CADJ &                       key = iicekey, byte = isbyte  CADJ &                       key = iicekey, byte = isbyte
2398  # endif /* ALLOW_AUTODIFF_TAMC */  # endif /* ALLOW_AUTODIFF_TAMC */
2399        IF ( SEAICEheatConsFix ) THEN  cgf Unlike for evap and precip, the temperature of gained/lost
2400  c Unlike for evap and precip, the temperature of gained/lost  C ocean liquid water due to melt/freeze of solid water cannot be chosen
2401  c ocean liquid water due to melt/freeze of solid water cannot be chosen  C arbitrarily to be e.g. the ocean SST. Indeed the present seaice model
2402  c to be e.g. the ocean SST. It must be done at 0degC. The fix below anticipates  C implies a constant ice temperature of 0degC. If melt/freeze water is exchanged
2403  c on external_forcing_surf.F and applies the correction to QNET.  C at a different temperature, it leads to a loss of conservation in the
2404        IF ((convertFW2Salt.EQ.-1.).OR.(temp_EvPrRn.EQ.UNSET_RL)) THEN  C ocean+ice system. While this is mostly a serious issue in the
2405  c I leave alone the exotic case when onvertFW2Salt.NE.-1 and temp_EvPrRn.NE.UNSET_RL and  C real fresh water + non linear free surface framework, a mismatch
2406  c the small error of the synchronous time stepping case (see external_forcing_surf.F).  C between ice and ocean boundary condition can result in all cases.
2407    C Below we therefore anticipate on external_forcing_surf.F
2408    C to diagnoze and/or apply the correction to QNET.
2409          DO J=1,sNy          DO J=1,sNy
2410           DO I=1,sNx           DO I=1,sNx
2411  #ifdef ALLOW_DIAGNOSTICS  C ocean water going to ice/snow, in precip units
2412  c store unaltered QNET for diagnostic purposes             tmpscal3=rhoConstFresh*maskC(I,J,kSurface,bi,bj)*(
            DIAGarrayA(I,J)=QNET(I,J,bi,bj)  
 #endif  
 c compute the ocean water going to ice/snow, in precip units  
            tmpscal3=rhoConstFresh*maskC(I,J,kSurface,bi,bj)*  
2413       &       ( d_HSNWbyATMonSNW(I,J)*SNOW2ICE       &       ( d_HSNWbyATMonSNW(I,J)*SNOW2ICE
2414       &       + d_HSNWbyOCNonSNW(I,J)*SNOW2ICE       &       + d_HSNWbyOCNonSNW(I,J)*SNOW2ICE
2415       &       + d_HEFFbyOCNonICE(I,J) + d_HEFFbyATMonOCN(I,J)       &       + d_HEFFbyOCNonICE(I,J) + d_HEFFbyATMonOCN(I,J)
2416       &       + d_HEFFbyNEG(I,J) + d_HSNWbyNEG(I,J)*SNOW2ICE )       &       + d_HEFFbyNEG(I,J) + d_HSNWbyNEG(I,J)*SNOW2ICE )
2417       &       * convertHI2PRECIP       &       * convertHI2PRECIP
2418  c factor in the heat content that external_forcing_surf.F       &       - snowPrecip(i,j,bi,bj) * (ONE-AREApreTH(I,J)) )
2419  c will associate with EMPMR, and remove it from QNET, so that  C factor in the heat content as done in external_forcing_surf.F
2420  c melt/freez water is in effect consistently gained/lost at 0degC        IF ( (temp_EvPrRn.NE.UNSET_RL).AND.useRealFreshWaterFlux
2421             IF (temp_EvPrRn.NE.UNSET_RL) THEN       &     .AND.(nonlinFreeSurf.NE.0) ) THEN
2422               QNET(I,J,bi,bj)=QNET(I,J,bi,bj) - tmpscal3*               tmpscal1 = - tmpscal3*
2423       &         HeatCapacity_Cp * temp_EvPrRn       &         HeatCapacity_Cp * temp_EvPrRn
2424             ELSE        ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL).AND.useRealFreshWaterFlux
2425               QNET(I,J,bi,bj)=QNET(I,J,bi,bj) - tmpscal3*       &         .AND.(nonlinFreeSurf.NE.0) ) THEN
2426                 tmpscal1 = - tmpscal3*
2427       &         HeatCapacity_Cp * theta(I,J,kSurface,bi,bj)       &         HeatCapacity_Cp * theta(I,J,kSurface,bi,bj)
2428             ENDIF        ELSEIF ( (temp_EvPrRn.NE.UNSET_RL) ) THEN
2429               tmpscal1 = - tmpscal3*HeatCapacity_Cp*
2430         &       ( temp_EvPrRn - theta(I,J,kSurface,bi,bj) )
2431          ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL) ) THEN
2432               tmpscal1 = ZERO
2433          ENDIF
2434  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
2435  c back out the eventual TFLUX adjustement and fill diag  C in all cases, diagnoze the boundary condition mismatch to SIaaflux
2436             DIAGarrayA(I,J)=QNET(I,J,bi,bj)-DIAGarrayA(I,J)             DIAGarrayA(I,J)=tmpscal1
2437  #endif  #endif
2438    C remove the mismatch when real fresh water is exchanged (at 0degC here)
2439          IF ( useRealFreshWaterFlux.AND.(nonlinFreeSurf.GT.0).AND.
2440         &   SEAICEheatConsFix ) QNET(I,J,bi,bj)=QNET(I,J,bi,bj)+tmpscal1
2441           ENDDO           ENDDO
2442          ENDDO          ENDDO
       ENDIF  
2443  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
2444          CALL DIAGNOSTICS_FILL(DIAGarrayA,          CALL DIAGNOSTICS_FILL(DIAGarrayA,
2445       &      'SIaaflux',0,1,3,bi,bj,myThid)       &      'SIaaflux',0,1,3,bi,bj,myThid)
2446  #endif  #endif
       ENDIF  
2447  #endif /* ndef SEAICE_DISABLE_HEATCONSFIX */  #endif /* ndef SEAICE_DISABLE_HEATCONSFIX */
2448    
2449    C compute the net heat flux, incl. adv. by water, entering ocean+ice
2450    C ===================================================================
2451             DO J=1,sNy
2452              DO I=1,sNx
2453    cgf 1) SIatmQnt (analogous to qnet; excl. adv. by water exch.)
2454    CML If I consider the atmosphere above the ice, the surface flux
2455    CML which is relevant for the air temperature dT/dt Eq
2456    CML accounts for sensible and radiation (with different treatment
2457    CML according to wave-length) fluxes but not for "latent heat flux",
2458    CML since it does not contribute to heating the air.
2459    CML So this diagnostic is only good for heat budget calculations within
2460    CML the ice-ocean system.
2461               SIatmQnt(I,J,bi,bj) =
2462         &            maskC(I,J,kSurface,bi,bj)*convertHI2Q*(
2463    #ifndef SEAICE_GROWTH_LEGACY
2464         &            a_QSWbyATM_cover(I,J) +
2465    #endif /* SEAICE_GROWTH_LEGACY */
2466         &            a_QbyATM_cover(I,J) + a_QbyATM_open(I,J) )
2467    cgf 2) SItflux (analogous to tflux; includes advection by water
2468    C             exchanged between atmosphere and ocean+ice)
2469    C solid water going to atm, in precip units
2470               tmpscal1 = rhoConstFresh*maskC(I,J,kSurface,bi,bj)
2471         &       * convertHI2PRECIP * ( - d_HSNWbyRAIN(I,J)*SNOW2ICE
2472         &       + a_FWbySublim(I,J) - r_FWbySublim(I,J) )
2473    C liquid water going to atm, in precip units
2474               tmpscal2=rhoConstFresh*maskC(I,J,kSurface,bi,bj)*
2475         &       ( ( EVAP(I,J,bi,bj)-PRECIP(I,J,bi,bj) )
2476         &         * ( ONE - AREApreTH(I,J) )
2477    #ifdef ALLOW_RUNOFF
2478         &         - RUNOFF(I,J,bi,bj)
2479    #endif /* ALLOW_RUNOFF */
2480         &         + ( d_HFRWbyRAIN(I,J) + r_FWbySublim(I,J) )
2481         &         *convertHI2PRECIP )
2482    C In real fresh water flux + nonlinFS, we factor in the advected specific
2483    C energy (referenced to 0 for 0deC liquid water). In virtual salt flux or
2484    C linFS, rain/evap get a special treatment (see external_forcing_surf.F).
2485               tmpscal1= - tmpscal1*
2486         &       ( -SEAICE_lhFusion + HeatCapacity_Cp * ZERO )
2487          IF ( (temp_EvPrRn.NE.UNSET_RL).AND.useRealFreshWaterFlux
2488         &     .AND.(nonlinFreeSurf.NE.0) ) THEN
2489               tmpscal2= - tmpscal2*
2490         &       ( ZERO + HeatCapacity_Cp * temp_EvPrRn )
2491          ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL).AND.useRealFreshWaterFlux
2492         &        .AND.(nonlinFreeSurf.NE.0) ) THEN
2493               tmpscal2= - tmpscal2*
2494         &       ( ZERO + HeatCapacity_Cp * theta(I,J,kSurface,bi,bj) )
2495          ELSEIF ( (temp_EvPrRn.NE.UNSET_RL) ) THEN
2496               tmpscal2= - tmpscal2*HeatCapacity_Cp*
2497         &       ( temp_EvPrRn - theta(I,J,kSurface,bi,bj) )
2498          ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL) ) THEN
2499               tmpscal2= ZERO
2500          ENDIF
2501               SItflux(I,J,bi,bj)=
2502         &            SIatmQnt(I,J,bi,bj)-tmpscal1-tmpscal2    
2503              ENDDO
2504             ENDDO
2505    
2506  C compute net fresh water flux leaving/entering  C compute net fresh water flux leaving/entering
2507  C the ocean, accounting for fresh/salt water stocks.  C the ocean, accounting for fresh/salt water stocks.
2508  C ==================================================  C ==================================================
# Line 2293  C ====================================== Line 2516  C ======================================
2516       &             +d_HEFFbyOCNonICE(I,J)       &             +d_HEFFbyOCNonICE(I,J)
2517       &             +d_HEFFbyATMonOCN(I,J)       &             +d_HEFFbyATMonOCN(I,J)
2518       &             +d_HEFFbyNEG(I,J)       &             +d_HEFFbyNEG(I,J)
2519  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
2520       &             +d_HEFFbyRLX(I,J)       &             +d_HEFFbyRLX(I,J)
2521  #endif  #endif
2522       &             +d_HSNWbyNEG(I,J)*SNOW2ICE       &             +d_HSNWbyNEG(I,J)*SNOW2ICE
# Line 2307  C     If r_FWbySublim>0, then it is evap Line 2530  C     If r_FWbySublim>0, then it is evap
2530  #endif /* ALLOW_RUNOFF */  #endif /* ALLOW_RUNOFF */
2531       &         + tmpscal1*convertHI2PRECIP       &         + tmpscal1*convertHI2PRECIP
2532       &         )*rhoConstFresh       &         )*rhoConstFresh
2533    c and the flux leaving/entering the ocean+ice
2534               SIatmFW(I,J,bi,bj) = maskC(I,J,kSurface,bi,bj)*(
2535         &          EVAP(I,J,bi,bj)*( ONE - AREApreTH(I,J) )
2536         &          - PRECIP(I,J,bi,bj)
2537    #ifdef ALLOW_RUNOFF
2538         &          - RUNOFF(I,J,bi,bj)
2539    #endif /* ALLOW_RUNOFF */
2540         &           )*rhoConstFresh
2541         &     + a_FWbySublim(I,J) * SEAICE_rhoIce * recip_deltaTtherm
2542    
2543           ENDDO           ENDDO
2544          ENDDO          ENDDO        
2545    
2546  #ifdef ALLOW_SSH_GLOBMEAN_COST_CONTRIBUTION  #ifdef ALLOW_SSH_GLOBMEAN_COST_CONTRIBUTION
2547  C--  C--
# Line 2379  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 2612  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
2612           ENDDO           ENDDO
2613          ENDIF          ENDIF
2614    
2615    #ifdef ALLOW_BALANCE_FLUXES
2616    C Compute tile integrals of heat/fresh water fluxes to/from atm.
2617    C ==============================================================
2618           FWFsiTile(bi,bj) = 0. _d 0
2619           IF ( balanceEmPmR ) THEN
2620            DO j=1,sNy
2621             DO i=1,sNx
2622              FWFsiTile(bi,bj) =
2623         &      FWFsiTile(bi,bj) + SIatmFW(i,j,bi,bj)
2624         &      * rA(i,j,bi,bj) * maskInC(i,j,bi,bj)
2625             ENDDO
2626            ENDDO
2627           ENDIF
2628    c to translate global mean FWF adjustements (see below) we may need :
2629           FWF2HFsiTile(bi,bj) = 0. _d 0      
2630           IF ( balanceEmPmR.AND.(temp_EvPrRn.EQ.UNSET_RL) ) THEN
2631            DO j=1,sNy
2632             DO i=1,sNx
2633              FWF2HFsiTile(bi,bj) = FWF2HFsiTile(bi,bj) +
2634         &      HeatCapacity_Cp * theta(I,J,kSurface,bi,bj)
2635         &      * rA(i,j,bi,bj) * maskInC(i,j,bi,bj)
2636             ENDDO
2637            ENDDO
2638           ENDIF
2639           HFsiTile(bi,bj) = 0. _d 0
2640           IF ( balanceQnet ) THEN
2641            DO j=1,sNy
2642             DO i=1,sNx
2643              HFsiTile(bi,bj) =
2644         &      HFsiTile(bi,bj) + SItflux(i,j,bi,bj)
2645         &      * rA(i,j,bi,bj) * maskInC(i,j,bi,bj)
2646             ENDDO
2647            ENDDO
2648           ENDIF
2649    #endif
2650    
2651  C ===================================================================  C ===================================================================
2652  C ======================PART 8: diagnostics==========================  C ======================PART 8: diagnostics==========================
2653  C ===================================================================  C ===================================================================
# Line 2429  C three that actually need intermediate Line 2698  C three that actually need intermediate
2698  #ifdef ALLOW_ATM_TEMP  #ifdef ALLOW_ATM_TEMP
2699           DO J=1,sNy           DO J=1,sNy
2700            DO I=1,sNx            DO I=1,sNx
 CML If I consider the atmosphere above the ice, the surface flux  
 CML which is relevant for the air temperature dT/dt Eq  
 CML accounts for sensible and radiation (with different treatment  
 CML according to wave-length) fluxes but not for "latent heat flux",  
 CML since it does not contribute to heating the air.  
 CML So this diagnostic is only good for heat budget calculations within  
 CML the ice-ocean system.  
            DIAGarrayA(I,J) = maskC(I,J,kSurface,bi,bj)*convertHI2Q*(  
 #ifndef SEAICE_GROWTH_LEGACY  
      &            a_QSWbyATM_cover(I,J) +  
 #endif /* SEAICE_GROWTH_LEGACY */  
      &            a_QbyATM_cover(I,J) + a_QbyATM_open(I,J) )  
 C  
2701             DIAGarrayB(I,J) = maskC(I,J,kSurface,bi,bj) *             DIAGarrayB(I,J) = maskC(I,J,kSurface,bi,bj) *
2702       &       a_FWbySublim(I,J) * SEAICE_rhoIce * recip_deltaTtherm       &       a_FWbySublim(I,J) * SEAICE_rhoIce * recip_deltaTtherm
 C  
            DIAGarrayC(I,J) = maskC(I,J,kSurface,bi,bj)*(  
      &          PRECIP(I,J,bi,bj)  
      &          - EVAP(I,J,bi,bj)*( ONE - AREApreTH(I,J) )  
 #ifdef ALLOW_RUNOFF  
      &          + RUNOFF(I,J,bi,bj)  
 #endif /* ALLOW_RUNOFF */  
      &           )*rhoConstFresh  
      &     - a_FWbySublim(I,J) * SEAICE_rhoIce * recip_deltaTtherm  
2703            ENDDO            ENDDO
2704           ENDDO           ENDDO
          CALL DIAGNOSTICS_FILL(DIAGarrayA,  
      &      'SIatmQnt',0,1,3,bi,bj,myThid)  
2705           CALL DIAGNOSTICS_FILL(DIAGarrayB,           CALL DIAGNOSTICS_FILL(DIAGarrayB,
2706       &      'SIfwSubl',0,1,3,bi,bj,myThid)       &      'SIfwSubl',0,1,3,bi,bj,myThid)
          CALL DIAGNOSTICS_FILL(DIAGarrayC,  
      &      'SIatmFW ',0,1,3,bi,bj,myThid)  
2707  C  C
2708           DO J=1,sNy           DO J=1,sNy
2709            DO I=1,sNx            DO I=1,sNx
# Line 2468  C the actual Freshwater flux of sublimat Line 2711  C the actual Freshwater flux of sublimat
2711             DIAGarrayA(I,J) = maskC(I,J,kSurface,bi,bj)             DIAGarrayA(I,J) = maskC(I,J,kSurface,bi,bj)
2712       &       * (a_FWbySublim(I,J)-r_FWbySublim(I,J))       &       * (a_FWbySublim(I,J)-r_FWbySublim(I,J))
2713       &       * SEAICE_rhoIce * recip_deltaTtherm       &       * SEAICE_rhoIce * recip_deltaTtherm
2714  c the residual Freshwater flux of sublimated ice  C the residual Freshwater flux of sublimated ice
2715             DIAGarrayC(I,J) = maskC(I,J,kSurface,bi,bj)             DIAGarrayC(I,J) = maskC(I,J,kSurface,bi,bj)
2716       &       * r_FWbySublim(I,J)       &       * r_FWbySublim(I,J)
2717       &       * SEAICE_rhoIce * recip_deltaTtherm       &       * SEAICE_rhoIce * recip_deltaTtherm
# Line 2485  C the latent heat flux Line 2728  C the latent heat flux
2728           CALL DIAGNOSTICS_FILL(DIAGarrayA,'SIacSubl',0,1,3,bi,bj,myThid)           CALL DIAGNOSTICS_FILL(DIAGarrayA,'SIacSubl',0,1,3,bi,bj,myThid)
2729           CALL DIAGNOSTICS_FILL(DIAGarrayC,'SIrsSubl',0,1,3,bi,bj,myThid)           CALL DIAGNOSTICS_FILL(DIAGarrayC,'SIrsSubl',0,1,3,bi,bj,myThid)
2730           CALL DIAGNOSTICS_FILL(DIAGarrayB,'SIhl    ',0,1,3,bi,bj,myThid)           CALL DIAGNOSTICS_FILL(DIAGarrayB,'SIhl    ',0,1,3,bi,bj,myThid)
   
          DO J=1,sNy  
           DO I=1,sNx  
 c compute ice/snow water going to atm, in precip units  
            tmpscal1 = rhoConstFresh*maskC(I,J,kSurface,bi,bj)  
      &       * convertHI2PRECIP * ( - d_HSNWbyRAIN(I,J)*SNOW2ICE  
      &       + a_FWbySublim(I,J) - r_FWbySublim(I,J) )  
 c compute ocean water going to atm, in precip units  
            tmpscal2=rhoConstFresh*maskC(I,J,kSurface,bi,bj)*  
      &       ( ( EVAP(I,J,bi,bj)-PRECIP(I,J,bi,bj) )  
      &         * ( ONE - AREApreTH(I,J) )  
 #ifdef ALLOW_RUNOFF  
      &         - RUNOFF(I,J,bi,bj)  
 #endif /* ALLOW_RUNOFF */  
      &         + ( d_HFRWbyRAIN(I,J) + r_FWbySublim(I,J) )  
      &         *convertHI2PRECIP )  
 c factor in the advected specific energy (referenced to 0 for 0deC liquid water)  
            tmpscal1= - tmpscal1*  
      &       ( -SEAICE_lhFusion + HeatCapacity_Cp * ZERO )  
            IF (temp_EvPrRn.NE.UNSET_RL) THEN  
            tmpscal2= - tmpscal2*  
      &       ( ZERO + HeatCapacity_Cp * temp_EvPrRn )  
            ELSE  
            tmpscal2= - tmpscal2*  
      &       ( ZERO + HeatCapacity_Cp * theta(I,J,kSurface,bi,bj) )  
            ENDIF  
 c add to SIatmQnt, leading to SItflux, which is analogous to TFLUX  
            DIAGarrayA(I,J)=maskC(I,J,kSurface,bi,bj)*convertHI2Q*(  
 #ifndef SEAICE_GROWTH_LEGACY  
      &            a_QSWbyATM_cover(I,J) +  
 #endif  
      &            a_QbyATM_cover(I,J) + a_QbyATM_open(I,J) )  
      &            -tmpscal1-tmpscal2  
           ENDDO  
          ENDDO  
          CALL DIAGNOSTICS_FILL(DIAGarrayA,  
      &      'SItflux ',0,1,3,bi,bj,myThid)  
2731  #endif /* ALLOW_ATM_TEMP */  #endif /* ALLOW_ATM_TEMP */
2732    
2733          ENDIF          ENDIF
# Line 2531  C close bi,bj loops Line 2737  C close bi,bj loops
2737         ENDDO         ENDDO
2738        ENDDO        ENDDO
2739    
2740    
2741    C ===================================================================
2742    C =========PART 9: HF/FWF global integrals and balancing=============
2743    C ===================================================================
2744    
2745    #ifdef ALLOW_BALANCE_FLUXES
2746    
2747    c 1)  global sums
2748    # ifdef ALLOW_AUTODIFF_TAMC
2749    CADJ STORE FWFsiTile = comlev1, key=ikey_dynamics, kind=isbyte
2750    CADJ STORE HFsiTile = comlev1, key=ikey_dynamics, kind=isbyte
2751    CADJ STORE FWF2HFsiTile = comlev1, key=ikey_dynamics, kind=isbyte
2752    # endif /* ALLOW_AUTODIFF_TAMC */
2753          FWFsiGlob=0. _d 0
2754          IF ( balanceEmPmR )
2755         &   CALL GLOBAL_SUM_TILE_RL( FWFsiTile, FWFsiGlob, myThid )        
2756          FWF2HFsiGlob=0. _d 0
2757          IF ( balanceEmPmR.AND.(temp_EvPrRn.EQ.UNSET_RL) ) THEN
2758             CALL GLOBAL_SUM_TILE_RL(FWF2HFsiTile, FWF2HFsiGlob, myThid)
2759          ELSEIF ( balanceEmPmR ) THEN
2760             FWF2HFsiGlob=HeatCapacity_Cp * temp_EvPrRn * globalArea
2761          ENDIF
2762          HFsiGlob=0. _d 0
2763          IF ( balanceQnet )
2764         &   CALL GLOBAL_SUM_TILE_RL( HFsiTile, HFsiGlob, myThid )
2765    
2766    c 2) global means
2767    c mean SIatmFW
2768          tmpscal0=FWFsiGlob / globalArea
2769    c corresponding mean advection by atm to ocean+ice water exchange
2770    c        (if mean SIatmFW was removed uniformely from ocean)
2771          tmpscal1=FWFsiGlob / globalArea * FWF2HFsiGlob / globalArea
2772    c mean SItflux (before potential adjustement due to SIatmFW)
2773          tmpscal2=HFsiGlob / globalArea
2774    c mean SItflux (after potential adjustement due to SIatmFW)
2775          IF ( balanceEmPmR ) tmpscal2=tmpscal2-tmpscal1
2776    
2777    c 3) balancing adjustments
2778          IF ( balanceEmPmR ) THEN
2779          DO bj=myByLo(myThid),myByHi(myThid)
2780           DO bi=myBxLo(myThid),myBxHi(myThid)
2781            DO j=1-OLy,sNy+OLy
2782             DO i=1-OLx,sNx+OLx
2783                empmr(i,j,bi,bj) = empmr(i,j,bi,bj) - tmpscal0
2784                SIatmFW(i,j,bi,bj) = SIatmFW(i,j,bi,bj) - tmpscal0
2785    c           adjust SItflux consistently      
2786                IF ( (temp_EvPrRn.NE.UNSET_RL).AND.
2787         &        useRealFreshWaterFlux.AND.(nonlinFreeSurf.NE.0) ) THEN
2788                tmpscal1=
2789         &       ( ZERO + HeatCapacity_Cp * temp_EvPrRn )
2790                ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL).AND.
2791         &        useRealFreshWaterFlux.AND.(nonlinFreeSurf.NE.0) ) THEN
2792                tmpscal1=
2793         &       ( ZERO + HeatCapacity_Cp * theta(I,J,kSurface,bi,bj) )
2794                ELSEIF ( (temp_EvPrRn.NE.UNSET_RL) ) THEN
2795                tmpscal1=
2796         &       HeatCapacity_Cp*(temp_EvPrRn - theta(I,J,kSurface,bi,bj))
2797                ELSE
2798                tmpscal1=ZERO
2799                ENDIF
2800                SItflux(i,j,bi,bj) = SItflux(i,j,bi,bj) - tmpscal0*tmpscal1
2801    c           no qnet or tflux adjustement is needed
2802             ENDDO
2803            ENDDO
2804           ENDDO
2805          ENDDO
2806          IF ( balancePrintMean ) THEN
2807           _BEGIN_MASTER( myThid )
2808           WRITE(msgbuf,'(a,a,e24.17)') 'rm Global mean of ',
2809         &      'SIatmFW = ', tmpscal0
2810           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
2811         &      SQUEEZE_RIGHT , myThid)
2812           _END_MASTER( myThid )
2813          ENDIF
2814          ENDIF
2815          IF ( balanceQnet ) THEN
2816          DO bj=myByLo(myThid),myByHi(myThid)
2817           DO bi=myBxLo(myThid),myBxHi(myThid)
2818            DO j=1-OLy,sNy+OLy
2819             DO i=1-OLx,sNx+OLx
2820                SItflux(i,j,bi,bj) = SItflux(i,j,bi,bj) - tmpscal2
2821                qnet(i,j,bi,bj) = qnet(i,j,bi,bj) - tmpscal2
2822                SIatmQnt(i,j,bi,bj) = SIatmQnt(i,j,bi,bj) - tmpscal2
2823             ENDDO
2824            ENDDO
2825           ENDDO
2826          ENDDO
2827          IF ( balancePrintMean ) THEN
2828           _BEGIN_MASTER( myThid )
2829           WRITE(msgbuf,'(a,a,e24.17)') 'rm Global mean of ',
2830         &      'SItflux = ', tmpscal2
2831           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
2832         &      SQUEEZE_RIGHT , myThid)
2833           _END_MASTER( myThid )
2834          ENDIF
2835          ENDIF
2836    #endif /* */
2837    
2838    #ifdef ALLOW_DIAGNOSTICS
2839    c these diags need to be done outside of the bi,bj loop so that
2840    c we may do potential global mean adjustement to them consistently.
2841             CALL DIAGNOSTICS_FILL(SItflux,
2842         &      'SItflux ',0,1,0,1,1,myThid)
2843             CALL DIAGNOSTICS_FILL(SIatmQnt,
2844         &      'SIatmQnt',0,1,0,1,1,myThid)
2845    c SIatmFW follows the same convention as empmr -- SIatmFW diag does not
2846             tmpscal1= - 1. _d 0
2847             CALL DIAGNOSTICS_SCALE_FILL(SIatmFW,
2848         &      tmpscal1,1,'SIatmFW ',0,1,0,1,1,myThid)
2849    #endif /* ALLOW_DIAGNOSTICS */
2850    
2851        RETURN        RETURN
2852        END        END

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.22