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

source: branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/step.F90 @ 2200

Last change on this file since 2200 was 2200, checked in by smasson, 14 years ago

merge trunk rev 2198 into DEV_r2106_LOCEAN2010

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