Back to home page

MITgcm

 
 

    


File indexing completed on 2024-06-06 05:10:14 UTC

view on githubraw file Latest commit af61e5eb on 2024-06-06 03:30:35 UTC
6d54cf9ca1 Ed H*0001 #include "PACKAGES_CONFIG.h"
d8ea337c6c Patr*0002 #include "CPP_OPTIONS.h"
6d54cf9ca1 Ed H*0003 
517dbdc414 Jean*0004 #ifdef ALLOW_AUTODIFF
                0005 # include "AUTODIFF_OPTIONS.h"
                0006 #endif
83df00bce7 Patr*0007 #ifdef ALLOW_GENERIC_ADVDIFF
                0008 # include "GAD_OPTIONS.h"
                0009 #endif
685f7544b6 Patr*0010 #ifdef ALLOW_GGL90
                0011 # include "GGL90_OPTIONS.h"
                0012 #endif
9b184aa726 Patr*0013 #ifdef ALLOW_GMREDI
                0014 # include "GMREDI_OPTIONS.h"
                0015 #endif
65b69c6b17 Patr*0016 #ifdef ALLOW_OBCS
                0017 # include "OBCS_OPTIONS.h"
                0018 #endif
a7828ed4d5 Patr*0019 #ifdef ALLOW_THSICE
                0020 # include "THSICE_OPTIONS.h"
                0021 #endif
9b45bc1f6c Patr*0022 #ifdef ALLOW_SEAICE
                0023 # include "SEAICE_OPTIONS.h"
                0024 #endif
544a4ff6e0 Patr*0025 #ifdef ALLOW_PTRACERS
                0026 # include "PTRACERS_OPTIONS.h"
                0027 #endif
1dc3e353c5 Jean*0028 #ifdef ALLOW_GCHEM
                0029 # include "GCHEM_OPTIONS.h"
                0030 #endif
                0031 #ifdef ALLOW_DIC
                0032 # include "DIC_OPTIONS.h"
                0033 #endif
4e5fc818bf Matt*0034 #ifdef ALLOW_BLING
                0035 # include "BLING_OPTIONS.h"
                0036 #endif
9a00d4fc17 Gael*0037 #ifdef ALLOW_EXF
                0038 # include "EXF_OPTIONS.h"
                0039 #endif
376d4a0160 Patr*0040 #ifdef ALLOW_STREAMICE
                0041 # include "STREAMICE_OPTIONS.h"
                0042 #endif
9952f046d7 dngo*0043 #ifdef ALLOW_SHELFICE
                0044 # include "SHELFICE_OPTIONS.h"
                0045 #endif
517dbdc414 Jean*0046 #ifdef ALLOW_COST
                0047 # include "COST_OPTIONS.h"
                0048 #endif
c1fca7389f Gael*0049 #ifdef ALLOW_CTRL
                0050 # include "CTRL_OPTIONS.h"
                0051 #endif
30c7aa4d63 Gael*0052 #ifdef ALLOW_ECCO
                0053 # include "ECCO_OPTIONS.h"
                0054 #endif
d8ea337c6c Patr*0055 
9e647b4f24 Jean*0056 #define ALLOW_MOM_STEPPING
                0057 #if ( defined (ALLOW_AUTODIFF) && defined (ALLOW_OFFLINE) )
                0058 # undef ALLOW_MOM_STEPPING
                0059 #endif
                0060 
9366854e02 Chri*0061 CBOP
                0062 C     !ROUTINE: FORWARD_STEP
                0063 C     !INTERFACE:
b7d016da10 Alis*0064       SUBROUTINE FORWARD_STEP( iloop, myTime, myIter, myThid )
d8ea337c6c Patr*0065 
9366854e02 Chri*0066 C     !DESCRIPTION: \bv
adcc4b1a0c Jean*0067 C     *=================================================================
9366854e02 Chri*0068 C     | SUBROUTINE forward_step
adcc4b1a0c Jean*0069 C     | o Step forward in time the model variables for one time-step
                0070 C     *=================================================================
                0071 C     | The algorithm...
9366854e02 Chri*0072 C     |
adcc4b1a0c Jean*0073 C     | "Calculation of Gs"
                0074 C     | ===================
                0075 C     | This is where all the accelerations and tendencies (ie.
                0076 C     | physics, parameterizations etc...) are calculated
                0077 C     |   rho = rho ( theta[n], salt[n] )
                0078 C     |   b   = b(rho, theta)
                0079 C     |   K31 = K31 ( rho )
                0080 C     |   Gu[n] = Gu( u[n], v[n], wVel, b, ... )
                0081 C     |   Gv[n] = Gv( u[n], v[n], wVel, b, ... )
                0082 C     |   Gt[n] = Gt( theta[n], u[n], v[n], wVel, K31, ... )
                0083 C     |   Gs[n] = Gs( salt[n], u[n], v[n], wVel, K31, ... )
