/[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.8 by torge, Mon Oct 22 16:02:25 2012 UTC revision 1.13 by torge, Fri Nov 2 19:15:42 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          CHARACTER*12 msgBufForm
66  c ToM>>>  c ToM>>>
67    #endif
68  C  C
69  C unit/sign convention:  C unit/sign convention:
70  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 98  C     i,j,bi,bj :: Loop counters
98        INTEGER i, j, bi, bj        INTEGER i, j, bi, bj
99  C     number of surface interface layer  C     number of surface interface layer
100        INTEGER kSurface        INTEGER kSurface
101    C     IT :: ice thickness category index (MULTICATEGORIES and ITD code)
102          INTEGER IT
103          _RL pFac
104  C     constants  C     constants
105        _RL tempFrz, ICE2SNOW, SNOW2ICE        _RL tempFrz, ICE2SNOW, SNOW2ICE
106        _RL QI, QS, recip_QI        _RL QI, QS, recip_QI
107          _RL lhSublim
108    
109    C conversion factors to go from Q (W/m2) to HEFF (ice meters)
110          _RL convertQ2HI, convertHI2Q
111    C conversion factors to go from precip (m/s) unit to HEFF (ice meters)
112          _RL convertPRECIP2HI, convertHI2PRECIP
113    C     Factor by which we increase the upper ocean friction velocity (u*) when
114    C     ice is absent in a grid cell  (dimensionless)
115          _RL MixedLayerTurbulenceFactor
116    
117    C     wind speed square
118          _RL SPEED_SQ
119    
120    C     Regularization values squared
121          _RL area_reg_sq, hice_reg_sq
122    C     pathological cases thresholds
123          _RL heffTooHeavy
124    
125    C     Helper variables: reciprocal of some constants
126          _RL recip_multDim
127          _RL recip_deltaTtherm
128          _RL recip_rhoIce
129    C     local value (=1/HO or 1/HO_south)
130          _RL recip_HO
131    C     local value (=1/ice thickness)
132          _RL recip_HH
133    C     facilitate multi-category snow implementation
134          _RL pFacSnow
135    
136    C     temporary variables available for the various computations
137          _RL tmpscal0, tmpscal1, tmpscal2, tmpscal3, tmpscal4
138    #ifdef SEAICE_ITD
139          _RL tmpscal1itd(1:sNx,1:sNy), tmpscal2itd(1:sNx,1:sNy)
140          _RL tmpscal3itd(1:sNx,1:sNy)
141    #endif
142    
143    #ifdef ALLOW_SITRACER
144          INTEGER iTr
145    #ifdef ALLOW_DIAGNOSTICS
146          CHARACTER*8   diagName
147    #endif
148    #endif /* ALLOW_SITRACER */
149    #ifdef ALLOW_AUTODIFF_TAMC
150          INTEGER ilockey
151    #endif
152    
153    C==   local arrays ==
154  C--   TmixLoc        :: ocean surface/mixed-layer temperature (in K)  C--   TmixLoc        :: ocean surface/mixed-layer temperature (in K)
155        _RL TmixLoc       (1:sNx,1:sNy)        _RL TmixLoc       (1:sNx,1:sNy)
156    
157    C     actual ice thickness (with upper and lower limit)
158          _RL heffActual          (1:sNx,1:sNy)
159    C     actual snow thickness
160          _RL hsnowActual         (1:sNx,1:sNy)
161    C     actual ice thickness (with lower limit only) Reciprocal
162          _RL recip_heffActual    (1:sNx,1:sNy)
163    
164    C     AREA_PRE :: hold sea-ice fraction field before any seaice-thermo update
165          _RL AREApreTH           (1:sNx,1:sNy)
166          _RL HEFFpreTH           (1:sNx,1:sNy)
167          _RL HSNWpreTH           (1:sNx,1:sNy)
168    #ifdef SEAICE_ITD
169          _RL AREAITDpreTH        (1:sNx,1:sNy,1:nITD)
170          _RL HEFFITDpreTH        (1:sNx,1:sNy,1:nITD)
171          _RL HSNWITDpreTH        (1:sNx,1:sNy,1:nITD)
172          _RL areaFracFactor      (1:sNx,1:sNy,1:nITD)
173          _RL leadIceThickMin
174    #endif
175    
176    C     wind speed
177          _RL UG                  (1:sNx,1:sNy)
178    
179    C     temporary variables available for the various computations
180          _RL tmparr1             (1:sNx,1:sNy)
181    #ifdef SEAICE_VARIABLE_SALINITY
182          _RL saltFluxAdjust      (1:sNx,1:sNy)
183    #endif
184    
185          _RL ticeInMult          (1:sNx,1:sNy,MULTDIM)
186          _RL ticeOutMult         (1:sNx,1:sNy,MULTDIM)
187          _RL heffActualMult      (1:sNx,1:sNy,MULTDIM)
188          _RL hsnowActualMult     (1:sNx,1:sNy,MULTDIM)
189    #ifdef SEAICE_ITD
190          _RL recip_heffActualMult(1:sNx,1:sNy,MULTDIM)
191    #endif
192          _RL a_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)
193          _RL a_QSWbyATMmult_cover(1:sNx,1:sNy,MULTDIM)
194          _RL a_FWbySublimMult    (1:sNx,1:sNy,MULTDIM)
195    #ifdef SEAICE_ITD
196          _RL r_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)
197          _RL r_FWbySublimMult    (1:sNx,1:sNy,MULTDIM)
198    #endif
199    
200  C     a_QbyATM_cover :: available heat (in W/m^2) due to the interaction of  C     a_QbyATM_cover :: available heat (in W/m^2) due to the interaction of
201  C             the atmosphere and the ocean surface - for ice covered water  C             the atmosphere and the ocean surface - for ice covered water
202  C     a_QbyATM_open  :: same but for open water  C     a_QbyATM_open  :: same but for open water
# Line 122  C             processes have been accoun Line 217  C             processes have been accoun
217        _RL a_QbyOCN            (1:sNx,1:sNy)        _RL a_QbyOCN            (1:sNx,1:sNy)
218        _RL r_QbyOCN            (1:sNx,1:sNy)        _RL r_QbyOCN            (1:sNx,1:sNy)
219    
220  C conversion factors to go from Q (W/m2) to HEFF (ice meters)  C     The change of mean ice thickness due to out-of-bounds values following
221        _RL convertQ2HI, convertHI2Q  C     sea ice dyhnamics
 C conversion factors to go from precip (m/s) unit to HEFF (ice meters)  
       _RL convertPRECIP2HI, convertHI2PRECIP  
   
 #ifdef ALLOW_DIAGNOSTICS  
 C ICE/SNOW stocks tendencies associated with the various melt/freeze processes  
       _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  
   
 c     The change of mean ice thickness due to out-of-bounds values following  
 c     sea ice dynamics  
222        _RL d_HEFFbyNEG         (1:sNx,1:sNy)        _RL d_HEFFbyNEG         (1:sNx,1:sNy)
223    
224  c     The change of mean ice thickness due to turbulent ocean-sea ice heat fluxes  C     The change of mean ice thickness due to turbulent ocean-sea ice heat fluxes
225        _RL d_HEFFbyOCNonICE    (1:sNx,1:sNy)        _RL d_HEFFbyOCNonICE    (1:sNx,1:sNy)
226    
227  c     The sum of mean ice thickness increments due to atmospheric fluxes over the open water  C     The sum of mean ice thickness increments due to atmospheric fluxes over
228  c     fraction and ice-covered fractions of the grid cell  C     the open water fraction and ice-covered fractions of the grid cell
229        _RL d_HEFFbyATMonOCN    (1:sNx,1:sNy)        _RL d_HEFFbyATMonOCN    (1:sNx,1:sNy)
230  c     The change of mean ice thickness due to flooding by snow  C     The change of mean ice thickness due to flooding by snow
231        _RL d_HEFFbyFLOODING    (1:sNx,1:sNy)        _RL d_HEFFbyFLOODING    (1:sNx,1:sNy)
232    
233  c     The mean ice thickness increments due to atmospheric fluxes over the open water  C     The mean ice thickness increments due to atmospheric fluxes over the open
234  c     fraction and ice-covered fractions of the grid cell, respectively  C     water fraction and ice-covered fractions of the grid cell, respectively
235        _RL d_HEFFbyATMonOCN_open(1:sNx,1:sNy)        _RL d_HEFFbyATMonOCN_open(1:sNx,1:sNy)
236        _RL d_HEFFbyATMonOCN_cover(1:sNx,1:sNy)        _RL d_HEFFbyATMonOCN_cover(1:sNx,1:sNy)
237    
# Line 165  c     fraction and ice-covered fractions Line 241  c     fraction and ice-covered fractions
241        _RL d_HSNWbyRAIN        (1:sNx,1:sNy)        _RL d_HSNWbyRAIN        (1:sNx,1:sNy)
242    
243        _RL d_HFRWbyRAIN        (1:sNx,1:sNy)        _RL d_HFRWbyRAIN        (1:sNx,1:sNy)
244  C  
245  C     a_FWbySublim :: fresh water flux implied by latent heat of  C     a_FWbySublim :: fresh water flux implied by latent heat of
246  C                     sublimation to atmosphere, same sign convention  C                     sublimation to atmosphere, same sign convention
247  C                     as EVAP (positive upward)  C                     as EVAP (positive upward)
# Line 178  C                     as EVAP (positive Line 254  C                     as EVAP (positive
254  C     The latent heat flux which will sublimate all snow and ice  C     The latent heat flux which will sublimate all snow and ice
255  C     over one time step  C     over one time step
256        _RL latentHeatFluxMax   (1:sNx,1:sNy)        _RL latentHeatFluxMax   (1:sNx,1:sNy)
257        _RL latentHeatFluxMaxMult  (1:sNx,1:sNy,MULTDIM)        _RL latentHeatFluxMaxMult(1:sNx,1:sNy,MULTDIM)
258  #endif  #endif
259    
260  C     actual ice thickness (with upper and lower limit)  #ifdef EXF_ALLOW_SEAICE_RELAX
261        _RL heffActual          (1:sNx,1:sNy)  C     ICE/SNOW stocks tendency associated with relaxation towards observation
262  C     actual snow thickness        _RL d_AREAbyRLX         (1:sNx,1:sNy)
263        _RL hsnowActual         (1:sNx,1:sNy)  C     The change of mean ice thickness due to relaxation
264  C     actual ice thickness (with lower limit only) Reciprocal        _RL d_HEFFbyRLX         (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  
   
 C     AREA_PRE :: hold sea-ice fraction field before any seaice-thermo update  
       _RL AREApreTH           (1:sNx,1:sNy)  
       _RL HEFFpreTH           (1:sNx,1:sNy)  
       _RL HSNWpreTH           (1:sNx,1:sNy)  
 #ifdef SEAICE_ITD  
       _RL AREAITDpreTH        (1:sNx,1:sNy,1:nITD)  
       _RL HEFFITDpreTH        (1:sNx,1:sNy,1:nITD)  
       _RL HSNWITDpreTH        (1:sNx,1:sNy,1:nITD)  
       _RL areaFracFactor      (1:sNx,1:sNy,1:nITD)  
       _RL leadIceThickMin  
 #endif  
   
 C     wind speed  
       _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  
   
 C temporary variables available for the various computations  
       _RL tmpscal0, tmpscal1, tmpscal2, tmpscal3, tmpscal4  
       _RL tmparr1             (1:sNx,1:sNy)  
   
 #ifdef SEAICE_VARIABLE_SALINITY  
       _RL saltFluxAdjust      (1:sNx,1:sNy)  
265  #endif  #endif
266    
       INTEGER ilockey  
       INTEGER it  
       _RL pFac  
       _RL ticeInMult          (1:sNx,1:sNy,MULTDIM)  
       _RL ticeOutMult         (1:sNx,1:sNy,MULTDIM)  
       _RL heffActualMult      (1:sNx,1:sNy,MULTDIM)  
 #ifdef SEAICE_ITD  
       _RL hsnowActualMult     (1:sNx,1:sNy,MULTDIM)  
       _RL recip_heffActualMult(1:sNx,1:sNy,MULTDIM)  
 #endif  
       _RL a_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)  
       _RL a_QSWbyATMmult_cover(1:sNx,1:sNy,MULTDIM)  
       _RL a_FWbySublimMult    (1:sNx,1:sNy,MULTDIM)  
267  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
268        _RL r_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)        _RL d_HEFFbySublim_ITD         (1:sNx,1:sNy,1:nITD)
269        _RL r_FWbySublimMult    (1:sNx,1:sNy,MULTDIM)        _RL d_HSNWbySublim_ITD         (1:sNx,1:sNy,1:nITD)
270          _RL d_HEFFbyOCNonICE_ITD       (1:sNx,1:sNy,1:nITD)
271          _RL d_HSNWbyATMonSNW_ITD       (1:sNx,1:sNy,1:nITD)
272          _RL d_HEFFbyATMonOCN_ITD       (1:sNx,1:sNy,1:nITD)
273          _RL d_HEFFbyATMonOCN_cover_ITD (1:sNx,1:sNy,1:nITD)
274          _RL d_HEFFbyATMonOCN_open_ITD  (1:sNx,1:sNy,1:nITD)
275          _RL d_HSNWbyRAIN_ITD           (1:sNx,1:sNy,1:nITD)
276          _RL d_HSNWbyOCNonSNW_ITD       (1:sNx,1:sNy,1:nITD)
277          _RL d_HEFFbyFLOODING_ITD       (1:sNx,1:sNy,1:nITD)
278  #endif  #endif
 C     Helper variables: reciprocal of some constants  
       _RL recip_multDim  
       _RL recip_deltaTtherm  
       _RL recip_rhoIce  
   
 C     Factor by which we increase the upper ocean friction velocity (u*) when  
 C     ice is absent in a grid cell  (dimensionless)  
       _RL MixedLayerTurbulenceFactor  
279    
 #ifdef ALLOW_SITRACER  
       INTEGER iTr  
       CHARACTER*8   diagName  
 #endif  
