| 1 | 
dgoldberg | 
1.3 | 
C $Header: /u/gcmpack/MITgcm/pkg/shelfice/shelfice_thermodynamics.F,v 1.44 2015/02/15 15:46:24 jmc Exp $ | 
| 2 | 
dgoldberg | 
1.1 | 
C $Name:  $ | 
| 3 | 
  | 
  | 
 | 
| 4 | 
  | 
  | 
#include "SHELFICE_OPTIONS.h" | 
| 5 | 
dgoldberg | 
1.2 | 
#ifdef ALLOW_AUTODIFF | 
| 6 | 
  | 
  | 
# include "AUTODIFF_OPTIONS.h" | 
| 7 | 
  | 
  | 
#endif | 
| 8 | 
  | 
  | 
#ifdef ALLOW_CTRL | 
| 9 | 
  | 
  | 
# include "CTRL_OPTIONS.h" | 
| 10 | 
  | 
  | 
#endif | 
| 11 | 
  | 
  | 
 | 
| 12 | 
dgoldberg | 
1.1 | 
CBOP | 
| 13 | 
  | 
  | 
C     !ROUTINE: SHELFICE_THERMODYNAMICS | 
| 14 | 
  | 
  | 
C     !INTERFACE: | 
| 15 | 
  | 
  | 
      SUBROUTINE SHELFICE_THERMODYNAMICS( | 
| 16 | 
  | 
  | 
     I                        myTime, myIter, myThid ) | 
| 17 | 
  | 
  | 
C     !DESCRIPTION: \bv | 
| 18 | 
  | 
  | 
C     *=============================================================* | 
| 19 | 
  | 
  | 
C     | S/R  SHELFICE_THERMODYNAMICS | 
| 20 | 
  | 
  | 
C     | o shelf-ice main routine. | 
| 21 | 
  | 
  | 
C     |   compute temperature and (virtual) salt flux at the | 
| 22 | 
  | 
  | 
C     |   shelf-ice ocean interface | 
| 23 | 
  | 
  | 
C     | | 
| 24 | 
  | 
  | 
C     | stresses at the ice/water interface are computed in separate | 
| 25 | 
  | 
  | 
C     | routines that are called from mom_fluxform/mom_vecinv | 
| 26 | 
  | 
  | 
C     *=============================================================* | 
| 27 | 
dgoldberg | 
1.3 | 
C     \ev | 
| 28 | 
dgoldberg | 
1.1 | 
 | 
| 29 | 
  | 
  | 
C     !USES: | 
| 30 | 
  | 
  | 
      IMPLICIT NONE | 
| 31 | 
  | 
  | 
 | 
| 32 | 
  | 
  | 
C     === Global variables === | 
| 33 | 
  | 
  | 
#include "SIZE.h" | 
| 34 | 
  | 
  | 
#include "EEPARAMS.h" | 
| 35 | 
  | 
  | 
#include "PARAMS.h" | 
| 36 | 
  | 
  | 
#include "GRID.h" | 
| 37 | 
  | 
  | 
#include "DYNVARS.h" | 
| 38 | 
  | 
  | 
#include "FFIELDS.h" | 
| 39 | 
  | 
  | 
#include "SHELFICE.h" | 
| 40 | 
dgoldberg | 
1.2 | 
#include "SHELFICE_COST.h" | 
| 41 | 
dgoldberg | 
1.1 | 
#ifdef ALLOW_AUTODIFF | 
| 42 | 
  | 
  | 
# include "CTRL_SIZE.h" | 
| 43 | 
  | 
  | 
# include "ctrl.h" | 
| 44 | 
  | 
  | 
# include "ctrl_dummy.h" | 
| 45 | 
  | 
  | 
#endif /* ALLOW_AUTODIFF */ | 
| 46 | 
  | 
  | 
#ifdef ALLOW_AUTODIFF_TAMC | 
| 47 | 
  | 
  | 
# ifdef SHI_ALLOW_GAMMAFRICT | 
| 48 | 
  | 
  | 
#  include "tamc.h" | 
| 49 | 
  | 
  | 
#  include "tamc_keys.h" | 
| 50 | 
  | 
  | 
# endif /* SHI_ALLOW_GAMMAFRICT */ | 
| 51 | 
  | 
  | 
#endif /* ALLOW_AUTODIFF_TAMC */ | 
| 52 | 
  | 
  | 
 | 
| 53 | 
  | 
  | 
C     !INPUT/OUTPUT PARAMETERS: | 
| 54 | 
  | 
  | 
C     === Routine arguments === | 
| 55 | 
  | 
  | 
C     myIter :: iteration counter for this thread | 
| 56 | 
  | 
  | 
C     myTime :: time counter for this thread | 
| 57 | 
  | 
  | 
C     myThid :: thread number for this instance of the routine. | 
| 58 | 
  | 
  | 
      _RL  myTime | 
| 59 | 
  | 
  | 
      INTEGER myIter | 
| 60 | 
  | 
  | 
      INTEGER myThid | 
| 61 | 
  | 
  | 
 | 
| 62 | 
  | 
  | 
#ifdef ALLOW_SHELFICE | 
| 63 | 
  | 
  | 
C     !LOCAL VARIABLES : | 
| 64 | 
  | 
  | 
C     === Local variables === | 
| 65 | 
  | 
  | 
C     I,J,K,Kp1,bi,bj  :: loop counters | 
| 66 | 
  | 
  | 
C     tLoc, sLoc, pLoc :: local in-situ temperature, salinity, pressure | 
| 67 | 
  | 
  | 
C     theta/saltFreeze :: temperature and salinity of water at the | 
| 68 | 
  | 
  | 
C                         ice-ocean interface (at the freezing point) | 
| 69 | 
  | 
  | 
C     freshWaterFlux   :: local variable for fresh water melt flux due | 
| 70 | 
  | 
  | 
C                         to melting in kg/m^2/s | 
| 71 | 
  | 
  | 
C                         (negative density x melt rate) | 
| 72 | 
  | 
  | 
C     convertFW2SaltLoc:: local copy of convertFW2Salt | 
| 73 | 
  | 
  | 
C     cFac             :: 1 for conservative form, 0, otherwise | 
| 74 | 
  | 
  | 
C     rFac             :: realFreshWaterFlux factor | 
| 75 | 
dgoldberg | 
1.3 | 
C     dFac             :: 0 for diffusive heat flux (Holland and Jenkins, 1999, | 
| 76 | 
  | 
  | 
C                           eq21) | 
| 77 | 
dgoldberg | 
1.1 | 
C                         1 for advective and diffusive heat flux (eq22, 26, 31) | 
| 78 | 
dgoldberg | 
1.3 | 
C     fwflxFac         :: only effective for dFac=1, 1 if we expect a melting | 
| 79 | 
  | 
  | 
C                         fresh water flux, 0 otherwise | 
| 80 | 
dgoldberg | 
1.1 | 
C     auxiliary variables and abbreviations: | 
| 81 | 
  | 
  | 
C     a0, a1, a2, b, c0 | 
| 82 | 
  | 
  | 
C     eps1, eps2, eps3, eps3a, eps4, eps5, eps6, eps7, eps8 | 
| 83 | 
  | 
  | 
C     aqe, bqe, cqe, discrim, recip_aqe | 
| 84 | 
  | 
  | 
