/[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.9 by torge, Mon Oct 22 16:36:45 2012 UTC revision 1.10 by torge, Mon Oct 22 21:12:47 2012 UTC
# Line 97  C     i,j,bi,bj :: Loop counters Line 97  C     i,j,bi,bj :: Loop counters
97        INTEGER i, j, bi, bj        INTEGER i, j, bi, bj
98  C     number of surface interface layer  C     number of surface interface layer
99        INTEGER kSurface        INTEGER kSurface
100    C     IT :: ice thickness category index (MULTICATEGORIES and ITD code)
101          INTEGER IT
102          _RL pFac
103  C     constants  C     constants
104        _RL tempFrz, ICE2SNOW, SNOW2ICE        _RL tempFrz, ICE2SNOW, SNOW2ICE
105        _RL QI, QS, recip_QI        _RL QI, QS, recip_QI
106          _RL lhSublim
107    
108    C conversion factors to go from Q (W/m2) to HEFF (ice meters)
109          _RL convertQ2HI, convertHI2Q
110    C conversion factors to go from precip (m/s) unit to HEFF (ice meters)
111          _RL convertPRECIP2HI, convertHI2PRECIP
112    C     Factor by which we increase the upper ocean friction velocity (u*) when
113    C     ice is absent in a grid cell  (dimensionless)
114          _RL MixedLayerTurbulenceFactor
115    
116    C     wind speed square
117          _RL SPEED_SQ
118    
119    C     Regularization values squared
120          _RL area_reg_sq, hice_reg_sq
121    C     pathological cases thresholds
122          _RL heffTooHeavy
123    
124    C     Helper variables: reciprocal of some constants
125          _RL recip_multDim
126          _RL recip_deltaTtherm
127          _RL recip_rhoIce
128    C     local value (=1/HO or 1/HO_south)
129          _RL recip_HO
130    C     local value (=1/ice thickness)
131          _RL recip_HH
132    C     facilitate multi-category snow implementation
133          _RL pFacSnow
134    
135    C     temporary variables available for the various computations
136          _RL tmpscal0, tmpscal1, tmpscal2, tmpscal3, tmpscal4
137    
138    #ifdef ALLOW_SITRACER
139          INTEGER iTr
140    #ifdef ALLOW_DIAGNOSTICS
141          CHARACTER*8   diagName
142    #endif
143    #endif /* ALLOW_SITRACER */
144    #ifdef ALLOW_AUTODIFF_TAMC
145          INTEGER ilockey
146    #endif
147    
148    C==   local arrays ==
149  C--   TmixLoc        :: ocean surface/mixed-layer temperature (in K)  C--   TmixLoc        :: ocean surface/mixed-layer temperature (in K)
150        _RL TmixLoc       (1:sNx,1:sNy)        _RL TmixLoc       (1:sNx,1:sNy)
151    
152    C     actual ice thickness (with upper and lower limit)
153          _RL heffActual          (1:sNx,1:sNy)
154    C     actual snow thickness
155          _RL hsnowActual         (1:sNx,1:sNy)
156    C     actual ice thickness (with lower limit only) Reciprocal
157          _RL recip_heffActual    (1:sNx,1:sNy)
158    
159    C     AREA_PRE :: hold sea-ice fraction field before any seaice-thermo update
160          _RL AREApreTH           (1:sNx,1:sNy)
161          _RL HEFFpreTH           (1:sNx,1:sNy)
162          _RL HSNWpreTH           (1:sNx,1:sNy)
163    #ifdef SEAICE_ITD
164          _RL AREAITDpreTH        (1:sNx,1:sNy,1:nITD)
165          _RL HEFFITDpreTH        (1:sNx,1:sNy,1:nITD)
166          _RL HSNWITDpreTH        (1:sNx,1:sNy,1:nITD)
167          _RL areaFracFactor      (1:sNx,1:sNy,1:nITD)
168          _RL leadIceThickMin
169    #endif
170    
171    C     wind speed
172          _RL UG                  (1:sNx,1:sNy)
173    
174    C     temporary variables available for the various computations
175          _RL tmparr1             (1:sNx,1:sNy)
176    #ifdef SEAICE_VARIABLE_SALINITY
177          _RL saltFluxAdjust      (1:sNx,1:sNy)
178    #endif
179    
180          _RL ticeInMult          (1:sNx,1:sNy,MULTDIM)
181          _RL ticeOutMult         (1:sNx,1:sNy,MULTDIM)
182          _RL heffActualMult      (1:sNx,1:sNy,MULTDIM)
183          _RL hsnowActualMult     (1:sNx,1:sNy,MULTDIM)
184    #ifdef SEAICE_ITD
185          _RL recip_heffActualMult(1:sNx,1:sNy,MULTDIM)
186    #endif
187          _RL a_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)
188          _RL a_QSWbyATMmult_cover(1:sNx,1:sNy,MULTDIM)
189          _RL a_FWbySublimMult    (1:sNx,1:sNy,MULTDIM)
190    #ifdef SEAICE_ITD
191          _RL r_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)
192          _RL r_FWbySublimMult    (1:sNx,1:sNy,MULTDIM)
193    #endif
194    
195  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
196  C             the atmosphere and the ocean surface - for ice covered water  C             the atmosphere and the ocean surface - for ice covered water
197  C     a_QbyATM_open  :: same but for open water  C     a_QbyATM_open  :: same but for open water
# Line 124  C             processes have been accoun Line 212  C             processes have been accoun
212        _RL a_QbyOCN            (1:sNx,1:sNy)        _RL a_QbyOCN            (1:sNx,1:sNy)
213        _RL r_QbyOCN            (1:sNx,1:sNy)        _RL r_QbyOCN            (1:sNx,1:sNy)
214    
215  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
216        _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  
217        _RL d_HEFFbyNEG         (1:sNx,1:sNy)        _RL d_HEFFbyNEG         (1:sNx,1:sNy)
218    
219  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
220        _RL d_HEFFbyOCNonICE    (1:sNx,1:sNy)        _RL d_HEFFbyOCNonICE    (1:sNx,1:sNy)
221    
222  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
223  c     fraction and ice-covered fractions of the grid cell  C     the open water fraction and ice-covered fractions of the grid cell
224        _RL d_HEFFbyATMonOCN    (1:sNx,1:sNy)        _RL d_HEFFbyATMonOCN    (1:sNx,1:sNy)
225  c     The change of mean ice thickness due to flooding by snow  C     The change of mean ice thickness due to flooding by snow
226        _RL d_HEFFbyFLOODING    (1:sNx,1:sNy)        _RL d_HEFFbyFLOODING    (1:sNx,1:sNy)
227    
228  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
229  c     fraction and ice-covered fractions of the grid cell, respectively  C     water fraction and ice-covered fractions of the grid cell, respectively
230        _RL d_HEFFbyATMonOCN_open(1:sNx,1:sNy)        _RL d_HEFFbyATMonOCN_open(1:sNx,1:sNy)
231        _RL d_HEFFbyATMonOCN_cover(1:sNx,1:sNy)        _RL d_HEFFbyATMonOCN_cover(1:sNx,1:sNy)
232    
# Line 167  c     fraction and ice-covered fractions Line 236  c     fraction and ice-covered fractions
236        _RL d_HSNWbyRAIN        (1:sNx,1:sNy)        _RL d_HSNWbyRAIN        (1:sNx,1:sNy)
237    
238        _RL d_HFRWbyRAIN        (1:sNx,1:sNy)        _RL d_HFRWbyRAIN        (1:sNx,1:sNy)
239  C  
240  C     a_FWbySublim :: fresh water flux implied by latent heat of  C     a_FWbySublim :: fresh water flux implied by latent heat of
241  C                     sublimation to atmosphere, same sign convention  C                     sublimation to atmosphere, same sign convention
242  C                     as EVAP (positive upward)  C                     as EVAP (positive upward)
# Line 180  C                     as EVAP (positive Line 249  C                     as EVAP (positive
249  C     The latent heat flux which will sublimate all snow and ice  C     The latent heat flux which will sublimate all snow and ice
250  C     over one time step  C     over one time step
251        _RL latentHeatFluxMax   (1:sNx,1:sNy)        _RL latentHeatFluxMax   (1:sNx,1:sNy)
252        _RL latentHeatFluxMaxMult  (1:sNx,1:sNy,MULTDIM)        _RL latentHeatFluxMaxMult(1:sNx,1:sNy,MULTDIM)
253  #endif  #endif
254    
255  C     actual ice thickness (with upper and lower limit)  #ifdef EXF_ALLOW_SEAICE_RELAX
256        _RL heffActual          (1:sNx,1:sNy)  C     ICE/SNOW stocks tendency associated with relaxation towards observation
257  C     actual snow thickness        _RL d_AREAbyRLX         (1:sNx,1:sNy)
258        _RL hsnowActual         (1:sNx,1:sNy)  C     The change of mean ice thickness due to relaxation
259  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)  
 #endif  
   
       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)  
 #ifdef SEAICE_ITD  
       _RL r_QbyATMmult_cover  (1:sNx,1:sNy,MULTDIM)  
       _RL r_FWbySublimMult    (1:sNx,1:sNy,MULTDIM)  
