2 |
C $Name$ |
C $Name$ |
3 |
|
|
4 |
#include "SEAICE_OPTIONS.h" |
#include "SEAICE_OPTIONS.h" |
5 |
|
#ifdef ALLOW_OBCS |
6 |
|
# include "OBCS_OPTIONS.h" |
7 |
|
#else |
8 |
|
# define OBCS_UVICE_OLD |
9 |
|
#endif |
10 |
|
|
11 |
CStartOfInterface |
CBOP |
12 |
SUBROUTINE SEAICE_CALC_STRAINRATES( |
C !ROUTINE: SEAICE_CALC_STRAINRATES |
13 |
|
C !INTERFACE: |
14 |
|
SUBROUTINE SEAICE_CALC_STRAINRATES( |
15 |
I uFld, vFld, |
I uFld, vFld, |
16 |
O e11, e22, e12, |
O e11Loc, e22Loc, e12Loc, |
17 |
I myThid ) |
I iStep, myTime, myIter, myThid ) |
18 |
C /==========================================================\ |
|
19 |
C | SUBROUTINE SEAICE_CALC_STRAINRATES | |
C !DESCRIPTION: \bv |
20 |
C | o compute strain rates from ice velocities | |
C *==========================================================* |
21 |
C |==========================================================| |
C | SUBROUTINE SEAICE_CALC_STRAINRATES |
22 |
C | written by Martin Losch, Apr 2007 | |
C | o compute strain rates from ice velocities |
23 |
C \==========================================================/ |
C *==========================================================* |
24 |
|
C | written by Martin Losch, Apr 2007 |
25 |
|
C *==========================================================* |
26 |
|
C \ev |
27 |
|
|
28 |
|
C !USES: |
29 |
IMPLICIT NONE |
IMPLICIT NONE |
30 |
|
|
31 |
C === Global variables === |
C === Global variables === |
33 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
34 |
#include "PARAMS.h" |
#include "PARAMS.h" |
35 |
#include "GRID.h" |
#include "GRID.h" |
36 |
|
#include "SEAICE_SIZE.h" |
37 |
#include "SEAICE_PARAMS.h" |
#include "SEAICE_PARAMS.h" |
38 |
|
#include "SEAICE.h" |
39 |
|
|
40 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
41 |
# include "tamc.h" |
# include "tamc.h" |
42 |
#endif |
#endif |
43 |
|
|
44 |
|
C !INPUT/OUTPUT PARAMETERS: |
45 |
C === Routine arguments === |
C === Routine arguments === |
46 |
C myThid - Thread no. that called this routine. |
C uFld :: ice velocity, u-component |
47 |
|
C vFld :: ice velocity, v-component |
48 |
|
C e11Loc :: strain rate tensor, component 1,1 |
49 |
|
C e22Loc :: strain rate tensor, component 2,2 |
50 |
|
C e12Loc :: strain rate tensor, component 1,2 |
51 |
|
C iStep :: Sub-time-step number |
52 |
|
C myTime :: Simulation time |
53 |
|
C myIter :: Simulation timestep number |
54 |
|
C myThid :: My Thread Id. number |
55 |
|
_RL uFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
56 |
|
_RL vFld (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
57 |
|
_RL e11Loc (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
58 |
|
_RL e22Loc (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
59 |
|
_RL e12Loc (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
60 |
|
INTEGER iStep |
61 |
|
_RL myTime |
62 |
|
INTEGER myIter |
63 |
INTEGER myThid |
INTEGER myThid |
64 |
C ice velocities |
CEOP |
|
_RL uFld(1-Olx:sNx+Olx,1-Oly:sNy+Oly,nSx,nSy) |
|
|
_RL vFld(1-Olx:sNx+Olx,1-Oly:sNy+Oly,nSx,nSy) |
|
|
C strain rate tensor |
|
|
_RL e11 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
|
|
_RL e22 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
|
|
_RL e12 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
|
|
CEndOfInterface |
|
65 |
|
|
66 |
#ifdef SEAICE_CGRID |
#ifdef SEAICE_CGRID |
67 |
#ifdef SEAICE_ALLOW_DYNAMICS |
#ifdef SEAICE_ALLOW_DYNAMICS |
68 |
|
C !LOCAL VARIABLES: |
69 |
C === Local variables === |
C === Local variables === |
70 |
C i,j,bi,bj - Loop counters |
C i,j,bi,bj :: Loop counters |
71 |
INTEGER i, j, bi, bj |
INTEGER i, j, bi, bj |
72 |
C hFacU, hFacV - determine the no-slip boundary condition |
C hFacU, hFacV :: determine the no-slip boundary condition |
73 |
INTEGER k |
INTEGER k |
74 |
_RS hFacU, hFacV |
_RS hFacU, hFacV, noSlipFac |
75 |
|
C auxillary variables that help writing code that |
76 |
|
C vectorizes even after TAFization |
77 |
|
_RL dudx (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
78 |
|
_RL dvdy (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
79 |
|
_RL dudy (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
80 |
|
_RL dvdx (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
81 |
|
_RL uave (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
82 |
|
_RL vave (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
83 |
|
|
84 |
k = 1 |
k = 1 |
85 |
|
noSlipFac = 0. _d 0 |
86 |
|
IF ( SEAICE_no_slip ) noSlipFac = 1. _d 0 |
87 |
|
C in order repoduce results before fixing a bug in r1.20 comment out |
88 |
|
C the following line |
89 |
|
CML IF ( SEAICE_no_slip ) noSlipFac = 2. _d 0 |
90 |
C |
C |
91 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
92 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
93 |
DO j=1-Oly,sNy+Oly-1 |
C abbreviations on C-points, need to do them in separate loops |
94 |
DO i=1-Olx,sNx+Olx-1 |
C for vectorization |
95 |
C evaluate strain rates |
DO j=1-OLy,sNy+OLy-1 |
96 |
e11(I,J,bi,bj) = _recip_dxF(I,J,bi,bj) * |
DO i=1-OLx,sNx+OLx-1 |
97 |
& (uFld(I+1,J,bi,bj)-uFld(I,J,bi,bj)) |
dudx(i,j) = _recip_dxF(i,j,bi,bj) * |
98 |
& -HALF* |
& (uFld(i+1,j,bi,bj)-uFld(i,j,bi,bj)) |
99 |
& (vFld(I,J,bi,bj)+vFld(I,J+1,bi,bj)) |
uave(i,j) = 0.5 _d 0 * (uFld(i,j,bi,bj)+uFld(i+1,j,bi,bj)) |
100 |
& * _tanPhiAtU(I,J,bi,bj)*recip_rSphere |
ENDDO |
101 |
e22(I,J,bi,bj) = _recip_dyF(I,J,bi,bj) * |
ENDDO |
102 |
& (vFld(I,J+1,bi,bj)-vFld(I,J,bi,bj)) |
DO j=1-OLy,sNy+OLy-1 |
103 |
C one metric term is missing |
DO i=1-OLx,sNx+OLx-1 |
104 |
ENDDO |
dvdy(i,j) = _recip_dyF(i,j,bi,bj) * |
105 |
ENDDO |
& (vFld(i,j+1,bi,bj)-vFld(i,j,bi,bj)) |
106 |
DO j=1-Oly+1,sNy+Oly |
vave(i,j) = 0.5 _d 0 * (vFld(i,j,bi,bj)+vFld(i,j+1,bi,bj)) |
107 |
DO i=1-Olx+1,sNx+Olx |
ENDDO |
108 |
e12(I,J,bi,bj) = HALF*( |
ENDDO |
109 |
& (uFld(I ,J ,bi,bj) * _dxC(I ,J ,bi,bj) |
C evaluate strain rates at C-points |
110 |
& -uFld(I ,J-1,bi,bj) * _dxC(I ,J-1,bi,bj) |
DO j=1-OLy,sNy+OLy-1 |
111 |
& +vFld(I ,J ,bi,bj) * _dyC(I ,J ,bi,bj) |
DO i=1-OLx,sNx+OLx-1 |
112 |
& -vFld(I-1,J ,bi,bj) * _dyC(I-1,J ,bi,bj)) |
e11Loc(i,j,bi,bj) = dudx(i,j) + vave(i,j) * k2AtC(i,j,bi,bj) |
113 |
& * recip_rAz(I,J,bi,bj) |
e22Loc(i,j,bi,bj) = dvdy(i,j) + uave(i,j) * k1AtC(i,j,bi,bj) |
114 |
& + |
ENDDO |
115 |
& 0.25 _d 0 * (uFld(I,J,bi,bj)+uFld(I ,J-1,bi,bj)) |
ENDDO |
116 |
& * ( _tanPhiAtU(I,J,bi,bj) + _tanPhiAtU(I,J-1,bi,bj) ) |
#ifndef OBCS_UVICE_OLD |
117 |
& *recip_rSphere |
C-- for OBCS: assume no gradient beyong OB |
118 |
|
DO j=1-OLy,sNy+OLy-1 |
119 |
|
DO i=1-OLx,sNx+OLx-1 |
120 |
|
e11Loc(i,j,bi,bj) = e11Loc(i,j,bi,bj)*maskInC(i,j,bi,bj) |
121 |
|
e22Loc(i,j,bi,bj) = e22Loc(i,j,bi,bj)*maskInC(i,j,bi,bj) |
122 |
|
ENDDO |
123 |
|
ENDDO |
124 |
|
#endif /* OBCS_UVICE_OLD */ |
125 |
|
|
126 |
|
C abbreviations at Z-points, need to do them in separate loops |
127 |
|
C for vectorization |
128 |
|
DO j=1-OLy+1,sNy+OLy |
129 |
|
DO i=1-OLx+1,sNx+OLx |
130 |
|
dudy(i,j) = ( uFld(i,j,bi,bj) - uFld(i ,j-1,bi,bj) ) |
131 |
|
& * _recip_dyU(i,j,bi,bj) |
132 |
|
uave(i,j) = 0.5 _d 0 * (uFld(i,j,bi,bj)+uFld(i ,j-1,bi,bj)) |
133 |
|
ENDDO |
134 |
|
ENDDO |
135 |
|
DO j=1-OLy+1,sNy+OLy |
136 |
|
DO i=1-OLx+1,sNx+OLx |
137 |
|
dvdx(i,j) = ( vFld(i,j,bi,bj) - vFld(i-1,j ,bi,bj) ) |
138 |
|
& * _recip_dxV(i,j,bi,bj) |
139 |
|
vave(i,j) = 0.5 _d 0 * (vFld(i,j,bi,bj)+vFld(i-1,j ,bi,bj)) |
140 |
|
ENDDO |
141 |
|
ENDDO |
142 |
|
C evaluate strain rates at Z-points |
143 |
|
DO j=1-OLy+1,sNy+OLy |
144 |
|
DO i=1-OLx+1,sNx+OLx |
145 |
|
hFacU = _maskW(i,j,k,bi,bj) - _maskW(i,j-1,k,bi,bj) |
146 |
|
hFacV = _maskS(i,j,k,bi,bj) - _maskS(i-1,j,k,bi,bj) |
147 |
|
e12Loc(i,j,bi,bj) = 0.5 _d 0 * ( |
148 |
|
& dudy(i,j) + dvdx(i,j) |
149 |
|
& - k1AtZ(i,j,bi,bj) * vave(i,j) |
150 |
|
& - k2AtZ(i,j,bi,bj) * uave(i,j) |
151 |
|
& ) |
152 |
|
& *maskC(i ,j ,k,bi,bj)*maskC(i-1,j ,k,bi,bj) |
153 |
|
& *maskC(i ,j-1,k,bi,bj)*maskC(i-1,j-1,k,bi,bj) |
154 |
|
& + noSlipFac * ( |
155 |
|
& 2.0 _d 0 * uave(i,j) * _recip_dyU(i,j,bi,bj) * hFacU |
156 |
|
& + 2.0 _d 0 * vave(i,j) * _recip_dxV(i,j,bi,bj) * hFacV |
157 |
& ) |
& ) |
158 |
& *maskC(I ,J ,k,bi,bj)*maskC(I-1,J ,k,bi,bj) |
C no slip at the boundary implies u(j)+u(j-1)=0 and v(i)+v(i-1)=0 |
159 |
& *maskC(I ,J-1,k,bi,bj)*maskC(I-1,J-1,k,bi,bj) |
C accross the boundary; this is already accomplished by masking so |
160 |
C one metric term is missing |
C that the following lines are not necessary |
161 |
ENDDO |
c$$$ & - hFacV * k1AtZ(i,j,bi,bj) * vave(i,j) |
162 |
ENDDO |
c$$$ & - hFacU * k2AtZ(i,j,bi,bj) * uave(i,j) |
|
IF ( SEAICE_no_slip ) THEN |
|
|
C no slip boundary conditions apply only to e12 |
|
|
DO j=1-Oly+1,sNy+Oly |
|
|
DO i=1-Olx+1,sNx+Olx |
|
|
hFacU = _maskW(i,j,k,bi,bj) - _maskW(i,j-1,k,bi,bj) |
|
|
hFacV = _maskS(i,j,k,bi,bj) - _maskS(i-1,j,k,bi,bj) |
|
|
|
|
|
e12(I,J,bi,bj) = e12(I,J,bi,bj) |
|
|
& + recip_rAz(i,j,bi,bj) * |
|
|
& ( hFacU * ( _dxC(i,j ,bi,bj)*uFld(i,j ,bi,bj) |
|
|
& + _dxC(i,j-1,bi,bj)*uFld(i,j-1,bi,bj) ) |
|
|
& + hFacV * ( _dyC(i ,j,bi,bj)*vFld(i ,j,bi,bj) |
|
|
& + _dyC(i-1,j,bi,bj)*vFld(i-1,j,bi,bj) ) ) |
|
|
& - hFacU |
|
|
& * 0.25 _d 0 * (uFld(I,J,bi,bj)+uFld(I ,J-1,bi,bj)) |
|
|
& * ( _tanPhiAtU(I,J,bi,bj) + _tanPhiAtU(I,J-1,bi,bj) ) |
|
|
& *recip_rSphere |
|
|
C one metric term is missing |
|
|
ENDDO |
|
163 |
ENDDO |
ENDDO |
164 |
|
ENDDO |
165 |
|
|
|
ENDIF |
|
166 |
ENDDO |
ENDDO |
167 |
ENDDO |
ENDDO |
168 |
|
|
169 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
170 |
|
#ifdef SEAICE_DYN_STABLE_ADJOINT |
171 |
|
cgf zero out adjoint fields to stabilize pkg/seaice dyna. adjoint |
172 |
|
CALL ZERO_ADJ( 1, e11Loc, myThid) |
173 |
|
CALL ZERO_ADJ( 1, e12Loc, myThid) |
174 |
|
CALL ZERO_ADJ( 1, e22Loc, myThid) |
175 |
|
#endif |
176 |
|
#endif /* ALLOW_AUTODIFF_TAMC */ |
177 |
|
|
178 |
#endif /* SEAICE_ALLOW_DYNAMICS */ |
#endif /* SEAICE_ALLOW_DYNAMICS */ |
179 |
#endif /* SEAICE_CGRID */ |
#endif /* SEAICE_CGRID */ |
180 |
RETURN |
RETURN |