C     drKp1, recip_drLoc | 
| 85 | 
  | 
  | 
      INTEGER I,J,K,Kp1 | 
| 86 | 
  | 
  | 
      INTEGER bi,bj | 
| 87 | 
  | 
  | 
      _RL tLoc(1:sNx,1:sNy) | 
| 88 | 
  | 
  | 
      _RL sLoc(1:sNx,1:sNy) | 
| 89 | 
  | 
  | 
      _RL pLoc(1:sNx,1:sNy) | 
| 90 | 
  | 
  | 
      _RL uLoc(1:sNx,1:sNy) | 
| 91 | 
  | 
  | 
      _RL vLoc(1:sNx,1:sNy) | 
| 92 | 
  | 
  | 
      _RL thetaFreeze, saltFreeze, recip_Cp | 
| 93 | 
  | 
  | 
      _RL freshWaterFlux, convertFW2SaltLoc | 
| 94 | 
  | 
  | 
      _RL a0, a1, a2, b, c0 | 
| 95 | 
  | 
  | 
      _RL eps1, eps2, eps3, eps3a, eps4, eps5, eps6, eps7, eps8 | 
| 96 | 
  | 
  | 
      _RL cFac, rFac, dFac, fwflxFac | 
| 97 | 
  | 
  | 
      _RL aqe, bqe, cqe, discrim, recip_aqe | 
| 98 | 
  | 
  | 
      _RL drKp1, recip_drLoc | 
| 99 | 
dgoldberg | 
1.3 | 
      _RL recip_latentHeat | 
| 100 | 
dgoldberg | 
1.1 | 
      _RL tmpFac | 
| 101 | 
  | 
  | 
 | 
| 102 | 
  | 
  | 
#ifdef SHI_ALLOW_GAMMAFRICT | 
| 103 | 
  | 
  | 
      _RL shiPr, shiSc, shiLo, recip_shiKarman, shiTwoThirds | 
| 104 | 
  | 
  | 
      _RL gammaTmoleT, gammaTmoleS, gammaTurb, gammaTurbConst | 
| 105 | 
  | 
  | 
      _RL ustar, ustarSq, etastar | 
| 106 | 
  | 
  | 
      PARAMETER ( shiTwoThirds = 0.66666666666666666666666666667D0 ) | 
| 107 | 
dgoldberg | 
1.3 | 
#ifdef ALLOW_DIAGNOSTICS | 
| 108 | 
  | 
  | 
      _RL uStarDiag(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) | 
| 109 | 
  | 
  | 
#endif /* ALLOW_DIAGNOSTICS */ | 
| 110 | 
dgoldberg | 
1.1 | 
#endif | 
| 111 | 
  | 
  | 
 | 
| 112 | 
  | 
  | 
#ifndef ALLOW_OPENAD | 
| 113 | 
  | 
  | 
      _RL SW_TEMP | 
| 114 | 
  | 
  | 
      EXTERNAL SW_TEMP | 
| 115 | 
  | 
  | 
#endif | 
| 116 | 
  | 
  | 
 | 
| 117 | 
  | 
  | 
#ifdef ALLOW_SHIFWFLX_CONTROL | 
| 118 | 
  | 
  | 
      _RL xx_shifwflx_loc(1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) | 
| 119 | 
  | 
  | 
#endif | 
| 120 | 
dgoldberg | 
1.3 | 
CEOP | 
| 121 | 
dgoldberg | 
1.1 | 
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| | 
| 122 | 
  | 
  | 
 | 
| 123 | 
  | 
  | 
#ifdef SHI_ALLOW_GAMMAFRICT | 
| 124 | 
dgoldberg | 
1.2 | 
#ifdef ALLOW_AUTODIFF | 
| 125 | 
dgoldberg | 
1.1 | 
C     re-initialize here again, curtesy to TAF | 
| 126 | 
  | 
  | 
      DO bj = myByLo(myThid), myByHi(myThid) | 
| 127 | 
  | 
  | 
       DO bi = myBxLo(myThid), myBxHi(myThid) | 
| 128 | 
  | 
  | 
        DO J = 1-OLy,sNy+OLy | 
| 129 | 
  | 
  | 
         DO I = 1-OLx,sNx+OLx | 
| 130 | 
  | 
  | 
          shiTransCoeffT(i,j,bi,bj) = SHELFICEheatTransCoeff | 
| 131 | 
  | 
  | 
          shiTransCoeffS(i,j,bi,bj) = SHELFICEsaltTransCoeff | 
| 132 | 
  | 
  | 
         ENDDO | 
| 133 | 
  | 
  | 
        ENDDO | 
| 134 | 
  | 
  | 
       ENDDO | 
| 135 | 
  | 
  | 
      ENDDO | 
| 136 | 
dgoldberg | 
1.2 | 
#endif /* ALLOW_AUTODIFF */ | 
| 137 | 
dgoldberg | 
1.1 | 
      IF ( SHELFICEuseGammaFrict ) THEN | 
| 138 | 
  | 
  | 
C     Implement friction velocity-dependent transfer coefficient | 
| 139 | 
  | 
  | 
C     of Holland and Jenkins, JPO, 1999 | 
| 140 | 
  | 
  | 
       recip_shiKarman= 1. _d 0 / 0.4 _d 0 | 
| 141 | 
  | 
  | 
       shiLo = 0. _d 0 | 
| 142 | 
  | 
  | 
       shiPr = shiPrandtl**shiTwoThirds | 
| 143 | 
  | 
  | 
       shiSc = shiSchmidt**shiTwoThirds | 
| 144 | 
  | 
  | 
cph      shiPr = (viscArNr(1)/diffKrNrT(1))**shiTwoThirds | 
| 145 | 
  | 
  | 
cph      shiSc = (viscArNr(1)/diffKrNrS(1))**shiTwoThirds | 
| 146 | 
  | 
  | 
       gammaTmoleT = 12.5 _d 0 * shiPr - 6. _d 0 | 
| 147 | 
  | 
  | 
       gammaTmoleS = 12.5 _d 0 * shiSc - 6. _d 0 | 
| 148 | 
  | 
  | 
C     instead of etastar = sqrt(1+zetaN*ustar./(f*Lo*Rc)) | 
| 149 | 
  | 
  | 
       etastar = 1. _d 0 | 
| 150 | 
  | 
  | 
       gammaTurbConst  = 1. _d 0 / (2. _d 0 * shiZetaN*etastar) | 
| 151 | 
  | 
  | 
     &      - recip_shiKarman | 
| 152 | 
dgoldberg | 
1.2 | 
#ifdef ALLOW_AUTODIFF | 
| 153 | 
dgoldberg | 
1.1 | 
       DO bj = myByLo(myThid), myByHi(myThid) | 
| 154 | 
  | 
  | 
        DO bi = myBxLo(myThid), myBxHi(myThid) | 
| 155 | 
  | 
  | 
         DO J = 1-OLy,sNy+OLy | 
| 156 | 
  | 
  | 
          DO I = 1-OLx,sNx+OLx | 
| 157 | 
  | 
  | 
           shiTransCoeffT(i,j,bi,bj) = 0. _d 0 | 
| 158 | 
  | 
  | 
           shiTransCoeffS(i,j,bi,bj) = 0. _d 0 | 