260  #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  
261    
 #ifdef ALLOW_SITRACER  
       INTEGER iTr  
       CHARACTER*8   diagName  
 #endif  
262  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
263  c     Helper variables for diagnostics  C ICE/SNOW stocks tendencies associated with the various melt/freeze processes
264          _RL d_AREAbyATM         (1:sNx,1:sNy)
265          _RL d_AREAbyOCN         (1:sNx,1:sNy)
266          _RL d_AREAbyICE         (1:sNx,1:sNy)
267    C     Helper variables for diagnostics
268        _RL DIAGarrayA    (1:sNx,1:sNy)        _RL DIAGarrayA    (1:sNx,1:sNy)
269        _RL DIAGarrayB    (1:sNx,1:sNy)        _RL DIAGarrayB    (1:sNx,1:sNy)
270        _RL DIAGarrayC    (1:sNx,1:sNy)        _RL DIAGarrayC    (1:sNx,1:sNy)
271        _RL DIAGarrayD    (1:sNx,1:sNy)        _RL DIAGarrayD    (1:sNx,1:sNy)
272  #endif  #endif /* ALLOW_DIAGNOSTICS */
273    
274          _RL SItflux     (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
275          _RL SIatmQnt    (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
276          _RL SIatmFW     (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
277    #ifdef ALLOW_BALANCE_FLUXES
278          _RL FWFsiTile(nSx,nSy)
279          _RL FWFsiGlob
280          _RL HFsiTile(nSx,nSy)
281          _RL HFsiGlob
282          _RL FWF2HFsiTile(nSx,nSy)
283          _RL FWF2HFsiGlob
284          CHARACTER*(max_len_mbuf) msgbuf
285    #endif
286    
287  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
288    
# Line 335  C conversion factors to go from precip ( Line 352  C conversion factors to go from precip (
352       &                       + act4*max1*max2*max3       &                       + act4*max1*max2*max3
353  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
354    
   
355  C array initializations  C array initializations
356  C =====================  C =====================
357    
# Line 358  C ===================== Line 374  C =====================
374            d_AREAbyOCN(I,J)           = 0.0 _d 0            d_AREAbyOCN(I,J)           = 0.0 _d 0
375  #endif  #endif
376    
377  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
378            d_AREAbyRLX(I,J)           = 0.0 _d 0            d_AREAbyRLX(I,J)           = 0.0 _d 0
379            d_HEFFbyRLX(I,J)           = 0.0 _d 0            d_HEFFbyRLX(I,J)           = 0.0 _d 0
380  #endif  #endif
# Line 382  C ===================== Line 398  C =====================
398  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
399            latentHeatFluxMax(I,J)     = 0.0 _d 0            latentHeatFluxMax(I,J)     = 0.0 _d 0
400  #endif  #endif
 c  
401            d_HFRWbyRAIN(I,J)          = 0.0 _d 0            d_HFRWbyRAIN(I,J)          = 0.0 _d 0
   
402            tmparr1(I,J)               = 0.0 _d 0            tmparr1(I,J)               = 0.0 _d 0
   
403  #ifdef SEAICE_VARIABLE_SALINITY  #ifdef SEAICE_VARIABLE_SALINITY
404            saltFluxAdjust(I,J)        = 0.0 _d 0            saltFluxAdjust(I,J)        = 0.0 _d 0
405  #endif  #endif
# Line 414  c Line 427  c
427          ENDDO          ENDDO
428  #endif  #endif
429    
   
430  C =====================================================================  C =====================================================================
431  C ===========PART 1: treat pathological cases (post advdiff)===========  C ===========PART 1: treat pathological cases (post advdiff)===========
432  C =====================================================================  C =====================================================================
# Line 455  Cgf no dependency through pathological c Line 467  Cgf no dependency through pathological c
467          IF ( SEAICEadjMODE.EQ.0 ) THEN          IF ( SEAICEadjMODE.EQ.0 ) THEN
468  #endif  #endif
469    
470  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
471  CADJ STORE heff(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE heff(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte
472  CADJ STORE area(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte  CADJ STORE area(:,:,bi,bj) = comlev1_bibj, key = iicekey,byte=isbyte
473  C 0) relax sea ice concentration towards observation  C 0) relax sea ice concentration towards observation
# Line 485  C           d_HEFFbyRLX(i,j) = 1. _d 1 * Line 497  C           d_HEFFbyRLX(i,j) = 1. _d 1 *
497           ENDDO           ENDDO
498          ENDDO          ENDDO
499          ENDIF          ENDIF
500  #endif /* SEAICE_ALLOW_AREA_RELAXATION */  #endif /* EXF_ALLOW_SEAICE_RELAX */
501    
502  C 1) treat the case of negative values:  C 1) treat the case of negative values:
503    
# Line 881  cif       Do not regularize when HEFFpre Line 893  cif       Do not regularize when HEFFpre
893              tmpscal2         = HEFFpreTH(I,J)/tmpscal1              tmpscal2         = HEFFpreTH(I,J)/tmpscal1
894              heffActual(I,J)  = MAX(tmpscal2,SEAICE_hice_reg)              heffActual(I,J)  = MAX(tmpscal2,SEAICE_hice_reg)
895  #else /* SEAICE_GROWTH_LEGACY */  #else /* SEAICE_GROWTH_LEGACY */
896  cif        regularize AREA with SEAICE_area_reg  Cif        regularize AREA with SEAICE_area_reg
897             tmpscal1 = SQRT(AREApreTH(I,J)* AREApreTH(I,J) + area_reg_sq)             tmpscal1 = SQRT(AREApreTH(I,J)* AREApreTH(I,J) + area_reg_sq)
898  cif        heffActual calculated with the regularized AREA  Cif        heffActual calculated with the regularized AREA
899             tmpscal2 = HEFFpreTH(I,J) / tmpscal1             tmpscal2 = HEFFpreTH(I,J) / tmpscal1
900  cif        regularize heffActual with SEAICE_hice_reg (add lower bound)  Cif        regularize heffActual with SEAICE_hice_reg (add lower bound)
901             heffActual(I,J) = SQRT(tmpscal2 * tmpscal2 + hice_reg_sq)             heffActual(I,J) = SQRT(tmpscal2 * tmpscal2 + hice_reg_sq)
902  cif        hsnowActual calculated with the regularized AREA  Cif        hsnowActual calculated with the regularized AREA
903             hsnowActual(I,J) = HSNWpreTH(I,J) / tmpscal1             hsnowActual(I,J) = HSNWpreTH(I,J) / tmpscal1
904  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
905  cif        regularize the inverse of heffActual by hice_reg  Cif        regularize the inverse of heffActual by hice_reg
906             recip_heffActual(I,J)  = AREApreTH(I,J) /             recip_heffActual(I,J)  = AREApreTH(I,J) /
907       &                 sqrt(HEFFpreTH(I,J)*HEFFpreTH(I,J) + hice_reg_sq)       &                 sqrt(HEFFpreTH(I,J)*HEFFpreTH(I,J) + hice_reg_sq)
908  cif       Do not regularize when HEFFpreTH = 0  Cif       Do not regularize when HEFFpreTH = 0
909            ELSE            ELSE
910              heffActual(I,J) = ZERO              heffActual(I,J) = ZERO
911              hsnowActual(I,J) = ZERO              hsnowActual(I,J) = ZERO
# Line 921  C    AND SNOW THICKNESS Line 933  C    AND SNOW THICKNESS
933  #endif  #endif
934          DO J=1,sNy          DO J=1,sNy
935           DO I=1,sNx           DO I=1,sNx
936  c        The latent heat flux over the sea ice which  C        The latent heat flux over the sea ice which
937  c        will sublimate all of the snow and ice over one time  C        will sublimate all of the snow and ice over one time
938  c        step (W/m^2)  C        step (W/m^2)
939  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
940            IF (HEFFITDpreTH(I,J,IT) .GT. ZERO) THEN            IF (HEFFITDpreTH(I,J,IT) .GT. ZERO) THEN
941              latentHeatFluxMaxMult(I,J,IT) = lhSublim*recip_deltaTtherm *              latentHeatFluxMaxMult(I,J,IT) = lhSublim*recip_deltaTtherm *
# Line 981  cCADJ STORE TmixLoc = comlev1_bibj, key Line 993  cCADJ STORE TmixLoc = comlev1_bibj, key
993  C determine available heat due to the atmosphere -- for ice covered water  C determine available heat due to the atmosphere -- for ice covered water
994  C =======================================================================  C =======================================================================
995    
996  #ifdef ALLOW_ATM_WIND          IF (useRelativeWind.AND.useAtmWind) THEN
         IF (useRelativeWind) THEN  
997  C     Compute relative wind speed over sea ice.  C     Compute relative wind speed over sea ice.
998           DO J=1,sNy           DO J=1,sNy
999            DO I=1,sNx            DO I=1,sNx
# Line 1003  C     Compute relative wind speed over s Line 1014  C     Compute relative wind speed over s
1014            ENDDO            ENDDO
1015           ENDDO           ENDDO
1016          ENDIF          ENDIF
 #endif /* ALLOW_ATM_WIND */  
1017    
1018  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
1019  CADJ STORE tice(:,:,bi,bj)  CADJ STORE tice(:,:,bi,bj)
# Line 1022  C--   Start loop over multi-categories Line 1032  C--   Start loop over multi-categories
1032  CToM  SEAICE_multDim = nITD (see SEAICE_SIZE.h and seaice_readparms.F)  CToM  SEAICE_multDim = nITD (see SEAICE_SIZE.h and seaice_readparms.F)
1033  #endif  #endif
1034          DO IT=1,SEAICE_multDim          DO IT=1,SEAICE_multDim
1035  c        homogeneous distribution between 0 and 2 x heffActual  C        homogeneous distribution between 0 and 2 x heffActual
1036  #ifndef SEAICE_ITD  #ifndef SEAICE_ITD
1037           pFac = (2.0 _d 0*real(IT)-1.0 _d 0)*recip_multDim           pFac = (2.0 _d 0*IT - 1.0 _d 0)*recip_multDim
1038             pFacSnow = 1. _d 0
1039             IF ( SEAICE_useMultDimSnow ) pFacSnow=pFac
1040  #endif  #endif
1041           DO J=1,sNy           DO J=1,sNy
1042            DO I=1,sNx            DO I=1,sNx
# Line 1032  c        homogeneous distribution betwee Line 1044  c        homogeneous distribution betwee
1044  CToM for SEAICE_ITD heffActualMult and latentHeatFluxMaxMult are calculated above  CToM for SEAICE_ITD heffActualMult and latentHeatFluxMaxMult are calculated above
1045  C    (instead of heffActual and latentHeatFluxMax)  C    (instead of heffActual and latentHeatFluxMax)
1046             heffActualMult(I,J,IT)= heffActual(I,J)*pFac             heffActualMult(I,J,IT)= heffActual(I,J)*pFac
1047               hsnowActualMult(I,J,IT)=hsnowActual(I,J)*pFacSnow
1048  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
1049             latentHeatFluxMaxMult(I,J,IT) = latentHeatFluxMax(I,J)*pFac             latentHeatFluxMaxMult(I,J,IT) = latentHeatFluxMax(I,J)*pFac
1050  #endif  #endif
# Line 1046  C    (instead of heffActual and latentHe Line 1059  C    (instead of heffActual and latentHe
1059    
1060  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
1061  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte
1062    CADJ STORE hsnowActualMult= comlev1_bibj, key = iicekey, byte = isbyte
1063  CADJ STORE ticeInMult     = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE ticeInMult     = comlev1_bibj, key = iicekey, byte = isbyte
1064  # ifdef SEAICE_CAP_SUBLIM  # ifdef SEAICE_CAP_SUBLIM
1065  CADJ STORE latentHeatFluxMaxMult  CADJ STORE latentHeatFluxMaxMult
# Line 1061  CADJ &     comlev1_bibj, key = iicekey, Line 1075  CADJ &     comlev1_bibj, key = iicekey,
1075    
1076          DO IT=1,SEAICE_multDim          DO IT=1,SEAICE_multDim
1077           CALL SEAICE_SOLVE4TEMP(           CALL SEAICE_SOLVE4TEMP(
 #ifdef SEAICE_ITD  
1078       I        UG, heffActualMult(1,1,IT), hsnowActualMult(1,1,IT),       I        UG, heffActualMult(1,1,IT), hsnowActualMult(1,1,IT),
 #else  
      I        UG, heffActualMult(1,1,IT), hsnowActual,  
 #endif  
1079  #ifdef SEAICE_CAP_SUBLIM  #ifdef SEAICE_CAP_SUBLIM
1080       I        latentHeatFluxMaxMult(1,1,IT),       I        latentHeatFluxMaxMult(1,1,IT),
1081  #endif  #endif
1082       U        ticeInMult(1,1,IT), ticeOutMult(1,1,IT),       U        ticeInMult(1,1,IT), ticeOutMult(1,1,IT),
1083       O        a_QbyATMmult_cover(1,1,IT), a_QSWbyATMmult_cover(1,1,IT),       O        a_QbyATMmult_cover(1,1,IT),
1084         O        a_QSWbyATMmult_cover(1,1,IT),
1085       O        a_FWbySublimMult(1,1,IT),       O        a_FWbySublimMult(1,1,IT),
1086       I        bi, bj, myTime, myIter, myThid )       I        bi, bj, myTime, myIter, myThid )
1087          ENDDO          ENDDO
1088    
1089  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
1090  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE heffActualMult = comlev1_bibj, key = iicekey, byte = isbyte
1091    CADJ STORE hsnowActualMult= comlev1_bibj, key = iicekey, byte = isbyte
1092  CADJ STORE ticeOutMult    = comlev1_bibj, key = iicekey, byte = isbyte  CADJ STORE ticeOutMult    = comlev1_bibj, key = iicekey, byte = isbyte
1093  # ifdef SEAICE_CAP_SUBLIM  # ifdef SEAICE_CAP_SUBLIM
1094  CADJ STORE latentHeatFluxMaxMult  CADJ STORE latentHeatFluxMaxMult
# Line 1134  C     (fluxes are per unit (ice surface) Line 1146  C     (fluxes are per unit (ice surface)
1146  # ifdef ALLOW_DIAGNOSTICS  # ifdef ALLOW_DIAGNOSTICS
1147          DO J=1,sNy          DO J=1,sNy
1148           DO I=1,sNx           DO I=1,sNx
1149  c          The actual latent heat flux realized by SOLVE4TEMP  C          The actual latent heat flux realized by SOLVE4TEMP
1150             DIAGarrayA(I,J) = a_FWbySublim(I,J) * lhSublim             DIAGarrayA(I,J) = a_FWbySublim(I,J) * lhSublim
1151           ENDDO           ENDDO
1152          ENDDO          ENDDO
1153  cif     The actual vs. maximum latent heat flux  Cif     The actual vs. maximum latent heat flux
1154          IF ( useDiagnostics ) THEN          IF ( useDiagnostics ) THEN
1155            CALL DIAGNOSTICS_FILL(DIAGarrayA,            CALL DIAGNOSTICS_FILL(DIAGarrayA,
1156       &     'SIactLHF',0,1,3,bi,bj,myThid)       &     'SIactLHF',0,1,3,bi,bj,myThid)
# Line 1206  C and initialize r_QbyATM_cover/r_QbyATM Line 1218  C and initialize r_QbyATM_cover/r_QbyATM
1218  C     Convert fresh water flux by sublimation to 'effective' ice meters.  C     Convert fresh water flux by sublimation to 'effective' ice meters.
1219  C     Negative sublimation is resublimation and will be added as snow.  C     Negative sublimation is resublimation and will be added as snow.
1220  #ifdef SEAICE_DISABLE_SUBLIM  #ifdef SEAICE_DISABLE_SUBLIM
1221  cgf just for those who may need to omit this term to reproduce old results  Cgf just for those who may need to omit this term to reproduce old results
1222            a_FWbySublim(I,J) = ZERO            a_FWbySublim(I,J) = ZERO
1223  #endif  #endif /* SEAICE_DISABLE_SUBLIM */
1224            a_FWbySublim(I,J) = SEAICE_deltaTtherm*recip_rhoIce            a_FWbySublim(I,J) = SEAICE_deltaTtherm*recip_rhoIce
1225       &           * a_FWbySublim(I,J)*AREApreTH(I,J)       &           * a_FWbySublim(I,J)*AREApreTH(I,J)
1226            r_FWbySublim(I,J)=a_FWbySublim(I,J)            r_FWbySublim(I,J)=a_FWbySublim(I,J)
# Line 1266  CADJ &                       key = iicek Line 1278  CADJ &                       key = iicek
1278    
1279          DO J=1,sNy          DO J=1,sNy
1280           DO I=1,sNx           DO I=1,sNx
1281  c         FREEZING TEMP. OF SEA WATER (deg C)  C         FREEZING TEMP. OF SEA WATER (deg C)
1282            tempFrz = SEAICE_tempFrz0 +            tempFrz = SEAICE_tempFrz0 +
1283       &              SEAICE_dTempFrz_dS *salt(I,J,kSurface,bi,bj)       &              SEAICE_dTempFrz_dS *salt(I,J,kSurface,bi,bj)
1284  c efficiency of turbulent fluxes : dependency to sign of THETA-TBC  C efficiency of turbulent fluxes : dependency to sign of THETA-TBC
1285            IF ( theta(I,J,kSurface,bi,bj) .GE. tempFrz ) THEN            IF ( theta(I,J,kSurface,bi,bj) .GE. tempFrz ) THEN
1286             tmpscal1 = SEAICE_mcPheePiston             tmpscal1 = SEAICE_mcPheePiston
1287            ELSE            ELSE
1288             tmpscal1 =SEAICE_frazilFrac*drF(kSurface)/SEAICE_deltaTtherm             tmpscal1 =SEAICE_frazilFrac*drF(kSurface)/SEAICE_deltaTtherm
1289            ENDIF            ENDIF
1290  c efficiency of turbulent fluxes : dependency to AREA (McPhee cases)  C efficiency of turbulent fluxes : dependency to AREA (McPhee cases)
1291            IF ( (AREApreTH(I,J) .GT. 0. _d 0).AND.            IF ( (AREApreTH(I,J) .GT. 0. _d 0).AND.
1292       &         (.NOT.SEAICE_mcPheeStepFunc) ) THEN       &         (.NOT.SEAICE_mcPheeStepFunc) ) THEN
1293             MixedLayerTurbulenceFactor = ONE -             MixedLayerTurbulenceFactor = ONE -
# Line 1286  c efficiency of turbulent fluxes : depen Line 1298  c efficiency of turbulent fluxes : depen
1298            ELSE            ELSE
1299             MixedLayerTurbulenceFactor = ONE             MixedLayerTurbulenceFactor = ONE
1300            ENDIF            ENDIF
1301  c maximum turbulent flux, in ice meters  C maximum turbulent flux, in ice meters
1302            tmpscal2= - (HeatCapacity_Cp*rhoConst * recip_QI)            tmpscal2= - (HeatCapacity_Cp*rhoConst * recip_QI)
1303       &         * (theta(I,J,kSurface,bi,bj)-tempFrz)       &         * (theta(I,J,kSurface,bi,bj)-tempFrz)
1304       &         * SEAICE_deltaTtherm * maskC(i,j,kSurface,bi,bj)       &         * SEAICE_deltaTtherm * maskC(i,j,kSurface,bi,bj)
1305  c available turbulent flux  C available turbulent flux
1306            a_QbyOCN(i,j) =            a_QbyOCN(i,j) =
1307       &         tmpscal1 * tmpscal2 * MixedLayerTurbulenceFactor       &         tmpscal1 * tmpscal2 * MixedLayerTurbulenceFactor
1308            r_QbyOCN(i,j) = a_QbyOCN(i,j)            r_QbyOCN(i,j) = a_QbyOCN(i,j)
# Line 1301  c available turbulent flux Line 1313  c available turbulent flux
1313          CALL ZERO_ADJ_1D( sNx*sNy, r_QbyOCN, myThid)          CALL ZERO_ADJ_1D( sNx*sNy, r_QbyOCN, myThid)
1314  #endif  #endif
1315    
   
1316  C ===================================================================  C ===================================================================
1317  C =========PART 3: determine effective thicknesses increments========  C =========PART 3: determine effective thicknesses increments========
1318  C ===================================================================  C ===================================================================
# Line 1578  c         Limit ice growth by potential Line 1589  c         Limit ice growth by potential
1589            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J))            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J))
1590  #else  #else
1591            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J)+            tmpscal2 = MAX(-HEFF(I,J,bi,bj),r_QbyATM_cover(I,J)+
1592  c         Limit ice growth by potential melt by ocean  C         Limit ice growth by potential melt by ocean
1593       &        AREApreTH(I,J) * r_QbyOCN(I,J))       &        AREApreTH(I,J) * r_QbyOCN(I,J))
1594  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
1595    
# Line 1590  c         Limit ice growth by potential Line 1601  c         Limit ice growth by potential
1601  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
1602            SItrHEFF(I,J,bi,bj,3)=HEFF(I,J,bi,bj)            SItrHEFF(I,J,bi,bj,3)=HEFF(I,J,bi,bj)
1603  #endif  #endif
1604           ENDDO           ENDDO
1605          ENDDO          ENDDO
1606  #endif /* SEAICE_ITD */  #endif /* SEAICE_ITD */
1607  #ifdef SEAICE_DEBUG  #ifdef SEAICE_DEBUG
1608  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
# Line 1613  c ToM<<< debug seaice_growth Line 1624  c ToM<<< debug seaice_growth
1624  c ToM>>>  c ToM>>>
1625  #endif  #endif
1626    
1627  C attribute precip to fresh water or snow stock,  C add snow precipitation to HSNOW.
 C depending on atmospheric conditions.  