280  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
281  c     Helper variables for diagnostics  C ICE/SNOW stocks tendencies associated with the various melt/freeze processes
282          _RL d_AREAbyATM         (1:sNx,1:sNy)
283          _RL d_AREAbyOCN         (1:sNx,1:sNy)
284          _RL d_AREAbyICE         (1:sNx,1:sNy)
285    C     Helper variables for diagnostics
286        _RL DIAGarrayA    (1:sNx,1:sNy)        _RL DIAGarrayA    (1:sNx,1:sNy)
287        _RL DIAGarrayB    (1:sNx,1:sNy)        _RL DIAGarrayB    (1:sNx,1:sNy)
288        _RL DIAGarrayC    (1:sNx,1:sNy)        _RL DIAGarrayC    (1:sNx,1:sNy)
289        _RL DIAGarrayD    (1:sNx,1:sNy)        _RL DIAGarrayD    (1:sNx,1:sNy)
290  #endif  #endif /* ALLOW_DIAGNOSTICS */
291    
292          _RL SItflux     (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
293          _RL SIatmQnt    (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
294          _RL SIatmFW     (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
295    #ifdef ALLOW_BALANCE_FLUXES
296          _RL FWFsiTile(nSx,nSy)
297          _RL FWFsiGlob
298          _RL HFsiTile(nSx,nSy)
299          _RL HFsiGlob
300          _RL FWF2HFsiTile(nSx,nSy)
301          _RL FWF2HFsiGlob
302          CHARACTER*(max_len_mbuf) msgbuf
303    #endif
304    
305  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
306    
# Line 333  C conversion factors to go from precip ( Line 370  C conversion factors to go from precip (
370       &                       + act4*max1*max2*max3       &                       + act4*max1*max2*max3
371  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
372    
   
373  C array initializations  C array initializations
374  C =====================  C =====================
375    
# Line 356  C ===================== Line 392  C =====================
392            d_AREAbyOCN(I,J)           = 0.0 _d 0            d_AREAbyOCN(I,J)           = 0.0 _d 0
393  #endif  #endif
394    
395  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
396            d_AREAbyRLX(I,J)           = 0.0 _d 0            d_AREAbyRLX(I,J)           = 0.0 _d 0
397            d_HEFFbyRLX(I,J)           = 0.0 _d 0            d_HEFFbyRLX(I,J)           = 0.0 _d 0
398  #endif  #endif
# Line 380  C ===================== Line 416  C =====================
416  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
417            latentHeatFluxMax(I,J)     = 0.0 _d 0            latentHeatFluxMax(I,J)     = 0.0 _d 0
418  #endif  #endif
 c  
419            d_HFRWbyRAIN(I,J)          = 0.0 _d 0            d_HFRWbyRAIN(I,J)          = 0.0 _d 0
   
420            tmparr1(I,J)               = 0.0 _d 0            tmparr1(I,J)               = 0.0 _d 0
   
421  #ifdef SEAICE_VARIABLE_SALINITY  #ifdef SEAICE_VARIABLE_SALINITY
422            saltFluxAdjust(I,J)        = 0.0 _d 0            saltFluxAdjust(I,J)        = 0.0 _d 0
423  #endif  #endif
# Line 398  c Line 431  c
431              latentHeatFluxMaxMult(I,J,IT) = 0.0 _d 0              latentHeatFluxMaxMult(I,J,IT) = 0.0 _d 0
432  #endif  #endif
433  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
434              r_QbyATMmult_cover (I,J,IT)   = 0.0 _d 0              d_HEFFbySublim_ITD(I,J,IT)         = 0.0 _d 0
435              r_FWbySublimMult(I,J,IT)      = 0.0 _d 0              d_HSNWbySublim_ITD(I,J,IT)         = 0.0 _d 0
436                d_HEFFbyOCNonICE_ITD(I,J,IT)       = 0.0 _d 0
437                d_HSNWbyATMonSNW_ITD(I,J,IT)       = 0.0 _d 0
438                d_HEFFbyATMonOCN_ITD(I,J,IT)       = 0.0 _d 0
439                d_HEFFbyATMonOCN_cover_ITD(I,J,IT) = 0.0 _d 0
440                d_HEFFbyATMonOCN_open_ITD(I,J,IT)  = 0.0 _d 0
441                d_HSNWbyRAIN_ITD(I,J,IT)           = 0.0 _d 0
442                d_HSNWbyOCNonSNW_ITD(I,J,IT)       = 0.0 _d 0
443                d_HEFFbyFLOODING_ITD(I,J,IT)       = 0.0 _d 0
444                r_QbyATMmult_cover(I,J,IT) = 0.0 _d 0
445                r_FWbySublimMult(I,J,IT)   = 0.0 _d 0
446  #endif  #endif
447            ENDDO            ENDDO
448           ENDDO           ENDDO
# Line 412  c Line 455  c
455          ENDDO          ENDDO
456  #endif  #endif
457    
   
458  C =====================================================================  C =====================================================================
459  C ===========PART 1: treat pathological cases (post advdiff)===========  C ===========PART 1: treat pathological cases (post advdiff)===========
460  C =====================================================================  C =====================================================================
# Line 453  Cgf no dependency through pathological c Line 495  Cgf no dependency through pathological c
495          IF ( SEAICEadjMODE.EQ.0 ) THEN          IF ( SEAICEadjMODE.EQ.0 ) THEN
496  #endif  #endif
497    
498  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
499  CADJ STORE heff(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE heff(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte
500  CADJ STORE area(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE area(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte
501  C 0) relax sea ice concentration towards observation  C 0) relax sea ice concentration towards observation
# Line 483  C           d_HEFFbyRLX(i,j) = 1. _d 1 * Line 525  C           d_HEFFbyRLX(i,j) = 1. _d 1 *
525           ENDDO           ENDDO
526          ENDDO          ENDDO
527          ENDIF          ENDIF
528  #endif /* SEAICE_ALLOW_AREA_RELAXATION */  #endif /* EXF_ALLOW_SEAICE_RELAX */
529    
530  C 1) treat the case of negative values:  C 1) treat the case of negative values:
531    
# Line 492  CADJ STORE heff(:,:,bi,bj)  = comlev1_bi Line 534  CADJ STORE heff(:,:,bi,bj)  = comlev1_bi
534  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte
535  CADJ STORE area(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE area(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte
536  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
537    #ifdef SEAICE_ITD
538            DO IT=1,nITD
539    #endif
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 IT=1,nITD            tmpscal2=0. _d 0
544             tmpscal2=0. _d 0            tmpscal3=0. _d 0
545             tmpscal3=0. _d 0            tmpscal2=MAX(-HEFFITD(I,J,IT,bi,bj),0. _d 0)
546             tmpscal2=MAX(-HEFFITD(I,J,IT,bi,bj),0. _d 0)            HEFFITD(I,J,IT,bi,bj)=HEFFITD(I,J,IT,bi,bj)+tmpscal2
547             HEFFITD(I,J,IT,bi,bj)=HEFFITD(I,J,IT,bi,bj)+tmpscal2            d_HEFFbyNEG(I,J)=d_HEFFbyNEG(I,J)+tmpscal2
548             d_HEFFbyNEG(I,J)=d_HEFFbyNEG(I,J)+tmpscal2            tmpscal3=MAX(-HSNOWITD(I,J,IT,bi,bj),0. _d 0)
549             tmpscal3=MAX(-HSNOWITD(I,J,IT,bi,bj),0. _d 0)            HSNOWITD(I,J,IT,bi,bj)=HSNOWITD(I,J,IT,bi,bj)+tmpscal3
550             HSNOWITD(I,J,IT,bi,bj)=HSNOWITD(I,J,IT,bi,bj)+tmpscal3            d_HSNWbyNEG(I,J)=d_HSNWbyNEG(I,J)+tmpscal3
551             d_HSNWbyNEG(I,J)=d_HSNWbyNEG(I,J)+tmpscal3            AREAITD(I,J,IT,bi,bj)=MAX(AREAITD(I,J,IT,bi,bj),0. _d 0)
            AREAITD(I,J,IT,bi,bj)=MAX(AREAITD(I,J,IT,bi,bj),0. _d 0)  
           ENDDO  
552  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
553  C         by calling SEAICE_ITD_SUM  C         by calling SEAICE_ITD_SUM
554  #else  #else
# Line 517  C         by calling SEAICE_ITD_SUM Line 560  C         by calling SEAICE_ITD_SUM
560  #endif  #endif
561           ENDDO           ENDDO
562          ENDDO          ENDDO
563    #ifdef SEAICE_ITD
564            ENDDO
565    #endif
566    
567  C 1.25) treat the case of very thin ice:  C 1.25) treat the case of very thin ice:
568    
569  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
570  CADJ STORE heff(:,:,bi,bj)  = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE heff(:,:,bi,bj)  = comlev1_bibj, key = iicekey,byte=isbyte
571  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
         DO J=1,sNy  
          DO I=1,sNx  
572  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
573            DO IT=1,nITD          DO IT=1,nITD
574  #endif  #endif
575            DO J=1,sNy
576             DO I=1,sNx
577            tmpscal2=0. _d 0            tmpscal2=0. _d 0
578            tmpscal3=0. _d 0            tmpscal3=0. _d 0
579  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
580             IF (HEFFITD(I,J,IT,bi,bj).LE.siEps) THEN            IF (HEFFITD(I,J,IT,bi,bj).LE.siEps) THEN
581              tmpscal2=-HEFFITD(I,J,IT,bi,bj)             tmpscal2=-HEFFITD(I,J,IT,bi,bj)
582              tmpscal3=-HSNOWITD(I,J,IT,bi,bj)             tmpscal3=-HSNOWITD(I,J,IT,bi,bj)
583              TICES(I,J,IT,bi,bj)=celsius2K             TICES(I,J,IT,bi,bj)=celsius2K
584  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
585             ENDIF            ENDIF
586             HEFFITD(I,J,IT,bi,bj) =HEFFITD(I,J,IT,bi,bj) +tmpscal2            HEFFITD(I,J,IT,bi,bj) =HEFFITD(I,J,IT,bi,bj) +tmpscal2
587             HSNOWITD(I,J,IT,bi,bj)=HSNOWITD(I,J,IT,bi,bj)+tmpscal3            HSNOWITD(I,J,IT,bi,bj)=HSNOWITD(I,J,IT,bi,bj)+tmpscal3
588  #else  #else
589            IF (HEFF(I,J,bi,bj).LE.siEps) THEN            IF (HEFF(I,J,bi,bj).LE.siEps) THEN
590             tmpscal2=-HEFF(I,J,bi,bj)             tmpscal2=-HEFF(I,J,bi,bj)
# Line 553  CToM        TICE will be updated at end Line 599  CToM        TICE will be updated at end
599  #endif  #endif
600            d_HEFFbyNEG(I,J)=d_HEFFbyNEG(I,J)+tmpscal2            d_HEFFbyNEG(I,J)=d_HEFFbyNEG(I,J)+tmpscal2
601            d_HSNWbyNEG(I,J)=d_HSNWbyNEG(I,J)+tmpscal3            d_HSNWbyNEG(I,J)=d_HSNWbyNEG(I,J)+tmpscal3
 #ifdef SEAICE_ITD  
           ENDDO  
 #endif  
602           ENDDO           ENDDO
603          ENDDO          ENDDO
604    #ifdef SEAICE_ITD
605            ENDDO
606    #endif
607    
608  C 1.5) treat the case of area but no ice/snow:  C 1.5) treat the case of area but no ice/snow:
609    
# Line 565  C 1.5) treat the case of area but no ice Line 611  C 1.5) treat the case of area but no ice
611  CADJ STORE heff(:,:,bi,bj)  = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE heff(:,:,bi,bj)  = comlev1_bibj, key = iicekey,byte=isbyte
612  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte
613  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
614    #ifdef SEAICE_ITD
615            DO IT=1,nITD
616    #endif
617          DO J=1,sNy          DO J=1,sNy
618           DO I=1,sNx           DO I=1,sNx
619  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
620            DO IT=1,nITD            IF ((HEFFITD(I,J,IT,bi,bj).EQ.0. _d 0).AND.
621             IF ((HEFFITD(I,J,IT,bi,bj).EQ.0. _d 0).AND.       &        (HSNOWITD(I,J,IT,bi,bj).EQ.0. _d 0))
622       &         (HSNOWITD(I,J,IT,bi,bj).EQ.0. _d 0))       &     AREAITD(I,J,IT,bi,bj)=0. _d 0
      &      AREAITD(I,J,IT,bi,bj)=0. _d 0  
           ENDDO  
623  #else  #else
624            IF ((HEFF(i,j,bi,bj).EQ.0. _d 0).AND.            IF ((HEFF(i,j,bi,bj).EQ.0. _d 0).AND.
625       &        (HSNOW(i,j,bi,bj).EQ.0. _d 0)) AREA(I,J,bi,bj)=0. _d 0       &        (HSNOW(i,j,bi,bj).EQ.0. _d 0)) AREA(I,J,bi,bj)=0. _d 0
626  #endif  #endif
627           ENDDO           ENDDO
628          ENDDO          ENDDO
629    #ifdef SEAICE_ITD
630            ENDDO
631    #endif
632    
633  C 2) treat the case of very small area:  C 2) treat the case of very small area:
634    
# Line 586  C 2) treat the case of very small area: Line 636  C 2) treat the case of very small area:
636  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
637  CADJ STORE area(:,:,bi,bj)  = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE area(:,:,bi,bj)  = comlev1_bibj, key = iicekey,byte=isbyte
638  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
639    #ifdef SEAICE_ITD
640            DO IT=1,nITD
641    #endif
642          DO J=1,sNy          DO J=1,sNy
643           DO I=1,sNx           DO I=1,sNx
644  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
645            DO IT=1,nITD            IF ((HEFFITD(I,J,IT,bi,bj).GT.0).OR.
646             IF ((HEFFITD(I,J,IT,bi,bj).GT.0).OR.       &        (HSNOWITD(I,J,IT,bi,bj).GT.0)) THEN
647       &         (HSNOWITD(I,J,IT,bi,bj).GT.0)) THEN  CToM       SEAICE_area_floor*nITD cannot be allowed to exceed 1
648  CToM        SEAICE_area_floor*nITD cannot be allowed to exceed 1  C          hence use SEAICE_area_floor devided by nITD
649  C           hence use SEAICE_area_floor devided by nITD  C          (or install a warning in e.g. seaice_readparms.F)
650  C           (or install a warning in e.g. seaice_readparms.F)             AREAITD(I,J,IT,bi,bj)=
651              AREAITD(I,J,IT,bi,bj)=       &        MAX(AREAITD(I,J,IT,bi,bj),SEAICE_area_floor/float(nITD))
652       &         MAX(AREAITD(I,J,IT,bi,bj),SEAICE_area_floor/float(nITD))            ENDIF
            ENDIF  
           ENDDO  
653  #else  #else
654            IF ((HEFF(i,j,bi,bj).GT.0).OR.(HSNOW(i,j,bi,bj).GT.0)) THEN            IF ((HEFF(i,j,bi,bj).GT.0).OR.(HSNOW(i,j,bi,bj).GT.0)) THEN
655             AREA(I,J,bi,bj)=MAX(AREA(I,J,bi,bj),SEAICE_area_floor)             AREA(I,J,bi,bj)=MAX(AREA(I,J,bi,bj),SEAICE_area_floor)
# Line 606  C           (or install a warning in e.g Line 657  C           (or install a warning in e.g
657  #endif  #endif
658           ENDDO           ENDDO
659          ENDDO          ENDDO
660    #ifdef SEAICE_ITD
661            ENDDO
662    #endif
663  #endif /* DISABLE_AREA_FLOOR */  #endif /* DISABLE_AREA_FLOOR */
664    
665  C 2.5) treat case of excessive ice cover, e.g., due to ridging:  C 2.5) treat case of excessive ice cover, e.g., due to ridging:
# Line 631  CADJ STORE area(:,:,bi,bj)  = comlev1_bi Line 685  CADJ STORE area(:,:,bi,bj)  = comlev1_bi
685    
686  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
687  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
688          DO J=1,sNy          DO IT=1,nITD
689           DO I=1,sNx           DO J=1,sNy
690              DO I=1,sNx
691  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
692  C     weighted average of TICES  C     weighted average of TICES
693  C    also compute total of AREAITD (needed for finishing item 2.5, see below)  C    also compute total of AREAITD (needed for finishing item 2.5, see below)
694            tmpscal1 = 0. _d 0             IF (IT .eq. 1) THEN
695            tmpscal2 = 0. _d 0              tmpscal1itd(i,j) = 0. _d 0
696            tmpscal3 = 0. _d 0              tmpscal2itd(i,j) = 0. _d 0
697            DO IT=1,nITD              tmpscal3itd(i,j) = 0. _d 0
698             tmpscal1=tmpscal1 + TICES(I,J,IT,bi,bj)*HEFFITD(I,J,IT,bi,bj)             ENDIF
699             tmpscal2=tmpscal2 + HEFFITD(I,J,IT,bi,bj)             tmpscal1itd(i,j)=tmpscal1itd(i,j) + TICES(I,J,IT,bi,bj)
700             tmpscal3=tmpscal3 + AREAITD(I,J,IT,bi,bj)       &                                       * HEFFITD(I,J,IT,bi,bj)
701            ENDDO             tmpscal2itd(i,j)=tmpscal2itd(i,j) + HEFFITD(I,J,IT,bi,bj)
702            TICE(I,J,bi,bj)=tmpscal1/tmpscal2             tmpscal3itd(i,j)=tmpscal3itd(i,j) + AREAITD(I,J,IT,bi,bj)
703               IF (IT .eq. nITD) THEN
704                TICE(I,J,bi,bj)=tmpscal1itd(i,j)/tmpscal2itd(i,j)
705  C    lines of item 2.5 that were omitted:  C    lines of item 2.5 that were omitted:
706  C    in 2.5 these lines are executed before "ridging" is applied to AREA  C    in 2.5 these lines are executed before "ridging" is applied to AREA
707  C    hence we execute them here before SEAICE_ITD_REDIST is called  C    hence we execute them here before SEAICE_ITD_REDIST is called
708  C    although this means that AREA has not been completely regularized  C    although this means that AREA has not been completely regularized
709  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
710            DIAGarrayA(I,J) = tmpscal3              DIAGarrayA(I,J) = tmpscal3itd(i,j)
711  #endif  #endif
712  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
713            SItrAREA(I,J,bi,bj,1)=tmpscal3              SItrAREA(I,J,bi,bj,1)=tmpscal3itd(i,j)
714  #endif  #endif
715               ENDIF
716              ENDDO
717           ENDDO           ENDDO
718          ENDDO          ENDDO
719    
# Line 663  C    which includes ridging as in item 2 Line 722  C    which includes ridging as in item 2
722  C    and update AREA, HEFF, and HSNOW  C    and update AREA, HEFF, and HSNOW
723          CALL SEAICE_ITD_REDIST(bi, bj, myTime, myIter, myThid)          CALL SEAICE_ITD_REDIST(bi, bj, myTime, myIter, myThid)
724          CALL SEAICE_ITD_SUM(bi, bj, myTime, myIter, myThid)          CALL SEAICE_ITD_SUM(bi, bj, myTime, myIter, myThid)
725    #endif /* SEAICE_ITD */
726    
727  c ToM<<< debug seaice_growth  #ifdef SEAICE_DEBUG
728          WRITE(msgBuf,'(A,7F8.4)')  #ifdef SEAICE_ITD
729       &    ' SEAICE_GROWTH: Heff increments 0, HEFFITD = ',          WRITE(msgBufForm,'(A,I2,A)') '(A,',nITD,'F14.10)'
      &     HEFFITD(1,1,:,bi,bj)  
         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,  
      &    SQUEEZE_RIGHT , myThid)  
         WRITE(msgBuf,'(A,7F8.4)')  
      &    ' SEAICE_GROWTH: Area increments 0, AREAITD = ',  
      &     AREAITD(1,1,:,bi,bj)  
         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,  
      &    SQUEEZE_RIGHT , myThid)  