| 159 | 
  | 
  | 
          ENDDO | 
| 160 | 
  | 
  | 
         ENDDO | 
| 161 | 
  | 
  | 
        ENDDO | 
| 162 | 
  | 
  | 
       ENDDO | 
| 163 | 
dgoldberg | 
1.2 | 
#endif /* ALLOW_AUTODIFF */ | 
| 164 | 
dgoldberg | 
1.1 | 
      ENDIF | 
| 165 | 
  | 
  | 
#endif /* SHI_ALLOW_GAMMAFRICT */ | 
| 166 | 
  | 
  | 
 | 
| 167 | 
dgoldberg | 
1.3 | 
      recip_latentHeat = 0. _d 0 | 
| 168 | 
  | 
  | 
      IF ( SHELFICElatentHeat .NE. 0. _d 0 ) | 
| 169 | 
  | 
  | 
     &     recip_latentHeat = 1. _d 0/SHELFICElatentHeat | 
| 170 | 
dgoldberg | 
1.1 | 
C     are we doing the conservative form of Jenkins et al. (2001)? | 
| 171 | 
  | 
  | 
      recip_Cp = 1. _d 0 / HeatCapacity_Cp | 
| 172 | 
  | 
  | 
      cFac = 0. _d 0 | 
| 173 | 
  | 
  | 
      IF ( SHELFICEconserve ) cFac = 1. _d 0 | 
| 174 | 
  | 
  | 
C     with "real fresh water flux" (affecting ETAN), | 
| 175 | 
  | 
  | 
C     there is more to modify | 
| 176 | 
  | 
  | 
      rFac = 1. _d 0 | 
| 177 | 
  | 
  | 
      IF ( SHELFICEconserve .AND. useRealFreshWaterFlux ) rFac = 0. _d 0 | 
| 178 | 
  | 
  | 
C     heat flux into the ice shelf, default is diffusive flux | 
| 179 | 
  | 
  | 
C     (Holland and Jenkins, 1999, eq.21) | 
| 180 | 
  | 
  | 
      dFac = 0. _d 0 | 
| 181 | 
  | 
  | 
      IF ( SHELFICEadvDiffHeatFlux ) dFac = 1. _d 0 | 
| 182 | 
  | 
  | 
      fwflxFac = 0. _d 0 | 
| 183 | 
  | 
  | 
C     linear dependence of freezing point on salinity | 
| 184 | 
  | 
  | 
      a0 = -0.0575   _d  0 | 
| 185 | 
  | 
  | 
      a1 =  0.0      _d -0 | 
| 186 | 
  | 
  | 
      a2 =  0.0      _d -0 | 
| 187 | 
  | 
  | 
      c0 =  0.0901   _d  0 | 
| 188 | 
  | 
  | 
      b  =  -7.61    _d -4 | 
| 189 | 
  | 
  | 
#ifdef ALLOW_ISOMIP_TD | 
| 190 | 
  | 
  | 
      IF ( useISOMIPTD ) THEN | 
| 191 | 
  | 
  | 
C     non-linear dependence of freezing point on salinity | 
| 192 | 
  | 
  | 
       a0 = -0.0575   _d  0 | 
| 193 | 
  | 
  | 
       a1 = 1.710523  _d -3 | 
| 194 | 
  | 
  | 
       a2 = -2.154996 _d -4 | 
| 195 | 
  | 
  | 
       b  = -7.53     _d -4 | 
| 196 | 
  | 
  | 
       c0 = 0. _d 0 | 
| 197 | 
  | 
  | 
      ENDIF | 
| 198 | 
  | 
  | 
      convertFW2SaltLoc = convertFW2Salt | 
| 199 | 
  | 
  | 
C     hardcoding this value here is OK because it only applies to ISOMIP | 
| 200 | 
  | 
  | 
C     where this value is part of the protocol | 
| 201 | 
  | 
  | 
      IF ( convertFW2SaltLoc .EQ. -1. ) convertFW2SaltLoc = 33.4 _d 0 | 
| 202 | 
  | 
  | 
#endif /* ALLOW_ISOMIP_TD */ | 
| 203 | 
  | 
  | 
 | 
| 204 | 
  | 
  | 
      DO bj = myByLo(myThid), myByHi(myThid) | 
| 205 | 
  | 
  | 
       DO bi = myBxLo(myThid), myBxHi(myThid) | 
| 206 | 
  | 
  | 
        DO J = 1-OLy,sNy+OLy | 
| 207 | 
  | 
  | 
         DO I = 1-OLx,sNx+OLx | 
| 208 | 
  | 
  | 
          shelfIceHeatFlux      (I,J,bi,bj) = 0. _d 0 | 
| 209 | 
  | 
  | 
          shelfIceFreshWaterFlux(I,J,bi,bj) = 0. _d 0 | 
| 210 | 
  | 
  | 
          shelficeForcingT      (I,J,bi,bj) = 0. _d 0 | 
| 211 | 
  | 
  | 
          shelficeForcingS      (I,J,bi,bj) = 0. _d 0 | 
| 212 | 
dgoldberg | 
1.3 | 
#if (defined SHI_ALLOW_GAMMAFRICT && defined ALLOW_DIAGNOSTICS) | 
| 213 | 
  | 
  | 
          uStarDiag             (I,J,bi,bj) = 0. _d 0 | 
| 214 | 
  | 
  | 
#endif /* SHI_ALLOW_GAMMAFRICT and ALLOW_DIAGNOSTICS */ | 
| 215 | 
dgoldberg | 
1.1 | 
         ENDDO | 
| 216 | 
  | 
  | 
        ENDDO | 
| 217 | 
  | 
  | 
       ENDDO | 
| 218 | 
  | 
  | 
      ENDDO | 
| 219 | 
  | 
  | 
#ifdef ALLOW_SHIFWFLX_CONTROL | 
| 220 | 
  | 
  | 
      DO bj = myByLo(myThid), myByHi(myThid) | 
| 221 | 
  | 
  | 
       DO bi = myBxLo(myThid), myBxHi(myThid) | 
| 222 | 
  | 
  | 
        DO J = 1-OLy,sNy+OLy | 
| 223 | 
  | 
  | 
         DO I = 1-OLx,sNx+OLx | 
| 224 | 
  | 
  | 
          xx_shifwflx_loc(I,J,bi,bj) = 0. _d 0 | 
| 225 | 
  | 
  | 
         ENDDO | 
| 226 | 
  | 
  | 
        ENDDO | 
| 227 | 
  | 
  | 
       ENDDO | 
| 228 | 
  | 
  | 
      ENDDO | 
| 229 | 
dgoldberg | 
1.2 | 
#ifdef ALLOW_CTRL | 
| 230 | 
  | 
  | 
      if (useCTRL) CALL CTRL_GET_GEN ( | 
| 231 | 
dgoldberg | 
1.1 | 
     &     xx_shifwflx_file, xx_shifwflxstartdate, xx_shifwflxperiod, | 
| 232 | 
  | 
  | 
     &     maskSHI, xx_shifwflx_loc, xx_shifwflx0, xx_shifwflx1, | 
| 233 | 
  | 
  | 
     &     xx_shifwflx_dummy, | 
| 234 | 
  | 
  | 
     &     xx_shifwflx_remo_intercept, xx_shifwflx_remo_slope, | 
| 235 | 
dgoldberg | 
1.2 | 
     &     wshifwflx, | 
| 236 | 
dgoldberg | 
1.1 | 
     &     myTime, myIter, myThid ) | 
