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

source: trunk/NEMO/OPA_SRC/step.F90 @ 1044

Last change on this file since 1044 was 1037, checked in by ctlod, 16 years ago

trunk: replace freeze(:,:) variable with fr_i(:,:), use the tfreez function defined in eosbn2.F90 and remove the useless ocfzpt.F90 module, see ticket: #177

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