730  #else  #else
731          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBufForm,'(A,I2,A)') '(A,  F14.10)'
732    #endif
733            WRITE(msgBuf,msgBufForm)
734       &    ' SEAICE_GROWTH: Heff increments 0, HEFF = ',       &    ' SEAICE_GROWTH: Heff increments 0, HEFF = ',
735    #ifdef SEAICE_ITD
736         &     HEFFITD(1,1,:,bi,bj)
737    #else
738       &     HEFF(1,1,bi,bj)       &     HEFF(1,1,bi,bj)
739    #endif
740          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
741       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
742          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
743       &    ' SEAICE_GROWTH: Area increments 0, AREA = ',       &    ' SEAICE_GROWTH: Area increments 0, AREA = ',
744    #ifdef SEAICE_ITD
745         &     AREAITD(1,1,:,bi,bj)
746    #else
747       &     AREA(1,1,bi,bj)       &     AREA(1,1,bi,bj)
748    #endif
749          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
750       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
751  c ToM>>>  #endif
752  #endif /* SEAICE_ITD */  
753  #if (defined ALLOW_AUTODIFF_TAMC && defined SEAICE_MODIFY_GROWTH_ADJ)  #if (defined ALLOW_AUTODIFF_TAMC && defined SEAICE_MODIFY_GROWTH_ADJ)
754  C        end SEAICEadjMODE.EQ.0 statement:  C        end SEAICEadjMODE.EQ.0 statement:
755          ENDIF          ENDIF
# Line 732  C           if there's no ice, potential Line 794  C           if there's no ice, potential
794            ENDDO            ENDDO
795           ENDDO           ENDDO
796          ENDDO          ENDDO
797    #ifdef ALLOW_SITRACER
798  C prepare SItrHEFF to be computed as cumulative sum  C prepare SItrHEFF to be computed as cumulative sum
799          DO iTr=2,5          DO iTr=2,5
800           DO J=1,sNy           DO J=1,sNy
# Line 747  C prepare SItrAREA to be computed as cum Line 810  C prepare SItrAREA to be computed as cum
810           ENDDO           ENDDO
811          ENDDO          ENDDO
812  #endif  #endif
813    #endif /* SEAICE_ITD */
814    
815  C 4) treat sea ice salinity pathological cases  C 4) treat sea ice salinity pathological cases
816  #ifdef SEAICE_VARIABLE_SALINITY  #ifdef SEAICE_VARIABLE_SALINITY
# Line 875  cif       Do not regularize when HEFFpre Line 939  cif       Do not regularize when HEFFpre
939              tmpscal2         = HEFFpreTH(I,J)/tmpscal1              tmpscal2         = HEFFpreTH(I,J)/tmpscal1
940              heffActual(I,J)  = MAX(tmpscal2,SEAICE_hice_reg)              heffActual(I,J)  = MAX(tmpscal2,SEAICE_hice_reg)
941  #else /* SEAICE_GROWTH_LEGACY */  #else /* SEAICE_GROWTH_LEGACY */
942  cif        regularize AREA with SEAICE_area_reg  Cif        regularize AREA with SEAICE_area_reg
943             tmpscal1 = SQRT(AREApreTH(I,J)* AREApreTH(I,J) + area_reg_sq)             tmpscal1 = SQRT(AREApreTH(I,J)* AREApreTH(I,J) + area_reg_sq)
944  cif        heffActual calculated with the regularized AREA  Cif        heffActual calculated with the regularized AREA
945             tmpscal2 = HEFFpreTH(I,J) / tmpscal1             tmpscal2 = HEFFpreTH(I,J) / tmpscal1
946  cif        regularize heffActual with SEAICE_hice_reg (add lower bound)  Cif        regularize heffActual with SEAICE_hice_reg (add lower bound)
947             heffActual(I,J) = SQRT(tmpscal2 * tmpscal2 + hice_reg_sq)             heffActual(I,J) = SQRT(tmpscal2 * tmpscal2 + hice_reg_sq)
948  cif        hsnowActual calculated with the regularized AREA  Cif        hsnowActual calculated with the regularized AREA
949             hsnowActual(I,J) = HSNWpreTH(I,J) / tmpscal1             hsnowActual(I,J) = HSNWpreTH(I,J) / tmpscal1
950  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
951  cif        regularize the inverse of heffActual by hice_reg  Cif        regularize the inverse of heffActual by hice_reg
952             recip_heffActual(I,J)  = AREApreTH(I,J) /             recip_heffActual(I,J)  = AREApreTH(I,J) /
953       &                 sqrt(HEFFpreTH(I,J)*HEFFpreTH(I,J) + hice_reg_sq)       &                 sqrt(HEFFpreTH(I,J)*HEFFpreTH(I,J) + hice_reg_sq)
954  cif       Do not regularize when HEFFpreTH = 0  Cif       Do not regularize when HEFFpreTH = 0
955            ELSE            ELSE
956              heffActual(I,J) = ZERO              heffActual(I,J) = ZERO
957              hsnowActual(I,J) = ZERO              hsnowActual(I,J) = ZERO
# Line 915  C    AND SNOW THICKNESS Line 979  C    AND SNOW THICKNESS
979  #endif  #endif
980          DO J=1,sNy          DO J=1,sNy
981           DO I=1,sNx           DO I=1,sNx
982  c        The latent heat flux over the sea ice which  C        The latent heat flux over the sea ice which
983  c        will sublimate all of the snow and ice over one time  C        will sublimate all of the snow and ice over one time
984  c        step (W/m^2)  C        step (W/m^2)
985  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
986            IF (HEFFITDpreTH(I,J,IT) .GT. ZERO) THEN            IF (HEFFITDpreTH(I,J,IT) .GT. ZERO) THEN
987              latentHeatFluxMaxMult(I,J,IT) = lhSublim*recip_deltaTtherm *              latentHeatFluxMaxMult(I,J,IT) = lhSublim*recip_deltaTtherm *
# Line 971  cCADJ STORE TmixLoc = comlev1_bibj, key Line 1035  cCADJ STORE TmixLoc = comlev1_bibj, key
1035       I       TmixLoc,       I       TmixLoc,
1036       O       a_QbyATM_open, a_QSWbyATM_open,       O       a_QbyATM_open, a_QSWbyATM_open,
1037       I       bi, bj, myTime, myIter, myThid )       I       bi, bj, myTime, myIter, myThid )
 c ToM<<< debugging  
         print*,' '  
         print*,'UG = ',UG(1,1)  
         print*,'Tsurf = ',TmixLoc(1,1)  
         print*,'a_QbyATM_open = ',a_QbyATM_open(1,1)  
         print*,' '  
 c ToM>>>  
1038    
1039  C determine available heat due to the atmosphere -- for ice covered water  C determine available heat due to the atmosphere -- for ice covered water
1040  C =======================================================================  C =======================================================================
1041    
1042  #ifdef ALLOW_ATM_WIND          IF (useRelativeWind.AND.useAtmWind) THEN
         IF (useRelativeWind) THEN  
1043  C     Compute relative wind speed over sea ice.  C     Compute relative wind speed over sea ice.
1044           DO J=1,sNy           DO J=1,sNy
1045            DO I=1,sNx            DO I=1,sNx
# Line 1004  C     Compute relative wind speed over s Line 1060  C     Compute relative wind speed over s
1060            ENDDO            ENDDO
1061           ENDDO           ENDDO
1062          ENDIF          ENDIF
 #endif /* ALLOW_ATM_WIND */  
1063    
1064  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
1065  CADJ STORE tice(:,:,bi,bj)  CADJ STORE tice(:,:,bi,bj)
# Line 1020  CADJ &                       key = iicek Line 1075  CADJ &                       key = iicek
1075    
1076  C--   Start loop over multi-categories  C--   Start loop over multi-categories
1077  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1078  CToM  SEAICE_multDim = nITD (see SEAICE_SIZE.h and seaice_readparms.F)          DO IT=1,nITD
 #endif  
         DO IT=1,SEAICE_multDim  
 c        homogeneous distribution between 0 and 2 x heffActual  
 #ifndef SEAICE_ITD  
          pFac = (2.0 _d 0*real(IT)-1.0 _d 0)*recip_multDim  
 #endif  
1079           DO J=1,sNy           DO J=1,sNy
1080            DO I=1,sNx            DO I=1,sNx
 #ifndef SEAICE_ITD  
1081  CToM for SEAICE_ITD heffActualMult and latentHeatFluxMaxMult are calculated above  CToM for SEAICE_ITD heffActualMult and latentHeatFluxMaxMult are calculated above
1082  C    (instead of heffActual and latentHeatFluxMax)  C    (instead of heffActual and latentHeatFluxMax)
1083               ticeInMult(I,J,IT)=TICES(I,J,IT,bi,bj)
1084               ticeOutMult(I,J,IT)=TICES(I,J,IT,bi,bj)
1085               TICE(I,J,bi,bj) = ZERO
1086               TICES(I,J,IT,bi,bj) = ZERO
1087              ENDDO
1088             ENDDO
1089            ENDDO
1090    #else
1091            DO IT=1,SEAICE_multDim
1092    C        homogeneous distribution between 0 and 2 x heffActual
1093             pFac = (2.0 _d 0*IT - 1.0 _d 0)*recip_multDim
1094             pFacSnow = 1. _d 0
1095             IF ( SEAICE_useMultDimSnow ) pFacSnow=pFac
1096             DO J=1,sNy
1097              DO I=1,sNx
1098             heffActualMult(I,J,IT)= heffActual(I,J)*pFac             heffActualMult(I,J,IT)= heffActual(I,J)*pFac
1099               hsnowActualMult(I,J,IT)=hsnowActual(I,J)*pFacSnow
1100  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
1101             latentHeatFluxMaxMult(I,J,IT) = latentHeatFluxMax(I,J)*pFac             latentHeatFluxMaxMult(I,J,IT) = latentHeatFluxMax(I,J)*pFac
1102  #endif  #endif
 #endif  
1103             ticeInMult(I,J,IT)=TICES(I,J,IT,bi,bj)             ticeInMult(I,J,IT)=TICES(I,J,IT,bi,bj)
1104             ticeOutMult(I,J,IT)=TICES(I,J,IT,bi,bj)             ticeOutMult(I,J,IT)=TICES(I,J,IT,bi,bj)
1105             TICE(I,J,bi,bj) = ZERO             TICE(I,J,bi,bj) = ZERO
# Line 1044  C    (instead of heffActual and latentHe Line 1107  C    (instead of heffActual and latentHe
1107            ENDDO            ENDDO
1108           ENDDO           ENDDO
1109          ENDDO          ENDDO
1110    #endif
1111    
1112  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
1113  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte
1114    CADJ STORE hsnowActualMult= comlev1_bibj, key = iicekey, byte = isbyte
1115  CADJ STORE ticeInMult     = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE ticeInMult     = comlev1_bibj, key = iicekey, byte = isbyte
1116  # ifdef SEAICE_CAP_SUBLIM  # ifdef SEAICE_CAP_SUBLIM
1117  CADJ STORE latentHeatFluxMaxMult  CADJ STORE latentHeatFluxMaxMult
# Line 1062  CADJ &     comlev1_bibj, key = iicekey, Line 1127  CADJ &     comlev1_bibj, key = iicekey,
1127    
1128          DO IT=1,SEAICE_multDim          DO IT=1,SEAICE_multDim
1129           CALL SEAICE_SOLVE4TEMP(           CALL SEAICE_SOLVE4TEMP(
 #ifdef SEAICE_ITD  
1130       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  
1131  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
1132       I        latentHeatFluxMaxMult(1,1,IT),       I        latentHeatFluxMaxMult(1,1,IT),
1133  #endif  #endif
1134       U        ticeInMult(1,1,IT), ticeOutMult(1,1,IT),       U        ticeInMult(1,1,IT), ticeOutMult(1,1,IT),
1135       O        a_QbyATMmult_cover(1,1,IT), a_QSWbyATMmult_cover(1,1,IT),       O        a_QbyATMmult_cover(1,1,IT),
1136         O        a_QSWbyATMmult_cover(1,1,IT),
1137       O        a_FWbySublimMult(1,1,IT),       O        a_FWbySublimMult(1,1,IT),
1138       I        bi, bj, myTime, myIter, myThid )       I        bi, bj, myTime, myIter, myThid )
1139          ENDDO          ENDDO
1140    
1141  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
1142  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte
1143    CADJ STORE hsnowActualMult= comlev1_bibj, key = iicekey, byte = isbyte
1144  CADJ STORE ticeOutMult    = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE ticeOutMult    = comlev1_bibj, key = iicekey, byte = isbyte
1145  # ifdef SEAICE_CAP_SUBLIM  # ifdef SEAICE_CAP_SUBLIM
1146  CADJ STORE latentHeatFluxMaxMult  CADJ STORE latentHeatFluxMaxMult
# Line 1130  C     (fluxes are per unit (ice surface) Line 1193  C     (fluxes are per unit (ice surface)
1193            ENDDO            ENDDO
1194           ENDDO           ENDDO
1195          ENDDO          ENDDO
 c ToM<<< debugging  
         print*,' '  
         print*,'after SOLVE4TEMP: '  
         print*,'TICE  = ',TICE(1,1,bi,bj)  
         print*,'TICES = ',TICES(1,1,:,bi,bj)  
         print*,'a_QSWbyATM_cover     = ',a_QSWbyATM_cover(1,1)  
         print*,'a_QSWbyATMmult_cover = ',a_QSWbyATMmult_cover(1,1,:)  
         print*,' '  
 c ToM>>>  