1628  C =================================================  C =================================================
1629  #ifdef ALLOW_ATM_TEMP  #ifdef ALLOW_ATM_TEMP
1630  #ifdef ALLOW_AUTODIFF_TAMC  # ifdef ALLOW_AUTODIFF_TAMC
1631  CADJ STORE a_QbyATM_cover = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE a_QbyATM_cover = comlev1_bibj,key=iicekey,byte=isbyte
1632  CADJ STORE PRECIP(:,:,bi,bj) = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE PRECIP(:,:,bi,bj) = comlev1_bibj,key=iicekey,byte=isbyte
1633  CADJ STORE AREApreTH = comlev1_bibj,key=iicekey,byte=isbyte  CADJ STORE AREApreTH = comlev1_bibj,key=iicekey,byte=isbyte
1634  #endif /* ALLOW_AUTODIFF_TAMC */  # endif /* ALLOW_AUTODIFF_TAMC */
1635          DO J=1,sNy          IF ( snowPrecipFile .NE. ' ' ) THEN
1636           DO I=1,sNx  C add snowPrecip to HSNOW
1637             DO J=1,sNy
1638              DO I=1,sNx
1639               d_HSNWbyRAIN(I,J) = convertPRECIP2HI * ICE2SNOW *
1640         &          snowPrecip(i,j,bi,bj) * AREApreTH(I,J)
1641               d_HFRWbyRAIN(I,J) = -convertPRECIP2HI *
1642         &          ( PRECIP(I,J,bi,bj) - snowPrecip(I,J,bi,bj) ) *
1643         &          AREApreTH(I,J)
1644               HSNOW(I,J,bi,bj) = HSNOW(I,J,bi,bj) + d_HSNWbyRAIN(I,J)
1645              ENDDO
1646             ENDDO
1647            ELSE
1648    C attribute precip to fresh water or snow stock,
1649    C depending on atmospheric conditions.
1650             DO J=1,sNy
1651              DO I=1,sNx
1652  C possible alternatives to the a_QbyATM_cover criterium  C possible alternatives to the a_QbyATM_cover criterium
1653  c          IF (TICE(I,J,bi,bj) .LT. TMIX) THEN  c          IF (TICE(I,J,bi,bj) .LT. TMIX) THEN
1654  c          IF (atemp(I,J,bi,bj) .LT. celsius2K) THEN  c          IF (atemp(I,J,bi,bj) .LT. celsius2K) THEN
1655            IF ( a_QbyATM_cover(I,J).GE. 0. _d 0 ) THEN             IF ( a_QbyATM_cover(I,J).GE. 0. _d 0 ) THEN
1656  C           add precip as snow  C           add precip as snow
1657              d_HFRWbyRAIN(I,J)=0. _d 0              d_HFRWbyRAIN(I,J)=0. _d 0
1658              d_HSNWbyRAIN(I,J)=convertPRECIP2HI*ICE2SNOW*              d_HSNWbyRAIN(I,J)=convertPRECIP2HI*ICE2SNOW*
1659       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)
1660            ELSE             ELSE
1661  C           add precip to the fresh water bucket  C           add precip to the fresh water bucket
1662              d_HFRWbyRAIN(I,J)=-convertPRECIP2HI*              d_HFRWbyRAIN(I,J)=-convertPRECIP2HI*
1663       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)       &            PRECIP(I,J,bi,bj)*AREApreTH(I,J)
1664              d_HSNWbyRAIN(I,J)=0. _d 0              d_HSNWbyRAIN(I,J)=0. _d 0
1665            ENDIF             ENDIF
1666           ENDDO           ENDDO
1667          ENDDO          ENDDO
1668  #ifdef SEAICE_ITD  #ifdef SEAICE_ITD
# Line 1659  C           add precip to the fresh wate Line 1684  C           add precip to the fresh wate
1684  Cgf note: this does not affect air-sea heat flux,  Cgf note: this does not affect air-sea heat flux,
1685  Cgf since the implied air heat gain to turn  Cgf since the implied air heat gain to turn
1686  Cgf rain to snow is not a surface process.  Cgf rain to snow is not a surface process.
1687    C end of IF statement snowPrecipFile:
1688            ENDIF
1689  #endif /* ALLOW_ATM_TEMP */  #endif /* ALLOW_ATM_TEMP */
1690  #ifdef SEAICE_DEBUG  #ifdef SEAICE_DEBUG
1691  c ToM<<< debug seaice_growth  c ToM<<< debug seaice_growth
# Line 1758  CADJ STORE a_QSWbyATM_open = comlev1_bib Line 1785  CADJ STORE a_QSWbyATM_open = comlev1_bib
1785    
1786          DO J=1,sNy          DO J=1,sNy
1787           DO I=1,sNx           DO I=1,sNx
1788  c           Initial ice growth is triggered by open water  C           Initial ice growth is triggered by open water
1789  c           heat flux overcoming potential melt by ocean  C           heat flux overcoming potential melt by ocean
1790              tmpscal1=r_QbyATM_open(I,J)+r_QbyOCN(i,j) *              tmpscal1=r_QbyATM_open(I,J)+r_QbyOCN(i,j) *
1791       &            (1.0 _d 0 - AREApreTH(I,J))       &            (1.0 _d 0 - AREApreTH(I,J))
1792  c           Penetrative shortwave flux beyond first layer  C           Penetrative shortwave flux beyond first layer
1793  c           that is therefore not available to ice growth/melt  C           that is therefore not available to ice growth/melt
1794              tmpscal2=SWFracB * a_QSWbyATM_open(I,J)              tmpscal2=SWFracB * a_QSWbyATM_open(I,J)
1795  C           impose -HEFF as the maxmum melting if SEAICE_doOpenWaterMelt  C           impose -HEFF as the maxmum melting if SEAICE_doOpenWaterMelt
1796  C           or 0. otherwise (no melting if not SEAICE_doOpenWaterMelt)  C           or 0. otherwise (no melting if not SEAICE_doOpenWaterMelt)
# Line 1819  c needs to be here to allow use also wit Line 1846  c needs to be here to allow use also wit
1846  #else  #else
1847          DO J=1,sNy          DO J=1,sNy
1848           DO I=1,sNx           DO I=1,sNx
1849  c needs to be here to allow use also with LEGACY branch  C needs to be here to allow use also with LEGACY branch
1850            SItrHEFF(I,J,bi,bj,4)=HEFF(I,J,bi,bj)            SItrHEFF(I,J,bi,bj,4)=HEFF(I,J,bi,bj)
1851           ENDDO           ENDDO
1852          ENDDO          ENDDO
# Line 1885  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 1912  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
1912             HEFF(I,J,bi,bj) = HEFF(I,J,bi,bj)+d_HEFFbyFLOODING(I,J)             HEFF(I,J,bi,bj) = HEFF(I,J,bi,bj)+d_HEFFbyFLOODING(I,J)
1913             HSNOW(I,J,bi,bj) = HSNOW(I,J,bi,bj)-             HSNOW(I,J,bi,bj) = HSNOW(I,J,bi,bj)-
1914       &                           d_HEFFbyFLOODING(I,J)*ICE2SNOW       &                           d_HEFFbyFLOODING(I,J)*ICE2SNOW
1915            ENDDO            ENDDO
1916           ENDDO           ENDDO
1917  #endif  #endif
1918          ENDIF          ENDIF
1919  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
# Line 2088  CADJ &                       key = iicek Line 2115  CADJ &                       key = iicek
2115            tmpscal1 = d_HEFFbyNEG(I,J) + d_HEFFbyOCNonICE(I,J) +            tmpscal1 = d_HEFFbyNEG(I,J) + d_HEFFbyOCNonICE(I,J) +
2116       &               d_HEFFbyATMonOCN(I,J) + d_HEFFbyFLOODING(I,J)       &               d_HEFFbyATMonOCN(I,J) + d_HEFFbyFLOODING(I,J)
2117       &             + d_HEFFbySublim(I,J)       &             + d_HEFFbySublim(I,J)
2118  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
2119                     + d_HEFFbyRLX(I,J)       &             + d_HEFFbyRLX(I,J)
2120  #endif  #endif
2121            tmpscal2 = tmpscal1 * SEAICE_salt0 * HEFFM(I,J,bi,bj)            tmpscal2 = tmpscal1 * SEAICE_salt0 * HEFFM(I,J,bi,bj)
2122       &            * recip_deltaTtherm * SEAICE_rhoIce       &            * recip_deltaTtherm * SEAICE_rhoIce
# Line 2183  C set HSALT = 0 if HEFF = 0 and compute Line 2210  C set HSALT = 0 if HEFF = 0 and compute
2210          ENDDO          ENDDO
2211  #endif /* SEAICE_VARIABLE_SALINITY */  #endif /* SEAICE_VARIABLE_SALINITY */
2212    
   
