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
RevLine 
[456]1MODULE dynzdf
2   !!==============================================================================
3   !!                 ***  MODULE  dynzdf  ***
4   !! Ocean dynamics :  vertical component of the momentum mixing trend
5   !!==============================================================================
[2528]6   !! History :  1.0  !  2005-11  (G. Madec)  Original code
7   !!            3.3  !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
[456]8   !!----------------------------------------------------------------------
[503]9
10   !!----------------------------------------------------------------------
[456]11   !!   dyn_zdf      : Update the momentum trend with the vertical diffusion
[2528]12   !!   dyn_zdf_init : initializations of the vertical diffusion scheme
[456]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
[2636]25   USE lib_mpp         ! MPP library
[456]26   USE prtctl          ! Print control
27
28   IMPLICIT NONE
29   PRIVATE
30
[2528]31   PUBLIC   dyn_zdf       !  routine called by step.F90
32   PUBLIC   dyn_zdf_init  !  routine called by opa.F90
[456]33
[2528]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
[456]36
37   !! * Substitutions
38#  include "domzgr_substitute.h90"
39#  include "zdfddm_substitute.h90"
40#  include "vectopt_loop_substitute.h90"
41   !!----------------------------------------------------------------------
[2528]42   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
[1152]43   !! $Id$
[2528]44   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
[456]45   !!----------------------------------------------------------------------
46
47CONTAINS
48   
49   SUBROUTINE dyn_zdf( kt )
50      !!----------------------------------------------------------------------
51      !!                  ***  ROUTINE dyn_zdf  ***
52      !!
53      !! ** Purpose :   compute the vertical ocean dynamics physics.
54      !!---------------------------------------------------------------------
[2633]55      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
[2590]56      USE wrk_nemo, ONLY: ztrdu => wrk_3d_1, ztrdv => wrk_3d_2
57      !!
[456]58      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
59      !!---------------------------------------------------------------------
60
[2633]61      IF(wrk_in_use(3, 1,2))THEN
[2590]62         CALL ctl_stop('dyn_zdf: requested workspace arrays unavailable.')
63         RETURN
64      END IF
[456]65      !                                          ! set time step
[2528]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)
[456]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
[503]76      !
[2528]77      CASE ( 0 )   ;   CALL dyn_zdf_exp( kt, r2dt )      ! explicit scheme
78      CASE ( 1 )   ;   CALL dyn_zdf_imp( kt, r2dt )      ! implicit scheme
[503]79      !
80      CASE ( -1 )                                      ! esopa: test all possibility with control print
[2528]81                       CALL dyn_zdf_exp( kt, r2dt )
[684]82                       CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf0 - Ua: ', mask1=umask,               &
[503]83            &                        tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
[2528]84                       CALL dyn_zdf_imp( kt, r2dt )
[684]85                       CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf1 - Ua: ', mask1=umask,               &
[503]86            &                        tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
[456]87      END SELECT
88
[503]89      IF( l_trddyn )   THEN                      ! save the vertical diffusive trends for further diagnostics
[456]90         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
91         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
[503]92         CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_zdf, 'DYN', kt )
[456]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' )
[503]97      !
[2633]98      IF(wrk_not_released(3, 1,2))THEN
[2590]99         CALL ctl_stop('dyn_zdf: failed to release workspace arrays.')
100      END IF
101      !
[456]102   END SUBROUTINE dyn_zdf
103
104
[2528]105   SUBROUTINE dyn_zdf_init
[456]106      !!----------------------------------------------------------------------
[2528]107      !!                 ***  ROUTINE dyn_zdf_init  ***
[456]108      !!
[503]109      !! ** Purpose :   initializations of the vertical diffusion scheme
[456]110      !!
111      !! ** Method  :   implicit (euler backward) scheme (default)
112      !!                explicit (time-splitting) scheme if ln_zdfexp=T
113      !!----------------------------------------------------------------------
114      USE zdftke
[2528]115      USE zdfgls
[456]116      USE zdfkpp
117      !!----------------------------------------------------------------------
[2528]118      !
[456]119      ! Choice from ln_zdfexp read in namelist in zdfini
[503]120      IF( ln_zdfexp ) THEN   ;   nzdf = 0           ! use explicit scheme
121      ELSE                   ;   nzdf = 1           ! use implicit scheme
[456]122      ENDIF
[2528]123      !
[456]124      ! Force implicit schemes
[2528]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      !
[503]129      IF( lk_esopa )    nzdf = -1                   ! Esopa key: All schemes used
[2528]130      !
[503]131      IF(lwp) THEN                                  ! Print the choice
[456]132         WRITE(numout,*)
[2528]133         WRITE(numout,*) 'dyn_zdf_init : vertical dynamics physics scheme'
[456]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
[503]139      !
[2528]140   END SUBROUTINE dyn_zdf_init
[456]141
142   !!==============================================================================
143END MODULE dynzdf
Note: See TracBrowser for help on using the repository browser.