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

source: trunk/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90 @ 2715

Last change on this file since 2715 was 2715, checked in by rblod, 13 years ago

First attempt to put dynamic allocation on the trunk

  • Property svn:keywords set to Id
File size: 7.6 KB
Line 
1MODULE trazdf
2   !!==============================================================================
3   !!                 ***  MODULE  trazdf  ***
4   !! Ocean active tracers:  vertical component of the tracer mixing trend
5   !!==============================================================================
6   !! History :  1.0  ! 2005-11  (G. Madec)  Original code
7   !!            3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   tra_zdf      : Update the tracer trend with the vertical diffusion
12   !!   tra_zdf_init : initialisation of the computation
13   !!----------------------------------------------------------------------
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 dynspg_oce
21
22   USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
23   USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
24
25   USE ldftra_oce      ! ocean active tracers: lateral physics
26   USE trdmod_oce      ! ocean active tracers: lateral physics
27   USE trdtra      ! ocean tracers trends
28   USE in_out_manager  ! I/O manager
29   USE prtctl          ! Print control
30   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
31   USE lib_mpp         ! MPP library
32
33
34   IMPLICIT NONE
35   PRIVATE
36
37   PUBLIC   tra_zdf        ! routine called by step.F90
38   PUBLIC   tra_zdf_init   ! routine called by nemogcm.F90
39
40   INTEGER ::   nzdf = 0   ! type vertical diffusion algorithm used (defined from ln_zdf...  namlist logicals)
41
42   !! * Substitutions
43#  include "domzgr_substitute.h90"
44#  include "zdfddm_substitute.h90"
45#  include "vectopt_loop_substitute.h90"
46   !!----------------------------------------------------------------------
47   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
48   !! $Id$
49   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
50   !!----------------------------------------------------------------------
51CONTAINS
52
53   SUBROUTINE tra_zdf( kt )
54      !!----------------------------------------------------------------------
55      !!                  ***  ROUTINE tra_zdf  ***
56      !!
57      !! ** Purpose :   compute the vertical ocean tracer physics.
58      !!---------------------------------------------------------------------
59      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
60      !!
61      INTEGER  ::   jk                   ! Dummy loop indices
62      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrdt, ztrds   ! 3D workspace
63      !!---------------------------------------------------------------------
64
65      !                                          ! set time step
66      IF( neuler == 0 .AND. kt == nit000 ) THEN     ! at nit000
67         r2dtra(:) =  rdttra(:)                          ! = rdtra (restarting with Euler time stepping)
68      ELSEIF( kt <= nit000 + 1) THEN                ! at nit000 or nit000+1
69         r2dtra(:) = 2. * rdttra(:)                      ! = 2 rdttra (leapfrog)
70      ENDIF
71
72      IF( l_trdtra )   THEN                    !* Save ta and sa trends
73         ALLOCATE( ztrdt(jpi,jpj,jpk) )   ;    ztrdt(:,:,:) = tsa(:,:,:,jp_tem)
74         ALLOCATE( ztrds(jpi,jpj,jpk) )   ;    ztrds(:,:,:) = tsa(:,:,:,jp_sal)
75      ENDIF
76
77      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
78      CASE ( 0 )    ;    CALL tra_zdf_exp( kt, 'TRA', r2dtra, nn_zdfexp, tsb, tsa, jpts )  !   explicit scheme
79      CASE ( 1 )    ;    CALL tra_zdf_imp( kt, 'TRA', r2dtra,            tsb, tsa, jpts )  !   implicit scheme
80      CASE ( -1 )                                       ! esopa: test all possibility with control print
81         CALL tra_zdf_exp( kt, 'TRA', r2dtra, nn_zdfexp, tsb, tsa, jpts )
82         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' zdf0 - Ta: ', mask1=tmask,               &
83         &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
84         CALL tra_zdf_imp( kt, 'TRA', r2dtra,            tsb, tsa, jpts ) 
85         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' zdf1 - Ta: ', mask1=tmask,               &
86         &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
87      END SELECT
88
89      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
90         DO jk = 1, jpkm1
91            ztrdt(:,:,jk) = ( ( tsa(:,:,jk,jp_tem) - tsb(:,:,jk,jp_tem) ) / r2dtra(jk) ) - ztrdt(:,:,jk)
92            ztrds(:,:,jk) = ( ( tsa(:,:,jk,jp_sal) - tsb(:,:,jk,jp_sal) ) / r2dtra(jk) ) - ztrds(:,:,jk)
93         END DO
94         CALL trd_tra( kt, 'TRA', jp_tem, jptra_trd_zdf, ztrdt )
95         CALL trd_tra( kt, 'TRA', jp_sal, jptra_trd_zdf, ztrds )
96         DEALLOCATE( ztrdt )      ;     DEALLOCATE( ztrds ) 
97      ENDIF
98
99      !                                          ! print mean trends (used for debugging)
100      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' zdf  - Ta: ', mask1=tmask,               &
101         &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
102      !
103   END SUBROUTINE tra_zdf
104
105
106   SUBROUTINE tra_zdf_init
107      !!----------------------------------------------------------------------
108      !!                 ***  ROUTINE tra_zdf_init  ***
109      !!
110      !! ** Purpose :   Choose the vertical mixing scheme
111      !!
112      !! ** Method  :   Set nzdf from ln_zdfexp
113      !!      nzdf = 0   explicit (time-splitting) scheme (ln_zdfexp=T)
114      !!           = 1   implicit (euler backward) scheme (ln_zdfexp=F)
115      !!      NB: rotation of lateral mixing operator or TKE or KPP scheme,
116      !!      the implicit scheme is required.
117      !!----------------------------------------------------------------------
118      USE zdftke
119      USE zdfgls
120      USE zdfkpp
121      !!----------------------------------------------------------------------
122
123      ! Choice from ln_zdfexp already read in namelist in zdfini module
124      IF( ln_zdfexp ) THEN   ;   nzdf = 0           ! use explicit scheme
125      ELSE                   ;   nzdf = 1           ! use implicit scheme
126      ENDIF
127
128      ! Force implicit schemes
129      IF( lk_zdftke .OR. lk_zdfgls .OR. lk_zdfkpp )   nzdf = 1      ! TKE, GLS or KPP physics
130      IF( ln_traldf_iso                           )   nzdf = 1      ! iso-neutral lateral physics
131      IF( ln_traldf_hor .AND. ln_sco              )   nzdf = 1      ! horizontal lateral physics in s-coordinate
132      IF( ln_zdfexp .AND. nzdf == 1 )   CALL ctl_stop( 'tra_zdf : If using the rotation of lateral mixing operator',   &
133            &                         ' TKE or KPP scheme, the implicit scheme is required, set ln_zdfexp = .false.' )
134
135      ! Test: esopa
136      IF( lk_esopa )    nzdf = -1                      ! All schemes used
137
138      IF(lwp) THEN
139         WRITE(numout,*)
140         WRITE(numout,*) 'tra_zdf_init : vertical tracer physics scheme'
141         WRITE(numout,*) '~~~~~~~~~~~'
142         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
143         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
144         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
145      ENDIF
146      !
147   END SUBROUTINE tra_zdf_init
148
149   !!==============================================================================
150END MODULE trazdf
Note: See TracBrowser for help on using the repository browser.