2213  C =======================================================================  C =======================================================================
2214  C ==LEGACY PART 6 (LEGACY) treat pathological cases, then do flooding ===  C ==LEGACY PART 6 (LEGACY) treat pathological cases, then do flooding ===
2215  C =======================================================================  C =======================================================================
# Line 2266  C ================================= Line 2292  C =================================
2292  #ifdef ALLOW_SITRACER  #ifdef ALLOW_SITRACER
2293          DO J=1,sNy          DO J=1,sNy
2294           DO I=1,sNx           DO I=1,sNx
2295  c needs to be here to allow use also with LEGACY branch  C needs to be here to allow use also with LEGACY branch
2296            SItrHEFF(I,J,bi,bj,5)=HEFF(I,J,bi,bj)            SItrHEFF(I,J,bi,bj,5)=HEFF(I,J,bi,bj)
2297           ENDDO           ENDDO
2298          ENDDO          ENDDO
# Line 2329  C in principle a_QSWbyATM_cover should a Line 2355  C in principle a_QSWbyATM_cover should a
2355  C for backward compatibility it is left out of the LEGACY branch  C for backward compatibility it is left out of the LEGACY branch
2356       &         +   a_QSWbyATM_cover(I,J)       &         +   a_QSWbyATM_cover(I,J)
2357  #endif /* SEAICE_GROWTH_LEGACY */  #endif /* SEAICE_GROWTH_LEGACY */
2358       &         - ( d_HEFFbyOCNonICE(I,J) +       &         - ( d_HEFFbyOCNonICE(I,J)
2359       &             d_HSNWbyOCNonSNW(I,J)*SNOW2ICE +       &           + d_HSNWbyOCNonSNW(I,J)*SNOW2ICE
2360       &             d_HEFFbyNEG(I,J) +       &           + d_HEFFbyNEG(I,J)
2361  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
2362       &             d_HEFFbyRLX(I,J) +       &           + d_HEFFbyRLX(I,J)
2363  #endif  #endif
2364       &             d_HSNWbyNEG(I,J)*SNOW2ICE )       &           + d_HSNWbyNEG(I,J)*SNOW2ICE
2365       &         * maskC(I,J,kSurface,bi,bj)       &           - convertPRECIP2HI *
2366         &             snowPrecip(i,j,bi,bj) * (ONE-AREApreTH(I,J))
2367         &           ) * maskC(I,J,kSurface,bi,bj)
2368             ENDDO
2369            ENDDO
2370            DO J=1,sNy
2371             DO I=1,sNx
2372            QSW(I,J,bi,bj)  = a_QSWbyATM_cover(I,J) + a_QSWbyATM_open(I,J)            QSW(I,J,bi,bj)  = a_QSWbyATM_cover(I,J) + a_QSWbyATM_open(I,J)
2373           ENDDO           ENDDO
2374          ENDDO          ENDDO
# Line 2364  CADJ STORE d_HSNWbyATMonSNW = comlev1_bi Line 2396  CADJ STORE d_HSNWbyATMonSNW = comlev1_bi
2396  CADJ STORE theta(:,:,kSurface,bi,bj) = comlev1_bibj,  CADJ STORE theta(:,:,kSurface,bi,bj) = comlev1_bibj,
2397  CADJ &                       key = iicekey, byte = isbyte  CADJ &                       key = iicekey, byte = isbyte
2398  # endif /* ALLOW_AUTODIFF_TAMC */  # endif /* ALLOW_AUTODIFF_TAMC */
2399        IF ( SEAICEheatConsFix ) THEN  cgf Unlike for evap and precip, the temperature of gained/lost
2400  c Unlike for evap and precip, the temperature of gained/lost  C ocean liquid water due to melt/freeze of solid water cannot be chosen
2401  c ocean liquid water due to melt/freeze of solid water cannot be chosen  C arbitrarily to be e.g. the ocean SST. Indeed the present seaice model
2402  c to be e.g. the ocean SST. It must be done at 0degC. The fix below anticipates  C implies a constant ice temperature of 0degC. If melt/freeze water is exchanged
2403  c on external_forcing_surf.F and applies the correction to QNET.  C at a different temperature, it leads to a loss of conservation in the
2404        IF ((convertFW2Salt.EQ.-1.).OR.(temp_EvPrRn.EQ.UNSET_RL)) THEN  C ocean+ice system. While this is mostly a serious issue in the
2405  c I leave alone the exotic case when onvertFW2Salt.NE.-1 and temp_EvPrRn.NE.UNSET_RL and  C real fresh water + non linear free surface framework, a mismatch
2406  c the small error of the synchronous time stepping case (see external_forcing_surf.F).  C between ice and ocean boundary condition can result in all cases.
2407    C Below we therefore anticipate on external_forcing_surf.F
2408    C to diagnoze and/or apply the correction to QNET.
2409          DO J=1,sNy          DO J=1,sNy
2410           DO I=1,sNx           DO I=1,sNx
2411  #ifdef ALLOW_DIAGNOSTICS  C ocean water going to ice/snow, in precip units
2412  c store unaltered QNET for diagnostic purposes             tmpscal3=rhoConstFresh*maskC(I,J,kSurface,bi,bj)*(
            DIAGarrayA(I,J)=QNET(I,J,bi,bj)  
 #endif  
 c compute the ocean water going to ice/snow, in precip units  
            tmpscal3=rhoConstFresh*maskC(I,J,kSurface,bi,bj)*  
2413       &       ( d_HSNWbyATMonSNW(I,J)*SNOW2ICE       &       ( d_HSNWbyATMonSNW(I,J)*SNOW2ICE
2414       &       + d_HSNWbyOCNonSNW(I,J)*SNOW2ICE       &       + d_HSNWbyOCNonSNW(I,J)*SNOW2ICE
2415       &       + d_HEFFbyOCNonICE(I,J) + d_HEFFbyATMonOCN(I,J)       &       + d_HEFFbyOCNonICE(I,J) + d_HEFFbyATMonOCN(I,J)
2416       &       + d_HEFFbyNEG(I,J) + d_HSNWbyNEG(I,J)*SNOW2ICE )       &       + d_HEFFbyNEG(I,J) + d_HSNWbyNEG(I,J)*SNOW2ICE )
2417       &       * convertHI2PRECIP       &       * convertHI2PRECIP
2418  c factor in the heat content that external_forcing_surf.F       &       - snowPrecip(i,j,bi,bj) * (ONE-AREApreTH(I,J)) )
2419  c will associate with EMPMR, and remove it from QNET, so that  C factor in the heat content as done in external_forcing_surf.F
2420  c melt/freez water is in effect consistently gained/lost at 0degC        IF ( (temp_EvPrRn.NE.UNSET_RL).AND.useRealFreshWaterFlux
2421             IF (temp_EvPrRn.NE.UNSET_RL) THEN       &     .AND.(nonlinFreeSurf.NE.0) ) THEN
2422               QNET(I,J,bi,bj)=QNET(I,J,bi,bj) - tmpscal3*               tmpscal1 = - tmpscal3*
2423       &         HeatCapacity_Cp * temp_EvPrRn       &         HeatCapacity_Cp * temp_EvPrRn
2424             ELSE        ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL).AND.useRealFreshWaterFlux
2425               QNET(I,J,bi,bj)=QNET(I,J,bi,bj) - tmpscal3*       &         .AND.(nonlinFreeSurf.NE.0) ) THEN
2426                 tmpscal1 = - tmpscal3*
2427       &         HeatCapacity_Cp * theta(I,J,kSurface,bi,bj)       &         HeatCapacity_Cp * theta(I,J,kSurface,bi,bj)
2428             ENDIF        ELSEIF ( (temp_EvPrRn.NE.UNSET_RL) ) THEN
2429               tmpscal1 = - tmpscal3*HeatCapacity_Cp*
2430         &       ( temp_EvPrRn - theta(I,J,kSurface,bi,bj) )
2431          ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL) ) THEN
2432               tmpscal1 = ZERO
2433          ENDIF
2434  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
2435  c back out the eventual TFLUX adjustement and fill diag  C in all cases, diagnoze the boundary condition mismatch to SIaaflux
2436             DIAGarrayA(I,J)=QNET(I,J,bi,bj)-DIAGarrayA(I,J)             DIAGarrayA(I,J)=tmpscal1
2437  #endif  #endif
2438    C remove the mismatch when real fresh water is exchanged (at 0degC here)
2439          IF ( useRealFreshWaterFlux.AND.(nonlinFreeSurf.GT.0).AND.
2440         &   SEAICEheatConsFix ) QNET(I,J,bi,bj)=QNET(I,J,bi,bj)+tmpscal1
2441           ENDDO           ENDDO
2442          ENDDO          ENDDO
       ENDIF  
