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 @ 2598

Last change on this file since 2598 was 2590, checked in by trackstand2, 13 years ago

Merge branch 'dynamic_memory' into master-svn-dyn

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