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.
trazdf.F90 in branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/OPA_SRC/TRA – NEMO

source: branches/2017/dev_r7881_HPC09_ZDF/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90 @ 7953

Last change on this file since 7953 was 7953, checked in by gm, 7 years ago

#1880 (HPC-09): add zdfphy (the ZDF manager) + remove all key_...

  • Property svn:keywords set to Id
File size: 7.2 KB
RevLine 
[458]1MODULE trazdf
2   !!==============================================================================
3   !!                 ***  MODULE  trazdf  ***
4   !! Ocean active tracers:  vertical component of the tracer mixing trend
5   !!==============================================================================
[2528]6   !! History :  1.0  ! 2005-11  (G. Madec)  Original code
7   !!            3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
[458]8   !!----------------------------------------------------------------------
[503]9
10   !!----------------------------------------------------------------------
[6140]11   !!   tra_zdf       : Update the tracer trend with the vertical diffusion
12   !!   tra_zdf_init  : initialisation of the computation
[458]13   !!----------------------------------------------------------------------
[6140]14   USE oce            ! ocean dynamics and tracers variables
15   USE dom_oce        ! ocean space and time domain variables
16   USE domvvl         ! variable volume
17   USE phycst         ! physical constant
18   USE zdf_oce        ! ocean vertical physics variables
19   USE sbc_oce        ! surface boundary condition: ocean
20   USE ldftra         ! lateral diffusion: eddy diffusivity
21   USE ldfslp         ! lateral diffusion: iso-neutral slope
22   USE trazdf_exp     ! vertical diffusion: explicit (tra_zdf_exp routine)
23   USE trazdf_imp     ! vertical diffusion: implicit (tra_zdf_imp routine)
24   USE trd_oce        ! trends: ocean variables
25   USE trdtra         ! trends: tracer trend manager
[5836]26   !
[6140]27   USE in_out_manager ! I/O manager
28   USE prtctl         ! Print control
29   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
30   USE lib_mpp        ! MPP library
31   USE wrk_nemo       ! Memory allocation
32   USE timing         ! Timing
[592]33
[458]34   IMPLICIT NONE
35   PRIVATE
36
[2715]37   PUBLIC   tra_zdf        ! routine called by step.F90
38   PUBLIC   tra_zdf_init   ! routine called by nemogcm.F90
[458]39
[2715]40   INTEGER ::   nzdf = 0   ! type vertical diffusion algorithm used (defined from ln_zdf...  namlist logicals)
[458]41
42   !! * Substitutions
43#  include "vectopt_loop_substitute.h90"
44   !!----------------------------------------------------------------------
[5836]45   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
[888]46   !! $Id$
[2715]47   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
[458]48   !!----------------------------------------------------------------------
[2715]49CONTAINS
[458]50
51   SUBROUTINE tra_zdf( kt )
52      !!----------------------------------------------------------------------
53      !!                  ***  ROUTINE tra_zdf  ***
54      !!
55      !! ** Purpose :   compute the vertical ocean tracer physics.
56      !!---------------------------------------------------------------------
57      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
[6140]58      !
[7753]59      INTEGER  ::   jk                   ! Dummy loop indices
[3294]60      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztrdt, ztrds   ! 3D workspace
[458]61      !!---------------------------------------------------------------------
[3294]62      !
63      IF( nn_timing == 1 )  CALL timing_start('tra_zdf')
64      !
[458]65      IF( neuler == 0 .AND. kt == nit000 ) THEN     ! at nit000
[6140]66         r2dt =  rdt                          ! = rdt (restarting with Euler time stepping)
[458]67      ELSEIF( kt <= nit000 + 1) THEN                ! at nit000 or nit000+1
[6140]68         r2dt = 2. * rdt                      ! = 2 rdt (leapfrog)
[458]69      ENDIF
[6140]70      !
[2528]71      IF( l_trdtra )   THEN                    !* Save ta and sa trends
[3294]72         CALL wrk_alloc( jpi, jpj, jpk, ztrdt, ztrds )
[7753]73         ztrdt(:,:,:) = tsa(:,:,:,jp_tem)
74         ztrds(:,:,:) = tsa(:,:,:,jp_sal)
[458]75      ENDIF
[6140]76      !
[458]77      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
[6140]78      CASE ( 0 )    ;    CALL tra_zdf_exp( kt, nit000, 'TRA', r2dt, nn_zdfexp, tsb, tsa, jpts )  !   explicit scheme
79      CASE ( 1 )    ;    CALL tra_zdf_imp( kt, nit000, 'TRA', r2dt,            tsb, tsa, jpts )  !   implicit scheme
[458]80      END SELECT
[5836]81!!gm WHY here !   and I don't like that !
[5385]82      ! DRAKKAR SSS control {
83      ! JMM avoid negative salinities near river outlet ! Ugly fix
84      ! JMM : restore negative salinities to small salinities:
[7753]85      WHERE( tsa(:,:,:,jp_sal) < 0._wp )   tsa(:,:,:,jp_sal) = 0.1_wp
[5836]86!!gm
[458]87
[1110]88      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
89         DO jk = 1, jpkm1
[7753]90            ztrdt(:,:,jk) = ( ( tsa(:,:,jk,jp_tem) - tsb(:,:,jk,jp_tem) ) / r2dt ) - ztrdt(:,:,jk)
91            ztrds(:,:,jk) = ( ( tsa(:,:,jk,jp_sal) - tsb(:,:,jk,jp_sal) ) / r2dt ) - ztrds(:,:,jk)
[1110]92         END DO
[5836]93!!gm this should be moved in trdtra.F90 and done on all trends
[4990]94         CALL lbc_lnk( ztrdt, 'T', 1. )
95         CALL lbc_lnk( ztrds, 'T', 1. )
[5836]96!!gm
[4990]97         CALL trd_tra( kt, 'TRA', jp_tem, jptra_zdf, ztrdt )
98         CALL trd_tra( kt, 'TRA', jp_sal, jptra_zdf, ztrds )
[3294]99         CALL wrk_dealloc( jpi, jpj, jpk, ztrdt, ztrds )
[1110]100      ENDIF
101      !                                          ! print mean trends (used for debugging)
[2528]102      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' zdf  - Ta: ', mask1=tmask,               &
103         &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
[2715]104      !
[3294]105      IF( nn_timing == 1 )  CALL timing_stop('tra_zdf')
106      !
[458]107   END SUBROUTINE tra_zdf
108
109
[2528]110   SUBROUTINE tra_zdf_init
[458]111      !!----------------------------------------------------------------------
[2528]112      !!                 ***  ROUTINE tra_zdf_init  ***
[458]113      !!
114      !! ** Purpose :   Choose the vertical mixing scheme
115      !!
[789]116      !! ** Method  :   Set nzdf from ln_zdfexp
[458]117      !!      nzdf = 0   explicit (time-splitting) scheme (ln_zdfexp=T)
118      !!           = 1   implicit (euler backward) scheme (ln_zdfexp=F)
[5836]119      !!      NB: rotation of lateral mixing operator or TKE & GLS schemes,
120      !!          an implicit scheme is required.
[458]121      !!----------------------------------------------------------------------
122      USE zdftke
[2528]123      USE zdfgls
[458]124      !!----------------------------------------------------------------------
[6140]125      !
[7953]126      ! Choice from ln_zdfexp (namzdf namelist variable read in zdfphy module)
[2528]127      IF( ln_zdfexp ) THEN   ;   nzdf = 0           ! use explicit scheme
128      ELSE                   ;   nzdf = 1           ! use implicit scheme
[458]129      ENDIF
[6140]130      !
[458]131      ! Force implicit schemes
[7953]132      IF( ln_zdftke .OR. ln_zdfgls   )   nzdf = 1   ! TKE, or GLS physics
[5836]133      IF( ln_traldf_iso              )   nzdf = 1   ! iso-neutral lateral physics
134      IF( ln_traldf_hor .AND. ln_sco )   nzdf = 1   ! horizontal lateral physics in s-coordinate
[2528]135      IF( ln_zdfexp .AND. nzdf == 1 )   CALL ctl_stop( 'tra_zdf : If using the rotation of lateral mixing operator',   &
[5836]136            &                         ' GLS or TKE scheme, the implicit scheme is required, set ln_zdfexp = .false.' )
[6140]137            !
[458]138      IF(lwp) THEN
139         WRITE(numout,*)
[2528]140         WRITE(numout,*) 'tra_zdf_init : vertical tracer physics scheme'
[458]141         WRITE(numout,*) '~~~~~~~~~~~'
[7646]142         IF( nzdf ==  0 )   WRITE(numout,*) '      ===>>   Explicit time-splitting scheme'
143         IF( nzdf ==  1 )   WRITE(numout,*) '      ===>>   Implicit (euler backward) scheme'
[458]144      ENDIF
[2528]145      !
146   END SUBROUTINE tra_zdf_init
[458]147
148   !!==============================================================================
149END MODULE trazdf
Note: See TracBrowser for help on using the repository browser.