| 237 | 
dgoldberg | 
1.2 | 
#endif | 
| 238 | 
dgoldberg | 
1.1 | 
#endif /* ALLOW_SHIFWFLX_CONTROL */ | 
| 239 | 
  | 
  | 
      DO bj = myByLo(myThid), myByHi(myThid) | 
| 240 | 
  | 
  | 
       DO bi = myBxLo(myThid), myBxHi(myThid) | 
| 241 | 
  | 
  | 
#ifdef ALLOW_AUTODIFF_TAMC | 
| 242 | 
  | 
  | 
# ifdef SHI_ALLOW_GAMMAFRICT | 
| 243 | 
  | 
  | 
        act1 = bi - myBxLo(myThid) | 
| 244 | 
  | 
  | 
        max1 = myBxHi(myThid) - myBxLo(myThid) + 1 | 
| 245 | 
  | 
  | 
        act2 = bj - myByLo(myThid) | 
| 246 | 
  | 
  | 
        max2 = myByHi(myThid) - myByLo(myThid) + 1 | 
| 247 | 
  | 
  | 
        act3 = myThid - 1 | 
| 248 | 
  | 
  | 
        max3 = nTx*nTy | 
| 249 | 
  | 
  | 
        act4 = ikey_dynamics - 1 | 
| 250 | 
  | 
  | 
        ikey = (act1 + 1) + act2*max1 | 
| 251 | 
  | 
  | 
     &                    + act3*max1*max2 | 
| 252 | 
  | 
  | 
     &                    + act4*max1*max2*max3 | 
| 253 | 
  | 
  | 
# endif /* SHI_ALLOW_GAMMAFRICT */ | 
| 254 | 
  | 
  | 
#endif /* ALLOW_AUTODIFF_TAMC */ | 
| 255 | 
  | 
  | 
        DO J = 1, sNy | 
| 256 | 
  | 
  | 
         DO I = 1, sNx | 
| 257 | 
  | 
  | 
C--   make local copies of temperature, salinity and depth (pressure in deci-bar) | 
| 258 | 
  | 
  | 
C--   underneath the ice | 
| 259 | 
  | 
  | 
          K         = MAX(1,kTopC(I,J,bi,bj)) | 
| 260 | 
  | 
  | 
          pLoc(I,J) = ABS(R_shelfIce(I,J,bi,bj)) | 
| 261 | 
  | 
  | 
c         pLoc(I,J) = shelficeMass(I,J,bi,bj)*gravity*1. _d -4 | 
| 262 | 
  | 
  | 
          tLoc(I,J) = theta(I,J,K,bi,bj) | 
| 263 | 
  | 
  | 
          sLoc(I,J) = MAX(salt(I,J,K,bi,bj), zeroRL) | 
| 264 | 
  | 
  | 
          uLoc(I,J) = recip_hFacC(I,J,K,bi,bj) * | 
| 265 | 
  | 
  | 
     &         ( uVel(I,  J,K,bi,bj) * _hFacW(I,  J,K,bi,bj) | 
| 266 | 
  | 
  | 
     &         + uVel(I+1,J,K,bi,bj) * _hFacW(I+1,J,K,bi,bj) ) | 
| 267 | 
  | 
  | 
          vLoc(I,J) = recip_hFacC(I,J,K,bi,bj) * | 
| 268 | 
  | 
  | 
     &         ( vVel(I,J,  K,bi,bj) * _hFacS(I,J,  K,bi,bj) | 
| 269 | 
  | 
  | 
     &         + vVel(I,J+1,K,bi,bj) * _hFacS(I,J+1,K,bi,bj) ) | 
| 270 | 
  | 
  | 
         ENDDO | 
| 271 | 
  | 
  | 
        ENDDO | 
| 272 | 
  | 
  | 
        IF ( SHELFICEBoundaryLayer ) THEN | 
| 273 | 
  | 
  | 
C--   average over boundary layer width | 
| 274 | 
  | 
  | 
         DO J = 1, sNy | 
| 275 | 
  | 
  | 
          DO I = 1, sNx | 
| 276 | 
  | 
  | 
           K   = kTopC(I,J,bi,bj) | 
| 277 | 
  | 
  | 
           IF ( K .NE. 0 .AND. K .LT. Nr ) THEN | 
| 278 | 
  | 
  | 
            Kp1 = MIN(Nr,K+1) | 
| 279 | 
  | 
  | 
C--   overlap into lower cell | 
| 280 | 
  | 
  | 
            drKp1 = drF(K)*( 1. _d 0 - _hFacC(I,J,K,bi,bj) ) | 
| 281 | 
  | 
  | 
C--   lower cell may not be as thick as required | 
| 282 | 
  | 
  | 
            drKp1 = MIN( drKp1, drF(Kp1) * _hFacC(I,J,Kp1,bi,bj) ) | 
| 283 | 
dgoldberg | 
1.3 | 
            drKp1 = MAX( drKp1, 0. _d 0 ) | 
| 284 | 
dgoldberg | 
1.1 | 
            recip_drLoc = 1. _d 0 / | 
| 285 | 
  | 
  | 
     &           ( drF(K)*_hFacC(I,J,K,bi,bj) + drKp1 ) | 
| 286 | 
  | 
  | 
            tLoc(I,J) = ( tLoc(I,J) * drF(K)*_hFacC(I,J,K,bi,bj) | 
| 287 | 
  | 
  | 
     &           + theta(I,J,Kp1,bi,bj) *drKp1 ) | 
| 288 | 
  | 
  | 
     &           * recip_drLoc | 
| 289 | 
  | 
  | 
            sLoc(I,J) = ( sLoc(I,J) * drF(K)*_hFacC(I,J,K,bi,bj) | 
| 290 | 
  | 
  | 
     &           + MAX(salt(I,J,Kp1,bi,bj), zeroRL) * drKp1 ) | 
| 291 | 
  | 
  | 
     &           * recip_drLoc | 
| 292 | 
  | 
  | 
            uLoc(I,J) = ( uLoc(I,J) * drF(K)*_hFacC(I,J,K,bi,bj) | 
| 293 | 
  | 
  | 
     &           + drKp1 * recip_hFacC(I,J,Kp1,bi,bj) * | 
| 294 | 
  | 
  | 
     &           ( uVel(I,  J,Kp1,bi,bj) * _hFacW(I,  J,Kp1,bi,bj) | 
| 295 | 
  | 
  | 
     &           + uVel(I+1,J,Kp1,bi,bj) * _hFacW(I+1,J,Kp1,bi,bj) ) | 
| 296 | 
  | 
  | 
     &           ) * recip_drLoc | 
| 297 | 
  | 
  | 
            vLoc(I,J) = ( vLoc(I,J) * drF(K)*_hFacC(I,J,K,bi,bj) | 
| 298 | 
  | 
  | 
     &           + drKp1 * recip_hFacC(I,J,Kp1,bi,bj) * | 
| 299 | 
  | 
  | 
     &           ( vVel(I,J,  Kp1,bi,bj) * _hFacS(I,J,  Kp1,bi,bj) | 
| 300 | 
  | 
  | 
     &           + vVel(I,J+1,Kp1,bi,bj) * _hFacS(I,J+1,Kp1,bi,bj) ) | 
| 301 | 
  | 
  | 
     &           ) * recip_drLoc | 