1196    
1197  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
1198  # ifdef ALLOW_DIAGNOSTICS  # ifdef ALLOW_DIAGNOSTICS
1199          DO J=1,sNy          DO J=1,sNy
1200           DO I=1,sNx           DO I=1,sNx
1201  c          The actual latent heat flux realized by SOLVE4TEMP  C          The actual latent heat flux realized by SOLVE4TEMP
1202             DIAGarrayA(I,J) = a_FWbySublim(I,J) * lhSublim             DIAGarrayA(I,J) = a_FWbySublim(I,J) * lhSublim
1203           ENDDO           ENDDO
1204          ENDDO          ENDDO
1205  cif     The actual vs. maximum latent heat flux  Cif     The actual vs. maximum latent heat flux
1206          IF ( useDiagnostics ) THEN          IF ( useDiagnostics ) THEN
1207            CALL DIAGNOSTICS_FILL(DIAGarrayA,            CALL DIAGNOSTICS_FILL(DIAGarrayA,
1208       &     'SIactLHF',0,1,3,bi,bj,myThid)       &     'SIactLHF',0,1,3,bi,bj,myThid)
# Line 1216  C and initialize r_QbyATM_cover/r_QbyATM Line 1270  C and initialize r_QbyATM_cover/r_QbyATM
1270  C     Convert fresh water flux by sublimation to 'effective' ice meters.  C     Convert fresh water flux by sublimation to 'effective' ice meters.
1271  C     Negative sublimation is resublimation and will be added as snow.  C     Negative sublimation is resublimation and will be added as snow.
1272  #ifdef SEAICE_DISABLE_SUBLIM  #ifdef SEAICE_DISABLE_SUBLIM
1273  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
1274            a_FWbySublim(I,J) = ZERO            a_FWbySublim(I,J) = ZERO
1275  #endif  #endif /* SEAICE_DISABLE_SUBLIM */
1276            a_FWbySublim(I,J) = SEAICE_deltaTtherm*recip_rhoIce            a_FWbySublim(I,J) = SEAICE_deltaTtherm*recip_rhoIce
1277       &           * a_FWbySublim(I,J)*AREApreTH(I,J)       &           * a_FWbySublim(I,J)*AREApreTH(I,J)
1278            r_FWbySublim(I,J)=a_FWbySublim(I,J)            r_FWbySublim(I,J)=a_FWbySublim(I,J)
# Line 1276  CADJ &                       key = iicek Line 1330  CADJ &                       key = iicek
1330    
1331          DO J=1,sNy          DO J=1,sNy
1332           DO I=1,sNx           DO I=1,sNx
1333  c         FREEZING TEMP. OF SEA WATER (deg C)  C         FREEZING TEMP. OF SEA WATER (deg C)
1334            tempFrz = SEAICE_tempFrz0 +            tempFrz = SEAICE_tempFrz0 +
1335       &              SEAICE_dTempFrz_dS *salt(I,J,kSurface,bi,bj)       &              SEAICE_dTempFrz_dS *salt(I,J,kSurface,bi,bj)
1336  c efficiency of turbulent fluxes : dependency to sign of THETA-TBC  C efficiency of turbulent fluxes : dependency to sign of THETA-TBC
1337            IF ( theta(I,J,kSurface,bi,bj) .GE. tempFrz ) THEN            IF ( theta(I,J,kSurface,bi,bj) .GE. tempFrz ) THEN
1338             tmpscal1 = SEAICE_mcPheePiston             tmpscal1 = SEAICE_mcPheePiston
1339            ELSE            ELSE
1340             tmpscal1 =SEAICE_frazilFrac*drF(kSurface)/SEAICE_deltaTtherm             tmpscal1 =SEAICE_frazilFrac*drF(kSurface)/SEAICE_deltaTtherm
1341            ENDIF            ENDIF
1342  c efficiency of turbulent fluxes : dependency to AREA (McPhee cases)  C efficiency of turbulent fluxes : dependency to AREA (McPhee cases)
1343            IF ( (AREApreTH(I,J) .GT. 0. _d 0).AND.            IF ( (AREApreTH(I,J) .GT. 0. _d 0).AND.
1344       &         (.NOT.SEAICE_mcPheeStepFunc) ) THEN       &         (.NOT.SEAICE_mcPheeStepFunc) ) THEN
1345             MixedLayerTurbulenceFactor = ONE -             MixedLayerTurbulenceFactor = ONE -
# Line 1296  c efficiency of turbulent fluxes : depen Line 1350  c efficiency of turbulent fluxes : depen
1350            ELSE            ELSE
1351             MixedLayerTurbulenceFactor = ONE             MixedLayerTurbulenceFactor = ONE
1352            ENDIF            ENDIF
1353  c maximum turbulent flux, in ice meters  C maximum turbulent flux, in ice meters
1354            tmpscal2= - (HeatCapacity_Cp*rhoConst * recip_QI)            tmpscal2= - (HeatCapacity_Cp*rhoConst * recip_QI)
1355       &         * (theta(I,J,kSurface,bi,bj)-tempFrz)       &         * (theta(I,J,kSurface,bi,bj)-tempFrz)
1356       &         * SEAICE_deltaTtherm * maskC(i,j,kSurface,bi,bj)       &         * SEAICE_deltaTtherm * maskC(i,j,kSurface,bi,bj)
1357  c available turbulent flux  C available turbulent flux
1358            a_QbyOCN(i,j) =            a_QbyOCN(i,j) =
1359       &         tmpscal1 * tmpscal2 * MixedLayerTurbulenceFactor       &         tmpscal1 * tmpscal2 * MixedLayerTurbulenceFactor
1360            r_QbyOCN(i,j) = a_QbyOCN(i,j)            r_QbyOCN(i,j) = a_QbyOCN(i,j)
 c ToM<<< debugging  
           if (i.eq.1 .and. j.eq.1) then  
             print *, 'salt [psu]     = ',salt(i,j,kSurface,bi,bj)  
             print *, 'theta [degC]   = ',theta(i,j,kSurface,bi,bj)  
             print *, 'tempFrz [degC] = ',tempFrz  
             print *, 'max turb flx [m]   = ',tmpscal2  
             print *, 'avail trub flx [m] = ',a_QbyOCN(i,j)  
           endif  
 c ToM>>>  
1361           ENDDO           ENDDO
1362          ENDDO          ENDDO
1363    
# Line 1320  c ToM>>> Line 1365  c ToM>>>
1365          CALL ZERO_ADJ_1D( sNx*sNy, r_QbyOCN, myThid)          CALL ZERO_ADJ_1D( sNx*sNy, r_QbyOCN, myThid)
1366  #endif  #endif
1367    
   
1368  C ===================================================================  C ===================================================================
1369  C =========PART 3: determine effective thicknesses increments========  C =========PART 3: determine effective thicknesses increments========
1370  C ===================================================================  C ===================================================================
# Line 1342  C     First sublimate/deposite snow Line 1386  C     First sublimate/deposite snow
1386  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1387       &     MAX(MIN(r_FWbySublimMult(I,J,IT),HSNOWITD(I,J,IT,bi,bj)       &     MAX(MIN(r_FWbySublimMult(I,J,IT),HSNOWITD(I,J,IT,bi,bj)
1388       &             *SNOW2ICE),ZERO)       &             *SNOW2ICE),ZERO)
1389              d_HSNWbySublim_ITD(I,J,IT) = - tmpscal2 * ICE2SNOW
1390  C         accumulate change over ITD categories  C         accumulate change over ITD categories
1391            d_HSNWbySublim(I,J)     = d_HSNWbySublim(I,J)      - tmpscal2            d_HSNWbySublim(I,J)     = d_HSNWbySublim(I,J)      - tmpscal2
1392       &                                                       *ICE2SNOW       &                                                       *ICE2SNOW
           HSNOWITD(I,J,IT,bi,bj)  = HSNOWITD(I,J,IT,bi,bj)   - tmpscal2  
      &                                                       *ICE2SNOW  
1393            r_FWbySublimMult(I,J,IT)= r_FWbySublimMult(I,J,IT) - tmpscal2            r_FWbySublimMult(I,J,IT)= r_FWbySublimMult(I,J,IT) - tmpscal2
1394  #else  #else
1395       &     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)
# Line 1366  C     If anything is left, sublimate ice Line 1409  C     If anything is left, sublimate ice
1409            tmpscal2 =            tmpscal2 =
1410  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1411       &     MAX(MIN(r_FWbySublimMult(I,J,IT),HEFFITD(I,J,IT,bi,bj)),ZERO)       &     MAX(MIN(r_FWbySublimMult(I,J,IT),HEFFITD(I,J,IT,bi,bj)),ZERO)
1412              d_HEFFbySublim_ITD(I,J,IT) = - tmpscal2
1413  C         accumulate change over ITD categories  C         accumulate change over ITD categories
1414            d_HSNWbySublim(I,J)      = d_HSNWbySublim(I,J)      - tmpscal2            d_HEFFbySublim(I,J)      = d_HEFFbySublim(I,J)      - tmpscal2
           HEFFITD(I,J,IT,bi,bj)    = HEFFITD(I,J,IT,bi,bj)    - tmpscal2  
1415            r_FWbySublimMult(I,J,IT) = r_FWbySublimMult(I,J,IT) - tmpscal2            r_FWbySublimMult(I,J,IT) = r_FWbySublimMult(I,J,IT) - tmpscal2
1416  #else  #else
1417       &     MAX(MIN(r_FWbySublim(I,J),HEFF(I,J,bi,bj)),ZERO)       &     MAX(MIN(r_FWbySublim(I,J),HEFF(I,J,bi,bj)),ZERO)
# Line 1398  C     remove the fusion part for the res Line 1441  C     remove the fusion part for the res
1441  C       end IT loop  C       end IT loop
1442          ENDDO          ENDDO
1443  #endif  #endif
1444    #ifdef SEAICE_DEBUG
1445  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1446          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1447         &    ' SEAICE_GROWTH: Hsnow increments 1, d_HSNWySublim = ',
1448  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1449       &    ' SEAICE_GROWTH: Heff increments 1, HEFFITD = ',       &     d_HSNWbySublim_ITD(1,1,:)
1450       &     HEFFITD(1,1,:,bi,bj)  #else
1451         &     d_HSNWbySublim(1,1)
1452    #endif
1453          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1454       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1455          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1456       &    ' SEAICE_GROWTH: Area increments 1, AREAITD = ',       &    ' SEAICE_GROWTH: Heff increments 1, d_HEFFbySublim = ',
1457       &     AREAITD(1,1,:,bi,bj)  #ifdef SEAICE_ITD
1458         &     d_HEFFbySublim_ITD(1,1,:)
1459  #else  #else
1460       &    ' SEAICE_GROWTH: Heff increments 1, HEFF = ',       &     d_HEFFbySublim(1,1)
      &     HEFF(1,1,bi,bj)  
1461  #endif  #endif
1462          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1463       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1464  c ToM>>>  c ToM>>>
1465    #endif
1466    
1467  C compute ice thickness tendency due to ice-ocean interaction  C compute ice thickness tendency due to ice-ocean interaction
1468  C ===========================================================  C ===========================================================
# Line 1433  C          equally distributed under the Line 1481  C          equally distributed under the
1481  C          fractional area of each thickness category  C          fractional area of each thickness category
1482             tmpscal1=MAX(r_QbyOCN(i,j)*areaFracFactor(I,J,IT),             tmpscal1=MAX(r_QbyOCN(i,j)*areaFracFactor(I,J,IT),
1483       &                               -HEFFITD(I,J,IT,bi,bj))       &                               -HEFFITD(I,J,IT,bi,bj))
1484               d_HEFFbyOCNonICE_ITD(I,J,IT)=tmpscal1
1485             d_HEFFbyOCNonICE(I,J) = d_HEFFbyOCNonICE(I,J) + tmpscal1             d_HEFFbyOCNonICE(I,J) = d_HEFFbyOCNonICE(I,J) + tmpscal1
            HEFFITD(I,J,IT,bi,bj) = HEFFITD(I,J,IT,bi,bj) + tmpscal1  
 #ifdef ALLOW_SITRACER  
            SItrHEFF(I,J,bi,bj,2) = SItrHEFF(I,J,bi,bj,2)  
      &                           + HEFFITD(I,J,IT,bi,bj)  
 #endif  
1486            ENDDO            ENDDO
1487           ENDDO           ENDDO
1488          ENDDO          ENDDO
1489    #ifdef ALLOW_SITRACER
1490            DO J=1,sNy
1491             DO I=1,sNx
1492              SItrHEFF(I,J,bi,bj,2) = HEFFpreTH(I,J)
1493         &                          + d_HEFFbySublim(I,J)
1494         &                          + d_HEFFbyOCNonICE(I,J)
1495             ENDDO
1496            ENDDO
1497    #endif
1498          DO J=1,sNy          DO J=1,sNy
1499           DO I=1,sNx           DO I=1,sNx
1500            r_QbyOCN(I,J)=r_QbyOCN(I,J)-d_HEFFbyOCNonICE(I,J)            r_QbyOCN(I,J)=r_QbyOCN(I,J)-d_HEFFbyOCNonICE(I,J)
# Line 1459  C          fractional area of each thick Line 1512  C          fractional area of each thick
1512           ENDDO           ENDDO
1513          ENDDO          ENDDO
1514  #endif /* SEAICE_ITD */  #endif /* SEAICE_ITD */
1515    #ifdef SEAICE_DEBUG
1516  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1517          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1518         &    ' SEAICE_GROWTH: Heff increments 2, d_HEFFbyOCNonICE = ',
1519  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1520       &    ' SEAICE_GROWTH: Heff increments 2, HEFFITD = ',       &     d_HEFFbyOCNonICE_ITD(1,1,:)
      &     HEFFITD(1,1,:,bi,bj)  
         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,  
      &    SQUEEZE_RIGHT , myThid)  
         WRITE(msgBuf,'(A,7F8.4)')  
      &    ' SEAICE_GROWTH: Area increments 2, AREAITD = ',  
      &     AREAITD(1,1,:,bi,bj)  
1521  #else  #else
1522       &    ' SEAICE_GROWTH: Heff increments 2, HEFF = ',       &     d_HEFFbyOCNonICE(1,1)
      &     HEFF(1,1,bi,bj)  
1523  #endif  #endif
1524          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1525       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1526  c ToM>>>  c ToM>>>
1527    #endif
1528    
1529  C compute snow melt tendency due to snow-atmosphere interaction  C compute snow melt tendency due to snow-atmosphere interaction
1530  C ==================================================================  C ==================================================================
# Line 1498  C     of snow. This appears to be more r Line 1547  C     of snow. This appears to be more r
1547  Cgf no additional dependency through snow  Cgf no additional dependency through snow
1548             IF ( SEAICEadjMODE.GE.2 ) tmpscal2 = 0. _d 0             IF ( SEAICEadjMODE.GE.2 ) tmpscal2 = 0. _d 0
1549  #endif  #endif
1550               d_HSNWbyATMonSNW_ITD(I,J,IT) = tmpscal2*ICE2SNOW
1551             d_HSNWbyATMonSNW(I,J) = d_HSNWbyATMonSNW(I,J)             d_HSNWbyATMonSNW(I,J) = d_HSNWbyATMonSNW(I,J)
1552       &                           + tmpscal2*ICE2SNOW       &                           + tmpscal2*ICE2SNOW
            HSNOWITD(I,J,IT,bi,bj)= HSNOWITD(I,J,IT,bi,bj)  
      &                           + tmpscal2*ICE2SNOW  
1553             r_QbyATMmult_cover(I,J,IT)=r_QbyATMmult_cover(I,J,IT)             r_QbyATMmult_cover(I,J,IT)=r_QbyATMmult_cover(I,J,IT)
1554       &                           - tmpscal2       &                           - tmpscal2
1555            ENDDO            ENDDO
# Line 1524  Cgf no additional dependency through sno Line 1572  Cgf no additional dependency through sno
1572           ENDDO           ENDDO
1573          ENDDO          ENDDO
1574  #endif /* SEAICE_ITD */  #endif /* SEAICE_ITD */
1575    #ifdef SEAICE_DEBUG
1576  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1577          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1578         &    ' SEAICE_GROWTH: Hsnow increments 3, d_HSNWbyATMonSNW = ',
1579  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1580       &    ' SEAICE_GROWTH: Heff increments 3, HEFFITD = ',       &    d_HSNWbyATMonSNW_ITD(1,1,:)
      &     HEFFITD(1,1,:,bi,bj)  
         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,  
      &    SQUEEZE_RIGHT , myThid)  
         WRITE(msgBuf,'(A,7F8.4)')  
      &    ' SEAICE_GROWTH: Area increments 3, AREAITD = ',  
      &     AREAITD(1,1,:,bi,bj)  
1581  #else  #else
1582       &    ' SEAICE_GROWTH: Heff increments 3, HEFF = ',       &    d_HSNWbyATMonSNW(1,1)
      &     HEFF(1,1,bi,bj)  