2443  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
2444          CALL DIAGNOSTICS_FILL(DIAGarrayA,          CALL DIAGNOSTICS_FILL(DIAGarrayA,
2445       &      'SIaaflux',0,1,3,bi,bj,myThid)       &      'SIaaflux',0,1,3,bi,bj,myThid)
2446  #endif  #endif
       ENDIF  
2447  #endif /* ndef SEAICE_DISABLE_HEATCONSFIX */  #endif /* ndef SEAICE_DISABLE_HEATCONSFIX */
2448    
2449    C compute the net heat flux, incl. adv. by water, entering ocean+ice
2450    C ===================================================================
2451             DO J=1,sNy
2452              DO I=1,sNx
2453    cgf 1) SIatmQnt (analogous to qnet; excl. adv. by water exch.)
2454    CML If I consider the atmosphere above the ice, the surface flux
2455    CML which is relevant for the air temperature dT/dt Eq
2456    CML accounts for sensible and radiation (with different treatment
2457    CML according to wave-length) fluxes but not for "latent heat flux",
2458    CML since it does not contribute to heating the air.
2459    CML So this diagnostic is only good for heat budget calculations within
2460    CML the ice-ocean system.
2461               SIatmQnt(I,J,bi,bj) =
2462         &            maskC(I,J,kSurface,bi,bj)*convertHI2Q*(
2463    #ifndef SEAICE_GROWTH_LEGACY
2464         &            a_QSWbyATM_cover(I,J) +
2465    #endif /* SEAICE_GROWTH_LEGACY */
2466         &            a_QbyATM_cover(I,J) + a_QbyATM_open(I,J) )
2467    cgf 2) SItflux (analogous to tflux; includes advection by water
2468    C             exchanged between atmosphere and ocean+ice)
2469    C solid water going to atm, in precip units
2470               tmpscal1 = rhoConstFresh*maskC(I,J,kSurface,bi,bj)
2471         &       * convertHI2PRECIP * ( - d_HSNWbyRAIN(I,J)*SNOW2ICE
2472         &       + a_FWbySublim(I,J) - r_FWbySublim(I,J) )
2473    C liquid water going to atm, in precip units
2474               tmpscal2=rhoConstFresh*maskC(I,J,kSurface,bi,bj)*
2475         &       ( ( EVAP(I,J,bi,bj)-PRECIP(I,J,bi,bj) )
2476         &         * ( ONE - AREApreTH(I,J) )
2477    #ifdef ALLOW_RUNOFF
2478         &         - RUNOFF(I,J,bi,bj)
2479    #endif /* ALLOW_RUNOFF */
2480         &         + ( d_HFRWbyRAIN(I,J) + r_FWbySublim(I,J) )
2481         &         *convertHI2PRECIP )
2482    C In real fresh water flux + nonlinFS, we factor in the advected specific
2483    C energy (referenced to 0 for 0deC liquid water). In virtual salt flux or
2484    C linFS, rain/evap get a special treatment (see external_forcing_surf.F).
2485               tmpscal1= - tmpscal1*
2486         &       ( -SEAICE_lhFusion + HeatCapacity_Cp * ZERO )
2487          IF ( (temp_EvPrRn.NE.UNSET_RL).AND.useRealFreshWaterFlux
2488         &     .AND.(nonlinFreeSurf.NE.0) ) THEN
2489               tmpscal2= - tmpscal2*
2490         &       ( ZERO + HeatCapacity_Cp * temp_EvPrRn )
2491          ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL).AND.useRealFreshWaterFlux
2492         &        .AND.(nonlinFreeSurf.NE.0) ) THEN
2493               tmpscal2= - tmpscal2*
2494         &       ( ZERO + HeatCapacity_Cp * theta(I,J,kSurface,bi,bj) )
2495          ELSEIF ( (temp_EvPrRn.NE.UNSET_RL) ) THEN
2496               tmpscal2= - tmpscal2*HeatCapacity_Cp*
2497         &       ( temp_EvPrRn - theta(I,J,kSurface,bi,bj) )
2498          ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL) ) THEN
2499               tmpscal2= ZERO
2500          ENDIF
2501               SItflux(I,J,bi,bj)=
2502         &            SIatmQnt(I,J,bi,bj)-tmpscal1-tmpscal2    
2503              ENDDO
2504             ENDDO
2505    
2506  C compute net fresh water flux leaving/entering  C compute net fresh water flux leaving/entering
2507  C the ocean, accounting for fresh/salt water stocks.  C the ocean, accounting for fresh/salt water stocks.
2508  C ==================================================  C ==================================================
# Line 2422  C ====================================== Line 2516  C ======================================
2516       &             +d_HEFFbyOCNonICE(I,J)       &             +d_HEFFbyOCNonICE(I,J)
2517       &             +d_HEFFbyATMonOCN(I,J)       &             +d_HEFFbyATMonOCN(I,J)
2518       &             +d_HEFFbyNEG(I,J)       &             +d_HEFFbyNEG(I,J)
2519  #ifdef SEAICE_ALLOW_AREA_RELAXATION  #ifdef EXF_ALLOW_SEAICE_RELAX
2520       &             +d_HEFFbyRLX(I,J)       &             +d_HEFFbyRLX(I,J)
2521  #endif  #endif
2522       &             +d_HSNWbyNEG(I,J)*SNOW2ICE       &             +d_HSNWbyNEG(I,J)*SNOW2ICE
# Line 2436  C     If r_FWbySublim>0, then it is evap Line 2530  C     If r_FWbySublim>0, then it is evap
2530  #endif /* ALLOW_RUNOFF */  #endif /* ALLOW_RUNOFF */
2531       &         + tmpscal1*convertHI2PRECIP       &         + tmpscal1*convertHI2PRECIP
2532       &         )*rhoConstFresh       &         )*rhoConstFresh
2533    c and the flux leaving/entering the ocean+ice
2534               SIatmFW(I,J,bi,bj) = maskC(I,J,kSurface,bi,bj)*(
2535         &          EVAP(I,J,bi,bj)*( ONE - AREApreTH(I,J) )
2536         &          - PRECIP(I,J,bi,bj)
2537    #ifdef ALLOW_RUNOFF
2538         &          - RUNOFF(I,J,bi,bj)
2539    #endif /* ALLOW_RUNOFF */
2540         &           )*rhoConstFresh
2541         &     + a_FWbySublim(I,J) * SEAICE_rhoIce * recip_deltaTtherm
2542    
2543           ENDDO           ENDDO
2544          ENDDO          ENDDO        
2545    
2546  #ifdef ALLOW_SSH_GLOBMEAN_COST_CONTRIBUTION  #ifdef ALLOW_SSH_GLOBMEAN_COST_CONTRIBUTION
2547  C--  C--
# Line 2508  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi Line 2612  CADJ STORE hsnow(:,:,bi,bj) = comlev1_bi
2612           ENDDO           ENDDO
2613          ENDIF          ENDIF
2614    
2615    #ifdef ALLOW_BALANCE_FLUXES
2616    C Compute tile integrals of heat/fresh water fluxes to/from atm.
2617    C ==============================================================
2618           FWFsiTile(bi,bj) = 0. _d 0
2619           IF ( balanceEmPmR ) THEN
2620            DO j=1,sNy
2621             DO i=1,sNx
2622              FWFsiTile(bi,bj) =
2623         &      FWFsiTile(bi,bj) + SIatmFW(i,j,bi,bj)
2624         &      * rA(i,j,bi,bj) * maskInC(i,j,bi,bj)
2625             ENDDO
2626            ENDDO
2627           ENDIF
2628    c to translate global mean FWF adjustements (see below) we may need :
2629           FWF2HFsiTile(bi,bj) = 0. _d 0      
2630           IF ( balanceEmPmR.AND.(temp_EvPrRn.EQ.UNSET_RL) ) THEN
2631            DO j=1,sNy
2632             DO i=1,sNx
2633              FWF2HFsiTile(bi,bj) = FWF2HFsiTile(bi,bj) +
2634         &      HeatCapacity_Cp * theta(I,J,kSurface,bi,bj)
2635         &      * rA(i,j,bi,bj) * maskInC(i,j,bi,bj)
2636             ENDDO
2637            ENDDO
2638           ENDIF
2639           HFsiTile(bi,bj) = 0. _d 0
2640           IF ( balanceQnet ) THEN
2641            DO j=1,sNy
2642             DO i=1,sNx
2643              HFsiTile(bi,bj) =
2644         &      HFsiTile(bi,bj) + SItflux(i,j,bi,bj)
2645         &      * rA(i,j,bi,bj) * maskInC(i,j,bi,bj)
2646             ENDDO
2647            ENDDO
2648           ENDIF
2649    #endif
2650    
2651  C ===================================================================  C ===================================================================
2652  C ======================PART 8: diagnostics==========================  C ======================PART 8: diagnostics==========================
2653  C ===================================================================  C ===================================================================
# Line 2558  C three that actually need intermediate Line 2698  C three that actually need intermediate
2698  #ifdef ALLOW_ATM_TEMP  #ifdef ALLOW_ATM_TEMP
2699           DO J=1,sNy           DO J=1,sNy
2700            DO I=1,sNx            DO I=1,sNx
 CML If I consider the atmosphere above the ice, the surface flux  
 CML which is relevant for the air temperature dT/dt Eq  
 CML accounts for sensible and radiation (with different treatment  
 CML according to wave-length) fluxes but not for "latent heat flux",  
 CML since it does not contribute to heating the air.  
 CML So this diagnostic is only good for heat budget calculations within  
 CML the ice-ocean system.  
            DIAGarrayA(I,J) = maskC(I,J,kSurface,bi,bj)*convertHI2Q*(  
 #ifndef SEAICE_GROWTH_LEGACY  
      &            a_QSWbyATM_cover(I,J) +  
 #endif /* SEAICE_GROWTH_LEGACY */  
      &            a_QbyATM_cover(I,J) + a_QbyATM_open(I,J) )  
 C  