| 302 | 
  | 
  | 
           ENDIF | 
| 303 | 
  | 
  | 
          ENDDO | 
| 304 | 
  | 
  | 
         ENDDO | 
| 305 | 
  | 
  | 
        ENDIF | 
| 306 | 
  | 
  | 
 | 
| 307 | 
  | 
  | 
C--   turn potential temperature into in-situ temperature relative | 
| 308 | 
  | 
  | 
C--   to the surface | 
| 309 | 
  | 
  | 
        DO J = 1, sNy | 
| 310 | 
  | 
  | 
         DO I = 1, sNx | 
| 311 | 
  | 
  | 
#ifndef ALLOW_OPENAD | 
| 312 | 
  | 
  | 
          tLoc(I,J) = SW_TEMP(sLoc(I,J),tLoc(I,J),pLoc(I,J),zeroRL) | 
| 313 | 
  | 
  | 
#else | 
| 314 | 
  | 
  | 
          CALL SW_TEMP(sLoc(I,J),tLoc(I,J),pLoc(I,J),zeroRL,tLoc(I,J)) | 
| 315 | 
  | 
  | 
#endif | 
| 316 | 
  | 
  | 
         ENDDO | 
| 317 | 
  | 
  | 
        ENDDO | 
| 318 | 
  | 
  | 
 | 
| 319 | 
  | 
  | 
#ifdef SHI_ALLOW_GAMMAFRICT | 
| 320 | 
  | 
  | 
        IF ( SHELFICEuseGammaFrict ) THEN | 
| 321 | 
  | 
  | 
         DO J = 1, sNy | 
| 322 | 
  | 
  | 
          DO I = 1, sNx | 
| 323 | 
  | 
  | 
           K = kTopC(I,J,bi,bj) | 
| 324 | 
  | 
  | 
           IF ( K .NE. 0 .AND. pLoc(I,J) .GT. 0. _d 0 ) THEN | 
| 325 | 
  | 
  | 
            ustarSq = shiCdrag * MAX( 1.D-6, | 
| 326 | 
  | 
  | 
     &           0.25 _d 0 *(uLoc(I,J)*uLoc(I,J)+vLoc(I,J)*vLoc(I,J)) ) | 
| 327 | 
  | 
  | 
            ustar   = SQRT(ustarSq) | 
| 328 | 
dgoldberg | 
1.3 | 
#ifdef ALLOW_DIAGNOSTICS | 
| 329 | 
  | 
  | 
            uStarDiag(I,J,bi,bj) = ustar | 
| 330 | 
  | 
  | 
#endif /* ALLOW_DIAGNOSTICS */ | 
| 331 | 
dgoldberg | 
1.1 | 
C     instead of etastar = sqrt(1+zetaN*ustar./(f*Lo*Rc)) | 
| 332 | 
  | 
  | 
C           etastar = 1. _d 0 | 
| 333 | 
  | 
  | 
C           gammaTurbConst  = 1. _d 0 / (2. _d 0 * shiZetaN*etastar) | 
| 334 | 
  | 
  | 
C    &           - recip_shiKarman | 
| 335 | 
  | 
  | 
            IF ( fCori(I,J,bi,bj) .NE. 0. _d 0 ) THEN | 
| 336 | 
  | 
  | 
             gammaTurb = LOG( ustarSq * shiZetaN * etastar**2 | 
| 337 | 
  | 
  | 
     &            / ABS(fCori(I,J,bi,bj) * 5.0 _d 0 * shiKinVisc)) | 
| 338 | 
  | 
  | 
     &            * recip_shiKarman | 
| 339 | 
  | 
  | 
     &            + gammaTurbConst | 
| 340 | 
  | 
  | 
C     Do we need to catch the unlikely case of very small ustar | 
| 341 | 
  | 
  | 
C     that can lead to negative gammaTurb? | 
| 342 | 
  | 
  | 
C            gammaTurb = MAX(0.D0, gammaTurb) | 
| 343 | 
  | 
  | 
            ELSE | 
| 344 | 
  | 
  | 
             gammaTurb = gammaTurbConst | 
| 345 | 
  | 
  | 
            ENDIF | 
| 346 | 
  | 
  | 
            shiTransCoeffT(i,j,bi,bj) = MAX( zeroRL, | 
| 347 | 
  | 
  | 
     &           ustar/(gammaTurb + gammaTmoleT) ) | 
| 348 | 
  | 
  | 
            shiTransCoeffS(i,j,bi,bj) = MAX( zeroRL, | 
| 349 | 
  | 
  | 
     &           ustar/(gammaTurb + gammaTmoleS) ) | 
| 350 | 
  | 
  | 
           ENDIF | 
| 351 | 
  | 
  | 
          ENDDO | 
| 352 | 
  | 
  | 
         ENDDO | 
| 353 | 
  | 
  | 
        ENDIF | 
| 354 | 
  | 
  | 
#endif /* SHI_ALLOW_GAMMAFRICT */ | 
| 355 | 
  | 
  | 
 | 
| 356 | 
  | 
  | 
#ifdef ALLOW_AUTODIFF_TAMC | 
| 357 | 
  | 
  | 
# ifdef SHI_ALLOW_GAMMAFRICT | 
| 358 | 
  | 
  | 
CADJ STORE shiTransCoeffS(:,:,bi,bj) = comlev1_bibj, | 
| 359 | 
  | 
  | 
CADJ &     key=ikey, byte=isbyte | 
| 360 | 
  | 
  | 
CADJ STORE shiTransCoeffT(:,:,bi,bj) = comlev1_bibj, | 
| 361 | 
  | 
  | 
CADJ &     key=ikey, byte=isbyte | 
| 362 | 
  | 
  | 
# endif /* SHI_ALLOW_GAMMAFRICT */ | 
| 363 | 
  | 
  | 
#endif /* ALLOW_AUTODIFF_TAMC */ | 
| 364 | 
  | 
  | 
#ifdef ALLOW_ISOMIP_TD | 
| 365 | 
  | 
  | 
        IF ( useISOMIPTD ) THEN | 
| 366 | 
  | 
  | 
         DO J = 1, sNy | 
| 367 | 
  | 
  | 
          DO I = 1, sNx | 
| 368 | 
  | 
  | 
           K = kTopC(I,J,bi,bj) | 
| 369 | 
  | 
  | 
           IF ( K .NE. 0 .AND. pLoc(I,J) .GT. 0. _d 0 ) THEN | 
| 370 | 
  | 
  | 
C--   Calculate freezing temperature as a function of salinity and pressure | 
| 371 | 
  | 
  | 
            thetaFreeze = | 
| 372 | 
  | 
  | 
     &           sLoc(I,J) * ( a0 + a1*sqrt(sLoc(I,J)) + a2*sLoc(I,J) ) | 
| 373 | 
  | 
  | 
     &           + b*pLoc(I,J) + c0 | 
| 374 | 
  | 
  | 
