File indexing completed on 2024-05-25 05:10:20 UTC
view on githubraw file Latest commit 00f81e67 on 2024-05-24 21:00:12 UTC
6d54cf9ca1 Ed H*0001 #include "PACKAGES_CONFIG.h"
2846da876f Alis*0002 #include "CPP_OPTIONS.h"
c10ffac493 Jean*0003 #ifdef ALLOW_AUTODIFF
0004 # include "AUTODIFF_OPTIONS.h"
0005 #endif
83df00bce7 Patr*0006 #ifdef ALLOW_GENERIC_ADVDIFF
0007 # include "GAD_OPTIONS.h"
0008 #endif
1dc3e353c5 Jean*0009 #ifdef ALLOW_GGL90
0010 # include "GGL90_OPTIONS.h"
0011 #endif
7ef85e240a Mart*0012 #ifdef ALLOW_GMREDI
0013 # include "GMREDI_OPTIONS.h"
0014 #endif
1dc3e353c5 Jean*0015 #ifdef ALLOW_OBCS
0016 # include "OBCS_OPTIONS.h"
58c557b4ea Patr*0017 #endif
1dc3e353c5 Jean*0018 #ifdef ALLOW_SEAICE
0019 # include "SEAICE_OPTIONS.h"
0020 #endif
0021 #ifdef ALLOW_GCHEM
0022 # include "GCHEM_OPTIONS.h"
0023 #endif
0024 #ifdef ALLOW_DIC
0025 # include "DIC_OPTIONS.h"
9a00d4fc17 Gael*0026 #endif
2b118f1270 Matt*0027 #ifdef ALLOW_BLING
0028 # include "BLING_OPTIONS.h"
0029 #endif
9a00d4fc17 Gael*0030 #ifdef ALLOW_EXF
0031 # include "EXF_OPTIONS.h"
0032 #endif
1dc3e353c5 Jean*0033 #ifdef ALLOW_STREAMICE
0034 # include "STREAMICE_OPTIONS.h"
0035 #endif
c10ffac493 Jean*0036 #ifdef ALLOW_COST
0037 # include "COST_OPTIONS.h"
0038 #endif
c1fca7389f Gael*0039 #ifdef ALLOW_CTRL
0040 # include "CTRL_OPTIONS.h"
0041 #endif
30c7aa4d63 Gael*0042 #ifdef ALLOW_ECCO
0043 # include "ECCO_OPTIONS.h"
0044 #endif
9cfac49d8b Gael*0045 #ifdef ALLOW_PROFILES
0046 # include "PROFILES_OPTIONS.h"
0047 #endif
2cfc9d59a2 Patr*0048
9366854e02 Chri*0049
0050
0051
b31265ed88 Jean*0052 SUBROUTINE THE_MAIN_LOOP( myTime, myIter, myThid )
9366854e02 Chri*0053
0054
0055
0056
0057
0058
0059
0060
88794ad36d Jean*0061
ded033bbc1 Patr*0062
9366854e02 Chri*0063
0064
0065
88794ad36d Jean*0066
0067
9366854e02 Chri*0068
0069
0070
0071
0072
0073 IMPLICIT NONE
0074
2846da876f Alis*0075 #include "SIZE.h"
0076 #include "EEPARAMS.h"
0077 #include "PARAMS.h"
39154404ca Patr*0078
0079
6528621149 Patr*0080 #ifdef ALLOW_AUTODIFF
c10ffac493 Jean*0081 # ifndef ALLOW_OPENAD
39154404ca Patr*0082
88794ad36d Jean*0083
0084
39154404ca Patr*0085
0086
7f4c5015d5 Patr*0087 # include "AUTODIFF_MYFIELDS.h"
71d68194c9 Patr*0088 # include "GRID.h"
0089 # include "DYNVARS.h"
bef5cbe0ec Patr*0090 # include "SURFACE.h"
71d68194c9 Patr*0091 # include "FFIELDS.h"
0092 # include "EOS.h"
bef5cbe0ec Patr*0093 # include "AUTODIFF.h"
5728d4a98b Patr*0094
c633f73536 Patr*0095 # ifdef ALLOW_GENERIC_ADVDIFF
0096 # include "GAD.h"
83df00bce7 Patr*0097 # include "GAD_SOM_VARS.h"
c633f73536 Patr*0098 # endif
0099 # ifdef ALLOW_MOM_FLUXFORM
0100 # include "MOM_FLUXFORM.h"
0101 # endif
71d68194c9 Patr*0102 # ifdef ALLOW_CD_CODE
0103 # include "CD_CODE_VARS.h"
0104 # endif
65b69c6b17 Patr*0105 # ifdef ALLOW_PTRACERS
71d68194c9 Patr*0106 # include "PTRACERS_SIZE.h"
85f77391e5 Jean*0107 # include "PTRACERS_FIELDS.h"
5463551803 Patr*0108 # include "PTRACERS_START.h"
65b69c6b17 Patr*0109 # endif
f09d2da379 Jean*0110 # ifdef ALLOW_GCHEM
1dc3e353c5 Jean*0111 # include "GCHEM_SIZE.h"
f09d2da379 Jean*0112 # include "GCHEM_FIELDS.h"
0113 # endif
0114 # ifdef ALLOW_CFC
0115 # include "CFC.h"
0116 # endif
0117 # ifdef ALLOW_DIC
0118 # include "DIC_VARS.h"
0119 # include "DIC_LOAD.h"
0120 # include "DIC_ATMOS.h"
0121 # include "DIC_CTRL.h"
0122 # include "DIC_COST.h"
0123 # endif
71d68194c9 Patr*0124 # ifdef ALLOW_OBCS
6f4cf52d27 Dimi*0125 # include "OBCS_PARAMS.h"
a9eb030de2 Jean*0126 # include "OBCS_FIELDS.h"
0127 # include "OBCS_SEAICE.h"
71d68194c9 Patr*0128 # ifdef ALLOW_PTRACERS
0129 # include "OBCS_PTRACERS.h"
0130 # endif
0131 # endif
0132 # ifdef ALLOW_EXF
0133 # ifdef ALLOW_BULKFORMULAE
0134 # include "EXF_CONSTANTS.h"
0135 # endif
67647493ca Jean*0136 # include "EXF_INTERP_SIZE.h"
0137 # include "EXF_FIELDS.h"
71d68194c9 Patr*0138 # endif /* ALLOW_EXF */
f7286c3b8b Matt*0139 # ifdef ALLOW_BLING
0140 # include "BLING_VARS.h"
0141 # include "BLING_LOAD.h"
0142 # endif
71d68194c9 Patr*0143 # ifdef ALLOW_SEAICE
ccaa3c61f4 Patr*0144 # include "SEAICE_SIZE.h"
71d68194c9 Patr*0145 # include "SEAICE.h"
8a37a22def Patr*0146 # include "SEAICE_PARAMS.h"
1e22f5fc71 Patr*0147 # include "SEAICE_COST.h"
13c01105ad Patr*0148 # include "SEAICE_TRACER.h"
71d68194c9 Patr*0149 # endif
56b3a0d0fa Patr*0150 # ifdef ALLOW_SALT_PLUME
0151 # include "SALT_PLUME.h"
0152 # endif
71d68194c9 Patr*0153 # ifdef ALLOW_THSICE
0154 # include "THSICE_SIZE.h"
0155 # include "THSICE_VARS.h"
2d30aeeef0 Patr*0156 # include "THSICE_COST.h"
71d68194c9 Patr*0157 # endif
3e86393e2c Patr*0158 # ifdef ALLOW_SHELFICE
0159 # include "SHELFICE.h"
0160 # include "SHELFICE_COST.h"
0161 # endif
58c557b4ea Patr*0162 # ifdef ALLOW_STREAMICE
0163 # include "STREAMICE.h"
0164 # include "STREAMICE_ADV.h"
0165 # include "STREAMICE_BDRY.h"
0166 # include "STREAMICE_CG.h"
0167 # endif
71d68194c9 Patr*0168 # ifdef ALLOW_EBM
0169 # include "EBM.h"
0170 # endif
0171 # ifdef ALLOW_RBCS
de7a0e15d8 Jean*0172 # include "RBCS_SIZE.h"
0173 # include "RBCS_FIELDS.h"
71d68194c9 Patr*0174 # endif
9683f9bbcc Patr*0175 # ifdef ALLOW_OFFLINE
0176 # include "OFFLINE.h"
0177 # endif
aecc8b0f47 Mart*0178 # if (defined ALLOW_CG2D_NSA || defined NONLIN_FRSURF || \
0179 defined ALLOW_DEPTH_CONTROL)
55d9234027 Patr*0180 # include "CG2D.h"
0181 # endif
22b72941c7 Jean*0182 # ifdef ALLOW_DIVIDED_ADJOINT
0183 # ifdef ALLOW_USE_MPI
0184 # include "mpif.h"
0185 # endif
71d68194c9 Patr*0186 # endif
0187
b4daa24319 Shre*0188
71d68194c9 Patr*0189 # include "tamc.h"
9a00d4fc17 Gael*0190
56a89d1ef6 Mart*0191 # ifdef ALLOW_GGL90
0192 # include "GGL90.h"
0193 # endif
0194 # ifdef ALLOW_PROFILES
0195 # include "PROFILES_SIZE.h"
0196 # include "profiles.h"
0197 # endif
0198 # ifdef ALLOW_ECCO
0199 # include "ecco_cost.h"
0200 # endif
0201
0202 # include "AUTODIFF_STORE.h"
c10ffac493 Jean*0203 # endif /* undef ALLOW_OPENAD */
39154404ca Patr*0204
0513668de6 Gael*0205 # ifdef ALLOW_CTRL
0206 # include "CTRL_SIZE.h"
4d72283393 Mart*0207 # include "CTRL.h"
edcd27be69 Mart*0208 # include "CTRL_DUMMY.h"
c1fca7389f Gael*0209 # include "CTRL_GENARR.h"
4948b10fac Gael*0210 # include "CTRL_OBCS.h"
0513668de6 Gael*0211 # endif
0212 # ifdef ALLOW_COST
0213 # include "cost.h"
0214 # endif
39154404ca Patr*0215
6528621149 Patr*0216 #endif /* ALLOW_AUTODIFF */
b4daa24319 Shre*0217
0218 #ifdef ALLOW_TAPENADE
0219 # ifdef ALLOW_GMREDI
0220 # include "GMREDI.h"
0221 # include "GMREDI_TAVE.h"
0222 # endif
0223 # ifdef ALLOW_KPP
0224 # include "KPP.h"
0225
0226 # endif
0227 # ifdef ALLOW_TIMEAVE
0228 # include "TIMEAVE_STATV.h"
0229 # endif
0230 # ifdef ALLOW_EXF
0231 # include "EXF_PARAM.h"
0232 # include "EXF_INTERP_PARAM.h"
0233 # endif
0234 # ifdef ALLOW_DOWN_SLOPE
0235 # include "DWNSLP_SIZE.h"
0236 # include "DWNSLP_VARS.h"
0237 # endif
0238 # ifdef ALLOW_PTRACERS
0239 # include "PTRACERS_PARAMS.h"
0240 # endif
0241 #endif /* ALLOW_TAPENADE */
0242
39154404ca Patr*0243
2cfc9d59a2 Patr*0244
9366854e02 Chri*0245
0246
22b72941c7 Jean*0247
0248
88794ad36d Jean*0249
0250
9366854e02 Chri*0251
8440e8ae5d Jean*0252
0253
0254
9366854e02 Chri*0255 _RL myTime
8440e8ae5d Jean*0256 INTEGER myIter
88794ad36d Jean*0257 INTEGER myThid
9366854e02 Chri*0258
1eeb28fe07 Alis*0259
0260
0261
9366854e02 Chri*0262
0263
e5d0e61ee8 Patr*0264 INTEGER iloop
d5885b3057 Jean*0265 #ifdef STORE_LOADEDREC_TEST
0266 INTEGER bi,bj
0267 #endif /* STORE_LOADEDREC_TEST */
cda1c18f72 Jean*0268 #ifdef ALLOW_AUTODIFF
0269 # ifdef ALLOW_TAMC_CHECKPOINTING
7c50f07931 Mart*0270 INTEGER ilev_1
20dee61641 Mart*0271 INTEGER ilev_2, max_lev2
cda1c18f72 Jean*0272 # ifndef AUTODIFF_2_LEVEL_CHECKPOINT
20dee61641 Mart*0273 INTEGER ilev_3, max_lev3
7c50f07931 Mart*0274 # endif
cda1c18f72 Jean*0275 # ifdef AUTODIFF_4_LEVEL_CHECKPOINT
20dee61641 Mart*0276 INTEGER ilev_4, max_lev4
cda1c18f72 Jean*0277 # endif
0278 # endif /* ALLOW_TAMC_CHECKPOINTING */
0279 #endif /* ALLOW_AUTODIFF */
9366854e02 Chri*0280
2846da876f Alis*0281
49e3578e36 Ed H*0282 #ifdef ALLOW_DEBUG
73ead277e0 Alis*0283 IF (debugMode) CALL DEBUG_ENTER('THE_MAIN_LOOP',myThid)
0284 #endif
0285
2cfc9d59a2 Patr*0286 #ifdef ALLOW_AUTODIFF_TAMC
0287
7855a13227 Mart*0288
0289
910e5c3e29 Mart*0290 # if ( defined ALLOW_AUTODIFF_WHTAPEIO &&
7855a13227 Mart*0291
31dc1201f0 Jean*0292 # else
7855a13227 Mart*0293
31dc1201f0 Jean*0294 # endif
7855a13227 Mart*0295
0296
51575f66de Mart*0297 # ifdef INCLUDE_CONVECT_INI_CALL
7855a13227 Mart*0298
910e5c3e29 Mart*0299 # if ( defined ALLOW_AUTODIFF_WHTAPEIO &&
20dee61641 Mart*0300
910e5c3e29 Mart*0301 # else
0302
0303 # endif
51575f66de Mart*0304 # endif
7448700841 Mart*0305 # ifdef ALLOW_GENTIM2D_CONTROL
7855a13227 Mart*0306
0307
e1de04fee5 Patr*0308 # endif
31dc1201f0 Jean*0309
7855a13227 Mart*0310
e1de04fee5 Patr*0311 # ifdef ALLOW_TAMC_CHECKPOINTING
0312 # if (defined (AUTODIFF_2_LEVEL_CHECKPOINT))
3b6c79e4de Mart*0313
0314
e1de04fee5 Patr*0315 # elif (defined (AUTODIFF_4_LEVEL_CHECKPOINT))
3b6c79e4de Mart*0316
0317
e1de04fee5 Patr*0318 # else
3b6c79e4de Mart*0319
0320
e1de04fee5 Patr*0321 # endif
ded033bbc1 Patr*0322 # endif
31dc1201f0 Jean*0323 #endif /* ALLOW_AUTODIFF_TAMC */
620589f74d Patr*0324
71d68194c9 Patr*0325 #ifdef ALLOW_AUTODIFF
51d88069bf Jean*0326 nIter0 = NINT( (startTime-baseTime)/deltaTClock )
0097108a55 Alis*0327 #endif
2846da876f Alis*0328
cdc9f269ae Patr*0329 #ifdef ALLOW_AUTODIFF_TAMC
7c50f07931 Mart*0330 ikey_dynamics = 1
910e5c3e29 Mart*0331 # if ( defined ALLOW_AUTODIFF_WHTAPEIO && defined ALLOW_DIVIDED_ADJOINT )
0332
0333 CALL AUTODIFF_WHTAPEIO_SYNC( 1 , 0, myThid )
0334 # endif
3bafcf6020 Timo*0335 # ifdef ALLOW_GENTIM2D_CONTROL
0336
0337 # endif
0338 # ifdef ALLOW_SHELFICE
c69ccc91fb antn*0339
7b8b86ab99 Timo*0340 # endif
3bafcf6020 Timo*0341 # ifdef ALLOW_STREAMICE
96b006450c dngo*0342
0343
0344
0345
0346
0347 # ifdef USE_ALT_RLOW
0348
0349 # endif
a78204c019 Mart*0350 # endif
11c3150c71 Mart*0351 # ifdef ALLOW_DIC
0352
0353
0354 # endif
cdc9f269ae Patr*0355 #endif
0356
c10ffac493 Jean*0357 #ifdef ALLOW_OPENAD
707ab205a2 Patr*0358 # ifdef ALLOW_GENARR2D_CONTROL
57b21c88e4 Patr*0359
fffd070878 Patr*0360
707ab205a2 Patr*0361 # endif
0362 # ifdef ALLOW_GENARR3D_CONTROL
57b21c88e4 Patr*0363
0364
707ab205a2 Patr*0365 # endif
81a1cb3057 Patr*0366 # ifdef ALLOW_GENTIM2D_CONTROL
57b21c88e4 Patr*0367
1a5e3fa960 Patr*0368
81a1cb3057 Patr*0369 # endif
c10ffac493 Jean*0370 #endif /* ALLOW_OPENAD */
71d68194c9 Patr*0371
49e3578e36 Ed H*0372 #ifdef ALLOW_DEBUG
73ead277e0 Alis*0373 IF (debugMode) CALL DEBUG_CALL('INITIALISE_VARIA',myThid)
0374 #endif
2846da876f Alis*0375
22b72941c7 Jean*0376 CALL TIMER_START('INITIALISE_VARIA [THE_MAIN_LOOP]', myThid)
0377 CALL INITIALISE_VARIA( myThid )
0378 CALL TIMER_STOP ('INITIALISE_VARIA [THE_MAIN_LOOP]', myThid)
2cfc9d59a2 Patr*0379
12dfc08227 Patr*0380 #ifdef ALLOW_SHOWFLOPS
22b72941c7 Jean*0381 CALL TIMER_START('SHOWFLOPS_INIT [THE_MAIN_LOOP]', myThid)
ded033bbc1 Patr*0382 CALL SHOWFLOPS_INIT( myThid )
22b72941c7 Jean*0383 CALL TIMER_STOP ('SHOWFLOPS_INIT [THE_MAIN_LOOP]', myThid)
008ba3ca0d Cons*0384 #endif
ce86d9b87b Cons*0385
2cfc9d59a2 Patr*0386
22b72941c7 Jean*0387 CALL TIMER_START('MAIN LOOP [THE_MAIN_LOOP]', myThid)
2cfc9d59a2 Patr*0388
0389
0390
0391
5586314dc5 Mart*0392 #ifdef USE_PDAF
0393
0394 CALL TIMER_START('INIT_PDAF [THE_MAIN_LOOP]', myThid)
0395 CALL INIT_PDAF( nIter0, myTime, myIter, myThid )
0396 CALL TIMER_STOP ('INIT_PDAF [THE_MAIN_LOOP]', myThid)
0397 #endif
0398
910e5c3e29 Mart*0399 #if ( defined ALLOW_AUTODIFF_WHTAPEIO && defined ALLOW_DIVIDED_ADJOINT )
0400
0401 CALL AUTODIFF_WHTAPEIO_SYNC( 1 , 1, myThid )
0402 #endif
0403
e5d0e61ee8 Patr*0404
c10ffac493 Jean*0405 #ifndef ALLOW_OPENAD
e5d0e61ee8 Patr*0406 # ifdef ALLOW_AUTODIFF
0407 # ifdef ALLOW_TAMC_CHECKPOINTING
0408
0409
20dee61641 Mart*0410 # ifdef AUTODIFF_4_LEVEL_CHECKPOINT
e5d0e61ee8 Patr*0411 max_lev4=nTimeSteps/(nchklev_1*nchklev_2*nchklev_3)+1
20dee61641 Mart*0412 # endif
0413 # ifndef AUTODIFF_2_LEVEL_CHECKPOINT
e5d0e61ee8 Patr*0414 max_lev3=nTimeSteps/(nchklev_1*nchklev_2)+1
20dee61641 Mart*0415 # endif
e5d0e61ee8 Patr*0416 max_lev2=nTimeSteps/nchklev_1+1
0417
0418
0419 # ifdef ALLOW_DIVIDED_ADJOINT
0420
0421 # endif
0422
0423
0424 # ifdef AUTODIFF_4_LEVEL_CHECKPOINT
0425 do ilev_4 = 1,nchklev_4
0426 if(ilev_4.le.max_lev4) then
0427
cda1c18f72 Jean*0428 # ifdef ALLOW_AUTODIFF_WHTAPEIO
22b72941c7 Jean*0429 CALL AUTODIFF_WHTAPEIO_SYNC( 4 , 0, myThid )
cda1c18f72 Jean*0430 # endif
e5d0e61ee8 Patr*0431 CALL AUTODIFF_STORE( myThid )
0432 #include "checkpoint_lev4_directives.h"
0433 CALL AUTODIFF_RESTORE( myThid )
cda1c18f72 Jean*0434 # ifdef ALLOW_AUTODIFF_WHTAPEIO
22b72941c7 Jean*0435 CALL AUTODIFF_WHTAPEIO_SYNC( 4 , 1, myThid )
cda1c18f72 Jean*0436 # endif
e5d0e61ee8 Patr*0437
0438
0439
3b6c79e4de Mart*0440
e5d0e61ee8 Patr*0441 # endif /* AUTODIFF_4_LEVEL_CHECKPOINT */
0442
0443 # ifndef AUTODIFF_2_LEVEL_CHECKPOINT
0444 do ilev_3 = 1,nchklev_3
0445 if(ilev_3.le.max_lev3) then
0446
cda1c18f72 Jean*0447 # ifdef ALLOW_AUTODIFF_WHTAPEIO
22b72941c7 Jean*0448 CALL AUTODIFF_WHTAPEIO_SYNC( 3 , 0, myThid )
cda1c18f72 Jean*0449 # endif
e5d0e61ee8 Patr*0450 CALL AUTODIFF_STORE( myThid )
0451 #include "checkpoint_lev3_directives.h"
0452 CALL AUTODIFF_RESTORE( myThid )
cda1c18f72 Jean*0453 # ifdef ALLOW_AUTODIFF_WHTAPEIO
22b72941c7 Jean*0454 CALL AUTODIFF_WHTAPEIO_SYNC( 3 , 1, myThid )
cda1c18f72 Jean*0455 # endif
e5d0e61ee8 Patr*0456
0457
0458
3b6c79e4de Mart*0459
e5d0e61ee8 Patr*0460 # endif /* AUTODIFF_2_LEVEL_CHECKPOINT */
0461
0462 do ilev_2 = 1,nchklev_2
0463 if(ilev_2.le.max_lev2) then
0464
cda1c18f72 Jean*0465 # ifdef ALLOW_AUTODIFF_WHTAPEIO
22b72941c7 Jean*0466 CALL AUTODIFF_WHTAPEIO_SYNC( 2 , 0, myThid )
cda1c18f72 Jean*0467 # endif
e5d0e61ee8 Patr*0468 CALL AUTODIFF_STORE( myThid )
0469 #include "checkpoint_lev2_directives.h"
0470 CALL AUTODIFF_RESTORE( myThid )
cda1c18f72 Jean*0471 # ifdef ALLOW_AUTODIFF_WHTAPEIO
22b72941c7 Jean*0472 CALL AUTODIFF_WHTAPEIO_SYNC( 2 , 1, myThid )
cda1c18f72 Jean*0473 # endif
e5d0e61ee8 Patr*0474
0475
cda1c18f72 Jean*0476 # endif /* ALLOW_TAMC_CHECKPOINTING */
e5d0e61ee8 Patr*0477
cda1c18f72 Jean*0478 # ifdef ALLOW_AUTODIFF_TAMC
e5d0e61ee8 Patr*0479
0480
0481
0482
0483
20dee61641 Mart*0484
0485
fe1862e69b Mart*0486 # ifdef ALLOW_BLING
0487
20dee61641 Mart*0488
fe1862e69b Mart*0489 # endif
e5d0e61ee8 Patr*0490
0491 # ifdef ALLOW_KPP
31dc1201f0 Jean*0492
0493
e5d0e61ee8 Patr*0494 # endif /* ALLOW_KPP */
0495
0496 # ifdef ALLOW_GMREDI
20dee61641 Mart*0497
5a6997640b Mart*0498
e5d0e61ee8 Patr*0499 # endif /* ALLOW_GMREDI */
0500
0501 # ifdef ALLOW_PTRACERS
0502
20dee61641 Mart*0503
e5d0e61ee8 Patr*0504
20dee61641 Mart*0505
e5d0e61ee8 Patr*0506 # endif /* ALLOW_PTRACERS */
0507
0508 # ifdef ALLOW_MOM_COMMON
0509 # ifndef AUTODIFF_DISABLE_LEITH
0510
20dee61641 Mart*0511
e5d0e61ee8 Patr*0512 # endif /* AUTODIFF_DISABLE_LEITH */
0513 # endif /* ALLOW_MOM_COMMON */
0514
9c41af81f6 Timo*0515 # if (defined ALLOW_EXF && defined ALLOW_BULKFORMULAE)
20dee61641 Mart*0516
0517
e5d0e61ee8 Patr*0518 # endif /* ALLOW_BULKFORMULAE */
0519
0520 # ifdef ALLOW_SEAICE
45315406aa Mart*0521 # ifdef SEAICE_CGRID
e5d0e61ee8 Patr*0522
5c9256813c Mart*0523 # ifdef SEAICE_LSR_ADJOINT_ITER
0524
0525
20dee61641 Mart*0526
5c9256813c Mart*0527 # else /* make the common blocks smaller to reduce memory footprint */
20dee61641 Mart*0528
0529
5c9256813c Mart*0530 # endif
7448700841 Mart*0531 # ifdef SEAICE_ALLOW_EVP
20dee61641 Mart*0532
0533
7448700841 Mart*0534 # endif
5c9256813c Mart*0535 # endif
dacfc8921c Mart*0536
20dee61641 Mart*0537
dacfc8921c Mart*0538
e5d0e61ee8 Patr*0539 # ifndef DISABLE_MULTIDIM_ADVECTION
0540
20dee61641 Mart*0541
e5d0e61ee8 Patr*0542
20dee61641 Mart*0543
e5d0e61ee8 Patr*0544 # endif /* DISABLE_MULTIDIM_ADVECTION */
cda1c18f72 Jean*0545 # endif /* ALLOW_SEAICE */
e5d0e61ee8 Patr*0546
0547 # ifdef ALLOW_THSICE
a85293d087 Mart*0548
0549
edb6656069 Mart*0550
20dee61641 Mart*0551
0552
edb6656069 Mart*0553
cda1c18f72 Jean*0554 # if (defined ALLOW_EXF && defined ALLOW_BULKFORMULAE)
edb6656069 Mart*0555
0556
0557
a85293d087 Mart*0558
edb6656069 Mart*0559
0560
0561
cda1c18f72 Jean*0562 # endif
e5d0e61ee8 Patr*0563 # endif /* ALLOW_THSICE */
0564
00f81e6785 Ou W*0565 # ifdef ALLOW_STEEP_ICECAVITY
0566
0567
0568 # endif
0569
e5d0e61ee8 Patr*0570 # ifdef ALLOW_STREAMICE
20dee61641 Mart*0571
e5d0e61ee8 Patr*0572
0573
31dc1201f0 Jean*0574
20dee61641 Mart*0575
e5d0e61ee8 Patr*0576 # endif
0577
0578 # ifdef ALLOW_CG2D_NSA
20dee61641 Mart*0579
0580
e5d0e61ee8 Patr*0581 # endif
cda1c18f72 Jean*0582 # endif /* ALLOW_AUTODIFF_TAMC */
e5d0e61ee8 Patr*0583
35c4fdc74b Emma*0584 # ifdef ALLOW_GENCOST_CONTRIBUTION
0585
0586 # endif
e5d0e61ee8 Patr*0587
0588
cda1c18f72 Jean*0589 # ifdef STORE_LOADEDREC_TEST
d5885b3057 Jean*0590 DO bj = myByLo(myThid), myByHi(myThid)
0591 DO bi = myBxLo(myThid), myBxHi(myThid)
0592 loadedRec(bi,bj) = 0
0593 ENDDO
0594 ENDDO
cda1c18f72 Jean*0595 # endif /* STORE_LOADEDREC_TEST */
d5885b3057 Jean*0596
cda1c18f72 Jean*0597 # if ( defined ALLOW_AUTODIFF_TAMC && defined ALLOW_OFFLINE )
3c775cbf98 Mart*0598
0599
0600
0601
0602
cda1c18f72 Jean*0603 # ifndef AUTODIFF_USE_STORE_RESTORE
3c775cbf98 Mart*0604
cda1c18f72 Jean*0605 # endif
0606 # endif
0607 # ifdef ALLOW_TAMC_CHECKPOINTING
e5d0e61ee8 Patr*0608
0609 do ilev_1 = 1,nchklev_1
0610
0611
0612
0613
0614 iloop = (ilev_2 - 1)*nchklev_1 + ilev_1
cda1c18f72 Jean*0615 # ifndef AUTODIFF_2_LEVEL_CHECKPOINT
e5d0e61ee8 Patr*0616 & + (ilev_3 - 1)*nchklev_2*nchklev_1
cda1c18f72 Jean*0617 # endif
0618 # ifdef AUTODIFF_4_LEVEL_CHECKPOINT
e5d0e61ee8 Patr*0619 & + (ilev_4 - 1)*nchklev_3*nchklev_2*nchklev_1
cda1c18f72 Jean*0620 # endif
e5d0e61ee8 Patr*0621
0622 if ( iloop .le. nTimeSteps ) then
0623
0624 # else /* ALLOW_TAMC_CHECKPOINTING undefined */
0625
0626 DO iloop = 1, nTimeSteps
0627
0628
0629 # endif /* ALLOW_TAMC_CHECKPOINTING */
0630 # endif /* ALLOW_AUTODIFF */
c10ffac493 Jean*0631 #endif /* undef ALLOW_OPENAD */
e5d0e61ee8 Patr*0632
0633
0634 #ifndef ALLOW_AUTODIFF
0635 DO iloop = 1, nTimeSteps
0636 #endif /* ALLOW_AUTODIFF */
0637
0638
0639
c10ffac493 Jean*0640 #ifdef ALLOW_AUTODIFF
e5d0e61ee8 Patr*0641 nIter0 = NINT( (startTime-baseTime)/deltaTClock )
0642
0643 myIter = nIter0 + (iloop-1)
7c3b863339 Jean*0644 myTime = startTime + deltaTClock*(iloop-1)
7c50f07931 Mart*0645 # ifdef ALLOW_AUTODIFF_TAMC
20dee61641 Mart*0646 # ifdef ALLOW_TAMC_CHECKPOINTING
e5d0e61ee8 Patr*0647 ikey_dynamics = ilev_1
20dee61641 Mart*0648 # else
0649 ikey_dynamics = iloop
0650 # endif
e5d0e61ee8 Patr*0651 # endif
20dee61641 Mart*0652 #endif /* ALLOW_AUTODIFF */
e5d0e61ee8 Patr*0653
ac03b700cb Gael*0654 #ifdef ALLOW_ECCO
a424c359ed Gael*0655 IF ( useECCO ) then
e5d0e61ee8 Patr*0656 # ifdef ALLOW_DEBUG
a424c359ed Gael*0657 IF (debugMode) CALL DEBUG_CALL('cost_averagesfields',myThid)
e5d0e61ee8 Patr*0658 # endif
0659
a424c359ed Gael*0660 CALL TIMER_START('COST_AVERAGESFIELDS [MAIN_DO_LOOP]',myThid)
0661 CALL COST_AVERAGESFIELDS( myTime, myThid )
0662 CALL TIMER_STOP ('COST_AVERAGESFIELDS [MAIN_DO_LOOP]',myThid)
0663 ENDIF
ac03b700cb Gael*0664 #endif /* ALLOW_ECCO */
e5d0e61ee8 Patr*0665
0666 #ifdef ALLOW_PROFILES
0667 IF (usePROFILES) THEN
0668 #ifdef ALLOW_DEBUG
0669 IF (debugMode) CALL DEBUG_CALL('profiles_inloop',myThid)
0670 #endif
0671
0672 #ifdef ALLOW_AUTODIFF
0673
0674 myIter = nIter0 + (iloop-1)
7c3b863339 Jean*0675 myTime = startTime + deltaTClock*(iloop-1)
e5d0e61ee8 Patr*0676 #endif
22b72941c7 Jean*0677 CALL TIMER_START('PROFILES_INLOOP [MAIN_DO_LOOP]', myThid)
0678 CALL PROFILES_INLOOP( myTime, myThid )
0679 CALL TIMER_STOP ('PROFILES_INLOOP [MAIN_DO_LOOP]', myThid)
e5d0e61ee8 Patr*0680 ENDIF
0681 #endif
0682
22b72941c7 Jean*0683 CALL TIMER_START('MAIN_DO_LOOP [THE_MAIN_LOOP]', myThid)
e5d0e61ee8 Patr*0684 CALL MAIN_DO_LOOP( iloop, myTime, myIter, myThid )
22b72941c7 Jean*0685 CALL TIMER_STOP ('MAIN_DO_LOOP [THE_MAIN_LOOP]', myThid)
2cfc9d59a2 Patr*0686
5586314dc5 Mart*0687 #ifdef USE_PDAF
0688
0689 CALL TIMER_START('ASSIMILATE_PDAF [THE_MAIN_LOOP]', myThid)
0690 CALL ASSIMILATE_PDAF( myTime, myIter, myThid )
0691 CALL TIMER_STOP ('ASSIMILATE_PDAF [THE_MAIN_LOOP]', myThid)
0692 #endif
0693
e5d0e61ee8 Patr*0694
c10ffac493 Jean*0695 #ifndef ALLOW_OPENAD
e5d0e61ee8 Patr*0696 # ifdef ALLOW_AUTODIFF
0697 # ifdef ALLOW_TAMC_CHECKPOINTING
0698 endif
0699 enddo
0700 endif
0701 enddo
0702 # ifndef AUTODIFF_2_LEVEL_CHECKPOINT
0703 endif
0704 enddo
0705 # endif
0706 # ifdef AUTODIFF_4_LEVEL_CHECKPOINT
0707 endif
0708 enddo
0709 # endif
0710 # else /* ndef ALLOW_TAMC_CHECKPOINTING */
0711 ENDDO
0712 # endif /* ALLOW_TAMC_CHECKPOINTING */
0713 # else /* ALLOW_AUTODIFF */
0714 ENDDO
0715 # endif /* ALLOW_AUTODIFF */
c10ffac493 Jean*0716 #endif /* undef ALLOW_OPENAD */
e5d0e61ee8 Patr*0717
01070dbc48 Patr*0718
0719
2cfc9d59a2 Patr*0720
19f2597004 Gael*0721 #ifdef ALLOW_ECCO
345f7357c1 Gael*0722
22b72941c7 Jean*0723 CALL TIMER_START('COST_AVERAGESFIELDS [THE_MAIN_LOOP]',myThid)
0724 CALL COST_AVERAGESFIELDS( endtime, myThid )
0725 CALL TIMER_STOP ('COST_AVERAGESFIELDS [THE_MAIN_LOOP]',myThid)
19f2597004 Gael*0726 #endif /* ALLOW_ECCO */
345f7357c1 Gael*0727
24462d2fa8 Patr*0728 #ifdef ALLOW_PROFILES
e994210c2e Gael*0729 IF (usePROFILES) THEN
ded033bbc1 Patr*0730
22b72941c7 Jean*0731 CALL TIMER_START('PROFILES_INLOOP [THE_MAIN_LOOP]', myThid)
0732 CALL PROFILES_INLOOP( endtime, myThid )
0733 CALL TIMER_STOP ('PROFILES_INLOOP [THE_MAIN_LOOP]', myThid)
f29c9a8cb9 Gael*0734
7c3b863339 Jean*0735 CALL COST_PROFILES( myIter, myTime, myThid )
e994210c2e Gael*0736 ENDIF
24462d2fa8 Patr*0737 #endif
0738
19f2597004 Gael*0739 #ifdef ALLOW_ECCO
a424c359ed Gael*0740 IF ( useECCO ) then
345f7357c1 Gael*0741
a424c359ed Gael*0742 CALL TIMER_START('ECCO_COST_DRIVER [THE_MAIN_LOOP]', myThid)
0743 CALL ECCO_COST_DRIVER ( endTime, myIter, myThid )
0744 CALL TIMER_STOP ('ECCO_COST_DRIVER [THE_MAIN_LOOP]', myThid)
0745 ENDIF
19f2597004 Gael*0746 #endif /* ALLOW_ECCO */
345f7357c1 Gael*0747
ad9b3080a0 Patr*0748 #ifdef ALLOW_COST
0749
22b72941c7 Jean*0750 CALL TIMER_START('COST_FINAL [ADJOINT SPIN-DOWN]', myThid)
0751 CALL COST_FINAL ( myThid )
0752 CALL TIMER_STOP ('COST_FINAL [ADJOINT SPIN-DOWN]', myThid)
ad9b3080a0 Patr*0753
c10ffac493 Jean*0754 # ifdef ALLOW_OPENAD
ded033bbc1 Patr*0755
c10ffac493 Jean*0756 # endif /* ALLOW_OPENAD */
71d68194c9 Patr*0757
0758 #endif /* ALLOW_COST */
ded033bbc1 Patr*0759
16367ff26d Mart*0760 #ifdef USE_PDAF
0761
0762 CALL FINALIZE_PDAF( )
0763 #endif
0764
2cfc9d59a2 Patr*0765 _BARRIER
22b72941c7 Jean*0766 CALL TIMER_STOP ('MAIN LOOP [THE_MAIN_LOOP]', myThid)
2cfc9d59a2 Patr*0767
49e3578e36 Ed H*0768 #ifdef ALLOW_DEBUG
73ead277e0 Alis*0769 IF (debugMode) CALL DEBUG_LEAVE('THE_MAIN_LOOP',myThid)
0770 #endif
0771
8440e8ae5d Jean*0772 RETURN
0097108a55 Alis*0773 END