1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/the_main_loop.F,v 1.49 2006/12/14 22:31:18 heimbach Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
|
7 |
#ifdef ALLOW_OBCS |
8 |
# include "OBCS_OPTIONS.h" |
9 |
#endif |
10 |
#ifdef ALLOW_SEAICE |
11 |
# include "SEAICE_OPTIONS.h" |
12 |
#endif |
13 |
#ifdef ALLOW_GMREDI |
14 |
# include "GMREDI_OPTIONS.h" |
15 |
#endif |
16 |
|
17 |
subroutine the_main_loop( myTime, myIter, mythid ) |
18 |
|
19 |
c ================================================================== |
20 |
c SUBROUTINE the_main_loop |
21 |
c ================================================================== |
22 |
c |
23 |
c o Run the ocean model and evaluate the specified cost function. |
24 |
c |
25 |
c *the_main_loop* is the top-level routine for the Tangent Linear and |
26 |
c Adjoint Model Compiler (TAMC). For this purpose, the initialization |
27 |
c of the model was split into two parts. Those parameters that do |
28 |
c not depend on a specific model run are set in *initialise_fixed*, |
29 |
c whereas those that do depend on the specific realization are |
30 |
c initialized in *initialise_varia*. In order to do a so called |
31 |
c checkpointing during the adjoint calculation and to account for the |
32 |
c typical data involved in oceanographic applications a call tree |
33 |
c that is divided into yearly, monthly, daily, and step parts can |
34 |
c be used. |
35 |
c |
36 |
c This routine is to be used in conjuction with the MITgcmuv release |
37 |
c checkpoint 24. |
38 |
c |
39 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
40 |
c |
41 |
c changed: Christian Eckert eckert@mit.edu 14-Jul-1999 |
42 |
c |
43 |
c - The call to mapping was moved to initialise_varia, |
44 |
c since this routine has to be called before |
45 |
c ini_predictor. |
46 |
c |
47 |
c Christian Eckert eckert@mit.edu 11-Feb-2000 |
48 |
c |
49 |
c - Restructured the code in order to create a package |
50 |
c for the MITgcmUV. |
51 |
c |
52 |
c Patrick Heimbach heimbach@mit.edu 3-Jun-2000 |
53 |
c - corrected computation of ikey_dynamics and |
54 |
c added computation of ikey_dynamics for the case |
55 |
c undef ALLOW_TAMC_CHECKPOINTING |
56 |
c |
57 |
c Patrick Heimbach heimbach@mit.edu 6-Jun-2000 |
58 |
c - corrected initialisation of comlev1 common blocks |
59 |
c |
60 |
c Dimitris Menemenlis menemenlis@jpl.nasa.gov 26-Feb-2003 |
61 |
c - modifications for pkg/seaice |
62 |
c |
63 |
c ================================================================== |
64 |
c SUBROUTINE the_main_loop |
65 |
c ================================================================== |
66 |
|
67 |
implicit none |
68 |
|
69 |
c == global variables == |
70 |
|
71 |
#include "SIZE.h" |
72 |
#include "EEPARAMS.h" |
73 |
#include "PARAMS.h" |
74 |
|
75 |
#ifdef ALLOW_MNC |
76 |
#include "MNC_PARAMS.h" |
77 |
EXTERNAL DIFFERENT_MULTIPLE |
78 |
LOGICAL DIFFERENT_MULTIPLE |
79 |
#endif |
80 |
|
81 |
#ifdef HAVE_SIGREG |
82 |
#include "SIGREG.h" |
83 |
#endif |
84 |
|
85 |
#ifdef ALLOW_SHAP_FILT |
86 |
# include "SHAP_FILT.h" |
87 |
#endif |
88 |
#ifdef ALLOW_ZONAL_FILT |
89 |
# include "ZONAL_FILT.h" |
90 |
#endif |
91 |
#ifdef COMPONENT_MODULE |
92 |
# include "CPL_PARAMS.h" |
93 |
#endif |
94 |
|
95 |
c************************************** |
96 |
#ifdef ALLOW_AUTODIFF_TAMC |
97 |
|
98 |
c These includes are needed for |
99 |
c AD-checkpointing. |
100 |
c They provide the fields to be stored. |
101 |
|
102 |
# include "GRID.h" |
103 |
# include "DYNVARS.h" |
104 |
# include "FFIELDS.h" |
105 |
# include "EOS.h" |
106 |
|
107 |
# ifdef ALLOW_GENERIC_ADVDIFF |
108 |
# include "GAD.h" |
109 |
# endif |
110 |
# ifdef ALLOW_CD_CODE |
111 |
# include "CD_CODE_VARS.h" |
112 |
# endif |
113 |
# ifdef ALLOW_PTRACERS |
114 |
# include "PTRACERS_SIZE.h" |
115 |
# include "PTRACERS.h" |
116 |
# endif |
117 |
# ifdef ALLOW_NONHYDROSTATIC |
118 |
# include "CG3D.h" |
119 |
# endif |
120 |
# if (defined (EXACT_CONSERV) || defined (NONLIN_FRSURF)) |
121 |
# include "SURFACE.h" |
122 |
# endif |
123 |
# ifdef ALLOW_OBCS |
124 |
# include "OBCS.h" |
125 |
# endif |
126 |
# ifdef ALLOW_EXF |
127 |
# include "exf_fields.h" |
128 |
# include "exf_clim_fields.h" |
129 |
# ifdef ALLOW_BULKFORMULAE |
130 |
# include "exf_constants.h" |
131 |
# endif |
132 |
# endif /* ALLOW_EXF */ |
133 |
# ifdef ALLOW_SEAICE |
134 |
# include "SEAICE.h" |
135 |
# include "SEAICE_COST.h" |
136 |
# endif |
137 |
# ifdef ALLOW_KPP |
138 |
# include "KPP.h" |
139 |
# endif |
140 |
# ifdef ALLOW_GMREDI |
141 |
# include "GMREDI.h" |
142 |
# endif |
143 |
# ifdef ALLOW_RBCS |
144 |
# include "RBCS.h" |
145 |
# endif |
146 |
# ifdef ALLOW_PROFILES |
147 |
# include "profiles.h" |
148 |
# endif |
149 |
# ifdef ALLOW_DIVIDED_ADJOINT_MPI |
150 |
# include "mpif.h" |
151 |
# endif |
152 |
|
153 |
# include "tamc.h" |
154 |
# include "ctrl.h" |
155 |
# include "ctrl_dummy.h" |
156 |
# include "cost.h" |
157 |
# include "ecco_cost.h" |
158 |
|
159 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
160 |
c************************************** |
161 |
|
162 |
c == routine arguments == |
163 |
c note: under the multi-threaded model myiter and |
164 |
c mytime are local variables passed around as routine |
165 |
c arguments. Although this is fiddly it saves the need to |
166 |
c impose additional synchronisation points when they are |
167 |
c updated. |
168 |
c myiter - iteration counter for this thread |
169 |
c mytime - time counter for this thread |
170 |
c mythid - thread number for this instance of the routine. |
171 |
integer mythid |
172 |
integer myiter |
173 |
_RL mytime |
174 |
|
175 |
c == local variables == |
176 |
|
177 |
integer bi,bj |
178 |
integer iloop |
179 |
integer mydate(4) |
180 |
#ifdef ALLOW_SNAPSHOTS |
181 |
character yprefix*3 |
182 |
#endif |
183 |
|
184 |
#ifdef ALLOW_TAMC_CHECKPOINTING |
185 |
integer ilev_1 |
186 |
integer ilev_2 |
187 |
integer ilev_3 |
188 |
integer ilev_4 |
189 |
integer max_lev2 |
190 |
integer max_lev3 |
191 |
integer max_lev4 |
192 |
#endif |
193 |
|
194 |
#if defined(TIME_PER_TIMESTEP) || defined(USE_PAPI_FLOPS) || defined(USE_PCL_FLOPS) |
195 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
196 |
#ifdef TIME_PER_TIMESTEP |
197 |
CCE107 common block for per timestep timing |
198 |
C !TIMING VARIABLES |
199 |
C == Timing variables == |
200 |
REAL*8 utnew, utold, stnew, stold, wtnew, wtold |
201 |
DATA utnew, utold, stnew, stold, wtnew, wtold /6*0.0D0/ |
202 |
#endif |
203 |
#ifdef USE_PAPI_FLOPS |
204 |
CCE107 common block for PAPI summary performance |
205 |
#include <fpapi.h> |
206 |
INTEGER*8 flpops, instr |
207 |
DATA flpops, instr /2*0/ |
208 |
INTEGER check |
209 |
REAL*4 real_time, proc_time, mflops, ipc |
210 |
DATA real_time, proc_time, mflops, ipc /4*0.0E0/ |
211 |
#else |
212 |
#ifdef USE_PCL_FLOPS |
213 |
CCE107 common block for PCL summary performance |
214 |
#include <pclh.f> |
215 |
INTEGER pcl_counter_list(5), flags, nevents, res, ipcl |
216 |
INTEGER*8 i_result(5), descr |
217 |
REAL*8 fp_result(5) |
218 |
COMMON /pclvars/ i_result, descr, fp_result, pcl_counter_list, |
219 |
$ flags, nevents |
220 |
INTEGER nmaxevents |
221 |
PARAMETER (nmaxevents = 61) |
222 |
CHARACTER*22 pcl_counter_name(0:nmaxevents-1) |
223 |
COMMON /pclnames/ pcl_counter_name |
224 |
#endif |
225 |
#endif |
226 |
#endif |
227 |
c-- == end of interface == |
228 |
|
229 |
#ifndef DISABLE_DEBUGMODE |
230 |
IF ( debugLevel .GE. debLevB ) |
231 |
& CALL DEBUG_ENTER('THE_MAIN_LOOP',myThid) |
232 |
#endif |
233 |
|
234 |
#ifdef ALLOW_AUTODIFF_TAMC |
235 |
c-- Initialize storage for the initialisations. |
236 |
CADJ INIT tapelev_ini_bibj_k = USER |
237 |
CADJ INIT tapelev_init = USER |
238 |
c |
239 |
#if (defined (AUTODIFF_2_LEVEL_CHECKPOINT)) |
240 |
CADJ INIT tapelev2 = USER |
241 |
#elif (defined (AUTODIFF_4_LEVEL_CHECKPOINT)) |
242 |
CADJ INIT tapelev4 = USER |
243 |
#else |
244 |
CADJ INIT tapelev3 = USER |
245 |
#endif |
246 |
c |
247 |
# ifdef ALLOW_DIVIDED_ADJOINT |
248 |
CADJ INIT onetape = user |
249 |
cphCADJ INIT onetape = common, 1 |
250 |
cph We want to avoid common blocks except in the inner loop. |
251 |
cph Reason: the active write and consecutive read may occur |
252 |
cph in separate model executions for which the info |
253 |
cph in common blocks are lost. |
254 |
cph Thus, we can only store real values (no integers) |
255 |
cph because we only have active file handling to real available. |
256 |
# endif |
257 |
# ifdef ALLOW_TAMC_CHECKPOINTING |
258 |
ikey_dynamics = 1 |
259 |
# endif |
260 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
261 |
|
262 |
CALL TIMER_START('ECCO SPIN-UP', mythid) |
263 |
|
264 |
#ifdef ALLOW_CAL |
265 |
c-- Get the current date. |
266 |
call CAL_TIMESTAMP( myiter, mytime, mydate, mythid ) |
267 |
#endif |
268 |
|
269 |
#ifdef ALLOW_AUTODIFF_TAMC |
270 |
# ifdef NONLIN_FRSURF |
271 |
CADJ STORE hFacC = tapelev_init, key = 1 |
272 |
# endif |
273 |
#endif |
274 |
|
275 |
C-- Set initial conditions (variable arrays) |
276 |
#ifndef DISABLE_DEBUGMODE |
277 |
IF ( debugLevel .GE. debLevB ) |
278 |
& CALL DEBUG_CALL('INITIALISE_VARIA',myThid) |
279 |
#endif |
280 |
CALL TIMER_START('INITIALISE_VARIA [THE_MAIN_LOOP]', mythid) |
281 |
CALL INITIALISE_VARIA( mythid ) |
282 |
CALL TIMER_STOP ('INITIALISE_VARIA [THE_MAIN_LOOP]', mythid) |
283 |
|
284 |
#ifdef ALLOW_MONITOR |
285 |
#ifdef ALLOW_DEBUG |
286 |
IF (debugMode) CALL DEBUG_CALL('MONITOR',myThid) |
287 |
#endif |
288 |
C-- Check status of solution (statistics, cfl, etc...) |
289 |
CALL TIMER_START('MONITOR [THE_MAIN_LOOP]', mythid) |
290 |
CALL MONITOR( myIter, myTime, myThid ) |
291 |
CALL TIMER_STOP ('MONITOR [THE_MAIN_LOOP]', mythid) |
292 |
#endif /* ALLOW_MONITOR */ |
293 |
|
294 |
C-- Do IO if needed (Dump for start state). |
295 |
#ifdef ALLOW_DEBUG |
296 |
IF (debugMode) CALL DEBUG_CALL('DO_THE_MODEL_IO',myThid) |
297 |
#endif |
298 |
|
299 |
#ifdef ALLOW_OFFLINE |
300 |
CALL TIMER_START('OFFLINE_MODEL_IO [FORWARD_STEP]',myThid) |
301 |
CALL OFFLINE_MODEL_IO( myTime, myIter, myThid ) |
302 |
CALL TIMER_STOP ('OFFLINE_MODEL_IO [FORWARD_STEP]',myThid) |
303 |
#else |
304 |
CALL TIMER_START('DO_THE_MODEL_IO [THE_MAIN_LOOP]', mythid) |
305 |
CALL DO_THE_MODEL_IO( myTime, myIter, mythid ) |
306 |
CALL TIMER_STOP ('DO_THE_MODEL_IO [THE_MAIN_LOOP]', mythid) |
307 |
#endif |
308 |
|
309 |
call timer_stop ('ECCO SPIN-UP', mythid) |
310 |
_BARRIER |
311 |
|
312 |
#ifdef TIME_PER_TIMESTEP |
313 |
CCE107 Initial call for timers |
314 |
_BEGIN_MASTER( myThid ) |
315 |
CALL TIMER_GET_TIME( utold, stold, wtold ) |
316 |
_END_MASTER( myThid ) |
317 |
#endif |
318 |
#ifdef USE_PAPI_FLOPS |
319 |
CCE107 Initial call for PAPI |
320 |
_BEGIN_MASTER( myThid ) |
321 |
#ifdef USE_FLIPS |
322 |
call PAPIF_flips(real_time, proc_time, flpops, mflops, check) |
323 |
#else |
324 |
call PAPIF_flops(real_time, proc_time, flpops, mflops, check) |
325 |
#endif |
326 |
WRITE(msgBuf,'(A34,F10.6,A,F10.6)') |
327 |
$ 'Mflop/s before timestepping:', mflops, ' ', mflops*proc_time |
328 |
$ /(real_time + 1E-36) |
329 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
330 |
#ifdef PAPI_VERSION |
331 |
call PAPIF_ipc(real_time, proc_time, instr, ipc, check) |
332 |
WRITE(msgBuf,'(A34,F10.6,A,F10.6)') |
333 |
$ 'IPC before timestepping:', ipc, ' ', ipc*proc_time |
334 |
$ /(real_time + 1E-36) |
335 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
336 |
#endif |
337 |
_END_MASTER( myThid ) |
338 |
#else |
339 |
#ifdef USE_PCL_FLOPS |
340 |
CCE107 Initial call for PCL |
341 |
_BEGIN_MASTER( myThid ) |
342 |
res = PCLstop(descr, i_result, fp_result, nevents) |
343 |
do ipcl = 1, nevents |
344 |
WRITE(msgBuf,'(A22,A26,F10.6)'), |
345 |
$ pcl_counter_name(pcl_counter_list(ipcl)), |
346 |
$ 'before timestepping:', fp_result(ipcl) |
347 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
348 |
enddo |
349 |
res = PCLstart(descr, pcl_counter_list, nevents, flags) |
350 |
_END_MASTER( myThid ) |
351 |
#endif |
352 |
#endif |
353 |
|
354 |
c-- Do the model integration. |
355 |
call timer_start('ECCO MAIN LOOP',mythid) |
356 |
|
357 |
c >>>>>>>>>>>>>>>>>>>>>>>>>>> LOOP <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
358 |
c >>>>>>>>>>>>>>>>>>>>>>>>>>> STARTS <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
359 |
|
360 |
#ifdef ALLOW_AUTODIFF_TAMC |
361 |
#ifdef ALLOW_TAMC_CHECKPOINTING |
362 |
|
363 |
max_lev4=nTimeSteps/(nchklev_1*nchklev_2*nchklev_3)+1 |
364 |
max_lev3=nTimeSteps/(nchklev_1*nchklev_2)+1 |
365 |
max_lev2=nTimeSteps/nchklev_1+1 |
366 |
|
367 |
c************************************** |
368 |
#ifdef ALLOW_DIVIDED_ADJOINT |
369 |
CADJ loop = divided |
370 |
#endif |
371 |
c************************************** |
372 |
|
373 |
#ifdef AUTODIFF_4_LEVEL_CHECKPOINT |
374 |
do ilev_4 = 1,nchklev_4 |
375 |
if(ilev_4.le.max_lev4) then |
376 |
c************************************** |
377 |
#include "checkpoint_lev4_directives.h" |
378 |
c************************************** |
379 |
c-- Initialise storage for the middle loop. |
380 |
CADJ INIT tapelev3 = USER |
381 |
#endif /* AUTODIFF_4_LEVEL_CHECKPOINT */ |
382 |
|
383 |
#ifndef AUTODIFF_2_LEVEL_CHECKPOINT |
384 |
do ilev_3 = 1,nchklev_3 |
385 |
if(ilev_3.le.max_lev3) then |
386 |
c************************************** |
387 |
#include "checkpoint_lev3_directives.h" |
388 |
c************************************** |
389 |
c-- Initialise storage for the middle loop. |
390 |
CADJ INIT tapelev2 = USER |
391 |
#endif /* AUTODIFF_2_LEVEL_CHECKPOINT */ |
392 |
|
393 |
do ilev_2 = 1,nchklev_2 |
394 |
if(ilev_2.le.max_lev2) then |
395 |
c************************************** |
396 |
#include "checkpoint_lev2_directives.h" |
397 |
c************************************** |
398 |
|
399 |
c************************************** |
400 |
#ifdef ALLOW_AUTODIFF_TAMC |
401 |
c-- Initialize storage for the innermost loop. |
402 |
c-- Always check common block sizes for the checkpointing! |
403 |
c-- |
404 |
CADJ INIT comlev1 = COMMON,nchklev_1 |
405 |
CADJ INIT comlev1_bibj = COMMON,nchklev_1*nsx*nsy*nthreads_chkpt |
406 |
CADJ INIT comlev1_bibj_k = COMMON,nchklev_1*nsx*nsy*nr*nthreads_chkpt |
407 |
c-- |
408 |
# ifdef ALLOW_KPP |
409 |
CADJ INIT comlev1_kpp = COMMON,nchklev_1*nsx*nsy |
410 |
CADJ INIT comlev1_kpp_k = COMMON,nchklev_1*nsx*nsy*nr |
411 |
# endif /* ALLOW_KPP */ |
412 |
c-- |
413 |
# ifdef ALLOW_GMREDI |
414 |
CADJ INIT comlev1_gmredi_k_gad |
415 |
CADJ & = COMMON,nchklev_1*nsx*nsy*nr*nthreads_chkpt*maxpass |
416 |
# endif /* ALLOW_GMREDI */ |
417 |
c-- |
418 |
# ifdef ALLOW_PTRACERS |
419 |
CADJ INIT comlev1_bibj_ptracers = COMMON, |
420 |
CADJ & nchklev_1*nsx*nsy*nthreads_chkpt*PTRACERS_num |
421 |
CADJ INIT comlev1_bibj_k_ptracers = COMMON, |
422 |
CADJ & nchklev_1*nsx*nsy*nthreads_chkpt*PTRACERS_num*nr |
423 |
# endif /* ALLOW_PTRACERS */ |
424 |
c-- |
425 |
cph Now also needed by seaice |
426 |
cph# ifndef DISABLE_MULTIDIM_ADVECTION |
427 |
CADJ INIT comlev1_bibj_k_gad |
428 |
CADJ & = COMMON,nchklev_1*nsx*nsy*nr*nthreads_chkpt*maxpass |
429 |
CADJ INIT comlev1_bibj_k_gad_pass |
430 |
CADJ & = COMMON,nchklev_1*nsx*nsy*nr*nthreads_chkpt*maxpass*maxcube |
431 |
cph# endif /* DISABLE_MULTIDIM_ADVECTION */ |
432 |
c-- |
433 |
# if (defined (ALLOW_EXF) && defined (ALLOW_BULKFORMULAE)) |
434 |
CADJ INIT comlev1_exf_1 |
435 |
CADJ & = COMMON,nchklev_1*snx*nsx*sny*nsy*nthreads_chkpt |
436 |
CADJ INIT comlev1_exf_2 |
437 |
CADJ & = COMMON,niter_bulk*nchklev_1*snx*nsx*sny*nsy*nthreads_chkpt |
438 |
# endif |
439 |
c-- |
440 |
# ifdef ALLOW_SEAICE |
441 |
# ifdef SEAICE_ALLOW_DYNAMICS |
442 |
CADJ INIT comlev1_lsr = COMMON,nchklev_1*2 |
443 |
# endif |
444 |
# ifdef SEAICE_ALLOW_EVP |
445 |
CADJ INIT comlev1_evp = COMMON,nchklev_1 |
446 |
# endif |
447 |
# ifdef SEAICE_MULTILEVEL |
448 |
CADJ INIT comlev1_multdim |
449 |
CADJ & = COMMON,nchklev_1*nsx*nsy*nthreads_chkpt*multdim |
450 |
# endif |
451 |
# endif /* ALLOW_SEAICE */ |
452 |
c-- |
453 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
454 |
c************************************** |
455 |
|
456 |
do ilev_1 = 1,nchklev_1 |
457 |
|
458 |
c-- The if-statement below introduces a some flexibility in the |
459 |
c-- choice of the 3-tupel ( nchklev_1, nchklev_2, nchklev_3 ). |
460 |
c-- |
461 |
c-- Requirement: nchklev_1*nchklev_2*nchklev_3 .ge. nTimeSteps . |
462 |
|
463 |
iloop = (ilev_2 - 1)*nchklev_1 + ilev_1 |
464 |
#ifndef AUTODIFF_2_LEVEL_CHECKPOINT |
465 |
& + (ilev_3 - 1)*nchklev_2*nchklev_1 |
466 |
#endif |
467 |
#ifdef AUTODIFF_4_LEVEL_CHECKPOINT |
468 |
& + (ilev_4 - 1)*nchklev_3*nchklev_2*nchklev_1 |
469 |
#endif |
470 |
|
471 |
if ( iloop .le. nTimeSteps ) then |
472 |
|
473 |
#else /* ALLOW_TAMC_CHECKPOINTING undefined */ |
474 |
c-- Initialise storage for the reference trajectory without TAMC check- |
475 |
c-- pointing. |
476 |
CADJ INIT history = USER |
477 |
CADJ INIT comlev1_bibj = COMMON,nchklev_0*nsx*nsy*nthreads_chkpt |
478 |
CADJ INIT comlev1_bibj_k = COMMON,nchklev_0*nsx*nsy*nr*nthreads_chkpt |
479 |
CADJ INIT comlev1_kpp = COMMON,nchklev_0*nsx*nsy |
480 |
|
481 |
c-- Check the choice of the checkpointing parameters in relation |
482 |
c-- to nTimeSteps: (nchklev_0 .ge. nTimeSteps) |
483 |
if (nchklev_0 .lt. nTimeSteps) then |
484 |
print* |
485 |
print*, ' the_main_loop: ', |
486 |
& 'TAMC checkpointing parameter nchklev_0 = ', |
487 |
& nchklev_0 |
488 |
print*, ' is not consistent with nTimeSteps = ', |
489 |
& nTimeSteps |
490 |
stop ' ... stopped in the_main_loop.' |
491 |
endif |
492 |
|
493 |
do iloop = 1, nTimeSteps |
494 |
|
495 |
#endif /* ALLOW_TAMC_CHECKPOINTING */ |
496 |
|
497 |
#else /* ALLOW_AUTODIFF_TAMC undefined */ |
498 |
c-- Start the main loop of ecco_Objfunc. Automatic differentiation is |
499 |
c-- NOT enabled. |
500 |
do iloop = 1, nTimeSteps |
501 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
502 |
|
503 |
#ifdef ALLOW_TAMC_CHECKPOINTING |
504 |
nIter0 = NINT( (startTime-baseTime)/deltaTClock ) |
505 |
ikey_dynamics = ilev_1 |
506 |
#endif |
507 |
|
508 |
c-- Set the model iteration counter and the model time. |
509 |
myiter = nIter0 + (iloop-1) |
510 |
mytime = startTime + float(iloop-1)*deltaTclock |
511 |
|
512 |
#ifdef ALLOW_AUTODIFF_TAMC |
513 |
CALL AUTODIFF_INADMODE_UNSET( myThid ) |
514 |
#endif |
515 |
|
516 |
#ifdef ALLOW_DIAGNOSTICS |
517 |
C-- State-variables diagnostics |
518 |
IF ( useDiagnostics ) THEN |
519 |
C-- Switch on/off diagnostics for snap-shot output: |
520 |
CALL DIAGNOSTICS_SWITCH_ONOFF( myTime, myIter, myThid ) |
521 |
CALL TIMER_START('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
522 |
CALL DO_STATEVARS_DIAGS( myTime, 0, myIter, myThid ) |
523 |
CALL TIMER_STOP ('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
524 |
ENDIF |
525 |
#endif |
526 |
|
527 |
#ifdef ALLOW_PROFILES |
528 |
c-- Accumulate in-situ time averages of temperature, salinity, and SSH. |
529 |
call timer_start('PROFILES_INLOOP [ECCO MAIN]', mythid) |
530 |
call profiles_inloop( mytime, mythid ) |
531 |
call timer_stop ('PROFILES_INLOOP [ECCO MAIN]', mythid) |
532 |
#endif |
533 |
|
534 |
#ifdef ALLOW_COST |
535 |
|
536 |
c-- Accumulate time averages of temperature, salinity |
537 |
call timer_start('COST_AVERAGESFIELDS [ECCO MAIN]', mythid) |
538 |
call cost_averagesFields( mytime, mythid ) |
539 |
call timer_stop ('COST_AVERAGESFIELDS [ECCO MAIN]', mythid) |
540 |
|
541 |
|
542 |
#ifdef ALLOW_COST_ATLANTIC |
543 |
c-- Compute meridional heat transport |
544 |
call timer_start('cost_atlantic [ECCO MAIN]', mythid) |
545 |
call cost_atlantic( mytime, myiter,mythid ) |
546 |
call timer_stop ('cost_atlantic [ECCO MAIN]', mythid) |
547 |
#endif |
548 |
#endif /* ALLOW_COST */ |
549 |
|
550 |
#ifdef ALLOW_AUTODIFF_TAMC |
551 |
c************************************** |
552 |
#include "checkpoint_lev1_directives.h" |
553 |
#include "checkpoint_lev1_template.h" |
554 |
c************************************** |
555 |
#endif |
556 |
|
557 |
C-- Call driver to load external forcing fields from file |
558 |
#ifdef ALLOW_DEBUG |
559 |
IF ( debugLevel .GE. debLevB ) |
560 |
& CALL DEBUG_CALL('LOAD_FIELDS_DRIVER',myThid) |
561 |
#endif |
562 |
CALL TIMER_START('LOAD_FIELDS_DRIVER [FORWARD_STEP]',myThid) |
563 |
CALL LOAD_FIELDS_DRIVER( myTime, myIter, myThid ) |
564 |
CALL TIMER_STOP ('LOAD_FIELDS_DRIVER [FORWARD_STEP]',myThid) |
565 |
|
566 |
|
567 |
#ifdef ALLOW_AUTODIFF_TAMC |
568 |
# if (defined (ALLOW_AUTODIFF_MONITOR)) |
569 |
CALL DUMMY_IN_STEPPING( myTime, myIter, myThid ) |
570 |
# endif |
571 |
#endif |
572 |
|
573 |
#ifdef ALLOW_AUTODIFF_TAMC |
574 |
# ifdef ALLOW_PTRACERS |
575 |
cph this replaces _bibj storing of ptracer within thermodynamics |
576 |
CADJ STORE ptracer = comlev1, key = ikey_dynamics |
577 |
# endif |
578 |
#endif |
579 |
|
580 |
#ifdef ALLOW_EBM |
581 |
IF ( useEBM ) THEN |
582 |
# ifdef ALLOW_DEBUG |
583 |
IF ( debugLevel .GE. debLevB ) |
584 |
& CALL DEBUG_CALL('EBM',myThid) |
585 |
# endif |
586 |
CALL TIMER_START('EBM [FORWARD_STEP]',mythid) |
587 |
CALL EBM_DRIVER ( myTime, myIter, myThid ) |
588 |
CALL TIMER_STOP ('EBM [FORWARD_STEP]',mythid) |
589 |
ENDIF |
590 |
#endif |
591 |
|
592 |
C-- Step forward fields and calculate time tendency terms. |
593 |
|
594 |
#ifdef ALLOW_DEBUG |
595 |
IF ( debugLevel .GE. debLevB ) |
596 |
& CALL DEBUG_CALL('DO_ATMOSPHERIC_PHYS',myThid) |
597 |
#endif |
598 |
CALL TIMER_START('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',mythid) |
599 |
CALL DO_ATMOSPHERIC_PHYS( myTime, myIter, myThid ) |
600 |
CALL TIMER_STOP ('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',mythid) |
601 |
|
602 |
#ifdef ALLOW_AUTODIFF_TAMC |
603 |
CADJ STORE surfaceforcingtice = comlev1, key = ikey_dynamics |
604 |
# ifdef EXACT_CONSERV |
605 |
cphCADJ STORE empmr = comlev1, key = ikey_dynamics |
606 |
cphCADJ STORE pmepr = comlev1, key = ikey_dynamics |
607 |
# endif |
608 |
# ifdef ALLOW_PTRACERS |
609 |
CADJ STORE ptracer = comlev1, key = ikey_dynamics |
610 |
# endif |
611 |
# ifdef NONLIN_FRSURF |
612 |
CADJ STORE hFacC = comlev1, key = ikey_dynamics |
613 |
# endif |
614 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
615 |
|
616 |
#ifndef ALLOW_OFFLINE |
617 |
#ifdef ALLOW_DEBUG |
618 |
IF ( debugLevel .GE. debLevB ) |
619 |
& CALL DEBUG_CALL('DO_OCEANIC_PHYS',myThid) |
620 |
#endif |
621 |
CALL TIMER_START('DO_OCEANIC_PHYS [FORWARD_STEP]',mythid) |
622 |
CALL DO_OCEANIC_PHYS( myTime, myIter, myThid ) |
623 |
CALL TIMER_STOP ('DO_OCEANIC_PHYS [FORWARD_STEP]',mythid) |
624 |
#ifdef ALLOW_AUTODIFF_TAMC |
625 |
CADJ STORE EmPmR = comlev1, key = ikey_dynamics |
626 |
# ifdef EXACT_CONSERV |
627 |
CADJ STORE pmepr = comlev1, key = ikey_dynamics |
628 |
# endif |
629 |
#endif |
630 |
#endif |
631 |
|
632 |
#ifdef ALLOW_AUTODIFF_TAMC |
633 |
# ifdef NONLIN_FRSURF |
634 |
cph-test |
635 |
CADJ STORE hFac_surfC = comlev1, key = ikey_dynamics |
636 |
CADJ STORE hfac_surfs = comlev1, key = ikey_dynamics |
637 |
CADJ STORE hfac_surfw = comlev1, key = ikey_dynamics |
638 |
CADJ STORE hFacC, hFacS, hFacW |
639 |
CADJ & = comlev1, key = ikey_dynamics |
640 |
CADJ STORE recip_hFacC, recip_hFacS, recip_hFacW |
641 |
CADJ & = comlev1, key = ikey_dynamics |
642 |
c |
643 |
CADJ STORE surfaceforcingu = comlev1, key = ikey_dynamics |
644 |
CADJ STORE surfaceforcingv = comlev1, key = ikey_dynamics |
645 |
# endif |
646 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
647 |
|
648 |
#ifdef ALLOW_GCHEM |
649 |
C GCHEM package is an interface for any bio-geochemical or |
650 |
C ecosystem model you would like to include. |
651 |
C If GCHEM_SEPARATE_FORCING is not defined, you are |
652 |
C responsible for computing tendency terms for passive |
653 |
C tracers and storing them on a 3DxNumPtracers-array called |
654 |
C gchemTendency in GCHEM_CALC_TENDENCY. This tendency is then added |
655 |
C to gPtr in ptracers_forcing later-on. |
656 |
C If GCHEM_SEPARATE_FORCING is defined, you are reponsible for |
657 |
C UPDATING ptracers directly in GCHEM_FORCING_SEP. This amounts |
658 |
C to a completely separate time step that you have to implement |
659 |
C yourself (Eulerian seems to be fine in most cases). |
660 |
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC |
661 |
C CAVEAT: Up to now, when GCHEM is turned on the field ptracerForcingSurf, |
662 |
C which is needed for KPP is not set properly. ptracerForcingSurf must |
663 |
C be treated differently depending on whether GCHEM_SEPARATE_FORCING |
664 |
C is define or not. TBD. |
665 |
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC |
666 |
IF ( useGCHEM ) THEN |
667 |
#ifdef ALLOW_DEBUG |
668 |
IF ( debugLevel .GE. debLevB ) |
669 |
& CALL DEBUG_CALL('GCHEM_CALC_TENDENCY',myThid) |
670 |
#endif |
671 |
CALL TIMER_START('GCHEM_CALC_TENDENCY [FORWARD_STEP]',myThid) |
672 |
CALL GCHEM_CALC_TENDENCY( myTime, myIter, myThid ) |
673 |
CALL TIMER_STOP ('GCHEM_CALC_TENDENCY [FORWARD_STEP]',myThid) |
674 |
ENDIF |
675 |
#endif /* ALLOW_GCHEM */ |
676 |
|
677 |
#ifdef ALLOW_AUTODIFF_TAMC |
678 |
cph needed to be moved here from do_oceanic_physics |
679 |
cph to be visible down the road |
680 |
c |
681 |
CADJ STORE surfaceForcingS = comlev1, key = ikey_dynamics |
682 |
CADJ STORE surfaceForcingT = comlev1, key = ikey_dynamics |
683 |
CADJ STORE surfaceForcingTice = comlev1, key = ikey_dynamics |
684 |
ctest( |
685 |
CADJ STORE IVDConvCount = comlev1, key = ikey_dynamics |
686 |
ctest) |
687 |
# ifdef ALLOW_PTRACERS |
688 |
CADJ STORE surfaceForcingPtr = comlev1, key = ikey_dynamics |
689 |
# endif |
690 |
c |
691 |
# ifdef ALLOW_GMREDI |
692 |
CADJ STORE Kwx = comlev1, key = ikey_dynamics |
693 |
CADJ STORE Kwy = comlev1, key = ikey_dynamics |
694 |
CADJ STORE Kwz = comlev1, key = ikey_dynamics |
695 |
# ifdef GM_BOLUS_ADVEC |
696 |
CADJ STORE GM_PsiX = comlev1, key = ikey_dynamics |
697 |
CADJ STORE GM_PsiY = comlev1, key = ikey_dynamics |
698 |
# endif |
699 |
# endif |
700 |
c |
701 |
# ifdef ALLOW_KPP |
702 |
CADJ STORE KPPghat = comlev1, key = ikey_dynamics |
703 |
CADJ STORE KPPfrac = comlev1, key = ikey_dynamics |
704 |
CADJ STORE KPPdiffKzS = comlev1, key = ikey_dynamics |
705 |
CADJ STORE KPPdiffKzT = comlev1, key = ikey_dynamics |
706 |
# endif |
707 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
708 |
|
709 |
#ifdef ALLOW_AUTODIFF_TAMC |
710 |
# ifdef NONLIN_FRSURF |
711 |
CADJ STORE etaH = comlev1, key = ikey_dynamics |
712 |
# ifdef ALLOW_CD_CODE |
713 |
CADJ STORE etanm1 = comlev1, key = ikey_dynamics |
714 |
# endif |
715 |
# endif |
716 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
717 |
|
718 |
IF ( .NOT.staggerTimeStep ) THEN |
719 |
#ifdef ALLOW_DEBUG |
720 |
IF ( debugLevel .GE. debLevB ) |
721 |
& CALL DEBUG_CALL('THERMODYNAMICS',myThid) |
722 |
#endif |
723 |
CALL TIMER_START('THERMODYNAMICS [FORWARD_STEP]',mythid) |
724 |
CALL THERMODYNAMICS( myTime, myIter, myThid ) |
725 |
CALL TIMER_STOP ('THERMODYNAMICS [FORWARD_STEP]',mythid) |
726 |
C-- if not staggerTimeStep: end |
727 |
ENDIF |
728 |
|
729 |
#ifdef ALLOW_AUTODIFF_TAMC |
730 |
# ifdef NONLIN_FRSURF |
731 |
CADJ STORE hFacC = comlev1, key = ikey_dynamics |
732 |
CADJ STORE hFacS = comlev1, key = ikey_dynamics |
733 |
CADJ STORE hFacW = comlev1, key = ikey_dynamics |
734 |
CADJ STORE recip_hFacC = comlev1, key = ikey_dynamics |
735 |
CADJ STORE recip_hFacS = comlev1, key = ikey_dynamics |
736 |
CADJ STORE recip_hFacW = comlev1, key = ikey_dynamics |
737 |
CADJ STORE etaN = comlev1, key = ikey_dynamics |
738 |
# endif |
739 |
#endif |
740 |
|
741 |
C-- Step forward fields and calculate time tendency terms. |
742 |
#ifndef ALLOW_OFFLINE |
743 |
#ifndef ALLOW_AUTODIFF_TAMC |
744 |
IF ( momStepping ) THEN |
745 |
#endif |
746 |
#ifdef ALLOW_DEBUG |
747 |
IF ( debugLevel .GE. debLevB ) |
748 |
& CALL DEBUG_CALL('DYNAMICS',myThid) |
749 |
#endif |
750 |
CALL TIMER_START('DYNAMICS [FORWARD_STEP]',mythid) |
751 |
CALL DYNAMICS( myTime, myIter, myThid ) |
752 |
CALL TIMER_STOP ('DYNAMICS [FORWARD_STEP]',mythid) |
753 |
#ifndef ALLOW_AUTODIFF_TAMC |
754 |
ENDIF |
755 |
#endif |
756 |
#endif |
757 |
|
758 |
#ifdef ALLOW_AUTODIFF_TAMC |
759 |
# ifdef NONLIN_FRSURF |
760 |
cph-test |
761 |
CADJ STORE gU, gV = comlev1, key = ikey_dynamics |
762 |
# endif |
763 |
#endif |
764 |
|
765 |
C-- Update time-counter |
766 |
myIter = nIter0 + iLoop |
767 |
myTime = startTime + deltaTClock * float(iLoop) |
768 |
|
769 |
#ifdef ALLOW_MNC |
770 |
C Update the default next iter for MNC |
771 |
IF ( useMNC ) THEN |
772 |
CALL MNC_CW_CITER_SETG( 1, 1, -1, myIter , myThid ) |
773 |
|
774 |
C TODO: Logic should be added here so that users can specify, on |
775 |
C a per-citer-group basis, when it is time to update the |
776 |
C "current" (and not just the "next") iteration |
777 |
|
778 |
C TODO: the following is just a temporary band-aid (mostly, for |
779 |
C Baylor) until someone writes a routine that better handles time |
780 |
C boundaries such as weeks, months, years, etc. |
781 |
IF ( mnc_filefreq .GT. 0 ) THEN |
782 |
IF (DIFFERENT_MULTIPLE(mnc_filefreq,myTime,deltaTClock)) |
783 |
& THEN |
784 |
CALL MNC_CW_CITER_SETG( 1, 1, myIter, -1 , myThid ) |
785 |
ENDIF |
786 |
ENDIF |
787 |
ENDIF |
788 |
#endif |
789 |
|
790 |
C-- Update geometric factors: |
791 |
#ifdef NONLIN_FRSURF |
792 |
C- update hfacC,W,S and recip_hFac according to etaH(n+1) : |
793 |
IF ( nonlinFreeSurf.GT.0) THEN |
794 |
IF ( select_rStar.GT.0 ) THEN |
795 |
# ifndef DISABLE_RSTAR_CODE |
796 |
# ifdef ALLOW_AUTODIFF_TAMC |
797 |
cph-test |
798 |
CADJ STORE hFacC = comlev1, key = ikey_dynamics |
799 |
CADJ STORE hFacS = comlev1, key = ikey_dynamics |
800 |
CADJ STORE hFacW = comlev1, key = ikey_dynamics |
801 |
CADJ STORE recip_hFacC = comlev1, key = ikey_dynamics |
802 |
CADJ STORE recip_hFacS = comlev1, key = ikey_dynamics |
803 |
CADJ STORE recip_hFacW = comlev1, key = ikey_dynamics |
804 |
# endif |
805 |
CALL TIMER_START('UPDATE_R_STAR [FORWARD_STEP]',myThid) |
806 |
CALL UPDATE_R_STAR( myTime, myIter, myThid ) |
807 |
CALL TIMER_STOP ('UPDATE_R_STAR [FORWARD_STEP]',myThid) |
808 |
# ifdef ALLOW_AUTODIFF_TAMC |
809 |
cph-test |
810 |
CADJ STORE hFacC = comlev1, key = ikey_dynamics |
811 |
CADJ STORE hFacS = comlev1, key = ikey_dynamics |
812 |
CADJ STORE hFacW = comlev1, key = ikey_dynamics |
813 |
CADJ STORE recip_hFacC = comlev1, key = ikey_dynamics |
814 |
CADJ STORE recip_hFacS = comlev1, key = ikey_dynamics |
815 |
CADJ STORE recip_hFacW = comlev1, key = ikey_dynamics |
816 |
# endif |
817 |
# endif /* DISABLE_RSTAR_CODE */ |
818 |
ELSE |
819 |
#ifdef ALLOW_AUTODIFF_TAMC |
820 |
CADJ STORE hFac_surfC, hFac_surfS, hFac_surfW |
821 |
CADJ & = comlev1, key = ikey_dynamics |
822 |
#endif |
823 |
CALL TIMER_START('UPDATE_SURF_DR [FORWARD_STEP]',myThid) |
824 |
CALL UPDATE_SURF_DR( myTime, myIter, myThid ) |
825 |
CALL TIMER_STOP ('UPDATE_SURF_DR [FORWARD_STEP]',myThid) |
826 |
ENDIF |
827 |
ENDIF |
828 |
# ifdef ALLOW_AUTODIFF_TAMC |
829 |
cph-test |
830 |
CADJ STORE hFacC = comlev1, key = ikey_dynamics |
831 |
CADJ STORE hFacS = comlev1, key = ikey_dynamics |
832 |
CADJ STORE hFacW = comlev1, key = ikey_dynamics |
833 |
CADJ STORE recip_hFacC = comlev1, key = ikey_dynamics |
834 |
CADJ STORE recip_hFacS = comlev1, key = ikey_dynamics |
835 |
CADJ STORE recip_hFacW = comlev1, key = ikey_dynamics |
836 |
# endif |
837 |
C- update also CG2D matrix (and preconditioner) |
838 |
IF ( momStepping .AND. nonlinFreeSurf.GT.2 ) THEN |
839 |
CALL TIMER_START('UPDATE_CG2D [FORWARD_STEP]',myThid) |
840 |
CALL UPDATE_CG2D( myTime, myIter, myThid ) |
841 |
CALL TIMER_STOP ('UPDATE_CG2D [FORWARD_STEP]',myThid) |
842 |
ENDIF |
843 |
#endif /* NONLIN_FRSURF */ |
844 |
|
845 |
C-- Apply Filters to u*,v* before SOLVE_FOR_PRESSURE |
846 |
#ifdef ALLOW_SHAP_FILT |
847 |
IF (useSHAP_FILT .AND. shap_filt_uvStar) THEN |
848 |
CALL TIMER_START('SHAP_FILT [FORWARD_STEP]',myThid) |
849 |
IF (implicDiv2Dflow.LT.1.) THEN |
850 |
C-- Explicit+Implicit part of the Barotropic Flow Divergence |
851 |
C => Filtering of uVel,vVel is necessary |
852 |
CALL SHAP_FILT_APPLY_UV( uVel,vVel, |
853 |
& myTime, myIter, myThid ) |
854 |
ENDIF |
855 |
CALL SHAP_FILT_APPLY_UV( gU,gV,myTime,myIter,myThid) |
856 |
CALL TIMER_STOP ('SHAP_FILT [FORWARD_STEP]',myThid) |
857 |
ENDIF |
858 |
#endif |
859 |
#ifdef ALLOW_ZONAL_FILT |
860 |
IF (useZONAL_FILT .AND. zonal_filt_uvStar) THEN |
861 |
CALL TIMER_START('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
862 |
IF (implicDiv2Dflow.LT.1.) THEN |
863 |
C-- Explicit+Implicit part of the Barotropic Flow Divergence |
864 |
C => Filtering of uVel,vVel is necessary |
865 |
CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid ) |
866 |
ENDIF |
867 |
CALL ZONAL_FILT_APPLY_UV( gU, gV, myThid ) |
868 |
CALL TIMER_STOP ('ZONAL_FILT_APPLY [FORWARD_STEP]',myThid) |
869 |
ENDIF |
870 |
#endif |
871 |
|
872 |
C-- Solve elliptic equation(s). |
873 |
C Two-dimensional only for conventional hydrostatic or |
874 |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
875 |
#ifndef ALLOW_OFFLINE |
876 |
IF ( momStepping ) THEN |
877 |
#ifdef ALLOW_AUTODIFF_TAMC |
878 |
# ifdef NONLIN_FRSURF |
879 |
CADJ STORE uvel, vvel |
880 |
CADJ & = comlev1, key = ikey_dynamics |
881 |
CADJ STORE empmr,hfacs,hfacw |
882 |
CADJ & = comlev1, key = ikey_dynamics |
883 |
# endif |
884 |
#endif |
885 |
CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
886 |
CALL SOLVE_FOR_PRESSURE(myTime, myIter, myThid) |
887 |
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
888 |
ENDIF |
889 |
#endif |
890 |
|
891 |
C-- Correct divergence in flow field and cycle time-stepping momentum |
892 |
c IF ( momStepping ) THEN |
893 |
#ifndef ALLOW_OFFLINE |
894 |
CALL TIMER_START('UV_CORRECTION_STEP [FORWARD_STEP]',myThid) |
895 |
CALL MOMENTUM_CORRECTION_STEP(myTime, myIter, myThid) |
896 |
CALL TIMER_STOP ('UV_CORRECTION_STEP [FORWARD_STEP]',myThid) |
897 |
#endif |
898 |
c ENDIF |
899 |
|
900 |
#ifdef EXACT_CONSERV |
901 |
IF (exactConserv) THEN |
902 |
#ifdef ALLOW_AUTODIFF_TAMC |
903 |
cph-test |
904 |
cphCADJ STORE etaH = comlev1, key = ikey_dynamics |
905 |
#endif |
906 |
C-- Update etaH(n+1) : |
907 |
CALL TIMER_START('UPDATE_ETAH [FORWARD_STEP]',mythid) |
908 |
CALL UPDATE_ETAH( myTime, myIter, myThid ) |
909 |
CALL TIMER_STOP ('UPDATE_ETAH [FORWARD_STEP]',mythid) |
910 |
ENDIF |
911 |
#endif /* EXACT_CONSERV */ |
912 |
|
913 |
#ifdef NONLIN_FRSURF |
914 |
IF ( select_rStar.NE.0 ) THEN |
915 |
# ifndef DISABLE_RSTAR_CODE |
916 |
C-- r* : compute the future level thickness according to etaH(n+1) |
917 |
CALL TIMER_START('CALC_R_STAR [FORWARD_STEP]',mythid) |
918 |
CALL CALC_R_STAR(etaH, myTime, myIter, myThid ) |
919 |
CALL TIMER_STOP ('CALC_R_STAR [FORWARD_STEP]',mythid) |
920 |
# endif /* DISABLE_RSTAR_CODE */ |
921 |
ELSEIF ( nonlinFreeSurf.GT.0) THEN |
922 |
C-- compute the future surface level thickness according to etaH(n+1) |
923 |
# ifdef ALLOW_AUTODIFF_TAMC |
924 |
CADJ STORE etaH = comlev1, key = ikey_dynamics |
925 |
# endif |
926 |
CALL TIMER_START('CALC_SURF_DR [FORWARD_STEP]',mythid) |
927 |
CALL CALC_SURF_DR(etaH, myTime, myIter, myThid ) |
928 |
CALL TIMER_STOP ('CALC_SURF_DR [FORWARD_STEP]',mythid) |
929 |
ENDIF |
930 |
# ifdef ALLOW_AUTODIFF_TAMC |
931 |
cph-test |
932 |
CADJ STORE hFac_surfC = comlev1, key = ikey_dynamics |
933 |
# endif |
934 |
#endif /* NONLIN_FRSURF */ |
935 |
|
936 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
937 |
IF ( staggerTimeStep ) THEN |
938 |
C-- do exchanges of U,V (needed for multiDim) when using stagger time-step : |
939 |
#ifdef ALLOW_DEBUG |
940 |
IF ( debugLevel .GE. debLevB ) |
941 |
& CALL DEBUG_CALL('DO_STAGGER_FIELDS_EXCH.',myThid) |
942 |
#endif |
943 |
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
944 |
CALL DO_STAGGER_FIELDS_EXCHANGES( myTime, myIter, myThid ) |
945 |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
946 |
|
947 |
#ifdef ALLOW_DIAGNOSTICS |
948 |
C-- State-variables diagnostics |
949 |
IF ( usediagnostics ) THEN |
950 |
CALL TIMER_START('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
951 |
CALL DO_STATEVARS_DIAGS( myTime, 1, myIter, myThid ) |
952 |
CALL TIMER_STOP ('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
953 |
ENDIF |
954 |
#endif |
955 |
|
956 |
#ifdef ALLOW_DEBUG |
957 |
IF ( debugLevel .GE. debLevB ) |
958 |
& CALL DEBUG_CALL('THERMODYNAMICS',myThid) |
959 |
#endif |
960 |
CALL TIMER_START('THERMODYNAMICS [FORWARD_STEP]',mythid) |
961 |
CALL THERMODYNAMICS( myTime, myIter, myThid ) |
962 |
CALL TIMER_STOP ('THERMODYNAMICS [FORWARD_STEP]',mythid) |
963 |
|
964 |
C-- if staggerTimeStep: end |
965 |
ENDIF |
966 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
967 |
|
968 |
#ifdef ALLOW_AUTODIFF_TAMC |
969 |
cph This is needed because convective_adjustment calls |
970 |
cph find_rho which may use pressure() |
971 |
CADJ STORE totphihyd = comlev1, key = ikey_dynamics |
972 |
#endif |
973 |
C-- Cycle time-stepping Tracers arrays (T,S,+pTracers) |
974 |
CALL TIMER_START('TS_CORRECTION_STEP [FORWARD_STEP]',myThid) |
975 |
CALL TRACERS_CORRECTION_STEP(myTime, myIter, myThid) |
976 |
CALL TIMER_STOP ('TS_CORRECTION_STEP [FORWARD_STEP]',myThid) |
977 |
|
978 |
#ifdef ALLOW_GCHEM |
979 |
C Add separate timestepping of chemical/biological/forcing |
980 |
C of ptracers here in GCHEM_FORCING_SEP |
981 |
IF ( useGCHEM ) THEN |
982 |
#ifdef ALLOW_DEBUG |
983 |
IF ( debugLevel .GE. debLevB ) |
984 |
& CALL DEBUG_CALL('GCHEM_FORCING_SEP',myThid) |
985 |
#endif /* ALLOW_DEBUG */ |
986 |
CALL TIMER_START('GCHEM_FORCING_SEP [FORWARD_STEP]',myThid) |
987 |
CALL GCHEM_FORCING_SEP( myTime,myIter,myThid ) |
988 |
CALL TIMER_STOP ('GCHEM_FORCING_SEP [FORWARD_STEP]',myThid) |
989 |
ENDIF |
990 |
#endif /* ALLOW_GCHEM */ |
991 |
|
992 |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
993 |
c CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
994 |
c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
995 |
c CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
996 |
|
997 |
C-- Do "blocking" sends and receives for field "overlap" terms |
998 |
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
999 |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
1000 |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
1001 |
|
1002 |
#ifdef ALLOW_DIAGNOSTICS |
1003 |
IF ( useDiagnostics ) THEN |
1004 |
CALL TIMER_START('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
1005 |
CALL DO_STATEVARS_DIAGS( myTime, 2, myIter, myThid ) |
1006 |
CALL TIMER_STOP ('DO_STATEVARS_DIAGS [FORWARD_STEP]',myThid) |
1007 |
ENDIF |
1008 |
#endif |
1009 |
|
1010 |
#ifdef ALLOW_FLT |
1011 |
C-- Calculate float trajectories |
1012 |
IF (useFLT) THEN |
1013 |
CALL TIMER_START('FLOATS [FORWARD_STEP]',myThid) |
1014 |
CALL FLT_MAIN(myIter,myTime, myThid) |
1015 |
CALL TIMER_STOP ('FLOATS [FORWARD_STEP]',myThid) |
1016 |
ENDIF |
1017 |
#endif |
1018 |
|
1019 |
#ifdef ALLOW_AUTODIFF_TAMC |
1020 |
CALL AUTODIFF_INADMODE_SET( myThid ) |
1021 |
#endif |
1022 |
|
1023 |
#ifdef ALLOW_TIMEAVE |
1024 |
C-- State-variables time-averaging |
1025 |
CALL TIMER_START('DO_STATEVARS_TAVE [FORWARD_STEP]',myThid) |
1026 |
CALL DO_STATEVARS_TAVE( myTime, myIter, myThid ) |
1027 |
CALL TIMER_STOP ('DO_STATEVARS_TAVE [FORWARD_STEP]',myThid) |
1028 |
#endif |
1029 |
|
1030 |
#ifndef ALLOW_OFFLINE |
1031 |
#ifdef ALLOW_MONITOR |
1032 |
C-- Check status of solution (statistics, cfl, etc...) |
1033 |
CALL TIMER_START('MONITOR [FORWARD_STEP]',myThid) |
1034 |
CALL MONITOR( myIter, myTime, myThid ) |
1035 |
CALL TIMER_STOP ('MONITOR [FORWARD_STEP]',myThid) |
1036 |
#endif /* ALLOW_MONITOR */ |
1037 |
#endif |
1038 |
|
1039 |
C-- Do IO if needed. |
1040 |
#ifdef ALLOW_OFFLINE |
1041 |
CALL TIMER_START('OFFLINE_MODEL_IO [FORWARD_STEP]',myThid) |
1042 |
CALL OFFLINE_MODEL_IO( myTime, myIter, myThid ) |
1043 |
CALL TIMER_STOP ('OFFLINE_MODEL_IO [FORWARD_STEP]',myThid) |
1044 |
#else |
1045 |
CALL TIMER_START('DO_THE_MODEL_IO [FORWARD_STEP]',myThid) |
1046 |
CALL DO_THE_MODEL_IO( myTime, myIter, myThid ) |
1047 |
CALL TIMER_STOP ('DO_THE_MODEL_IO [FORWARD_STEP]',myThid) |
1048 |
#endif |
1049 |
|
1050 |
#ifndef ALLOW_DIVIDED_ADJOINT |
1051 |
# ifdef HAVE_SIGREG |
1052 |
IF ( useSIGREG ) THEN |
1053 |
IF ( i_got_signal .GT. 0 ) THEN |
1054 |
CALL PACKAGES_WRITE_PICKUP( |
1055 |
I .TRUE., myTime, myIter, myThid ) |
1056 |
CALL WRITE_PICKUP( |
1057 |
I .TRUE., myTime, myIter, myThid ) |
1058 |
STOP 'Checkpoint completed -- killed by signal handler' |
1059 |
ENDIF |
1060 |
ENDIF |
1061 |
# endif /* HAVE_SIGREG */ |
1062 |
C-- Save state for restarts |
1063 |
CALL TIMER_START('DO_WRITE_PICKUP [FORWARD_STEP]',myThid) |
1064 |
CALL DO_WRITE_PICKUP( |
1065 |
I .FALSE., myTime, myIter, myThid ) |
1066 |
CALL TIMER_STOP ('DO_WRITE_PICKUP [FORWARD_STEP]',myThid) |
1067 |
#endif /* ALLOW_DIVIDED_ADJOINT */ |
1068 |
|
1069 |
#ifdef TIME_PER_TIMESTEP |
1070 |
CCE107 Time per timestep information |
1071 |
_BEGIN_MASTER( myThid ) |
1072 |
CALL TIMER_GET_TIME( utnew, stnew, wtnew ) |
1073 |
WRITE(msgBuf,'(A34,3F10.6,I8)') |
1074 |
$ 'User, system and wallclock time:', utnew - utold, |
1075 |
$ stnew - stold, wtnew - wtold, iloop |
1076 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
1077 |
utold = utnew |
1078 |
stold = stnew |
1079 |
wtold = wtnew |
1080 |
_END_MASTER( myThid ) |
1081 |
#endif |
1082 |
#ifdef USE_PAPI_FLOPS |
1083 |
CCE107 PAPI summary performance |
1084 |
_BEGIN_MASTER( myThid ) |
1085 |
#ifdef USE_FLIPS |
1086 |
call PAPIF_flips(real_time, proc_time, flpops, mflops, check) |
1087 |
#else |
1088 |
call PAPIF_flops(real_time, proc_time, flpops, mflops, check) |
1089 |
#endif |
1090 |
WRITE(msgBuf,'(F10.6,A,F10.6,A34,I8)') |
1091 |
$ mflops, ' ', mflops*proc_time/(real_time + 1E-36), |
1092 |
$ 'Mflop/s during timestep ', iloop |
1093 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
1094 |
#ifdef PAPI_VERSION |
1095 |
call PAPIF_ipc(real_time, proc_time, instr, ipc, check) |
1096 |
WRITE(msgBuf,'(F10.6,A,F10.6,A34,I8)') |
1097 |
$ ipc, ' ', ipc*proc_time/(real_time + 1E-36), |
1098 |
$ 'IPC during timestep ', iloop |
1099 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
1100 |
#endif |
1101 |
_END_MASTER( myThid ) |
1102 |
#else |
1103 |
#ifdef USE_PCL_FLOPS |
1104 |
CCE107 PCL summary performance |
1105 |
_BEGIN_MASTER( myThid ) |
1106 |
res = PCLstop(descr, i_result, fp_result, nevents) |
1107 |
do ipcl = 1, nevents |
1108 |
WRITE(msgBuf,'(F10.6,A2,A22,A17,I8)'), fp_result(ipcl), |
1109 |
$ ' ', pcl_counter_name(pcl_counter_list(ipcl)), |
1110 |
$ 'during timestep ', iloop |
1111 |
CALL PRINT_MESSAGE(msgBuf,standardMessageUnit,SQUEEZE_RIGHT,1) |
1112 |
enddo |
1113 |
res = PCLstart(descr, pcl_counter_list, nevents, flags) |
1114 |
_END_MASTER( myThid ) |
1115 |
#endif |
1116 |
#endif |
1117 |
|
1118 |
#ifdef ALLOW_AUTODIFF_TAMC |
1119 |
#ifdef ALLOW_TAMC_CHECKPOINTING |
1120 |
endif |
1121 |
enddo |
1122 |
endif |
1123 |
enddo |
1124 |
#ifndef AUTODIFF_2_LEVEL_CHECKPOINT |
1125 |
endif |
1126 |
enddo |
1127 |
#endif |
1128 |
#ifdef AUTODIFF_4_LEVEL_CHECKPOINT |
1129 |
endif |
1130 |
enddo |
1131 |
#endif |
1132 |
c |
1133 |
#else /* ndef ALLOW_TAMC_CHECKPOINTING */ |
1134 |
enddo |
1135 |
#endif /* ALLOW_TAMC_CHECKPOINTING */ |
1136 |
|
1137 |
#else /* ndef ALLOW_AUTODIFF_TAMC */ |
1138 |
enddo |
1139 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
1140 |
|
1141 |
_BARRIER |
1142 |
call timer_stop ('ECCO MAIN LOOP', mythid) |
1143 |
|
1144 |
call timer_start('ECCO SPIN-DOWN', mythid) |
1145 |
|
1146 |
#ifdef ALLOW_PROFILES |
1147 |
#ifndef ALLOW_DIVIDED_ADJOINT |
1148 |
c-- Accumulate in-situ time averages of temperature, salinity, and SSH. |
1149 |
call timer_start('PROFILES_INLOOP [ECCO SPIN-DOWN]', mythid) |
1150 |
call profiles_inloop( mytime, mythid ) |
1151 |
call timer_stop ('PROFILES_INLOOP [ECCO SPIN-DOWN]', mythid) |
1152 |
#endif |
1153 |
#endif |
1154 |
|
1155 |
#ifdef ALLOW_COST |
1156 |
|
1157 |
#ifdef ALLOW_DIVIDED_ADJOINT |
1158 |
CADJ STORE mytime = onetape |
1159 |
#endif |
1160 |
c-- Accumulate time averages of temperature, salinity, and SSH. |
1161 |
#ifndef DISABLE_DEBUGMODE |
1162 |
IF ( debugLevel .GE. debLevB ) |
1163 |
& CALL DEBUG_CALL('cost_averagesfields',myThid) |
1164 |
#endif |
1165 |
call timer_start('cost_averagesfields [ECCO SPIN-DOWN]', mythid) |
1166 |
call cost_averagesfields( mytime, mythid ) |
1167 |
call timer_stop ('cost_averagesfields [ECCO SPIN-DOWN]', mythid) |
1168 |
#ifdef ALLOW_DIVIDED_ADJOINT |
1169 |
c************************************** |
1170 |
#include "cost_averages_bar_directives.h" |
1171 |
c************************************** |
1172 |
#endif |
1173 |
|
1174 |
#ifdef ALLOW_COST_ATLANTIC |
1175 |
c-- Compute meridional heat transport |
1176 |
#ifndef DISABLE_DEBUGMODE |
1177 |
IF ( debugLevel .GE. debLevB ) |
1178 |
& CALL DEBUG_CALL('cost_atlantic',myThid) |
1179 |
#endif |
1180 |
call timer_start('cost_atlantic [ECCO SPIN-DOWN]', mythid) |
1181 |
call cost_atlantic( mytime, myiter,mythid ) |
1182 |
call timer_stop ('cost_atlantic [ECCO SPIN-DOWN]', mythid) |
1183 |
#endif |
1184 |
|
1185 |
c-- Compute the cost function contribution of the boundary forcing, |
1186 |
c-- i.e. heat flux, salt flux, zonal and meridional wind stress. |
1187 |
#ifndef DISABLE_DEBUGMODE |
1188 |
IF ( debugLevel .GE. debLevB ) |
1189 |
& CALL DEBUG_CALL('cost_forcing',myThid) |
1190 |
#endif |
1191 |
call timer_start('cost_forcing [ECCO SPIN-DOWN]', mythid) |
1192 |
call cost_forcing( myiter, mytime, mythid ) |
1193 |
call timer_stop ('cost_forcing [ECCO SPIN-DOWN]', mythid) |
1194 |
cph( |
1195 |
c-- Compute cost function contribution of wind stress observations. |
1196 |
#ifdef ALLOW_MEAN_HFLUX_COST_CONTRIBUTION |
1197 |
call cost_mean_heatflux( myiter, mytime, mythid ) |
1198 |
# ifdef ALLOW_AUTODIFF_TAMC |
1199 |
CADJ STORE objf_hfluxmm = tapelev_init, key = 1 |
1200 |
# endif |
1201 |
#endif |
1202 |
|
1203 |
c-- Compute cost function contribution of wind stress observations. |
1204 |
#ifdef ALLOW_MEAN_SFLUX_COST_CONTRIBUTION |
1205 |
call cost_mean_saltflux( myiter, mytime, mythid ) |
1206 |
# ifdef ALLOW_AUTODIFF_TAMC |
1207 |
CADJ STORE objf_sfluxmm = tapelev_init, key = 1 |
1208 |
# endif |
1209 |
#endif |
1210 |
cph) |
1211 |
|
1212 |
c-- Compute cost function contribution of SSH. |
1213 |
#ifdef ALLOW_SSH_COST_CONTRIBUTION |
1214 |
# ifndef DISABLE_DEBUGMODE |
1215 |
IF ( debugLevel .GE. debLevB ) |
1216 |
& CALL DEBUG_CALL('cost_ssh',myThid) |
1217 |
# endif |
1218 |
call timer_start('cost_ssh [ECCO SPIN-DOWN]', mythid) |
1219 |
call cost_ssh( myiter, mytime, mythid ) |
1220 |
call timer_stop ('cost_ssh [ECCO SPIN-DOWN]', mythid) |
1221 |
# ifdef ALLOW_AUTODIFF_TAMC |
1222 |
# ifdef ALLOW_PROFILES |
1223 |
CADJ STORE prof_etan_mean = tapelev_init, key = 1 |
1224 |
# endif |
1225 |
# endif |
1226 |
#endif |
1227 |
|
1228 |
c-- Compute cost function contribution of Temperature and Salinity. |
1229 |
#ifndef DISABLE_DEBUGMODE |
1230 |
IF ( debugLevel .GE. debLevB ) |
1231 |
& CALL DEBUG_CALL('cost_hyd',myThid) |
1232 |
#endif |
1233 |
call timer_start('cost_hyd [ECCO SPIN-DOWN]', mythid) |
1234 |
call cost_hyd( myiter, mytime, mythid ) |
1235 |
call timer_stop ('cost_hyd [ECCO SPIN-DOWN]', mythid) |
1236 |
|
1237 |
#ifdef ALLOW_SEAICE |
1238 |
#ifndef DISABLE_DEBUGMODE |
1239 |
IF ( debugLevel .GE. debLevB ) |
1240 |
& CALL DEBUG_CALL('seaice_cost_driver',myThid) |
1241 |
#endif |
1242 |
call timer_start('seaice_cost_driver [ECCO SPIN-DOWN]', mythid) |
1243 |
call seaice_cost_driver( myiter, mytime, mythid ) |
1244 |
call timer_stop ('seaice_cost_driver [ECCO SPIN-DOWN]', mythid) |
1245 |
#endif |
1246 |
|
1247 |
#ifdef ALLOW_OBCS_COST_CONTRIBUTION |
1248 |
#ifndef DISABLE_DEBUGMODE |
1249 |
IF ( debugLevel .GE. debLevB ) |
1250 |
& CALL DEBUG_CALL('cost_obcs',myThid) |
1251 |
#endif |
1252 |
call timer_start('cost_obcs [ECCO SPIN-DOWN]', mythid) |
1253 |
call cost_obcs( myiter, mytime, mythid ) |
1254 |
call timer_stop ('cost_obcs [ECCO SPIN-DOWN]', mythid) |
1255 |
#endif |
1256 |
|
1257 |
#ifdef ALLOW_CURMTR_COST_CONTRIBUTION |
1258 |
#ifndef DISABLE_DEBUGMODE |
1259 |
IF ( debugLevel .GE. debLevB ) |
1260 |
& CALL DEBUG_CALL('cost_curmtr',myThid) |
1261 |
#endif |
1262 |
call timer_start('cost_curmtr [ECCO SPIN-DOWN]', mythid) |
1263 |
call cost_curmtr( myiter, mytime, mythid ) |
1264 |
call timer_stop ('cost_curmtr [ECCO SPIN-DOWN]', mythid) |
1265 |
#endif |
1266 |
|
1267 |
c-- Compute cost function contribution of drifter's velocities. |
1268 |
#ifdef ALLOW_DRIFTER_COST_CONTRIBUTION |
1269 |
#ifndef DISABLE_DEBUGMODE |
1270 |
IF ( debugLevel .GE. debLevB ) |
1271 |
& CALL DEBUG_CALL('cost_drifter',myThid) |
1272 |
#endif |
1273 |
call timer_start('cost_drifter [ECCO SPIN-DOWN]', mythid) |
1274 |
call cost_drifter( myiter, mytime, mythid ) |
1275 |
call timer_stop ('cost_drifter [ECCO SPIN-DOWN]', mythid) |
1276 |
#endif |
1277 |
|
1278 |
c-- Compute cost function contribution of wind stress observations. |
1279 |
#ifdef ALLOW_SCAT_COST_CONTRIBUTION |
1280 |
#ifndef DISABLE_DEBUGMODE |
1281 |
IF ( debugLevel .GE. debLevB ) |
1282 |
& CALL DEBUG_CALL('cost_scat',myThid) |
1283 |
#endif |
1284 |
call timer_start('cost_scat [ECCO SPIN-DOWN]', mythid) |
1285 |
call cost_scat( myiter, mytime, mythid ) |
1286 |
call timer_stop ('cost_scat [ECCO SPIN-DOWN]', mythid) |
1287 |
#endif |
1288 |
|
1289 |
c-- Compute cost function contribution of drift between the first |
1290 |
c and the last year. |
1291 |
#ifdef ALLOW_DRIFT_COST_CONTRIBUTION |
1292 |
#ifndef DISABLE_DEBUGMODE |
1293 |
IF ( debugLevel .GE. debLevB ) |
1294 |
& CALL DEBUG_CALL('cost_drift',myThid) |
1295 |
#endif |
1296 |
call timer_start('cost_drift [ECCO SPIN-DOWN]', mythid) |
1297 |
call cost_drift( myiter, mytime, mythid ) |
1298 |
call timer_stop ('cost_drift [ECCO SPIN-DOWN]', mythid) |
1299 |
#endif |
1300 |
#ifdef ALLOW_DRIFTW_COST_CONTRIBUTION |
1301 |
#ifndef DISABLE_DEBUGMODE |
1302 |
IF ( debugLevel .GE. debLevB ) |
1303 |
& CALL DEBUG_CALL('cost_driftw',myThid) |
1304 |
#endif |
1305 |
call timer_start('cost_driftw [ECCO SPIN-DOWN]', mythid) |
1306 |
call cost_driftw( myiter, mytime, mythid ) |
1307 |
call timer_stop ('cost_driftw [ECCO SPIN-DOWN]', mythid) |
1308 |
#endif |
1309 |
_BARRIER |
1310 |
|
1311 |
c-- Compute initial vs. final T/S deviation |
1312 |
#ifdef ALLOW_COST_INI_FIN |
1313 |
call timer_start('cost_ini_fin [ECCO SPIN-DOWN]', mythid) |
1314 |
call cost_theta_ini_fin( myiter, mytime, mythid ) |
1315 |
call cost_salt_ini_fin( myiter, mytime, mythid ) |
1316 |
call timer_stop ('cost_ini_fin [ECCO SPIN-DOWN]', mythid) |
1317 |
#endif |
1318 |
_BARRIER |
1319 |
|
1320 |
c-- Eddy stress penalty term |
1321 |
#ifdef ALLOW_COST_TAU_EDDY |
1322 |
call timer_start('cost_tau_eddy [ECCO SPIN-DOWN]', mythid) |
1323 |
call cost_tau_eddy( mythid ) |
1324 |
call timer_stop ('cost_tau_eddy [ECCO SPIN-DOWN]', mythid) |
1325 |
#endif |
1326 |
|
1327 |
c-- Sum all cost function contributions. |
1328 |
#ifndef DISABLE_DEBUGMODE |
1329 |
IF ( debugLevel .GE. debLevB ) |
1330 |
& CALL DEBUG_CALL('cost_final',myThid) |
1331 |
#endif |
1332 |
call timer_start('COST_FINAL [ECCO SPIN-DOWN]', mythid) |
1333 |
call cost_final( mythid ) |
1334 |
call timer_stop ('COST_FINAL [ECCO SPIN-DOWN]', mythid) |
1335 |
|
1336 |
#endif /* ALLOW_COST */ |
1337 |
|
1338 |
call timer_stop ('ECCO SPIN-DOWN', mythid) |
1339 |
|
1340 |
#ifndef DISABLE_DEBUGMODE |
1341 |
IF ( debugLevel .GE. debLevB ) |
1342 |
& CALL DEBUG_LEAVE('THE_MAIN_LOOP',myThid) |
1343 |
#endif |
1344 |
|
1345 |
return |
1346 |
end |
1347 |
|