New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
step.F90 in NEMO/trunk/tests/ICB/MY_SRC – NEMO

source: NEMO/trunk/tests/ICB/MY_SRC/step.F90 @ 14239

Last change on this file since 14239 was 14239, checked in by smasson, 3 years ago

trunk: replace key_iomput by key_xios

File size: 9.4 KB
Line 
1MODULE 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   !!            3.6  !  2012-07  (J. Simeon, G. Madec. C. Ethe)  Online coarsening of outputs
27   !!            3.6  !  2014-04  (F. Roquet, G. Madec) New equations of state
28   !!            3.6  !  2014-10  (E. Clementi, P. Oddo) Add Qiao vertical mixing in case of waves
29   !!            3.7  !  2014-10  (G. Madec)  LDF simplication
30   !!             -   !  2014-12  (G. Madec) remove KPP scheme
31   !!             -   !  2015-11  (J. Chanut) free surface simplification (remove filtered free surface)
32   !!            4.0  !  2017-05  (G. Madec)  introduction of the vertical physics manager (zdfphy)
33   !!            4.1  !  2019-08  (A. Coward, D. Storkey) rewrite in preparation for new timestepping scheme
34   !!----------------------------------------------------------------------
35#if defined key_qco
36   !!----------------------------------------------------------------------
37   !!   'key_qco'      EMPTY MODULE      Quasi-Eulerian vertical coordonate
38   !!----------------------------------------------------------------------
39#else
40   !!----------------------------------------------------------------------
41   !!   stp             : OCE system time-stepping
42   !!----------------------------------------------------------------------
43   USE step_oce         ! time stepping definition modules
44   !
45   USE iom              ! xIOs server
46
47   IMPLICIT NONE
48   PRIVATE
49
50   PUBLIC   stp   ! called by nemogcm.F90
51
52   !!----------------------------------------------------------------------
53   !! time level indices
54   !!----------------------------------------------------------------------
55   INTEGER, PUBLIC :: Nbb, Nnn, Naa, Nrhs          !! used by nemo_init
56
57   !!----------------------------------------------------------------------
58   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
59   !! $Id: step.F90 13237 2020-07-03 09:12:53Z smasson $
60   !! Software governed by the CeCILL license (see ./LICENSE)
61   !!----------------------------------------------------------------------
62CONTAINS
63
64#if defined key_agrif
65   RECURSIVE SUBROUTINE stp( )
66      INTEGER             ::   kstp   ! ocean time-step index
67#else
68   SUBROUTINE stp( kstp )
69      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
70#endif
71      !!----------------------------------------------------------------------
72      !!                     ***  ROUTINE stp  ***
73      !!
74      !! ** Purpose : - Time stepping of OCE  (momentum and active tracer eqs.)
75      !!              - Time stepping of SI3 (dynamic and thermodynamic eqs.)
76      !!              - Time stepping of TRC  (passive tracer eqs.)
77      !!
78      !! ** Method  : -1- Update forcings and data
79      !!              -2- Update ocean physics
80      !!              -3- Compute the t and s trends
81      !!              -4- Update t and s
82      !!              -5- Compute the momentum trends
83      !!              -6- Update the horizontal velocity
84      !!              -7- Compute the diagnostics variables (rd,N2, hdiv,w)
85      !!              -8- Outputs and diagnostics
86      !!----------------------------------------------------------------------
87      INTEGER ::   ji, jj, jk   ! dummy loop indice
88!!gm kcall can be removed, I guess
89      INTEGER ::   kcall        ! optional integer argument (dom_vvl_sf_nxt)
90      !! ---------------------------------------------------------------------
91#if defined key_agrif
92      IF( nstop > 0 ) RETURN   ! avoid to go further if an error was detected during previous time step (child grid)
93      kstp = nit000 + Agrif_Nb_Step()
94      Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices
95      IF( lk_agrif_debug ) THEN
96         IF( Agrif_Root() .and. lwp)   WRITE(*,*) '---'
97         IF(lwp)   WRITE(*,*) 'Grid Number', Agrif_Fixed(),' time step ', kstp, 'int tstep', Agrif_NbStepint()
98      ENDIF
99      IF( kstp == nit000 + 1 )   lk_agrif_fstep = .FALSE.
100# if defined key_xios
101      IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context )
102# endif
103#endif
104      !
105      IF( ln_timing )   CALL timing_start('stp')
106      !
107      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
108      ! model timestep
109      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
110      !
111      IF( l_1st_euler ) THEN 
112         ! start or restart with Euler 1st time-step
113         rDt =  rn_Dt   
114         r1_Dt = 1._wp / rDt
115      ENDIF
116      !
117      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
118      ! update I/O and calendar
119      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
120      IF( kstp == nit000 ) THEN                       ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS)
121                             CALL iom_init( cxios_context, ld_closedef=.FALSE. )   ! for model grid (including possible AGRIF zoom)
122         IF( lk_diamlr   )   CALL dia_mlr_iom_init    ! with additional setup for multiple-linear-regression analysis
123                             CALL iom_init_closedef
124         IF( ln_crs      )   CALL iom_init( TRIM(cxios_context)//"_crs" )  ! for coarse grid
125      ENDIF
126      IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
127                             CALL iom_setkt( kstp - nit000 + 1,      cxios_context          )   ! tell IOM we are at time step kstp
128
129      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
130      ! Update external forcing (tides, open boundaries, ice shelf interaction and surface boundary condition (including sea-ice)
131      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
132                         CALL sbc     ( kstp, Nbb, Nnn )              ! Sea Boundary Condition (including sea-ice)
133
134                         CALL dia_wri   ( kstp,      Nnn )      ! ocean model: outputs
135
136!!gm : This does not only concern the dynamics ==>>> add a new title
137!!gm2: why ouput restart before AGRIF update?
138!!
139!!jc: That would be better, but see comment above
140!!
141      IF( lrst_oce   )   CALL rst_write    ( kstp, Nbb, Nnn )   ! write output ocean restart file
142
143      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
144      ! File manipulation at the end of the first time step
145      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<                         
146      IF( kstp == nit000 ) THEN                          ! 1st time step only
147                                        CALL iom_close( numror )   ! close input  ocean restart file
148         IF(lwm)                        CALL FLUSH    ( numond )   ! flush output namelist oce
149         IF(lwm .AND. numoni /= -1 )    CALL FLUSH    ( numoni )   ! flush output namelist ice (if exist)
150      ENDIF
151      !
152#if defined key_xios
153      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
154      ! Finalize contextes if end of simulation or error detected
155      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<                         
156      IF( kstp == nitend .OR. nstop > 0 ) THEN
157                      CALL iom_context_finalize(      cxios_context          ) ! needed for XIOS+AGRIF
158         IF( lrxios ) CALL iom_context_finalize(      crxios_context         )
159         IF( ln_crs ) CALL iom_context_finalize( trim(cxios_context)//"_crs" ) !
160      ENDIF
161#endif
162      !
163      IF( l_1st_euler ) THEN         ! recover Leap-frog timestep
164         rDt = 2._wp * rn_Dt   
165         r1_Dt = 1._wp / rDt
166         l_1st_euler = .FALSE.     
167      ENDIF
168      !
169      IF( ln_timing )   CALL timing_stop('stp')
170      !
171   END SUBROUTINE stp
172   !
173#endif
174   !!======================================================================
175END MODULE step
Note: See TracBrowser for help on using the repository browser.