91 |
C | | |-OPTIM_READPARMS :: Optimisation support package. see pkg/ctrl |
C | | |-OPTIM_READPARMS :: Optimisation support package. see pkg/ctrl |
92 |
C | | |-GRDCHK_READPARMS :: Gradient check package. see pkg/grdchk |
C | | |-GRDCHK_READPARMS :: Gradient check package. see pkg/grdchk |
93 |
C | | |-ECCO_READPARMS :: ECCO Support Package. see pkg/ecco |
C | | |-ECCO_READPARMS :: ECCO Support Package. see pkg/ecco |
94 |
|
C | | |-PTRACERS_READPARMS :: multiple tracer package, see pkg/ptracers |
95 |
|
C | | |-GCHEM_READPARMS :: tracer interface package, see pkg/gchem |
96 |
C | | |
C | | |
97 |
C | |-PACKAGES_CHECK |
C | |-PACKAGES_CHECK |
98 |
C | | | |
C | | | |
103 |
C | |-PACKAGES_INIT_FIXED |
C | |-PACKAGES_INIT_FIXED |
104 |
C | | |-OBCS_INIT_FIXED :: Open bndy Package. see pkg/obcs |
C | | |-OBCS_INIT_FIXED :: Open bndy Package. see pkg/obcs |
105 |
C | | |-FLT_INIT :: Floats Package. see pkg/flt |
C | | |-FLT_INIT :: Floats Package. see pkg/flt |
106 |
|
C | | |-GCHEM_INIT_FIXED :: tracer interface pachage, see pkg/gchem |
107 |
C | | |
C | | |
108 |
C | |-ZONAL_FILT_INIT :: FFT filter Package. see pkg/zonal_filt |
C | |-ZONAL_FILT_INIT :: FFT filter Package. see pkg/zonal_filt |
109 |
C | | |
C | | |
181 |
C | | | |-KPP_INIT :: KPP package. ( see pkg/kpp ) |
C | | | |-KPP_INIT :: KPP package. ( see pkg/kpp ) |
182 |
C | | | |-KPP_OPEN_DIAGS |
C | | | |-KPP_OPEN_DIAGS |
183 |
C | | | |-OBCS_INIT_VARIABLES :: Open bndy. package. ( see pkg/obcs ) |
C | | | |-OBCS_INIT_VARIABLES :: Open bndy. package. ( see pkg/obcs ) |
184 |
|
C | | | |-PTRACERS_INIT :: multi. tracer package,(see pkg/ptracers) |
185 |
|
C | | | |-GCHEM_INIT : : tracer interface pkg (see pkh/gchem) |
186 |
C | | | |-AIM_INIT :: Interm. atmos package. ( see pkg/aim ) |
C | | | |-AIM_INIT :: Interm. atmos package. ( see pkg/aim ) |
187 |
C | | | |-CTRL_MAP_INI :: Control vector package.( see pkg/ctrl ) |
C | | | |-CTRL_MAP_INI :: Control vector package.( see pkg/ctrl ) |
188 |
C | | | |-COST_INIT :: Cost function package. ( see pkg/cost ) |
C | | | |-COST_INIT :: Cost function package. ( see pkg/cost ) |
226 |
C/\ | | | | |
C/\ | | | | |
227 |
C/\ | | | |-EXCH :: Sync forcing. in overlap regions. |
C/\ | | | |-EXCH :: Sync forcing. in overlap regions. |
228 |
C/\ | | |-SEAICE_MODEL :: Compute sea-ice terms. ( pkg/seaice ) |
C/\ | | |-SEAICE_MODEL :: Compute sea-ice terms. ( pkg/seaice ) |
229 |
|
C/\ | | |-GCHEM_FIELD_LOAD :: load tracer forcing fields (pkg/gchem) |
230 |
C/\ | | | |
C/\ | | | |
231 |
C/\ | | |-THERMODYNAMICS :: theta, salt + tracer equations driver. |
C/\ | | |-THERMODYNAMICS :: theta, salt + tracer equations driver. |
232 |
C/\ | | | | |
C/\ | | | | |
238 |
C/\ | | | | |
C/\ | | | | |
239 |
C/\ | | | |-OBCS_CALC :: Open bndy. package ( see pkg/obcs ). |
C/\ | | | |-OBCS_CALC :: Open bndy. package ( see pkg/obcs ). |
240 |
C/\ | | | |-EXTERNAL_FORCING_SURF:: Accumulates appropriately dimensioned |
C/\ | | | |-EXTERNAL_FORCING_SURF:: Accumulates appropriately dimensioned |
241 |
C/\ | | | | :: forcing terms. |
C/\ | | | | | :: forcing terms. |
242 |
|
C/\ | | | | |-PTRACERS_FORCING_SURF :: Tracer package ( see pkg/ptracers ). |
243 |
C/\ | | | | |
C/\ | | | | |
244 |
C/\ | | | |-GMREDI_CALC_TENSOR :: GM package ( see pkg/gmredi ). |
C/\ | | | |-GMREDI_CALC_TENSOR :: GM package ( see pkg/gmredi ). |
245 |
C/\ | | | |-GMREDI_CALC_TENSOR_DUMMY :: GM package ( see pkg/gmredi ). |
C/\ | | | |-GMREDI_CALC_TENSOR_DUMMY :: GM package ( see pkg/gmredi ). |
257 |
C/\ | | | |-CALC_GT :: Calculate the temperature tendency terms |
C/\ | | | |-CALC_GT :: Calculate the temperature tendency terms |
258 |
C/\ | | | | | |
C/\ | | | | | |
259 |
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
260 |
C/\ | | | | | :: ( see pkg/gad ) |
C/\ | | | | | | :: ( see pkg/gad ) |
261 |
|
C/\ | | | | | |-KPP_TRANSPORT_T :: KPP non-local transport ( see pkg/kpp ). |
262 |
|
C/\ | | | | | |
263 |
C/\ | | | | |-EXTERNAL_FORCING_T :: Problem specific forcing for temperature. |
C/\ | | | | |-EXTERNAL_FORCING_T :: Problem specific forcing for temperature. |
264 |
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
265 |
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height. |
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gt for free-surface height. |
269 |
C/\ | | | |-CALC_GS :: Calculate the salinity tendency terms |
C/\ | | | |-CALC_GS :: Calculate the salinity tendency terms |
270 |
C/\ | | | | | |
C/\ | | | | | |
271 |
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
272 |
C/\ | | | | | :: ( see pkg/gad ) |
C/\ | | | | | | :: ( see pkg/gad ) |
273 |
|
C/\ | | | | | |-KPP_TRANSPORT_S :: KPP non-local transport ( see pkg/kpp ). |
274 |
|
C/\ | | | | | |
275 |
C/\ | | | | |-EXTERNAL_FORCING_S :: Problem specific forcing for salt. |
C/\ | | | | |-EXTERNAL_FORCING_S :: Problem specific forcing for salt. |
276 |
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
277 |
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height. |
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height. |
282 |
C/\ | | | | | |
C/\ | | | | | |
283 |
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
284 |
C/\ | | | | | :: ( see pkg/gad ) |
C/\ | | | | | :: ( see pkg/gad ) |
285 |
|
C/\ | | | | | |
286 |
C/\ | | | | |-EXTERNAL_FORCING_TR:: Problem specific forcing for tracer. |
C/\ | | | | |-EXTERNAL_FORCING_TR:: Problem specific forcing for tracer. |
287 |
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
288 |
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height. |
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height. |
289 |
C/\ | | | | |
C/\ | | | | |
290 |
C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time |
C/\ | | | |-TIMESTEP_TRACER :: Step tracer field forward in time |
291 |
|
C/\ | | | | |
292 |
|
C/\ | | | |-PTRACERS_INTEGRATE :: Integrate other tracer(s) ( see pkg/ptracers ). |
293 |
|
C/\ | | | | | |
294 |
|
C/\ | | | | |-GAD_CALC_RHS :: Generalised advection package |
295 |
|
C/\ | | | | | | :: ( see pkg/gad ) |
296 |
|
C/\ | | | | | |-KPP_TRANSPORT_PTR:: KPP non-local transport ( see pkg/kpp ). |
297 |
|
C/\ | | | | | |
298 |
|
C/\ | | | | |-PTRACERS_FORCING :: Problem specific forcing for tracer. |
299 |
|
C/\ | | | | |-GCHEM_FORCING_INT :: tracer forcing for gchem pkg (if all |
300 |
|
C/\ | | | | | tendancy terms calcualted together) |
301 |
|
C/\ | | | | |-ADAMS_BASHFORTH2 :: Extrapolate tendencies forward in time. |
302 |
|
C/\ | | | | |-FREESURF_RESCALE_G :: Re-scale Gs for free-surface height. |
303 |
|
C/\ | | | | |-TIMESTEP_TRACER :: Step tracer field forward in time |
304 |
|
C/\ | | | | |
305 |
C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ). |
C/\ | | | |-OBCS_APPLY_TS :: Open bndy. package (see pkg/obcs ). |
306 |
C/\ | | | |-FREEZE :: Limit range of temperature. |
C/\ | | | |-FREEZE :: Limit range of temperature. |
307 |
C/\ | | | | |
C/\ | | | | |
362 |
C/\ | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions. |
C/\ | | |-DO_FIELDS_BLOCKING_EXCHANGES :: Sync up overlap regions. |
363 |
C/\ | | | |-EXCH |
C/\ | | | |-EXCH |
364 |
C/\ | | | |
C/\ | | | |
365 |
|
C/\ | | |-GCHEM_FORCING_SEP :: tracer forcing for gchem pkg (if |
366 |
|
C/\ | | | tracer dependent tendencies calculated |
367 |
|
C/\ | | | separatly) |
368 |
|
C/\ | | | |
369 |
C/\ | | |-FLT_MAIN :: Float package ( pkg/flt ). |
C/\ | | |-FLT_MAIN :: Float package ( pkg/flt ). |
370 |
C/\ | | | |
C/\ | | | |
371 |
C/\ | | |-MONITOR :: Monitor package ( pkg/monitor ). |
C/\ | | |-MONITOR :: Monitor package ( pkg/monitor ). |
378 |
C/\ | | | |-KPP_DO_DIAGS :: KPP diags. see pkg/kpp |
C/\ | | | |-KPP_DO_DIAGS :: KPP diags. see pkg/kpp |
379 |
C/\ | | | |-SBO_CALC :: SBO diags. see pkg/sbo |
C/\ | | | |-SBO_CALC :: SBO diags. see pkg/sbo |
380 |
C/\ | | | |-SBO_DIAGS :: SBO diags. see pkg/sbo |
C/\ | | | |-SBO_DIAGS :: SBO diags. see pkg/sbo |
381 |
|
C/\ | | | |-GCHEM_DIAGS :: gchem diags. see pkg/gchem |
382 |
C/\ | | | |
C/\ | | | |
383 |
C/\ | | |-WRITE_CHECKPOINT :: Do I/O for restart files. |
C/\ | | |-WRITE_CHECKPOINT :: Do I/O for restart files. |
384 |
C/\ | | |
C/\ | | |
402 |
CEOI |
CEOI |
403 |
|
|
404 |
|
|
405 |
|
#include "AD_CONFIG.h" |
406 |
|
#include "PACKAGES_CONFIG.h" |
407 |
#include "CPP_OPTIONS.h" |
#include "CPP_OPTIONS.h" |
408 |
|
|
409 |
CBOP |
CBOP |
495 |
logical exst |
logical exst |
496 |
logical lastdiva |
logical lastdiva |
497 |
CEOP |
CEOP |
498 |
|
c-- set default: |
499 |
|
lastdiva = .TRUE. |
500 |
|
|
501 |
|
#ifndef DISABLE_DEBUGMODE |
502 |
|
IF (debugMode) CALL DEBUG_ENTER('THE_MODEL_MAIN',myThid) |
503 |
|
#endif |
504 |
|
|
505 |
C-- This timer encompasses the whole code |
C-- This timer encompasses the whole code |
506 |
CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid) |
CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid) |
507 |
|
|
508 |
|
#ifndef DISABLE_DEBUGMODE |
509 |
|
IF (debugMode) CALL DEBUG_CALL('INITIALISE_FIXED',myThid) |
510 |
|
#endif |
511 |
|
|
512 |
C-- Set model configuration (fixed arrays) |
C-- Set model configuration (fixed arrays) |
513 |
CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid) |
514 |
CALL INITIALISE_FIXED( myThid ) |
CALL INITIALISE_FIXED( myThid ) |
517 |
myCurrentTime = startTime |
myCurrentTime = startTime |
518 |
myCurrentIter = nIter0 |
myCurrentIter = nIter0 |
519 |
|
|
520 |
#if ( defined (ALLOW_ADJOINT_RUN) || \ |
#if ( defined (ALLOW_ADMTLM_RUN) ) |
521 |
|
c |
522 |
|
CALL TIMER_START('ADMTLM_DRIVER [THE_MODEL_MAIN]',mythid) |
523 |
|
CALL ADMTLM_DRIVER ( myThid ) |
524 |
|
CALL TIMER_STOP ('ADMTLM_DRIVER [THE_MODEL_MAIN]',mythid) |
525 |
|
c |
526 |
|
#elif ( defined (ALLOW_ADJOINT_RUN) || \ |
527 |
defined (ALLOW_TANGENTLINEAR_RUN) || \ |
defined (ALLOW_TANGENTLINEAR_RUN) || \ |
528 |
defined (ALLOW_GRADIENT_CHECK) || \ |
defined (ALLOW_GRADIENT_CHECK) || \ |
529 |
defined (ALLOW_ECCO_OPTIMIZATION) ) |
defined (ALLOW_ECCO_OPTIMIZATION) ) |
543 |
CALL COST_DEPENDENT_INIT ( mythid ) |
CALL COST_DEPENDENT_INIT ( mythid ) |
544 |
_BARRIER |
_BARRIER |
545 |
|
|
546 |
#if ( defined (ALLOW_ADJOINT_RUN) || \ |
# if ( defined (ALLOW_TANGENTLINEAR_RUN) ) |
547 |
defined (ALLOW_ECCO_OPTIMIZATION) ) |
c |
548 |
# ifdef ALLOW_DIVIDED_ADJOINT |
CALL TIMER_START('G_THE_MAIN_LOOP [TANGENT RUN]',mythid) |
549 |
|
CALL G_THE_MAIN_LOOP ( myCurrentTime, myCurrentIter, myThid ) |
550 |
|
CALL TIMER_STOP ('G_THE_MAIN_LOOP [TANGENT RUN]',mythid) |
551 |
|
c |
552 |
|
# elif ( defined (ALLOW_ADJOINT_RUN) || \ |
553 |
|
defined (ALLOW_ECCO_OPTIMIZATION) ) |
554 |
|
c |
555 |
|
# ifdef ALLOW_DIVIDED_ADJOINT |
556 |
c-- The following assumes the TAF option '-pure' |
c-- The following assumes the TAF option '-pure' |
557 |
inquire( file='costfinal', exist=exst ) |
inquire( file='costfinal', exist=exst ) |
558 |
IF ( .NOT. exst) THEN |
IF ( .NOT. exst) THEN |
567 |
CALL COST_FINAL_RESTORE ( mythid, lastdiva ) |
CALL COST_FINAL_RESTORE ( mythid, lastdiva ) |
568 |
ENDIF |
ENDIF |
569 |
c-- |
c-- |
570 |
# else |
# else /* ALLOW_DIVIDED_ADJOINT undef */ |
571 |
CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
CALL TIMER_START('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
572 |
CALL ADTHE_MAIN_LOOP ( mythid ) |
CALL ADTHE_MAIN_LOOP ( mythid ) |
573 |
CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
CALL TIMER_STOP ('ADTHE_MAIN_LOOP [ADJOINT RUN]', mythid) |
574 |
|
# endif /* ALLOW_DIVIDED_ADJOINT */ |
575 |
|
c |
576 |
# endif |
# endif |
|
c-- |
|
|
#elif (defined (ALLOW_TANGENTLINEAR_RUN)) |
|
|
CALL TIMER_START('G_THE_MAIN_LOOP [TANGENT RUN]',mythid) |
|
|
CALL G_THE_MAIN_LOOP ( myCurrentTime, myCurrentIter, myThid ) |
|
|
CALL TIMER_STOP ('G_THE_MAIN_LOOP [TANGENT RUN]',mythid) |
|
|
#endif |
|
|
_BARRIER |
|
577 |
|
|
578 |
_BEGIN_MASTER( mythid ) |
_BEGIN_MASTER( mythid ) |
579 |
IF ( myProcId .eq. 0 .AND. lastdiva ) THEN |
IF ( myProcId .eq. 0 .AND. lastdiva ) THEN |
580 |
CALL TIMER_START('CTLR_PACK [THE_MODEL_MAIN]',mythid) |
CALL TIMER_START('CTRL_PACK [THE_MODEL_MAIN]',mythid) |
581 |
call CTRL_PACK( mycurrentiter, mycurrenttime, mythid ) |
call CTRL_PACK( mycurrentiter, mycurrenttime, mythid ) |
582 |
CALL TIMER_STOP ('CTLR_PACK [THE_MODEL_MAIN]',mythid) |
CALL TIMER_STOP ('CTRL_PACK [THE_MODEL_MAIN]',mythid) |
583 |
ENDIF |
ENDIF |
584 |
_END_MASTER( mythid ) |
_END_MASTER( mythid ) |
585 |
_BARRIER |
_BARRIER |
586 |
|
c |
587 |
|
|
588 |
#ifdef ALLOW_GRADIENT_CHECK |
# ifdef ALLOW_GRADIENT_CHECK |
589 |
IF ( useGrdchk .AND. lastdiva ) THEN |
IF ( useGrdchk .AND. lastdiva ) THEN |
590 |
CALL TIMER_START('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid) |
CALL TIMER_START('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid) |
591 |
CALL GRDCHK_MAIN( mythid ) |
CALL GRDCHK_MAIN( mythid ) |
592 |
CALL TIMER_STOP ('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid) |
CALL TIMER_STOP ('GRDCHK_MAIN [THE_MODEL_MAIN]',mythid) |
593 |
_BARRIER |
_BARRIER |
594 |
ENDIF |
ENDIF |
595 |
#endif |
# endif |
596 |
|
|
597 |
#else /* ALLOW_ADJOINT_RUN undef */ |
#else /* ALL AD-related undef */ |
598 |
|
|
599 |
|
#ifndef DISABLE_DEBUGMODE |
600 |
|
IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid) |
601 |
|
#endif |
602 |
|
|
603 |
C-- Call time stepping loop of full model |
C-- Call time stepping loop of full model |
604 |
CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
CALL TIMER_START('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
605 |
CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid ) |
CALL THE_MAIN_LOOP( myCurrentTime, myCurrentIter, myThid ) |
606 |
CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
CALL TIMER_STOP ('THE_MAIN_LOOP [THE_MODEL_MAIN]',myThid) |
607 |
|
|
608 |
#endif /* ALLOW_ADJOINT_RUN */ |
#endif /* ALLOW_TANGENTLINEAR_RUN ALLOW_ADJOINT_RUN ALLOW_ADMTLM_RUN */ |
609 |
|
|
610 |
C-- Sea-ice checkpoint (in case the in-loop checkpoint was missed) |
C-- Sea-ice checkpoint (in case the in-loop checkpoint was missed) |
611 |
#ifdef ALLOW_SEAICE |
#ifdef ALLOW_SEAICE |
628 |
CALL COMM_STATS |
CALL COMM_STATS |
629 |
ENDIF |
ENDIF |
630 |
|
|
631 |
|
#ifndef DISABLE_DEBUGMODE |
632 |
|
IF (debugMode) CALL DEBUG_LEAVE('THE_MODEL_MAIN',myThid) |
633 |
|
#endif |
634 |
|
|
635 |
RETURN |
RETURN |
636 |
END |
END |