1 |
C $Header: /u/gcmpack/MITgcm/pkg/seaice/seaice_calc_residual.F,v 1.3 2012/11/09 14:03:10 mlosch Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "SEAICE_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: SEAICE_CALC_RESIDUAL |
8 |
C !INTERFACE: |
9 |
SUBROUTINE SEAICE_CALC_RESIDUAL( |
10 |
I uIceLoc, vIceLoc, |
11 |
O uIceRes, vIceRes, |
12 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
13 |
|
14 |
C !DESCRIPTION: \bv |
15 |
C *==========================================================* |
16 |
C | SUBROUTINE SEAICE_CALC_RESIDUAL |
17 |
C | o For Jacobian-free Newton-Krylov solver compute |
18 |
C | the residual of the momentum equations |
19 |
C *==========================================================* |
20 |
C | written by Martin Losch, Oct 2012 |
21 |
C *==========================================================* |
22 |
C \ev |
23 |
|
24 |
C !USES: |
25 |
IMPLICIT NONE |
26 |
|
27 |
C === Global variables === |
28 |
#include "SIZE.h" |
29 |
#include "EEPARAMS.h" |
30 |
#include "SEAICE_SIZE.h" |
31 |
#include "SEAICE.h" |
32 |
|
33 |
C !INPUT/OUTPUT PARAMETERS: |
34 |
C === Routine arguments === |
35 |
C myTime :: Simulation time |
36 |
C myIter :: Simulation timestep number |
37 |
C myThid :: my Thread Id. number |
38 |
C newtonIter :: current iterate of Newton iteration |
39 |
C krylovIter :: current iterate of Krylov iteration |
40 |
_RL myTime |
41 |
INTEGER myIter |
42 |
INTEGER myThid |
43 |
INTEGER newtonIter |
44 |
INTEGER krylovIter |
45 |
C u/vIceLoc :: local copies of the current ice velocity |
46 |
_RL uIceLoc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
47 |
_RL vIceLoc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
48 |
C u/vIceRes :: residual of sea-ice momentum equations |
49 |
_RL uIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
50 |
_RL vIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
51 |
|
52 |
#ifdef SEAICE_ALLOW_JFNK |
53 |
C u/vIceLHS :: left hand side of momentum equations |
54 |
_RL uIceLHS(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
55 |
_RL vIceLHS(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
56 |
C u/vIceRHS :: righ hand side of momentum equations |
57 |
_RL uIceRHS(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
58 |
_RL vIceRHS(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
59 |
|
60 |
C i,j,bi,bj :: loop indices |
61 |
INTEGER i,j,bi,bj |
62 |
CEOP |
63 |
|
64 |
C Initialise |
65 |
DO bj=myByLo(myThid),myByHi(myThid) |
66 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
67 |
DO J=1-Oly,sNy+Oly |
68 |
DO I=1-Olx,sNx+Olx |
69 |
uIceLHS(I,J,bi,bj) = 0. _d 0 |
70 |
vIceLHS(I,J,bi,bj) = 0. _d 0 |
71 |
uIceRHS(I,J,bi,bj) = 0. _d 0 |
72 |
vIceRHS(I,J,bi,bj) = 0. _d 0 |
73 |
ENDDO |
74 |
ENDDO |
75 |
ENDDO |
76 |
ENDDO |
77 |
C u/vIceLoc have changed so that new drag coefficients and |
78 |
C viscosities are required |
79 |
CALL SEAICE_OCEANDRAG_COEFFS( |
80 |
I uIceLoc, vIceLoc, |
81 |
O DWATN, |
82 |
I krylovIter, myTime, myIter, myThid ) |
83 |
CALL SEAICE_CALC_STRAINRATES( |
84 |
I uIceLoc, vIceLoc, |
85 |
O e11, e22, e12, |
86 |
I krylovIter, myTime, myIter, myThid ) |
87 |
CALL SEAICE_CALC_VISCOSITIES( |
88 |
I e11, e22, e12, zMin, zMax, hEffM, press0, |
89 |
O eta, etaZ, zeta, press, |
90 |
I krylovIter, myTime, myIter, myThid ) |
91 |
|
92 |
C The scheme is backward Euler in time, i.e. the rhs-vector contains |
93 |
C only terms that are independent of u/vIce, except for the time |
94 |
C derivative part mass*(u/vIce-u/vIceNm1)/deltaT |
95 |
|
96 |
C compute new right hand side (depends to DWATN=Cdrag) |
97 |
C sea-surface tilt and wind stress: FORCEX0, FORCEY0 |
98 |
C + mass*(u/vIceNm1)/deltaT |
99 |
C + Cdrag*(uVel*cosWat - vVel*sinWat)/(vVel*cosWat + uVel*sinWat) |
100 |
CALL SEAICE_CALC_RHS( |
101 |
O uIceRHS, vIceRHS, |
102 |
I newtonIter, krylovIter, myTime, myIter, myThid ) |
103 |
|
104 |
C Left-hand side contributions: |
105 |
C + mass*(u/vIce)/deltaT |
106 |
C + Cdrag*(uIce*cosWat - vIce*sinWat)/(vIce*cosWat + uIce*sinWat) |
107 |
C - mass*f*vIce/+mass*f*uIce |
108 |
C - dsigma/dx / -dsigma/dy, eta and zeta are only computed once per |
109 |
C Newton iterate |
110 |
CALL SEAICE_CALC_LHS( |
111 |
I uIceLoc, vIceLoc, |
112 |
O uIceLHS, vIceLHS, |
113 |
I newtonIter, myTime, myIter, myThid ) |
114 |
|
115 |
C Right-hand side contributions only need to be computed once per |
116 |
C time step, therefore we will put them into a separate routine |
117 |
C and call them elsewhere to save floating point operations |
118 |
|
119 |
C Calculate the residual |
120 |
DO bj=myByLo(myThid),myByHi(myThid) |
121 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
122 |
DO J=1,sNy |
123 |
DO I=1,sNx |
124 |
uIceRes(I,J,bi,bj) = uIceLHS(I,J,bi,bj) - uIceRHS(I,J,bi,bj) |
125 |
vIceRes(I,J,bi,bj) = vIceLHS(I,J,bi,bj) - vIceRHS(I,J,bi,bj) |
126 |
ENDDO |
127 |
ENDDO |
128 |
ENDDO |
129 |
ENDDO |
130 |
|
131 |
#endif /* SEAICE_ALLOW_JFNK */ |
132 |
|
133 |
RETURN |
134 |
END |