2701             DIAGarrayB(I,J) = maskC(I,J,kSurface,bi,bj) *             DIAGarrayB(I,J) = maskC(I,J,kSurface,bi,bj) *
2702       &       a_FWbySublim(I,J) * SEAICE_rhoIce * recip_deltaTtherm       &       a_FWbySublim(I,J) * SEAICE_rhoIce * recip_deltaTtherm
 C  
            DIAGarrayC(I,J) = maskC(I,J,kSurface,bi,bj)*(  
      &          PRECIP(I,J,bi,bj)  
      &          - EVAP(I,J,bi,bj)*( ONE - AREApreTH(I,J) )  
 #ifdef ALLOW_RUNOFF  
      &          + RUNOFF(I,J,bi,bj)  
 #endif /* ALLOW_RUNOFF */  
      &           )*rhoConstFresh  
      &     - a_FWbySublim(I,J) * SEAICE_rhoIce * recip_deltaTtherm  
2703            ENDDO            ENDDO
2704           ENDDO           ENDDO
          CALL DIAGNOSTICS_FILL(DIAGarrayA,  
      &      'SIatmQnt',0,1,3,bi,bj,myThid)  
2705           CALL DIAGNOSTICS_FILL(DIAGarrayB,           CALL DIAGNOSTICS_FILL(DIAGarrayB,
2706       &      'SIfwSubl',0,1,3,bi,bj,myThid)       &      'SIfwSubl',0,1,3,bi,bj,myThid)
          CALL DIAGNOSTICS_FILL(DIAGarrayC,  
      &      'SIatmFW ',0,1,3,bi,bj,myThid)  