9366854e02 Chri*0084 C     |
adcc4b1a0c Jean*0085 C     | "Time-stepping" or "Prediction"
                0086 C     | ================================
                0087 C     | The models variables are stepped forward with the appropriate
                0088 C     | time-stepping scheme (currently we use Adams-Bashforth II)
                0089 C     | - For momentum, the result is always *only* a "prediction"
                0090 C     | in that the flow may be divergent and will be "corrected"
                0091 C     | later with a surface pressure gradient.
                0092 C     | - Normally for tracers the result is the new field at time
                0093 C     | level [n+1} *BUT* in the case of implicit diffusion the result
                0094 C     | is also *only* a prediction.
                0095 C     | - We denote "predictors" with an asterisk (*).
                0096 C     |   U* = U[n] + dt x ( 3/2 Gu[n] - 1/2 Gu[n-1] )
                0097 C     |   V* = V[n] + dt x ( 3/2 Gv[n] - 1/2 Gv[n-1] )
                0098 C     |   theta[n+1] = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
                0099 C     |   salt[n+1]  = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
                0100 C     | With implicit diffusion:
                0101 C     |   theta* = theta[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
                0102 C     |   salt*  = salt[n] + dt x ( 3/2 Gt[n] - 1/2 atG[n-1] )
                0103 C     |   (1 + dt * K * d_zz) theta[n+1] = theta*
                0104 C     |   (1 + dt * K * d_zz) salt[n+1]  = salt*
                0105 C     |
                0106 C     | "Correction Step"
                0107 C     | =================
                0108 C     | Here we update the horizontal velocities with the surface
                0109 C     | pressure such that the resulting flow is either consistent
                0110 C     | with the free-surface evolution or the rigid-lid:
                0111 C     |   U[n] = U* + dt x d/dx P
                0112 C     |   V[n] = V* + dt x d/dy P
                0113 C     |   W[n] = W* + dt x d/dz P  (NH mode)
                0114 C     *=================================================================
9366854e02 Chri*0115 C     \ev
d8ea337c6c Patr*0116 
8f92343d9b Jean*0117 C     !CALLING SEQUENCE:
                0118 C     FORWARD_STEP
                0119 C       |
                0120 C       |-- AUTODIFF_INADMODE_UNSET
                0121 C       |
9952f046d7 dngo*0122 C       |-- SHELFICE_REMESHING
                0123 C       |
8f92343d9b Jean*0124 C       |-- RESET_NLFS_VARS
                0125 C       |-- UPDATE_R_STAR
                0126 C       |-- UPDATE_SURF_DR
                0127 C       |
                0128 C       |-- PTRACERS_SWITCH_ONOFF
                0129 C       |
                0130 C       |-- DIAGNOSTICS_SWITCH_ONOFF
                0131 C       |-- DO_STATEVARS_DIAGS
                0132 C       |
                0133 C       |-- NEST_CHILD_SETMEMO
                0134 C       |-- NEST_PARENT_IO_1
                0135 C       |
                0136 C       |-- LOAD_FIELDS_DRIVER
                0137 C       |
                0138 C       |-- BULKF_FORCING
                0139 C       |
                0140 C       |-- CHEAPAML
                0141 C       |
                0142 C       |-- CTRL_MAP_FORCING
                0143 C       |-- DUMMY_IN_STEPPING
                0144 C       |
f533a5790a Jean*0145 C       |-- CPL_EXPORT_IMPORT_DATA
8f92343d9b Jean*0146 C       |
                0147 C       |-- OASIS_PUT
                0148 C       |-- OASIS_GET
                0149 C       |
                0150 C       |-- EBM_DRIVER
                0151 C       |
                0152 C       |-- DO_ATMOSPHERIC_PHYS
                0153 C       |
                0154 C       |-- DO_OCEANIC_PHYS
                0155 C       |
9400d89b34 Dani*0156 C       |-- STREAMICE_TIMESTEP
8f92343d9b Jean*0157 C       |
                0158 C       |-- GCHEM_CALC_TENDENCY
                0159 C       |
                0160 C       |-- LONGSTEP_AVERAGE
                0161 C       |-- LONGSTEP_THERMODYNAMICS
                0162 C       |
                0163 C       |-- THERMODYNAMICS
                0164 C       |
                0165 C       |-- LONGSTEP_AVERAGE
6a828494d3 Jean*0166 C       |-- LONGSTEP_THERMODYNAMICS
8f92343d9b Jean*0167 C       |
                0168 C       |-- DO_STAGGER_FIELDS_EXCHANGES
                0169 C       |
                0170 C       |-- DYNAMICS
                0171 C       |
                0172 C       |-- MNC_UPDATE_TIME
                0173 C       |
dc2ebbdaf0 Jean*0174 C       |-- OFFLINE_FIELDS_LOAD
                0175 C       |
8f92343d9b Jean*0176 C       |-- UPDATE_R_STAR
                0177 C       |-- UPDATE_SIGMA
                0178 C       |-- UPDATE_SURF_DR
                0179 C       |-- UPDATE_CG2D
                0180 C       |
                0181 C       |-- SHAP_FILT_APPLY_UV
                0182 C       |-- ZONAL_FILT_APPLY_UV
                0183 C       |
                0184 C       |-- SOLVE_FOR_PRESSURE
                0185 C       |
                0186 C       |-- MOMENTUM_CORRECTION_STEP
                0187 C       |
                0188 C       |-- INTEGR_CONTINUITY
                0189 C       |
                0190 C       |-- CALC_R_STAR
                0191 C       |-- CALC_SURF_DR
                0192 C       |
                0193 C       |-- DO_STAGGER_FIELDS_EXCHANGES
                0194 C       |
                0195 C       |-- DO_STATEVARS_DIAGS
                0196 C       |
                0197 C       |-- THERMODYNAMICS
                0198 C       |
                0199 C       |-- TRACERS_CORRECTION_STEP
                0200 C       |
                0201 C       |-- LONGSTEP_AVERAGE
                0202 C       |-- LONGSTEP_THERMODYNAMICS
                0203 C       |
                0204 C       |-- GCHEM_FORCING_SEP
                0205 C       |
                0206 C       |-- DO_FIELDS_BLOCKING_EXCHANGES
                0207 C       |
                0208 C       |-- DO_STATEVARS_DIAGS
                0209 C       |
                0210 C       |-- GRIDALT_UPDATE
                0211 C       |-- STEP_FIZHI_CORR
                0212 C       |
                0213 C       |-- FLT_MAIN
                0214 C       |
                0215 C       |-- DO_STATEVARS_TAVE
                0216 C       |
                0217 C       |-- NEST_PARENT_IO_2
                0218 C       |-- NEST_CHILD_TRANSP
                0219 C       |
                0220 C       |-- MONITOR
                0221 C       |
                0222 C       |-- COST_TILE
                0223 C       |
                0224 C       |-- DO_THE_MODEL_IO
                0225 C       |
                0226 C       |-- PTRACERS_RESET
                0227 C       |
                0228 C       |-- DO_WRITE_PICKUP
                0229 C       |
                0230 C       |-- AUTODIFF_INADMODE_SET
                0231 C       |
                0232 C       |-- SHOWFLOPS_INLOOP
                0233 
9366854e02 Chri*0234 C     !USES:
                0235       IMPLICIT NONE
                0236 C     == Global variables ==
d8ea337c6c Patr*0237 #include "SIZE.h"
                0238 #include "EEPARAMS.h"
                0239 #include "PARAMS.h"
                0240 #include "DYNVARS.h"
                0241 
b81731e160 Ed H*0242 #ifdef HAVE_SIGREG
                0243 #include "SIGREG.h"
                0244 #endif
                0245 
b649ac9bae Jean*0246 #ifdef ALLOW_SHAP_FILT
47738741e7 Jean*0247 # include "SHAP_FILT.h"
b649ac9bae Jean*0248 #endif
                0249 #ifdef ALLOW_ZONAL_FILT
47738741e7 Jean*0250 # include "ZONAL_FILT.h"
b649ac9bae Jean*0251 #endif
                0252 
4e66ab0b67 Oliv*0253 #ifdef ALLOW_LONGSTEP
                0254 # include "LONGSTEP_PARAMS.h"
                0255 # include "LONGSTEP.h"
                0256 #endif
                0257 
517dbdc414 Jean*0258 #ifdef ALLOW_AUTODIFF
7f4c5015d5 Patr*0259 # include "AUTODIFF_MYFIELDS.h"
47738741e7 Jean*0260 # include "FFIELDS.h"
bef5cbe0ec Patr*0261 # include "SURFACE.h"
47738741e7 Jean*0262 
7c50f07931 Mart*0263 # ifdef ALLOW_AUTODIFF_TAMC
                0264 #  include "tamc.h"
                0265 # endif
0513668de6 Gael*0266 # ifdef ALLOW_CTRL
                0267 #  include "CTRL_SIZE.h"
4d72283393 Mart*0268 #  include "CTRL.h"
edcd27be69 Mart*0269 #  include "CTRL_DUMMY.h"
c1fca7389f Gael*0270 #  include "CTRL_GENARR.h"
4948b10fac Gael*0271 #  include "CTRL_OBCS.h"
0513668de6 Gael*0272 # endif
                0273 # ifdef ALLOW_COST
                0274 #  include "cost.h"
                0275 # endif
345f7357c1 Gael*0276 # ifdef ALLOW_ECCO
                0277 #  include "ecco_cost.h"
                0278 # endif
7103bd8015 Patr*0279 # include "EOS.h"
616600b8d2 Patr*0280 # if (defined NONLIN_FRSURF) || (defined ALLOW_DEPTH_CONTROL)
cdc9f269ae Patr*0281 #  include "GRID.h"
                0282 # endif
685f7544b6 Patr*0283 # ifdef ALLOW_GMREDI
                0284 #  include "GMREDI.h"
                0285 # endif
95c7d150a4 Ed H*0286 # ifdef ALLOW_EXF
33c873885d Jean*0287 #  ifdef ALLOW_BULKFORMULAE
798a745844 Jean*0288 #   include "EXF_CONSTANTS.h"
de416ebcde Patr*0289 #  endif
67647493ca Jean*0290 #  include "EXF_INTERP_SIZE.h"
                0291 #  include "EXF_FIELDS.h"
de416ebcde Patr*0292 # endif
685f7544b6 Patr*0293 # ifdef ALLOW_CD_CODE
                0294 #  include "CD_CODE_VARS.h"
                0295 # endif
                0296 # ifdef ALLOW_GENERIC_ADVDIFF
                0297 #  include "GAD.h"
                0298 #  include "GAD_SOM_VARS.h"
                0299 # endif
                0300 # ifdef ALLOW_GGL90
                0301 #  include "GGL90.h"
                0302 # endif
cf2549e769 Patr*0303 # ifdef ALLOW_PTRACERS
636477d15b Jean*0304 #  include "PTRACERS_SIZE.h"
85f77391e5 Jean*0305 #  include "PTRACERS_FIELDS.h"
cf2549e769 Patr*0306 # endif
529eea311c Gael*0307 # ifdef ALLOW_GCHEM
1dc3e353c5 Jean*0308 #  include "GCHEM_SIZE.h"
529eea311c Gael*0309 #  include "GCHEM_FIELDS.h"
                0310 # endif
                0311 # ifdef ALLOW_CFC
                0312 #  include "CFC.h"
                0313 # endif
                0314 # ifdef ALLOW_DIC
                0315 #  include "DIC_VARS.h"
                0316 #  include "DIC_LOAD.h"
                0317 #  include "DIC_ATMOS.h"
fc62302ca1 Patr*0318 #  include "DIC_COST.h"
529eea311c Gael*0319 # endif
f09d2da379 Jean*0320 # ifdef ALLOW_BLING
                0321 #  include "BLING_VARS.h"
                0322 #  include "BLING_LOAD.h"
                0323 # endif
65b69c6b17 Patr*0324 # ifdef ALLOW_OBCS
6f4cf52d27 Dimi*0325 #  include "OBCS_PARAMS.h"
a9eb030de2 Jean*0326 #  include "OBCS_FIELDS.h"
                0327 #  include "OBCS_SEAICE.h"
65b69c6b17 Patr*0328 #  ifdef ALLOW_PTRACERS
                0329 #   include "OBCS_PTRACERS.h"
                0330 #  endif
                0331 # endif
c567874792 Patr*0332 # ifdef ALLOW_THSICE
a7828ed4d5 Patr*0333 #  include "THSICE_PARAMS.h"
                0334 #  include "THSICE_SIZE.h"
c567874792 Patr*0335 #  include "THSICE_VARS.h"
a7828ed4d5 Patr*0336 #  include "THSICE_COST.h"
c567874792 Patr*0337 # endif
9b45bc1f6c Patr*0338 # ifdef ALLOW_SEAICE
a2c8840cf9 Jean*0339 #  include "SEAICE_SIZE.h"
9b45bc1f6c Patr*0340 #  include "SEAICE.h"
34ea64e027 Patr*0341 #  include "SEAICE_COST.h"
9b45bc1f6c Patr*0342 # endif
56b3a0d0fa Patr*0343 # ifdef ALLOW_SALT_PLUME
                0344 #  include "SALT_PLUME.h"
                0345 # endif
9c41af81f6 Timo*0346 # ifdef ALLOW_DOWN_SLOPE
                0347 #  include "DWNSLP_SIZE.h"
                0348 #  include "DWNSLP_VARS.h"
                0349 # endif
3e86393e2c Patr*0350 # ifdef ALLOW_SHELFICE
                0351 #  include "SHELFICE.h"
                0352 #  include "SHELFICE_COST.h"
                0353 # endif
376d4a0160 Patr*0354 # ifdef ALLOW_STREAMICE
                0355 #  include "STREAMICE.h"
                0356 #  include "STREAMICE_ADV.h"
                0357 #  include "STREAMICE_BDRY.h"
                0358 #  include "STREAMICE_CG.h"
                0359 # endif
d8206d87ee Patr*0360 # ifdef ALLOW_EBM
                0361 #  include "EBM.h"
                0362 # endif
9b184aa726 Patr*0363 # ifdef ALLOW_KPP
                0364 #  include "KPP.h"
                0365 # endif
cc747f5a7a Patr*0366 # ifdef ALLOW_RBCS
de7a0e15d8 Jean*0367 #  include "RBCS_SIZE.h"
                0368 #  include "RBCS_FIELDS.h"
cc747f5a7a Patr*0369 # endif
9683f9bbcc Patr*0370 # ifdef ALLOW_OFFLINE
                0371 #  include "OFFLINE.h"
                0372 # endif
aecc8b0f47 Mart*0373 # if (defined ALLOW_CG2D_NSA || defined NONLIN_FRSURF || \
                0374       defined ALLOW_DEPTH_CONTROL)
55d9234027 Patr*0375 #  include "CG2D.h"
                0376 # endif
517dbdc414 Jean*0377 #endif /* ALLOW_AUTODIFF */
d8ea337c6c Patr*0378 
b4daa24319 Shre*0379 #ifdef ALLOW_TAPENADE
                0380 c# ifdef ALLOW_KPP
                0381 c#  include "KPP_PARAMS.h"
                0382 c# endif
                0383 # ifdef ALLOW_GMREDI
                0384 #  include "GMREDI_TAVE.h"
                0385 # endif
                0386 # ifdef ALLOW_TIMEAVE
                0387 #  include "TIMEAVE_STATV.h"
                0388 # endif
                0389 # ifdef ALLOW_MOM_FLUXFORM
                0390 #  include "MOM_FLUXFORM.h"
                0391 # endif
                0392 # ifdef ALLOW_EXF
                0393 #  include "EXF_PARAM.h"
                0394 #  include "EXF_INTERP_PARAM.h"
                0395 # endif
                0396 #endif /* ALLOW_TAPENADE */
                0397 
