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.
trczdf.F90 in branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90 @ 2636

Last change on this file since 2636 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: 8.8 KB
Line 
1MODULE trczdf
2   !!==============================================================================
3   !!                 ***  MODULE  trczdf  ***
4   !! Ocean Passive tracers : vertical diffusive trends
5   !!=====================================================================
6   !! History :  9.0  ! 2005-11 (G. Madec)  Original code
7   !!       NEMO 3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
8   !!----------------------------------------------------------------------
9#if defined key_top
10   !!----------------------------------------------------------------------
11   !!   'key_top'                                                TOP models
12   !!----------------------------------------------------------------------
13   !!----------------------------------------------------------------------
14   !!   trc_ldf     : update the tracer trend with the lateral diffusion
15   !!       ldf_ctl : initialization, namelist read, and parameters control
16   !!----------------------------------------------------------------------
17   USE oce_trc         ! ocean dynamics and active tracers
18   USE trc             ! ocean passive tracers variables
19   USE trcnam_trp      ! passive tracers transport namelist variables
20   USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
21   USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
22   USE trdmod_oce
23   USE trdtra
24   USE prtctl_trc      ! Print control
25   USE in_out_manager  ! I/O manager
26   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
27   USE lib_mpp         ! MPP library
28
29   IMPLICIT NONE
30   PRIVATE
31
32   PUBLIC   trc_zdf          ! called by step.F90
33   PUBLIC   trc_zdf_alloc    ! called by nemogcm.F90
34
35   INTEGER ::   nzdf = 0               ! type vertical diffusion algorithm used
36      !                                ! defined from ln_zdf...  namlist logicals)
37   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::  r2dt   ! vertical profile time-step, = 2 rdttra
38      !                                ! except at nit000 (=rdttra) if neuler=0
39
40   !! * Substitutions
41#  include "domzgr_substitute.h90"
42#  include "zdfddm_substitute.h90"
43#  include "vectopt_loop_substitute.h90"
44   !!----------------------------------------------------------------------
45   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
46   !! $Id$
47   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
48   !!----------------------------------------------------------------------
49
50CONTAINS
51   
52   FUNCTION trc_zdf_alloc()
53      !!----------------------------------------------------------------------
54      !!                  ***  ROUTINE trc_zdf_alloc  ***
55      !!----------------------------------------------------------------------
56      INTEGER :: trc_zdf_alloc
57      !!----------------------------------------------------------------------
58
59      ALLOCATE(r2dt(jpk), Stat=trc_zdf_alloc)
60
61      IF(trc_zdf_alloc /= 0)THEN
62         CALL ctl_warn('trc_zdf_alloc : failed to allocate array.')
63      END IF
64
65   END FUNCTION trc_zdf_alloc
66
67
68   SUBROUTINE trc_zdf( kt )
69      !!----------------------------------------------------------------------
70      !!                  ***  ROUTINE trc_zdf  ***
71      !!
72      !! ** Purpose :   compute the vertical ocean tracer physics.
73      !!---------------------------------------------------------------------
74      INTEGER, INTENT( in ) ::  kt      ! ocean time-step index
75      !
76      INTEGER               ::  jk, jn
77      CHARACTER (len=22)    :: charout
78      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   ztrtrd   ! 4D workspace
79      !!---------------------------------------------------------------------
80
81      IF( kt == nit000 )   CALL zdf_ctl          ! initialisation & control of options
82
83#if ! defined key_pisces
84      IF( neuler == 0 .AND. kt == nit000 ) THEN     ! at nit000
85         r2dt(:) =  rdttrc(:)           ! = rdttrc (restarting with Euler time stepping)
86      ELSEIF( kt <= nit000 + nn_dttrc ) THEN          ! at nit000 or nit000+1
87         r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
88      ENDIF
89#else
90      r2dt(:) =  rdttrc(:)              ! = rdttrc (for PISCES use Euler time stepping)
91#endif
92
93      IF( l_trdtrc )  THEN
94         ALLOCATE( ztrtrd(jpi,jpj,jpk,jptra) )   ! temporary save of trends
95         ztrtrd(:,:,:,:)  = tra(:,:,:,:)
96      ENDIF
97
98      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
99      CASE ( -1 )                                       ! esopa: test all possibility with control print
100         CALL tra_zdf_exp( kt, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra ) 
101         WRITE(charout, FMT="('zdf1 ')") ;  CALL prt_ctl_trc_info(charout)
102                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
103         CALL tra_zdf_imp( kt, 'TRC', r2dt,                trb, tra, jptra ) 
104         WRITE(charout, FMT="('zdf2 ')") ;  CALL prt_ctl_trc_info(charout)
105                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
106      CASE ( 0 ) ;  CALL tra_zdf_exp( kt, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra )    !   explicit scheme
107      CASE ( 1 ) ;  CALL tra_zdf_imp( kt, 'TRC', r2dt,                trb, tra, jptra )    !   implicit scheme         
108
109      END SELECT
110
111      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
112         DO jn = 1, jptra
113            DO jk = 1, jpkm1
114               ztrtrd(:,:,jk,jn) = ( ( tra(:,:,jk,jn) - trb(:,:,jk,jn) ) / r2dt(jk) ) - ztrtrd(:,:,jk,jn)
115            END DO
116            CALL trd_tra( kt, 'TRC', jn, jptra_trd_zdf, ztrtrd(:,:,:,jn) )
117         END DO
118         DEALLOCATE( ztrtrd )
119      ENDIF
120
121      !                                          ! print mean trends (used for debugging)
122      IF( ln_ctl )   THEN
123         WRITE(charout, FMT="('zdf ')") ;  CALL prt_ctl_trc_info(charout)
124                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
125      END IF
126      !
127   END SUBROUTINE trc_zdf
128
129
130   SUBROUTINE zdf_ctl
131      !!----------------------------------------------------------------------
132      !!                 ***  ROUTINE zdf_ctl  ***
133      !!
134      !! ** Purpose :   Choose the vertical mixing scheme
135      !!
136      !! ** Method  :   Set nzdf from ln_zdfexp
137      !!      nzdf = 0   explicit (time-splitting) scheme (ln_trczdf_exp=T)
138      !!           = 1   implicit (euler backward) scheme (ln_trczdf_exp=F)
139      !!      NB: The implicit scheme is required when using :
140      !!             - rotated lateral mixing operator
141      !!             - TKE, GLS or KPP vertical mixing scheme
142      !!----------------------------------------------------------------------
143
144      !  Define the vertical tracer physics scheme
145      ! ==========================================
146
147      ! Choice from ln_zdfexp already read in namelist in zdfini module
148      IF( ln_trczdf_exp ) THEN           ! use explicit scheme
149         nzdf = 0
150      ELSE                               ! use implicit scheme
151         nzdf = 1
152      ENDIF
153
154      ! Force implicit schemes
155      IF( ln_trcldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
156      IF( ln_trcldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
157#if defined key_zdftke || defined key_zdfgls || defined key_zdfkpp
158                                                          nzdf = 1      ! TKE, GLS or KPP physics       
159#endif
160      IF( ln_trczdf_exp .AND. nzdf == 1 )   THEN
161         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS or KPP vertical scheme ', &
162            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
163      ENDIF
164
165      ! Test: esopa
166      IF( lk_esopa )    nzdf = -1                      ! All schemes used
167
168      IF(lwp) THEN
169         WRITE(numout,*)
170         WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme'
171         WRITE(numout,*) '~~~~~~~~~~~'
172         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
173         IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
174         IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
175      ENDIF
176
177   END SUBROUTINE zdf_ctl
178#else
179   !!----------------------------------------------------------------------
180   !!   Default option                                         Empty module
181   !!----------------------------------------------------------------------
182CONTAINS
183   SUBROUTINE trc_zdf( kt )
184      INTEGER, INTENT(in) :: kt 
185      WRITE(*,*) 'trc_zdf: You should not have seen this print! error?', kt
186   END SUBROUTINE trc_zdf
187#endif
188   !!==============================================================================
189END MODULE trczdf
Note: See TracBrowser for help on using the repository browser.