2707  C  C
2708           DO J=1,sNy           DO J=1,sNy
2709            DO I=1,sNx            DO I=1,sNx
# Line 2597  C the actual Freshwater flux of sublimat Line 2711  C the actual Freshwater flux of sublimat
2711             DIAGarrayA(I,J) = maskC(I,J,kSurface,bi,bj)             DIAGarrayA(I,J) = maskC(I,J,kSurface,bi,bj)
2712       &       * (a_FWbySublim(I,J)-r_FWbySublim(I,J))       &       * (a_FWbySublim(I,J)-r_FWbySublim(I,J))
2713       &       * SEAICE_rhoIce * recip_deltaTtherm       &       * SEAICE_rhoIce * recip_deltaTtherm
2714  c the residual Freshwater flux of sublimated ice  C the residual Freshwater flux of sublimated ice
2715             DIAGarrayC(I,J) = maskC(I,J,kSurface,bi,bj)             DIAGarrayC(I,J) = maskC(I,J,kSurface,bi,bj)
2716       &       * r_FWbySublim(I,J)       &       * r_FWbySublim(I,J)
2717       &       * SEAICE_rhoIce * recip_deltaTtherm       &       * SEAICE_rhoIce * recip_deltaTtherm
# Line 2614  C the latent heat flux Line 2728  C the latent heat flux
2728           CALL DIAGNOSTICS_FILL(DIAGarrayA,'SIacSubl',0,1,3,bi,bj,myThid)           CALL DIAGNOSTICS_FILL(DIAGarrayA,'SIacSubl',0,1,3,bi,bj,myThid)
2729           CALL DIAGNOSTICS_FILL(DIAGarrayC,'SIrsSubl',0,1,3,bi,bj,myThid)           CALL DIAGNOSTICS_FILL(DIAGarrayC,'SIrsSubl',0,1,3,bi,bj,myThid)
2730           CALL DIAGNOSTICS_FILL(DIAGarrayB,'SIhl    ',0,1,3,bi,bj,myThid)           CALL DIAGNOSTICS_FILL(DIAGarrayB,'SIhl    ',0,1,3,bi,bj,myThid)
   
          DO J=1,sNy  
           DO I=1,sNx  
 c compute ice/snow water going to atm, in precip units  
            tmpscal1 = rhoConstFresh*maskC(I,J,kSurface,bi,bj)  
      &       * convertHI2PRECIP * ( - d_HSNWbyRAIN(I,J)*SNOW2ICE  
      &       + a_FWbySublim(I,J) - r_FWbySublim(I,J) )  
 c compute ocean water going to atm, in precip units  
            tmpscal2=rhoConstFresh*maskC(I,J,kSurface,bi,bj)*  
      &       ( ( EVAP(I,J,bi,bj)-PRECIP(I,J,bi,bj) )  
      &         * ( ONE - AREApreTH(I,J) )  
 #ifdef ALLOW_RUNOFF  
      &         - RUNOFF(I,J,bi,bj)  
 #endif /* ALLOW_RUNOFF */  
      &         + ( d_HFRWbyRAIN(I,J) + r_FWbySublim(I,J) )  
      &         *convertHI2PRECIP )  
 c factor in the advected specific energy (referenced to 0 for 0deC liquid water)  
            tmpscal1= - tmpscal1*  
      &       ( -SEAICE_lhFusion + HeatCapacity_Cp * ZERO )  
            IF (temp_EvPrRn.NE.UNSET_RL) THEN  
            tmpscal2= - tmpscal2*  
      &       ( ZERO + HeatCapacity_Cp * temp_EvPrRn )  
            ELSE  
            tmpscal2= - tmpscal2*  
      &       ( ZERO + HeatCapacity_Cp * theta(I,J,kSurface,bi,bj) )  
            ENDIF  
 c add to SIatmQnt, leading to SItflux, which is analogous to TFLUX  
            DIAGarrayA(I,J)=maskC(I,J,kSurface,bi,bj)*convertHI2Q*(  
 #ifndef SEAICE_GROWTH_LEGACY  
      &            a_QSWbyATM_cover(I,J) +  
 #endif  
      &            a_QbyATM_cover(I,J) + a_QbyATM_open(I,J) )  
      &            -tmpscal1-tmpscal2  
           ENDDO  
          ENDDO  
          CALL DIAGNOSTICS_FILL(DIAGarrayA,  
      &      'SItflux ',0,1,3,bi,bj,myThid)  
