/[MITgcm]/MITgcm/pkg/seaice/seaice_jacvec.F
ViewVC logotype

Contents of /MITgcm/pkg/seaice/seaice_jacvec.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Oct 16 07:00:21 2012 UTC (12 years, 9 months ago) by mlosch
Branch: MAIN
add JFNK-solver routines, mostly parallel and mult-threaded (except
for FGMRES)

1 C $Header: $
2 C $Name: $
3
4 #include "SEAICE_OPTIONS.h"
5
6 CBOP
7 C !ROUTINE: SEAICE_JACVEC
8 C !INTERFACE:
9 SUBROUTINE SEAICE_JACVEC(
10 I uIceLoc, vIceLoc, uIceRes, vIceRes,
11 U duIce, dvIce,
12 I newtonIter, krylovIter, myTime, myIter, myThid )
13
14 C !DESCRIPTION: \bv
15 C *==========================================================*
16 C | SUBROUTINE SEAICE_JACVEC
17 C | o For Jacobian-free Newton-Krylov solver compute
18 C | Jacobian times vector by finite difference approximation
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 "PARAMS.h"
31 #include "DYNVARS.h"
32 #include "GRID.h"
33 #include "SEAICE_SIZE.h"
34 #include "SEAICE_PARAMS.h"
35 #include "SEAICE.h"
36
37 C !INPUT/OUTPUT PARAMETERS:
38 C === Routine arguments ===
39 C myTime :: Simulation time
40 C myIter :: Simulation timestep number
41 C myThid :: my Thread Id. number
42 C newtonIter :: current iterate of Newton iteration
43 C krylovIter :: current iterate of Krylov iteration
44 _RL myTime
45 INTEGER myIter
46 INTEGER myThid
47 INTEGER newtonIter
48 INTEGER krylovIter
49 C u/vIceLoc :: local copies of the current ice velocity
50 _RL uIceLoc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
51 _RL vIceLoc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
52 C u/vIceRes :: initial residual of this Newton iterate
53 _RL uIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
54 _RL vIceRes(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
55 C du/vIce :: correction of ice velocities
56 _RL duIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
57 _RL dvIce (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
58
59 #if ( defined (SEAICE_CGRID) && \
60 defined (SEAICE_ALLOW_JFNK) && \
61 defined (SEAICE_ALLOW_DYNAMICS) )
62 C Local variables:
63 _RL utp (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
64 _RL vtp (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
65 C u/vIceResP :: residual computed with u/vtp
66 _RL uIceResP(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
67 _RL vIceResP(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
68
69 C i,j,bi,bj :: loop indices
70 INTEGER i,j,bi,bj
71 _RL epsilon, reps
72 CEOP
73
74 C Initialise
75 epsilon = 1. _d -06
76 reps = 1. _d 0/epsilon
77
78 DO bj=myByLo(myThid),myByHi(myThid)
79 DO bi=myBxLo(myThid),myBxHi(myThid)
80 DO J=1-Oly,sNy+Oly
81 DO I=1-Olx,sNx+Olx
82 utp(I,J,bi,bj) = uIce(I,J,bi,bj) + epsilon * duIce(I,J,bi,bj)
83 vtp(I,J,bi,bj) = vIce(I,J,bi,bj) + epsilon * dvIce(I,J,bi,bj)
84 ENDDO
85 ENDDO
86 ENDDO
87 ENDDO
88
89 C Compute new residual F(u)
90 CALL SEAICE_CALC_RESIDUAL(
91 I utp, vtp,
92 O uIceResP, vIceResP,
93 I newtonIter, krylovIter, myTime, myIter, myThid )
94
95 C approximate Jacobian times vector by one-sided finite differences
96 C and store in du/vIce
97 DO bj = myByLo(myThid),myByHi(myThid)
98 DO bi = myBxLo(myThid),myBxHi(myThid)
99 DO I = 1, sNx
100 DO J = 1, sNy
101 duIce(I,J,bi,bj) =
102 & (uIceResP(I,J,bi,bj)-uIceRes(I,J,bi,bj))*reps
103 dvIce(I,J,bi,bj) =
104 & (vIceResP(I,J,bi,bj)-vIceRes(I,J,bi,bj))*reps
105 ENDDO
106 ENDDO
107 ENDDO
108 ENDDO
109
110 #endif /* SEAICE_ALLOW_DYNAMICS and SEAICE_CGRID and SEAICE_ALLOW_JFNK */
111
112 RETURN
113 END

  ViewVC Help
Powered by ViewVC 1.1.22