/[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.3 - (show annotations) (download)
Fri Feb 20 21:07:17 2009 UTC (17 years, 6 months ago) by utke
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
FILE REMOVED
rename to make it go through the preprocessor

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 character*(80):: indentation='
55 + '
56
57 our_indent=our_indent+1
58
59 write(*, '(A,A,A)', ADVANCE='NO')
60 +'JU:',indentation(1:our_indent), 'enter __SRNAME__:'
61 call oad_dump_revmod(); call oad_dump_tapestats()
62 write(*,*)
63
64 if (our_rev_mode%switchedToCheckpoint) then
65
66 if (our_rev_mode%arg_store) then
67 call cp_write_open()
68 write(*,'(A,A,A)')
69 +'JU:',indentation(1:our_indent),
70 +' __SRNAME__: entering arg store'
71 !$PLACEHOLDER_PRAGMA$ id=8
72 call cp_close()
73 end if
74 if (our_rev_mode%arg_restore) then
75 write(*,'(A,A,A)')
76 +'JU:',indentation(1:our_indent),
77 +' __SRNAME__: entering arg restore'
78 call cp_read_open()
79 !$PLACEHOLDER_PRAGMA$ id=9
80 call cp_close()
81 end if
82 if (our_rev_mode%plain) then
83 write(*,'(A,A,A)')
84 +'JU:',indentation(1:our_indent),
85 +' __SRNAME__: entering plain'
86 our_orig_mode=our_rev_mode
87 our_rev_mode%arg_store=.FALSE.
88 write(*,'(A,A,A)')
89 +'JU:',indentation(1:our_indent),
90 +' __SRNAME__: run plain, down plain'
91 !$PLACEHOLDER_PRAGMA$ id=1
92 our_rev_mode=our_orig_mode
93 end if
94 if (our_rev_mode%tape) then
95 write(*,'(A,A,A)')
96 +'JU:',indentation(1:our_indent),
97 +' __SRNAME__: entering tape'
98 our_orig_mode=our_rev_mode
99 our_rev_mode%arg_store=.TRUE.
100 our_rev_mode%arg_restore=.FALSE.
101 our_rev_mode%plain=.TRUE.
102 our_rev_mode%tape=.FALSE.
103 our_rev_mode%adjoint=.FALSE.
104 write(*,'(A,A,A)')
105 +'JU:',indentation(1:our_indent),
106 +' __SRNAME__: run tape, down arg store/plain'
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 write(*,'(A,A,A)')
114 +'JU:',indentation(1:our_indent),
115 +' __SRNAME__: following with adjoint, down arg restor/tape'
116 !$PLACEHOLDER_PRAGMA$ id=3
117 our_rev_mode=our_orig_mode
118 end if
119
120 else
121
122 our_rev_mode%switchedToCheckpoint = .TRUE.
123
124 if (our_rev_mode%arg_store) then
125 write(*,'(A,A,A)')
126 +'JU:',indentation(1:our_indent),
127 +' __SRNAME__: s2c entering arg store'
128 write(*,*) 'JU: ERROR : arg store here is wrong logic'
129 stop
130 end if
131 if (our_rev_mode%arg_restore) then
132 write(*,'(A,A,A)')
133 +'JU:',indentation(1:our_indent),
134 +' __SRNAME__: entering arg restore'
135 write(*,*) 'JU: ERROR : arg restore here is wrong logic'
136 stop
137 end if
138 if (our_rev_mode%plain) then
139 write(*,'(A,A,A)')
140 +'JU:',indentation(1:our_indent),
141 +' __SRNAME__: s2c entering plain'
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 write(*,'(A,A,A)')
148 +'JU:',indentation(1:our_indent),
149 +' __SRNAME__: s2c entering as tape'
150 c we have to switch from split to checkpointing mode
151 c i.e. outside taping means top level checkpointing here
152 write(*,'(A,A,A)')
153 +'JU:',indentation(1:our_indent),
154 +' __SRNAME__: s2c store argument cp'
155 call cp_write_open()
156 !$PLACEHOLDER_PRAGMA$ id=8
157 call cp_close()
158 c now do the forward run down a plain
159 our_orig_mode=our_rev_mode
160 our_rev_mode%arg_store=.FALSE.
161 our_rev_mode%arg_restore=.FALSE.
162 our_rev_mode%plain=.TRUE.
163 our_rev_mode%tape=.FALSE.
164 our_rev_mode%adjoint=.FALSE.
165 write(*,'(A,A,A)')
166 +'JU:',indentation(1:our_indent), ' __SRNAME__: s2c run plain'
167 !$PLACEHOLDER_PRAGMA$ id=1
168 our_rev_mode=our_orig_mode
169 end if
170 if (our_rev_mode%adjoint) then
171 write(*,'(A,A,A)')
172 +'JU:',indentation(1:our_indent),
173 +' __SRNAME__: s2c entering as adjoint'
174 c we have to switch from split to checkpointing mode
175 c i.e. outside adjoint means argument restore, taping and then adjoint here
176 c argument restore
177 write(*,'(A,A,A)')
178 +'JU:',indentation(1:our_indent),
179 +' __SRNAME__: s2c restore argument cp'
180 call cp_read_open()
181 !$PLACEHOLDER_PRAGMA$ id=9
182 call cp_close()
183 c setup checkpointing downwards
184 our_orig_mode=our_rev_mode
185 our_rev_mode%arg_store=.TRUE.
186 our_rev_mode%arg_restore=.FALSE.
187 our_rev_mode%plain=.TRUE.
188 our_rev_mode%tape=.FALSE.
189 our_rev_mode%adjoint=.FALSE.
190 c taping this level
191 write(*,'(A,A,A,A)')
192 +'JU:',indentation(1:our_indent),
193 +' __SRNAME__: s2c run tape, down arg store/plain'
194 !$PLACEHOLDER_PRAGMA$ id=2
195 c setting up for taping downwards
196 our_rev_mode%arg_store=.FALSE.
197 our_rev_mode%arg_restore=.TRUE.
198 our_rev_mode%plain=.FALSE.
199 our_rev_mode%tape=.TRUE.
200 our_rev_mode%adjoint=.TRUE.
201 c adjoining this level
202 write(*,'(A,A,A,A)')
203 +'JU:',indentation(1:our_indent),
204 +' __SRNAME__: s2c run adjoint, down arg restore/tape'
205 !$PLACEHOLDER_PRAGMA$ id=3
206 our_rev_mode=our_orig_mode
207 end if
208
209 our_rev_mode%switchedToCheckpoint=.FALSE.
210
211 end if
212
213 write(*,'(A,A,A)', ADVANCE='NO')
214 +'JU:',indentation(1:our_indent), 'leave __SRNAME__:'
215 call oad_dump_revmod(); call oad_dump_tapestats()
216 write(*,*)
217
218 our_indent=our_indent-1
219 end subroutine template

  ViewVC Help
Powered by ViewVC 1.1.22