1583  #endif  #endif
1584          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1585       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1586  c ToM>>>  c ToM>>>
1587    #endif
1588    
1589  C compute ice thickness tendency due to the atmosphere  C compute ice thickness tendency due to the atmosphere
1590  C ====================================================  C ====================================================
# Line 1559  Cgf warming conditions, the lab_sea resu Line 1603  Cgf warming conditions, the lab_sea resu
1603          DO IT=1,nITD          DO IT=1,nITD
1604           DO J=1,sNy           DO J=1,sNy
1605            DO I=1,sNx            DO I=1,sNx
1606               tmpscal1 = HEFFITDpreTH(I,J,IT)
1607         &              + d_HEFFbySublim_ITD(I,J,IT)
1608         &              + d_HEFFbyOCNonICE_ITD(I,J,IT)
1609  #ifdef SEAICE_GROWTH_LEGACY  #ifdef SEAICE_GROWTH_LEGACY
1610             tmpscal2 = MAX(-HEFFITD(I,J,IT,bi,bj),             tmpscal2 = MAX(-tmpscal1,
1611       &                     r_QbyATMmult_cover(I,J,IT))       &                     r_QbyATMmult_cover(I,J,IT))
1612  #else  #else
1613             tmpscal2 = MAX(-HEFFITD(I,J,IT,bi,bj),             tmpscal2 = MAX(-tmpscal1,
1614       &                     r_QbyATMmult_cover(I,J,IT)       &                     r_QbyATMmult_cover(I,J,IT)
1615  c         Limit ice growth by potential melt by ocean  c         Limit ice growth by potential melt by ocean
1616       &              + AREAITDpreTH(I,J,IT) * r_QbyOCN(I,J))       &              + AREAITDpreTH(I,J,IT) * r_QbyOCN(I,J))
1617  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
1618               d_HEFFbyATMonOCN_cover_ITD(I,J,IT) = tmpscal2
1619             d_HEFFbyATMonOCN_cover(I,J) = d_HEFFbyATMonOCN_cover(I,J)             d_HEFFbyATMonOCN_cover(I,J) = d_HEFFbyATMonOCN_cover(I,J)
1620       &                                 + tmpscal2       &                                 + tmpscal2
1621               d_HEFFbyATMonOCN_ITD(I,J,IT) = d_HEFFbyATMonOCN_ITD(I,J,IT)
1622         &                                 + tmpscal2
1623             d_HEFFbyATMonOCN(I,J)       = d_HEFFbyATMonOCN(I,J)             d_HEFFbyATMonOCN(I,J)       = d_HEFFbyATMonOCN(I,J)
1624       &                                 + tmpscal2       &                                 + tmpscal2
1625             r_QbyATMmult_cover(I,J,IT)  = r_QbyATMmult_cover(I,J,IT)             r_QbyATMmult_cover(I,J,IT)  = r_QbyATMmult_cover(I,J,IT)
1626       &                                 - tmpscal2       &                                 - tmpscal2
            HEFFITD(I,J,IT,bi,bj) = HEFFITD(I,J,IT,bi,bj) + tmpscal2  
   
 #ifdef ALLOW_SITRACER  
            SItrHEFF(I,J,bi,bj,3) = SItrHEFF(I,J,bi,bj,3)  
      &                           + HEFFITD(I,J,IT,bi,bj)  
 #endif  
1627            ENDDO            ENDDO
1628           ENDDO           ENDDO
1629          ENDDO          ENDDO
1630    #ifdef ALLOW_SITRACER
1631            DO J=1,sNy
1632             DO I=1,sNx
1633              SItrHEFF(I,J,bi,bj,3) = SItrHEFF(I,J,bi,bj,2)
1634         &                          + d_HEFFbyATMonOCN_cover(I,J)
1635             ENDDO
1636            ENDDO
1637    #endif
1638  #else /* SEAICE_ITD */  #else /* SEAICE_ITD */
1639          DO J=1,sNy          DO J=1,sNy
1640           DO I=1,sNx           DO I=1,sNx
# Line 1591  c         Limit ice growth by potential Line 1643  c         Limit ice growth by potential
1643            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J))            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J))
1644  #else  #else
1645            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J)+            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J)+
1646  c         Limit ice growth by potential melt by ocean  C         Limit ice growth by potential melt by ocean
1647       &        AREApreTH(I,J) * r_QbyOCN(I,J))       &        AREApreTH(I,J) * r_QbyOCN(I,J))
1648  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
1649    
# Line 1603  c         Limit ice growth by potential Line 1655  c         Limit ice growth by potential
1655  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
1656            SItrHEFF(I,J,bi,bj,3)=HEFF(I,J,bi,bj)            SItrHEFF(I,J,bi,bj,3)=HEFF(I,J,bi,bj)
1657  #endif  #endif
1658           ENDDO           ENDDO
1659          ENDDO          ENDDO
1660  #endif /* SEAICE_ITD */  #endif /* SEAICE_ITD */
1661    #ifdef SEAICE_DEBUG
1662  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1663          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1664         &   ' SEAICE_GROWTH: Heff increments 4, d_HEFFbyATMonOCN_cover = ',
1665  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1666       &    ' SEAICE_GROWTH: Heff increments 4, HEFFITD = ',       &     d_HEFFbyATMonOCN_cover_ITD(1,1,:)
1667       &     HEFFITD(1,1,:,bi,bj)  #else
1668         &     d_HEFFbyATMonOCN_cover(1,1)
1669    #endif
1670          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1671       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1672          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1673       &    ' SEAICE_GROWTH: Area increments 4, AREAITD = ',       &    ' SEAICE_GROWTH: Heff increments 4, d_HEFFbyATMonOCN = ',
1674       &     AREAITD(1,1,:,bi,bj)  #ifdef SEAICE_ITD
1675         &     d_HEFFbyATMonOCN_ITD(1,1,:)
1676  #else  #else
1677       &    ' SEAICE_GROWTH: Heff increments 4, HEFF = ',       &     d_HEFFbyATMonOCN(1,1)
      &     HEFF(1,1,bi,bj)  
1678  #endif  #endif
1679          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1680       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1681  c ToM>>>  c ToM>>>
1682    #endif
1683    
1684  C attribute precip to fresh water or snow stock,  C add snow precipitation to HSNOW.
 C depending on atmospheric conditions.  
1685  C =================================================  C =================================================
1686  #ifdef ALLOW_ATM_TEMP  #ifdef ALLOW_ATM_TEMP
1687  #ifdef ALLOW_AUTODIFF_TAMC  # ifdef ALLOW_AUTODIFF_TAMC
1688  CADJ STORE a_QbyATM_cover = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE a_QbyATM_cover = comlev1_bibj,key=iicekey,byte=isbyte
1689  CADJ STORE PRECIP(:,:,bi,bj) = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE PRECIP(:,:,bi,bj) = comlev1_bibj,key=iicekey,byte=isbyte
1690  CADJ STORE AREApreTH = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE AREApreTH = comlev1_bibj,key=iicekey,byte=isbyte
1691  #endif /* ALLOW_AUTODIFF_TAMC */  # endif /* ALLOW_AUTODIFF_TAMC */
1692          DO J=1,sNy          IF ( snowPrecipFile .NE. ' ' ) THEN
1693           DO I=1,sNx  C add snowPrecip to HSNOW
1694             DO J=1,sNy
1695              DO I=1,sNx
1696               d_HSNWbyRAIN(I,J) = convertPRECIP2HI * ICE2SNOW *
1697         &          snowPrecip(i,j,bi,bj) * AREApreTH(I,J)
1698               d_HFRWbyRAIN(I,J) = -convertPRECIP2HI *
1699         &          ( PRECIP(I,J,bi,bj) - snowPrecip(I,J,bi,bj) ) *
1700         &          AREApreTH(I,J)
1701               HSNOW(I,J,bi,bj) = HSNOW(I,J,bi,bj) + d_HSNWbyRAIN(I,J)
1702              ENDDO
1703             ENDDO
1704            ELSE
1705    C attribute precip to fresh water or snow stock,
1706    C depending on atmospheric conditions.
1707             DO J=1,sNy
1708              DO I=1,sNx
1709  C possible alternatives to the a_QbyATM_cover criterium  C possible alternatives to the a_QbyATM_cover criterium
1710  c          IF (TICE(I,J,bi,bj) .LT. TMIX) THEN  c          IF (TICE(I,J,bi,bj) .LT. TMIX) THEN
1711  c          IF (atemp(I,J,bi,bj) .LT. celsius2K) THEN  c          IF (atemp(I,J,bi,bj) .LT. celsius2K) THEN
1712            IF ( a_QbyATM_cover(I,J).GE. 0. _d 0 ) THEN             IF ( a_QbyATM_cover(I,J).GE. 0. _d 0 ) THEN
1713  C           add precip as snow  C           add precip as snow
1714              d_HFRWbyRAIN(I,J)=0. _d 0              d_HFRWbyRAIN(I,J)=0. _d 0
1715              d_HSNWbyRAIN(I,J)=convertPRECIP2HI*ICE2SNOW*              d_HSNWbyRAIN(I,J)=convertPRECIP2HI*ICE2SNOW*
1716       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)
1717            ELSE             ELSE
1718  C           add precip to the fresh water bucket  C           add precip to the fresh water bucket
1719              d_HFRWbyRAIN(I,J)=-convertPRECIP2HI*              d_HFRWbyRAIN(I,J)=-convertPRECIP2HI*
1720       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)
1721              d_HSNWbyRAIN(I,J)=0. _d 0              d_HSNWbyRAIN(I,J)=0. _d 0
1722            ENDIF             ENDIF
1723           ENDDO           ENDDO
1724          ENDDO          ENDDO
1725  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1726          DO IT=1,nITD          DO IT=1,nITD
1727           DO J=1,sNy           DO J=1,sNy
1728            DO I=1,sNx            DO I=1,sNx
1729             HSNOWITD(I,J,IT,bi,bj) = HSNOWITD(I,J,IT,bi,bj)             d_HSNWbyRAIN_ITD(I,J,IT)
1730       &     + d_HSNWbyRAIN(I,J)*areaFracFactor(I,J,IT)       &     = d_HSNWbyRAIN(I,J)*areaFracFactor(I,J,IT)
1731            ENDDO            ENDDO
1732           ENDDO           ENDDO
1733          ENDDO          ENDDO
# Line 1670  C           add precip to the fresh wate Line 1741  C           add precip to the fresh wate
1741  Cgf note: this does not affect air-sea heat flux,  Cgf note: this does not affect air-sea heat flux,
1742  Cgf since the implied air heat gain to turn  Cgf since the implied air heat gain to turn
1743  Cgf rain to snow is not a surface process.  Cgf rain to snow is not a surface process.
1744    C end of IF statement snowPrecipFile:
1745            ENDIF
1746  #endif /* ALLOW_ATM_TEMP */  #endif /* ALLOW_ATM_TEMP */
1747    #ifdef SEAICE_DEBUG
1748  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1749          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1750         &    ' SEAICE_GROWTH: Hsnow increments 5, d_HSNWbyRAIN = ',
1751  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1752       &    ' SEAICE_GROWTH: Heff increments 5, HEFFITD = ',       &     d_HSNWbyRAIN_ITD(1,1,:)
      &     HEFFITD(1,1,:,bi,bj)  
         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,  
      &    SQUEEZE_RIGHT , myThid)  
         WRITE(msgBuf,'(A,7F8.4)')  
      &    ' SEAICE_GROWTH: Area increments 5, AREAITD = ',  
      &     AREAITD(1,1,:,bi,bj)  
1753  #else  #else
1754       &    ' SEAICE_GROWTH: Heff increments 5, HEFF = ',       &     d_HSNWbyRAIN(1,1)
      &     HEFF(1,1,bi,bj)  
1755  #endif  #endif
1756          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1757       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1758  c ToM>>>  c ToM>>>
1759    #endif
1760    
1761  C compute snow melt due to heat available from ocean.  C compute snow melt due to heat available from ocean.
1762  C =================================================================  C =================================================================
# Line 1704  CADJ STORE r_QbyOCN = comlev1_bibj,key=i Line 1773  CADJ STORE r_QbyOCN = comlev1_bibj,key=i
1773          DO IT=1,nITD          DO IT=1,nITD
1774           DO J=1,sNy           DO J=1,sNy
1775            DO I=1,sNx            DO I=1,sNx
1776               tmpscal4 = HSNWITDpreTH(I,J,IT)
1777         &              + d_HSNWbySublim_ITD(I,J,IT)
1778         &              + d_HSNWbyATMonSNW_ITD(I,J,IT)
1779         &              + d_HSNWbyRAIN_ITD(I,J,IT)
1780             tmpscal1=MAX(r_QbyOCN(i,j)*ICE2SNOW*areaFracFactor(I,J,IT),             tmpscal1=MAX(r_QbyOCN(i,j)*ICE2SNOW*areaFracFactor(I,J,IT),
1781       &                  -HSNOWITD(I,J,IT,bi,bj))       &                  -tmpscal4)
1782             tmpscal2=MIN(tmpscal1,0. _d 0)             tmpscal2=MIN(tmpscal1,0. _d 0)
1783  #ifdef SEAICE_MODIFY_GROWTH_ADJ  #ifdef SEAICE_MODIFY_GROWTH_ADJ
1784  Cgf no additional dependency through snow  Cgf no additional dependency through snow
1785             if ( SEAICEadjMODE.GE.2 ) tmpscal2 = 0. _d 0             if ( SEAICEadjMODE.GE.2 ) tmpscal2 = 0. _d 0
1786  #endif  #endif
1787               d_HSNWbyOCNonSNW_ITD(I,J,IT) = tmpscal2
1788             d_HSNWbyOCNonSNW(I,J) = d_HSNWbyOCNonSNW(I,J) + tmpscal2             d_HSNWbyOCNonSNW(I,J) = d_HSNWbyOCNonSNW(I,J) + tmpscal2
1789             r_QbyOCN(I,J)=r_QbyOCN(I,J) - tmpscal2*SNOW2ICE             r_QbyOCN(I,J)=r_QbyOCN(I,J) - tmpscal2*SNOW2ICE
            HSNOWITD(I,J,IT,bi,bj) = HSNOWITD(I,J,IT,bi,bj) + tmpscal2  
1790            ENDDO            ENDDO
1791           ENDDO           ENDDO
1792          ENDDO          ENDDO
# Line 1735  Cgf no additional dependency through sno Line 1808  Cgf no additional dependency through sno
1808  #endif /* SEAICE_ITD */  #endif /* SEAICE_ITD */
1809  #endif /* SEAICE_EXCLUDE_FOR_EXACT_AD_TESTING */  #endif /* SEAICE_EXCLUDE_FOR_EXACT_AD_TESTING */
1810  Cph)  Cph)
1811    #ifdef SEAICE_DEBUG
1812  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1813          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1814         &    ' SEAICE_GROWTH: Hsnow increments 6, d_HSNWbyOCNonSNW = ',
1815  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1816       &    ' SEAICE_GROWTH: Heff increments 6, HEFFITD = ',       &     d_HSNWbyOCNonSNW_ITD(1,1,:)
      &     HEFFITD(1,1,:,bi,bj)  
         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,  
      &    SQUEEZE_RIGHT , myThid)  
         WRITE(msgBuf,'(A,7F8.4)')  
      &    ' SEAICE_GROWTH: Area increments 6, AREAITD = ',  
      &     AREAITD(1,1,:,bi,bj)  
1817  #else  #else
1818       &    ' SEAICE_GROWTH: Heff increments 6, HEFF = ',       &     d_HSNWbyOCNonSNW(1,1)
      &     HEFF(1,1,bi,bj)  
