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

source: branches/dev_003_CPL/NEMO/OPA_SRC/step.F90 @ 990

Last change on this file since 990 was 990, checked in by smasson, 16 years ago

dev_003_CPL: to the trunk , see ticket #155

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.8 KB
Line 
1MODULE step
2   !!======================================================================
3   !!                       ***  MODULE step  ***
4   !! Time-stepping    : manager of the ocean, tracer and ice time stepping
5   !!======================================================================
6   !! History :        !  91-03  (G. Madec)  Original code
7   !!                  !  92-06  (M. Imbard)  add a first output record
8   !!                  !  96-04  (G. Madec)  introduction of dynspg
9   !!                  !  96-04  (M.A. Foujols)  introduction of passive tracer
10   !!             8.0  !  97-06  (G. Madec)  new architecture of call
11   !!             8.2  !  97-06  (G. Madec, M. Imbard, G. Roullet)  free surface
12   !!             8.2  !  99-02  (G. Madec, N. Grima)  hpg implicit
13   !!             8.2  !  00-07  (J-M Molines, M. Imbard)  Open Bondary Conditions
14   !!             9.0  !  02-06  (G. Madec)  free form, suppress macro-tasking
15   !!             " "  !  04-08  (C. Talandier) New trends organization
16   !!             " "  !  05-01  (C. Ethe) Add the KPP closure scheme
17   !!             " "  !  05-11  (V. Garnier) Surface pressure gradient organization
18   !!             " "  !  05-11  (G. Madec)  Reorganisation of tra and dyn calls
19   !!             " "  !  06-01  (L. Debreu, C. Mazauric)  Agrif implementation
20   !!             " "  !  06-07  (S. Masson)  restart using iom
21   !!             " "  !  06-08  (G. Madec)  surface module
22   !!             " "  !  07-07  (J. Chanut, A. Sellar) Unstructured open boundaries (BDY)
23   !!----------------------------------------------------------------------
24
25   !!----------------------------------------------------------------------
26   !!   stp            : OPA system time-stepping
27   !!----------------------------------------------------------------------
28   USE oce             ! ocean dynamics and tracers variables
29   USE dom_oce         ! ocean space and time domain variables
30   USE zdf_oce         ! ocean vertical physics variables
31   USE ldftra_oce      ! ocean tracer   - trends
32   USE ldfdyn_oce      ! ocean dynamics - trends
33   USE cpl_oce         ! coupled ocean-atmosphere variables
34   USE in_out_manager  ! I/O manager
35   USE iom             !
36   USE lbclnk
37
38   USE daymod          ! calendar                         (day     routine)
39
40   USE dtatem          ! ocean temperature data           (dta_tem routine)
41   USE dtasal          ! ocean salinity    data           (dta_sal routine)
42   USE sbcmod          ! surface boundary condition       (sbc     routine)
43   USE sbcrnf          ! surface boundary condition: runoff variables
44   USE ocfzpt          ! surface ocean freezing point    (oc_fz_pt routine)
45
46   USE trcstp          ! passive tracer time-stepping      (trc_stp routine)
47
48   USE traqsr          ! solar radiation penetration      (tra_qsr routine)
49   USE trasbc          ! surface boundary condition       (tra_sbc routine)
50   USE trabbc          ! bottom boundary condition        (tra_bbc routine)
51   USE trabbl          ! bottom boundary layer            (tra_bbl routine)
52   USE tradmp          ! internal damping                 (tra_dmp routine)
53   USE traadv          ! advection scheme control     (tra_adv_ctl routine)
54   USE traldf          ! lateral mixing                   (tra_ldf routine)
55   USE cla             ! cross land advection             (tra_cla routine)
56   !   zdfkpp          ! KPP non-local tracer fluxes      (tra_kpp routine)
57   USE trazdf          ! vertical mixing                  (tra_zdf routine)
58   USE tranxt          ! time-stepping                    (tra_nxt routine)
59   USE tranpc          ! non-penetrative convection       (tra_npc routine)
60
61   USE eosbn2          ! equation of state                (eos_bn2 routine)
62
63   USE dynadv          ! advection                        (dyn_adv routine)
64   USE dynvor          ! vorticity term                   (dyn_vor routine)
65   USE dynhpg          ! hydrostatic pressure grad.       (dyn_hpg routine)
66   USE dynldf          ! lateral momentum diffusion       (dyn_ldf routine)
67   USE dynzdf          ! vertical diffusion               (dyn_zdf routine)
68   USE dynspg_oce      ! surface pressure gradient        (dyn_spg routine)
69   USE dynspg          ! surface pressure gradient        (dyn_spg routine)
70   USE dynnxt          ! time-stepping                    (dyn_nxt routine)
71
72   USE obc_par         ! open boundary condition variables
73   USE obcdta          ! open boundary condition data     (obc_dta routine)
74   USE obcrst          ! open boundary cond. restart      (obc_rst routine)
75   USE obcrad          ! open boundary cond. radiation    (obc_rad routine)
76   USE obcspg          ! open boundary cond  spg          (obc_spg routine)
77
78   USE bdy_par         ! unstructured open boundary data variables
79   USE bdydta          ! unstructured open boundary data  (bdy_dta routine)
80
81   USE divcur          ! hor. divergence and curl      (div & cur routines)
82   USE cla_div         ! cross land: hor. divergence      (div_cla routine)
83   USE wzvmod          ! vertical velocity                (wzv     routine)
84
85   USE ldfslp          ! iso-neutral slopes               (ldf_slp routine)
86   USE ldfeiv          ! eddy induced velocity coef.      (ldf_eiv routine)
87
88   USE zdfbfr          ! bottom friction                  (zdf_bfr routine)
89   USE zdftke          ! TKE vertical mixing              (zdf_tke routine)
90   USE zdfkpp          ! KPP vertical mixing              (zdf_kpp routine)
91   USE zdfddm          ! double diffusion mixing          (zdf_ddm routine)
92   USE zdfevd          ! enhanced vertical diffusion      (zdf_evd routine)
93   USE zdfric          ! Richardson vertical mixing       (zdf_ric routine)
94   USE zdfmxl          ! Mixed-layer depth                (zdf_mxl routine)
95
96   USE zpshde          ! partial step: hor. derivative     (zps_hde routine)
97   USE ice_oce         ! sea-ice variable
98
99   USE diawri          ! Standard run outputs             (dia_wri routine)
100   USE trdicp          ! Ocean momentum/tracers trends    (trd_wri routine)
101   USE trdmld          ! mixed-layer trends               (trd_mld routine)
102   USE trdmld_rst      ! restart for mixed-layer trends
103   USE trdmod_oce      ! ocean momentum/tracers trends
104   USE trdvor          ! vorticity budget                 (trd_vor routine)
105   USE diagap          ! hor. mean model-data gap         (dia_gap routine)
106   USE diahdy          ! dynamic height                   (dia_hdy routine)
107   USE diaptr          ! poleward transports              (dia_ptr routine)
108   USE diahth          ! thermocline depth                (dia_hth routine)
109   USE diafwb          ! freshwater budget                (dia_fwb routine)
110   USE diaspr          ! suface pressure (rigid-lid)      (dia_spr routine)
111   USE flo_oce         ! floats variables
112   USE floats          ! floats computation               (flo_stp routine)
113
114   USE stpctl          ! time stepping control            (stp_ctl routine)
115   USE restart         ! ocean restart                    (rst_wri routine)
116   USE prtctl          ! Print control                    (prt_ctl routine)
117   USE domvvl          ! variable volume                  (dom_vvl routine)
118
119#if defined key_agrif
120   USE agrif_opa_sponge ! Momemtum and tracers sponges
121#endif
122
123   IMPLICIT NONE
124   PRIVATE
125
126   PUBLIC stp            ! called by opa.F90
127
128   !! * Substitutions
129#  include "domzgr_substitute.h90"
130#  include "zdfddm_substitute.h90"
131   !!----------------------------------------------------------------------
132   !!   OPA 9.0 , LOCEAN-IPSL (2005)
133   !! $Id$
134   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
135   !!----------------------------------------------------------------------
136
137CONTAINS
138
139#if defined key_agrif
140   SUBROUTINE stp( )
141#else
142   SUBROUTINE stp( kstp )
143#endif
144      !!----------------------------------------------------------------------
145      !!                     ***  ROUTINE stp  ***
146      !!                     
147      !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.)
148      !!              - Time stepping of LIM (dynamic and thermodynamic eqs.)
149      !!              - Tme stepping  of TRC (passive tracer eqs.)
150      !!
151      !! ** Method  : -1- Update forcings and data 
152      !!              -2- Update ocean physics
153      !!              -3- Compute the t and s trends
154      !!              -4- Update t and s
155      !!              -5- Compute the momentum trends
156      !!              -6- Update the horizontal velocity
157      !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w)
158      !!              -8- Outputs and diagnostics
159      !!----------------------------------------------------------------------
160      !! * Arguments
161#if defined key_agrif   
162      INTEGER             ::   kstp   ! ocean time-step index
163#else
164      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
165#endif     
166      INTEGER ::   jk       ! dummy loop indice
167      INTEGER ::   indic    ! error indicator if < 0
168      !! ---------------------------------------------------------------------
169
170#if defined key_agrif
171      kstp = nit000 + Agrif_Nb_Step()
172!      IF ( Agrif_Root() .and. lwp) Write(*,*) '---'
173!      IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp
174#endif   
175      indic = 1                    ! reset to no error condition
176
177      CALL day( kstp )             ! Calendar
178
179      CALL rst_opn( kstp )         ! Open the restart file
180
181      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
182      ! Update data, open boundaries, surface boundary condition (including sea-ice)
183      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
184
185      IF( lk_dtatem  )   CALL dta_tem( kstp )         ! update 3D temperature data
186      IF( lk_dtasal  )   CALL dta_sal( kstp )         ! update 3D salinity data
187
188                         CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice)
189
190      IF( lk_obc     )   CALL obc_dta( kstp )         ! update dynamic and tracer data at open boundaries
191      IF( lk_obc     )   CALL obc_rad( kstp )         ! compute phase velocities at open boundaries
192
193      IF( lk_bdy     )   CALL bdy_dta( kstp )         ! update dynamic and tracer data at unstructured open boundary
194
195      IF( ninist == 1 ) THEN                       ! Output the initial state and forcings
196                        CALL dia_wri_state( 'output.init' )
197                        ninist = 0
198      ENDIF
199
200
201      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
202      ! Ocean physics update
203      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
204      !-----------------------------------------------------------------------
205      !  VERTICAL PHYSICS
206      !-----------------------------------------------------------------------
207      ! N.B. ua, va, ta, sa arrays are used as workspace in this section
208      !-----------------------------------------------------------------------
209
210                        CALL bn2( tb, sb, rn2 )              ! before Brunt-Vaisala frequency
211     
212      !                                                     ! Vertical eddy viscosity and diffusivity coefficients
213      IF( lk_zdfric )   CALL zdf_ric( kstp )                       ! Richardson number dependent Kz
214
215      IF( lk_zdftke )   CALL zdf_tke( kstp )                       ! TKE closure scheme for Kz
216
217      IF( lk_zdfkpp )   CALL zdf_kpp( kstp )                       ! KPP closure scheme for Kz
218
219      IF( lk_zdfcst )   THEN                                       ! Constant Kz (reset avt, avm[uv] to the background value)
220         avt (:,:,:) = avt0 * tmask(:,:,:)
221         avmu(:,:,:) = avm0 * umask(:,:,:)
222         avmv(:,:,:) = avm0 * vmask(:,:,:)
223      ENDIF
224
225      IF( ln_rnf ) THEN                                     ! increase diffusivity at rivers mouths
226         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + rn_avt_rnf * rnfmsk(:,:)   ;   END DO
227      ENDIF
228
229      IF( ln_zdfevd )   CALL zdf_evd( kstp )                 ! enhanced vertical eddy diffusivity
230
231      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
232         &              CALL zdf_ddm( kstp )                 ! double diffusive mixing
233
234                        CALL zdf_bfr( kstp )                 ! bottom friction
235
236                        CALL zdf_mxl( kstp )                 ! mixed layer depth
237
238
239      !-----------------------------------------------------------------------
240      !  LATERAL PHYSICS
241      !-----------------------------------------------------------------------
242      ! N.B. ua, va, ta, sa arrays are used as workspace in this section
243      !-----------------------------------------------------------------------
244      IF( lk_ldfslp     )   CALL ldf_slp( kstp, rhd, rn2 )       ! before slope of the lateral mixing
245#if defined key_traldf_c2d
246      IF( lk_traldf_eiv )   CALL ldf_eiv( kstp )                 ! eddy induced velocity coefficient
247#endif
248
249#if defined key_top
250      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
251      ! Passive Tracer Model
252      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
253      ! N.B. ua, va, ta, sa arrays are used as workspace in this section
254      !-----------------------------------------------------------------------
255                             CALL trc_stp( kstp, indic )            ! time-stepping
256#endif
257
258      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
259      ! Active tracers
260      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
261      ! N.B. ua, va arrays are used as workspace in this section
262      !-----------------------------------------------------------------------
263                             ta(:,:,:) = 0.e0               ! set tracer trends to zero
264                             sa(:,:,:) = 0.e0
265
266                             CALL tra_sbc    ( kstp )       ! surface boundary condition
267      IF( ln_traqsr      )   CALL tra_qsr    ( kstp )       ! penetrative solar radiation qsr
268      IF( lk_trabbc      )   CALL tra_bbc    ( kstp )       ! bottom heat flux
269      IF( lk_trabbl_dif  )   CALL tra_bbl_dif( kstp )       ! diffusive bottom boundary layer scheme
270      IF( lk_trabbl_adv  )   CALL tra_bbl_adv( kstp )       ! advective (and/or diffusive) bottom boundary layer scheme
271      IF( lk_tradmp      )   CALL tra_dmp    ( kstp )       ! internal damping trends
272                             CALL tra_adv    ( kstp )       ! horizontal & vertical advection
273      IF( n_cla == 1     )   CALL tra_cla    ( kstp )       ! Cross Land Advection (Update Hor. advection)
274      IF( lk_zdfkpp )        CALL tra_kpp    ( kstp )       ! KPP non-local tracer fluxes
275                             CALL tra_ldf    ( kstp )       ! lateral mixing
276#if defined key_agrif
277      IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra          ! tracers sponge
278#endif
279                             CALL tra_zdf    ( kstp )       ! vertical mixing
280                             CALL tra_nxt( kstp )           ! tracer fields at next time step
281      IF( ln_zdfnpc      )   CALL tra_npc( kstp )           ! update the new (t,s) fields by non
282      !                                                     ! penetrative convective adjustment
283
284      IF( ln_dynhpg_imp  ) THEN                             ! semi-implicit hpg
285                               CALL eos( ta, sa, rhd, rhop )          ! Time-filtered in situ density used in dynhpg module
286         IF( ln_zps    )       CALL zps_hde( kstp, ta, sa, rhd,   &   ! Partial steps: time filtered hor. gradient
287            &                                     gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level
288            &                                     gtv, gsv, grv )
289      ELSE                                                  ! centered hpg (default case)
290                               CALL eos( tb, sb, rhd, rhop )          ! now (swap=before) in situ density for dynhpg module
291         IF( ln_zps    )       CALL zps_hde( kstp, tb, sb, rhd,   &   ! Partial steps: now horizontal gradient
292            &                                     gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level
293            &                                     gtv, gsv, grv )
294      ENDIF
295
296      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
297      ! Dynamics
298      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
299      ! N.B. ta, sa arrays are used as workspace in this section
300      !-----------------------------------------------------------------------
301                               ua(:,:,:) = 0.e0               ! set dynamics trends to zero
302                               va(:,:,:) = 0.e0
303
304                               CALL dyn_adv( kstp )           ! advection (vector or flux form)
305                               CALL dyn_vor( kstp )           ! vorticity term including Coriolis
306                               CALL dyn_ldf( kstp )           ! lateral mixing
307#if defined key_agrif
308      IF(.NOT. Agrif_Root())   CALL Agrif_Sponge_dyn          ! momemtum sponge
309#endif
310                               CALL dyn_hpg( kstp )           ! horizontal gradient of Hydrostatic pressure
311                               CALL dyn_zdf( kstp )           ! vertical diffusion
312      IF( lk_dynspg_rl ) THEN
313         IF( lk_obc    )       CALL obc_spg( kstp )           ! surface pressure gradient at open boundaries
314      ENDIF
315                               indic=0
316                               CALL dyn_spg( kstp, indic )    ! surface pressure gradient
317                               CALL dyn_nxt( kstp )           ! lateral velocity at next time step
318      IF( lk_vvl )             CALL dom_vvl                   ! vertical mesh at next time step
319
320
321      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
322      ! Computation of diagnostic variables
323      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
324      ! N.B. ua, va, ta, sa arrays are used as workspace in this section
325      !-----------------------------------------------------------------------
326                       CALL oc_fz_pt                        ! ocean surface freezing temperature
327                       CALL div_cur( kstp )                 ! Horizontal divergence & Relative vorticity
328      IF( n_cla == 1 ) CALL div_cla( kstp )                 ! Cross Land Advection (Update Hor. divergence)
329                       CALL wzv( kstp )                     ! Vertical velocity
330
331      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
332      ! Control and restarts
333      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
334                                 CALL stp_ctl( kstp, indic )
335      IF( indic < 0          )   CALL ctl_stop( 'step: indic < 0' )
336      IF( kstp == nit000     )   CALL iom_close( numror )             ! close input  ocean restart file
337      IF( lrst_oce           )   CALL rst_write  ( kstp )             ! write output ocean restart file
338      IF( lk_obc             )   CALL obc_rst_wri( kstp )             ! write open boundary restart file
339
340      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
341      ! diagnostics and outputs
342      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
343      ! N.B. ua, va, ta, sa arrays are used as workspace in this section
344      !-----------------------------------------------------------------------
345
346      IF( nstop == 0 ) THEN                                 ! Diagnostics:
347         IF( lk_floats  )   CALL flo_stp( kstp )                 ! drifting Floats
348         IF( lk_trddyn  )   CALL trd_dwr( kstp )                 ! trends: dynamics
349         IF( lk_trdtra  )   CALL trd_twr( kstp )                 ! trends: active tracers
350         IF( lk_trdmld  )   CALL trd_mld( kstp )                 ! trends: Mixed-layer
351         IF( lk_trdvor  )   CALL trd_vor( kstp )                 ! trends: vorticity budget
352         IF( lk_diaspr  )   CALL dia_spr( kstp )                 ! Surface pressure diagnostics
353         IF( lk_diahth  )   CALL dia_hth( kstp )                 ! Thermocline depth (20 degres isotherm depth)
354         IF( lk_diagap  )   CALL dia_gap( kstp )                 ! basin averaged diagnostics
355         IF( lk_diahdy  )   CALL dia_hdy( kstp )                 ! dynamical heigh diagnostics
356         IF( lk_diafwb  )   CALL dia_fwb( kstp )                 ! Fresh water budget diagnostics
357         IF( ln_diaptr  )   CALL dia_ptr( kstp )                 ! Poleward TRansports diagnostics
358         !                                                 ! outputs
359                            CALL dia_wri( kstp, indic )          ! ocean model: outputs
360      ENDIF
361
362      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
363      ! Coupled mode
364      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
365
366#if defined key_oasis3
367      IF( lk_cpl    )   CALL cpl_stp( kstp )                 ! coupled mode : field exchanges
368#endif
369      !
370   END SUBROUTINE stp
371
372   !!======================================================================
373END MODULE step
Note: See TracBrowser for help on using the repository browser.