Back to home page

MITgcm

 
 

    


File indexing completed on 2023-08-04 05:10:43 UTC

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