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.
dynzdf.F90 in branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN – NEMO

source: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90 @ 2676

Last change on this file since 2676 was 2636, checked in by gm, 13 years ago

dynamic mem: #785 ; move ctl_stop & warn in lib_mpp to avoid a circular dependency + ctl_stop improvment

  • Property svn:keywords set to Id
File size: 6.8 KB
Line 
1MODULE dynzdf
2   !!==============================================================================
3   !!                 ***  MODULE  dynzdf  ***
4   !! Ocean dynamics :  vertical component of the momentum mixing trend
5   !!==============================================================================
6   !! History :  1.0  !  2005-11  (G. Madec)  Original code
7   !!            3.3  !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   dyn_zdf      : Update the momentum trend with the vertical diffusion
12   !!   dyn_zdf_init : initializations of the vertical diffusion scheme
13   !!----------------------------------------------------------------------
14   USE oce             ! ocean dynamics and tracers variables
15   USE dom_oce         ! ocean space and time domain variables
16   USE zdf_oce         ! ocean vertical physics variables
17
18   USE dynzdf_exp      ! vertical diffusion: explicit (dyn_zdf_exp     routine)
19   USE dynzdf_imp      ! vertical diffusion: implicit (dyn_zdf_imp     routine)
20
21   USE ldfdyn_oce      ! ocean dynamics: lateral physics
22   USE trdmod          ! ocean active dynamics and tracers trends
23   USE trdmod_oce      ! ocean variables trends
24   USE in_out_manager  ! I/O manager
25   USE lib_mpp         ! MPP library
26   USE prtctl          ! Print control
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC   dyn_zdf       !  routine called by step.F90
32   PUBLIC   dyn_zdf_init  !  routine called by opa.F90
33
34   INTEGER  ::   nzdf = 0   ! type vertical diffusion algorithm used, defined from ln_zdf... namlist logicals
35   REAL(wp) ::   r2dt       ! time-step, = 2 rdttra except at nit000 (=rdttra) if neuler=0
36
37   !! * Substitutions
38#  include "domzgr_substitute.h90"
39#  include "zdfddm_substitute.h90"
40#  include "vectopt_loop_substitute.h90"
41   !!----------------------------------------------------------------------
42   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
43   !! $Id$
44   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
45   !!----------------------------------------------------------------------
46
47CONTAINS
48   
49   SUBROUTINE dyn_zdf( kt )
50      !!----------------------------------------------------------------------
51      !!                  ***  ROUTINE dyn_zdf  ***
52      !!
53      !! ** Purpose :   compute the vertical ocean dynamics physics.
54      !!---------------------------------------------------------------------
55      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
56      USE wrk_nemo, ONLY: ztrdu => wrk_3d_1, ztrdv => wrk_3d_2
57      !!
58      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
59      !!---------------------------------------------------------------------
60
61      IF(wrk_in_use(3, 1,2))THEN
62         CALL ctl_stop('dyn_zdf: requested workspace arrays unavailable.')
63         RETURN
64      END IF
65      !                                          ! set time step
66      IF( neuler == 0 .AND. kt == nit000     ) THEN   ;   r2dt =      rdt   ! = rdtra (restart with Euler time stepping)
67      ELSEIF(               kt <= nit000 + 1 ) THEN   ;   r2dt = 2. * rdt   ! = 2 rdttra (leapfrog)
68      ENDIF
69
70      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
71         ztrdu(:,:,:) = ua(:,:,:)
72         ztrdv(:,:,:) = va(:,:,:)
73      ENDIF
74
75      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
76      !
77      CASE ( 0 )   ;   CALL dyn_zdf_exp( kt, r2dt )      ! explicit scheme
78      CASE ( 1 )   ;   CALL dyn_zdf_imp( kt, r2dt )      ! implicit scheme
79      !
80      CASE ( -1 )                                      ! esopa: test all possibility with control print
81                       CALL dyn_zdf_exp( kt, r2dt )
82                       CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf0 - Ua: ', mask1=umask,               &
83            &                        tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
84                       CALL dyn_zdf_imp( kt, r2dt )
85                       CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf1 - Ua: ', mask1=umask,               &
86            &                        tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
87      END SELECT
88
89      IF( l_trddyn )   THEN                      ! save the vertical diffusive trends for further diagnostics
90         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
91         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
92         CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_zdf, 'DYN', kt )
93      ENDIF
94      !                                          ! print mean trends (used for debugging)
95      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf  - Ua: ', mask1=umask,               &
96            &                    tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
97      !
98      IF(wrk_not_released(3, 1,2))THEN
99         CALL ctl_stop('dyn_zdf: failed to release workspace arrays.')
100      END IF
101      !
102   END SUBROUTINE dyn_zdf
103
104
105   SUBROUTINE dyn_zdf_init
106      !!----------------------------------------------------------------------
107      !!                 ***  ROUTINE dyn_zdf_init  ***
108      !!
109      !! ** Purpose :   initializations of the vertical diffusion scheme
110      !!
111      !! ** Method  :   implicit (euler backward) scheme (default)
112      !!                explicit (time-splitting) scheme if ln_zdfexp=T
113      !!----------------------------------------------------------------------
114      USE zdftke
115      USE zdfgls
116      USE zdfkpp
117      !!----------------------------------------------------------------------
118      !
119      ! Choice from ln_zdfexp read in namelist in zdfini
120      IF( ln_zdfexp ) THEN   ;   nzdf = 0           ! use explicit scheme
121      ELSE                   ;   nzdf = 1           ! use implicit scheme
122      ENDIF
123      !
124      ! Force implicit schemes
125      IF( lk_zdftke .OR. lk_zdfgls .OR. lk_zdfkpp )   nzdf = 1   ! TKE, GLS or KPP physics
126      IF( ln_dynldf_iso                           )   nzdf = 1   ! iso-neutral lateral physics
127      IF( ln_dynldf_hor .AND. ln_sco              )   nzdf = 1   ! horizontal lateral physics in s-coordinate
128      !
129      IF( lk_esopa )    nzdf = -1                   ! Esopa key: All schemes used
130      !
131      IF(lwp) THEN                                  ! Print the choice
132         WRITE(numout,*)
133         WRITE(numout,*) 'dyn_zdf_init : vertical dynamics physics scheme'
134         WRITE(numout,*) '~~~~~~~~~~~'
135         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
136         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
137         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
138      ENDIF
139      !
140   END SUBROUTINE dyn_zdf_init
141
142   !!==============================================================================
143END MODULE dynzdf
Note: See TracBrowser for help on using the repository browser.