/[MITgcm]/MITgcm_contrib/heimbach/OpenAD/code_shallow_openad3/ad_template.checkpoint.f
ViewVC logotype

Contents of /MITgcm_contrib/heimbach/OpenAD/code_shallow_openad3/ad_template.checkpoint.f

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


Revision 1.3 - (show annotations) (download)
Thu Dec 19 16:10:20 2013 UTC (12 years, 10 months ago) by utke
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
FILE REMOVED
stale

1 subroutine template()
2 use OpenAD_checkpoints
3 use OpenAD_tape
4 use OpenAD_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 character*(80):: indentation='
55 + '
56
57 our_indent=our_indent+1
58
59 write(*,
60 +'(A,A,A,A,L,A,L,A,L,A,L,A,L,A,L,A,I8,A,I8)')
61 +'JU:',indentation(1:our_indent), 'enter __SRNAME__:',
62 +' As:',our_rev_mode%arg_store,
63 +' Ar:',our_rev_mode%arg_restore,
64 +' Pl:',our_rev_mode%plain,
65 +' Ta:',our_rev_mode%tape,
66 +' Ad:',our_rev_mode%adjoint,
67 +' Sw:',our_rev_mode%switchedToCheckpoint,
68 +' TD:',double_tape_pointer,
69 +' TI:',integer_tape_pointer
70
71 if (our_rev_mode%switchedToCheckpoint) then
72
73 if (our_rev_mode%arg_store) then
74 call cp_write_open()
75 write(*,'(A,A,A)')
76 +'JU:',indentation(1:our_indent),
77 +' __SRNAME__: entering arg store'
78 !$PLACEHOLDER_PRAGMA$ id=8
79 call cp_close()
80 end if
81 if (our_rev_mode%arg_restore) then
82 write(*,'(A,A,A)')
83 +'JU:',indentation(1:our_indent),
84 +' __SRNAME__: entering arg restore'
85 call cp_read_open()
86 !$PLACEHOLDER_PRAGMA$ id=9
87 call cp_close()
88 end if
89 if (our_rev_mode%plain) then
90 write(*,'(A,A,A)')
91 +'JU:',indentation(1:our_indent),
92 +' __SRNAME__: entering plain'
93 our_orig_mode=our_rev_mode
94 our_rev_mode%arg_store=.FALSE.
95 write(*,'(A,A,A)')
96 +'JU:',indentation(1:our_indent),
97 +' __SRNAME__: run plain, down plain'
98 !$PLACEHOLDER_PRAGMA$ id=1
99 our_rev_mode=our_orig_mode
100 end if
101 if (our_rev_mode%tape) then
102 write(*,'(A,A,A)')
103 +'JU:',indentation(1:our_indent),
104 +' __SRNAME__: entering tape'
105 our_orig_mode=our_rev_mode
106 our_rev_mode%arg_store=.TRUE.
107 our_rev_mode%arg_restore=.FALSE.
108 our_rev_mode%plain=.TRUE.
109 our_rev_mode%tape=.FALSE.
110 our_rev_mode%adjoint=.FALSE.
111 write(*,'(A,A,A)')
112 +'JU:',indentation(1:our_indent),
113 +' __SRNAME__: run tape, down arg store/plain'
114 !$PLACEHOLDER_PRAGMA$ id=2
115 our_rev_mode%arg_store=.FALSE.
116 our_rev_mode%arg_restore=.TRUE.
117 our_rev_mode%plain=.FALSE.
118 our_rev_mode%tape=.TRUE.
119 our_rev_mode%adjoint=.FALSE.
120 write(*,'(A,A,A)')
121 +'JU:',indentation(1:our_indent),
122 +' __SRNAME__: following with adjoint, down arg restor/tape'
123 !$PLACEHOLDER_PRAGMA$ id=3
124 our_rev_mode=our_orig_mode
125 end if
126
127 else
128
129 our_rev_mode%switchedToCheckpoint = .TRUE.
130
131 if (our_rev_mode%arg_store) then
132 write(*,'(A,A,A)')
133 +'JU:',indentation(1:our_indent),
134 +' __SRNAME__: s2c entering arg store'
135 write(*,*) 'JU: ERROR : arg store here is wrong logic'
136 stop
137 end if
138 if (our_rev_mode%arg_restore) then
139 write(*,'(A,A,A)')
140 +'JU:',indentation(1:our_indent),
141 +' __SRNAME__: entering arg restore'
142 write(*,*) 'JU: ERROR : arg restore here is wrong logic'
143 stop
144 end if
145 if (our_rev_mode%plain) then
146 write(*,'(A,A,A)')
147 +'JU:',indentation(1:our_indent),
148 +' __SRNAME__: s2c entering plain'
149 our_orig_mode=our_rev_mode
150 !$PLACEHOLDER_PRAGMA$ id=1
151 our_rev_mode=our_orig_mode
152 end if
153 if (our_rev_mode%tape) then
154 write(*,'(A,A,A)')
155 +'JU:',indentation(1:our_indent),
156 +' __SRNAME__: s2c entering as tape'
157 c we have to switch from split to checkpointing mode
158 c i.e. outside taping means top level checkpointing here
159 write(*,'(A,A,A)')
160 +'JU:',indentation(1:our_indent),
161 +' __SRNAME__: s2c store argument cp'
162 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 write(*,'(A,A,A)')
173 +'JU:',indentation(1:our_indent), ' __SRNAME__: s2c run plain'
174 !$PLACEHOLDER_PRAGMA$ id=1
175 our_rev_mode=our_orig_mode
176 end if
177 if (our_rev_mode%adjoint) then
178 write(*,'(A,A,A)')
179 +'JU:',indentation(1:our_indent),
180 +' __SRNAME__: s2c entering as adjoint'
181 c we have to switch from split to checkpointing mode
182 c i.e. outside adjoint means argument restore, taping and then adjoint here
183 c argument restore
184 write(*,'(A,A,A)')
185 +'JU:',indentation(1:our_indent),
186 +' __SRNAME__: s2c restore argument cp'
187 call cp_read_open()
188 !$PLACEHOLDER_PRAGMA$ id=9
189 call cp_close()
190 c setup checkpointing downwards
191 our_orig_mode=our_rev_mode
192 our_rev_mode%arg_store=.TRUE.
193 our_rev_mode%arg_restore=.FALSE.
194 our_rev_mode%plain=.TRUE.
195 our_rev_mode%tape=.FALSE.
196 our_rev_mode%adjoint=.FALSE.
197 c taping this level
198 write(*,'(A,A,A,A)')
199 +'JU:',indentation(1:our_indent),
200 +' __SRNAME__: s2c run tape, down arg store/plain'
201 !$PLACEHOLDER_PRAGMA$ id=2
202 c setting up for taping downwards
203 our_rev_mode%arg_store=.FALSE.
204 our_rev_mode%arg_restore=.TRUE.
205 our_rev_mode%plain=.FALSE.
206 our_rev_mode%tape=.TRUE.
207 our_rev_mode%adjoint=.TRUE.
208 c adjoining this level
209 write(*,'(A,A,A,A)')
210 +'JU:',indentation(1:our_indent),
211 +' __SRNAME__: s2c run adjoint, down arg restore/tape'
212 !$PLACEHOLDER_PRAGMA$ id=3
213 our_rev_mode=our_orig_mode
214 end if
215
216 our_rev_mode%switchedToCheckpoint=.FALSE.
217
218 end if
219
220 write(*,
221 +'(A,A,A,A,L,A,L,A,L,A,L,A,L,A,L,A,I8,A,I8)')
222 +'JU:',indentation(1:our_indent), 'leave __SRNAME__:',
223 +' As:',our_rev_mode%arg_store,
224 +' Ar:',our_rev_mode%arg_restore,
225 +' Pl:',our_rev_mode%plain,
226 +' Ta:',our_rev_mode%tape,
227 +' Ad:',our_rev_mode%adjoint,
228 +' Sw:',our_rev_mode%switchedToCheckpoint,
229 +' TD:',double_tape_pointer,
230 +' TI:',integer_tape_pointer
231
232 our_indent=our_indent-1
233 end subroutine template

  ViewVC Help
Powered by ViewVC 1.1.22