1 |
heimbach |
1.7 |
C $Header: /u/gcmpack/MITgcm/model/src/main_do_loop.F,v 1.6 2013/03/21 18:11:58 jahn Exp $ |
2 |
heimbach |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "PACKAGES_CONFIG.h" |
5 |
|
|
#include "CPP_OPTIONS.h" |
6 |
|
|
#ifdef ALLOW_OBCS |
7 |
|
|
# include "OBCS_OPTIONS.h" |
8 |
|
|
#endif |
9 |
|
|
#ifdef ALLOW_SEAICE |
10 |
|
|
# include "SEAICE_OPTIONS.h" |
11 |
|
|
#endif |
12 |
|
|
#ifdef ALLOW_GENERIC_ADVDIFF |
13 |
|
|
# include "GAD_OPTIONS.h" |
14 |
|
|
#endif |
15 |
|
|
#ifdef ALLOW_GMREDI |
16 |
|
|
# include "GMREDI_OPTIONS.h" |
17 |
|
|
#endif |
18 |
|
|
#ifdef ALLOW_STREAMICE |
19 |
|
|
# include "STREAMICE_OPTIONS.h" |
20 |
|
|
#endif |
21 |
|
|
#ifdef ALLOW_GGL90 |
22 |
|
|
# include "GGL90_OPTIONS.h" |
23 |
|
|
#endif |
24 |
|
|
#ifdef ALLOW_EXF |
25 |
|
|
# include "EXF_OPTIONS.h" |
26 |
|
|
#endif |
27 |
|
|
#ifdef ALLOW_CTRL |
28 |
|
|
# include "CTRL_OPTIONS.h" |
29 |
|
|
#endif |
30 |
|
|
|
31 |
|
|
CBOP |
32 |
|
|
C !ROUTINE: MAIN_DO_LOOP |
33 |
|
|
C !INTERFACE: |
34 |
jmc |
1.2 |
SUBROUTINE MAIN_DO_LOOP( myTime, myIter, myThid ) |
35 |
heimbach |
1.1 |
|
36 |
|
|
C !DESCRIPTION: \bv |
37 |
|
|
C *================================================================* |
38 |
|
|
C | SUBROUTINE the_loop_body |
39 |
|
|
C | o Run the ocean model and evaluate the specified cost function. |
40 |
|
|
C *================================================================* |
41 |
|
|
C | |
42 |
|
|
C | MAIN_DO_LOOP is the toplevel routine for the Tangent Linear and |
43 |
|
|
C | Adjoint Model Compiler (TAMC). |
44 |
|
|
C | For this purpose the initialization |
45 |
|
|
C | of the model was split into two parts. Those parameters that do |
46 |
|
|
C | not depend on a specific model run are set in INITIALISE_FIXED, |
47 |
|
|
C | whereas those that do depend on the specific realization are |
48 |
|
|
C | initialized in INITIALISE_VARIA. |
49 |
|
|
C | This routine is to be used in conjuction with the MITgcmuv |
50 |
|
|
C | checkpoint 37. |
51 |
|
|
C *================================================================* |
52 |
|
|
C \ev |
53 |
|
|
|
54 |
|
|
C !USES: |
55 |
|
|
IMPLICIT NONE |
56 |
|
|
C == Global variables == |
57 |
|
|
#include "SIZE.h" |
58 |
|
|
#include "EEPARAMS.h" |
59 |
|
|
#include "PARAMS.h" |
60 |
|
|
|
61 |
|
|
c************************************** |
62 |
|
|
#ifdef ALLOW_AUTODIFF |
63 |
|
|
# ifndef ALLOW_AUTODIFF_OPENAD |
64 |
|
|
|
65 |
|
|
c These includes are needed for |
66 |
|
|
c AD-checkpointing. |
67 |
|
|
c They provide the fields to be stored. |
68 |
|
|
|
69 |
|
|
# include "AUTODIFF_MYFIELDS.h" |
70 |
|
|
# include "GRID.h" |
71 |
|
|
# include "DYNVARS.h" |
72 |
|
|
# include "SURFACE.h" |
73 |
|
|
# include "FFIELDS.h" |
74 |
|
|
# include "EOS.h" |
75 |
|
|
# include "AUTODIFF.h" |
76 |
|
|
|
77 |
heimbach |
1.7 |
# endif /* ALLOW_AUTODIFF_OPENAD */ |
78 |
|
|
|
79 |
heimbach |
1.1 |
# ifdef ALLOW_GENERIC_ADVDIFF |
80 |
|
|
# include "GAD.h" |
81 |
|
|
# include "GAD_SOM_VARS.h" |
82 |
|
|
# endif |
83 |
|
|
# ifdef ALLOW_MOM_FLUXFORM |
84 |
|
|
# include "MOM_FLUXFORM.h" |
85 |
|
|
# endif |
86 |
|
|
# ifdef ALLOW_CD_CODE |
87 |
|
|
# include "CD_CODE_VARS.h" |
88 |
|
|
# endif |
89 |
|
|
# ifdef ALLOW_PTRACERS |
90 |
|
|
# include "PTRACERS_SIZE.h" |
91 |
|
|
# include "PTRACERS_FIELDS.h" |
92 |
|
|
# include "PTRACERS_START.h" |
93 |
|
|
# endif |
94 |
|
|
# ifdef ALLOW_GCHEM |
95 |
|
|
# include "GCHEM_FIELDS.h" |
96 |
|
|
# endif |
97 |
|
|
# ifdef ALLOW_CFC |
98 |
|
|
# include "CFC.h" |
99 |
|
|
# endif |
100 |
|
|
# ifdef ALLOW_DIC |
101 |
|
|
# include "DIC_VARS.h" |
102 |
|
|
# include "DIC_LOAD.h" |
103 |
|
|
# include "DIC_ATMOS.h" |
104 |
|
|
# include "DIC_CTRL.h" |
105 |
|
|
# include "DIC_COST.h" |
106 |
|
|
# endif |
107 |
|
|
# ifdef ALLOW_OBCS |
108 |
|
|
# include "OBCS_PARAMS.h" |
109 |
|
|
# include "OBCS_FIELDS.h" |
110 |
|
|
# include "OBCS_SEAICE.h" |
111 |
|
|
# ifdef ALLOW_PTRACERS |
112 |
|
|
# include "OBCS_PTRACERS.h" |
113 |
|
|
# endif |
114 |
|
|
# endif |
115 |
|
|
# ifdef ALLOW_EXF |
116 |
|
|
# include "EXF_FIELDS.h" |
117 |
|
|
# ifdef ALLOW_BULKFORMULAE |
118 |
|
|
# include "EXF_CONSTANTS.h" |
119 |
|
|
# endif |
120 |
|
|
# endif /* ALLOW_EXF */ |
121 |
|
|
# ifdef ALLOW_SEAICE |
122 |
|
|
# include "SEAICE_SIZE.h" |
123 |
|
|
# include "SEAICE.h" |
124 |
|
|
# include "SEAICE_PARAMS.h" |
125 |
|
|
# include "SEAICE_COST.h" |
126 |
|
|
# include "SEAICE_TRACER.h" |
127 |
|
|
# endif |
128 |
|
|
# ifdef ALLOW_SALT_PLUME |
129 |
|
|
# include "SALT_PLUME.h" |
130 |
|
|
# endif |
131 |
|
|
# ifdef ALLOW_THSICE |
132 |
|
|
# include "THSICE_SIZE.h" |
133 |
|
|
# include "THSICE_VARS.h" |
134 |
|
|
# endif |
135 |
|
|
# ifdef ALLOW_SHELFICE |
136 |
|
|
# include "SHELFICE.h" |
137 |
|
|
# include "SHELFICE_COST.h" |
138 |
|
|
# endif |
139 |
|
|
# ifdef ALLOW_STREAMICE |
140 |
|
|
# include "STREAMICE.h" |
141 |
|
|
# include "STREAMICE_ADV.h" |
142 |
|
|
# include "STREAMICE_BDRY.h" |
143 |
|
|
# include "STREAMICE_CG.h" |
144 |
|
|
# endif |
145 |
|
|
# ifdef ALLOW_EBM |
146 |
|
|
# include "EBM.h" |
147 |
|
|
# endif |
148 |
|
|
# ifdef ALLOW_RBCS |
149 |
|
|
# include "RBCS_SIZE.h" |
150 |
|
|
# include "RBCS_FIELDS.h" |
151 |
|
|
# endif |
152 |
|
|
# ifdef ALLOW_OFFLINE |
153 |
|
|
# include "OFFLINE.h" |
154 |
|
|
# endif |
155 |
|
|
# ifdef ALLOW_CG2D_NSA |
156 |
|
|
# include "CG2D.h" |
157 |
|
|
# endif |
158 |
|
|
# ifdef ALLOW_DIVIDED_ADJOINT_MPI |
159 |
|
|
# include "mpif.h" |
160 |
|
|
# endif |
161 |
|
|
|
162 |
|
|
# include "tamc.h" |
163 |
|
|
|
164 |
|
|
# ifdef ALLOW_GGL90 |
165 |
|
|
# include "GGL90.h" |
166 |
|
|
# endif |
167 |
|
|
# ifdef ALLOW_PROFILES |
168 |
|
|
# include "profiles.h" |
169 |
|
|
# endif |
170 |
|
|
|
171 |
|
|
# ifdef ALLOW_ECCO_EVOLUTION |
172 |
|
|
# ifdef ALLOW_ECCO |
173 |
|
|
# include "ecco_cost.h" |
174 |
|
|
# endif |
175 |
|
|
# endif |
176 |
|
|
|
177 |
heimbach |
1.7 |
cph# endif /* undef ALLOW_AUTODIFF_OPENAD */ |
178 |
heimbach |
1.1 |
|
179 |
|
|
# ifdef ALLOW_CTRL |
180 |
|
|
# include "CTRL_SIZE.h" |
181 |
|
|
# include "ctrl.h" |
182 |
|
|
# include "ctrl_dummy.h" |
183 |
|
|
# include "CTRL_GENARR.h" |
184 |
|
|
# endif |
185 |
|
|
# ifdef ALLOW_COST |
186 |
|
|
# include "cost.h" |
187 |
|
|
# endif |
188 |
|
|
|
189 |
|
|
#endif /* ALLOW_AUTODIFF */ |
190 |
|
|
c************************************** |
191 |
|
|
|
192 |
|
|
C !INPUT/OUTPUT PARAMETERS: |
193 |
|
|
C == Routine arguments == |
194 |
|
|
C note: under the multi-threaded model myiter and |
195 |
|
|
C mytime are local variables passed around as routine |
196 |
|
|
C arguments. Although this is fiddly it saves the need to |
197 |
|
|
C impose additional synchronisation points when they are |
198 |
|
|
C updated. |
199 |
|
|
C myTime :: time counter for this thread |
200 |
|
|
C myIter :: iteration counter for this thread |
201 |
|
|
C myThid :: thread number for this instance of the routine. |
202 |
|
|
_RL myTime |
203 |
|
|
INTEGER myIter |
204 |
|
|
INTEGER myThid |
205 |
|
|
|
206 |
|
|
C !FUNCTIONS: |
207 |
|
|
C == Functions == |
208 |
|
|
|
209 |
|
|
C !LOCAL VARIABLES: |
210 |
|
|
C == Local variables == |
211 |
jmc |
1.4 |
INTEGER iloop |
212 |
heimbach |
1.1 |
#ifdef ALLOW_AUTODIFF_TAMC |
213 |
|
|
#ifdef STORE_LOADEDREC_TEST |
214 |
jmc |
1.4 |
INTEGER bi,bj |
215 |
heimbach |
1.1 |
#endif /* STORE_LOADEDREC_TEST */ |
216 |
|
|
#endif |
217 |
|
|
|
218 |
|
|
CEOP |
219 |
|
|
|
220 |
|
|
#ifdef ALLOW_DEBUG |
221 |
|
|
IF (debugMode) CALL DEBUG_ENTER('MAIN_DO_LOOP',myThid) |
222 |
|
|
#endif |
223 |
|
|
|
224 |
|
|
c >>>>>>>>>>>>>>>>>>>>>>>>>>> LOOP <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
225 |
|
|
c >>>>>>>>>>>>>>>>>>>>>>>>>>> STARTS <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
226 |
|
|
|
227 |
|
|
c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
228 |
|
|
#ifndef ALLOW_AUTODIFF_OPENAD |
229 |
|
|
c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
230 |
|
|
# ifdef ALLOW_AUTODIFF |
231 |
|
|
# ifdef ALLOW_TAMC_CHECKPOINTING |
232 |
|
|
|
233 |
|
|
max_lev4=nTimeSteps/(nchklev_1*nchklev_2*nchklev_3)+1 |
234 |
|
|
max_lev3=nTimeSteps/(nchklev_1*nchklev_2)+1 |
235 |
|
|
max_lev2=nTimeSteps/nchklev_1+1 |
236 |
|
|
|
237 |
|
|
c************************************** |
238 |
|
|
# ifdef ALLOW_DIVIDED_ADJOINT |
239 |
|
|
CADJ loop = divided |
240 |
|
|
# endif |
241 |
|
|
c************************************** |
242 |
|
|
|
243 |
|
|
# ifdef AUTODIFF_4_LEVEL_CHECKPOINT |
244 |
|
|
do ilev_4 = 1,nchklev_4 |
245 |
|
|
if(ilev_4.le.max_lev4) then |
246 |
|
|
c************************************** |
247 |
|
|
#ifdef ALLOW_AUTODIFF_WHTAPEIO |
248 |
|
|
CALL AUTODIFF_WHTAPEIO_SYNC( 4 , 0, mythid ) |
249 |
|
|
#endif |
250 |
|
|
CALL AUTODIFF_STORE( myThid ) |
251 |
|
|
#include "checkpoint_lev4_directives.h" |
252 |
|
|
CALL AUTODIFF_RESTORE( myThid ) |
253 |
|
|
#ifdef ALLOW_AUTODIFF_WHTAPEIO |
254 |
|
|
CALL AUTODIFF_WHTAPEIO_SYNC( 4 , 1, mythid ) |
255 |
|
|
#endif |
256 |
|
|
c************************************** |
257 |
|
|
c-- Initialise storage for the middle loop. |
258 |
|
|
CADJ INIT tapelev3 = USER |
259 |
|
|
# endif /* AUTODIFF_4_LEVEL_CHECKPOINT */ |
260 |
|
|
|
261 |
|
|
# ifndef AUTODIFF_2_LEVEL_CHECKPOINT |
262 |
|
|
do ilev_3 = 1,nchklev_3 |
263 |
|
|
if(ilev_3.le.max_lev3) then |
264 |
|
|
c************************************** |
265 |
|
|
#ifdef ALLOW_AUTODIFF_WHTAPEIO |
266 |
|
|
CALL AUTODIFF_WHTAPEIO_SYNC( 3 , 0, mythid ) |
267 |
|
|
#endif |
268 |
|
|
CALL AUTODIFF_STORE( myThid ) |
269 |
|
|
#include "checkpoint_lev3_directives.h" |
270 |
|
|
CALL AUTODIFF_RESTORE( myThid ) |
271 |
|
|
#ifdef ALLOW_AUTODIFF_WHTAPEIO |
272 |
|
|
CALL AUTODIFF_WHTAPEIO_SYNC( 3 , 1, mythid ) |
273 |
|
|
#endif |
274 |
|
|
c************************************** |
275 |
|
|
c-- Initialise storage for the middle loop. |
276 |
|
|
CADJ INIT tapelev2 = USER |
277 |
|
|
# endif /* AUTODIFF_2_LEVEL_CHECKPOINT */ |
278 |
|
|
|
279 |
|
|
do ilev_2 = 1,nchklev_2 |
280 |
|
|
if(ilev_2.le.max_lev2) then |
281 |
|
|
c************************************** |
282 |
|
|
#ifdef ALLOW_AUTODIFF_WHTAPEIO |
283 |
|
|
CALL AUTODIFF_WHTAPEIO_SYNC( 2 , 0, mythid ) |
284 |
|
|
#endif |
285 |
|
|
CALL AUTODIFF_STORE( myThid ) |
286 |
|
|
#include "checkpoint_lev2_directives.h" |
287 |
|
|
CALL AUTODIFF_RESTORE( myThid ) |
288 |
|
|
#ifdef ALLOW_AUTODIFF_WHTAPEIO |
289 |
|
|
CALL AUTODIFF_WHTAPEIO_SYNC( 2 , 1, mythid ) |
290 |
|
|
#endif |
291 |
|
|
c************************************** |
292 |
|
|
|
293 |
|
|
# endif /* ALLOW_TAMC_CHECKPOINTING */ |
294 |
|
|
|
295 |
|
|
c************************************** |
296 |
|
|
c-- |
297 |
|
|
c-- Initialize storage for the innermost loop. |
298 |
|
|
c-- Always check common block sizes for the checkpointing! |
299 |
|
|
c-- |
300 |
|
|
CADJ INIT comlev1 = COMMON,nchklev_1 |
301 |
|
|
CADJ INIT comlev1_bibj = COMMON,nchklev_1*nsx*nsy*nthreads_chkpt |
302 |
|
|
CADJ INIT comlev1_bibj_k = COMMON,nchklev_1*nsx*nsy*nr*nthreads_chkpt |
303 |
|
|
c-- |
304 |
|
|
# ifdef ALLOW_KPP |
305 |
|
|
CADJ INIT comlev1_kpp = COMMON,nchklev_1*nsx*nsy |
306 |
|
|
CADJ INIT comlev1_kpp_k = COMMON,nchklev_1*nsx*nsy*nr |
307 |
|
|
# endif /* ALLOW_KPP */ |
308 |
|
|
c-- |
309 |
|
|
# ifdef ALLOW_GMREDI |
310 |
|
|
CADJ INIT comlev1_gmredi_k_gad |
311 |
|
|
CADJ & = COMMON,nchklev_1*nsx*nsy*nr*nthreads_chkpt*maxpass |
312 |
|
|
# endif /* ALLOW_GMREDI */ |
313 |
|
|
c-- |
314 |
|
|
# ifdef ALLOW_PTRACERS |
315 |
|
|
CADJ INIT comlev1_bibj_ptracers = COMMON, |
316 |
|
|
CADJ & nchklev_1*nsx*nsy*nthreads_chkpt*PTRACERS_num |
317 |
|
|
CADJ INIT comlev1_bibj_k_ptracers = COMMON, |
318 |
|
|
CADJ & nchklev_1*nsx*nsy*nthreads_chkpt*PTRACERS_num*nr |
319 |
|
|
# endif /* ALLOW_PTRACERS */ |
320 |
|
|
c-- |
321 |
|
|
# ifndef DISABLE_MULTIDIM_ADVECTION |
322 |
|
|
CADJ INIT comlev1_bibj_gad = COMMON, |
323 |
|
|
CADJ & nchklev_1*nsx*nsy*nthreads_chkpt*maxpass |
324 |
|
|
CADJ INIT comlev1_bibj_k_gad = COMMON, |
325 |
|
|
CADJ & nchklev_1*nsx*nsy*nr*nthreads_chkpt*maxpass |
326 |
|
|
CADJ INIT comlev1_bibj_k_gad_pass = COMMON, |
327 |
|
|
CADJ & nchklev_1*nsx*nsy*nr*nthreads_chkpt*maxpass*maxpass |
328 |
|
|
# endif /* DISABLE_MULTIDIM_ADVECTION */ |
329 |
|
|
c-- |
330 |
|
|
# ifdef ALLOW_MOM_COMMON |
331 |
|
|
# ifndef AUTODIFF_DISABLE_LEITH |
332 |
|
|
CADJ INIT comlev1_mom_ijk_loop |
333 |
|
|
CADJ & = COMMON,nchklev_1* |
334 |
|
|
CADJ & (snx+2*olx)*nsx*(sny+2*oly)*nsy*nr*nthreads_chkpt |
335 |
|
|
# endif /* AUTODIFF_DISABLE_LEITH */ |
336 |
|
|
# endif /* ALLOW_MOM_COMMON */ |
337 |
|
|
c-- |
338 |
|
|
# if (defined (ALLOW_EXF) && defined (ALLOW_BULKFORMULAE)) |
339 |
|
|
CADJ INIT comlev1_exf_1 |
340 |
|
|
CADJ & = COMMON,nchklev_1*snx*nsx*sny*nsy*nthreads_chkpt |
341 |
|
|
CADJ INIT comlev1_exf_2 |
342 |
|
|
CADJ & = COMMON,niter_bulk*nchklev_1*snx*nsx*sny*nsy*nthreads_chkpt |
343 |
|
|
# endif /* ALLOW_BULKFORMULAE */ |
344 |
|
|
c-- |
345 |
|
|
# ifdef ALLOW_SEAICE |
346 |
|
|
# ifdef SEAICE_ALLOW_DYNAMICS |
347 |
|
|
CADJ INIT comlev1_dynsol = COMMON,nchklev_1*MPSEUDOTIMESTEPS |
348 |
|
|
# ifdef SEAICE_LSR_ADJOINT_ITER |
349 |
|
|
CADJ INIT comlev1_dyniter = |
350 |
|
|
CADJ & COMMON,nchklev_1*MPSEUDOTIMESTEPS*SOLV_MAX_FIXED |
351 |
|
|
# endif |
352 |
|
|
# endif |
353 |
|
|
# ifdef SEAICE_ALLOW_EVP |
354 |
|
|
CADJ INIT comlev1_evp = COMMON,nEVPstepMax*nchklev_1 |
355 |
|
|
# endif |
356 |
|
|
# ifdef SEAICE_MULTICATEGORY |
357 |
|
|
CADJ INIT comlev1_multdim |
358 |
|
|
CADJ & = COMMON,nchklev_1*nsx*nsy*nthreads_chkpt*multdim |
359 |
|
|
# endif |
360 |
|
|
# ifndef DISABLE_MULTIDIM_ADVECTION |
361 |
|
|
CADJ INIT comlev1_bibj_k_gadice = COMMON, |
362 |
|
|
CADJ & nchklev_1*nsx*nsy*nthreads_chkpt*maxpass |
363 |
|
|
CADJ INIT comlev1_bibj_k_gadice_pass = COMMON, |
364 |
|
|
CADJ & nchklev_1*nsx*nsy*nthreads_chkpt*maxpass*maxpass |
365 |
|
|
# endif /* DISABLE_MULTIDIM_ADVECTION */ |
366 |
|
|
# endif /* ALLOW_SEAICE */ |
367 |
|
|
c-- |
368 |
|
|
# ifdef ALLOW_THSICE |
369 |
|
|
CADJ INIT comlev1_thsice_1 |
370 |
|
|
CADJ & = COMMON,nchklev_1*snx*nsx*sny*nsy*nthreads_chkpt |
371 |
|
|
CADJ INIT comlev1_thsice_2 |
372 |
|
|
CADJ & = COMMON,nchklev_1*snx*nsx*sny*nsy*nlyr*nthreads_chkpt |
373 |
|
|
CADJ INIT comlev1_thsice_3 |
374 |
|
|
CADJ & = COMMON,nchklev_1*snx*nsx*sny*nsy*MaxTsf*nthreads_chkpt |
375 |
|
|
CADJ INIT comlev1_thsice_4 |
376 |
|
|
CADJ & = COMMON,nchklev_1*nsx*nsy*maxpass*nthreads_chkpt |
377 |
|
|
# endif /* ALLOW_THSICE */ |
378 |
|
|
c-- |
379 |
|
|
# ifdef ALLOW_STREAMICE |
380 |
|
|
CADJ INIT comlev1_stream_nl = COMMON,nchklev_1*streamice_max_nl |
381 |
|
|
CADJ INIT comlev1_stream_front = COMMON,nchklev_1*4 |
382 |
|
|
CADJ INIT comlev1_stream_ij |
383 |
|
|
CADJ & = COMMON,nchklev_1*4*(snx+2)*nsx*(sny+2)*nsy |
384 |
|
|
CADJ INIT comlev1_stream_hybrid |
385 |
|
|
CADJ & = COMMON,nchklev_1*snx*nsx*sny*nsy*nr*nthreads_chkpt |
386 |
|
|
# endif |
387 |
|
|
c-- |
388 |
|
|
# ifdef ALLOW_CG2D_NSA |
389 |
|
|
CADJ INIT comlev1_cg2d |
390 |
|
|
CADJ & = COMMON,nchklev_1*nthreads_chkpt |
391 |
|
|
CADJ INIT comlev1_cg2d_iter |
392 |
|
|
CADJ & = COMMON,nchklev_1*nthreads_chkpt*numItersMax |
393 |
|
|
# endif |
394 |
|
|
c-- |
395 |
|
|
c************************************** |
396 |
|
|
|
397 |
|
|
#ifdef STORE_LOADEDREC_TEST |
398 |
|
|
DO bj = myByLo(myThid), myByHi(myThid) |
399 |
|
|
DO bi = myBxLo(myThid), myBxHi(myThid) |
400 |
|
|
loadedRec(bi,bj) = 0 |
401 |
|
|
ENDDO |
402 |
|
|
ENDDO |
403 |
|
|
#endif /* STORE_LOADEDREC_TEST */ |
404 |
|
|
|
405 |
|
|
#ifdef ALLOW_TAMC_CHECKPOINTING |
406 |
|
|
|
407 |
|
|
do ilev_1 = 1,nchklev_1 |
408 |
|
|
|
409 |
|
|
c-- The if-statement below introduces a some flexibility in the |
410 |
|
|
c-- choice of the 3-tupel ( nchklev_1, nchklev_2, nchklev_3 ). |
411 |
|
|
|
412 |
|
|
iloop = (ilev_2 - 1)*nchklev_1 + ilev_1 |
413 |
|
|
# ifndef AUTODIFF_2_LEVEL_CHECKPOINT |
414 |
|
|
& + (ilev_3 - 1)*nchklev_2*nchklev_1 |
415 |
|
|
# endif |
416 |
|
|
# ifdef AUTODIFF_4_LEVEL_CHECKPOINT |
417 |
|
|
& + (ilev_4 - 1)*nchklev_3*nchklev_2*nchklev_1 |
418 |
|
|
# endif |
419 |
|
|
|
420 |
|
|
if ( iloop .le. nTimeSteps ) then |
421 |
|
|
|
422 |
|
|
# else /* ALLOW_TAMC_CHECKPOINTING undefined */ |
423 |
|
|
|
424 |
|
|
DO iloop = 1, nTimeSteps |
425 |
|
|
|
426 |
|
|
# endif /* ALLOW_TAMC_CHECKPOINTING */ |
427 |
|
|
# endif /* ALLOW_AUTODIFF */ |
428 |
|
|
|
429 |
|
|
#endif /* undef ALLOW_AUTODIFF_OPENAD */ |
430 |
|
|
|
431 |
|
|
#ifdef ALLOW_AUTODIFF_OPENAD |
432 |
utke |
1.3 |
DO iloop = 1, nTimeSteps |
433 |
heimbach |
1.1 |
#endif |
434 |
|
|
|
435 |
|
|
#ifndef ALLOW_AUTODIFF |
436 |
|
|
|
437 |
|
|
c-- Start the main loop of adjoint_Objfunc. Automatic differentiation |
438 |
|
|
c-- NOT enabled. |
439 |
|
|
DO iloop = 1, nTimeSteps |
440 |
|
|
|
441 |
|
|
#endif /* ALLOW_AUTODIFF */ |
442 |
|
|
|
443 |
|
|
c-- >>> Loop body start <<< |
444 |
|
|
|
445 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
446 |
|
|
nIter0 = NINT( (startTime-baseTime)/deltaTClock ) |
447 |
utke |
1.3 |
# ifndef ALLOW_AUTODIFF_OPENAD |
448 |
heimbach |
1.1 |
ikey_dynamics = ilev_1 |
449 |
utke |
1.3 |
# endif |
450 |
heimbach |
1.1 |
#endif |
451 |
|
|
|
452 |
|
|
#ifdef ALLOW_ECCO |
453 |
|
|
#ifdef ALLOW_ECCO_EVOLUTION |
454 |
|
|
#ifdef ALLOW_DEBUG |
455 |
|
|
IF (debugMode) CALL DEBUG_CALL('cost_averagesfields',myThid) |
456 |
|
|
#endif |
457 |
|
|
c-- Accumulate time averages of temperature, salinity |
458 |
|
|
#ifdef ALLOW_AUTODIFF |
459 |
|
|
C-- Reset the model iteration counter and the model time. |
460 |
|
|
myIter = nIter0 + (iloop-1) |
461 |
jmc |
1.2 |
myTime = startTime + float(iloop-1)*deltaTClock |
462 |
heimbach |
1.1 |
#endif |
463 |
|
|
CALL TIMER_START('COST_AVERAGESFIELDS [MAIN_DO_LOOP]',mythid) |
464 |
|
|
CALL COST_AVERAGESFIELDS( mytime, mythid ) |
465 |
|
|
CALL TIMER_STOP ('COST_AVERAGESFIELDS [MAIN_DO_LOOP]',mythid) |
466 |
|
|
#endif /* ALLOW_ECCO_EVOLUTION */ |
467 |
|
|
#endif /* ALLOW_ECCO */ |
468 |
|
|
|
469 |
|
|
#ifdef ALLOW_PROFILES |
470 |
|
|
IF (usePROFILES) THEN |
471 |
|
|
#ifdef ALLOW_DEBUG |
472 |
|
|
IF (debugMode) CALL DEBUG_CALL('profiles_inloop',myThid) |
473 |
|
|
#endif |
474 |
|
|
c-- Accumulate in-situ time averages of theta, salt, and SSH. |
475 |
|
|
#ifdef ALLOW_AUTODIFF |
476 |
|
|
C-- Reset the model iteration counter and the model time. |
477 |
|
|
myIter = nIter0 + (iloop-1) |
478 |
jmc |
1.2 |
myTime = startTime + float(iloop-1)*deltaTClock |
479 |
heimbach |
1.1 |
#endif |
480 |
|
|
CALL TIMER_START('PROFILES_INLOOP [MAIN_DO_LOOP]', mythid) |
481 |
|
|
CALL PROFILES_INLOOP( mytime, mythid ) |
482 |
|
|
CALL TIMER_STOP ('PROFILES_INLOOP [MAIN_DO_LOOP]', mythid) |
483 |
|
|
ENDIF |
484 |
|
|
#endif |
485 |
|
|
|
486 |
|
|
#ifdef ALLOW_DEBUG |
487 |
|
|
IF (debugMode) CALL DEBUG_CALL('FORWARD_STEP',myThid) |
488 |
|
|
#endif |
489 |
|
|
|
490 |
|
|
#ifdef ALLOW_ATM2D |
491 |
|
|
CALL TIMER_START('FORWARD_STEP_ATM2D [MAIN_DO_LOOP]',mythid) |
492 |
|
|
CALL FORWARD_STEP_ATM2D( iloop, mytime, myiter, mythid ) |
493 |
|
|
CALL TIMER_STOP ('FORWARD_STEP_ATM2D [MAIN_DO_LOOP]',mythid) |
494 |
|
|
#else |
495 |
|
|
CALL TIMER_START('FORWARD_STEP [MAIN_DO_LOOP]',mythid) |
496 |
|
|
CALL FORWARD_STEP( iloop, mytime, myiter, mythid ) |
497 |
|
|
CALL TIMER_STOP ('FORWARD_STEP [MAIN_DO_LOOP]',mythid) |
498 |
|
|
#endif |
499 |
|
|
|
500 |
|
|
c-- >>> Loop body end <<< |
501 |
|
|
#ifdef ALLOW_AUTODIFF |
502 |
|
|
# ifndef ALLOW_AUTODIFF_OPENAD |
503 |
|
|
|
504 |
|
|
# ifdef ALLOW_TAMC_CHECKPOINTING |
505 |
|
|
endif |
506 |
|
|
enddo |
507 |
|
|
endif |
508 |
|
|
enddo |
509 |
|
|
# ifndef AUTODIFF_2_LEVEL_CHECKPOINT |
510 |
|
|
endif |
511 |
|
|
enddo |
512 |
|
|
# endif |
513 |
|
|
# ifdef AUTODIFF_4_LEVEL_CHECKPOINT |
514 |
|
|
endif |
515 |
|
|
enddo |
516 |
|
|
# endif |
517 |
|
|
# else /* ndef ALLOW_TAMC_CHECKPOINTING */ |
518 |
jmc |
1.4 |
ENDDO |
519 |
heimbach |
1.1 |
# endif /* ALLOW_TAMC_CHECKPOINTING */ |
520 |
jmc |
1.5 |
# else /* ndef ALLOW_AUTODIFF_OPENAD */ |
521 |
jmc |
1.4 |
ENDDO |
522 |
heimbach |
1.1 |
# endif /* ALLOW_AUTODIFF_OPENAD */ |
523 |
|
|
#else /* ALLOW_AUTODIFF */ |
524 |
jmc |
1.4 |
ENDDO |
525 |
heimbach |
1.1 |
#endif /* ALLOW_AUTODIFF */ |
526 |
|
|
|
527 |
|
|
#ifdef ALLOW_DEBUG |
528 |
|
|
IF (debugMode) CALL DEBUG_LEAVE('MAIN_DO_LOOP',myThid) |
529 |
|
|
#endif |
530 |
|
|
|
531 |
|
|
RETURN |
532 |
|
|
END |