1819  #endif  #endif
1820          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1821       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1822  c ToM>>>  c ToM>>>
1823    #endif
1824    
1825  C gain of new ice over open water  C gain of new ice over open water
1826  C ===============================  C ===============================
# Line 1765  CADJ STORE a_QSWbyATM_open = comlev1_bib Line 1834  CADJ STORE a_QSWbyATM_open = comlev1_bib
1834    
1835          DO J=1,sNy          DO J=1,sNy
1836           DO I=1,sNx           DO I=1,sNx
1837  c           Initial ice growth is triggered by open water  #ifdef SEAICE_ITD
1838  c           heat flux overcoming potential melt by ocean  C         HEFF will be updated at the end of PART 3,
1839    C         hence sum of tendencies so far is needed
1840              tmpscal4 = HEFFpreTH(I,J)
1841         &             + d_HEFFbySublim(I,J)
1842         &             + d_HEFFbyOCNonICE(I,J)
1843         &             + d_HEFFbyATMonOCN(I,J)
1844    #else
1845    C         HEFF is updated step by step throughout seaice_growth
1846              tmpscal4 = HEFF(I,J,bi,bj)
1847    #endif
1848    C           Initial ice growth is triggered by open water
1849    C           heat flux overcoming potential melt by ocean
1850              tmpscal1=r_QbyATM_open(I,J)+r_QbyOCN(i,j) *              tmpscal1=r_QbyATM_open(I,J)+r_QbyOCN(i,j) *
1851       &            (1.0 _d 0 - AREApreTH(I,J))       &            (1.0 _d 0 - AREApreTH(I,J))
1852  c           Penetrative shortwave flux beyond first layer  C           Penetrative shortwave flux beyond first layer
1853  c           that is therefore not available to ice growth/melt  C           that is therefore not available to ice growth/melt
1854              tmpscal2=SWFracB * a_QSWbyATM_open(I,J)              tmpscal2=SWFracB * a_QSWbyATM_open(I,J)
1855  C           impose -HEFF as the maxmum melting if SEAICE_doOpenWaterMelt  C           impose -HEFF as the maxmum melting if SEAICE_doOpenWaterMelt
1856  C           or 0. otherwise (no melting if not SEAICE_doOpenWaterMelt)  C           or 0. otherwise (no melting if not SEAICE_doOpenWaterMelt)
1857              tmpscal3=facOpenGrow*MAX(tmpscal1-tmpscal2,              tmpscal3=facOpenGrow*MAX(tmpscal1-tmpscal2,
1858       &           -HEFF(I,J,bi,bj)*facOpenMelt)*HEFFM(I,J,bi,bj)       &           -tmpscal4*facOpenMelt)*HEFFM(I,J,bi,bj)
1859  c ToM<<< debugging  #ifdef SEAICE_ITD
1860              if (I.eq.1 .and. J.eq.1) then  C         ice growth in open water adds to first category
1861               print*,'r_QbyATM_open(I,J) = ', r_QbyATM_open(I,J)            d_HEFFbyATMonOCN_open_ITD(I,J,1)=tmpscal3
1862               print*,'r_QbyOCN(i,j) = ', r_QbyOCN(i,j)            d_HEFFbyATMonOCN_ITD(I,J,1)     =d_HEFFbyATMonOCN_ITD(I,J,1)
1863               print*,'1 - AREApreTH = ', (1.0 _d 0 - AREApreTH(I,J))       &                                    +tmpscal3
1864               print*,'tmpscal1 = ', tmpscal1  #endif
              print*,' '  
              print*,'SWFracB = ', SWFracB  
              print*,'a_QSWbyATM_open(I,J) = ', a_QSWbyATM_open(I,J)  
              print*,'tmpscal2 = ', tmpscal2  
              print*,' '  
              print*,'facOpenGrow = ', facOpenGrow  
              print*,'HEFF(I,J,bi,bj) = ', HEFF(I,J,bi,bj)  
              print*,'facOpenMelt = ', facOpenMelt  
              print*,'MAX = ', MAX(tmpscal1-tmpscal2,  
      &              -HEFF(I,J,bi,bj)*facOpenMelt)  
              print*,'HEFFM(I,J,bi,bj) = ', HEFFM(I,J,bi,bj)  
              print*,'tmpscal3 = ', tmpscal3  
              print*,' '  
             endif  
 c ToM>>>  
1865            d_HEFFbyATMonOCN_open(I,J)=tmpscal3            d_HEFFbyATMonOCN_open(I,J)=tmpscal3
1866            d_HEFFbyATMonOCN(I,J)=d_HEFFbyATMonOCN(I,J)+tmpscal3            d_HEFFbyATMonOCN(I,J)=d_HEFFbyATMonOCN(I,J)+tmpscal3
1867            r_QbyATM_open(I,J)=r_QbyATM_open(I,J)-tmpscal3            r_QbyATM_open(I,J)=r_QbyATM_open(I,J)-tmpscal3
 #ifdef SEAICE_ITD  
 cC         open water area fraction  
 c          tmpscal0 = ONE-AREApreTH(I,J)  
 cC         determine thickness of new ice  
 cctomC         considering the entire open water area to refreeze  
 cctom          tmpscal1 = tmpscal3/tmpscal0  
 cC         considering a minimum lead ice thickness of 10 cm  
 cC         WATCH that leadIceThickMin is smaller that Hlimit(1)!  
 c          leadIceThickMin = 0.1  
 c          tmpscal1 = MAX(leadIceThickMin,tmpscal3/tmpscal0)  
 cC         adjust ice area fraction covered by new ice  
 c         tmpscal0 = tmpscal3/tmpscal1  
 cC         then add new ice volume to appropriate thickness category  
 c          DO IT=1,nITD  
 c          IF (tmpscal1.LT.Hlimit(IT)) THEN  
 c            HEFFITD(I,J,IT,bi,bj) = HEFFITD(I,J,IT,bi,bj) + tmpscal3  
 c           tmpscal3=ZERO  
 cC not sure if AREAITD should be changed here since AREA is incremented  
 cC   in PART 4 below in non-itd code  
 cC in this scenario all open water is covered by new ice instantaneously,  
 cC   i.e. no delayed lead closing is concidered such as is associated with  
 cC   Hibler's h_0 parameter  
 c           AREAITD(I,J,IT,bi,bj) = AREAITD(I,J,IT,bi,bj)  
 c     &                          + tmpscal0  
 c           tmpscal0=ZERO  
 c           ENDIF  
 c          ENDDO  
 ctom debugging: 1 category only  
           HEFFITD(I,J,1,bi,bj) = HEFFITD(I,J,1,bi,bj) + tmpscal3  
 #else  
1868            HEFF(I,J,bi,bj) = HEFF(I,J,bi,bj) + tmpscal3            HEFF(I,J,bi,bj) = HEFF(I,J,bi,bj) + tmpscal3
 #endif  
1869           ENDDO           ENDDO
1870          ENDDO          ENDDO
1871    
1872  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
 #ifdef SEAICE_ITD  
         DO IT=1,nITD  
          DO J=1,sNy  
           DO I=1,sNx  
 c needs to be here to allow use also with LEGACY branch  
            SItrHEFF(I,J,bi,bj,4) = SItrHEFF(I,J,bi,bj,4)  
      &                           + HEFFITD(I,J,IT,bi,bj)  
           ENDDO  
          ENDDO  
         ENDDO  
 #else  
1873          DO J=1,sNy          DO J=1,sNy
1874           DO I=1,sNx           DO I=1,sNx
1875  c needs to be here to allow use also with LEGACY branch  C needs to be here to allow use also with LEGACY branch
1876    #ifdef SEAICE_ITD
1877              SItrHEFF(I,J,bi,bj,4)=SItrHEFF(I,J,bi,bj,3)
1878         &                         +d_HEFFbyATMonOCN_open(I,J)
1879    #else
1880            SItrHEFF(I,J,bi,bj,4)=HEFF(I,J,bi,bj)            SItrHEFF(I,J,bi,bj,4)=HEFF(I,J,bi,bj)
1881    #endif
1882           ENDDO           ENDDO
1883          ENDDO          ENDDO
 #endif  
1884  #endif /* ALLOW_SITRACER */  #endif /* ALLOW_SITRACER */
1885    #ifdef SEAICE_DEBUG
1886  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1887          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1888         &    ' SEAICE_GROWTH: Heff increments 7, d_HEFFbyATMonOCN_open = ',
1889  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1890       &    ' SEAICE_GROWTH: Heff increments 7, HEFFITD = ',       &     d_HEFFbyATMonOCN_open_ITD(1,1,:)
      &     HEFFITD(1,1,:,bi,bj)  
         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,  
      &    SQUEEZE_RIGHT , myThid)  
         WRITE(msgBuf,'(A,7F8.4)')  
      &    ' SEAICE_GROWTH: Area increments 7, AREAITD = ',  
      &     AREAITD(1,1,:,bi,bj)  
1891  #else  #else
1892       &    ' SEAICE_GROWTH: Heff increments 7, HEFF = ',       &     d_HEFFbyATMonOCN_open(1,1)
1893       &     HEFF(1,1,bi,bj)  #endif
1894          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1895       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1896          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1897       &    ' SEAICE_GROWTH: Area increments 7, AREA = ',       &    ' SEAICE_GROWTH: Heff increments 7, d_HEFFbyATMonOCN = ',
1898       &     AREA(1,1,bi,bj)  #ifdef SEAICE_ITD
1899         &     d_HEFFbyATMonOCN_ITD(1,1,:)
1900    #else
1901         &     d_HEFFbyATMonOCN(1,1)
1902  #endif  #endif
1903          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1904       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1905  c ToM>>>  c ToM>>>
1906    #endif
1907    
1908  C convert snow to ice if submerged.  C convert snow to ice if submerged.
1909  C =================================  C =================================
# Line 1892  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 1919  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
1919           DO IT=1,nITD           DO IT=1,nITD
1920            DO J=1,sNy            DO J=1,sNy
1921             DO I=1,sNx             DO I=1,sNx
1922              tmpscal0 = (HSNOWITD(I,J,IT,bi,bj)*SEAICE_rhoSnow              tmpscal3 = HEFFITDpreTH(I,J,IT)
1923       &               +  HEFFITD(I,J,IT,bi,bj) *SEAICE_rhoIce)       &               + d_HEFFbySublim_ITD(I,J,IT)
1924       &                                        *recip_rhoConst       &               + d_HEFFbyOCNonICE_ITD(I,J,IT)
1925              tmpscal1 = MAX( 0. _d 0, tmpscal0 - HEFFITD(I,J,IT,bi,bj))       &               + d_HEFFbyATMonOCN_ITD(I,J,IT)
1926                tmpscal4 = HSNWITDpreTH(I,J,IT)
1927         &               + d_HSNWbySublim_ITD(I,J,IT)
1928         &               + d_HSNWbyATMonSNW_ITD(I,J,IT)
1929         &               + d_HSNWbyRAIN_ITD(I,J,IT)
1930                tmpscal0 = (tmpscal4*SEAICE_rhoSnow
1931         &               +  tmpscal3*SEAICE_rhoIce)
1932         &               * recip_rhoConst
1933                tmpscal1 = MAX( 0. _d 0, tmpscal0 - tmpscal3)
1934                d_HEFFbyFLOODING_ITD(I,J,IT) = tmpscal1
1935              d_HEFFbyFLOODING(I,J) = d_HEFFbyFLOODING(I,J)  + tmpscal1              d_HEFFbyFLOODING(I,J) = d_HEFFbyFLOODING(I,J)  + tmpscal1
             HEFFITD(I,J,IT,bi,bj) = HEFFITD(I,J,IT,bi,bj)  + tmpscal1  
             HSNOWITD(I,J,IT,bi,bj)= HSNOWITD(I,J,IT,bi,bj) - tmpscal1  
      &                            * ICE2SNOW  
1936             ENDDO             ENDDO
1937            ENDDO            ENDDO
1938           ENDDO           ENDDO
# Line 1913  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 1946  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
1946             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)
1947             HSNOW(I,J,bi,bj) = HSNOW(I,J,bi,bj)-             HSNOW(I,J,bi,bj) = HSNOW(I,J,bi,bj)-
1948       &                           d_HEFFbyFLOODING(I,J)*ICE2SNOW       &                           d_HEFFbyFLOODING(I,J)*ICE2SNOW
1949            ENDDO            ENDDO
1950           ENDDO           ENDDO
1951  #endif  #endif
1952          ENDIF          ENDIF
1953  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
1954    #ifdef SEAICE_DEBUG
1955  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
1956          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
1957         &    ' SEAICE_GROWTH: Heff increments 8, d_HEFFbyFLOODING = ',
1958  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
1959       &    ' SEAICE_GROWTH: Heff increments 8, HEFFITD = ',       &     d_HEFFbyFLOODING_ITD(1,1,:)
1960       &     HEFFITD(1,1,:,bi,bj)  #else
1961         &     d_HEFFbyFLOODING(1,1)
1962    #endif
1963          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1964       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1965          WRITE(msgBuf,'(A,7F8.4)')  c ToM>>>
1966       &    ' SEAICE_GROWTH: Area increments 8, AREAITD = ',  #endif
1967       &     AREAITD(1,1,:,bi,bj)  #ifdef SEAICE_ITD
1968    C apply ice and snow thickness changes
1969    C =================================================================
1970             DO IT=1,nITD
1971              DO J=1,sNy
1972               DO I=1,sNx
1973                HEFFITD(I,J,IT,bi,bj) = HEFFITD(I,J,IT,bi,bj)
1974         &                            + d_HEFFbySublim_ITD(I,J,IT)
1975         &                            + d_HEFFbyOCNonICE_ITD(I,J,IT)
1976         &                            + d_HEFFbyATMonOCN_ITD(I,J,IT)
1977         &                            + d_HEFFbyFLOODING_ITD(I,J,IT)
1978                HSNOWITD(I,J,IT,bi,bj) = HSNOWITD(I,J,IT,bi,bj)
1979         &                            + d_HSNWbySublim_ITD(I,J,IT)
1980         &                            + d_HSNWbyATMonSNW_ITD(I,J,IT)
1981         &                            + d_HSNWbyRAIN_ITD(I,J,IT)
1982         &                            + d_HSNWbyOCNonSNW_ITD(I,J,IT)
1983         &                            - d_HEFFbyFLOODING_ITD(I,J,IT)
1984         &                            * ICE2SNOW
1985               ENDDO
1986              ENDDO
1987             ENDDO
1988    #endif
1989    c ToM<<< debug seaice_growth
1990            WRITE(msgBuf,msgBufForm)
1991         &    ' SEAICE_GROWTH: Heff increments 9, HEFF = ',
1992    #ifdef SEAICE_ITD
1993         &     HEFFITD(1,1,:,bi,bj)
1994  #else  #else
      &    ' SEAICE_GROWTH: Heff increments 8, HEFF = ',  
1995       &     HEFF(1,1,bi,bj)       &     HEFF(1,1,bi,bj)
1996    #endif
1997          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
1998       &    SQUEEZE_RIGHT , myThid)       &    SQUEEZE_RIGHT , myThid)
1999          WRITE(msgBuf,'(A,7F8.4)')          WRITE(msgBuf,msgBufForm)
2000       &    ' SEAICE_GROWTH: Area increments 8, AREA = ',       &    ' SEAICE_GROWTH: Area increments 9, AREA = ',
2001    #ifdef SEAICE_ITD
2002         &     AREAITD(1,1,:,bi,bj)
2003    #else
2004       &     AREA(1,1,bi,bj)       &     AREA(1,1,bi,bj)
2005  #endif  #endif
2006          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,          CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
# Line 1965  CADJ STORE HSNOW(:,:,bi,bj) = comlev1_bi Line 2031  CADJ STORE HSNOW(:,:,bi,bj) = comlev1_bi
2031  CADJ STORE AREA(:,:,bi,bj) = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE AREA(:,:,bi,bj) = comlev1_bibj,key=iicekey,byte=isbyte
2032  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
2033    
2034  c#ifdef SEAICE_ITD  #ifdef SEAICE_ITD
2035  cC       replaces Hibler '79 scheme and lead closing parameter  C--     account for lateral ice growth and melt only in thinnest category
2036  cC       because ITD accounts explicitly for lead openings and  C--     use HEFF, ARE, HSNOW, etc. temporarily for 1st category
2037  cC       different melt rates due to varying ice thickness  C       (this way we can use same code for ITD and non-ITD case)
 cC  
 cC       only consider ice area loss due to total ice thickness loss;  
 cC       ice area gain due to freezing of open water is handled above  
 cC       under "gain of new ice over open water"  
 cC  
 cC       does not account for lateral melt of ice floes  
 cC  
 cC        AREAITD is incremented in section "gain of new ice over open water" above  
 cC  
 c        DO IT=1,nITD  
 c         DO J=1,sNy  
 c          DO I=1,sNx  
 c          IF (HEFFITD(I,J,IT,bi,bj).LE.ZERO) THEN  
 c           AREAITD(I,J,IT,bi,bj)=ZERO  
 c          ENDIF  
 c#ifdef ALLOW_SITRACER  
 c           SItrAREA(I,J,bi,bj,3) = SItrAREA(I,J,bi,bj,3)  
 c     &                           + AREAITD(I,J,IT,bi,bj)  
 c#endif /* ALLOW_SITRACER */  
 c         ENDDO  
 c        ENDDO  
 c       ENDDO  
 c#else /* SEAICE_ITD */  
2038          DO J=1,sNy          DO J=1,sNy
2039           DO I=1,sNx           DO I=1,sNx
   
 ctom<<< debugging  
 #ifdef SEAICE_ITD  