455a90837c Jean*0398 C     !INPUT/OUTPUT PARAMETERS:
9366854e02 Chri*0399 C     == Routine arguments ==
529408dc72 Jean*0400 C     note: under the multi-threaded model myIter and
                0401 C           myTime are local variables passed around as routine
                0402 C           arguments. Although this is fiddly it saves the need to
                0403 C           impose additional synchronisation points when they are
b7d016da10 Alis*0404 C           updated.
455a90837c Jean*0405 C     myTime :: time counter for this thread
                0406 C     myIter :: iteration counter for this thread
                0407 C     myThid :: thread number for this instance of the routine.
9fcf571bcd Jean*0408       INTEGER iloop
                0409       _RL     myTime
455a90837c Jean*0410       INTEGER myIter
                0411       INTEGER myThid
9fcf571bcd Jean*0412 
455a90837c Jean*0413 C     !LOCAL VARIABLES:
9fcf571bcd Jean*0414 C     == Local variables ==
455a90837c Jean*0415 C     modelEnd  :: true if reaching the end of the run
4e66ab0b67 Oliv*0416 C     myTimeBeg :: time at beginning of time step (needed by longstep)
                0417 C     myIterBeg :: iteration number at beginning of time step
455a90837c Jean*0418       LOGICAL modelEnd
ea669e205e Jean*0419 #ifdef ALLOW_LONGSTEP
fda3710353 Oliv*0420       INTEGER myIterBeg
                0421       _RL myTimeBeg
ea669e205e Jean*0422 #endif /* ALLOW_LONGSTEP */
9366854e02 Chri*0423 CEOP
d8ea337c6c Patr*0424 
49e3578e36 Ed H*0425 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0426       IF (debugMode) CALL DEBUG_ENTER('FORWARD_STEP',myThid)
73ead277e0 Alis*0427 #endif
                0428 
517dbdc414 Jean*0429 #ifdef ALLOW_AUTODIFF
cee16b76ae Dimi*0430 C--   Reset the model iteration counter and the model time.
51d88069bf Jean*0431       myIter = nIter0 + (iloop-1)
7c3b863339 Jean*0432       myTime = startTime + deltaTClock*(iLoop-1)
d8ea337c6c Patr*0433 #endif
                0434 
a10c595eb6 Timo*0435 #ifdef ALLOW_AUTODIFF
                0436       CALL AUTODIFF_INADMODE_UNSET( myTime, myIter, myThid )
                0437 #endif
                0438 
ea669e205e Jean*0439 #ifdef ALLOW_LONGSTEP
4e66ab0b67 Oliv*0440 C     store this for longstep_average with staggerTimeStep
fda3710353 Oliv*0441 C     which is called after myIter and myTime are incremented
                0442 C     but needs iter/time at beginning of time step
4e66ab0b67 Oliv*0443       myIterBeg = myIter
                0444       myTimeBeg = myTime
ea669e205e Jean*0445 #endif /* ALLOW_LONGSTEP */
4e66ab0b67 Oliv*0446 
32117771cc Patr*0447 #ifdef ALLOW_AUTODIFF_TAMC
                0448 c**************************************
                0449 #include "checkpoint_lev1_directives.h"
32af943b8a Patr*0450 #include "checkpoint_lev1_template.h"
32117771cc Patr*0451 c**************************************
67a1e439d8 Patr*0452 #endif
6424ee9bc0 Curt*0453 
9952f046d7 dngo*0454 #ifdef ALLOW_SHELFICE_REMESHING
                0455       IF ( useShelfIce ) THEN
                0456 C--   Remesh shelfice
                0457         CALL TIMER_START('SHELFICE_REMESHING     [FORWARD_STEP]',myThid)
                0458         CALL SHELFICE_REMESHING ( myTime, myIter, myThid )
                0459         CALL TIMER_STOP('SHELFICE_REMESHING     [FORWARD_STEP]',myThid)
                0460       ENDIF
                0461 #endif /* ALLOW_SHELFICE_REMESHING */
                0462 
0bcf1b56f4 Jean*0463 C--   Reset geometric factors (hFacC,W,S & recip_hFac) to their current values:
                0464 C     added to simplify adjoint derivation - no effect in forward run
72a058b866 Gael*0465 #ifdef NONLIN_FRSURF
517dbdc414 Jean*0466 #ifndef ALLOW_AUTODIFF
0bcf1b56f4 Jean*0467       IF ( doResetHFactors ) THEN
                0468 #endif
ccbf39d1a4 Jean*0469        CALL RESET_NLFS_VARS( myTime, myIter, myThid )
72a058b866 Gael*0470        IF ( select_rStar.GT.0 ) THEN
                0471 # ifndef DISABLE_RSTAR_CODE
                0472 # ifdef ALLOW_AUTODIFF_TAMC
35d3d94e31 Jean*0473 CADJ STORE rStarFacC, rStarFacS, rStarFacW =
ced23bb277 Gael*0474 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
72a058b866 Gael*0475 # endif
                0476         CALL TIMER_START('UPDATE_R_STAR       [FORWARD_STEP]',myThid)
                0477         CALL UPDATE_R_STAR( .FALSE., myTime, myIter, myThid )
                0478         CALL TIMER_STOP ('UPDATE_R_STAR       [FORWARD_STEP]',myThid)
                0479 # endif /* DISABLE_RSTAR_CODE */
                0480        ELSE
                0481 #ifdef ALLOW_AUTODIFF_TAMC
                0482 CADJ STORE hFac_surfC, hFac_surfS, hFac_surfW
ced23bb277 Gael*0483 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
72a058b866 Gael*0484 #endif
                0485         CALL TIMER_START('UPDATE_SURF_DR      [FORWARD_STEP]',myThid)
                0486         CALL UPDATE_SURF_DR( .FALSE., myTime, myIter, myThid )
                0487         CALL TIMER_STOP ('UPDATE_SURF_DR      [FORWARD_STEP]',myThid)
                0488        ENDIF
0bcf1b56f4 Jean*0489 #ifdef ALLOW_AUTODIFF_TAMC
ced23bb277 Gael*0490 CADJ STORE hFacC, hFacS, hFacW =
                0491 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
                0492 CADJ STORE recip_hFacC, recip_hFacS, recip_hFacW  =
                0493 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
45ae106d3b Jean*0494 #endif
                0495 #ifndef ALLOW_AUTODIFF
0bcf1b56f4 Jean*0496       ENDIF
                0497 #endif
72a058b866 Gael*0498 #endif /* NONLIN_FRSURF */
                0499 
7bfcf7940f Jean*0500 #ifdef ALLOW_PTRACERS
                0501 C--   Switch on/off individual tracer time-stepping
                0502       IF ( usePTRACERS ) THEN
                0503         CALL PTRACERS_SWITCH_ONOFF( myTime, myIter, myThid )
                0504       ENDIF
                0505 #endif /* ALLOW_PTRACERS */
                0506 
be7aceba73 Jean*0507 C--   Switch on/off diagnostics for snap-shot output:
                0508 #ifdef ALLOW_DIAGNOSTICS
                0509       IF ( useDiagnostics ) THEN
41c4545f8f Jean*0510         CALL DIAGNOSTICS_SWITCH_ONOFF( 1, myTime, myIter, myThid )
b5c2f2589c Jean*0511 C--   State-variables diagnostics
                0512         CALL TIMER_START('DO_STATEVARS_DIAGS  [FORWARD_STEP]',myThid)
                0513         CALL DO_STATEVARS_DIAGS( myTime, 0, myIter, myThid )
                0514         CALL TIMER_STOP ('DO_STATEVARS_DIAGS  [FORWARD_STEP]',myThid)
                0515       ENDIF
7bfcf7940f Jean*0516 #endif /* ALLOW_DIAGNOSTICS */
b5c2f2589c Jean*0517 
ba9a45d563 Jean*0518 #ifdef ALLOW_NEST_CHILD
                0519       IF ( useNEST_CHILD) THEN
8440e8ae5d Jean*0520         CALL NEST_CHILD_SETMEMO( myTime, myIter, myThid )
ba9a45d563 Jean*0521       ENDIF
                0522 #endif /* ALLOW_NEST_CHILD */
                0523 
                0524 #ifdef ALLOW_NEST_PARENT
                0525       IF ( useNEST_PARENT) THEN
                0526         CALL NEST_PARENT_IO_1( myTime, myIter, myThid )
                0527       ENDIF
                0528 #endif /* ALLOW_NEST_PARENT */
                0529 
529408dc72 Jean*0530 C--   Call driver to load external forcing fields from file
                0531 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0532       IF (debugMode) CALL DEBUG_CALL('LOAD_FIELDS_DRIVER',myThid)
529408dc72 Jean*0533 #endif
13783cb644 Patr*0534 #ifdef ALLOW_AUTODIFF_TAMC
                0535 cph Important STORE that avoids hidden recomp. of load_fields_driver
8a7ca847ff Patr*0536 CADJ STORE theta      = comlev1, key = ikey_dynamics,
                0537 CADJ &     kind = isbyte
35d3d94e31 Jean*0538 CADJ STORE uVel, vVel = comlev1, key = ikey_dynamics,
8a7ca847ff Patr*0539 CADJ &     kind = isbyte
13783cb644 Patr*0540 #endif
529408dc72 Jean*0541       CALL TIMER_START('LOAD_FIELDS_DRIVER  [FORWARD_STEP]',myThid)
                0542       CALL LOAD_FIELDS_DRIVER( myTime, myIter, myThid )
                0543       CALL TIMER_STOP ('LOAD_FIELDS_DRIVER  [FORWARD_STEP]',myThid)
                0544 
40ad671a6b Jean*0545 C--   Call Bulk-Formulae forcing package
7753507405 Curt*0546 #ifdef ALLOW_BULK_FORCE
10e4bbdd7f Jean*0547       IF ( useBulkForce ) THEN
49e3578e36 Ed H*0548 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0549         IF (debugMode) CALL DEBUG_CALL('BULKF_FORCING',myThid)
73ead277e0 Alis*0550 #endif
529408dc72 Jean*0551         CALL TIMER_START('BULKF_FORCING       [FORWARD_STEP]',myThid)
10e4bbdd7f Jean*0552 C-    calculate qnet and empmr (and wind stress)
529408dc72 Jean*0553         CALL BULKF_FORCING( myTime, myIter, myThid )
                0554         CALL TIMER_STOP ('BULKF_FORCING       [FORWARD_STEP]',myThid)
