/[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.5 - (hide annotations) (download)
Mon Jan 18 17:03:02 2010 UTC (16 years, 7 months ago) by utke
Branch: MAIN
Changes since 1.4: +0 -1 lines
rm DFILE reference

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

  ViewVC Help
Powered by ViewVC 1.1.22