/[MITgcm]/MITgcm/tools/OAD_support/ad_template.streamice_cg_solve.F
ViewVC logotype

Contents of /MITgcm/tools/OAD_support/ad_template.streamice_cg_solve.F

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


Revision 1.4 - (show annotations) (download)
Fri Sep 5 21:10:32 2014 UTC (4 years, 10 months ago) by dgoldberg
Branch: MAIN
CVS Tags: checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, HEAD
Changes since 1.3: +3 -1 lines
streamice_cg_solve template modified to reflect additional maxIter arg

1 subroutine template()
2 use OAD_cp
3 use OAD_tape
4 use OAD_rev
5
6 !$TEMPLATE_PRAGMA_DECLARATIONS
7
8 integer :: cp_loop_variable_1,cp_loop_variable_2,
9 + cp_loop_variable_3,cp_loop_variable_4
10
11 type(modeType) :: our_orig_mode
12
13 integer iaddr
14 external iaddr
15
16 Real*8 cg_Uin_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
17 Real*8 cg_Vin_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
18 Real*8 cg_Bu_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
19 Real*8 cg_Bv_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
20 Real*8 A_uu_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
21 Real*8 A_vu_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
22 Real*8 A_uv_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
23 Real*8 A_vv_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
24 Real*8 cg_Uin_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
25 Real*8 cg_Vin_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
26 Real*8 cg_Bu_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
27 Real*8 cg_Bv_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
28 Real*8 A_uu_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
29 Real*8 A_vu_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
30 Real*8 A_uv_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
31 Real*8 A_vv_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
32
33 #ifdef OAD_DEBUG_JOINT
34 character*(80):: indentation='
35 + '
36 our_indent=our_indent+1
37
38 write(standardmessageunit, '(A,A,A)', ADVANCE='NO')
39 +'OAD:',indentation(1:our_indent), 'enter __SRNAME__:'
40 call oad_dump_revmod(); call oad_dump_tapestats()
41 write(standardmessageunit,*)
42 #endif
43 if (our_rev_mode%plain) then
44 #ifdef OAD_DEBUG_JOINT
45 write(standardmessageunit,'(A,A,A)')
46 +'OAD:',indentation(1:our_indent),
47 +' __SRNAME__: entering plain'
48 #endif
49 c set up for plain execution
50 our_orig_mode=our_rev_mode
51 our_rev_mode%arg_store=.FALSE.
52 our_rev_mode%arg_restore=.FALSE.
53 our_rev_mode%plain=.TRUE.
54 our_rev_mode%tape=.FALSE.
55 our_rev_mode%adjoint=.FALSE.
56 #ifdef OAD_DEBUG_JOINT
57 write(standardmessageunit,'(A,A,A)')
58 +'OAD:',indentation(1:our_indent),
59 +' __SRNAME__: runninng plain / down plain'
60 #endif
61 cg_Uin_p = cg_Uin%v
62 cg_Vin_p = cg_Vin%v
63 cg_Bu_p = cg_Bu%v
64 cg_Bv_p = cg_Bv%v
65 A_uu_p = A_uu%v
66 A_uv_p = A_uv%v
67 A_vu_p = A_vu%v
68 A_vv_p = A_vv%v
69 call STREAMICE_CG_SOLVE(
70 U cg_Uin_p,
71 U cg_Vin_p,
72 I cg_Bu_p,
73 I cg_Bv_p,
74 I A_uu_p,
75 I A_uv_p,
76 I A_vu_p,
77 I A_vv_p,
78 I tolerance,
79 O iters,
80 I maxIter,
81 I myThid )
82 cg_Uin%v = cg_Uin_p
83 cg_Vin%v = cg_Vin_p
84 c reset the mode
85 our_rev_mode=our_orig_mode
86 end if
87 if (our_rev_mode%tape) then
88
89 #ifdef OAD_DEBUG_JOINT
90 write(standardmessageunit,'(A,A,A)')
91 +'OAD:',indentation(1:our_indent),
92 +' __SRNAME__: entering tape'
93 #endif
94 c set up for plain execution
95 our_orig_mode=our_rev_mode
96 our_rev_mode%arg_store=.FALSE.
97 our_rev_mode%arg_restore=.FALSE.
98 our_rev_mode%plain=.TRUE.
99 our_rev_mode%tape=.FALSE.
100 our_rev_mode%adjoint=.FALSE.
101 #ifdef OAD_DEBUG_JOINT
102 write(standardmessageunit,'(A,A,A)')
103 +'OAD:',indentation(1:our_indent),
104 +' __SRNAME__: runninng plain / down plain'
105 #endif
106 cg_Uin_p = cg_Uin%v
107 cg_Vin_p = cg_Vin%v
108 cg_Bu_p = cg_Bu%v
109 cg_Bv_p = cg_Bv%v
110 A_uu_p = A_uu%v
111 A_uv_p = A_uv%v
112 A_vu_p = A_vu%v
113 A_vv_p = A_vv%v
114 call oad_tape_push(cg_Bu_p)
115 call oad_tape_push(cg_Bv_p)
116 call oad_tape_push(A_uu_p)
117 call oad_tape_push(A_uv_p)
118 call oad_tape_push(A_vu_p)
119 call oad_tape_push(A_vv_p)
120 call oad_tape_push(tolerance)
121 call oad_tape_push(mythid)
122 call STREAMICE_CG_SOLVE(
123 U cg_Uin_p,
124 U cg_Vin_p,
125 I cg_Bu_p,
126 I cg_Bv_p,
127 I A_uu_p,
128 I A_uv_p,
129 I A_vu_p,
130 I A_vv_p,
131 I tolerance,
132 O iters,
133 I maxIter,
134 I myThid )
135 call oad_tape_push(cg_Uin_p)
136 call oad_tape_push(cg_Vin_p)
137 cg_Uin%v = cg_Uin_p
138 cg_Vin%v = cg_Vin_p
139 c reset the mode
140 our_rev_mode=our_orig_mode
141 end if
142 if (our_rev_mode%adjoint) then
143 #ifdef OAD_DEBUG_JOINT
144 write(standardmessageunit,'(A,A,A)')
145 +'OAD:',indentation(1:our_indent),
146 +' __SRNAME__: entering adjoint'
147 #endif
148 call oad_tape_pop(cg_Vin_p)
149 call oad_tape_pop(cg_Uin_p)
150 call oad_tape_pop(mythid)
151 call oad_tape_pop(tolerance)
152 call oad_tape_pop(A_vv_p)
153 call oad_tape_pop(A_vu_p)
154 call oad_tape_pop(A_uv_p)
155 call oad_tape_pop(A_uu_p)
156 call oad_tape_pop(cg_Bv_p)
157 call oad_tape_pop(cg_Bu_p)
158 c set up for plain execution
159 our_orig_mode=our_rev_mode
160 our_rev_mode%arg_store=.FALSE.
161 our_rev_mode%arg_restore=.FALSE.
162 our_rev_mode%plain=.TRUE.
163 our_rev_mode%tape=.FALSE.
164 our_rev_mode%adjoint=.FALSE.
165 #ifdef OAD_DEBUG_JOINT
166 write(standardmessageunit,'(A,A,A)')
167 +'OAD:',indentation(1:our_indent),
168 +' __SRNAME__: runninng self adjoint / down plain'
169 #endif
170 cg_Uin_d = cg_Uin%d
171 cg_Vin_d = cg_Vin%d
172 cg_Bu_d = cg_Bu%d
173 cg_Bv_d = cg_Bv%d
174 A_uu_d = A_uu%d
175 A_uv_d = A_uv%d
176 A_vu_d = A_vu%d
177 A_vv_d = A_vv%d
178 call ADSTREAMICE_CG_SOLVE(
179 U cg_Uin_p, ! velocities - solution
180 I cg_Uin_d, ! adjoint of vel (input)
181 U cg_Vin_p, ! velocities - solution
182 I cg_Vin_d, ! adjoint of vel (input)
183 I cg_Bu_p, ! to recalc velocities
184 U cg_Bu_d, ! adjoint of RHS (output)
185 I cg_Bv_p, ! to recalc velocities
186 U cg_Bv_d, ! adjoint of RHS (output)
187 I A_uu_p, ! section of matrix that multiplies u and projects on u
188 U A_uu_d, ! adjoint of matrix coeffs (output)
189 I A_uv_p, ! section of matrix that multiplies v and projects on u
190 U A_uv_d, ! adjoint of matrix coeffs (output)
191 I A_vu_p, ! section of matrix that multiplies u and projects on v
192 U A_vu_d, ! adjoint of matrix coeffs (output)
193 I A_vv_p, ! section of matrix that multiplies v and projects on v
194 U A_vv_d, ! adjoint of matrix coeffs (output)
195 I tolerance,
196 I maxIter,
197 I myThid )
198 c reset the mode
199 cg_Uin%d = cg_Uin_d
200 cg_Vin%d = cg_Vin_d
201 cg_Bu%d = cg_Bu_d
202 cg_Bv%d = cg_Bv_d
203 A_uu%d = A_uu_d
204 A_uv%d = A_uv_d
205 A_vu%d = A_vu_d
206 A_vv%d = A_vv_d
207 our_rev_mode=our_orig_mode
208 end if
209 #ifdef OAD_DEBUG_JOINT
210 write(standardmessageunit,'(A,A,A)', ADVANCE='NO')
211 +'OAD:',indentation(1:our_indent), 'leave __SRNAME__:'
212 call oad_dump_revmod(); call oad_dump_tapestats()
213 write(standardmessageunit,*)
214
215 our_indent=our_indent-1
216 #endif
217
218 end subroutine template

  ViewVC Help
Powered by ViewVC 1.1.22