40ad671a6b Jean*0555       ENDIF
b2498468b3 Jean*0556 #endif /* ALLOW_BULK_FORCE */
33c873885d Jean*0557 
86f14fa6df Jean*0558 C--   Call external chepaml forcing package
                0559 #ifdef ALLOW_CHEAPAML
                0560       IF ( useCheapAML  ) THEN
                0561 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0562         IF (debugMode) CALL DEBUG_CALL('CHEAPAML',myThid)
86f14fa6df Jean*0563 #endif
9e647b4f24 Jean*0564         CALL TIMER_START('CHEAPAML      [FORWARD_STEP]',myThid)
86f14fa6df Jean*0565 C-    calculate qnet (and wind stress)
8440e8ae5d Jean*0566         CALL CHEAPAML( myTime, myIter,myThid )
9e647b4f24 Jean*0567         CALL TIMER_STOP ('CHEAPAML      [FORWARD_STEP]',myThid)
86f14fa6df Jean*0568       ENDIF
                0569 #endif /*ALLOW_CHEAPAML */
                0570 
a424c359ed Gael*0571 #ifdef ALLOW_CTRL
35d3d94e31 Jean*0572 C--   Add control vector for forcing and parameter fields
25c5ed8154 Gael*0573       IF ( useCTRL ) THEN
                0574        CALL TIMER_START('CTRL_MAP_FORCING  [FORWARD_STEP]',myThid)
                0575        CALL CTRL_MAP_FORCING( myTime, myIter, myThid )
                0576        CALL TIMER_STOP ('CTRL_MAP_FORCING  [FORWARD_STEP]',myThid)
                0577       ENDIF
448ff6251a Patr*0578 #endif
6424ee9bc0 Curt*0579 
517dbdc414 Jean*0580 #ifdef ALLOW_AUTODIFF_MONITOR
8f0b59c61c Patr*0581       CALL DUMMY_IN_STEPPING( myTime, myIter, myThid )
176ce185cd Step*0582 #endif
                0583 
c1b6df074d Jean*0584 #ifdef COMPONENT_MODULE
904dd2a012 Jean*0585       IF ( useCoupler ) THEN
c1b6df074d Jean*0586 C      Post coupling data that I export.
                0587 C      Read in coupling data that I import.
                0588          CALL TIMER_START('CPL_EXPORT-IMPORT  [FORWARD_STEP]',myThid)
f533a5790a Jean*0589          CALL CPL_EXPORT_IMPORT_DATA( myTime, myIter, myThid )
c1b6df074d Jean*0590          CALL TIMER_STOP ('CPL_EXPORT-IMPORT  [FORWARD_STEP]',myThid)
529408dc72 Jean*0591       ENDIF
c1b6df074d Jean*0592 #endif /* COMPONENT_MODULE */
696c4221e9 Mart*0593 #ifdef ALLOW_OASIS
                0594       IF ( useOASIS ) THEN
                0595        CALL TIMER_START('OASIS_PUT-GET  [FORWARD_STEP]',myThid)
                0596 C      Post coupling data that I export.
                0597        CALL OASIS_PUT( myTime, myIter, myThid )
                0598 C      Read in coupling data that I import.
                0599        CALL OASIS_GET( myTime, myIter, myThid )
                0600        CALL TIMER_STOP ('OASIS_PUT-GET  [FORWARD_STEP]',myThid)
                0601       ENDIF
                0602 #endif /* ALLOW_OASIS */
                0603 
d8206d87ee Patr*0604 #ifdef ALLOW_EBM
529408dc72 Jean*0605       IF ( useEBM ) THEN
d8206d87ee Patr*0606 # ifdef ALLOW_DEBUG
8440e8ae5d Jean*0607         IF (debugMode) CALL DEBUG_CALL('EBM',myThid)
d8206d87ee Patr*0608 # endif
8440e8ae5d Jean*0609         CALL TIMER_START('EBM                [FORWARD_STEP]',myThid)
                0610         CALL EBM_DRIVER ( myTime, myIter, myThid )
                0611         CALL TIMER_STOP ('EBM                [FORWARD_STEP]',myThid)
529408dc72 Jean*0612       ENDIF
                0613 #endif /* ALLOW_EBM */
d8206d87ee Patr*0614 
9c41af81f6 Timo*0615 #ifdef ALLOW_AUTODIFF_TAMC
                0616 C******************************************************
                0617 C     Store surface forcing fields if required to avoid
                0618 C     calling load_fields_driver in forward_step_ad
                0619 # include "check_lev1_dir_forcing.h"
                0620 C******************************************************
                0621 #endif /* ALLOW_AUTODIFF_TAMC */
                0622 
c8e3a3b543 Jean*0623 C--     Step forward fields and calculate time tendency terms.
                0624 
                0625 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0626       IF (debugMode) CALL DEBUG_CALL('DO_ATMOSPHERIC_PHYS',myThid)
c8e3a3b543 Jean*0627 #endif
529408dc72 Jean*0628       CALL TIMER_START('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',myThid)
                0629       CALL DO_ATMOSPHERIC_PHYS( myTime, myIter, myThid )
                0630       CALL TIMER_STOP ('DO_ATMOSPHERIC_PHYS [FORWARD_STEP]',myThid)
c8e3a3b543 Jean*0631 
9b184aa726 Patr*0632 #ifdef ALLOW_AUTODIFF_TAMC
                0633 # ifdef ALLOW_KPP
aecc8b0f47 Mart*0634 CADJ STORE uVel, vVel = comlev1, key = ikey_dynamics, kind = isbyte
38b71af82a Patr*0635 # endif /* ALLOW_KPP */
544a4ff6e0 Patr*0636 # ifdef EXACT_CONSERV
aecc8b0f47 Mart*0637 CADJ STORE EmPmR      = comlev1, key = ikey_dynamics, kind = isbyte
                0638 CADJ STORE PmEpR      = comlev1, key = ikey_dynamics, kind = isbyte
544a4ff6e0 Patr*0639 # endif
b919404dfb Patr*0640 # ifdef ALLOW_OBCS
aecc8b0f47 Mart*0641 CADJ STORE salt       = comlev1, key = ikey_dynamics, kind = isbyte
                0642 CADJ STORE totphihyd  = comlev1, key = ikey_dynamics, kind = isbyte
38b71af82a Patr*0643 # endif /* ALLOW_OBCS */
49a23c9cb2 Patr*0644 # ifdef ALLOW_PTRACERS
aecc8b0f47 Mart*0645 CADJ STORE pTracer    = comlev1, key = ikey_dynamics, kind = isbyte
38b71af82a Patr*0646 # endif /* ALLOW_PTRACERS */
0bcf1b56f4 Jean*0647 # ifdef ALLOW_DEPTH_CONTROL
aecc8b0f47 Mart*0648 CADJ STORE hFacC      = comlev1, key = ikey_dynamics, kind = isbyte
cdc9f269ae Patr*0649 # endif
9b184aa726 Patr*0650 #endif /* ALLOW_AUTODIFF_TAMC */
                0651 
49e3578e36 Ed H*0652 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0653        IF (debugMode) CALL DEBUG_CALL('DO_OCEANIC_PHYS',myThid)
1d71c648ad Jean*0654 #endif
529408dc72 Jean*0655        CALL TIMER_START('DO_OCEANIC_PHYS     [FORWARD_STEP]',myThid)
615c650f5e Jean*0656        CALL DO_OCEANIC_PHYS( myTime, myIter, myThid )
529408dc72 Jean*0657        CALL TIMER_STOP ('DO_OCEANIC_PHYS     [FORWARD_STEP]',myThid)
376d4a0160 Patr*0658 
9e647b4f24 Jean*0659 #ifdef ALLOW_STREAMICE
5fb2fbfa94 Jean*0660        IF (useStreamIce) THEN
                0661          CALL STREAMICE_TIMESTEP ( myThid, myIter,
                0662      &                             iLoop, myTime )
                0663        ENDIF
376d4a0160 Patr*0664 #endif
                0665 
a1ee12c555 Patr*0666 #ifdef ALLOW_AUTODIFF_TAMC
9c41af81f6 Timo*0667 C***********************************************************************
                0668 C     This block of store directives is for variables that have been
                0669 C     computed in do_oceanics_phys. Storing them here avoids calling
                0670 C     do_oceanic_phys again in forward_step_ad, which should improve
                0671 C     performance because expensive parts of the model are not
                0672 C     recomputed (e.g. seaice).
                0673 # include "check_lev1_dir_ocephys.h"
                0674 C***********************************************************************
0499e7ef48 Patr*0675 #endif /* ALLOW_AUTODIFF_TAMC */
91bac1c842 Andr*0676 
9c41af81f6 Timo*0677 #ifdef GCHEM_ADD2TR_TENDENCY
                0678 #ifndef ALLOW_AUTODIFF
35d3d94e31 Jean*0679       IF ( useGCHEM ) THEN
9c41af81f6 Timo*0680 #endif
529eea311c Gael*0681 #ifdef ALLOW_AUTODIFF_TAMC
9c41af81f6 Timo*0682 CADJ STORE pTracer     = comlev1, key=ikey_dynamics, kind=isbyte
                0683 CADJ STORE theta, salt = comlev1, key=ikey_dynamics, kind=isbyte
529eea311c Gael*0684 #endif
6153ee95d4 Mart*0685 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0686         IF (debugMode) CALL DEBUG_CALL('GCHEM_CALC_TENDENCY',myThid)
6153ee95d4 Mart*0687 #endif
                0688         CALL TIMER_START('GCHEM_CALC_TENDENCY [FORWARD_STEP]',myThid)
                0689         CALL GCHEM_CALC_TENDENCY( myTime, myIter, myThid )
                0690         CALL TIMER_STOP ('GCHEM_CALC_TENDENCY [FORWARD_STEP]',myThid)
9b184aa726 Patr*0691 #ifdef ALLOW_AUTODIFF_TAMC
9c41af81f6 Timo*0692 CADJ STORE gchemTendency = comlev1, key=ikey_dynamics, kind=isbyte
                0693 #endif
                0694 #ifndef ALLOW_AUTODIFF
                0695       ENDIF
                0696 #endif
                0697 #endif /* GCHEM_ADD2TR_TENDENCY */
