/[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.3 - (hide annotations) (download)
Fri Nov 10 15:34:14 2006 UTC (20 years ago) by utke
Branch: MAIN
Changes since 1.2: +4 -8 lines
cleanup checkpoints

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

  ViewVC Help
Powered by ViewVC 1.1.22