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 branches/DEV_r2006_merge_TRA_TRC/NEMO/OPA_SRC – NEMO

source: branches/DEV_r2006_merge_TRA_TRC/NEMO/OPA_SRC/step.F90 @ 2027

Last change on this file since 2027 was 2027, checked in by cetlod, 14 years ago

Reorganisation of the initialisation phase, see ticket:695

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 15.3 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   !!----------------------------------------------------------------------
24
25   !!----------------------------------------------------------------------
26   !!   stp            : OPA system time-stepping
27   !!----------------------------------------------------------------------
28   USE step_oce         ! time stepping definition modules
29
30   IMPLICIT NONE
31   PRIVATE
32
33   PUBLIC   stp        ! called by opa.F90
34
35   !! * Substitutions
36#  include "domzgr_substitute.h90"
37#  include "zdfddm_substitute.h90"
38   !!----------------------------------------------------------------------
39   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
40   !! $Id$
41   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
42   !!----------------------------------------------------------------------
43
44CONTAINS
45
46#if defined key_agrif
47   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      !! ---------------------------------------------------------------------
72
73#if defined key_agrif
74      kstp = nit000 + Agrif_Nb_Step()
75!      IF( Agrif_Root() .and. lwp) Write(*,*) '---'
76!      IF(lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp
77# if defined key_iomput
78      IF( Agrif_Nbstepint() == 0) CALL iom_swap
79# endif   
80#endif   
81      indic = 1                                       ! reset to no error condition
82
83      IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
84
85      CALL iom_setkt( kstp )                          ! say to iom that we are at time step kstp
86     
87      CALL rst_opn( kstp )                            ! Open the restart file
88
89      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
90      ! Update data, open boundaries, surface boundary condition (including sea-ice)
91      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
92      IF( lk_dtatem  )   CALL dta_tem( kstp )         ! update 3D temperature data
93      IF( lk_dtasal  )   CALL dta_sal( kstp )         ! update 3D salinity data
94                         CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice)
95      IF( lk_obc     )   CALL obc_dta( kstp )         ! update dynamic and tracer data at open boundaries
96      IF( lk_obc     )   CALL obc_rad( kstp )         ! compute phase velocities at open boundaries
97      IF( lk_bdy     )   CALL bdy_dta( kstp )         ! update dynamic and tracer data at unstructured open boundary
98
99      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
100      !  Ocean dynamics : ssh, wn, hdiv, rot                                 !
101      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
102                         CALL ssh_wzv( kstp )         ! after ssh & vertical velocity
103
104      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
105      ! Ocean physics update                (ua, va, ta, sa used as workspace)
106      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
107                         CALL bn2( tb, sb, rn2b )     ! before Brunt-Vaisala frequency
108                         CALL bn2( tn, sn, rn2  )     ! now    Brunt-Vaisala frequency
109      !
110      !  VERTICAL PHYSICS   
111                         CALL zdf_bfr( kstp )         ! bottom friction
112      !                                               ! Vertical eddy viscosity and diffusivity coefficients
113      IF( lk_zdfric     )   CALL zdf_ric    ( kstp )  ! Richardson number dependent Kz
114      IF( lk_zdftke_old )   CALL zdf_tke_old( kstp )  ! TKE closure scheme for Kz (old scheme)
115      IF( lk_zdftke     )   CALL zdf_tke    ( kstp )  ! TKE closure scheme for Kz
116      IF( lk_zdfkpp     )   CALL zdf_kpp    ( kstp )  ! KPP closure scheme for Kz
117      IF( lk_zdfcst     )   THEN                      ! Constant Kz (reset avt, avm[uv] to the background value)
118         avt (:,:,:) = rn_avt0 * tmask(:,:,:)
119         avmu(:,:,:) = rn_avm0 * umask(:,:,:)
120         avmv(:,:,:) = rn_avm0 * vmask(:,:,:)
121      ENDIF
122      IF( ln_rnf_mouth ) THEN                         ! increase diffusivity at rivers mouths
123         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk)   ;   END DO
124      ENDIF
125      IF( ln_zdfevd  )   CALL zdf_evd( kstp )         ! enhanced vertical eddy diffusivity
126
127      IF( lk_zdftmx  )   CALL zdf_tmx( kstp )         ! tidal vertical mixing
128
129      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
130         &               CALL zdf_ddm( kstp )         ! double diffusive mixing
131                         CALL zdf_mxl( kstp )         ! mixed layer depth
132
133                                                      ! write tke information in the restart file
134      IF( lrst_oce .AND. lk_zdftke )   CALL tke_rst( kstp, 'WRITE' )
135      !
136      !  LATERAL  PHYSICS
137      !
138      IF( lk_ldfslp ) THEN                            ! slope of lateral mixing
139                         CALL eos( tb, sb, rhd )                ! before in situ density
140         IF( ln_zps )    CALL zps_hde( kstp, tb, sb, rhd,  &    ! Partial steps: before horizontal gradient
141            &                              gtu, gsu, gru,  &    ! of t, s, rd at the last ocean level
142            &                              gtv, gsv, grv )
143                         CALL ldf_slp( kstp, rhd, rn2b )        ! before slope of the lateral mixing
144      ENDIF
145#if defined key_traldf_c2d
146      IF( lk_traldf_eiv )   CALL ldf_eiv( kstp )      ! eddy induced velocity coefficient
147#  endif
148
149      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
150      ! diagnostics and outputs             (ua, va, ta, sa used as workspace)
151      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
152      IF( lk_floats  )   CALL flo_stp( kstp )         ! drifting Floats
153      IF( lk_diahth  )   CALL dia_hth( kstp )         ! Thermocline depth (20 degres isotherm depth)
154      IF( lk_diagap  )   CALL dia_gap( kstp )         ! basin averaged diagnostics
155      IF( lk_diahdy  )   CALL dia_hdy( kstp )         ! dynamical heigh diagnostics
156      IF( lk_diafwb  )   CALL dia_fwb( kstp )         ! Fresh water budget diagnostics
157      IF( ln_diaptr  )   CALL dia_ptr( kstp )         ! Poleward TRansports diagnostics
158      IF( lk_diaar5  )   CALL dia_ar5( kstp )         ! ar5 diag
159                         CALL dia_wri( kstp )         ! ocean model: outputs
160
161#if defined key_top
162      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
163      ! Passive Tracer Model
164      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
165                         CALL trc_stp( kstp )         ! time-stepping
166#endif
167
168      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
169      ! Active tracers                              (ua, va used as workspace)
170      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
171                             ta(:,:,:) = 0.e0               ! set tracer trends to zero
172                             sa(:,:,:) = 0.e0
173
174                             CALL tra_swap
175                             CALL tra_sbc    ( kstp )       ! surface boundary condition
176      IF( ln_traqsr      )   CALL tra_qsr    ( kstp )       ! penetrative solar radiation qsr
177      IF( lk_trabbc      )   CALL tra_bbc    ( kstp )       ! bottom heat flux
178      IF( lk_trabbl      )   CALL tra_bbl    ( kstp )       ! advective (and/or diffusive) bottom boundary layer scheme
179      IF( lk_tradmp      )   CALL tra_dmp    ( kstp )       ! internal damping trends
180                             CALL tra_adv    ( kstp )       ! horizontal & vertical advection
181      IF( n_cla == 1     )   CALL tra_cla    ( kstp )       ! Cross Land Advection (Update Hor. advection)
182      IF( lk_zdfkpp )        CALL tra_kpp    ( kstp )       ! KPP non-local tracer fluxes
183                             CALL tra_ldf    ( kstp )       ! lateral mixing
184#if defined key_agrif
185                             CALL tra_unswap
186      IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra          ! tracers sponge
187                             CALL tra_swap
188#endif
189                             CALL tra_zdf    ( kstp )       ! vertical mixing and after tracer fields
190
191      IF( ln_dynhpg_imp  ) THEN                             ! semi-implicit hpg (time stepping then eos)
192         IF( ln_zdfnpc   )   CALL tra_npc    ( kstp )            ! update after fields by non-penetrative convection
193                             CALL tra_nxt    ( kstp )            ! tracer fields at next time step
194                             CALL tra_unswap
195                             CALL eos( ta, sa, rhd, rhop )       ! Time-filtered in situ density for hpg computation
196         IF( ln_zps      )   CALL zps_hde( kstp, ta, sa, rhd,   &   ! Partial steps: time filtered hor. derivative
197            &                                   gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level
198            &                                   gtv, gsv, grv )
199         
200      ELSE                                                  ! centered hpg  (eos then time stepping)
201                             CALL tra_unswap
202                             CALL eos( tn, sn, rhd, rhop )       ! now in situ density for hpg computation
203         IF( ln_zps      )   CALL zps_hde( kstp, tn, sn, rhd,   &   ! Partial steps: now horizontal derivative
204            &                                   gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level
205            &                                   gtv, gsv, grv )
206                             CALL tra_swap
207         IF( ln_zdfnpc   )   CALL tra_npc    ( kstp )       ! update after fields by non-penetrative convection
208                             CALL tra_nxt    ( kstp )       ! tracer fields at next time step
209                             CALL tra_unswap
210      ENDIF 
211
212      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
213      ! Dynamics                                    (ta, sa used as workspace)
214      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
215                               ua(:,:,:) = 0.e0             ! set dynamics trends to zero
216                               va(:,:,:) = 0.e0
217
218                               CALL dyn_adv( kstp )         ! advection (vector or flux form)
219                               CALL dyn_vor( kstp )         ! vorticity term including Coriolis
220                               CALL dyn_ldf( kstp )         ! lateral mixing
221#if defined key_agrif
222      IF(.NOT. Agrif_Root())   CALL Agrif_Sponge_dyn        ! momemtum sponge
223#endif
224                               CALL dyn_hpg( kstp )         ! horizontal gradient of Hydrostatic pressure
225                               CALL dyn_bfr( kstp )           ! bottom friction   
226                               CALL dyn_zdf( kstp )         ! vertical diffusion
227                               indic=0
228                               CALL dyn_spg( kstp, indic )  ! surface pressure gradient
229                               CALL dyn_nxt( kstp )         ! lateral velocity at next time step
230
231                               CALL ssh_nxt( kstp )         ! sea surface height at next time step
232
233      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
234      ! Control and restarts
235      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
236                               CALL stp_ctl( kstp, indic )
237      IF( indic < 0        )   THEN
238                               CALL ctl_stop( 'step: indic < 0' )
239                               CALL dia_wri_state( 'output.abort', kstp )
240      ENDIF
241      IF( kstp == nit000   )   CALL iom_close( numror )     ! close input  ocean restart file
242      IF( lrst_oce         )   CALL rst_write    ( kstp )   ! write output ocean restart file
243      IF( lk_obc           )   CALL obc_rst_write( kstp )   ! write open boundary restart file
244
245      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
246      ! Trends                              (ua, va, ta, sa used as workspace)
247      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
248      IF( nstop == 0 ) THEN                         
249         IF( lk_trddyn     )   CALL trd_dwr( kstp )         ! trends: dynamics
250         IF( lk_trdtra     )   CALL trd_twr( kstp )         ! trends: active tracers
251         IF( lk_trdmld     )   CALL trd_mld( kstp )         ! trends: Mixed-layer
252         IF( lk_trdvor     )   CALL trd_vor( kstp )         ! trends: vorticity budget
253      ENDIF
254
255      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
256      ! Coupled mode
257      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
258      IF( lk_cpl           )   CALL sbc_cpl_snd( kstp )     ! coupled mode : field exchanges
259      !
260      !
261   END SUBROUTINE stp
262
263   !!======================================================================
264END MODULE step
Note: See TracBrowser for help on using the repository browser.