9b184aa726 Patr*0698 
4e66ab0b67 Oliv*0699 #ifdef ALLOW_LONGSTEP
9e647b4f24 Jean*0700       IF ( usePTRACERS .AND. LS_whenToSample .EQ. 0 ) THEN
4e66ab0b67 Oliv*0701 C       Average all variables before advection (but after do_oceanic_phys
                0702 C       where Qsw, KPP and GMRedi stuff is computed).
                0703 C       This is like diagnostics package and will reproduce offline
                0704 C       results.
                0705 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0706         IF (debugMode) CALL DEBUG_CALL('LONGSTEP_AVERAGE',myThid)
4e66ab0b67 Oliv*0707 #endif
                0708         CALL TIMER_START('LONGSTEP_AVERAGE    [FORWARD_STEP]',myThid)
                0709         CALL LONGSTEP_AVERAGE( myTime, myIter, myThid )
                0710         CALL TIMER_STOP ('LONGSTEP_AVERAGE    [FORWARD_STEP]',myThid)
fda3710353 Oliv*0711 
                0712 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0713         IF (debugMode)
fda3710353 Oliv*0714      &    CALL DEBUG_CALL('LONGSTEP_THERMODYNAMICS',myThid)
                0715 #endif
                0716         CALL TIMER_START('LONGSTEP_THERMODYNAMICS      [FORWARD_STEP]',
                0717      &                   myThid)
                0718         CALL LONGSTEP_THERMODYNAMICS( myTime, myIter, myThid )
                0719         CALL TIMER_STOP ('LONGSTEP_THERMODYNAMICS      [FORWARD_STEP]',
                0720      &                    myThid)
4e66ab0b67 Oliv*0721       ENDIF
                0722 #endif /* ALLOW_LONGSTEP */
                0723 
615c650f5e Jean*0724       IF ( .NOT.staggerTimeStep ) THEN
35d3d94e31 Jean*0725 #ifdef ALLOW_AUTODIFF_TAMC
                0726 CADJ STORE wVel = comlev1, key = ikey_dynamics, kind = isbyte
                0727 #endif
49e3578e36 Ed H*0728 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0729         IF (debugMode) CALL DEBUG_CALL('THERMODYNAMICS',myThid)
73ead277e0 Alis*0730 #endif
529408dc72 Jean*0731         CALL TIMER_START('THERMODYNAMICS      [FORWARD_STEP]',myThid)
615c650f5e Jean*0732         CALL THERMODYNAMICS( myTime, myIter, myThid )
529408dc72 Jean*0733         CALL TIMER_STOP ('THERMODYNAMICS      [FORWARD_STEP]',myThid)
fda3710353 Oliv*0734 C--     if not staggerTimeStep: end
b649ac9bae Jean*0735       ENDIF
9c41af81f6 Timo*0736 #if (defined ALLOW_AUTODIFF_TAMC) && (defined ALLOW_OBCS)
                0737 CADJ STORE salt, theta = comlev1, key = ikey_dynamics, kind = isbyte
                0738 #endif /* ALLOW_AUTODIFF_TAMC && ALLOW_OBCS */
4e66ab0b67 Oliv*0739 
                0740 #ifdef ALLOW_LONGSTEP
9e647b4f24 Jean*0741       IF ( usePTRACERS .AND. LS_whenToSample .EQ. 1 ) THEN
fda3710353 Oliv*0742 C       Average T and S after thermodynamics, but U,V,W before dynamics.
                0743 C       This will reproduce online results with staggerTimeStep=.FALSE.
4e66ab0b67 Oliv*0744 C       for LS_nIter=1
                0745 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0746         IF (debugMode) CALL DEBUG_CALL('LONGSTEP_AVERAGE',myThid)
4e66ab0b67 Oliv*0747 #endif
                0748         CALL TIMER_START('LONGSTEP_AVERAGE    [FORWARD_STEP]',myThid)
                0749         CALL LONGSTEP_AVERAGE( myTime, myIter, myThid )
                0750         CALL TIMER_STOP ('LONGSTEP_AVERAGE    [FORWARD_STEP]',myThid)
fda3710353 Oliv*0751 
                0752 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0753         IF (debugMode)
fda3710353 Oliv*0754      &    CALL DEBUG_CALL('LONGSTEP_THERMODYNAMICS',myThid)
                0755 #endif
                0756         CALL TIMER_START('LONGSTEP_THERMODYNAMICS      [FORWARD_STEP]',
                0757      &                   myThid)
                0758         CALL LONGSTEP_THERMODYNAMICS( myTime, myIter, myThid )
                0759         CALL TIMER_STOP ('LONGSTEP_THERMODYNAMICS      [FORWARD_STEP]',
                0760      &                   myThid)
4e66ab0b67 Oliv*0761       ENDIF
                0762 #endif /* ALLOW_LONGSTEP */
                0763 
