MODULE step !!====================================================================== !! *** MODULE step *** !! Time-stepping : manager of the ocean, tracer and ice time stepping !!====================================================================== !! History : OPA ! 1991-03 (G. Madec) Original code !! - ! 1991-11 (G. Madec) !! - ! 1992-06 (M. Imbard) add a first output record !! - ! 1996-04 (G. Madec) introduction of dynspg !! - ! 1996-04 (M.A. Foujols) introduction of passive tracer !! 8.0 ! 1997-06 (G. Madec) new architecture of call !! 8.2 ! 1997-06 (G. Madec, M. Imbard, G. Roullet) free surface !! - ! 1999-02 (G. Madec, N. Grima) hpg implicit !! - ! 2000-07 (J-M Molines, M. Imbard) Open Bondary Conditions !! NEMO 1.0 ! 2002-06 (G. Madec) free form, suppress macro-tasking !! - ! 2004-08 (C. Talandier) New trends organization !! - ! 2005-01 (C. Ethe) Add the KPP closure scheme !! - ! 2005-11 (G. Madec) Reorganisation of tra and dyn calls !! - ! 2006-01 (L. Debreu, C. Mazauric) Agrif implementation !! - ! 2006-07 (S. Masson) restart using iom !! 3.2 ! 2009-02 (G. Madec, R. Benshila) reintroduicing z*-coordinate !! - ! 2009-06 (S. Masson, G. Madec) TKE restart compatible with key_cpl !! 3.3 ! 2010-05 (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface !! - ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase + merge TRC-TRA !! 3.4 ! 2011-04 (G. Madec, C. Ethe) Merge of dtatem and dtasal !! 3.6 ! 2012-07 (J. Simeon, G. Madec. C. Ethe) Online coarsening of outputs !! 3.6 ! 2014-04 (F. Roquet, G. Madec) New equations of state !! 3.6 ! 2014-10 (E. Clementi, P. Oddo) Add Qiao vertical mixing in case of waves !! 3.7 ! 2014-10 (G. Madec) LDF simplication !! - ! 2014-12 (G. Madec) remove KPP scheme !! - ! 2015-11 (J. Chanut) free surface simplification (remove filtered free surface) !! 4.0 ! 2017-05 (G. Madec) introduction of the vertical physics manager (zdfphy) !! 4.1 ! 2019-08 (A. Coward, D. Storkey) rewrite in preparation for new timestepping scheme !!---------------------------------------------------------------------- #if defined key_qco !!---------------------------------------------------------------------- !! 'key_qco' EMPTY MODULE Quasi-Eulerian vertical coordonate !!---------------------------------------------------------------------- #else !!---------------------------------------------------------------------- !! stp : OCE system time-stepping !!---------------------------------------------------------------------- USE step_oce ! time stepping definition modules ! USE iom ! xIOs server IMPLICIT NONE PRIVATE PUBLIC stp ! called by nemogcm.F90 !!---------------------------------------------------------------------- !! time level indices !!---------------------------------------------------------------------- INTEGER, PUBLIC :: Nbb, Nnn, Naa, Nrhs !! used by nemo_init !!---------------------------------------------------------------------- !! NEMO/OCE 4.0 , NEMO Consortium (2018) !! $Id: step.F90 13237 2020-07-03 09:12:53Z smasson $ !! Software governed by the CeCILL license (see ./LICENSE) !!---------------------------------------------------------------------- CONTAINS #if defined key_agrif RECURSIVE SUBROUTINE stp( ) INTEGER :: kstp ! ocean time-step index #else SUBROUTINE stp( kstp ) INTEGER, INTENT(in) :: kstp ! ocean time-step index #endif !!---------------------------------------------------------------------- !! *** ROUTINE stp *** !! !! ** Purpose : - Time stepping of OCE (momentum and active tracer eqs.) !! - Time stepping of SI3 (dynamic and thermodynamic eqs.) !! - Time stepping of TRC (passive tracer eqs.) !! !! ** Method : -1- Update forcings and data !! -2- Update ocean physics !! -3- Compute the t and s trends !! -4- Update t and s !! -5- Compute the momentum trends !! -6- Update the horizontal velocity !! -7- Compute the diagnostics variables (rd,N2, hdiv,w) !! -8- Outputs and diagnostics !!---------------------------------------------------------------------- INTEGER :: ji, jj, jk ! dummy loop indice !!gm kcall can be removed, I guess INTEGER :: kcall ! optional integer argument (dom_vvl_sf_nxt) !! --------------------------------------------------------------------- #if defined key_agrif IF( nstop > 0 ) RETURN ! avoid to go further if an error was detected during previous time step (child grid) kstp = nit000 + Agrif_Nb_Step() Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs ! agrif_oce module copies of time level indices IF( lk_agrif_debug ) THEN IF( Agrif_Root() .and. lwp) WRITE(*,*) '---' IF(lwp) WRITE(*,*) 'Grid Number', Agrif_Fixed(),' time step ', kstp, 'int tstep', Agrif_NbStepint() ENDIF IF( kstp == nit000 + 1 ) lk_agrif_fstep = .FALSE. # if defined key_xios IF( Agrif_Nbstepint() == 0 ) CALL iom_swap( cxios_context ) # endif #endif ! IF( ln_timing ) CALL timing_start('stp') ! !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ! model timestep !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ! IF( l_1st_euler ) THEN ! start or restart with Euler 1st time-step rDt = rn_Dt r1_Dt = 1._wp / rDt ENDIF ! !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ! update I/O and calendar !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< IF( kstp == nit000 ) THEN ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS) CALL iom_init( cxios_context, ld_closedef=.FALSE. ) ! for model grid (including possible AGRIF zoom) IF( lk_diamlr ) CALL dia_mlr_iom_init ! with additional setup for multiple-linear-regression analysis CALL iom_init_closedef IF( ln_crs ) CALL iom_init( TRIM(cxios_context)//"_crs" ) ! for coarse grid ENDIF IF( kstp /= nit000 ) CALL day( kstp ) ! Calendar (day was already called at nit000 in day_init) CALL iom_setkt( kstp - nit000 + 1, cxios_context ) ! tell IOM we are at time step kstp !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ! Update external forcing (tides, open boundaries, ice shelf interaction and surface boundary condition (including sea-ice) !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< CALL sbc ( kstp, Nbb, Nnn ) ! Sea Boundary Condition (including sea-ice) CALL dia_wri ( kstp, Nnn ) ! ocean model: outputs !!gm : This does not only concern the dynamics ==>>> add a new title !!gm2: why ouput restart before AGRIF update? !! !!jc: That would be better, but see comment above !! IF( lrst_oce ) CALL rst_write ( kstp, Nbb, Nnn ) ! write output ocean restart file !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ! File manipulation at the end of the first time step !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< IF( kstp == nit000 ) THEN ! 1st time step only CALL iom_close( numror ) ! close input ocean restart file IF(lwm) CALL FLUSH ( numond ) ! flush output namelist oce IF(lwm .AND. numoni /= -1 ) CALL FLUSH ( numoni ) ! flush output namelist ice (if exist) ENDIF ! #if defined key_xios !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ! Finalize contextes if end of simulation or error detected !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< IF( kstp == nitend .OR. nstop > 0 ) THEN CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF IF( lrxios ) CALL iom_context_finalize( crxios_context ) IF( ln_crs ) CALL iom_context_finalize( trim(cxios_context)//"_crs" ) ! ENDIF #endif ! IF( l_1st_euler ) THEN ! recover Leap-frog timestep rDt = 2._wp * rn_Dt r1_Dt = 1._wp / rDt l_1st_euler = .FALSE. ENDIF ! IF( ln_timing ) CALL timing_stop('stp') ! END SUBROUTINE stp ! #endif !!====================================================================== END MODULE step