C--   Calculate the upward heat and  fresh water fluxes | 
| 375 | 
  | 
  | 
            shelfIceHeatFlux(I,J,bi,bj) = maskC(I,J,K,bi,bj) | 
| 376 | 
  | 
  | 
     &           * shiTransCoeffT(i,j,bi,bj) | 
| 377 | 
  | 
  | 
     &           * ( tLoc(I,J) - thetaFreeze ) | 
| 378 | 
  | 
  | 
     &           * HeatCapacity_Cp*rUnit2mass | 
| 379 | 
  | 
  | 
#ifdef ALLOW_SHIFWFLX_CONTROL | 
| 380 | 
  | 
  | 
     &           - xx_shifwflx_loc(I,J,bi,bj)*SHELFICElatentHeat | 
| 381 | 
  | 
  | 
#endif /*  ALLOW_SHIFWFLX_CONTROL */ | 
| 382 | 
  | 
  | 
C     upward heat flux into the shelf-ice implies basal melting, | 
| 383 | 
  | 
  | 
C     thus a downward (negative upward) fresh water flux (as a mass flux), | 
| 384 | 
  | 
  | 
C     and vice versa | 
| 385 | 
  | 
  | 
            shelfIceFreshWaterFlux(I,J,bi,bj) = | 
| 386 | 
  | 
  | 
     &           - shelfIceHeatFlux(I,J,bi,bj) | 
| 387 | 
dgoldberg | 
1.3 | 
     &           *recip_latentHeat | 
| 388 | 
dgoldberg | 
1.1 | 
C--   compute surface tendencies | 
| 389 | 
  | 
  | 
            shelficeForcingT(i,j,bi,bj) = | 
| 390 | 
  | 
  | 
     &           - shelfIceHeatFlux(I,J,bi,bj) | 
| 391 | 
  | 
  | 
     &           *recip_Cp*mass2rUnit | 
| 392 | 
  | 
  | 
     &           - cFac * shelfIceFreshWaterFlux(I,J,bi,bj)*mass2rUnit | 
| 393 | 
  | 
  | 
     &           * ( thetaFreeze - tLoc(I,J) ) | 
| 394 | 
  | 
  | 
            shelficeForcingS(i,j,bi,bj) = | 
| 395 | 
  | 
  | 
     &           shelfIceFreshWaterFlux(I,J,bi,bj) * mass2rUnit | 
| 396 | 
  | 
  | 
     &           * ( cFac*sLoc(I,J) + (1. _d 0-cFac)*convertFW2SaltLoc ) | 
| 397 | 
  | 
  | 
C--   stress at the ice/water interface is computed in separate | 
| 398 | 
  | 
  | 
C     routines that are called from mom_fluxform/mom_vecinv | 
| 399 | 
  | 
  | 
           ELSE | 
| 400 | 
  | 
  | 
            shelfIceHeatFlux      (I,J,bi,bj) = 0. _d 0 | 
| 401 | 
  | 
  | 
            shelfIceFreshWaterFlux(I,J,bi,bj) = 0. _d 0 | 
| 402 | 
  | 
  | 
            shelficeForcingT      (I,J,bi,bj) = 0. _d 0 | 
| 403 | 
  | 
  | 
            shelficeForcingS      (I,J,bi,bj) = 0. _d 0 | 
| 404 | 
  | 
  | 
           ENDIF | 
| 405 | 
  | 
  | 
          ENDDO | 
| 406 | 
  | 
  | 
         ENDDO | 
| 407 | 
  | 
  | 
        ELSE | 
| 408 | 
  | 
  | 
#else | 
| 409 | 
  | 
  | 
        IF ( .TRUE. ) THEN | 
| 410 | 
  | 
  | 
#endif /* ALLOW_ISOMIP_TD */ | 
| 411 | 
  | 
  | 
C     use BRIOS thermodynamics, following Hellmers PhD thesis: | 
| 412 | 
  | 
  | 
C     Hellmer, H., 1989, A two-dimensional model for the thermohaline | 
| 413 | 
  | 
  | 
C     circulation under an ice shelf, Reports on Polar Research, No. 60 | 
| 414 | 
  | 
  | 
C     (in German). | 
| 415 | 
  | 
  | 
 | 
| 416 | 
  | 
  | 
         DO J = 1, sNy | 
| 417 | 
  | 
  | 
          DO I = 1, sNx | 
| 418 | 
  | 
  | 
           K    = kTopC(I,J,bi,bj) | 
| 419 | 
  | 
  | 
           IF ( K .NE. 0 .AND. pLoc(I,J) .GT. 0. _d 0 ) THEN | 
| 420 | 
  | 
  | 
C     heat flux into the ice shelf, default is diffusive flux | 
| 421 | 
  | 
  | 
C     (Holland and Jenkins, 1999, eq.21) | 
| 422 | 
  | 
  | 
            thetaFreeze = a0*sLoc(I,J)+c0+b*pLoc(I,J) | 
| 423 | 
  | 
  | 
            fwflxFac    = 0. _d 0 | 
| 424 | 
  | 
  | 
            IF ( tLoc(I,J) .GT. thetaFreeze ) fwflxFac = dFac | 
| 425 | 
  | 
  | 
C     a few abbreviations | 
| 426 | 
  | 
  | 
            eps1 = rUnit2mass*HeatCapacity_Cp | 
| 427 | 
  | 
  | 
     &           *shiTransCoeffT(i,j,bi,bj) | 
| 428 | 
  | 
  | 
            eps2 = rUnit2mass*SHELFICElatentHeat | 
| 429 | 
  | 
  | 
     &           *shiTransCoeffS(i,j,bi,bj) | 
| 430 | 
  | 
  | 
            eps5 = rUnit2mass*HeatCapacity_Cp | 
| 431 | 
  | 
  | 
     &           *shiTransCoeffS(i,j,bi,bj) | 
| 432 | 
  | 
  | 
 | 
| 433 | 
  | 
  | 
C     solve quadratic equation for salinity at shelfice-ocean interface | 
| 434 | 
  | 
  | 
C     note: this part of the code is not very intuitive as it involves | 
| 435 | 
  | 
  | 
C     many arbitrary abbreviations that were introduced to derive the | 
| 436 | 
  | 
  | 
C     correct form of the quadratic equation for salinity. The abbreviations | 
| 437 | 
  | 
  | 
C     only make sense in connection with my notes on this (M.Losch) | 
| 438 | 
  | 
  | 
C | 
| 439 | 
  | 
  | 
C     eps3a was introduced as a constant variant of eps3 to avoid AD of | 
| 440 | 
  | 
  | 
C     code of typ (pLoc-const)/pLoc | 
| 441 | 
  | 
  | 
            eps3a = rhoShelfIce*SHELFICEheatCapacity_Cp | 
| 442 | 
  | 
  | 
     &           * SHELFICEkappa *  ( 1. _d 0 - dFac ) | 
| 443 | 
  | 
  | 
            eps3 = eps3a/pLoc(I,J) | 
| 444 | 
  | 
  | 
            eps4 = b*pLoc(I,J) + c0 | 
| 445 | 
  | 
  | 
            eps6 = eps4 - tLoc(I,J) | 
| 446 | 
  | 
  | 
            eps7 = eps4 - SHELFICEthetaSurface | 
