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

Annotation 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.3 - (hide annotations) (download)
Tue Feb 24 20:01:50 2009 UTC (17 years, 6 months ago) by utke
Branch: MAIN
Changes since 1.2: +19 -19 lines
using message units as the rest of the code

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

  ViewVC Help
Powered by ViewVC 1.1.22