2040            HEFF(I,J,bi,bj)=HEFFITD(I,J,1,bi,bj)            HEFF(I,J,bi,bj)=HEFFITD(I,J,1,bi,bj)
2041            AREA(I,J,bi,bj)=AREAITD(I,J,1,bi,bj)            AREA(I,J,bi,bj)=AREAITD(I,J,1,bi,bj)
2042            HSNOW(I,J,bi,bj)=HSNOWITD(I,J,1,bi,bj)            HSNOW(I,J,bi,bj)=HSNOWITD(I,J,1,bi,bj)
2043            HEFFpreTH(I,J)=HEFFITDpreTH(I,J,1)            HEFFpreTH(I,J)=HEFFITDpreTH(I,J,1)
2044            AREApreTH(I,J)=AREAITDpreTH(I,J,1)            AREApreTH(I,J)=AREAITDpreTH(I,J,1)
2045            recip_heffActual(I,J)=recip_heffActualMult(I,J,1)            recip_heffActual(I,J)=recip_heffActualMult(I,J,1)
2046             ENDDO
2047            ENDDO
2048    C       all other categories only experience basal growth or melt,
2049    C       i.e. change sin AREA only occur when all ice in a category is melted
2050            IF (nITD .gt. 1) THEN
2051             DO IT=2,nITD
2052              DO J=1,sNy
2053               DO I=1,sNx
2054                IF (HEFFITD(I,J,IT,bi,bj).LE.ZERO) THEN
2055                 AREAITD(I,J,IT,bi,bj)=ZERO
2056                ENDIF
2057               ENDDO
2058              ENDDO
2059             ENDDO
2060            ENDIF
2061  #endif  #endif
2062  ctom>>> debugging          DO J=1,sNy
2063             DO I=1,sNx
2064    
2065            IF ( YC(I,J,bi,bj) .LT. ZERO ) THEN            IF ( YC(I,J,bi,bj) .LT. ZERO ) THEN
2066             recip_HO=1. _d 0 / HO_south             recip_HO=1. _d 0 / HO_south
# Line 2070  C apply tendency Line 2126  C apply tendency
2126            d_AREAbyOCN(I,J)=            d_AREAbyOCN(I,J)=
2127       &        HALF*recip_HH*MIN( 0. _d 0,d_HEFFbyOCNonICE(I,J) )       &        HALF*recip_HH*MIN( 0. _d 0,d_HEFFbyOCNonICE(I,J) )
2128  #endif /* ALLOW_DIAGNOSTICS */  #endif /* ALLOW_DIAGNOSTICS */
2129  ctom<<< debugging           ENDDO
2130            ENDDO
2131  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
2132    C       transfer 1st category values back into ITD variables
2133            DO J=1,sNy
2134             DO I=1,sNx
2135            HEFFITD(I,J,1,bi,bj)=HEFF(I,J,bi,bj)            HEFFITD(I,J,1,bi,bj)=HEFF(I,J,bi,bj)
2136            AREAITD(I,J,1,bi,bj)=AREA(I,J,bi,bj)            AREAITD(I,J,1,bi,bj)=AREA(I,J,bi,bj)
2137            HSNOWITD(I,J,1,bi,bj)=HSNOW(I,J,bi,bj)            HSNOWITD(I,J,1,bi,bj)=HSNOW(I,J,bi,bj)
 #endif  
 ctom>>> debugging  
2138           ENDDO           ENDDO
2139          ENDDO          ENDDO
2140  c#endif /* SEAICE_ITD */  #endif
2141    
2142  #if (defined ALLOW_AUTODIFF_TAMC && defined SEAICE_MODIFY_GROWTH_ADJ)  #if (defined ALLOW_AUTODIFF_TAMC && defined SEAICE_MODIFY_GROWTH_ADJ)
2143  Cgf 'bulk' linearization of area=f(HEFF)  Cgf 'bulk' linearization of area=f(HEFF)
# Line 2111  C finally update total AREA, HEFF, HSNOW Line 2169  C finally update total AREA, HEFF, HSNOW
2169          CALL SEAICE_ITD_SUM(bi, bj, myTime,myIter,myThid)          CALL SEAICE_ITD_SUM(bi, bj, myTime,myIter,myThid)
2170  #endif  #endif
2171    
 c ToM<<< debugging  
         DO J=1,sNy  
          DO I=1,sNx  
           if (I.eq.1 .and. J.eq.1) then  
            print *, 'd_HEFFbyNEG(I,J)      = ', d_HEFFbyNEG(I,J)  
            print *, 'd_HEFFbyOCNonICE(I,J) = ', d_HEFFbyOCNonICE(I,J)  
            print *, 'd_HEFFbyATMonOCN(I,J) = ', d_HEFFbyATMonOCN(I,J)  
            print *, 'd_HEFFbyATMonOCN_cover(I,J) = ',  
      &               d_HEFFbyATMonOCN_cover(I,J)  
            print *, 'd_HEFFbyATMonOCN_open(I,J) = ',  
      &               d_HEFFbyATMonOCN_open(I,J)  
            print *, 'd_HEFFbyFLOODING(I,J) = ', d_HEFFbyFLOODING(I,J)  
            print *, 'd_HEFFbySublim(I,J)   = ', d_HEFFbySublim(I,J)  
           endif  
          ENDDO  
         ENDDO  
 c ToM>>>  
2172  C ===================================================================  C ===================================================================
2173  C =============PART 5: determine ice salinity increments=============  C =============PART 5: determine ice salinity increments=============
2174  C ===================================================================  C ===================================================================
# Line 2149  CADJ &                       key = iicek Line 2190  CADJ &                       key = iicek
2190            tmpscal1 = d_HEFFbyNEG(I,J) + d_HEFFbyOCNonICE(I,J) +            tmpscal1 = d_HEFFbyNEG(I,J) + d_HEFFbyOCNonICE(I,J) +
2191       &               d_HEFFbyATMonOCN(I,J) + d_HEFFbyFLOODING(I,J)       &               d_HEFFbyATMonOCN(I,J) + d_HEFFbyFLOODING(I,J)
2192       &             + d_HEFFbySublim(I,J)       &             + d_HEFFbySublim(I,J)
2193  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
2194                     + d_HEFFbyRLX(I,J)       &             + d_HEFFbyRLX(I,J)
2195  #endif  #endif
2196            tmpscal2 = tmpscal1 * SEAICE_salt0 * HEFFM(I,J,bi,bj)            tmpscal2 = tmpscal1 * SEAICE_salt0 * HEFFM(I,J,bi,bj)
2197       &            * recip_deltaTtherm * SEAICE_rhoIce       &            * recip_deltaTtherm * SEAICE_rhoIce
# Line 2244  C set HSALT = 0 if HEFF = 0 and compute Line 2285  C set HSALT = 0 if HEFF = 0 and compute
2285          ENDDO          ENDDO
2286  #endif /* SEAICE_VARIABLE_SALINITY */  #endif /* SEAICE_VARIABLE_SALINITY */
2287    
   
2288  C =======================================================================  C =======================================================================
2289  C ==LEGACY PART 6 (LEGACY) treat pathological cases, then do flooding ===  C ==LEGACY PART 6 (LEGACY) treat pathological cases, then do flooding ===
2290  C =======================================================================  C =======================================================================
# Line 2327  C ================================= Line 2367  C =================================
2367  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
2368          DO J=1,sNy          DO J=1,sNy
2369           DO I=1,sNx           DO I=1,sNx
2370  c needs to be here to allow use also with LEGACY branch  C needs to be here to allow use also with LEGACY branch
2371            SItrHEFF(I,J,bi,bj,5)=HEFF(I,J,bi,bj)            SItrHEFF(I,J,bi,bj,5)=HEFF(I,J,bi,bj)
2372           ENDDO           ENDDO
2373          ENDDO          ENDDO
# Line 2390  C in principle a_QSWbyATM_cover should a Line 2430  C in principle a_QSWbyATM_cover should a
2430  C for backward compatibility it is left out of the LEGACY branch  C for backward compatibility it is left out of the LEGACY branch
2431       &         +   a_QSWbyATM_cover(I,J)       &         +   a_QSWbyATM_cover(I,J)
2432  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
2433       &         - ( d_HEFFbyOCNonICE(I,J) +       &         - ( d_HEFFbyOCNonICE(I,J)
2434       &             d_HSNWbyOCNonSNW(I,J)*SNOW2ICE +       &           + d_HSNWbyOCNonSNW(I,J)*SNOW2ICE
2435       &             d_HEFFbyNEG(I,J) +       &           + d_HEFFbyNEG(I,J)
2436  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
2437       &             d_HEFFbyRLX(I,J) +       &           + d_HEFFbyRLX(I,J)
2438  #endif  #endif
2439       &             d_HSNWbyNEG(I,J)*SNOW2ICE )       &           + d_HSNWbyNEG(I,J)*SNOW2ICE
2440       &         * maskC(I,J,kSurface,bi,bj)       &           - convertPRECIP2HI *
2441         &             snowPrecip(i,j,bi,bj) * (ONE-AREApreTH(I,J))
2442         &           ) * maskC(I,J,kSurface,bi,bj)
2443             ENDDO
2444            ENDDO
2445            DO J=1,sNy
2446             DO I=1,sNx
2447            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)
2448           ENDDO           ENDDO
2449          ENDDO          ENDDO
 cToM<<< debugging  
         print*,'------------------'  
         print*,'OcnModFrc: QNET = ',QNET(1,1,bi,bj)  
         print*,'OcnModFrc: QSW  = ',QSW(1,1,bi,bj)  
         print*,' '  
         print*,'r_QbyATM_cover  = ', r_QbyATM_cover(1,1)  
         print*,'r_QbyATM_open   = ', r_QbyATM_open(1,1)  
         print*,'a_QSWbyATM_cover = ', a_QSWbyATM_cover(1,1)  
         print*,'d_HEFFbyOCNonICE = ', d_HEFFbyOCNonICE(1,1)  
         print*,'d_HSNWbyOCNonSNW = ', d_HSNWbyOCNonSNW(1,1)  
         print*,'d_HEFFbyNEG = ', d_HEFFbyNEG(1,1)  
         print*,'d_HSNWbyNEG = ', d_HSNWbyNEG(1,1)  
         print*,'SNOW2ICE = ',SNOW2ICE  
         print*,'maskC       = ', maskC(1,1,kSurface,bi,bj)  
         print*,'------------------'  
 cToM>>>  
2450    
2451  C switch heat fluxes from 'effective' ice meters to W/m2  C switch heat fluxes from 'effective' ice meters to W/m2
2452  C ======================================================  C ======================================================
# Line 2441  CADJ STORE d_HSNWbyATMonSNW = comlev1_bi Line 2471  CADJ STORE d_HSNWbyATMonSNW = comlev1_bi
2471  CADJ STORE theta(:,:,kSurface,bi,bj) = comlev1_bibj,  CADJ STORE theta(:,:,kSurface,bi,bj) = comlev1_bibj,
2472  CADJ &                       key = iicekey, byte = isbyte  CADJ &                       key = iicekey, byte = isbyte
2473  # endif /* ALLOW_AUTODIFF_TAMC */  # endif /* ALLOW_AUTODIFF_TAMC */
2474        IF ( SEAICEheatConsFix ) THEN  cgf Unlike for evap and precip, the temperature of gained/lost
2475  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
2476  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
2477  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
2478  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
2479        IF ((convertFW2Salt.EQ.-1.).OR.(temp_EvPrRn.EQ.UNSET_RL)) THEN  C ocean+ice system. While this is mostly a serious issue in the
2480  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
2481  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.
2482    C Below we therefore anticipate on external_forcing_surf.F
2483    C to diagnoze and/or apply the correction to QNET.
2484          DO J=1,sNy          DO J=1,sNy
2485           DO I=1,sNx           DO I=1,sNx
2486  #ifdef ALLOW_DIAGNOSTICS  C ocean water going to ice/snow, in precip units
2487  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)*  
2488       &       ( d_HSNWbyATMonSNW(I,J)*SNOW2ICE       &       ( d_HSNWbyATMonSNW(I,J)*SNOW2ICE
2489       &       + d_HSNWbyOCNonSNW(I,J)*SNOW2ICE       &       + d_HSNWbyOCNonSNW(I,J)*SNOW2ICE
2490       &       + d_HEFFbyOCNonICE(I,J) + d_HEFFbyATMonOCN(I,J)       &       + d_HEFFbyOCNonICE(I,J) + d_HEFFbyATMonOCN(I,J)
2491       &       + d_HEFFbyNEG(I,J) + d_HSNWbyNEG(I,J)*SNOW2ICE )       &       + d_HEFFbyNEG(I,J) + d_HSNWbyNEG(I,J)*SNOW2ICE )
2492       &       * convertHI2PRECIP       &       * convertHI2PRECIP
2493  c factor in the heat content that external_forcing_surf.F       &       - snowPrecip(i,j,bi,bj) * (ONE-AREApreTH(I,J)) )
2494  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
2495  c melt/freez water is in effect consistently gained/lost at 0degC        IF ( (temp_EvPrRn.NE.UNSET_RL).AND.useRealFreshWaterFlux
2496             IF (temp_EvPrRn.NE.UNSET_RL) THEN       &     .AND.(nonlinFreeSurf.NE.0) ) THEN
2497               QNET(I,J,bi,bj)=QNET(I,J,bi,bj) - tmpscal3*               tmpscal1 = - tmpscal3*
2498       &         HeatCapacity_Cp * temp_EvPrRn       &         HeatCapacity_Cp * temp_EvPrRn
2499             ELSE        ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL).AND.useRealFreshWaterFlux
2500               QNET(I,J,bi,bj)=QNET(I,J,bi,bj) - tmpscal3*       &         .AND.(nonlinFreeSurf.NE.0) ) THEN
2501                 tmpscal1 = - tmpscal3*
2502       &         HeatCapacity_Cp * theta(I,J,kSurface,bi,bj)       &         HeatCapacity_Cp * theta(I,J,kSurface,bi,bj)
2503             ENDIF        ELSEIF ( (temp_EvPrRn.NE.UNSET_RL) ) THEN
2504               tmpscal1 = - tmpscal3*HeatCapacity_Cp*
2505         &       ( temp_EvPrRn - theta(I,J,kSurface,bi,bj) )
2506          ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL) ) THEN
2507               tmpscal1 = ZERO
2508          ENDIF
2509  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
2510  c back out the eventual TFLUX adjustement and fill diag  C in all cases, diagnoze the boundary condition mismatch to SIaaflux
2511             DIAGarrayA(I,J)=QNET(I,J,bi,bj)-DIAGarrayA(I,J)             DIAGarrayA(I,J)=tmpscal1
2512  #endif  #endif
2513    C remove the mismatch when real fresh water is exchanged (at 0degC here)
2514          IF ( useRealFreshWaterFlux.AND.(nonlinFreeSurf.GT.0).AND.
2515         &   SEAICEheatConsFix ) QNET(I,J,bi,bj)=QNET(I,J,bi,bj)+tmpscal1
2516           ENDDO           ENDDO
2517          ENDDO          ENDDO
       ENDIF  
2518  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
2519          CALL DIAGNOSTICS_FILL(DIAGarrayA,          CALL DIAGNOSTICS_FILL(DIAGarrayA,
2520       &      'SIaaflux',0,1,3,bi,bj,myThid)       &      'SIaaflux',0,1,3,bi,bj,myThid)
2521  #endif  #endif
       ENDIF  
