Back to home page

MITgcm

 
 

    


File indexing completed on 2026-05-05 05:09:01 UTC

view on githubraw file Latest commit 3f0f10fc on 2026-05-04 14:55:37 UTC
037351a1a6 Mart*0001 #include "SEAICE_OPTIONS.h"
fec75090d3 Jean*0002 #ifdef ALLOW_OBCS
                0003 # include "OBCS_OPTIONS.h"
                0004 #else
                0005 # define OBCS_UVICE_OLD
                0006 #endif
037351a1a6 Mart*0007 
fec75090d3 Jean*0008 CBOP
                0009 C     !ROUTINE: SEAICE_CALC_STRAINRATES
                0010 C     !INTERFACE:
b4949dd6db Jean*0011       SUBROUTINE SEAICE_CALC_STRAINRATES(
037351a1a6 Mart*0012      I     uFld, vFld,
7bdcfa8e6c Mart*0013      O     e11Loc, e22Loc, e12Loc,
2e75568507 Mart*0014      I     iStep, myTime, myIter, myThid )
fec75090d3 Jean*0015 
                0016 C     !DESCRIPTION: \bv
                0017 C     *==========================================================*
                0018 C     | SUBROUTINE  SEAICE_CALC_STRAINRATES
                0019 C     | o compute strain rates from ice velocities
                0020 C     *==========================================================*
                0021 C     | written by Martin Losch, Apr 2007
                0022 C     *==========================================================*
                0023 C     \ev
                0024 
                0025 C     !USES:
037351a1a6 Mart*0026       IMPLICIT NONE
                0027 
                0028 C     === Global variables ===
                0029 #include "SIZE.h"
                0030 #include "EEPARAMS.h"
                0031 #include "PARAMS.h"
                0032 #include "GRID.h"
03c669d1ab Jean*0033 #include "SEAICE_SIZE.h"
037351a1a6 Mart*0034 #include "SEAICE_PARAMS.h"
3f0f10fc37 Mart*0035 #include "SEAICE_GRID.h"
694d703a74 Mart*0036 #include "SEAICE.h"
037351a1a6 Mart*0037 
fec75090d3 Jean*0038 C     !INPUT/OUTPUT PARAMETERS:
037351a1a6 Mart*0039 C     === Routine arguments ===
fec75090d3 Jean*0040 C     uFld   :: ice velocity, u-component
                0041 C     vFld   :: ice velocity, v-component
                0042 C     e11Loc :: strain rate tensor, component 1,1
                0043 C     e22Loc :: strain rate tensor, component 2,2
                0044 C     e12Loc :: strain rate tensor, component 1,2
b4949dd6db Jean*0045 C     iStep  :: Sub-time-step number
                0046 C     myTime :: Simulation time
                0047 C     myIter :: Simulation timestep number
                0048 C     myThid :: My Thread Id. number
