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

source: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90 @ 2623

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

dynamic mem: #785 ; TRA: move dyn allocation from nemogcm to module when possible (continuation)

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