2522  #endif /* ndef SEAICE_DISABLE_HEATCONSFIX */  #endif /* ndef SEAICE_DISABLE_HEATCONSFIX */
2523    
2524    C compute the net heat flux, incl. adv. by water, entering ocean+ice
2525    C ===================================================================
2526             DO J=1,sNy
2527              DO I=1,sNx
2528    cgf 1) SIatmQnt (analogous to qnet; excl. adv. by water exch.)
2529    CML If I consider the atmosphere above the ice, the surface flux
2530    CML which is relevant for the air temperature dT/dt Eq
2531    CML accounts for sensible and radiation (with different treatment
2532    CML according to wave-length) fluxes but not for "latent heat flux",
2533    CML since it does not contribute to heating the air.
2534    CML So this diagnostic is only good for heat budget calculations within
2535    CML the ice-ocean system.
2536               SIatmQnt(I,J,bi,bj) =
2537         &            maskC(I,J,kSurface,bi,bj)*convertHI2Q*(
2538    #ifndef SEAICE_GROWTH_LEGACY
2539         &            a_QSWbyATM_cover(I,J) +
2540    #endif /* SEAICE_GROWTH_LEGACY */
2541         &            a_QbyATM_cover(I,J) + a_QbyATM_open(I,J) )
2542    cgf 2) SItflux (analogous to tflux; includes advection by water
2543    C             exchanged between atmosphere and ocean+ice)
2544    C solid water going to atm, in precip units
2545               tmpscal1 = rhoConstFresh*maskC(I,J,kSurface,bi,bj)
2546         &       * convertHI2PRECIP * ( - d_HSNWbyRAIN(I,J)*SNOW2ICE
2547         &       + a_FWbySublim(I,J) - r_FWbySublim(I,J) )
2548    C liquid water going to atm, in precip units
2549               tmpscal2=rhoConstFresh*maskC(I,J,kSurface,bi,bj)*
2550         &       ( ( EVAP(I,J,bi,bj)-PRECIP(I,J,bi,bj) )
2551         &         * ( ONE - AREApreTH(I,J) )
2552    #ifdef ALLOW_RUNOFF
2553         &         - RUNOFF(I,J,bi,bj)
2554    #endif /* ALLOW_RUNOFF */
2555         &         + ( d_HFRWbyRAIN(I,J) + r_FWbySublim(I,J) )
2556         &         *convertHI2PRECIP )
2557    C In real fresh water flux + nonlinFS, we factor in the advected specific
2558    C energy (referenced to 0 for 0deC liquid water). In virtual salt flux or
2559    C linFS, rain/evap get a special treatment (see external_forcing_surf.F).
2560               tmpscal1= - tmpscal1*
2561         &       ( -SEAICE_lhFusion + HeatCapacity_Cp * ZERO )
2562          IF ( (temp_EvPrRn.NE.UNSET_RL).AND.useRealFreshWaterFlux
2563         &     .AND.(nonlinFreeSurf.NE.0) ) THEN
2564               tmpscal2= - tmpscal2*
2565         &       ( ZERO + HeatCapacity_Cp * temp_EvPrRn )
2566          ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL).AND.useRealFreshWaterFlux
2567         &        .AND.(nonlinFreeSurf.NE.0) ) THEN
2568               tmpscal2= - tmpscal2*
2569         &       ( ZERO + HeatCapacity_Cp * theta(I,J,kSurface,bi,bj) )
2570          ELSEIF ( (temp_EvPrRn.NE.UNSET_RL) ) THEN
2571               tmpscal2= - tmpscal2*HeatCapacity_Cp*
2572         &       ( temp_EvPrRn - theta(I,J,kSurface,bi,bj) )
2573          ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL) ) THEN
2574               tmpscal2= ZERO
2575          ENDIF
2576               SItflux(I,J,bi,bj)=
2577         &            SIatmQnt(I,J,bi,bj)-tmpscal1-tmpscal2    
2578              ENDDO
2579             ENDDO
2580    
2581  C compute net fresh water flux leaving/entering  C compute net fresh water flux leaving/entering
2582  C the ocean, accounting for fresh/salt water stocks.  C the ocean, accounting for fresh/salt water stocks.
2583  C ==================================================  C ==================================================
# Line 2499  C ====================================== Line 2591  C ======================================
2591       &             +d_HEFFbyOCNonICE(I,J)       &             +d_HEFFbyOCNonICE(I,J)
2592       &             +d_HEFFbyATMonOCN(I,J)       &             +d_HEFFbyATMonOCN(I,J)
2593       &             +d_HEFFbyNEG(I,J)       &             +d_HEFFbyNEG(I,J)
2594  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
2595       &             +d_HEFFbyRLX(I,J)       &             +d_HEFFbyRLX(I,J)
2596  #endif  #endif
2597       &             +d_HSNWbyNEG(I,J)*SNOW2ICE       &             +d_HSNWbyNEG(I,J)*SNOW2ICE
# Line 2513  C     If r_FWbySublim>0, then it is evap Line 2605  C     If r_FWbySublim>0, then it is evap
2605  #endif /* ALLOW_RUNOFF */  #endif /* ALLOW_RUNOFF */
2606       &         + tmpscal1*convertHI2PRECIP       &         + tmpscal1*convertHI2PRECIP
2607       &         )*rhoConstFresh       &         )*rhoConstFresh
2608    c and the flux leaving/entering the ocean+ice
2609               SIatmFW(I,J,bi,bj) = maskC(I,J,kSurface,bi,bj)*(
2610         &          EVAP(I,J,bi,bj)*( ONE - AREApreTH(I,J) )
2611         &          - PRECIP(I,J,bi,bj)
2612    #ifdef ALLOW_RUNOFF
2613         &          - RUNOFF(I,J,bi,bj)
2614    #endif /* ALLOW_RUNOFF */
2615         &           )*rhoConstFresh
2616         &     + a_FWbySublim(I,J) * SEAICE_rhoIce * recip_deltaTtherm
2617    
2618           ENDDO           ENDDO
2619          ENDDO          ENDDO        
2620    
2621  #ifdef ALLOW_SSH_GLOBMEAN_COST_CONTRIBUTION  #ifdef ALLOW_SSH_GLOBMEAN_COST_CONTRIBUTION
2622  C--  C--
# Line 2585  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 2687  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
2687           ENDDO           ENDDO
2688          ENDIF          ENDIF
2689    
2690    #ifdef ALLOW_BALANCE_FLUXES
2691    C Compute tile integrals of heat/fresh water fluxes to/from atm.
2692    C ==============================================================
2693           FWFsiTile(bi,bj) = 0. _d 0
2694           IF ( balanceEmPmR ) THEN
2695            DO j=1,sNy
2696             DO i=1,sNx
2697              FWFsiTile(bi,bj) =
2698         &      FWFsiTile(bi,bj) + SIatmFW(i,j,bi,bj)
2699         &      * rA(i,j,bi,bj) * maskInC(i,j,bi,bj)
2700             ENDDO
2701            ENDDO
2702           ENDIF
2703    c to translate global mean FWF adjustements (see below) we may need :
2704           FWF2HFsiTile(bi,bj) = 0. _d 0      
2705           IF ( balanceEmPmR.AND.(temp_EvPrRn.EQ.UNSET_RL) ) THEN
2706            DO j=1,sNy
2707             DO i=1,sNx
2708              FWF2HFsiTile(bi,bj) = FWF2HFsiTile(bi,bj) +
2709         &      HeatCapacity_Cp * theta(I,J,kSurface,bi,bj)
2710         &      * rA(i,j,bi,bj) * maskInC(i,j,bi,bj)
2711             ENDDO
2712            ENDDO
2713           ENDIF
2714           HFsiTile(bi,bj) = 0. _d 0
2715           IF ( balanceQnet ) THEN
2716            DO j=1,sNy
2717             DO i=1,sNx
2718              HFsiTile(bi,bj) =
2719         &      HFsiTile(bi,bj) + SItflux(i,j,bi,bj)
2720         &      * rA(i,j,bi,bj) * maskInC(i,j,bi,bj)
2721             ENDDO
2722            ENDDO
2723           ENDIF
2724    #endif
2725    
2726  C ===================================================================  C ===================================================================
2727  C ======================PART 8: diagnostics==========================  C ======================PART 8: diagnostics==========================
2728  C ===================================================================  C ===================================================================
# Line 2635  C three that actually need intermediate Line 2773  C three that actually need intermediate
2773  #ifdef ALLOW_ATM_TEMP  #ifdef ALLOW_ATM_TEMP
2774           DO J=1,sNy           DO J=1,sNy
2775            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  
2776             DIAGarrayB(I,J) = maskC(I,J,kSurface,bi,bj) *             DIAGarrayB(I,J) = maskC(I,J,kSurface,bi,bj) *
2777       &       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  
2778            ENDDO            ENDDO
2779           ENDDO           ENDDO
          CALL DIAGNOSTICS_FILL(DIAGarrayA,  
      &      'SIatmQnt',0,1,3,bi,bj,myThid)  
2780           CALL DIAGNOSTICS_FILL(DIAGarrayB,           CALL DIAGNOSTICS_FILL(DIAGarrayB,
2781       &      '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)  
2782  C  C
2783           DO J=1,sNy           DO J=1,sNy
2784            DO I=1,sNx            DO I=1,sNx
# Line 2674  C the actual Freshwater flux of sublimat Line 2786  C the actual Freshwater flux of sublimat
2786             DIAGarrayA(I,J) = maskC(I,J,kSurface,bi,bj)             DIAGarrayA(I,J) = maskC(I,J,kSurface,bi,bj)
2787       &       * (a_FWbySublim(I,J)-r_FWbySublim(I,J))       &       * (a_FWbySublim(I,J)-r_FWbySublim(I,J))
2788       &       * SEAICE_rhoIce * recip_deltaTtherm       &       * SEAICE_rhoIce * recip_deltaTtherm
2789  c the residual Freshwater flux of sublimated ice  C the residual Freshwater flux of sublimated ice
2790             DIAGarrayC(I,J) = maskC(I,J,kSurface,bi,bj)             DIAGarrayC(I,J) = maskC(I,J,kSurface,bi,bj)
2791       &       * r_FWbySublim(I,J)       &       * r_FWbySublim(I,J)
2792       &       * SEAICE_rhoIce * recip_deltaTtherm       &       * SEAICE_rhoIce * recip_deltaTtherm
# Line 2691  C the latent heat flux Line 2803  C the latent heat flux
2803           CALL DIAGNOSTICS_FILL(DIAGarrayA,'SIacSubl',0,1,3,bi,bj,myThid)           CALL DIAGNOSTICS_FILL(DIAGarrayA,'SIacSubl',0,1,3,bi,bj,myThid)
2804           CALL DIAGNOSTICS_FILL(DIAGarrayC,'SIrsSubl',0,1,3,bi,bj,myThid)           CALL DIAGNOSTICS_FILL(DIAGarrayC,'SIrsSubl',0,1,3,bi,bj,myThid)
2805           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)  
2806  #endif /* ALLOW_ATM_TEMP */  #endif /* ALLOW_ATM_TEMP */
2807    
2808          ENDIF          ENDIF
# Line 2737  C close bi,bj loops Line 2812  C close bi,bj loops
2812         ENDDO         ENDDO
2813        ENDDO        ENDDO
2814    
2815    
2816    C ===================================================================
2817    C =========PART 9: HF/FWF global integrals and balancing=============
2818    C ===================================================================
2819    
2820    #ifdef ALLOW_BALANCE_FLUXES
2821    
2822    c 1)  global sums
2823    # ifdef ALLOW_AUTODIFF_TAMC
2824    CADJ STORE FWFsiTile = comlev1, key=ikey_dynamics, kind=isbyte
2825    CADJ STORE HFsiTile = comlev1, key=ikey_dynamics, kind=isbyte
2826    CADJ STORE FWF2HFsiTile = comlev1, key=ikey_dynamics, kind=isbyte
2827    # endif /* ALLOW_AUTODIFF_TAMC */
2828          FWFsiGlob=0. _d 0
2829          IF ( balanceEmPmR )
2830         &   CALL GLOBAL_SUM_TILE_RL( FWFsiTile, FWFsiGlob, myThid )        
2831          FWF2HFsiGlob=0. _d 0
2832          IF ( balanceEmPmR.AND.(temp_EvPrRn.EQ.UNSET_RL) ) THEN
2833             CALL GLOBAL_SUM_TILE_RL(FWF2HFsiTile, FWF2HFsiGlob, myThid)
2834          ELSEIF ( balanceEmPmR ) THEN
2835             FWF2HFsiGlob=HeatCapacity_Cp * temp_EvPrRn * globalArea
2836          ENDIF
2837          HFsiGlob=0. _d 0
2838          IF ( balanceQnet )
2839         &   CALL GLOBAL_SUM_TILE_RL( HFsiTile, HFsiGlob, myThid )
2840    
2841    c 2) global means
2842    c mean SIatmFW
2843          tmpscal0=FWFsiGlob / globalArea
2844    c corresponding mean advection by atm to ocean+ice water exchange
2845    c        (if mean SIatmFW was removed uniformely from ocean)
2846          tmpscal1=FWFsiGlob / globalArea * FWF2HFsiGlob / globalArea
2847    c mean SItflux (before potential adjustement due to SIatmFW)
2848          tmpscal2=HFsiGlob / globalArea
2849    c mean SItflux (after potential adjustement due to SIatmFW)
2850          IF ( balanceEmPmR ) tmpscal2=tmpscal2-tmpscal1
2851    
2852    c 3) balancing adjustments
2853          IF ( balanceEmPmR ) THEN
2854          DO bj=myByLo(myThid),myByHi(myThid)
2855           DO bi=myBxLo(myThid),myBxHi(myThid)
2856            DO j=1-OLy,sNy+OLy
2857             DO i=1-OLx,sNx+OLx
2858                empmr(i,j,bi,bj) = empmr(i,j,bi,bj) - tmpscal0
2859                SIatmFW(i,j,bi,bj) = SIatmFW(i,j,bi,bj) - tmpscal0
2860    c           adjust SItflux consistently      
2861                IF ( (temp_EvPrRn.NE.UNSET_RL).AND.
2862         &        useRealFreshWaterFlux.AND.(nonlinFreeSurf.NE.0) ) THEN
2863                tmpscal1=
2864         &       ( ZERO + HeatCapacity_Cp * temp_EvPrRn )
2865                ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL).AND.
2866         &        useRealFreshWaterFlux.AND.(nonlinFreeSurf.NE.0) ) THEN
2867                tmpscal1=
2868         &       ( ZERO + HeatCapacity_Cp * theta(I,J,kSurface,bi,bj) )
2869                ELSEIF ( (temp_EvPrRn.NE.UNSET_RL) ) THEN
2870                tmpscal1=
2871         &       HeatCapacity_Cp*(temp_EvPrRn - theta(I,J,kSurface,bi,bj))
2872                ELSE
2873                tmpscal1=ZERO
2874                ENDIF
2875                SItflux(i,j,bi,bj) = SItflux(i,j,bi,bj) - tmpscal0*tmpscal1
2876    c           no qnet or tflux adjustement is needed
2877             ENDDO
2878            ENDDO
2879           ENDDO
2880          ENDDO
2881          IF ( balancePrintMean ) THEN
2882           _BEGIN_MASTER( myThid )
2883           WRITE(msgbuf,'(a,a,e24.17)') 'rm Global mean of ',
2884         &      'SIatmFW = ', tmpscal0
2885           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
2886         &      SQUEEZE_RIGHT , myThid)
2887           _END_MASTER( myThid )
2888          ENDIF
2889          ENDIF
2890          IF ( balanceQnet ) THEN
2891          DO bj=myByLo(myThid),myByHi(myThid)
2892           DO bi=myBxLo(myThid),myBxHi(myThid)
2893            DO j=1-OLy,sNy+OLy
2894             DO i=1-OLx,sNx+OLx
2895                SItflux(i,j,bi,bj) = SItflux(i,j,bi,bj) - tmpscal2
2896                qnet(i,j,bi,bj) = qnet(i,j,bi,bj) - tmpscal2
2897                SIatmQnt(i,j,bi,bj) = SIatmQnt(i,j,bi,bj) - tmpscal2
2898             ENDDO
2899            ENDDO
2900           ENDDO
2901          ENDDO
2902          IF ( balancePrintMean ) THEN
2903           _BEGIN_MASTER( myThid )
2904           WRITE(msgbuf,'(a,a,e24.17)') 'rm Global mean of ',
2905         &      'SItflux = ', tmpscal2
2906           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
2907         &      SQUEEZE_RIGHT , myThid)
2908           _END_MASTER( myThid )
2909          ENDIF
2910          ENDIF
2911    #endif /* */
2912    
2913    #ifdef ALLOW_DIAGNOSTICS
2914    c these diags need to be done outside of the bi,bj loop so that
2915    c we may do potential global mean adjustement to them consistently.
2916             CALL DIAGNOSTICS_FILL(SItflux,
2917         &      'SItflux ',0,1,0,1,1,myThid)
2918             CALL DIAGNOSTICS_FILL(SIatmQnt,
2919         &      'SIatmQnt',0,1,0,1,1,myThid)
2920    c SIatmFW follows the same convention as empmr -- SIatmFW diag does not
2921             tmpscal1= - 1. _d 0
2922             CALL DIAGNOSTICS_SCALE_FILL(SIatmFW,
2923         &      tmpscal1,1,'SIatmFW ',0,1,0,1,1,myThid)
2924    #endif /* ALLOW_DIAGNOSTICS */
2925    
2926        RETURN        RETURN
2927        END        END

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.22