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

Annotation of /MITgcm_contrib/heimbach/OpenAD/code_shallow_openad2/ad_template.checkpoint.f

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


Revision 1.2 - (hide annotations) (download)
Tue Nov 7 19:18:39 2006 UTC (20 years ago) by utke
Branch: MAIN
Changes since 1.1: +18 -14 lines
switch checkpoint writes to file

1 utke 1.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 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     character*(80):: indentation='
53     + '
54    
55     our_indent=our_indent+1
56    
57     write(*,
58 utke 1.2 +'(A,A,A,A,L,A,L,A,L,A,L,A,L,A,L,A,I8,A,I8)')
59 utke 1.1 +'JU:',indentation(1:our_indent), 'enter __SRNAME__:',
60     +' As:',our_rev_mode%arg_store,
61     +' Ar:',our_rev_mode%arg_restore,
62     +' Pl:',our_rev_mode%plain,
63     +' Ta:',our_rev_mode%tape,
64     +' Ad:',our_rev_mode%adjoint,
65     +' Sw:',our_rev_mode%switchedToCheckpoint,
66     +' TD:',double_tape_pointer,
67     +' TI:',integer_tape_pointer
68    
69     if (our_rev_mode%switchedToCheckpoint) then
70    
71     if (our_rev_mode%arg_store) then
72 utke 1.2 call cp_open()
73 utke 1.1 write(*,'(A,A,A)')
74     +'JU:',indentation(1:our_indent),
75     +' __SRNAME__: entering arg store'
76 utke 1.2 !$PLACEHOLDER_PRAGMA$ id=8
77     call cp_close()
78     cp_file_number=cp_file_number+1
79 utke 1.1 end if
80     if (our_rev_mode%arg_restore) then
81     write(*,'(A,A,A)')
82     +'JU:',indentation(1:our_indent),
83     +' __SRNAME__: entering arg restore'
84 utke 1.2 cp_file_number=cp_file_number-1
85     call cp_open()
86     !$PLACEHOLDER_PRAGMA$ id=9
87     call cp_close()
88 utke 1.1 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 utke 1.2 call cp_open()
163     !$PLACEHOLDER_PRAGMA$ id=8
164     call cp_close()
165     cp_file_number=cp_file_number+1
166 utke 1.1 c now do the forward run down a plain
167     our_orig_mode=our_rev_mode
168     our_rev_mode%arg_store=.FALSE.
169     our_rev_mode%arg_restore=.FALSE.
170     our_rev_mode%plain=.TRUE.
171     our_rev_mode%tape=.FALSE.
172     our_rev_mode%adjoint=.FALSE.
173     write(*,'(A,A,A)')
174     +'JU:',indentation(1:our_indent), ' __SRNAME__: s2c run plain'
175     !$PLACEHOLDER_PRAGMA$ id=1
176     our_rev_mode=our_orig_mode
177     end if
178     if (our_rev_mode%adjoint) then
179     write(*,'(A,A,A)')
180     +'JU:',indentation(1:our_indent),
181     +' __SRNAME__: s2c entering as adjoint'
182     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     write(*,'(A,A,A)')
186     +'JU:',indentation(1:our_indent),
187     +' __SRNAME__: s2c restore argument cp'
188 utke 1.2 cp_file_number=cp_file_number-1
189     call cp_open()
190     !$PLACEHOLDER_PRAGMA$ id=9
191     call cp_close()
192 utke 1.1 c setup checkpointing downwards
193     our_orig_mode=our_rev_mode
194     our_rev_mode%arg_store=.TRUE.
195     our_rev_mode%arg_restore=.FALSE.
196     our_rev_mode%plain=.TRUE.
197     our_rev_mode%tape=.FALSE.
198     our_rev_mode%adjoint=.FALSE.
199     c taping this level
200     write(*,'(A,A,A,A)')
201     +'JU:',indentation(1:our_indent),
202     +' __SRNAME__: s2c run tape, down arg store/plain'
203     !$PLACEHOLDER_PRAGMA$ id=2
204     c setting up for taping downwards
205     our_rev_mode%arg_store=.FALSE.
206     our_rev_mode%arg_restore=.TRUE.
207     our_rev_mode%plain=.FALSE.
208     our_rev_mode%tape=.TRUE.
209     our_rev_mode%adjoint=.TRUE.
210     c adjoining this level
211     write(*,'(A,A,A,A)')
212     +'JU:',indentation(1:our_indent),
213     +' __SRNAME__: s2c run adjoint, down arg restore/tape'
214     !$PLACEHOLDER_PRAGMA$ id=3
215     our_rev_mode=our_orig_mode
216     end if
217    
218     our_rev_mode%switchedToCheckpoint=.FALSE.
219    
220     end if
221    
222     write(*,
223 utke 1.2 +'(A,A,A,A,L,A,L,A,L,A,L,A,L,A,L,A,I8,A,I8)')
224 utke 1.1 +'JU:',indentation(1:our_indent), 'leave __SRNAME__:',
225     +' As:',our_rev_mode%arg_store,
226     +' Ar:',our_rev_mode%arg_restore,
227     +' Pl:',our_rev_mode%plain,
228     +' Ta:',our_rev_mode%tape,
229     +' Ad:',our_rev_mode%adjoint,
230     +' Sw:',our_rev_mode%switchedToCheckpoint,
231     +' TD:',double_tape_pointer,
232     +' TI:',integer_tape_pointer
233    
234     our_indent=our_indent-1
235     end subroutine template

  ViewVC Help
Powered by ViewVC 1.1.22