/[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.6 - (hide annotations) (download)
Mon Mar 8 05:58:29 2010 UTC (16 years, 6 months ago) by utke
Branch: MAIN
Changes since 1.5: +0 -1 lines
header file removed

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_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 utke 1.2 #ifdef OAD_DEBUG_JOINT
52 utke 1.1 character*(80):: indentation='
53     + '
54     our_indent=our_indent+1
55    
56 utke 1.3 write(standardmessageunit, '(A,A,A)', ADVANCE='NO')
57 utke 1.2 +'OAD:',indentation(1:our_indent), 'enter __SRNAME__:'
58 utke 1.1 call oad_dump_revmod(); call oad_dump_tapestats()
59 utke 1.3 write(standardmessageunit,*)
60 utke 1.2 #endif
61 utke 1.1
62     if (our_rev_mode%switchedToCheckpoint) then
63    
64     if (our_rev_mode%arg_store) then
65     call cp_write_open()
66 utke 1.2 #ifdef OAD_DEBUG_JOINT
67 utke 1.3 write(standardmessageunit,'(A,A,A)')
68 utke 1.2 +'OAD:',indentation(1:our_indent),
69 utke 1.1 +' __SRNAME__: entering arg store'
70 utke 1.2 #endif
71 utke 1.1 !$PLACEHOLDER_PRAGMA$ id=8
72     call cp_close()
73     end if
74     if (our_rev_mode%arg_restore) then
75 utke 1.2 #ifdef OAD_DEBUG_JOINT
76 utke 1.3 write(standardmessageunit,'(A,A,A)')
77 utke 1.2 +'OAD:',indentation(1:our_indent),
78 utke 1.1 +' __SRNAME__: entering arg restore'
79 utke 1.2 #endif
80 utke 1.1 call cp_read_open()
81     !$PLACEHOLDER_PRAGMA$ id=9
82     call cp_close()
83     end if
84     if (our_rev_mode%plain) then
85 utke 1.2 #ifdef OAD_DEBUG_JOINT
86 utke 1.3 write(standardmessageunit,'(A,A,A)')
87 utke 1.2 +'OAD:',indentation(1:our_indent),
88     +' __SRNAME__: run plain, down plain'
89     #endif
90 utke 1.1 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 utke 1.2 #ifdef OAD_DEBUG_JOINT
97 utke 1.3 write(standardmessageunit,'(A,A,A)')
98 utke 1.2 +'OAD:',indentation(1:our_indent),
99     +' __SRNAME__: run tape, down arg store/plain'
100     #endif
101 utke 1.1 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 utke 1.2 #ifdef OAD_DEBUG_JOINT
114 utke 1.3 write(standardmessageunit,'(A,A,A)')
115 utke 1.2 +'OAD:',indentation(1:our_indent),
116 utke 1.1 +' __SRNAME__: following with adjoint, down arg restor/tape'
117 utke 1.2 #endif
118 utke 1.1 !$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 utke 1.3 write(errorMessageUnit,'(A)')
128 utke 1.2 +'OAD ERROR __SRNAME__: s2c arg store is the wrong logic'
129 utke 1.1 stop
130     end if
131     if (our_rev_mode%arg_restore) then
132 utke 1.3 write(errorMessageUnit,'(A)')
133 utke 1.2 +'OAD ERROR __SRNAME__: s2c arg restore is the wrong logic'
134 utke 1.1 stop
135     end if
136     if (our_rev_mode%plain) then
137 utke 1.2 #ifdef OAD_DEBUG_JOINT
138 utke 1.3 write(standardmessageunit,'(A,A,A)')
139 utke 1.2 +'OAD:',indentation(1:our_indent),
140 utke 1.1 +' __SRNAME__: s2c entering plain'
141 utke 1.2 #endif
142 utke 1.1 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 utke 1.2 #ifdef OAD_DEBUG_JOINT
148 utke 1.3 write(standardmessageunit,'(A,A,A)')
149 utke 1.2 +'OAD:',indentation(1:our_indent),
150 utke 1.1 +' __SRNAME__: s2c entering as tape'
151 utke 1.2 #endif
152 utke 1.1 c we have to switch from split to checkpointing mode
153     c i.e. outside taping means top level checkpointing here
154 utke 1.2 #ifdef OAD_DEBUG_JOINT
155 utke 1.3 write(standardmessageunit,'(A,A,A)')
156 utke 1.2 +'OAD:',indentation(1:our_indent),
157 utke 1.1 +' __SRNAME__: s2c store argument cp'
158 utke 1.2 #endif
159 utke 1.1 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 utke 1.2 #ifdef OAD_DEBUG_JOINT
170 utke 1.3 write(standardmessageunit,'(A,A,A)')
171 utke 1.2 +'OAD:',indentation(1:our_indent), ' __SRNAME__: s2c run plain'
172     #endif
173 utke 1.1 !$PLACEHOLDER_PRAGMA$ id=1
174     our_rev_mode=our_orig_mode
175     end if
176     if (our_rev_mode%adjoint) then
177 utke 1.2 #ifdef OAD_DEBUG_JOINT
178 utke 1.3 write(standardmessageunit,'(A,A,A)')
179 utke 1.2 +'OAD:',indentation(1:our_indent),
180 utke 1.1 +' __SRNAME__: s2c entering as adjoint'
181 utke 1.2 #endif
182 utke 1.1 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 utke 1.2 #ifdef OAD_DEBUG_JOINT
186 utke 1.3 write(standardmessageunit,'(A,A,A)')
187 utke 1.2 +'OAD:',indentation(1:our_indent),
188 utke 1.1 +' __SRNAME__: s2c restore argument cp'
189 utke 1.2 #endif
190 utke 1.1 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 utke 1.2 #ifdef OAD_DEBUG_JOINT
202 utke 1.3 write(standardmessageunit,'(A,A,A,A)')
203 utke 1.2 +'OAD:',indentation(1:our_indent),
204 utke 1.1 +' __SRNAME__: s2c run tape, down arg store/plain'
205 utke 1.2 #endif
206 utke 1.1 !$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 utke 1.2 #ifdef OAD_DEBUG_JOINT
215 utke 1.3 write(standardmessageunit,'(A,A,A,A)')
216 utke 1.2 +'OAD:',indentation(1:our_indent),
217 utke 1.1 +' __SRNAME__: s2c run adjoint, down arg restore/tape'
218 utke 1.2 #endif
219 utke 1.1 !$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 utke 1.2 #ifdef OAD_DEBUG_JOINT
228 utke 1.3 write(standardmessageunit,'(A,A,A)', ADVANCE='NO')
229 utke 1.2 +'OAD:',indentation(1:our_indent), 'leave __SRNAME__:'
230 utke 1.1 call oad_dump_revmod(); call oad_dump_tapestats()
231 utke 1.3 write(standardmessageunit,*)
232 utke 1.1
233     our_indent=our_indent-1
234 utke 1.2 #endif
235    
236 utke 1.1 end subroutine template

  ViewVC Help
Powered by ViewVC 1.1.22