03c669d1ab Jean*0049       _RL uFld   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
                0050       _RL vFld   (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
7bdcfa8e6c Mart*0051       _RL e11Loc (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
                0052       _RL e22Loc (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
                0053       _RL e12Loc (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
fec75090d3 Jean*0054       INTEGER iStep
                0055       _RL     myTime
                0056       INTEGER myIter
                0057       INTEGER myThid
                0058 CEOP
037351a1a6 Mart*0059 
                0060 #ifdef SEAICE_CGRID
fec75090d3 Jean*0061 C     !LOCAL VARIABLES:
037351a1a6 Mart*0062 C     === Local variables ===
fec75090d3 Jean*0063 C     i,j,bi,bj :: Loop counters
037351a1a6 Mart*0064       INTEGER i, j, bi, bj
fec75090d3 Jean*0065 C     hFacU, hFacV :: determine the no-slip boundary condition
694d703a74 Mart*0066       _RS hFacU, hFacV, noSlipFac
5dac41bc68 Mart*0067       _RL third
                0068       PARAMETER ( third = 0.333333333333333333333333333 _d 0 )
03cd49feda Mart*0069 C     auxillary variables that help writing code that
                0070 C     vectorizes even after TAFization
                0071       _RL dudx (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
                0072       _RL dvdy (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
                0073       _RL dudy (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
                0074       _RL dvdx (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
                0075       _RL uave (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
                0076       _RL vave (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
ba20a6318c Mart*0077 
694d703a74 Mart*0078       noSlipFac = 0. _d 0
                0079       IF ( SEAICE_no_slip ) noSlipFac = 1. _d 0
4d92a76442 Mart*0080 C     in order repoduce results before fixing a bug in r1.20 comment out
                0081 C     the following line
                0082 CML      IF ( SEAICE_no_slip ) noSlipFac = 2. _d 0
037351a1a6 Mart*0083 C
694d703a74 Mart*0084       DO bj=myByLo(myThid),myByHi(myThid)
                0085        DO bi=myBxLo(myThid),myBxHi(myThid)
03cd49feda Mart*0086 C     abbreviations on C-points, need to do them in separate loops
                0087 C     for vectorization
03c669d1ab Jean*0088         DO j=1-OLy,sNy+OLy-1
                0089          DO i=1-OLx,sNx+OLx-1
fec75090d3 Jean*0090           dudx(i,j) = _recip_dxF(i,j,bi,bj) *
                0091      &         (uFld(i+1,j,bi,bj)-uFld(i,j,bi,bj))
                0092           uave(i,j) = 0.5 _d 0 * (uFld(i,j,bi,bj)+uFld(i+1,j,bi,bj))
03cd49feda Mart*0093          ENDDO
                0094         ENDDO
03c669d1ab Jean*0095         DO j=1-OLy,sNy+OLy-1
                0096          DO i=1-OLx,sNx+OLx-1
fec75090d3 Jean*0097           dvdy(i,j) = _recip_dyF(i,j,bi,bj) *
                0098      &         (vFld(i,j+1,bi,bj)-vFld(i,j,bi,bj))
                0099           vave(i,j) = 0.5 _d 0 * (vFld(i,j,bi,bj)+vFld(i,j+1,bi,bj))
03cd49feda Mart*0100          ENDDO
                0101         ENDDO
                0102 C     evaluate strain rates at C-points
03c669d1ab Jean*0103         DO j=1-OLy,sNy+OLy-1
                0104          DO i=1-OLx,sNx+OLx-1
fec75090d3 Jean*0105           e11Loc(i,j,bi,bj) = dudx(i,j) + vave(i,j) * k2AtC(i,j,bi,bj)
                0106           e22Loc(i,j,bi,bj) = dvdy(i,j) + uave(i,j) * k1AtC(i,j,bi,bj)
                0107          ENDDO
                0108         ENDDO
                0109 #ifndef OBCS_UVICE_OLD
                0110 C--     for OBCS: assume no gradient beyong OB
03c669d1ab Jean*0111         DO j=1-OLy,sNy+OLy-1
                0112          DO i=1-OLx,sNx+OLx-1
fec75090d3 Jean*0113           e11Loc(i,j,bi,bj) = e11Loc(i,j,bi,bj)*maskInC(i,j,bi,bj)
                0114           e22Loc(i,j,bi,bj) = e22Loc(i,j,bi,bj)*maskInC(i,j,bi,bj)
694d703a74 Mart*0115          ENDDO
                0116         ENDDO
fec75090d3 Jean*0117 #endif /* OBCS_UVICE_OLD */
                0118 
03cd49feda Mart*0119 C     abbreviations at Z-points, need to do them in separate loops
                0120 C     for vectorization
03c669d1ab Jean*0121         DO j=1-OLy+1,sNy+OLy
                0122          DO i=1-OLx+1,sNx+OLx
fec75090d3 Jean*0123           dudy(i,j) = ( uFld(i,j,bi,bj) - uFld(i  ,j-1,bi,bj) )
                0124      &         * _recip_dyU(i,j,bi,bj)
                0125           uave(i,j) = 0.5 _d 0 * (uFld(i,j,bi,bj)+uFld(i  ,j-1,bi,bj))
03cd49feda Mart*0126          ENDDO
                0127         ENDDO
03c669d1ab Jean*0128         DO j=1-OLy+1,sNy+OLy
                0129          DO i=1-OLx+1,sNx+OLx
fec75090d3 Jean*0130           dvdx(i,j) = ( vFld(i,j,bi,bj) - vFld(i-1,j  ,bi,bj) )
                0131      &         * _recip_dxV(i,j,bi,bj)
                0132           vave(i,j) = 0.5 _d 0 * (vFld(i,j,bi,bj)+vFld(i-1,j  ,bi,bj))
03cd49feda Mart*0133          ENDDO
                0134         ENDDO
                0135 C     evaluate strain rates at Z-points
03c669d1ab Jean*0136         DO j=1-OLy+1,sNy+OLy
                0137          DO i=1-OLx+1,sNx+OLx
ec0d7df165 Mart*0138           hFacU = SIMaskU(i,j,bi,bj) - SIMaskU(i,j-1,bi,bj)
                0139           hFacV = SIMaskV(i,j,bi,bj) - SIMaskV(i-1,j,bi,bj)
fec75090d3 Jean*0140           e12Loc(i,j,bi,bj) = 0.5 _d 0 * (
                0141      &         dudy(i,j) + dvdx(i,j)
                0142      &         - k1AtZ(i,j,bi,bj) * vave(i,j)
                0143      &         - k2AtZ(i,j,bi,bj) * uave(i,j)
694d703a74 Mart*0144      &         )
ec0d7df165 Mart*0145      &         *HEFFM(i  ,j  ,bi,bj)*HEFFM(i-1,j  ,bi,bj)
                0146      &         *HEFFM(i  ,j-1,bi,bj)*HEFFM(i-1,j-1,bi,bj)
4d92a76442 Mart*0147      &         + noSlipFac * (
fec75090d3 Jean*0148      &           2.0 _d 0 * uave(i,j) * _recip_dyU(i,j,bi,bj) * hFacU
                0149      &         + 2.0 _d 0 * vave(i,j) * _recip_dxV(i,j,bi,bj) * hFacV
694d703a74 Mart*0150      &         )
                0151 C     no slip at the boundary implies u(j)+u(j-1)=0 and v(i)+v(i-1)=0
                0152 C     accross the boundary; this is already accomplished by masking so
                0153 C     that the following lines are not necessary
fec75090d3 Jean*0154 c$$$     &         - hFacV * k1AtZ(i,j,bi,bj) * vave(i,j)
                0155 c$$$     &         - hFacU * k2AtZ(i,j,bi,bj) * uave(i,j)
694d703a74 Mart*0156          ENDDO
                0157         ENDDO
5dac41bc68 Mart*0158         IF ( SEAICE_no_slip .AND. SEAICE_2ndOrderBC ) THEN
                0159          DO j=1-OLy+2,sNy+OLy-1
                0160           DO i=1-OLx+2,sNx+OLx-1
ec0d7df165 Mart*0161            hFacU = (SIMaskU(i,j,bi,bj) - SIMaskU(i,j-1,bi,bj))*third
                0162            hFacV = (SIMaskV(i,j,bi,bj) - SIMaskV(i-1,j,bi,bj))*third
                0163            hFacU = hFacU*( SIMaskU(i,j-2,bi,bj)*SIMaskU(i,j-1,bi,bj)
                0164      &                   + SIMaskU(i,j+1,bi,bj)*SIMaskU(i,j,  bi,bj) )
                0165            hFacV = hFacV*( SIMaskV(i-2,j,bi,bj)*SIMaskV(i-1,j,bi,bj)
                0166      &                   + SIMaskV(i+1,j,bi,bj)*SIMaskV(i  ,j,bi,bj) )
5dac41bc68 Mart*0167 C     right hand sided dv/dx = (9*v(i,j)-v(i+1,j))/(4*dxv(i,j)-dxv(i+1,j))
4e4ad91a39 Jean*0168 C     according to a Taylor expansion to 2nd order. We assume that dxv
5dac41bc68 Mart*0169 C     varies very slowly, so that the denominator simplifies to 3*dxv(i,j),
                0170 C     then dv/dx = (6*v(i,j)+3*v(i,j)-v(i+1,j))/(3*dxv(i,j))
                0171 C                = 2*v(i,j)/dxv(i,j) + (3*v(i,j)-v(i+1,j))/(3*dxv(i,j))
                0172 C     the left hand sided dv/dx is analogously
                0173 C                = - 2*v(i-1,j)/dxv(i,j) - (3*v(i-1,j)-v(i-2,j))/(3*dxv(i,j))
                0174 C     the first term is the first order part, which is already added.
4e4ad91a39 Jean*0175 C     For e12 we only need 0.5 of this gradient and vave = is either
5dac41bc68 Mart*0176 C     0.5*v(i,j) or 0.5*v(i-1,j) near the boundary so that we need an
                0177 C     extra factor of 2. This explains the six. du/dy is analogous.
                0178 C     The masking is ugly, but hopefully effective.
                0179            e12Loc(i,j,bi,bj) = e12Loc(i,j,bi,bj) + 0.5 _d 0 * (
4e4ad91a39 Jean*0180      &            _recip_dyU(i,j,bi,bj) * ( 6.0 _d 0 * uave(i,j)
ec0d7df165 Mart*0181      &          - uFld(i,j-2,bi,bj)*SIMaskU(i,j-1,bi,bj)
                0182      &          - uFld(i,j+1,bi,bj)*SIMaskU(i,j  ,bi,bj) ) * hFacU
5dac41bc68 Mart*0183      &          + _recip_dxV(i,j,bi,bj) * ( 6.0 _d 0 * vave(i,j)
ec0d7df165 Mart*0184      &          - vFld(i-2,j,bi,bj)*SIMaskV(i-1,j,bi,bj)
                0185      &          - vFld(i+1,j,bi,bj)*SIMaskV(i  ,j,bi,bj) ) * hFacV
5dac41bc68 Mart*0186      &          )
                0187           ENDDO
                0188          ENDDO
                0189         ENDIF
694d703a74 Mart*0190        ENDDO
                0191       ENDDO
4f95e6bec9 Gael*0192 
4e4ad91a39 Jean*0193 #ifdef ALLOW_AUTODIFF
4f95e6bec9 Gael*0194 #ifdef SEAICE_DYN_STABLE_ADJOINT
                0195 cgf zero out adjoint fields to stabilize pkg/seaice dyna. adjoint
                0196       CALL ZERO_ADJ( 1, e11Loc, myThid)
                0197       CALL ZERO_ADJ( 1, e12Loc, myThid)
                0198       CALL ZERO_ADJ( 1, e22Loc, myThid)
                0199 #endif
4e4ad91a39 Jean*0200 #endif /* ALLOW_AUTODIFF */
4f95e6bec9 Gael*0201 
037351a1a6 Mart*0202 #endif /* SEAICE_CGRID */
                0203       RETURN
                0204       END