step.F90 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. MODULE step
  2. !!======================================================================
  3. !! *** MODULE step ***
  4. !! Time-stepping : manager of the ocean, tracer and ice time stepping
  5. !!======================================================================
  6. !! History : OPA ! 1991-03 (G. Madec) Original code
  7. !! - ! 1991-11 (G. Madec)
  8. !! - ! 1992-06 (M. Imbard) add a first output record
  9. !! - ! 1996-04 (G. Madec) introduction of dynspg
  10. !! - ! 1996-04 (M.A. Foujols) introduction of passive tracer
  11. !! 8.0 ! 1997-06 (G. Madec) new architecture of call
  12. !! 8.2 ! 1997-06 (G. Madec, M. Imbard, G. Roullet) free surface
  13. !! - ! 1999-02 (G. Madec, N. Grima) hpg implicit
  14. !! - ! 2000-07 (J-M Molines, M. Imbard) Open Bondary Conditions
  15. !! NEMO 1.0 ! 2002-06 (G. Madec) free form, suppress macro-tasking
  16. !! - ! 2004-08 (C. Talandier) New trends organization
  17. !! - ! 2005-01 (C. Ethe) Add the KPP closure scheme
  18. !! - ! 2005-11 (G. Madec) Reorganisation of tra and dyn calls
  19. !! - ! 2006-01 (L. Debreu, C. Mazauric) Agrif implementation
  20. !! - ! 2006-07 (S. Masson) restart using iom
  21. !! 3.2 ! 2009-02 (G. Madec, R. Benshila) reintroduicing z*-coordinate
  22. !! - ! 2009-06 (S. Masson, G. Madec) TKE restart compatible with key_cpl
  23. !! 3.3 ! 2010-05 (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface
  24. !! - ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase + merge TRC-TRA
  25. !! 3.4 ! 2011-04 (G. Madec, C. Ethe) Merge of dtatem and dtasal
  26. !! ! 2012-07 (J. Simeon, G. Madec, C. Ethe) Online coarsening of outputs
  27. !! 3.7 ! 2014-04 (F. Roquet, G. Madec) New equations of state
  28. !!----------------------------------------------------------------------
  29. !!----------------------------------------------------------------------
  30. !! stp : OPA system time-stepping
  31. !!----------------------------------------------------------------------
  32. USE step_oce ! time stepping definition modules
  33. USE iom
  34. IMPLICIT NONE
  35. PRIVATE
  36. PUBLIC stp ! called by opa.F90
  37. !! * Substitutions
  38. # include "domzgr_substitute.h90"
  39. !!gm # include "zdfddm_substitute.h90"
  40. !!----------------------------------------------------------------------
  41. !! NEMO/OPA 3.7 , NEMO Consortium (2014)
  42. !! $Id: step.F90 8477 2017-08-31 12:41:13Z timgraham $
  43. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  44. !!----------------------------------------------------------------------
  45. CONTAINS
  46. #if defined key_agrif
  47. RECURSIVE SUBROUTINE stp( )
  48. INTEGER :: kstp ! ocean time-step index
  49. #else
  50. SUBROUTINE stp( kstp )
  51. INTEGER, INTENT(in) :: kstp ! ocean time-step index
  52. #endif
  53. !!----------------------------------------------------------------------
  54. !! *** ROUTINE stp ***
  55. !!
  56. !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.)
  57. !! - Time stepping of LIM (dynamic and thermodynamic eqs.)
  58. !! - Tme stepping of TRC (passive tracer eqs.)
  59. !!
  60. !! ** Method : -1- Update forcings and data
  61. !! -2- Update ocean physics
  62. !! -3- Compute the t and s trends
  63. !! -4- Update t and s
  64. !! -5- Compute the momentum trends
  65. !! -6- Update the horizontal velocity
  66. !! -7- Compute the diagnostics variables (rd,N2, div,cur,w)
  67. !! -8- Outputs and diagnostics
  68. !!----------------------------------------------------------------------
  69. INTEGER :: jk ! dummy loop indice
  70. INTEGER :: indic, indict ! error indicator if < 0
  71. INTEGER :: kcall ! optional integer argument (dom_vvl_sf_nxt)
  72. !! ---------------------------------------------------------------------
  73. #if defined key_agrif
  74. kstp = nit000 + Agrif_Nb_Step()
  75. IF ( lk_agrif_debug ) THEN
  76. IF ( Agrif_Root() .and. lwp) Write(*,*) '---'
  77. IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp, 'int tstep',Agrif_NbStepint()
  78. ENDIF
  79. IF ( kstp == (nit000 + 1) ) lk_agrif_fstep = .FALSE.
  80. # if defined key_iomput
  81. IF( Agrif_Nbstepint() == 0 ) CALL iom_swap( cxios_context )
  82. # endif
  83. #endif
  84. indic = 0 ! reset to no error condition
  85. indict = 0
  86. IF( kstp == nit000 ) THEN
  87. ! must be done after nemo_init for AGRIF+XIOS+OASIS
  88. CALL iom_init( cxios_context ) ! iom_put initialization
  89. IF( ln_crs ) CALL iom_init( TRIM(cxios_context)//"_crs" ) ! initialize context for coarse grid
  90. ENDIF
  91. IF( kstp /= nit000 ) CALL day( kstp ) ! Calendar (day was already called at nit000 in day_init)
  92. CALL iom_setkt( kstp - nit000 + 1, cxios_context ) ! tell iom we are at time step kstp
  93. IF( ln_crs ) CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" ) ! tell iom we are at time step kstp
  94. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  95. ! Update data, open boundaries, surface boundary condition (including sea-ice)
  96. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  97. IF( lk_tide ) CALL sbc_tide( kstp )
  98. IF( lk_bdy ) THEN
  99. IF( ln_apr_dyn) CALL sbc_apr( kstp ) ! bdy_dta needs ssh_ib
  100. CALL bdy_dta ( kstp, time_offset=+1 ) ! update dynamic & tracer data at open boundaries
  101. ENDIF
  102. CALL sbc ( kstp ) ! Sea Boundary Condition (including sea-ice)
  103. ! clem: moved here for bdy ice purpose
  104. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  105. ! Update stochastic parameters and random T/S fluctuations
  106. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  107. IF( ln_sto_eos ) CALL sto_par( kstp ) ! Stochastic parameters
  108. IF( ln_sto_eos ) CALL sto_pts( tsn ) ! Random T/S fluctuations
  109. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  110. ! Ocean physics update (ua, va, tsa used as workspace)
  111. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  112. ! THERMODYNAMICS
  113. CALL eos_rab( tsb, rab_b ) ! before local thermal/haline expension ratio at T-points
  114. CALL eos_rab( tsn, rab_n ) ! now local thermal/haline expension ratio at T-points
  115. CALL bn2 ( tsb, rab_b, rn2b ) ! before Brunt-Vaisala frequency
  116. CALL bn2 ( tsn, rab_n, rn2 ) ! now Brunt-Vaisala frequency
  117. !
  118. ! VERTICAL PHYSICS
  119. CALL zdf_bfr( kstp ) ! bottom friction (if quadratic)
  120. ! ! Vertical eddy viscosity and diffusivity coefficients
  121. IF( lk_zdfric ) CALL zdf_ric( kstp ) ! Richardson number dependent Kz
  122. IF( lk_zdftke ) CALL zdf_tke( kstp ) ! TKE closure scheme for Kz
  123. IF( lk_zdfgls ) CALL zdf_gls( kstp ) ! GLS closure scheme for Kz
  124. IF( lk_zdfkpp ) CALL zdf_kpp( kstp ) ! KPP closure scheme for Kz
  125. IF( lk_zdfcst ) THEN ! Constant Kz (reset avt, avm[uv] to the background value)
  126. avt (:,:,:) = rn_avt0 * wmask (:,:,:)
  127. avmu(:,:,:) = rn_avm0 * wumask(:,:,:)
  128. avmv(:,:,:) = rn_avm0 * wvmask(:,:,:)
  129. ENDIF
  130. IF( ln_rnf_mouth ) THEN ! increase diffusivity at rivers mouths
  131. DO jk = 2, nkrnf ; avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk) ; END DO
  132. ENDIF
  133. IF( ln_zdfevd ) CALL zdf_evd( kstp ) ! enhanced vertical eddy diffusivity
  134. IF( lk_zdftmx ) CALL zdf_tmx( kstp ) ! tidal vertical mixing
  135. IF( lk_zdfddm .AND. .NOT. lk_zdfkpp ) &
  136. & CALL zdf_ddm( kstp ) ! double diffusive mixing
  137. CALL zdf_mxl( kstp ) ! mixed layer depth
  138. ! write TKE or GLS information in the restart file
  139. IF( lrst_oce .AND. lk_zdftke ) CALL tke_rst( kstp, 'WRITE' )
  140. IF( lrst_oce .AND. lk_zdfgls ) CALL gls_rst( kstp, 'WRITE' )
  141. !
  142. ! LATERAL PHYSICS
  143. !
  144. IF( lk_ldfslp ) THEN ! slope of lateral mixing
  145. CALL eos( tsb, rhd, gdept_0(:,:,:) ) ! before in situ density
  146. IF( ln_zps .AND. .NOT. ln_isfcav) &
  147. & CALL zps_hde ( kstp, jpts, tsb, gtsu, gtsv, & ! Partial steps: before horizontal gradient
  148. & rhd, gru , grv ) ! of t, s, rd at the last ocean level
  149. IF( ln_zps .AND. ln_isfcav) &
  150. & CALL zps_hde_isf( kstp, jpts, tsb, gtsu, gtsv, & ! Partial steps for top cell (ISF)
  151. & rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv , &
  152. & gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi ) ! of t, s, rd at the first ocean level
  153. IF( ln_traldf_grif ) THEN ! before slope for Griffies operator
  154. CALL ldf_slp_grif( kstp )
  155. ELSE
  156. CALL ldf_slp( kstp, rhd, rn2b ) ! before slope for Madec operator
  157. ENDIF
  158. ENDIF
  159. #if defined key_traldf_c2d
  160. IF( lk_traldf_eiv ) CALL ldf_eiv( kstp ) ! eddy induced velocity coefficient
  161. #endif
  162. #if defined key_traldf_c3d && defined key_traldf_smag
  163. CALL ldf_tra_smag( kstp ) ! eddy induced velocity coefficient
  164. # endif
  165. #if defined key_dynldf_c3d && defined key_dynldf_smag
  166. CALL ldf_dyn_smag( kstp ) ! eddy induced velocity coefficient
  167. # endif
  168. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  169. ! Ocean dynamics : hdiv, rot, ssh, e3, wn
  170. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  171. CALL ssh_nxt ( kstp ) ! after ssh (includes call to div_cur)
  172. IF( lk_vvl ) CALL dom_vvl_sf_nxt( kstp ) ! after vertical scale factors
  173. CALL wzv ( kstp ) ! now cross-level velocity
  174. IF( lk_dynspg_ts ) THEN
  175. ! In case the time splitting case, update almost all momentum trends here:
  176. ! Note that the computation of vertical velocity above, hence "after" sea level
  177. ! is necessary to compute momentum advection for the rhs of barotropic loop:
  178. CALL eos ( tsn, rhd, rhop, fsdept_n(:,:,:) ) ! now in situ density for hpg computation
  179. IF( ln_zps .AND. .NOT. ln_isfcav) &
  180. & CALL zps_hde ( kstp, jpts, tsn, gtsu, gtsv, & ! Partial steps: before horizontal gradient
  181. & rhd, gru , grv ) ! of t, s, rd at the last ocean level
  182. IF( ln_zps .AND. ln_isfcav) &
  183. & CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv, & ! Partial steps for top cell (ISF)
  184. & rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv , &
  185. & gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi ) ! of t, s, rd at the last ocean level
  186. ua(:,:,:) = 0.e0 ! set dynamics trends to zero
  187. va(:,:,:) = 0.e0
  188. IF( lk_asminc .AND. ln_asmiau .AND. &
  189. & ln_dyninc ) CALL dyn_asm_inc ( kstp ) ! apply dynamics assimilation increment
  190. IF( ln_neptsimp ) CALL dyn_nept_cor ( kstp ) ! subtract Neptune velocities (simplified)
  191. IF( lk_bdy ) CALL bdy_dyn3d_dmp( kstp ) ! bdy damping trends
  192. CALL dyn_adv ( kstp ) ! advection (vector or flux form)
  193. CALL dyn_vor ( kstp ) ! vorticity term including Coriolis
  194. CALL dyn_ldf ( kstp ) ! lateral mixing
  195. IF( ln_neptsimp ) CALL dyn_nept_cor ( kstp ) ! add Neptune velocities (simplified)
  196. #if defined key_agrif
  197. IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_dyn ! momentum sponge
  198. #endif
  199. CALL dyn_hpg( kstp ) ! horizontal gradient of Hydrostatic pressure
  200. CALL dyn_spg( kstp, indic ) ! surface pressure gradient
  201. ua_sv(:,:,:) = ua(:,:,:) ! Save trends (barotropic trend has been fully updated at this stage)
  202. va_sv(:,:,:) = va(:,:,:)
  203. CALL div_cur( kstp ) ! Horizontal divergence & Relative vorticity (2nd call in time-split case)
  204. IF( lk_vvl ) CALL dom_vvl_sf_nxt( kstp, kcall=2 ) ! after vertical scale factors (update depth average component)
  205. CALL wzv ( kstp ) ! now cross-level velocity
  206. ENDIF
  207. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  208. ! diagnostics and outputs (ua, va, tsa used as workspace)
  209. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  210. IF( lk_floats ) CALL flo_stp( kstp ) ! drifting Floats
  211. IF( lk_diahth ) CALL dia_hth( kstp ) ! Thermocline depth (20 degres isotherm depth)
  212. IF( .NOT. ln_cpl ) CALL dia_fwb( kstp ) ! Fresh water budget diagnostics
  213. IF( lk_diadct ) CALL dia_dct( kstp ) ! Transports
  214. IF( lk_diaar5 ) CALL dia_ar5( kstp ) ! ar5 diag
  215. IF( lk_diaharm ) CALL dia_harm( kstp ) ! Tidal harmonic analysis
  216. CALL dia_prod( kstp ) ! ocean model: product diagnostics
  217. CALL dia_wri( kstp ) ! ocean model: outputs
  218. !
  219. IF( ln_crs ) CALL crs_fld( kstp ) ! ocean model: online field coarsening & output
  220. #if defined key_top
  221. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  222. ! Passive Tracer Model
  223. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  224. CALL trc_stp( kstp, indict ) ! time-stepping
  225. #endif
  226. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  227. ! Active tracers (ua, va used as workspace)
  228. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  229. tsa(:,:,:,:) = 0.e0 ! set tracer trends to zero
  230. IF( lk_asminc .AND. ln_asmiau .AND. &
  231. & ln_trainc ) CALL tra_asm_inc( kstp ) ! apply tracer assimilation increment
  232. CALL tra_sbc ( kstp ) ! surface boundary condition
  233. IF( ln_traqsr ) CALL tra_qsr ( kstp ) ! penetrative solar radiation qsr
  234. IF( ln_trabbc ) CALL tra_bbc ( kstp ) ! bottom heat flux
  235. IF( lk_trabbl ) CALL tra_bbl ( kstp ) ! advective (and/or diffusive) bottom boundary layer scheme
  236. IF( ln_tradmp ) CALL tra_dmp ( kstp ) ! internal damping trends
  237. IF( lk_bdy ) CALL bdy_tra_dmp( kstp ) ! bdy damping trends
  238. CALL tra_adv ( kstp ) ! horizontal & vertical advection
  239. IF( lk_zdfkpp ) CALL tra_kpp ( kstp ) ! KPP non-local tracer fluxes
  240. CALL tra_ldf ( kstp ) ! lateral mixing
  241. IF( ln_diaptr ) CALL dia_ptr ! Poleward adv/ldf TRansports diagnostics
  242. #if defined key_agrif
  243. IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra ! tracers sponge
  244. #endif
  245. CALL tra_zdf ( kstp ) ! vertical mixing and after tracer fields
  246. IF( ln_dynhpg_imp ) THEN ! semi-implicit hpg (time stepping then eos)
  247. IF( ln_zdfnpc ) CALL tra_npc( kstp ) ! update after fields by non-penetrative convection
  248. CALL tra_nxt( kstp ) ! tracer fields at next time step
  249. CALL eos ( tsa, rhd, rhop, fsdept_n(:,:,:) ) ! Time-filtered in situ density for hpg computation
  250. IF( ln_zps .AND. .NOT. ln_isfcav) &
  251. & CALL zps_hde ( kstp, jpts, tsa, gtsu, gtsv, & ! Partial steps: before horizontal gradient
  252. & rhd, gru , grv ) ! of t, s, rd at the last ocean level
  253. IF( ln_zps .AND. ln_isfcav) &
  254. & CALL zps_hde_isf( kstp, jpts, tsa, gtsu, gtsv, & ! Partial steps for top cell (ISF)
  255. & rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv , &
  256. & gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi ) ! of t, s, rd at the last ocean level
  257. ELSE ! centered hpg (eos then time stepping)
  258. IF ( .NOT. lk_dynspg_ts ) THEN ! eos already called in time-split case
  259. CALL eos ( tsn, rhd, rhop, fsdept_n(:,:,:) ) ! now in situ density for hpg computation
  260. IF( ln_zps .AND. .NOT. ln_isfcav) &
  261. & CALL zps_hde ( kstp, jpts, tsn, gtsu, gtsv, & ! Partial steps: before horizontal gradient
  262. & rhd, gru , grv ) ! of t, s, rd at the last ocean level
  263. IF( ln_zps .AND. ln_isfcav) &
  264. & CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv, & ! Partial steps for top cell (ISF)
  265. & rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv , &
  266. & gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi ) ! of t, s, rd at the last ocean level
  267. ENDIF
  268. IF( ln_zdfnpc ) CALL tra_npc( kstp ) ! update after fields by non-penetrative convection
  269. CALL tra_nxt( kstp ) ! tracer fields at next time step
  270. ENDIF
  271. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  272. ! Dynamics (tsa used as workspace)
  273. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  274. IF( lk_dynspg_ts ) THEN
  275. ! revert to previously computed momentum tendencies
  276. ! (not using ua, va as temporary arrays during tracers' update could avoid that)
  277. ua(:,:,:) = ua_sv(:,:,:)
  278. va(:,:,:) = va_sv(:,:,:)
  279. ! Revert now divergence and rotational to previously computed ones
  280. !(needed because of the time swap in div_cur, at the beginning of each time step)
  281. hdivn(:,:,:) = hdivb(:,:,:)
  282. rotn(:,:,:) = rotb(:,:,:)
  283. CALL dyn_bfr( kstp ) ! bottom friction
  284. CALL dyn_zdf( kstp ) ! vertical diffusion
  285. ELSE
  286. ua(:,:,:) = 0.e0 ! set dynamics trends to zero
  287. va(:,:,:) = 0.e0
  288. IF( lk_asminc .AND. ln_asmiau .AND. &
  289. & ln_dyninc ) CALL dyn_asm_inc( kstp ) ! apply dynamics assimilation increment
  290. IF( ln_bkgwri ) CALL asm_bkg_wri( kstp ) ! output background fields
  291. IF( ln_neptsimp ) CALL dyn_nept_cor( kstp ) ! subtract Neptune velocities (simplified)
  292. IF( lk_bdy ) CALL bdy_dyn3d_dmp(kstp ) ! bdy damping trends
  293. CALL dyn_adv( kstp ) ! advection (vector or flux form)
  294. CALL dyn_vor( kstp ) ! vorticity term including Coriolis
  295. CALL dyn_ldf( kstp ) ! lateral mixing
  296. IF( ln_neptsimp ) CALL dyn_nept_cor( kstp ) ! add Neptune velocities (simplified)
  297. #if defined key_agrif
  298. IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_dyn ! momemtum sponge
  299. #endif
  300. CALL dyn_hpg( kstp ) ! horizontal gradient of Hydrostatic pressure
  301. CALL dyn_bfr( kstp ) ! bottom friction
  302. CALL dyn_zdf( kstp ) ! vertical diffusion
  303. CALL dyn_spg( kstp, indic ) ! surface pressure gradient
  304. ENDIF
  305. CALL dyn_nxt( kstp ) ! lateral velocity at next time step
  306. CALL ssh_swp( kstp ) ! swap of sea surface height
  307. IF( lk_vvl ) CALL dom_vvl_sf_swp( kstp ) ! swap of vertical scale factors
  308. !
  309. IF( ln_diahsb ) CALL dia_hsb( kstp ) ! - ML - global conservation diagnostics
  310. IF( lrst_oce ) CALL rst_write( kstp ) ! write output ocean restart file
  311. IF( ln_sto_eos ) CALL sto_rst_write( kstp ) ! write restart file for stochastic parameters
  312. #if defined key_agrif
  313. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  314. ! AGRIF
  315. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  316. CALL Agrif_Integrate_ChildGrids( stp )
  317. IF ( Agrif_NbStepint().EQ.0 ) THEN
  318. CALL Agrif_Update_Tra() ! Update active tracers
  319. CALL Agrif_Update_Dyn() ! Update momentum
  320. ENDIF
  321. #endif
  322. IF( lk_diaobs ) CALL dia_obs( kstp ) ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
  323. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  324. ! Control
  325. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  326. CALL stp_ctl( kstp, indic )
  327. IF( indic < 0 ) THEN
  328. CALL ctl_stop( 'step: indic < 0' )
  329. CALL dia_wri_state( 'output.abort', kstp )
  330. ENDIF
  331. IF( kstp == nit000 ) THEN
  332. CALL iom_close( numror ) ! close input ocean restart file
  333. IF(lwm) CALL FLUSH ( numond ) ! flush output namelist oce
  334. IF( lwm.AND.numoni /= -1 ) CALL FLUSH ( numoni ) ! flush output namelist ice
  335. ENDIF
  336. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  337. ! Coupled mode
  338. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  339. IF( lk_oasis ) CALL sbc_cpl_snd( kstp ) ! coupled mode : field exchanges
  340. !
  341. #if defined key_iomput
  342. IF( kstp == nitend .OR. indic < 0 .OR. indict < 0 ) THEN
  343. CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF
  344. IF( ln_crs ) CALL iom_context_finalize( trim(cxios_context)//"_crs" ) !
  345. ENDIF
  346. #endif
  347. !
  348. IF( nn_timing == 1 .AND. kstp == nit000 ) CALL timing_reset
  349. !
  350. !
  351. END SUBROUTINE stp
  352. !!======================================================================
  353. END MODULE step