cb7fa97db9 Jean*0764 c #ifdef ALLOW_NONHYDROSTATIC
                0765       IF ( implicitIntGravWave ) THEN
                0766         CALL TIMER_START('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
                0767         CALL DO_STAGGER_FIELDS_EXCHANGES( myTime, myIter, myThid )
                0768         CALL TIMER_STOP ('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
                0769       ENDIF
                0770 c #endif
1d71c648ad Jean*0771 
0499e7ef48 Patr*0772 #ifdef ALLOW_AUTODIFF_TAMC
79fda098df Gael*0773 CADJ STORE etaN = comlev1, key = ikey_dynamics, kind = isbyte
bfdbc242ac Jean*0774 # ifdef ALLOW_DEPTH_CONTROL
ced23bb277 Gael*0775 CADJ STORE hFacC, hFacS, hFacW
                0776 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
                0777 CADJ STORE recip_hFacC, recip_hFacS, recip_hFacW
                0778 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
bfdbc242ac Jean*0779 # endif /* ALLOW_DEPTH_CONTROL */
                0780 #endif /* ALLOW_AUTODIFF_TAMC */
fc62302ca1 Patr*0781 
cee16b76ae Dimi*0782 C--   Step forward fields and calculate time tendency terms.
9e647b4f24 Jean*0783 #ifdef ALLOW_MOM_STEPPING
517dbdc414 Jean*0784 #ifndef ALLOW_AUTODIFF
cee16b76ae Dimi*0785       IF ( momStepping ) THEN
edc3e287c7 Patr*0786 #endif
49e3578e36 Ed H*0787 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*0788         IF (debugMode) CALL DEBUG_CALL('DYNAMICS',myThid)
73ead277e0 Alis*0789 #endif
529408dc72 Jean*0790         CALL TIMER_START('DYNAMICS            [FORWARD_STEP]',myThid)
d8ea337c6c Patr*0791         CALL DYNAMICS( myTime, myIter, myThid )
529408dc72 Jean*0792         CALL TIMER_STOP ('DYNAMICS            [FORWARD_STEP]',myThid)
517dbdc414 Jean*0793 #ifndef ALLOW_AUTODIFF
cee16b76ae Dimi*0794       ENDIF
edc3e287c7 Patr*0795 #endif
9e647b4f24 Jean*0796 #endif /* ALLOW_MOM_STEPPING */
a27159adf7 Jean*0797 
0499e7ef48 Patr*0798 #ifdef ALLOW_AUTODIFF_TAMC
616600b8d2 Patr*0799 # if (defined NONLIN_FRSURF) || (defined ALLOW_DEPTH_CONTROL)
8a7ca847ff Patr*0800 CADJ STORE gU, gV  = comlev1, key = ikey_dynamics,
                0801 CADJ &     kind = isbyte
0499e7ef48 Patr*0802 # endif
f66c946416 Step*0803 #endif
d8ea337c6c Patr*0804 
615c650f5e Jean*0805 C--   Update time-counter
                0806       myIter = nIter0 + iLoop
7c3b863339 Jean*0807       myTime = startTime + deltaTClock*iLoop
615c650f5e Jean*0808 
5bc9611487 Ed H*0809 #ifdef ALLOW_MNC
ce8f1dd452 Jean*0810 C     Update MNC time information
5bc9611487 Ed H*0811       IF ( useMNC ) THEN
ce8f1dd452 Jean*0812          CALL MNC_UPDATE_TIME( myTime, myIter, myThid )
529408dc72 Jean*0813       ENDIF
                0814 #endif /* ALLOW_MNC */
5bc9611487 Ed H*0815 
dc2ebbdaf0 Jean*0816 #ifdef ALLOW_OFFLINE
                0817 C     Load new Offline fields and update state-variable
                0818       IF ( useOffLine ) THEN
                0819 #ifdef ALLOW_DEBUG
                0820         IF (debugMode) CALL DEBUG_CALL('OFFLINE_FIELDS_LOAD',myThid)
                0821 #endif /* ALLOW_DEBUG */
                0822         CALL TIMER_START('OFFLINE_FLDS_LOAD   [FORWARD_STEP]',myThid)
                0823         CALL OFFLINE_FIELDS_LOAD( myTime, myIter, myThid )
                0824         CALL TIMER_STOP ('OFFLINE_FLDS_LOAD   [FORWARD_STEP]',myThid)
                0825       ENDIF
                0826 #endif /* ALLOW_OFFLINE */
                0827 
615c650f5e Jean*0828 C--   Update geometric factors:
8de3419279 Jean*0829 #ifdef NONLIN_FRSURF
615c650f5e Jean*0830 C-    update hfacC,W,S and recip_hFac according to etaH(n+1) :
855d57fc61 Jean*0831       IF ( select_rStar.GT.0 ) THEN
cdc9f269ae Patr*0832 # ifndef DISABLE_RSTAR_CODE
0499e7ef48 Patr*0833 # ifdef ALLOW_AUTODIFF_TAMC
35d3d94e31 Jean*0834 CADJ STORE rStarFacC, rStarFacS, rStarFacW =
ced23bb277 Gael*0835 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
0499e7ef48 Patr*0836 # endif
529408dc72 Jean*0837         CALL TIMER_START('UPDATE_R_STAR       [FORWARD_STEP]',myThid)
72a058b866 Gael*0838         CALL UPDATE_R_STAR( .TRUE., myTime, myIter, myThid )
529408dc72 Jean*0839         CALL TIMER_STOP ('UPDATE_R_STAR       [FORWARD_STEP]',myThid)
cdc9f269ae Patr*0840 # endif /* DISABLE_RSTAR_CODE */
855d57fc61 Jean*0841       ELSEIF ( selectSigmaCoord.NE.0 ) THEN
a2a20dcddc Jean*0842 # ifndef DISABLE_SIGMA_CODE
                0843         CALL UPDATE_SIGMA( etaH, myTime, myIter, myThid )
                0844 # endif /* DISABLE_RSTAR_CODE */
855d57fc61 Jean*0845       ELSE
517dbdc414 Jean*0846 # ifdef ALLOW_AUTODIFF_TAMC
ba9a45d563 Jean*0847 CADJ STORE hFac_surfC, hFac_surfS, hFac_surfW
ced23bb277 Gael*0848 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
517dbdc414 Jean*0849 # endif
529408dc72 Jean*0850         CALL TIMER_START('UPDATE_SURF_DR      [FORWARD_STEP]',myThid)
72a058b866 Gael*0851         CALL UPDATE_SURF_DR( .TRUE., myTime, myIter, myThid )
529408dc72 Jean*0852         CALL TIMER_STOP ('UPDATE_SURF_DR      [FORWARD_STEP]',myThid)
855d57fc61 Jean*0853       ENDIF
0499e7ef48 Patr*0854 # ifdef ALLOW_AUTODIFF_TAMC
de7a0e15d8 Jean*0855 CADJ STORE hFacC, hFacS, hFacW =
ced23bb277 Gael*0856 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
de7a0e15d8 Jean*0857 CADJ STORE recip_hFacC, recip_hFacS, recip_hFacW  =
ced23bb277 Gael*0858 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
0499e7ef48 Patr*0859 # endif
855d57fc61 Jean*0860 #endif /* NONLIN_FRSURF */
                0861 
aecc8b0f47 Mart*0862 #if ( defined NONLIN_FRSURF || defined ALLOW_SOLVE4_PS_AND_DRAG || \
                0863       defined ALLOW_CG2D_NSA || defined ALLOW_DEPTH_CONTROL )
855d57fc61 Jean*0864 C-    update CG2D matrix (and preconditioner)
                0865       IF ( momStepping .AND.
                0866      &     ( nonlinFreeSurf.GT.2 .OR. selectImplicitDrag.EQ.2 ) ) THEN
529408dc72 Jean*0867         CALL TIMER_START('UPDATE_CG2D         [FORWARD_STEP]',myThid)
8de3419279 Jean*0868         CALL UPDATE_CG2D( myTime, myIter, myThid )
529408dc72 Jean*0869         CALL TIMER_STOP ('UPDATE_CG2D         [FORWARD_STEP]',myThid)
8de3419279 Jean*0870       ENDIF
aecc8b0f47 Mart*0871 # ifdef ALLOW_AUTODIFF_TAMC
                0872 CADJ STORE aW2d, aS2d, aC2d =
                0873 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
                0874 CADJ STORE pC, pS, pW =
                0875 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
                0876 # endif
855d57fc61 Jean*0877 #endif /* NONLIN_FRSURF or ALLOW_SOLVE4_PS_AND_DRAG */
8de3419279 Jean*0878 
b649ac9bae Jean*0879 C--   Apply Filters to u*,v* before SOLVE_FOR_PRESSURE
                0880 #ifdef ALLOW_SHAP_FILT
                0881       IF (useSHAP_FILT .AND. shap_filt_uvStar) THEN
f3ec658fc9 Jean*0882         CALL TIMER_START('SHAP_FILT_UV        [FORWARD_STEP]',myThid)
f09d2da379 Jean*0883         IF (implicDiv2DFlow.LT.1.) THEN
b649ac9bae Jean*0884 C--   Explicit+Implicit part of the Barotropic Flow Divergence
                0885 C      => Filtering of uVel,vVel is necessary
db44121e58 Jean*0886           CALL SHAP_FILT_APPLY_UV( uVel,vVel,
615c650f5e Jean*0887      &                             myTime, myIter, myThid )
b649ac9bae Jean*0888         ENDIF
615c650f5e Jean*0889         CALL SHAP_FILT_APPLY_UV( gU,gV,myTime,myIter,myThid)
f3ec658fc9 Jean*0890         CALL TIMER_STOP ('SHAP_FILT_UV        [FORWARD_STEP]',myThid)
b649ac9bae Jean*0891       ENDIF
                0892 #endif
                0893 #ifdef ALLOW_ZONAL_FILT
                0894       IF (useZONAL_FILT .AND. zonal_filt_uvStar) THEN
f3ec658fc9 Jean*0895         CALL TIMER_START('ZONAL_FILT_UV       [FORWARD_STEP]',myThid)
f09d2da379 Jean*0896         IF (implicDiv2DFlow.LT.1.) THEN
b649ac9bae Jean*0897 C--   Explicit+Implicit part of the Barotropic Flow Divergence
                0898 C      => Filtering of uVel,vVel is necessary
                0899           CALL ZONAL_FILT_APPLY_UV( uVel, vVel, myThid )
                0900         ENDIF
db44121e58 Jean*0901         CALL ZONAL_FILT_APPLY_UV( gU, gV, myThid )
f3ec658fc9 Jean*0902         CALL TIMER_STOP ('ZONAL_FILT_UV       [FORWARD_STEP]',myThid)
b649ac9bae Jean*0903       ENDIF
a27159adf7 Jean*0904 #endif
b7d016da10 Alis*0905 
d8ea337c6c Patr*0906 C--   Solve elliptic equation(s).
529408dc72 Jean*0907 C     Two-dimensional only for conventional hydrostatic or
d8ea337c6c Patr*0908 C     three-dimensional for non-hydrostatic and/or IGW scheme.
85937bd52b Alis*0909       IF ( momStepping ) THEN
d6e8c9ce95 Patr*0910 #ifdef ALLOW_AUTODIFF_TAMC
616600b8d2 Patr*0911 # if (defined NONLIN_FRSURF) || (defined ALLOW_DEPTH_CONTROL)
35d3d94e31 Jean*0912 CADJ STORE uVel, vVel
ced23bb277 Gael*0913 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
35d3d94e31 Jean*0914 CADJ STORE EmPmR,hFacS,hFacW
ced23bb277 Gael*0915 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
d6e8c9ce95 Patr*0916 # endif
9c41af81f6 Timo*0917 #if ( defined NONLIN_FRSURF || defined ALLOW_SOLVE4_PS_AND_DRAG )
                0918 CADJ STORE aW2d, aS2d, aC2d =
                0919 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
                0920 CADJ STORE pC, pS, pW =
                0921 CADJ &     comlev1, key = ikey_dynamics, kind = isbyte
                0922 # endif
d6e8c9ce95 Patr*0923 #endif
615c650f5e Jean*0924         CALL TIMER_START('SOLVE_FOR_PRESSURE  [FORWARD_STEP]',myThid)
                0925         CALL SOLVE_FOR_PRESSURE(myTime, myIter, myThid)
                0926         CALL TIMER_STOP ('SOLVE_FOR_PRESSURE  [FORWARD_STEP]',myThid)
                0927       ENDIF
                0928 
                0929 C--   Correct divergence in flow field and cycle time-stepping momentum
9e647b4f24 Jean*0930 #ifdef ALLOW_MOM_STEPPING
517dbdc414 Jean*0931 #ifndef ALLOW_AUTODIFF
a27159adf7 Jean*0932       IF ( momStepping ) THEN
                0933 #endif
e2c5f2fe7c Patr*0934 #ifdef ALLOW_AUTODIFF_TAMC
bfdbc242ac Jean*0935 # ifdef ALLOW_DEPTH_CONTROL
35d3d94e31 Jean*0936 CADJ STORE etaN, uVel,vVel
b1d6b00360 Jean*0937 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
bfdbc242ac Jean*0938 # endif /* ALLOW_DEPTH_CONTROL */
                0939 #endif /* ALLOW_AUTODIFF_TAMC */
f3ec658fc9 Jean*0940         CALL TIMER_START('MOM_CORRECTION_STEP [FORWARD_STEP]',myThid)
615c650f5e Jean*0941         CALL MOMENTUM_CORRECTION_STEP(myTime, myIter, myThid)
f3ec658fc9 Jean*0942         CALL TIMER_STOP ('MOM_CORRECTION_STEP [FORWARD_STEP]',myThid)
517dbdc414 Jean*0943 #ifndef ALLOW_AUTODIFF
a27159adf7 Jean*0944       ENDIF
f66c946416 Step*0945 #endif
9e647b4f24 Jean*0946 #endif /* ALLOW_MOM_STEPPING */
9257d2aab8 Patr*0947 #ifdef ALLOW_AUTODIFF_TAMC
b1d6b00360 Jean*0948 CADJ STORE uVel, vVel = comlev1, key = ikey_dynamics, kind = isbyte
9257d2aab8 Patr*0949 #endif
615c650f5e Jean*0950 
bfdbc242ac Jean*0951       IF ( calc_wVelocity ) THEN
                0952 C--     Integrate continuity vertically for vertical velocity
                0953 C       (+ update "etaN" & "etaH", exact volume conservation):
                0954         CALL TIMER_START('INTEGR_CONTINUITY   [FORWARD_STEP]',myThid)
                0955         CALL INTEGR_CONTINUITY( uVel, vVel, myTime, myIter, myThid)
                0956         CALL TIMER_STOP ('INTEGR_CONTINUITY   [FORWARD_STEP]',myThid)
85937bd52b Alis*0957       ENDIF
9c41af81f6 Timo*0958 #ifdef ALLOW_AUTODIFF_TAMC
aa93ca8e85 Ciar*0959 C--   These store directives avoid an (expensive) extra
9c41af81f6 Timo*0960 C     "call solve_for_pressure" in forward_step_ad
                0961 CADJ STORE wVel = comlev1, key = ikey_dynamics, kind = isbyte
aa93ca8e85 Ciar*0962 CADJ STORE etaN = comlev1, key = ikey_dynamics, kind = isbyte
9c41af81f6 Timo*0963 #endif
615c650f5e Jean*0964 
                0965 #ifdef NONLIN_FRSURF
                0966       IF ( select_rStar.NE.0 ) THEN
cdc9f269ae Patr*0967 # ifndef DISABLE_RSTAR_CODE
e2c5f2fe7c Patr*0968 #  ifdef ALLOW_AUTODIFF_TAMC
9257d2aab8 Patr*0969 CADJ STORE etaH
                0970 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
35d3d94e31 Jean*0971 CADJ STORE rStarFacC,rStarFacS,rStarFacW
9257d2aab8 Patr*0972 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
e2c5f2fe7c Patr*0973 #  endif
529408dc72 Jean*0974 C--   r* : compute the future level thickness according to etaH(n+1)
                0975         CALL TIMER_START('CALC_R_STAR         [FORWARD_STEP]',myThid)
615c650f5e Jean*0976         CALL CALC_R_STAR(etaH, myTime, myIter, myThid )
529408dc72 Jean*0977         CALL TIMER_STOP ('CALC_R_STAR         [FORWARD_STEP]',myThid)
cdc9f269ae Patr*0978 # endif /* DISABLE_RSTAR_CODE */
a2a20dcddc Jean*0979       ELSEIF ( nonlinFreeSurf.GT.0 .AND. selectSigmaCoord.EQ.0 ) THEN
529408dc72 Jean*0980 C--   compute the future surface level thickness according to etaH(n+1)
0499e7ef48 Patr*0981 # ifdef ALLOW_AUTODIFF_TAMC
8a7ca847ff Patr*0982 CADJ STORE etaH          = comlev1, key = ikey_dynamics,
                0983 CADJ &     kind = isbyte
0499e7ef48 Patr*0984 # endif
529408dc72 Jean*0985         CALL TIMER_START('CALC_SURF_DR      [FORWARD_STEP]',myThid)
615c650f5e Jean*0986         CALL CALC_SURF_DR(etaH, myTime, myIter, myThid )
529408dc72 Jean*0987         CALL TIMER_STOP ('CALC_SURF_DR      [FORWARD_STEP]',myThid)
615c650f5e Jean*0988       ENDIF
0499e7ef48 Patr*0989 # ifdef ALLOW_AUTODIFF_TAMC
9257d2aab8 Patr*0990 CADJ STORE rStarExpC
                0991 CADJ &     = comlev1, key = ikey_dynamics, kind = isbyte
8a7ca847ff Patr*0992 CADJ STORE hFac_surfC       = comlev1, key = ikey_dynamics,
                0993 CADJ &     kind = isbyte
35d3d94e31 Jean*0994 CADJ STORE salt,theta = comlev1, key = ikey_dynamics,
8a7ca847ff Patr*0995 CADJ &     kind = isbyte
9c41af81f6 Timo*0996 #  ifdef ALLOW_PTRACERS
                0997 CADJ STORE pTracer    = comlev1, key = ikey_dynamics, kind = isbyte
                0998 #  endif /* ALLOW_PTRACERS */
529408dc72 Jean*0999 # endif
615c650f5e Jean*1000 #endif /* NONLIN_FRSURF */
                1001 
                1002 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
                1003       IF ( staggerTimeStep ) THEN
ffd0966f4f Jean*1004 C--   do exchanges of U,V (needed for multiDim) when using stagger time-step :
                1005 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*1006         IF (debugMode)
529408dc72 Jean*1007      &   CALL DEBUG_CALL('DO_STAGGER_FIELDS_EXCH.',myThid)
ffd0966f4f Jean*1008 #endif
                1009         CALL TIMER_START('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
                1010         CALL DO_STAGGER_FIELDS_EXCHANGES( myTime, myIter, myThid )
                1011         CALL TIMER_STOP ('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
615c650f5e Jean*1012 
0499e7ef48 Patr*1013 #ifdef ALLOW_DIAGNOSTICS
b5c2f2589c Jean*1014 C--   State-variables diagnostics
529408dc72 Jean*1015         IF ( useDiagnostics ) THEN
                1016           CALL TIMER_START('DO_STATEVARS_DIAGS  [FORWARD_STEP]',myThid)
                1017           CALL DO_STATEVARS_DIAGS( myTime, 1, myIter, myThid )
                1018           CALL TIMER_STOP ('DO_STATEVARS_DIAGS  [FORWARD_STEP]',myThid)
                1019         ENDIF
0499e7ef48 Patr*1020 #endif
b5c2f2589c Jean*1021 
35d3d94e31 Jean*1022 #ifdef ALLOW_AUTODIFF_TAMC
9c41af81f6 Timo*1023 C     these store directives prevent calling do_stagger_fields_exchanges
                1024 C     again in the AD-part of forward_step_ad
                1025 CADJ STORE salt, theta = comlev1, key = ikey_dynamics, kind = isbyte
                1026 CADJ STORE wVel        = comlev1, key = ikey_dynamics, kind = isbyte
35d3d94e31 Jean*1027 #endif
615c650f5e Jean*1028 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*1029         IF (debugMode) CALL DEBUG_CALL('THERMODYNAMICS',myThid)
615c650f5e Jean*1030 #endif
529408dc72 Jean*1031         CALL TIMER_START('THERMODYNAMICS      [FORWARD_STEP]',myThid)
615c650f5e Jean*1032         CALL THERMODYNAMICS( myTime, myIter, myThid )
529408dc72 Jean*1033         CALL TIMER_STOP ('THERMODYNAMICS      [FORWARD_STEP]',myThid)
615c650f5e Jean*1034 
                1035 C--    if staggerTimeStep: end
                1036       ENDIF
9c41af81f6 Timo*1037 #ifdef ALLOW_AUTODIFF_TAMC
                1038 C     this may not be necessary, but it does not do any harm (i.e. it is
                1039 C     ignored by TAF if not needed)
                1040 CADJ STORE salt, theta = comlev1, key = ikey_dynamics, kind = isbyte
                1041 #endif /* ALLOW_AUTODIFF_TAMC */
529408dc72 Jean*1042 C---+--------+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
d8ea337c6c Patr*1043 
7103bd8015 Patr*1044 #ifdef ALLOW_AUTODIFF_TAMC
                1045 cph This is needed because convective_adjustment calls
                1046 cph find_rho which may use pressure()
35d3d94e31 Jean*1047 CADJ STORE totPhiHyd  = comlev1, key = ikey_dynamics,
8a7ca847ff Patr*1048 CADJ &     kind = isbyte
7103bd8015 Patr*1049 #endif
bd27360393 Jean*1050 C--   Apply adjustments to Tracers arrays (T,S,+pTracers)
529408dc72 Jean*1051       CALL TIMER_START('TRC_CORRECTION_STEP [FORWARD_STEP]',myThid)
                1052       CALL TRACERS_CORRECTION_STEP(myTime, myIter, myThid)
                1053       CALL TIMER_STOP ('TRC_CORRECTION_STEP [FORWARD_STEP]',myThid)
d8ea337c6c Patr*1054 
4e66ab0b67 Oliv*1055 #ifdef ALLOW_LONGSTEP
                1056       IF ( usePTRACERS ) THEN
fda3710353 Oliv*1057        IF ( LS_whenToSample .EQ. 2 ) THEN
4e66ab0b67 Oliv*1058 C       Average everything at the end of the timestep.  This will
                1059 C       reproduce online results with staggerTimeStep=.TRUE.
fda3710353 Oliv*1060 C       when LS_nIter=1
4e66ab0b67 Oliv*1061 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*1062         IF (debugMode) CALL DEBUG_CALL('LONGSTEP_AVERAGE',myThid)
4e66ab0b67 Oliv*1063 #endif
                1064         CALL TIMER_START('LONGSTEP_AVERAGE    [FORWARD_STEP]',myThid)
                1065 C       myIter has been update after dynamics, but the averaging window
                1066 C       should be determined by myIter at beginning of timestep
                1067         CALL LONGSTEP_AVERAGE( myTimeBeg, myIterBeg, myThid )
                1068         CALL TIMER_STOP ('LONGSTEP_AVERAGE    [FORWARD_STEP]',myThid)
                1069 
                1070 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*1071         IF (debugMode)
fda3710353 Oliv*1072      &    CALL DEBUG_CALL('LONGSTEP_THERMODYNAMICS',myThid)
4e66ab0b67 Oliv*1073 #endif
fda3710353 Oliv*1074         CALL TIMER_START('LONGSTEP_THERMODYNAMICS      [FORWARD_STEP]',
4e66ab0b67 Oliv*1075      &                   myThid)
fda3710353 Oliv*1076         CALL LONGSTEP_THERMODYNAMICS( myTime, myIter, myThid )
                1077         CALL TIMER_STOP ('LONGSTEP_THERMODYNAMICS      [FORWARD_STEP]',
                1078      &                   myThid)
                1079 C--    if LS_whenToSample.EQ.2: end
                1080        ENDIF
4e66ab0b67 Oliv*1081 
bd27360393 Jean*1082 C--   Apply adjustments to passive Tracers arrays (pTracers)
                1083 c      CALL TIMER_START('LS_CORRECTION_STEP  [FORWARD_STEP]',myThid)
                1084 c      CALL LONGSTEP_CORRECTION_STEP(myTime, myIter, myThid)
                1085 c      CALL TIMER_STOP ('LS_CORRECTION_STEP  [FORWARD_STEP]',myThid)
fda3710353 Oliv*1086 C--    if usePTRACERS: end
4e66ab0b67 Oliv*1087       ENDIF
                1088 #endif /* ALLOW_LONGSTEP */
                1089 
6153ee95d4 Mart*1090 #ifdef ALLOW_GCHEM
e359829a2b Mart*1091 C     Add separate timestepping of chemical/biological/forcing
                1092 C     of ptracers here in GCHEM_FORCING_SEP
35d3d94e31 Jean*1093 #ifdef ALLOW_LONGSTEP
                1094       IF ( useGCHEM .AND. LS_doTimeStep ) THEN
                1095 #else
                1096       IF ( useGCHEM ) THEN
                1097 #endif
9c41af81f6 Timo*1098 # ifdef ALLOW_AUTODIFF_TAMC
                1099 CADJ STORE theta, salt = comlev1, key = ikey_dynamics, kind = isbyte
                1100 #  ifdef ALLOW_PTRACERS
                1101 CADJ STORE pTracer     = comlev1, key = ikey_dynamics, kind = isbyte
                1102 #  endif /* ALLOW_PTRACERS */
                1103 # endif
e359829a2b Mart*1104 #ifdef ALLOW_DEBUG
35d3d94e31 Jean*1105         IF (debugMode) CALL DEBUG_CALL('GCHEM_FORCING_SEP',myThid)
e359829a2b Mart*1106 #endif /* ALLOW_DEBUG */
35d3d94e31 Jean*1107         CALL TIMER_START('GCHEM_FORCING_SEP  [FORWARD_STEP]',myThid)
                1108         CALL GCHEM_FORCING_SEP( myTime,myIter,myThid )
                1109         CALL TIMER_STOP ('GCHEM_FORCING_SEP  [FORWARD_STEP]',myThid)
529408dc72 Jean*1110       ENDIF
6d54cf9ca1 Ed H*1111 #endif /* ALLOW_GCHEM */
e39d13c4c9 Step*1112 
30a55c64a0 Mart*1113 C--   Do "blocking" sends and receives for tendency "overlap" terms
                1114 c     CALL TIMER_START('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
                1115 c     CALL DO_GTERM_BLOCKING_EXCHANGES( myThid )
                1116 c     CALL TIMER_STOP ('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
                1117 
                1118 C--   Do "blocking" sends and receives for field "overlap" terms
                1119       CALL TIMER_START('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
                1120       CALL DO_FIELDS_BLOCKING_EXCHANGES( myThid )
                1121       CALL TIMER_STOP ('BLOCKING_EXCHANGES  [FORWARD_STEP]',myThid)
9c41af81f6 Timo*1122 #ifdef ALLOW_AUTODIFF_TAMC
                1123 C     These store directives avoid extra subroutine calls, for example,
                1124 C     thermodynamics, tracers_correction_step, gchem_forcing_sep, and
                1125 C     do_fields_blocking_exchages
                1126 CADJ STORE theta, salt = comlev1, key = ikey_dynamics, kind = isbyte
                1127 CADJ STORE uvel,  vvel = comlev1, key = ikey_dynamics, kind = isbyte
                1128 CADJ STORE totPhiHyd   = comlev1, key = ikey_dynamics, kind = isbyte
                1129 # ifdef ALLOW_PTRACERS
                1130 CADJ STORE pTracer     = comlev1, key = ikey_dynamics, kind = isbyte
                1131 # endif
                1132 #endif
30a55c64a0 Mart*1133 
0499e7ef48 Patr*1134 #ifdef ALLOW_DIAGNOSTICS
a27159adf7 Jean*1135       IF ( useDiagnostics ) THEN
cf44a6a231 Andr*1136        CALL TIMER_START('DO_STATEVARS_DIAGS  [FORWARD_STEP]',myThid)
                1137        CALL DO_STATEVARS_DIAGS( myTime, 2, myIter, myThid )
                1138        CALL TIMER_STOP ('DO_STATEVARS_DIAGS  [FORWARD_STEP]',myThid)
                1139       ENDIF
0499e7ef48 Patr*1140 #endif
30a55c64a0 Mart*1141 
bc57263004 Andr*1142 #ifdef ALLOW_GRIDALT
529408dc72 Jean*1143       IF (useGRIDALT) THEN
dc451e9e8f Andr*1144          CALL GRIDALT_UPDATE(myThid)
529408dc72 Jean*1145       ENDIF
bc57263004 Andr*1146 #endif
                1147 
468f196fcd Andr*1148 #ifdef ALLOW_FIZHI
529408dc72 Jean*1149       IF (useFIZHI) THEN
                1150          CALL TIMER_START('FIZHI               [FORWARD_STEP]',myThid)
a9203e518a Andr*1151          CALL STEP_FIZHI_CORR ( myTime, myIter, myThid, dTtracerLev(1) )
529408dc72 Jean*1152          CALL TIMER_STOP ('FIZHI               [FORWARD_STEP]',myThid)
                1153       ENDIF
468f196fcd Andr*1154 #endif
e39d13c4c9 Step*1155 
c806179eb4 Alis*1156 #ifdef ALLOW_FLT
                1157 C--   Calculate float trajectories
                1158       IF (useFLT) THEN
650cc6304d Patr*1159         CALL TIMER_START('FLOATS            [FORWARD_STEP]',myThid)
5fcc68371c Jean*1160         CALL FLT_MAIN( myTime, myIter, myThid )
650cc6304d Patr*1161         CALL TIMER_STOP ('FLOATS            [FORWARD_STEP]',myThid)
c806179eb4 Alis*1162       ENDIF
                1163 #endif
                1164 
0499e7ef48 Patr*1165 #ifdef ALLOW_TIMEAVE
b5c2f2589c Jean*1166 C--   State-variables time-averaging
                1167       CALL TIMER_START('DO_STATEVARS_TAVE   [FORWARD_STEP]',myThid)
                1168       CALL DO_STATEVARS_TAVE( myTime, myIter, myThid )
                1169       CALL TIMER_STOP ('DO_STATEVARS_TAVE   [FORWARD_STEP]',myThid)
0499e7ef48 Patr*1170 #endif
c8e3a3b543 Jean*1171 
94884059ae Jean*1172 #ifdef ALLOW_NEST_PARENT
                1173       IF ( useNEST_PARENT) THEN
                1174         CALL NEST_PARENT_IO_2( myTime, myIter, myThid )
                1175       ENDIF
                1176 #endif /* ALLOW_NEST_PARENT */
                1177 
                1178 #ifdef ALLOW_NEST_CHILD
                1179       IF ( useNEST_CHILD) THEN
                1180             CALL NEST_CHILD_TRANSP( myTime, myIter, myThid )
                1181       ENDIF
                1182 #endif /* ALLOW_NEST_CHILD */
                1183 
ffced37781 Ed H*1184 #ifdef ALLOW_MONITOR
5f45e58a14 Jean*1185       IF ( monitorFreq.GT.0. .OR. adjMonitorFreq.GT.0. ) THEN
d8ea337c6c Patr*1186 C--   Check status of solution (statistics, cfl, etc...)
a27159adf7 Jean*1187         CALL TIMER_START('MONITOR             [FORWARD_STEP]',myThid)
4f8feb8bdf Jean*1188         CALL MONITOR( myTime, myIter, myThid )
a27159adf7 Jean*1189         CALL TIMER_STOP ('MONITOR             [FORWARD_STEP]',myThid)
                1190       ENDIF
ffced37781 Ed H*1191 #endif /* ALLOW_MONITOR */
d8ea337c6c Patr*1192 
449f3c105b Patr*1193 #ifdef ALLOW_COST
                1194 C--     compare model with data and compute cost function
                1195 C--     this is done after exchanges to allow interpolation
                1196       CALL TIMER_START('COST_TILE           [FORWARD_STEP]',myThid)
529408dc72 Jean*1197       CALL COST_TILE  ( myTime, myIter, myThid )
449f3c105b Patr*1198       CALL TIMER_STOP ('COST_TILE           [FORWARD_STEP]',myThid)
                1199 #endif
                1200 
3949c257c5 Gael*1201 #ifdef ALLOW_ECCO
aa93ca8e85 Ciar*1202 C--   Diagnose variables for pkg/ecco averaging and cost function purposes
0cd0083da8 Ou W*1203       IF ( useECCO ) CALL ECCO_PHYS( myTime, myIter, myThid )
3949c257c5 Gael*1204 #endif
                1205 
94884059ae Jean*1206 C--   Check if it has reached the end of simulation
455a90837c Jean*1207       modelEnd = myTime.EQ.endTime .OR. myIter.EQ.nEndIter
b81731e160 Ed H*1208 #ifdef HAVE_SIGREG
                1209       IF ( useSIGREG ) THEN
455a90837c Jean*1210         modelEnd = modelEnd .OR. ( i_got_signal.GT.0 )
b81731e160 Ed H*1211       ENDIF
a27159adf7 Jean*1212 #endif /* HAVE_SIGREG */
b81731e160 Ed H*1213 
94884059ae Jean*1214 C--   Do IO if needed.
                1215       CALL TIMER_START('DO_THE_MODEL_IO     [FORWARD_STEP]',myThid)
                1216       CALL DO_THE_MODEL_IO( modelEnd, myTime, myIter, myThid )
                1217       CALL TIMER_STOP ('DO_THE_MODEL_IO     [FORWARD_STEP]',myThid)
                1218 
9fbec3c176 Oliv*1219 #ifdef ALLOW_PTRACERS
                1220 C     Reset the ptracers (but after the io is done)
                1221       IF ( usePTRACERS ) THEN
                1222         CALL TIMER_START('PTRACERS_RESET      [FORWARD_STEP]',myThid)
                1223         CALL PTRACERS_RESET( myTime, myIter, myThid )
                1224         CALL TIMER_STOP ('PTRACERS_RESET      [FORWARD_STEP]',myThid)
                1225       ENDIF
                1226 #endif /* ALLOW_PTRACERS */
                1227 
d8ea337c6c Patr*1228 C--   Save state for restarts
931983c6ab Jean*1229       CALL TIMER_START('DO_WRITE_PICKUP     [FORWARD_STEP]',myThid)
94884059ae Jean*1230       CALL DO_WRITE_PICKUP( modelEnd, myTime, myIter, myThid )
931983c6ab Jean*1231       CALL TIMER_STOP ('DO_WRITE_PICKUP     [FORWARD_STEP]',myThid)
d8ea337c6c Patr*1232 
455a90837c Jean*1233 #ifdef HAVE_SIGREG
                1234       IF ( useSIGREG ) THEN
                1235         IF ( modelEnd .AND. i_got_signal.GT.0 ) THEN
                1236           STOP 'Checkpoint completed -- killed by signal handler'
                1237         ENDIF
                1238       ENDIF
                1239 #endif /* HAVE_SIGREG */
e01e1e4fa5 Patr*1240 
517dbdc414 Jean*1241 #ifdef ALLOW_AUTODIFF
a10c595eb6 Timo*1242       CALL AUTODIFF_INADMODE_SET( myTime, myIter, myThid )
e01e1e4fa5 Patr*1243 #endif
                1244 
                1245 #ifdef ALLOW_SHOWFLOPS
9e647b4f24 Jean*1246       CALL TIMER_START('SHOWFLOPS_INLOOP   [THE_MAIN_LOOP]', myThid)
                1247       CALL SHOWFLOPS_INLOOP( iloop, myThid )
                1248       CALL TIMER_STOP ('SHOWFLOPS_INLOOP   [THE_MAIN_LOOP]', myThid)
e01e1e4fa5 Patr*1249 #endif
                1250 
49e3578e36 Ed H*1251 #ifdef ALLOW_DEBUG
8440e8ae5d Jean*1252       IF (debugMode) CALL DEBUG_LEAVE('FORWARD_STEP',myThid)
73ead277e0 Alis*1253 #endif
                1254 
fddb7fab2a Jean*1255       RETURN
d8ea337c6c Patr*1256       END