34 |
#include "PARAMS.h" |
#include "PARAMS.h" |
35 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
36 |
#include "FFIELDS.h" |
#include "FFIELDS.h" |
37 |
|
#include "TR1.h" |
38 |
|
|
39 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
40 |
#include "CG3D.h" |
#include "CG3D.h" |
104 |
CALL TIMER_STOP ('MONITOR [THE_MAIN_LOOP]', mythid) |
CALL TIMER_STOP ('MONITOR [THE_MAIN_LOOP]', mythid) |
105 |
#endif /* EXCLUDE_MONITOR */ |
#endif /* EXCLUDE_MONITOR */ |
106 |
|
|
107 |
#ifdef ALLOW_COST_TEST |
#ifdef ALLOW_ADJOINT_RUN |
108 |
c-- Add control vector for forcing and parameter fields |
c-- Add control vector for forcing and parameter fields |
109 |
CALL CTRL_MAP_FORCING (mythid) |
CALL CTRL_MAP_FORCING (mythid) |
110 |
#endif |
#endif |
159 |
CADJ STORE unm1 = tapelev3, key = ilev_3 |
CADJ STORE unm1 = tapelev3, key = ilev_3 |
160 |
CADJ STORE vnm1 = tapelev3, key = ilev_3 |
CADJ STORE vnm1 = tapelev3, key = ilev_3 |
161 |
#endif |
#endif |
162 |
|
#ifdef ALLOW_COST_TRACER |
163 |
|
CADJ STORE tr1 = tapelev3, key = ilev_3 |
164 |
|
CADJ STORE gtr1nm1 = tapelev3, key = ilev_3 |
165 |
|
#endif |
166 |
|
|
167 |
c-- Initialise storage for the middle loop. |
c-- Initialise storage for the middle loop. |
168 |
CADJ INIT tapelev2 = USER |
CADJ INIT tapelev2 = USER |
186 |
CADJ STORE unm1 = tapelev2, key = ilev_2 |
CADJ STORE unm1 = tapelev2, key = ilev_2 |
187 |
CADJ STORE vnm1 = tapelev2, key = ilev_2 |
CADJ STORE vnm1 = tapelev2, key = ilev_2 |
188 |
#endif |
#endif |
189 |
|
#ifdef ALLOW_COST_TRACER |
190 |
|
CADJ STORE tr1 = tapelev2, key = ilev_2 |
191 |
|
CADJ STORE gtr1nm1 = tapelev2, key = ilev_2 |
192 |
|
#endif |
193 |
|
|
194 |
c-- Initialize storage for the innermost loop. |
c-- Initialize storage for the innermost loop. |
195 |
c-- Always check common block sizes for the checkpointing! |
c-- Always check common block sizes for the checkpointing! |
196 |
CADJ INIT comlev1 = COMMON,nchklev_1 |
CADJ INIT comlev1 = COMMON,nchklev_1 |
197 |
CADJ INIT comlev1_bibj = COMMON,nchklev_1*nsx*nsy*nthreads_chkpt |
CADJ INIT comlev1_bibj = COMMON,nchklev_1*nsx*nsy*nthreads_chkpt |
198 |
CADJ INIT comlev1_bibj_k = COMMON,nchklev_1*nsx*nsy*nr*nthreads_chkpt |
CADJ INIT comlev1_bibj_k = COMMON,nchklev_1*nsx*nsy*nr*nthreads_chkpt |
|
cphCADJ INIT comlev1_impl = COMMON,nchklev_1*nsx*nsy*6 |
|
199 |
CADJ INIT comlev1_kpp = COMMON,nchklev_1*nsx*nsy |
CADJ INIT comlev1_kpp = COMMON,nchklev_1*nsx*nsy |
200 |
|
|
201 |
C-- RG replace 2 by max of num_v_smooth_Ri |
C-- RG replace 2 by max of num_v_smooth_Ri |
219 |
CADJ INIT history = USER |
CADJ INIT history = USER |
220 |
CADJ INIT comlev1_bibj = COMMON,nchklev_0*nsx*nsy*nthreads_chkpt |
CADJ INIT comlev1_bibj = COMMON,nchklev_0*nsx*nsy*nthreads_chkpt |
221 |
CADJ INIT comlev1_bibj_k = COMMON,nchklev_0*nsx*nsy*nr*nthreads_chkpt |
CADJ INIT comlev1_bibj_k = COMMON,nchklev_0*nsx*nsy*nr*nthreads_chkpt |
|
CADJ INIT comlev1_impl = COMMON,nchklev_0*nsx*nsy*6 |
|
|
CADJ INIT comlev1_impl_k = COMMON,nchklev_0*nsx*nsy*(nr-2)*6 |
|
222 |
CADJ INIT comlev1_kpp = COMMON,nchklev_0*nsx*nsy |
CADJ INIT comlev1_kpp = COMMON,nchklev_0*nsx*nsy |
223 |
|
|
224 |
C-- RG replace 2 by max of num_v_smooth_Ri |
C-- RG replace 2 by max of num_v_smooth_Ri |
253 |
c-- Set the model iteration counter and the model time. |
c-- Set the model iteration counter and the model time. |
254 |
myiter = nIter0 + (iloop-1) |
myiter = nIter0 + (iloop-1) |
255 |
mytime = startTime + float(iloop-1)*deltaTclock |
mytime = startTime + float(iloop-1)*deltaTclock |
256 |
|
|
257 |
|
c Include call to a dummy routine. Its adjoint will be |
258 |
|
c called at the proper place in the adjoint code. |
259 |
|
c The adjoint routine will print out adjoint values |
260 |
|
c if requested. The location of the call is important, |
261 |
|
c it has to be after the adjoint of the exchanges |
262 |
|
c (DO_GTERM_BLOCKING_EXCHANGES). |
263 |
|
call dummy_in_stepping( myTime, myIter, myThid ) |
264 |
#endif |
#endif |
265 |
|
|
266 |
c-- Load forcing/external data fields. |
c-- Load forcing/external data fields. |
327 |
CALL SOLVE_FOR_PRESSURE( myThid ) |
CALL SOLVE_FOR_PRESSURE( myThid ) |
328 |
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid) |
CALL TIMER_STOP ('SOLVE_FOR_PRESSURE [THE_MAIN_LOOP]',myThid) |
329 |
|
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
|
|
c Include call to a dummy routine. Its adjoint will be |
|
|
c called at the proper place in the adjoint code. |
|
|
c The adjoint routine will print out adjoint values |
|
|
c if requested. The location of the call is important, |
|
|
c it has to be after the adjoint of the exchanges |
|
|
c (DO_GTERM_BLOCKING_EXCHANGES). |
|
|
call dummy_in_stepping( myTime, myIter, myThid ) |
|
|
#endif |
|
|
|
|
330 |
C-- Correct divergence in flow field and cycle time-stepping |
C-- Correct divergence in flow field and cycle time-stepping |
331 |
C arrays (for all fields) ; update time-counter |
C arrays (for all fields) ; update time-counter |
332 |
myIter = nIter0 + iLoop |
myIter = nIter0 + iLoop |
345 |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid ) |
346 |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
CALL TIMER_STOP ('BLOCKING_EXCHANGES [THE_MAIN_LOOP]',myThid) |
347 |
|
|
348 |
|
#ifdef ALLOW_COST |
349 |
|
C-- compare model with data and compute cost function |
350 |
|
C-- this is done after exchanges to allow interpolation |
351 |
|
CALL TIMER_START('COST_TILE [THE_MAIN_LOOP]',myThid) |
352 |
|
CALL COST_TILE ( myThid ) |
353 |
|
CALL TIMER_STOP ('COST_TILE [THE_MAIN_LOOP]',myThid) |
354 |
|
#endif |
355 |
|
|
356 |
#ifndef EXCLUDE_MONITOR |
#ifndef EXCLUDE_MONITOR |
357 |
C-- Check status of solution (statistics, cfl, etc...) |
C-- Check status of solution (statistics, cfl, etc...) |
358 |
CALL MONITOR( myIter, myTime, myThid ) |
CALL MONITOR( myIter, myTime, myThid ) |
402 |
enddo |
enddo |
403 |
#endif |
#endif |
404 |
|
|
405 |
|
#ifdef ALLOW_COST |
406 |
|
c-- Sum all cost function contributions. |
407 |
|
call TIMER_START('COST_FINAL [ADJOINT SPIN-DOWN]', mythid) |
408 |
|
call COST_FINAL ( mythid ) |
409 |
|
call TIMER_STOP ('COST_FINAL [ADJOINT SPIN-DOWN]', mythid) |
410 |
|
#endif |
411 |
|
|
412 |
_BARRIER |
_BARRIER |
413 |
CALL TIMER_STOP ('MAIN LOOP [THE_MAIN_LOOP]', mythid) |
CALL TIMER_STOP ('MAIN LOOP [THE_MAIN_LOOP]', mythid) |
414 |
|
|
|
#ifdef ALLOW_COST_TEST |
|
|
call timer_start('ADJOINT FINALIZE COST', mythid) |
|
|
c-- Veronique's test case |
|
|
call timer_start('cost_test [ADJOINT SPIN-DOWN]', mythid) |
|
|
call cost_test( myThid ) |
|
|
call timer_stop ('cost_test [ADJOINT SPIN-DOWN]', mythid) |
|
|
|
|
|
c-- Sum all cost function contributions. |
|
|
call timer_start('COST_FINAL [ADJOINT SPIN-DOWN]', mythid) |
|
|
call cost_Final( mythid ) |
|
|
call timer_stop ('COST_FINAL [ADJOINT SPIN-DOWN]', mythid) |
|
|
call timer_stop ('ADJOINT FINALIZE COST', mythid) |
|
|
#endif |
|
415 |
|
|
416 |
|
|
417 |
END |
END |