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/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC – NEMO

source: branches/2011/DEV_r2739_STFC_dCSE/NEMOGCM/NEMO/OPA_SRC/step.F90 @ 4404

Last change on this file since 4404 was 4404, checked in by trackstand2, 10 years ago

Commented-out dump-arrays in stp()

  • Property svn:keywords set to Id
File size: 21.1 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   !!                 !  2011-05  (S. Pickles) dCSE NEMO optimisations - z index first
26   !!----------------------------------------------------------------------
27
28   !!----------------------------------------------------------------------
29   !!   stp             : OPA system time-stepping
30   !!----------------------------------------------------------------------
31   USE step_oce         ! time stepping definition modules
32#if defined key_top
33   USE trcstp           ! passive tracer time-stepping      (trc_stp routine)
34#endif
35#if defined key_agrif
36   USE agrif_opa_sponge ! Momemtum and tracers sponges
37#endif
38   USE asminc           ! assimilation increments    (tra_asm_inc, dyn_asm_inc routines)
39   USE timing, ONLY: timing_start, timing_stop, timing_reset, timing_disable
40   USE arpdebugging, ONLY: dump_array
41   IMPLICIT NONE
42   PRIVATE
43
44   PUBLIC   stp   ! called by opa.F90
45
46   !! * Control permutation of array indices
47   !! DCSE_NEMO: warning! dom_oce and zdf_oce public variables are made available
48   !! through the use of step_oce
49#  include "dom_oce_ftrans.h90"
50#  include "zdf_oce_ftrans.h90"
51
52   !! * Substitutions
53#  include "domzgr_substitute.h90"
54#  include "zdfddm_substitute.h90"
55   !!----------------------------------------------------------------------
56   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
57   !! $Id$
58   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
59   !!----------------------------------------------------------------------
60CONTAINS
61
62#if defined key_agrif
63   SUBROUTINE stp( )
64      INTEGER             ::   kstp   ! ocean time-step index
65#else
66   SUBROUTINE stp( kstp )
67      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
68#endif
69      !!----------------------------------------------------------------------
70      !!                     ***  ROUTINE stp  ***
71      !!                     
72      !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.)
73      !!              - Time stepping of LIM (dynamic and thermodynamic eqs.)
74      !!              - Tme stepping  of TRC (passive tracer eqs.)
75      !!
76      !! ** Method  : -1- Update forcings and data 
77      !!              -2- Update ocean physics
78      !!              -3- Compute the t and s trends
79      !!              -4- Update t and s
80      !!              -5- Compute the momentum trends
81      !!              -6- Update the horizontal velocity
82      !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w)
83      !!              -8- Outputs and diagnostics
84      !!----------------------------------------------------------------------
85      INTEGER ::   jk       ! dummy loop indice
86      INTEGER ::   indic    ! error indicator if < 0
87#if defined key_z_first
88      INTEGER ::   ji, jj   ! dummy loop indices
89#endif
90      INTEGER, PARAMETER :: DUMP_LEVEL = 26 ! ARPDBG - level to dump to disk
91      !! ---------------------------------------------------------------------
92                         CALL timing_start('Step') 
93
94#if defined key_agrif
95      kstp = nit000 + Agrif_Nb_Step()
96!      IF ( Agrif_Root() .and. lwp) Write(*,*) '---'
97!      IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp
98# if defined key_iomput
99      IF( Agrif_Nbstepint() == 0 )   CALL iom_swap
100# endif   
101#endif   
102                             indic = 0                ! reset to no error condition
103      IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
104                             CALL iom_setkt( kstp )   ! say to iom that we are at time step kstp
105
106      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
107      ! Update data, open boundaries, surface boundary condition (including sea-ice)
108      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
109                         CALL timing_start('Boundaries') 
110      IF( lk_dtatem  )   CALL dta_tem( kstp )         ! update 3D temperature data
111      IF( lk_dtasal  )   CALL dta_sal( kstp )         ! update 3D salinity data
112                         CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice)
113      IF( lk_obc     )   CALL obc_dta( kstp )         ! update dynamic and tracer data at open boundaries
114      IF( lk_obc     )   CALL obc_rad( kstp )         ! compute phase velocities at open boundaries
115      IF( lk_bdy     )   CALL bdy_dta_frs( kstp )     ! update dynamic and tracer data for FRS conditions (BDY)
116                         ! ARP - no 'section' arg here so the time taken
117                         ! in this region (which can involve IO) is
118                         ! subtracted from the time
119                         ! taken to do the whole step.
120                         CALL timing_stop('Boundaries') 
121
122      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
123      !  Ocean dynamics : ssh, wn, hdiv, rot                                 !
124      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
125                         CALL timing_start('Ocean Dyn.') 
126                         CALL ssh_wzv( kstp )         ! after ssh & vertical velocity
127                         CALL timing_stop('Ocean Dyn.','section') 
128
129      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
130      ! Ocean physics update                (ua, va, ta, sa used as workspace)
131      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
132                         CALL timing_start('Ocean Phys.') 
133                         CALL bn2( tsb, rn2b )        ! before Brunt-Vaisala frequency
134                         CALL bn2( tsn, rn2  )        ! now    Brunt-Vaisala frequency
135                         CALL timing_stop('Ocean Phys.','section') 
136      !
137      !  VERTICAL PHYSICS 
138                         CALL timing_start('Vert. Phys.') 
139                         CALL zdf_bfr( kstp )         ! bottom friction
140                         
141      !                                               ! Vertical eddy viscosity and diffusivity coefficients
142      IF( lk_zdfric  )   CALL zdf_ric( kstp )            ! Richardson number dependent Kz
143      IF( lk_zdftke  )   CALL zdf_tke( kstp )            ! TKE closure scheme for Kz
144      IF( lk_zdfgls  )   CALL zdf_gls( kstp )            ! GLS closure scheme for Kz
145      IF( lk_zdfkpp  )   CALL zdf_kpp( kstp )            ! KPP closure scheme for Kz
146      IF( lk_zdfcst  )   THEN                            ! Constant Kz (reset avt, avm[uv] to the background value)
147         avt (:,:,:) = rn_avt0 * tmask(:,:,:)
148         avmu(:,:,:) = rn_avm0 * umask(:,:,:)
149         avmv(:,:,:) = rn_avm0 * vmask(:,:,:)
150      ENDIF
151      IF( ln_rnf_mouth ) THEN                         ! increase diffusivity at rivers mouths
152#if defined key_z_first
153         DO ji = 1, jpi
154            DO jj = 1, jpj
155               DO jk = 2, nkrnf 
156                  avt(ji,jj,jk) = avt(ji,jj,jk) + 2.e0 * rn_avt_rnf * rnfmsk(ji,jj) * tmask(ji,jj,jk)
157               END DO
158            END DO
159         END DO
160#else
161         DO jk = 2, nkrnf
162            avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk)
163         END DO
164#endif
165      ENDIF
166      IF( ln_zdfevd  )   CALL zdf_evd( kstp )         ! enhanced vertical eddy diffusivity
167
168      IF( lk_zdftmx  )   CALL zdf_tmx( kstp )         ! tidal vertical mixing
169
170      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
171         &               CALL zdf_ddm( kstp )         ! double diffusive mixing
172         
173                         CALL zdf_mxl( kstp )         ! mixed layer depth
174
175                                                      ! write TKE or GLS information in the restart file
176      IF( lrst_oce .AND. lk_zdftke )   CALL tke_rst( kstp, 'WRITE' )
177      IF( lrst_oce .AND. lk_zdfgls )   CALL gls_rst( kstp, 'WRITE' )
178
179                         CALL timing_stop('Vert. Phys.','section') 
180      !
181      !  LATERAL  PHYSICS
182      !
183                         CALL timing_start('Lateral Phys.') 
184      !
185      IF( lk_ldfslp ) THEN                            ! slope of lateral mixing
186                         CALL eos( tsb, rhd )                ! before in situ density
187         IF( ln_zps )    CALL zps_hde( kstp, jpts, tsb, gtsu, gtsv,  &    ! Partial steps: before horizontal gradient
188            &                                      rhd, gru , grv  )      ! of t, s, rd at the last ocean level
189         IF( ln_traldf_grif ) THEN                           ! before slope for Griffies operator
190                         CALL ldf_slp_grif( kstp )
191         ELSE
192                         CALL ldf_slp( kstp, rhd, rn2b )     ! before slope for Madec operator
193         ENDIF
194      ENDIF
195#if defined key_traldf_c2d
196      IF( lk_traldf_eiv )   CALL ldf_eiv( kstp )      ! eddy induced velocity coefficient
197#endif
198                         CALL timing_stop('Lateral Phys.','section') 
199
200      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
201      ! diagnostics and outputs             (ua, va, ta, sa used as workspace)
202      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
203                         CALL timing_start('Diagnostics') 
204      IF( lk_floats  )   CALL flo_stp( kstp )         ! drifting Floats
205      IF( lk_diahth  )   CALL dia_hth( kstp )         ! Thermocline depth (20 degres isotherm depth)
206      IF( lk_diafwb  )   CALL dia_fwb( kstp )         ! Fresh water budget diagnostics
207      IF( ln_diaptr  )   CALL dia_ptr( kstp )         ! Poleward TRansports diagnostics
208      IF( lk_diaar5  )   CALL dia_ar5( kstp )         ! ar5 diag
209                         CALL dia_wri( kstp )         ! ocean model: outputs
210                         CALL timing_stop('Diagnostics','section') 
211
212#if defined key_top
213      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
214      ! Passive Tracer Model
215      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
216                         CALL trc_stp( kstp )         ! time-stepping
217#endif
218
219      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
220      ! Active tracers                              (ua, va used as workspace)
221      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
222                             CALL timing_start('Active tracers') 
223
224                             tsa(:,:,:,:) = 0.e0            ! set tracer trends to zero
225
226      IF(  ln_asmiau .AND. &
227         & ln_trainc     )   CALL tra_asm_inc( kstp )       ! apply tracer assimilation increment
228                             CALL tra_sbc    ( kstp )       ! surface boundary condition
229      IF( ln_traqsr      )   CALL tra_qsr    ( kstp )       ! penetrative solar radiation qsr
230      IF( ln_trabbc      )   CALL tra_bbc    ( kstp )       ! bottom heat flux
231      IF( lk_trabbl      )   CALL tra_bbl    ( kstp )       ! advective (and/or diffusive) bottom boundary layer scheme
232      IF( lk_tradmp      )   CALL tra_dmp    ( kstp )       ! internal damping trends
233                             CALL tra_adv    ( kstp )       ! horizontal & vertical advection
234      IF( lk_zdfkpp      )   CALL tra_kpp    ( kstp )       ! KPP non-local tracer fluxes
235                             CALL tra_ldf    ( kstp )       ! lateral mixing
236#if defined key_agrif
237                             CALL tra_unswap
238      IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra          ! tracers sponge
239                             CALL tra_swap
240#endif
241                             CALL tra_zdf    ( kstp )       ! vertical mixing and after tracer fields
242
243      IF( ln_dynhpg_imp  ) THEN                             ! semi-implicit hpg (time stepping then eos)
244         IF( ln_zdfnpc   )   CALL tra_npc( kstp )                ! update after fields by non-penetrative convection
245                             CALL tra_nxt( kstp )                ! tracer fields at next time step
246                             CALL eos    ( tsa, rhd, rhop )      ! Time-filtered in situ density for hpg computation
247         IF( ln_zps      )   CALL zps_hde( kstp, jpts, tsa, gtsu, gtsv,  &    ! zps: time filtered hor. derivative
248            &                                          rhd, gru , grv  )      ! of t, s, rd at the last ocean level
249         
250      ELSE                                                  ! centered hpg  (eos then time stepping)
251                             CALL eos    ( tsn, rhd, rhop )      ! now in situ density for hpg computation
252         IF( ln_zps      )   CALL zps_hde( kstp, jpts, tsn, gtsu, gtsv,  &    ! zps: now hor. derivative
253            &                                          rhd, gru , grv  )      ! of t, s, rd at the last ocean level
254         IF( ln_zdfnpc   )   CALL tra_npc( kstp )                ! update after fields by non-penetrative convection
255                             CALL tra_nxt( kstp )                ! tracer fields at next time step
256      ENDIF
257                             CALL tra_unswap                ! udate T & S 3D arrays  (to be suppressed)
258                             CALL timing_stop('Active tracers','section') 
259
260      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
261      ! Dynamics                                    (ta, sa used as workspace)
262      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
263                               CALL timing_start('Dynamics') 
264
265                               ua(:,:,:) = 0.e0             ! set dynamics trends to zero
266                               va(:,:,:) = 0.e0
267
268      IF(  ln_asmiau .AND. &
269         & ln_dyninc       )   CALL dyn_asm_inc( kstp )     ! apply dynamics assimilation increment
270
271                               !CALL timing_start('dyn_adv')
272                               CALL dyn_adv( kstp )         ! advection (vector or flux form)
273                               !CALL timing_stop('dyn_adv','section')
274
275!                               CALL dump_array(kstp,'ua_pre_vor',ua(:,:,DUMP_LEVEL), &
276!                                               withHalos=.TRUE.,atStep=1)
277
278                               !CALL timing_start('dyn_vor')
279                               CALL dyn_vor( kstp )         ! vorticity term including Coriolis
280                               !CALL timing_stop('dyn_vor','section')
281
282!                               CALL dump_array(kstp,'ua_pre_ldf',ua(:,:,DUMP_LEVEL), &
283!                                               withHalos=.TRUE.,atStep=1)
284
285                               !CALL timing_start('dyn_ldf')
286                               CALL dyn_ldf( kstp )         ! lateral mixing
287                               !CALL timing_stop('dyn_ldf','section')
288
289#if defined key_agrif
290      IF(.NOT. Agrif_Root())   CALL Agrif_Sponge_dyn        ! momemtum sponge
291#endif
292                               !CALL dump_array(kstp,'ua_pre_hpg',ua(:,:,DUMP_LEVEL), &
293                               !                withHalos=.TRUE.)
294
295                               !CALL timing_start('dyn_hpg')
296                               CALL dyn_hpg( kstp )         ! horizontal gradient of Hydrostatic pressure
297                               !CALL timing_stop('dyn_hpg','section')
298
299                               !CALL dump_array(kstp,'ua_pre_bfr',ua(:,:,26), &
300                               !                withHalos=.TRUE.)
301
302                               !CALL timing_start('dyn_bfr')
303                               CALL dyn_bfr( kstp )         ! bottom friction   
304                               !CALL timing_stop('dyn_bfr','section')
305                               
306!                               CALL dump_array(kstp,'ua_pre_zdf',ua(:,:,DUMP_LEVEL), &
307!                                               withHalos=.TRUE.,atStep=1)
308
309                               !CALL timing_start('dyn_zdf')
310                               CALL dyn_zdf( kstp )         ! vertical diffusion
311                               !CALL timing_stop('dyn_zdf','section')
312                               
313!                               CALL dump_array(kstp,'ua_pre_spg',ua(:,:,DUMP_LEVEL), &
314!                                               withHalos=.TRUE.,atStep=1)
315
316                               !CALL timing_start('dyn_spg')
317                               CALL dyn_spg( kstp, indic )  ! surface pressure gradient
318                               !CALL timing_stop('dyn_spg','section')
319!                               CALL dump_array(kstp,'ua_spg',ua(:,:,DUMP_LEVEL), &
320!                                               withHalos=.TRUE.,atStep=1)
321
322                               !CALL timing_start('dyn_nxt')
323                               CALL dyn_nxt( kstp )         ! lateral velocity at next time step
324                               !CALL timing_stop('dyn_nxt','section')
325
326                               !CALL timing_stop('dyn_nxt','section')
327
328                               !CALL timing_start('ssh_nxt')
329                               CALL ssh_nxt( kstp )         ! sea surface height at next time step
330                               !CALL timing_stop('ssh_nxt','section')
331
332      IF( ln_diahsb        )   CALL dia_hsb( kstp )         ! - ML - global conservation diagnostics
333      IF( lk_diaobs  )         CALL dia_obs( kstp )         ! obs-minus-model (assimilation) diagnostics
334                               !                            ! (call after dynamics update)
335                               CALL timing_stop('Dynamics','section') 
336
337      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
338      ! Control and restarts
339      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
340                               CALL timing_start('Control') 
341
342                               CALL stp_ctl( kstp, indic )
343      IF( indic < 0        )   THEN
344                               CALL ctl_stop( 'step: indic < 0' )
345                               CALL dia_wri_state( 'output.abort', kstp )
346      ENDIF
347      IF( kstp == nit000   )   CALL iom_close( numror )     ! close input  ocean restart file
348      IF( lrst_oce         )   CALL rst_write    ( kstp )   ! write output ocean restart file
349      IF( lk_obc           )   CALL obc_rst_write( kstp )   ! write open boundary restart file
350                               ! ARP - no 'section' arg here so the time taken
351                               ! in this region (which can involve IO) is
352                               ! subtracted from the time
353                               ! taken to do the whole step.
354                               CALL timing_stop('Control') 
355      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
356      ! Trends                              (ua, va, ta, sa used as workspace)
357      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
358      IF( nstop == 0 ) THEN                         
359         IF( lk_trddyn     )   CALL trd_dwr( kstp )         ! trends: dynamics
360         IF( lk_trdtra     )   CALL trd_twr( kstp )         ! trends: active tracers
361         IF( lk_trdmld     )   CALL trd_mld( kstp )         ! trends: Mixed-layer
362         IF( lk_trdvor     )   CALL trd_vor( kstp )         ! trends: vorticity budget
363      ENDIF
364
365      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
366      ! Coupled mode
367      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
368      IF( lk_cpl           )   CALL sbc_cpl_snd( kstp )     ! coupled mode : field exchanges
369      !
370                               CALL timing_stop('Step', 'section') 
371
372      !
373      IF( kstp == nit000   )   CALL timing_reset            ! Exclude first step from timing
374      IF( kstp == (nitend-2) ) CALL timing_disable()        ! Turn off timing two steps from end to avoid the IO
375      !
376
377   END SUBROUTINE stp
378
379   !!======================================================================
380END MODULE step
Note: See TracBrowser for help on using the repository browser.