/[MITgcm]/MITgcm_contrib/heimbach/OpenAD/OAD_support/ad_template.checkpoint.F
ViewVC logotype

Contents of /MITgcm_contrib/heimbach/OpenAD/OAD_support/ad_template.checkpoint.F

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


Revision 1.7 - (show annotations) (download)
Thu Dec 19 16:04:50 2013 UTC (12 years, 8 months ago) by utke
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +0 -0 lines
FILE REMOVED
obsolete duplicates

1 subroutine template()
2 use OAD_cp
3 use OAD_tape
4 use OAD_rev
5
6 c we may need these for the checkpointing
7 use SIZE_mod
8 use EEPARAMS_mod
9 use PARAMS_mod
10 use BAR2_mod
11 use BARRIER_mod
12 use CD_CODE_VARS_mod
13 use CG2D_mod
14 use CG3D_mod
15 use DYNVARS_mod
16 use EESUPPORT_mod
17 use EOS_mod
18 use EXCH_mod
19 use FC_NAMEMANGLE_mod
20 use FFIELDS_mod
21 use GAD_mod
22 use GLOBAL_MAX_mod
23 use GLOBAL_SUM_mod
24 use GMREDI_mod
25 use GMREDI_TAVE_mod
26 use GRID_mod
27 use MPI_INFO_mod
28 use SOLVE_FOR_PRESSURE3D_mod
29 use SOLVE_FOR_PRESSURE_mod
30 use SURFACE_mod
31 use tamc_mod
32 use tamc_keys_mod
33 use cost_mod
34 use g_cost_mod
35 use ctrl_mod
36 use ctrl_dummy_mod
37 use ctrl_weights_mod
38 use optim_mod
39 use grdchk_mod
40
41 !$TEMPLATE_PRAGMA_DECLARATIONS
42
43 integer :: cp_loop_variable_1,cp_loop_variable_2,
44 + cp_loop_variable_3,cp_loop_variable_4,cp_loop_variable_5
45
46 type(modeType) :: our_orig_mode
47
48 integer iaddr
49 external iaddr
50
51 #ifdef OAD_DEBUG_JOINT
52 character*(80):: indentation='
53 + '
54 our_indent=our_indent+1
55
56 write(standardmessageunit, '(A,A,A)', ADVANCE='NO')
57 +'OAD:',indentation(1:our_indent), 'enter __SRNAME__:'
58 call oad_dump_revmod(); call oad_dump_tapestats()
59 write(standardmessageunit,*)
60 #endif
61
62 if (our_rev_mode%switchedToCheckpoint) then
63
64 if (our_rev_mode%arg_store) then
65 call cp_write_open()
66 #ifdef OAD_DEBUG_JOINT
67 write(standardmessageunit,'(A,A,A)')
68 +'OAD:',indentation(1:our_indent),
69 +' __SRNAME__: entering arg store'
70 #endif
71 !$PLACEHOLDER_PRAGMA$ id=8
72 call cp_close()
73 end if
74 if (our_rev_mode%arg_restore) then
75 #ifdef OAD_DEBUG_JOINT
76 write(standardmessageunit,'(A,A,A)')
77 +'OAD:',indentation(1:our_indent),
78 +' __SRNAME__: entering arg restore'
79 #endif
80 call cp_read_open()
81 !$PLACEHOLDER_PRAGMA$ id=9
82 call cp_close()
83 end if
84 if (our_rev_mode%plain) then
85 #ifdef OAD_DEBUG_JOINT
86 write(standardmessageunit,'(A,A,A)')
87 +'OAD:',indentation(1:our_indent),
88 +' __SRNAME__: run plain, down plain'
89 #endif
90 our_orig_mode=our_rev_mode
91 our_rev_mode%arg_store=.FALSE.
92 !$PLACEHOLDER_PRAGMA$ id=1
93 our_rev_mode=our_orig_mode
94 end if
95 if (our_rev_mode%tape) then
96 #ifdef OAD_DEBUG_JOINT
97 write(standardmessageunit,'(A,A,A)')
98 +'OAD:',indentation(1:our_indent),
99 +' __SRNAME__: run tape, down arg store/plain'
100 #endif
101 our_orig_mode=our_rev_mode
102 our_rev_mode%arg_store=.TRUE.
103 our_rev_mode%arg_restore=.FALSE.
104 our_rev_mode%plain=.TRUE.
105 our_rev_mode%tape=.FALSE.
106 our_rev_mode%adjoint=.FALSE.
107 !$PLACEHOLDER_PRAGMA$ id=2
108 our_rev_mode%arg_store=.FALSE.
109 our_rev_mode%arg_restore=.TRUE.
110 our_rev_mode%plain=.FALSE.
111 our_rev_mode%tape=.TRUE.
112 our_rev_mode%adjoint=.FALSE.
113 #ifdef OAD_DEBUG_JOINT
114 write(standardmessageunit,'(A,A,A)')
115 +'OAD:',indentation(1:our_indent),
116 +' __SRNAME__: following with adjoint, down arg restor/tape'
117 #endif
118 !$PLACEHOLDER_PRAGMA$ id=3
119 our_rev_mode=our_orig_mode
120 end if
121
122 else
123
124 our_rev_mode%switchedToCheckpoint = .TRUE.
125
126 if (our_rev_mode%arg_store) then
127 write(errorMessageUnit,'(A)')
128 +'OAD ERROR __SRNAME__: s2c arg store is the wrong logic'
129 stop
130 end if
131 if (our_rev_mode%arg_restore) then
132 write(errorMessageUnit,'(A)')
133 +'OAD ERROR __SRNAME__: s2c arg restore is the wrong logic'
134 stop
135 end if
136 if (our_rev_mode%plain) then
137 #ifdef OAD_DEBUG_JOINT
138 write(standardmessageunit,'(A,A,A)')
139 +'OAD:',indentation(1:our_indent),
140 +' __SRNAME__: s2c entering plain'
141 #endif
142 our_orig_mode=our_rev_mode
143 !$PLACEHOLDER_PRAGMA$ id=1
144 our_rev_mode=our_orig_mode
145 end if
146 if (our_rev_mode%tape) then
147 #ifdef OAD_DEBUG_JOINT
148 write(standardmessageunit,'(A,A,A)')
149 +'OAD:',indentation(1:our_indent),
150 +' __SRNAME__: s2c entering as tape'
151 #endif
152 c we have to switch from split to checkpointing mode
153 c i.e. outside taping means top level checkpointing here
154 #ifdef OAD_DEBUG_JOINT
155 write(standardmessageunit,'(A,A,A)')
156 +'OAD:',indentation(1:our_indent),
157 +' __SRNAME__: s2c store argument cp'
158 #endif
159 call cp_write_open()
160 !$PLACEHOLDER_PRAGMA$ id=8
161 call cp_close()
162 c now do the forward run down a plain
163 our_orig_mode=our_rev_mode
164 our_rev_mode%arg_store=.FALSE.
165 our_rev_mode%arg_restore=.FALSE.
166 our_rev_mode%plain=.TRUE.
167 our_rev_mode%tape=.FALSE.
168 our_rev_mode%adjoint=.FALSE.
169 #ifdef OAD_DEBUG_JOINT
170 write(standardmessageunit,'(A,A,A)')
171 +'OAD:',indentation(1:our_indent), ' __SRNAME__: s2c run plain'
172 #endif
173 !$PLACEHOLDER_PRAGMA$ id=1
174 our_rev_mode=our_orig_mode
175 end if
176 if (our_rev_mode%adjoint) then
177 #ifdef OAD_DEBUG_JOINT
178 write(standardmessageunit,'(A,A,A)')
179 +'OAD:',indentation(1:our_indent),
180 +' __SRNAME__: s2c entering as adjoint'
181 #endif
182 c we have to switch from split to checkpointing mode
183 c i.e. outside adjoint means argument restore, taping and then adjoint here
184 c argument restore
185 #ifdef OAD_DEBUG_JOINT
186 write(standardmessageunit,'(A,A,A)')
187 +'OAD:',indentation(1:our_indent),
188 +' __SRNAME__: s2c restore argument cp'
189 #endif
190 call cp_read_open()
191 !$PLACEHOLDER_PRAGMA$ id=9
192 call cp_close()
193 c setup checkpointing downwards
194 our_orig_mode=our_rev_mode
195 our_rev_mode%arg_store=.TRUE.
196 our_rev_mode%arg_restore=.FALSE.
197 our_rev_mode%plain=.TRUE.
198 our_rev_mode%tape=.FALSE.
199 our_rev_mode%adjoint=.FALSE.
200 c taping this level
201 #ifdef OAD_DEBUG_JOINT
202 write(standardmessageunit,'(A,A,A,A)')
203 +'OAD:',indentation(1:our_indent),
204 +' __SRNAME__: s2c run tape, down arg store/plain'
205 #endif
206 !$PLACEHOLDER_PRAGMA$ id=2
207 c setting up for taping downwards
208 our_rev_mode%arg_store=.FALSE.
209 our_rev_mode%arg_restore=.TRUE.
210 our_rev_mode%plain=.FALSE.
211 our_rev_mode%tape=.TRUE.
212 our_rev_mode%adjoint=.TRUE.
213 c adjoining this level
214 #ifdef OAD_DEBUG_JOINT
215 write(standardmessageunit,'(A,A,A,A)')
216 +'OAD:',indentation(1:our_indent),
217 +' __SRNAME__: s2c run adjoint, down arg restore/tape'
218 #endif
219 !$PLACEHOLDER_PRAGMA$ id=3
220 our_rev_mode=our_orig_mode
221 end if
222
223 our_rev_mode%switchedToCheckpoint=.FALSE.
224
225 end if
226
227 #ifdef OAD_DEBUG_JOINT
228 write(standardmessageunit,'(A,A,A)', ADVANCE='NO')
229 +'OAD:',indentation(1:our_indent), 'leave __SRNAME__:'
230 call oad_dump_revmod(); call oad_dump_tapestats()
231 write(standardmessageunit,*)
232
233 our_indent=our_indent-1
234 #endif
235
236 end subroutine template

  ViewVC Help
Powered by ViewVC 1.1.22