80 |
#ifdef ALLOW_TAMC_CHECKPOINTING |
#ifdef ALLOW_TAMC_CHECKPOINTING |
81 |
ikey_dynamics = 1 |
ikey_dynamics = 1 |
82 |
#endif |
#endif |
|
#endif |
|
|
|
|
83 |
CALL TIMER_START('ADJOINT SPIN-UP', mythid) |
CALL TIMER_START('ADJOINT SPIN-UP', mythid) |
84 |
|
#endif |
85 |
|
|
86 |
C-- Set initial conditions (variable arrays) |
C-- Set initial conditions (variable arrays) |
87 |
CALL TIMER_START('INITIALISE_VARIA [ADJOINT SPIN-UP]', mythid) |
CALL TIMER_START('INITIALISE_VARIA [THE_MAIN_LOOP]', mythid) |
88 |
CALL INITIALISE_VARIA( mythid ) |
CALL INITIALISE_VARIA( mythid ) |
89 |
CALL TIMER_STOP ('INITIALISE_VARIA [ADJOINT SPIN-UP]', mythid) |
CALL TIMER_STOP ('INITIALISE_VARIA [THE_MAIN_LOOP]', mythid) |
90 |
|
|
91 |
#ifndef ALLOW_AUTODIFF_TAMC |
#ifndef ALLOW_AUTODIFF_TAMC |
92 |
c-- Dump for start state. |
c-- Dump for start state. |
93 |
CALL TIMER_START('I/O (WRITE) [ADJOINT SPIN-UP]', mythid) |
CALL TIMER_START('WRITE_STATE [THE_MAIN_LOOP]', mythid) |
94 |
CALL WRITE_STATE( mytime, myiter, mythid ) |
CALL WRITE_STATE( mytime, myiter, mythid ) |
95 |
CALL TIMER_STOP ('I/O (WRITE) [ADJOINT SPIN-UP]', mythid) |
CALL TIMER_STOP ('WRITE_STATE [THE_MAIN_LOOP]', mythid) |
96 |
#endif |
#endif |
97 |
|
|
98 |
#ifndef EXCLUDE_MONITOR |
#ifndef EXCLUDE_MONITOR |
99 |
C-- Check status of solution (statistics, cfl, etc...) |
C-- Check status of solution (statistics, cfl, etc...) |
100 |
|
CALL TIMER_START('MONITOR [THE_MAIN_LOOP]', mythid) |
101 |
CALL MONITOR( myIter, myTime, myThid ) |
CALL MONITOR( myIter, myTime, myThid ) |
102 |
|
CALL TIMER_STOP ('MONITOR [THE_MAIN_LOOP]', mythid) |
103 |
#endif /* EXCLUDE_MONITOR */ |
#endif /* EXCLUDE_MONITOR */ |
104 |
|
|
105 |
#ifdef ALLOW_COST_TEST |
#ifdef ALLOW_COST_TEST |
107 |
CALL CTRL_MAP_FORCING (mythid) |
CALL CTRL_MAP_FORCING (mythid) |
108 |
#endif |
#endif |
109 |
|
|
110 |
|
#ifdef ALLOW_AUTODIFF_TAMC |
111 |
CALL TIMER_STOP ('ADJOINT SPIN-UP', mythid) |
CALL TIMER_STOP ('ADJOINT SPIN-UP', mythid) |
112 |
_BARRIER |
_BARRIER |
113 |
|
#endif |
114 |
|
|
115 |
c-- Do the model integration. |
c-- Do the model integration. |
116 |
call timer_start('ADJOINT MAIN LOOP',mythid) |
CALL TIMER_START('MAIN LOOP [THE_MAIN_LOOP]', mythid) |
117 |
|
|
118 |
c >>>>>>>>>>>>>>>>>>>>>>>>>>> LOOP <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
c >>>>>>>>>>>>>>>>>>>>>>>>>>> LOOP <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
119 |
c >>>>>>>>>>>>>>>>>>>>>>>>>>> STARTS <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
c >>>>>>>>>>>>>>>>>>>>>>>>>>> STARTS <<<<<<<<<<<<<<<<<<<<<<<<<<<< |
228 |
stop ' ... stopped in the_main_loop.' |
stop ' ... stopped in the_main_loop.' |
229 |
endif |
endif |
230 |
|
|
231 |
do iloop = 1, nTimeSteps |
DO iloop = 1, nTimeSteps |
232 |
|
|
233 |
#endif /* ALLOW_TAMC_CHECKPOINTING */ |
#endif /* ALLOW_TAMC_CHECKPOINTING */ |
234 |
|
|
236 |
|
|
237 |
c-- Start the main loop of adjoint_Objfunc. Automatic differentiation |
c-- Start the main loop of adjoint_Objfunc. Automatic differentiation |
238 |
c-- NOT enabled. |
c-- NOT enabled. |
239 |
do iloop = 1, nTimeSteps |
DO iloop = 1, nTimeSteps |
240 |
|
|
241 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
242 |
|
|
243 |
c-- >>> Loop body start <<< |
c-- >>> Loop body start <<< |
244 |
|
|
245 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
246 |
c-- Set the model iteration counter and the model time. |
c-- Set the model iteration counter and the model time. |
247 |
myiter = nIter0 + (iloop-1) |
myiter = nIter0 + (iloop-1) |
248 |
mytime = startTime + float(iloop-1)*deltaTclock |
mytime = startTime + float(iloop-1)*deltaTclock |
249 |
#endif |
#endif |
250 |
|
|
251 |
c-- Load forcing/external data fields. |
c-- Load forcing/external data fields. |
|
call timer_start('EXTERNAL_FIELDS_LOAD [ADJOINT]',mythid) |
|
252 |
#ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE |
#ifdef INCLUDE_EXTERNAL_FORCING_PACKAGE |
253 |
c NOTE, that although the exf package is part of the |
c NOTE, that although the exf package is part of the |
254 |
c distribution, it is not currently maintained, i.e. |
c distribution, it is not currently maintained, i.e. |
255 |
c exf is disabled by default in genmake. |
c exf is disabled by default in genmake. |
256 |
call exf_getforcing( mytime, myiter, mythid ) |
call exf_getforcing( mytime, myiter, mythid ) |
257 |
#else |
#else |
258 |
call external_fields_load( mytime, myiter, mythid ) |
CALL TIMER_START('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid) |
259 |
|
CALL EXTERNAL_FIELDS_LOAD( mytime, myiter, mythid ) |
260 |
|
CALL TIMER_STOP ('EXTERNAL_FIELDS_LOAD[THE_MAIN_LOOP]',mythid) |
261 |
#endif |
#endif |
|
call timer_stop ('EXTERNAL_FIELDS_LOAD [ADJOINT]',mythid) |
|
262 |
|
|
263 |
#ifdef ALLOW_TAMC_CHECKPOINTING |
#ifdef ALLOW_TAMC_CHECKPOINTING |
264 |
ikey_dynamics = ilev_1 |
ikey_dynamics = ilev_1 |
265 |
#endif |
#endif |
266 |
c-- Step forward fields and calculate time tendency terms. |
c-- Step forward fields and calculate time tendency terms. |
267 |
call timer_start('DYNAMICS [ADJOINT]',mythid) |
CALL TIMER_START('DYNAMICS [THE_MAIN_LOOP]',mythid) |
268 |
call dynamics( mytime, myiter, mythid ) |
CALL DYNAMICS( myTime, myIter, myThid ) |
269 |
call timer_stop ('DYNAMICS [ADJOINT]',mythid) |
CALL TIMER_STOP ('DYNAMICS [THE_MAIN_LOOP]',mythid) |
270 |
|
|
271 |
#ifndef ALLOW_AUTODIFF_TAMC |
#ifndef ALLOW_AUTODIFF_TAMC |
272 |
|
|
273 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
274 |
C-- Step forward W field in N-H algorithm |
C-- Step forward W field in N-H algorithm |
275 |
IF ( nonHydrostatic ) THEN |
IF ( nonHydrostatic ) THEN |
276 |
CALL TIMER_START('CALC_GW [ADJOINT]',myThid) |
CALL TIMER_START('CALC_GW [THE_MAIN_LOOP]',myThid) |
277 |
CALL CALC_GW( myThid) |
CALL CALC_GW(myThid) |
278 |
CALL TIMER_STOP ('CALC_GW [ADJOINT]',myThid) |
CALL TIMER_STOP ('CALC_GW [THE_MAIN_LOOP]',myThid) |
279 |
ENDIF |
ENDIF |
280 |
#endif |
#endif |
281 |
|
|
282 |
#ifdef ALLOW_SHAP_FILT |
#ifdef ALLOW_SHAP_FILT |
283 |
C-- Step forward all tiles, filter and exchange. |
C-- Step forward all tiles, filter and exchange. |
284 |
CALL TIMER_START('SHAP_FILT [ADJOINT]',myThid) |
CALL TIMER_START('SHAP_FILT [THE_MAIN_LOOP]',myThid) |
285 |
CALL SHAP_FILT_APPLY( |
CALL SHAP_FILT_APPLY( |
286 |
I gUnm1, gVnm1, gTnm1, gSnm1, |
I gUnm1, gVnm1, gTnm1, gSnm1, |
287 |
I myTime, myIter, myThid ) |
I myTime, myIter, myThid ) |
290 |
C => Filtering of uVel,vVel is necessary |
C => Filtering of uVel,vVel is necessary |
291 |
CALL SHAP_FILT_UV( uVel, vVel, myTime, myThid ) |
CALL SHAP_FILT_UV( uVel, vVel, myTime, myThid ) |
292 |
ENDIF |
ENDIF |
293 |
CALL TIMER_STOP ('SHAP_FILT [ADJOINT]',myThid) |
CALL TIMER_STOP ('SHAP_FILT [THE_MAIN_LOOP]',myThid) |
294 |
#endif |
#endif |
295 |
|
|
296 |
#ifdef ALLOW_ZONAL_FILT |
#ifdef ALLOW_ZONAL_FILT |
297 |
IF (zonal_filt_lat.LT.90.) THEN |
IF (zonal_filt_lat.LT.90.) THEN |
298 |
CALL ZONAL_FILT_APPLY( |
CALL TIMER_START('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid) |
299 |
|
CALL ZONAL_FILT_APPLY( |
300 |
U gUnm1, gVnm1, gTnm1, gSnm1, |
U gUnm1, gVnm1, gTnm1, gSnm1, |
301 |
I myThid ) |
I myThid ) |
302 |
|
CALL TIMER_STOP ('ZONAL_FILT_APPLY [THE_MAIN_LOOP]',myThid) |
303 |
ENDIF |
ENDIF |
304 |
#endif |
#endif |
305 |
|
|
308 |
C-- Solve elliptic equation(s). |
C-- Solve elliptic equation(s). |
309 |
C Two-dimensional only for conventional hydrostatic or |
C Two-dimensional only for conventional hydrostatic or |
310 |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
C three-dimensional for non-hydrostatic and/or IGW scheme. |
311 |
CALL TIMER_START('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
CALL TIMER_START('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid) |
312 |
CALL SOLVE_FOR_PRESSURE( myThid ) |
CALL SOLVE_FOR_PRESSURE( myThid ) |
313 |
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [FORWARD_STEP]',myThid) |
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid) |
314 |
|
|
315 |
#ifdef ALLOW_AUTODIFF_TAMC |
#ifdef ALLOW_AUTODIFF_TAMC |
316 |
c Include call to a dummy routine. Its adjoint will be |
c Include call to a dummy routine. Its adjoint will be |
326 |
C arrays (for all fields) ; update time-counter |
C arrays (for all fields) ; update time-counter |
327 |
myIter = nIter0 + iLoop |
myIter = nIter0 + iLoop |
328 |
myTime = startTime + deltaTClock * float(iLoop) |
myTime = startTime + deltaTClock * float(iLoop) |
329 |
|
CALL TIMER_START('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid) |
330 |
CALL THE_CORRECTION_STEP(myTime, myIter, myThid) |
CALL THE_CORRECTION_STEP(myTime, myIter, myThid) |
331 |
|
CALL TIMER_STOP ('THE_CORRECTION_STEP [THE_MAIN_LOOP]',myThid) |
332 |
|
|
333 |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
C-- Do "blocking" sends and receives for tendency "overlap" terms |
334 |
c CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
c CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
335 |
c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
c CALL DO_GTERM_BLOCKING_EXCHANGES( myThid ) |
336 |
c CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
c CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
337 |
|
|
338 |
C-- Do "blocking" sends and receives for field "overlap" terms |
C-- Do "blocking" sends and receives for field "overlap" terms |
339 |
CALL TIMER_START('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
CALL TIMER_START('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
340 |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
341 |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [FORWARD_STEP]',myThid) |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
342 |
|
|
343 |
#ifndef EXCLUDE_MONITOR |
#ifndef EXCLUDE_MONITOR |
344 |
C-- Check status of solution (statistics, cfl, etc...) |
C-- Check status of solution (statistics, cfl, etc...) |
347 |
|
|
348 |
#ifndef ALLOW_AUTODIFF_TAMC |
#ifndef ALLOW_AUTODIFF_TAMC |
349 |
C-- Do IO if needed. |
C-- Do IO if needed. |
350 |
CALL TIMER_START('I/O (WRITE) [FORWARD_STEP]',myThid) |
CALL TIMER_START('DO_THE_MODEL_IO [THE_MAIN_LOOP]',myThid) |
351 |
CALL DO_THE_MODEL_IO( myTime, myIter, myThid ) |
CALL DO_THE_MODEL_IO( myTime, myIter, myThid ) |
352 |
CALL TIMER_STOP ('I/O (WRITE) [FORWARD_STEP]',myThid) |
CALL TIMER_STOP ('DO_THE_MODEL_IO [THE_MAIN_LOOP]',myThid) |
353 |
|
|
354 |
C-- Save state for restarts |
C-- Save state for restarts |
355 |
C Note: (jmc: is it still the case after ckp35 ?) |
C Note: (jmc: is it still the case after ckp35 ?) |
364 |
C etaN.0000000001 in the indexing scheme used for the model |
C etaN.0000000001 in the indexing scheme used for the model |
365 |
C "state" files. This example is referred to as a checkpoint |
C "state" files. This example is referred to as a checkpoint |
366 |
C at time level 1 |
C at time level 1 |
367 |
CALL TIMER_START('I/O (WRITE) [FORWARD_STEP]',myThid) |
CALL TIMER_START('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid) |
368 |
CALL WRITE_CHECKPOINT( |
CALL WRITE_CHECKPOINT( |
369 |
& .FALSE., myTime, myIter, myThid ) |
& .FALSE., myTime, myIter, myThid ) |
370 |
CALL TIMER_STOP ('I/O (WRITE) [FORWARD_STEP]',myThid) |
CALL TIMER_STOP ('WRITE_CHECKPOINT [THE_MAIN_LOOP]',myThid) |
371 |
|
|
372 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
#endif /* ALLOW_AUTODIFF_TAMC */ |
373 |
|
|
390 |
#endif |
#endif |
391 |
|
|
392 |
_BARRIER |
_BARRIER |
393 |
call timer_stop ('ADJOINT MAIN LOOP', mythid) |
CALL TIMER_STOP ('MAIN LOOP [THE_MAIN_LOOP]', mythid) |
|
|
|
|
call timer_start('ADJOINT FINALIZE COST', mythid) |
|
394 |
|
|
395 |
#ifdef ALLOW_COST_TEST |
#ifdef ALLOW_COST_TEST |
396 |
|
call timer_start('ADJOINT FINALIZE COST', mythid) |
397 |
c-- Veronique's test case |
c-- Veronique's test case |
398 |
call timer_start('cost_test [ADJOINT SPIN-DOWN]', mythid) |
call timer_start('cost_test [ADJOINT SPIN-DOWN]', mythid) |
399 |
call cost_test( myThid ) |
call cost_test( myThid ) |
403 |
call timer_start('COST_FINAL [ADJOINT SPIN-DOWN]', mythid) |
call timer_start('COST_FINAL [ADJOINT SPIN-DOWN]', mythid) |
404 |
call cost_Final( mythid ) |
call cost_Final( mythid ) |
405 |
call timer_stop ('COST_FINAL [ADJOINT SPIN-DOWN]', mythid) |
call timer_stop ('COST_FINAL [ADJOINT SPIN-DOWN]', mythid) |
|
#endif |
|
|
|
|
406 |
call timer_stop ('ADJOINT FINALIZE COST', mythid) |
call timer_stop ('ADJOINT FINALIZE COST', mythid) |
407 |
|
#endif |
408 |
|
|
|
end |
|
409 |
|
|
410 |
|
END |