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/branches/2020/dev_12905_xios_restart/src/SAS – NEMO

source: NEMO/branches/2020/dev_12905_xios_restart/src/SAS/step.F90 @ 12977

Last change on this file since 12977 was 12977, checked in by andmirek, 4 years ago

Ticket #2462 read restart with XIOS in SAS

  • Property svn:keywords set to Id
File size: 8.5 KB
Line 
1MODULE step
2   !!======================================================================
3   !!                       ***  MODULE step  ***
4   !! Time-stepping    : manager of the ocean, tracer and ice time stepping
5   !!                    version for standalone surface scheme
6   !!======================================================================
7   !! History :  OPA  !  1991-03  (G. Madec)  Original code
8   !!             .   !    .                                                     
9   !!             .   !    .                                                     
10   !!   NEMO     3.5  !  2012-03  (S. Alderson)
11   !!----------------------------------------------------------------------
12
13   !!----------------------------------------------------------------------
14   !!   stp             : OPA system time-stepping
15   !!----------------------------------------------------------------------
16   USE oce              ! ocean dynamics and tracers variables
17   USE dom_oce          ! ocean space and time domain variables
18   USE daymod           ! calendar                         (day     routine)
19   USE sbc_oce          ! surface boundary condition: fields
20   USE sbcmod           ! surface boundary condition       (sbc     routine)
21   USE sbcrnf           ! surface boundary condition: runoff variables
22   USE sbccpl           ! surface boundary condition: coupled interface
23   USE eosbn2           ! equation of state                (eos_bn2 routine)
24   USE diawri           ! Standard run outputs             (dia_wri routine)
25   USE bdy_oce   , ONLY: ln_bdy
26   USE bdydta           ! mandatory for sea-ice
27   USE stpctl           ! time stepping control            (stp_ctl routine)
28   !
29   USE in_out_manager   ! I/O manager
30   USE prtctl           ! Print control                    (prt_ctl routine)
31   USE iom              !
32   USE lbclnk           !
33   USE timing           ! Timing           
34#if defined key_iomput
35   USE xios
36#endif
37
38#if defined key_agrif
39   USE agrif_oce, ONLY: lk_agrif_debug
40#if defined key_si3
41   USE agrif_ice_update
42#endif
43#endif
44   
45   IMPLICIT NONE
46   PRIVATE
47
48   PUBLIC   stp   ! called by nemogcm.F90
49
50   !!----------------------------------------------------------------------
51   !! time level indices
52   !!----------------------------------------------------------------------
53   INTEGER, PUBLIC :: Nbb, Nnn, Naa, Nrhs          !! used by nemo_init
54   !!----------------------------------------------------------------------
55   !! NEMO/SAS 4.0 , NEMO Consortium (2018)
56   !! $Id$
57   !! Software governed by the CeCILL license (see ./LICENSE)
58   !!----------------------------------------------------------------------
59CONTAINS
60
61#if defined key_agrif
62   RECURSIVE SUBROUTINE stp( )
63      INTEGER             ::   kstp   ! ocean time-step index
64#else
65   SUBROUTINE stp( kstp )
66      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
67#endif
68      !!----------------------------------------------------------------------
69      !!                     ***  ROUTINE stp  ***
70      !!                     
71      !! ** Purpose : - Time stepping of SBC (surface boundary)
72      !!
73      !! ** Method  : -1- Update forcings and data 
74      !!              -2- Outputs and diagnostics
75      !!----------------------------------------------------------------------
76      INTEGER ::   indic    ! error indicator if < 0
77      !! ---------------------------------------------------------------------
78
79#if defined key_agrif
80      IF( nstop > 0 ) return   ! avoid to go further if an error was detected during previous time step
81      kstp = nit000 + Agrif_Nb_Step()
82      Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices
83      IF ( lk_agrif_debug ) THEN
84         IF ( Agrif_Root() .and. lwp) Write(*,*) '---'
85         IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp, 'int tstep',Agrif_NbStepint()
86      ENDIF
87
88      IF ( kstp == (nit000 + 1) ) lk_agrif_fstep = .FALSE.
89
90# if defined key_iomput
91      IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context )
92# endif   
93#endif   
94                             indic = 0                    ! although indic is not changed in stp_ctl
95                                                          ! need to keep the same interface
96      IF( kstp == nit000 )   CALL iom_init( cxios_context ) ! iom_put initialization (must be done after nemo_init for AGRIF+XIOS+OASIS)
97                             CALL iom_setkt( kstp - nit000 + 1, cxios_context )   ! tell iom we are at time step kstp
98      IF((kstp == nitrst) .AND. lwxios) THEN
99         CALL iom_swap(      cwxios_context          )
100         CALL iom_init_closedef(cwxios_context)
101         CALL iom_setkt( kstp - nit000 + 1,      cwxios_context          )
102#if defined key_top
103         CALL iom_swap(      cwtxios_context          )
104         CALL iom_init_closedef(cwtxios_context)
105         CALL iom_setkt( kstp - nit000 + 1,      cwtxios_context          )
106#endif
107      ENDIF
108      IF( kstp /= nit000 )   CALL day( kstp )             ! Calendar (day was already called at nit000 in day_init)
109
110#if defined key_si3
111      IF(((kstp + nn_fsbc - 1) == nitrst) .AND. lwxios) THEN
112         CALL iom_swap(      cwixios_context          )
113         CALL iom_init_closedef(cwixios_context)
114         CALL iom_setkt( kstp - nit000 + 1,      cwixios_context          )
115      ENDIF
116#endif
117
118      ! ==> clem: open boundaries is mandatory for sea-ice because ice BDY is not decoupled from 
119      !           the environment of ocean BDY. Therefore bdy is called in both OPA and SAS modules.
120      !           From SAS: ocean bdy data are wrong  (but we do not care) and ice bdy data are OK. 
121      !           This is not clean and should be changed in the future.
122      ! ==>
123      IF( ln_bdy     )       CALL bdy_dta( kstp,      Nnn )                   ! update dynamic & tracer data at open boundaries
124                             CALL sbc    ( kstp, Nbb, Nnn )                   ! Sea Boundary Condition (including sea-ice)
125
126                             CALL dia_wri( kstp,      Nnn )                   ! ocean model: outputs
127
128#if defined key_agrif
129      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
130      ! AGRIF recursive integration
131      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<     
132                             CALL Agrif_Integrate_ChildGrids( stp ) 
133#endif
134                             
135      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
136      ! Control
137      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
138                             CALL stp_ctl( kstp, indic )
139      IF( indic < 0  )  THEN
140                             CALL ctl_stop( 'step: indic < 0' )
141                             CALL dia_wri_state( Nnn, 'output.abort' )
142      ENDIF
143#if defined key_agrif
144      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
145      ! AGRIF update
146      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<     
147      IF( Agrif_NbStepint() == 0 .AND. nstop == 0 ) THEN                       ! AGRIF Update from zoom N to zoom 1 then to Parent
148#if defined key_si3
149                             CALL Agrif_Update_ice( )   ! update sea-ice
150#endif
151      ENDIF
152#endif
153      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
154      ! File manipulation at the end of the first time step
155      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<                         
156      IF( kstp == nit000   ) THEN
157            CALL iom_close( numror )                          ! close input  ocean restart file
158            IF( lroxios )     CALL iom_context_finalize(      crxios_context      )
159      ENDIF
160     
161      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
162      ! Coupled mode
163      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
164      IF( lk_oasis    )  CALL sbc_cpl_snd( kstp, Nbb, Nnn )     ! coupled mode : field exchanges if OASIS-coupled ice
165
166#if defined key_iomput
167      IF( kstp == nitrst ) THEN
168         IF(.NOT.lwxios) THEN
169            CALL iom_close( numrow )     
170         ELSE
171            CALL iom_context_finalize( cwxios_context )
172         ENDIF
173         lrst_oce = .FALSE.
174      ENDIF
175      IF( kstp == nitend .OR. indic < 0 ) THEN
176                             CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF
177      ENDIF
178#endif
179      !
180      IF( ln_timing .AND.  kstp == nit000  )   CALL timing_reset
181      !
182   END SUBROUTINE stp
183
184   !!======================================================================
185END MODULE step
Note: See TracBrowser for help on using the repository browser.