| 447 | 
  | 
  | 
            eps8 = rUnit2mass*SHELFICEheatCapacity_Cp | 
| 448 | 
  | 
  | 
     &           *shiTransCoeffS(i,j,bi,bj) * fwflxFac | 
| 449 | 
  | 
  | 
            aqe = a0  *(eps1+eps3-eps8) | 
| 450 | 
  | 
  | 
            recip_aqe = 0. _d 0 | 
| 451 | 
  | 
  | 
            IF ( aqe .NE. 0. _d 0 ) recip_aqe = 0.5 _d 0/aqe | 
| 452 | 
  | 
  | 
c           bqe = eps1*eps6 + eps3*eps7 - eps2 | 
| 453 | 
  | 
  | 
            bqe = eps1*eps6 | 
| 454 | 
  | 
  | 
     &           + eps3a*( b | 
| 455 | 
  | 
  | 
     &                   + ( c0 - SHELFICEthetaSurface )/pLoc(I,J) ) | 
| 456 | 
  | 
  | 
     &           - eps2 | 
| 457 | 
  | 
  | 
     &           + eps8*( a0*sLoc(I,J) - eps7 ) | 
| 458 | 
  | 
  | 
            cqe = ( eps2 + eps8*eps7 )*sLoc(I,J) | 
| 459 | 
  | 
  | 
            discrim = bqe*bqe - 4. _d 0*aqe*cqe | 
| 460 | 
  | 
  | 
#undef ALLOW_SHELFICE_DEBUG | 
| 461 | 
  | 
  | 
#ifdef ALLOW_SHELFICE_DEBUG | 
| 462 | 
  | 
  | 
            IF ( discrim .LT. 0. _d 0 ) THEN | 
| 463 | 
  | 
  | 
             print *, 'ml-shelfice: discrim = ', discrim,aqe,bqe,cqe | 
| 464 | 
  | 
  | 
             print *, 'ml-shelfice: pLoc    = ', pLoc(I,J) | 
| 465 | 
  | 
  | 
             print *, 'ml-shelfice: tLoc    = ', tLoc(I,J) | 
| 466 | 
  | 
  | 
             print *, 'ml-shelfice: sLoc    = ', sLoc(I,J) | 
| 467 | 
  | 
  | 
             print *, 'ml-shelfice: tsurface= ', | 
| 468 | 
  | 
  | 
     &            SHELFICEthetaSurface | 
| 469 | 
  | 
  | 
             print *, 'ml-shelfice: eps1    = ', eps1 | 
| 470 | 
  | 
  | 
             print *, 'ml-shelfice: eps2    = ', eps2 | 
| 471 | 
  | 
  | 
             print *, 'ml-shelfice: eps3    = ', eps3 | 
| 472 | 
  | 
  | 
             print *, 'ml-shelfice: eps4    = ', eps4 | 
| 473 | 
  | 
  | 
             print *, 'ml-shelfice: eps5    = ', eps5 | 
| 474 | 
  | 
  | 
             print *, 'ml-shelfice: eps6    = ', eps6 | 
| 475 | 
  | 
  | 
             print *, 'ml-shelfice: eps7    = ', eps7 | 
| 476 | 
  | 
  | 
             print *, 'ml-shelfice: eps8    = ', eps8 | 
| 477 | 
  | 
  | 
             print *, 'ml-shelfice: rU2mass = ', rUnit2mass | 
| 478 | 
  | 
  | 
             print *, 'ml-shelfice: rhoIce  = ', rhoShelfIce | 
| 479 | 
  | 
  | 
             print *, 'ml-shelfice: cFac    = ', cFac | 
| 480 | 
  | 
  | 
             print *, 'ml-shelfice: Cp_W    = ', HeatCapacity_Cp | 
| 481 | 
  | 
  | 
             print *, 'ml-shelfice: Cp_I    = ', | 
| 482 | 
  | 
  | 
     &            SHELFICEHeatCapacity_Cp | 
| 483 | 
  | 
  | 
             print *, 'ml-shelfice: gammaT  = ', | 
| 484 | 
  | 
  | 
     &            SHELFICEheatTransCoeff | 
| 485 | 
  | 
  | 
             print *, 'ml-shelfice: gammaS  = ', | 
| 486 | 
  | 
  | 
     &            SHELFICEsaltTransCoeff | 
| 487 | 
  | 
  | 
             print *, 'ml-shelfice: lat.heat= ', | 
| 488 | 
  | 
  | 
     &            SHELFICElatentHeat | 
| 489 | 
  | 
  | 
             STOP 'ABNORMAL END in S/R SHELFICE_THERMODYNAMICS' | 
| 490 | 
  | 
  | 
            ENDIF | 
| 491 | 
  | 
  | 
#endif /* ALLOW_SHELFICE_DEBUG */ | 
| 492 | 
  | 
  | 
            saltFreeze = (- bqe - SQRT(discrim))*recip_aqe | 
| 493 | 
  | 
  | 
            IF ( saltFreeze .LT. 0. _d 0 ) | 
| 494 | 
  | 
  | 
     &           saltFreeze = (- bqe + SQRT(discrim))*recip_aqe | 
| 495 | 
  | 
  | 
            thetaFreeze = a0*saltFreeze + eps4 | 
| 496 | 
  | 
  | 
C--   upward fresh water flux due to melting (in kg/m^2/s) | 
| 497 | 
  | 
  | 
cph change to identical form | 
| 498 | 
  | 
  | 
cph            freshWaterFlux = rUnit2mass | 
| 499 | 
  | 
  | 
cph     &           * shiTransCoeffS(i,j,bi,bj) | 
| 500 | 
  | 
  | 
cph     &           * ( saltFreeze - sLoc(I,J) ) / saltFreeze | 
| 501 | 
  | 
  | 
            freshWaterFlux = rUnit2mass | 
| 502 | 
  | 
  | 
     &           * shiTransCoeffS(i,j,bi,bj) | 
| 503 | 
  | 
  | 
     &           * ( 1. _d 0 - sLoc(I,J) / saltFreeze ) | 
| 504 | 
  | 
  | 
#ifdef ALLOW_SHIFWFLX_CONTROL | 
| 505 | 
  | 
  | 
     &           + xx_shifwflx_loc(I,J,bi,bj) | 
| 506 | 
  | 
  | 
#endif /*  ALLOW_SHIFWFLX_CONTROL */ | 
| 507 | 
  | 
  | 
C--   Calculate the upward heat and fresh water fluxes; | 
| 508 | 
  | 
  | 
C--   MITgcm sign conventions: downward (negative) fresh water flux | 
| 509 | 
  | 
  | 
C--   implies melting and due to upward (positive) heat flux | 
| 510 | 
  | 
  | 
            shelfIceHeatFlux(I,J,bi,bj) = | 
| 511 | 
  | 
  | 
     &           ( eps3 | 
| 512 | 
  | 
  | 
     &           - freshWaterFlux*SHELFICEheatCapacity_Cp*fwflxFac ) | 
| 513 | 
  | 
  | 
     &           * ( thetaFreeze - SHELFICEthetaSurface ) | 
| 514 | 
  | 
  | 
     &           -  cFac*freshWaterFlux*( SHELFICElatentHeat | 
| 515 | 
  | 
  | 
     &             - HeatCapacity_Cp*( thetaFreeze - rFac*tLoc(I,J) ) ) | 
