step.F90 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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 5510 2015-06-30 08:49:40Z clem $
  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 ! 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. IF( kstp == nit000 ) THEN
  86. ! must be done after nemo_init for AGRIF+XIOS+OASIS
  87. CALL iom_init( cxios_context ) ! iom_put initialization
  88. IF( ln_crs ) CALL iom_init( TRIM(cxios_context)//"_crs" ) ! initialize context for coarse grid
  89. ENDIF
  90. IF( kstp /= nit000 ) CALL day( kstp ) ! Calendar (day was already called at nit000 in day_init)
  91. CALL iom_setkt( kstp - nit000 + 1, cxios_context ) ! tell iom we are at time step kstp
  92. IF( ln_crs ) CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" ) ! tell iom we are at time step kstp
  93. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  94. ! Update data, open boundaries, surface boundary condition (including sea-ice)
  95. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  96. IF( lk_tide ) CALL sbc_tide( kstp )
  97. IF( lk_bdy ) THEN
  98. IF( ln_apr_dyn) CALL sbc_apr( kstp ) ! bdy_dta needs ssh_ib
  99. CALL bdy_dta ( kstp, time_offset=+1 ) ! update dynamic & tracer data at open boundaries
  100. ENDIF
  101. CALL sbc ( kstp ) ! Sea Boundary Condition (including sea-ice)
  102. ! clem: moved here for bdy ice purpose
  103. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  104. ! Update stochastic parameters and random T/S fluctuations
  105. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  106. IF( ln_sto_eos ) CALL sto_par( kstp ) ! Stochastic parameters
  107. IF( ln_sto_eos ) CALL sto_pts( tsn ) ! Random T/S fluctuations
  108. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  109. ! Ocean physics update (ua, va, tsa used as workspace)
  110. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  111. ! THERMODYNAMICS
  112. CALL eos_rab( tsb, rab_b ) ! before local thermal/haline expension ratio at T-points
  113. CALL eos_rab( tsn, rab_n ) ! now local thermal/haline expension ratio at T-points
  114. CALL bn2 ( tsb, rab_b, rn2b ) ! before Brunt-Vaisala frequency
  115. CALL bn2 ( tsn, rab_n, rn2 ) ! now Brunt-Vaisala frequency
  116. !
  117. ! VERTICAL PHYSICS
  118. CALL zdf_bfr( kstp ) ! bottom friction (if quadratic)
  119. ! ! Vertical eddy viscosity and diffusivity coefficients
  120. IF( lk_zdfric ) CALL zdf_ric( kstp ) ! Richardson number dependent Kz
  121. IF( lk_zdftke ) CALL zdf_tke( kstp ) ! TKE closure scheme for Kz
  122. IF( lk_zdfgls ) CALL zdf_gls( kstp ) ! GLS closure scheme for Kz
  123. IF( lk_zdfkpp ) CALL zdf_kpp( kstp ) ! KPP closure scheme for Kz
  124. IF( lk_zdfcst ) THEN ! Constant Kz (reset avt, avm[uv] to the background value)
  125. avt (:,:,:) = rn_avt0 * wmask (:,:,:)
  126. avmu(:,:,:) = rn_avm0 * wumask(:,:,:)
  127. avmv(:,:,:) = rn_avm0 * wvmask(:,:,:)
  128. ENDIF
  129. IF( ln_rnf_mouth ) THEN ! increase diffusivity at rivers mouths
  130. DO jk = 2, nkrnf ; avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk) ; END DO
  131. ENDIF
  132. IF( ln_zdfevd ) CALL zdf_evd( kstp ) ! enhanced vertical eddy diffusivity
  133. IF( lk_zdftmx ) CALL zdf_tmx( kstp ) ! tidal vertical mixing
  134. IF( lk_zdfddm .AND. .NOT. lk_zdfkpp ) &
  135. & CALL zdf_ddm( kstp ) ! double diffusive mixing
  136. CALL zdf_mxl( kstp ) ! mixed layer depth
  137. ! write TKE or GLS information in the restart file
  138. IF( lrst_oce .AND. lk_zdftke ) CALL tke_rst( kstp, 'WRITE' )
  139. IF( lrst_oce .AND. lk_zdfgls ) CALL gls_rst( kstp, 'WRITE' )
  140. !
  141. ! LATERAL PHYSICS
  142. !
  143. IF( lk_ldfslp ) THEN ! slope of lateral mixing
  144. CALL eos( tsb, rhd, gdept_0(:,:,:) ) ! before in situ density
  145. IF( ln_zps .AND. .NOT. ln_isfcav) &
  146. & CALL zps_hde ( kstp, jpts, tsb, gtsu, gtsv, & ! Partial steps: before horizontal gradient
  147. & rhd, gru , grv ) ! of t, s, rd at the last ocean level
  148. IF( ln_zps .AND. ln_isfcav) &
  149. & CALL zps_hde_isf( kstp, jpts, tsb, gtsu, gtsv, & ! Partial steps for top cell (ISF)
  150. & rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv , &
  151. & gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi ) ! of t, s, rd at the first ocean level
  152. IF( ln_traldf_grif ) THEN ! before slope for Griffies operator
  153. CALL ldf_slp_grif( kstp )
  154. ELSE
  155. CALL ldf_slp( kstp, rhd, rn2b ) ! before slope for Madec operator
  156. ENDIF
  157. ENDIF
  158. #if defined key_traldf_c2d
  159. IF( lk_traldf_eiv ) CALL ldf_eiv( kstp ) ! eddy induced velocity coefficient
  160. #endif
  161. #if defined key_traldf_c3d && defined key_traldf_smag
  162. CALL ldf_tra_smag( kstp ) ! eddy induced velocity coefficient
  163. # endif
  164. #if defined key_dynldf_c3d && defined key_dynldf_smag
  165. CALL ldf_dyn_smag( kstp ) ! eddy induced velocity coefficient
  166. # endif
  167. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  168. ! Ocean dynamics : hdiv, rot, ssh, e3, wn
  169. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  170. CALL ssh_nxt ( kstp ) ! after ssh (includes call to div_cur)
  171. IF( lk_vvl ) CALL dom_vvl_sf_nxt( kstp ) ! after vertical scale factors
  172. CALL wzv ( kstp ) ! now cross-level velocity
  173. IF( lk_dynspg_ts ) THEN
  174. ! In case the time splitting case, update almost all momentum trends here:
  175. ! Note that the computation of vertical velocity above, hence "after" sea level
  176. ! is necessary to compute momentum advection for the rhs of barotropic loop:
  177. CALL eos ( tsn, rhd, rhop, fsdept_n(:,:,:) ) ! now in situ density for hpg computation
  178. IF( ln_zps .AND. .NOT. ln_isfcav) &
  179. & CALL zps_hde ( kstp, jpts, tsn, gtsu, gtsv, & ! Partial steps: before horizontal gradient
  180. & rhd, gru , grv ) ! of t, s, rd at the last ocean level
  181. IF( ln_zps .AND. ln_isfcav) &
  182. & CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv, & ! Partial steps for top cell (ISF)
  183. & rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv , &
  184. & gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi ) ! of t, s, rd at the last ocean level
  185. ua(:,:,:) = 0.e0 ! set dynamics trends to zero
  186. va(:,:,:) = 0.e0
  187. IF( lk_asminc .AND. ln_asmiau .AND. &
  188. & ln_dyninc ) CALL dyn_asm_inc ( kstp ) ! apply dynamics assimilation increment
  189. IF( ln_neptsimp ) CALL dyn_nept_cor ( kstp ) ! subtract Neptune velocities (simplified)
  190. IF( lk_bdy ) CALL bdy_dyn3d_dmp( kstp ) ! bdy damping trends
  191. CALL dyn_adv ( kstp ) ! advection (vector or flux form)
  192. CALL dyn_vor ( kstp ) ! vorticity term including Coriolis
  193. CALL dyn_ldf ( kstp ) ! lateral mixing
  194. IF( ln_neptsimp ) CALL dyn_nept_cor ( kstp ) ! add Neptune velocities (simplified)
  195. #if defined key_agrif
  196. IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_dyn ! momentum sponge
  197. #endif
  198. CALL dyn_hpg( kstp ) ! horizontal gradient of Hydrostatic pressure
  199. CALL dyn_spg( kstp, indic ) ! surface pressure gradient
  200. ua_sv(:,:,:) = ua(:,:,:) ! Save trends (barotropic trend has been fully updated at this stage)
  201. va_sv(:,:,:) = va(:,:,:)
  202. CALL div_cur( kstp ) ! Horizontal divergence & Relative vorticity (2nd call in time-split case)
  203. IF( lk_vvl ) CALL dom_vvl_sf_nxt( kstp, kcall=2 ) ! after vertical scale factors (update depth average component)
  204. CALL wzv ( kstp ) ! now cross-level velocity
  205. ENDIF
  206. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  207. ! diagnostics and outputs (ua, va, tsa used as workspace)
  208. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  209. IF( lk_floats ) CALL flo_stp( kstp ) ! drifting Floats
  210. IF( lk_diahth ) CALL dia_hth( kstp ) ! Thermocline depth (20 degres isotherm depth)
  211. IF( .NOT. ln_cpl ) CALL dia_fwb( kstp ) ! Fresh water budget diagnostics
  212. IF( lk_diadct ) CALL dia_dct( kstp ) ! Transports
  213. IF( lk_diaar5 ) CALL dia_ar5( kstp ) ! ar5 diag
  214. IF( lk_diaharm ) CALL dia_harm( kstp ) ! Tidal harmonic analysis
  215. CALL dia_prod( kstp ) ! ocean model: product diagnostics
  216. CALL dia_wri( kstp ) ! ocean model: outputs
  217. !
  218. IF( ln_crs ) CALL crs_fld( kstp ) ! ocean model: online field coarsening & output
  219. #if defined key_top
  220. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  221. ! Passive Tracer Model
  222. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  223. CALL trc_stp( kstp ) ! time-stepping
  224. #endif
  225. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  226. ! Active tracers (ua, va used as workspace)
  227. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  228. tsa(:,:,:,:) = 0.e0 ! set tracer trends to zero
  229. IF( lk_asminc .AND. ln_asmiau .AND. &
  230. & ln_trainc ) CALL tra_asm_inc( kstp ) ! apply tracer assimilation increment
  231. CALL tra_sbc ( kstp ) ! surface boundary condition
  232. IF( ln_traqsr ) CALL tra_qsr ( kstp ) ! penetrative solar radiation qsr
  233. IF( ln_trabbc ) CALL tra_bbc ( kstp ) ! bottom heat flux
  234. IF( lk_trabbl ) CALL tra_bbl ( kstp ) ! advective (and/or diffusive) bottom boundary layer scheme
  235. IF( ln_tradmp ) CALL tra_dmp ( kstp ) ! internal damping trends
  236. IF( lk_bdy ) CALL bdy_tra_dmp( kstp ) ! bdy damping trends
  237. CALL tra_adv ( kstp ) ! horizontal & vertical advection
  238. IF( lk_zdfkpp ) CALL tra_kpp ( kstp ) ! KPP non-local tracer fluxes
  239. CALL tra_ldf ( kstp ) ! lateral mixing
  240. IF( ln_diaptr ) CALL dia_ptr ! Poleward adv/ldf TRansports diagnostics
  241. #if defined key_agrif
  242. IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra ! tracers sponge
  243. #endif
  244. CALL tra_zdf ( kstp ) ! vertical mixing and after tracer fields
  245. IF( ln_dynhpg_imp ) THEN ! semi-implicit hpg (time stepping then eos)
  246. IF( ln_zdfnpc ) CALL tra_npc( kstp ) ! update after fields by non-penetrative convection
  247. CALL tra_nxt( kstp ) ! tracer fields at next time step
  248. CALL eos ( tsa, rhd, rhop, fsdept_n(:,:,:) ) ! Time-filtered in situ density for hpg computation
  249. IF( ln_zps .AND. .NOT. ln_isfcav) &
  250. & CALL zps_hde ( kstp, jpts, tsa, gtsu, gtsv, & ! Partial steps: before horizontal gradient
  251. & rhd, gru , grv ) ! of t, s, rd at the last ocean level
  252. IF( ln_zps .AND. ln_isfcav) &
  253. & CALL zps_hde_isf( kstp, jpts, tsa, gtsu, gtsv, & ! Partial steps for top cell (ISF)
  254. & rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv , &
  255. & gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi ) ! of t, s, rd at the last ocean level
  256. ELSE ! centered hpg (eos then time stepping)
  257. IF ( .NOT. lk_dynspg_ts ) THEN ! eos already called in time-split case
  258. CALL eos ( tsn, rhd, rhop, fsdept_n(:,:,:) ) ! now in situ density for hpg computation
  259. IF( ln_zps .AND. .NOT. ln_isfcav) &
  260. & CALL zps_hde ( kstp, jpts, tsn, gtsu, gtsv, & ! Partial steps: before horizontal gradient
  261. & rhd, gru , grv ) ! of t, s, rd at the last ocean level
  262. IF( ln_zps .AND. ln_isfcav) &
  263. & CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv, & ! Partial steps for top cell (ISF)
  264. & rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv , &
  265. & gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi ) ! of t, s, rd at the last ocean level
  266. ENDIF
  267. IF( ln_zdfnpc ) CALL tra_npc( kstp ) ! update after fields by non-penetrative convection
  268. CALL tra_nxt( kstp ) ! tracer fields at next time step
  269. ENDIF
  270. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  271. ! Dynamics (tsa used as workspace)
  272. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  273. IF( lk_dynspg_ts ) THEN
  274. ! revert to previously computed momentum tendencies
  275. ! (not using ua, va as temporary arrays during tracers' update could avoid that)
  276. ua(:,:,:) = ua_sv(:,:,:)
  277. va(:,:,:) = va_sv(:,:,:)
  278. ! Revert now divergence and rotational to previously computed ones
  279. !(needed because of the time swap in div_cur, at the beginning of each time step)
  280. hdivn(:,:,:) = hdivb(:,:,:)
  281. rotn(:,:,:) = rotb(:,:,:)
  282. CALL dyn_bfr( kstp ) ! bottom friction
  283. CALL dyn_zdf( kstp ) ! vertical diffusion
  284. ELSE
  285. ua(:,:,:) = 0.e0 ! set dynamics trends to zero
  286. va(:,:,:) = 0.e0
  287. IF( lk_asminc .AND. ln_asmiau .AND. &
  288. & ln_dyninc ) CALL dyn_asm_inc( kstp ) ! apply dynamics assimilation increment
  289. IF( ln_bkgwri ) CALL asm_bkg_wri( kstp ) ! output background fields
  290. IF( ln_neptsimp ) CALL dyn_nept_cor( kstp ) ! subtract Neptune velocities (simplified)
  291. IF( lk_bdy ) CALL bdy_dyn3d_dmp(kstp ) ! bdy damping trends
  292. CALL dyn_adv( kstp ) ! advection (vector or flux form)
  293. CALL dyn_vor( kstp ) ! vorticity term including Coriolis
  294. CALL dyn_ldf( kstp ) ! lateral mixing
  295. IF( ln_neptsimp ) CALL dyn_nept_cor( kstp ) ! add Neptune velocities (simplified)
  296. #if defined key_agrif
  297. IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_dyn ! momemtum sponge
  298. #endif
  299. CALL dyn_hpg( kstp ) ! horizontal gradient of Hydrostatic pressure
  300. CALL dyn_bfr( kstp ) ! bottom friction
  301. CALL dyn_zdf( kstp ) ! vertical diffusion
  302. CALL dyn_spg( kstp, indic ) ! surface pressure gradient
  303. ENDIF
  304. CALL dyn_nxt( kstp ) ! lateral velocity at next time step
  305. CALL ssh_swp( kstp ) ! swap of sea surface height
  306. IF( lk_vvl ) CALL dom_vvl_sf_swp( kstp ) ! swap of vertical scale factors
  307. !
  308. IF( ln_diahsb ) CALL dia_hsb( kstp ) ! - ML - global conservation diagnostics
  309. IF( lrst_oce ) CALL rst_write( kstp ) ! write output ocean restart file
  310. IF( ln_sto_eos ) CALL sto_rst_write( kstp ) ! write restart file for stochastic parameters
  311. #if defined key_agrif
  312. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  313. ! AGRIF
  314. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  315. CALL Agrif_Integrate_ChildGrids( stp )
  316. IF ( Agrif_NbStepint().EQ.0 ) THEN
  317. CALL Agrif_Update_Tra() ! Update active tracers
  318. CALL Agrif_Update_Dyn() ! Update momentum
  319. ENDIF
  320. #endif
  321. IF( lk_diaobs ) CALL dia_obs( kstp ) ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
  322. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  323. ! Control
  324. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  325. CALL stp_ctl( kstp, indic )
  326. IF( indic < 0 ) THEN
  327. CALL ctl_stop( 'step: indic < 0' )
  328. CALL dia_wri_state( 'output.abort', kstp )
  329. ENDIF
  330. IF( kstp == nit000 ) THEN
  331. CALL iom_close( numror ) ! close input ocean restart file
  332. IF(lwm) CALL FLUSH ( numond ) ! flush output namelist oce
  333. IF( lwm.AND.numoni /= -1 ) CALL FLUSH ( numoni ) ! flush output namelist ice
  334. ENDIF
  335. !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  336. ! Coupled mode
  337. !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  338. IF( lk_oasis ) CALL sbc_cpl_snd( kstp ) ! coupled mode : field exchanges
  339. !
  340. #if defined key_iomput
  341. IF( kstp == nitend .OR. indic < 0 ) THEN
  342. CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF
  343. IF( ln_crs ) CALL iom_context_finalize( trim(cxios_context)//"_crs" ) !
  344. ENDIF
  345. #endif
  346. !
  347. IF( nn_timing == 1 .AND. kstp == nit000 ) CALL timing_reset
  348. !
  349. !
  350. END SUBROUTINE stp
  351. !!======================================================================
  352. END MODULE step