2731  #endif /* ALLOW_ATM_TEMP */  #endif /* ALLOW_ATM_TEMP */
2732    
2733          ENDIF          ENDIF
# Line 2660  C close bi,bj loops Line 2737  C close bi,bj loops
2737         ENDDO         ENDDO
2738        ENDDO        ENDDO
2739    
2740    
2741    C ===================================================================
2742    C =========PART 9: HF/FWF global integrals and balancing=============
2743    C ===================================================================
2744    
2745    #ifdef ALLOW_BALANCE_FLUXES
2746    
2747    c 1)  global sums
2748    # ifdef ALLOW_AUTODIFF_TAMC
2749    CADJ STORE FWFsiTile = comlev1, key=ikey_dynamics, kind=isbyte
2750    CADJ STORE HFsiTile = comlev1, key=ikey_dynamics, kind=isbyte
2751    CADJ STORE FWF2HFsiTile = comlev1, key=ikey_dynamics, kind=isbyte
2752    # endif /* ALLOW_AUTODIFF_TAMC */
2753          FWFsiGlob=0. _d 0
2754          IF ( balanceEmPmR )
2755         &   CALL GLOBAL_SUM_TILE_RL( FWFsiTile, FWFsiGlob, myThid )        
2756          FWF2HFsiGlob=0. _d 0
2757          IF ( balanceEmPmR.AND.(temp_EvPrRn.EQ.UNSET_RL) ) THEN
2758             CALL GLOBAL_SUM_TILE_RL(FWF2HFsiTile, FWF2HFsiGlob, myThid)
2759          ELSEIF ( balanceEmPmR ) THEN
2760             FWF2HFsiGlob=HeatCapacity_Cp * temp_EvPrRn * globalArea
2761          ENDIF
2762          HFsiGlob=0. _d 0
2763          IF ( balanceQnet )
2764         &   CALL GLOBAL_SUM_TILE_RL( HFsiTile, HFsiGlob, myThid )
2765    
2766    c 2) global means
2767    c mean SIatmFW
2768          tmpscal0=FWFsiGlob / globalArea
2769    c corresponding mean advection by atm to ocean+ice water exchange
2770    c        (if mean SIatmFW was removed uniformely from ocean)
2771          tmpscal1=FWFsiGlob / globalArea * FWF2HFsiGlob / globalArea
2772    c mean SItflux (before potential adjustement due to SIatmFW)
2773          tmpscal2=HFsiGlob / globalArea
2774    c mean SItflux (after potential adjustement due to SIatmFW)
2775          IF ( balanceEmPmR ) tmpscal2=tmpscal2-tmpscal1
2776    
2777    c 3) balancing adjustments
2778          IF ( balanceEmPmR ) THEN
2779          DO bj=myByLo(myThid),myByHi(myThid)
2780           DO bi=myBxLo(myThid),myBxHi(myThid)
2781            DO j=1-OLy,sNy+OLy
2782             DO i=1-OLx,sNx+OLx
2783                empmr(i,j,bi,bj) = empmr(i,j,bi,bj) - tmpscal0
2784                SIatmFW(i,j,bi,bj) = SIatmFW(i,j,bi,bj) - tmpscal0
2785    c           adjust SItflux consistently      
2786                IF ( (temp_EvPrRn.NE.UNSET_RL).AND.
2787         &        useRealFreshWaterFlux.AND.(nonlinFreeSurf.NE.0) ) THEN
2788                tmpscal1=
2789         &       ( ZERO + HeatCapacity_Cp * temp_EvPrRn )
2790                ELSEIF ( (temp_EvPrRn.EQ.UNSET_RL).AND.
2791         &        useRealFreshWaterFlux.AND.(nonlinFreeSurf.NE.0) ) THEN
2792                tmpscal1=
2793         &       ( ZERO + HeatCapacity_Cp * theta(I,J,kSurface,bi,bj) )
2794                ELSEIF ( (temp_EvPrRn.NE.UNSET_RL) ) THEN
2795                tmpscal1=
2796         &       HeatCapacity_Cp*(temp_EvPrRn - theta(I,J,kSurface,bi,bj))
2797                ELSE
2798                tmpscal1=ZERO
2799                ENDIF
2800                SItflux(i,j,bi,bj) = SItflux(i,j,bi,bj) - tmpscal0*tmpscal1
2801    c           no qnet or tflux adjustement is needed
2802             ENDDO
2803            ENDDO
2804           ENDDO
2805          ENDDO
2806          IF ( balancePrintMean ) THEN
2807           _BEGIN_MASTER( myThid )
2808           WRITE(msgbuf,'(a,a,e24.17)') 'rm Global mean of ',
2809         &      'SIatmFW = ', tmpscal0
2810           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
2811         &      SQUEEZE_RIGHT , myThid)
2812           _END_MASTER( myThid )
2813          ENDIF
2814          ENDIF
2815          IF ( balanceQnet ) THEN
2816          DO bj=myByLo(myThid),myByHi(myThid)
2817           DO bi=myBxLo(myThid),myBxHi(myThid)
2818            DO j=1-OLy,sNy+OLy
2819             DO i=1-OLx,sNx+OLx
2820                SItflux(i,j,bi,bj) = SItflux(i,j,bi,bj) - tmpscal2
2821                qnet(i,j,bi,bj) = qnet(i,j,bi,bj) - tmpscal2
2822                SIatmQnt(i,j,bi,bj) = SIatmQnt(i,j,bi,bj) - tmpscal2
2823             ENDDO
2824            ENDDO
2825           ENDDO
2826          ENDDO
2827          IF ( balancePrintMean ) THEN
2828           _BEGIN_MASTER( myThid )
2829           WRITE(msgbuf,'(a,a,e24.17)') 'rm Global mean of ',
2830         &      'SItflux = ', tmpscal2
2831           CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
2832         &      SQUEEZE_RIGHT , myThid)
2833           _END_MASTER( myThid )
2834          ENDIF
2835          ENDIF
2836    #endif /* */
2837    
2838    #ifdef ALLOW_DIAGNOSTICS
2839    c these diags need to be done outside of the bi,bj loop so that
2840    c we may do potential global mean adjustement to them consistently.
2841             CALL DIAGNOSTICS_FILL(SItflux,
2842         &      'SItflux ',0,1,0,1,1,myThid)
2843             CALL DIAGNOSTICS_FILL(SIatmQnt,
2844         &      'SIatmQnt',0,1,0,1,1,myThid)
2845    c SIatmFW follows the same convention as empmr -- SIatmFW diag does not
2846             tmpscal1= - 1. _d 0
2847             CALL DIAGNOSTICS_SCALE_FILL(SIatmFW,
2848         &      tmpscal1,1,'SIatmFW ',0,1,0,1,1,myThid)
2849    #endif /* ALLOW_DIAGNOSTICS */
2850    
2851        RETURN        RETURN
2852        END        END

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

  ViewVC Help
Powered by ViewVC 1.1.22