| 516 | 
  | 
  | 
            shelfIceFreshWaterFlux(I,J,bi,bj) = freshWaterFlux | 
| 517 | 
  | 
  | 
C--   compute surface tendencies | 
| 518 | 
  | 
  | 
            shelficeForcingT(i,j,bi,bj) = | 
| 519 | 
  | 
  | 
     &           ( shiTransCoeffT(i,j,bi,bj) | 
| 520 | 
  | 
  | 
     &           - cFac*shelfIceFreshWaterFlux(I,J,bi,bj)*mass2rUnit ) | 
| 521 | 
  | 
  | 
     &           * ( thetaFreeze - tLoc(I,J) ) | 
| 522 | 
  | 
  | 
            shelficeForcingS(i,j,bi,bj) = | 
| 523 | 
  | 
  | 
     &           ( shiTransCoeffS(i,j,bi,bj) | 
| 524 | 
  | 
  | 
     &           - cFac*shelfIceFreshWaterFlux(I,J,bi,bj)*mass2rUnit ) | 
| 525 | 
  | 
  | 
     &           * ( saltFreeze - sLoc(I,J) ) | 
| 526 | 
  | 
  | 
           ELSE | 
| 527 | 
  | 
  | 
            shelfIceHeatFlux      (I,J,bi,bj) = 0. _d 0 | 
| 528 | 
  | 
  | 
            shelfIceFreshWaterFlux(I,J,bi,bj) = 0. _d 0 | 
| 529 | 
  | 
  | 
            shelficeForcingT      (I,J,bi,bj) = 0. _d 0 | 
| 530 | 
  | 
  | 
            shelficeForcingS      (I,J,bi,bj) = 0. _d 0 | 
| 531 | 
  | 
  | 
           ENDIF | 
| 532 | 
  | 
  | 
          ENDDO | 
| 533 | 
  | 
  | 
         ENDDO | 
| 534 | 
  | 
  | 
        ENDIF | 
| 535 | 
  | 
  | 
C     endif (not) useISOMIPTD | 
| 536 | 
  | 
  | 
       ENDDO | 
| 537 | 
  | 
  | 
      ENDDO | 
| 538 | 
  | 
  | 
 | 
| 539 | 
dgoldberg | 
1.3 | 
      IF (SHELFICEMassStepping) THEN | 
| 540 | 
dgoldberg | 
1.1 | 
       CALL SHELFICE_STEP_ICEMASS( myTime, myIter, myThid ) | 
| 541 | 
  | 
  | 
      ENDIF | 
| 542 | 
  | 
  | 
 | 
| 543 | 
  | 
  | 
C--  Calculate new loading anomaly (in case the ice-shelf mass was updated) | 
| 544 | 
  | 
  | 
#ifndef ALLOW_AUTODIFF | 
| 545 | 
  | 
  | 
c     IF ( SHELFICEloadAnomalyFile .EQ. ' ' ) THEN | 
| 546 | 
  | 
  | 
       DO bj = myByLo(myThid), myByHi(myThid) | 
| 547 | 
  | 
  | 
        DO bi = myBxLo(myThid), myBxHi(myThid) | 
| 548 | 
  | 
  | 
         DO j = 1-OLy, sNy+OLy | 
| 549 | 
  | 
  | 
          DO i = 1-OLx, sNx+OLx | 
| 550 | 
  | 
  | 
           shelficeLoadAnomaly(i,j,bi,bj) = gravity | 
| 551 | 
  | 
  | 
     &      *( shelficeMass(i,j,bi,bj) + rhoConst*Ro_surf(i,j,bi,bj) ) | 
| 552 | 
  | 
  | 
          ENDDO | 
| 553 | 
  | 
  | 
         ENDDO | 
| 554 | 
  | 
  | 
        ENDDO | 
| 555 | 
  | 
  | 
       ENDDO | 
| 556 | 
  | 
  | 
c     ENDIF | 
| 557 | 
  | 
  | 
#endif /* ndef ALLOW_AUTODIFF */ | 
| 558 | 
dgoldberg | 
1.2 | 
 | 
| 559 | 
dgoldberg | 
1.1 | 
#ifdef ALLOW_DIAGNOSTICS | 
| 560 | 
  | 
  | 
      IF ( useDiagnostics ) THEN | 
| 561 | 
  | 
  | 
       CALL DIAGNOSTICS_FILL_RS(shelfIceFreshWaterFlux,'SHIfwFlx', | 
| 562 | 
  | 
  | 
     &      0,1,0,1,1,myThid) | 
| 563 | 
  | 
  | 
       CALL DIAGNOSTICS_FILL_RS(shelfIceHeatFlux,      'SHIhtFlx', | 
| 564 | 
  | 
  | 
     &      0,1,0,1,1,myThid) | 
| 565 | 
  | 
  | 
C     SHIForcT (Ice shelf forcing for theta [W/m2], >0 increases theta) | 
| 566 | 
  | 
  | 
       tmpFac = HeatCapacity_Cp*rUnit2mass | 
| 567 | 
  | 
  | 
       CALL DIAGNOSTICS_SCALE_FILL(shelficeForcingT,tmpFac,1, | 
| 568 | 
  | 
  | 
     &      'SHIForcT',0,1,0,1,1,myThid) | 
| 569 | 
  | 
  | 
C     SHIForcS (Ice shelf forcing for salt [g/m2/s], >0 increases salt) | 
| 570 | 
  | 
  | 
       tmpFac = rUnit2mass | 
| 571 | 
  | 
  | 
       CALL DIAGNOSTICS_SCALE_FILL(shelficeForcingS,tmpFac,1, | 
| 572 | 
  | 
  | 
     &      'SHIForcS',0,1,0,1,1,myThid) | 
| 573 | 
  | 
  | 
C     Transfer coefficients | 
| 574 | 
  | 
  | 
       CALL DIAGNOSTICS_FILL(shiTransCoeffT,'SHIgammT', | 
| 575 | 
  | 
  | 
     &      0,1,0,1,1,myThid) | 
| 576 | 
  | 
  | 
       CALL DIAGNOSTICS_FILL(shiTransCoeffS,'SHIgammS', | 
| 577 | 
  | 
  | 
     &      0,1,0,1,1,myThid) | 
| 578 | 
dgoldberg | 
1.3 | 
C     Friction velocity | 
| 579 | 
  | 
  | 
#ifdef SHI_ALLOW_GAMMAFRICT | 
| 580 | 
  | 
  | 
       IF ( SHELFICEuseGammaFrict ) | 
| 581 | 
  | 
  | 
     &  CALL DIAGNOSTICS_FILL(uStarDiag,'SHIuStar',0,1,0,1,1,myThid) | 
| 582 | 
  | 
  | 
#endif /* SHI_ALLOW_GAMMAFRICT */ | 
| 583 | 
dgoldberg | 
1.1 | 
      ENDIF | 
| 584 | 
  | 
  | 
#endif /* ALLOW_DIAGNOSTICS */ | 
| 585 | 
  | 
  | 
 | 
| 586 | 
  | 
  | 
#endif /* ALLOW_SHELFICE */ | 
| 587 | 
  | 
  | 
      RETURN | 
| 588 | 
  | 
  | 
      END |