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

Last change on this file since 7698 was 7698, checked in by mocavero, 7 years ago

update trunk with OpenMP parallelization

  • Property svn:keywords set to Id
File size: 7.8 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 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
26   !
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
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 "zdfddm_substitute.h90"
44#  include "vectopt_loop_substitute.h90"
45   !!----------------------------------------------------------------------
46   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
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, jj, ji           ! Dummy loop indices
61      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztrdt, ztrds   ! 3D workspace
62      !!---------------------------------------------------------------------
63      !
64      IF( nn_timing == 1 )  CALL timing_start('tra_zdf')
65      !
66      IF( neuler == 0 .AND. kt == nit000 ) THEN     ! at nit000
67         r2dt =  rdt                          ! = rdt (restarting with Euler time stepping)
68      ELSEIF( kt <= nit000 + 1) THEN                ! at nit000 or nit000+1
69         r2dt = 2. * rdt                      ! = 2 rdt (leapfrog)
70      ENDIF
71      !
72      IF( l_trdtra )   THEN                    !* Save ta and sa trends
73         CALL wrk_alloc( jpi, jpj, jpk, ztrdt, ztrds )
74!$OMP PARALLEL DO schedule(static) private(jk, jj, ji)
75         DO jk = 1, jpk
76            DO jj = 1, jpj
77               DO ji = 1, jpi
78                  ztrdt(ji,jj,jk) = tsa(ji,jj,jk,jp_tem)
79                  ztrds(ji,jj,jk) = tsa(ji,jj,jk,jp_sal)
80               END DO
81            END DO
82         END DO
83      ENDIF
84      !
85      SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
86      CASE ( 0 )    ;    CALL tra_zdf_exp( kt, nit000, 'TRA', r2dt, nn_zdfexp, tsb, tsa, jpts )  !   explicit scheme
87      CASE ( 1 )    ;    CALL tra_zdf_imp( kt, nit000, 'TRA', r2dt,            tsb, tsa, jpts )  !   implicit scheme
88      END SELECT
89!!gm WHY here !   and I don't like that !
90      ! DRAKKAR SSS control {
91      ! JMM avoid negative salinities near river outlet ! Ugly fix
92      ! JMM : restore negative salinities to small salinities:
93!$OMP PARALLEL DO schedule(static) private(jk, jj, ji)
94      DO jk = 1, jpk
95         DO jj = 1, jpj
96            DO ji = 1, jpi
97               IF( tsa(ji,jj,jk,jp_sal) < 0._wp )   tsa(ji,jj,jk,jp_sal) = 0.1_wp
98            END DO
99         END DO
100      END DO
101!!gm
102
103      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
104!$OMP PARALLEL DO schedule(static) private(jk,jj,ji)
105         DO jk = 1, jpkm1
106            DO jj = 1, jpj
107               DO ji = 1, jpi
108                  ztrdt(ji,jj,jk) = ( ( tsa(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) ) / r2dt ) - ztrdt(ji,jj,jk)
109                  ztrds(ji,jj,jk) = ( ( tsa(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) ) / r2dt ) - ztrds(ji,jj,jk)
110               END DO
111            END DO
112         END DO
113!!gm this should be moved in trdtra.F90 and done on all trends
114         CALL lbc_lnk( ztrdt, 'T', 1. )
115         CALL lbc_lnk( ztrds, 'T', 1. )
116!!gm
117         CALL trd_tra( kt, 'TRA', jp_tem, jptra_zdf, ztrdt )
118         CALL trd_tra( kt, 'TRA', jp_sal, jptra_zdf, ztrds )
119         CALL wrk_dealloc( jpi, jpj, jpk, ztrdt, ztrds )
120      ENDIF
121      !                                          ! print mean trends (used for debugging)
122      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' zdf  - Ta: ', mask1=tmask,               &
123         &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
124      !
125      IF( nn_timing == 1 )  CALL timing_stop('tra_zdf')
126      !
127   END SUBROUTINE tra_zdf
128
129
130   SUBROUTINE tra_zdf_init
131      !!----------------------------------------------------------------------
132      !!                 ***  ROUTINE tra_zdf_init  ***
133      !!
134      !! ** Purpose :   Choose the vertical mixing scheme
135      !!
136      !! ** Method  :   Set nzdf from ln_zdfexp
137      !!      nzdf = 0   explicit (time-splitting) scheme (ln_zdfexp=T)
138      !!           = 1   implicit (euler backward) scheme (ln_zdfexp=F)
139      !!      NB: rotation of lateral mixing operator or TKE & GLS schemes,
140      !!          an implicit scheme is required.
141      !!----------------------------------------------------------------------
142      USE zdftke
143      USE zdfgls
144      !!----------------------------------------------------------------------
145      !
146      ! Choice from ln_zdfexp already read in namelist in zdfini module
147      IF( ln_zdfexp ) THEN   ;   nzdf = 0           ! use explicit scheme
148      ELSE                   ;   nzdf = 1           ! use implicit scheme
149      ENDIF
150      !
151      ! Force implicit schemes
152      IF( lk_zdftke .OR. lk_zdfgls   )   nzdf = 1   ! TKE, or GLS physics
153      IF( ln_traldf_iso              )   nzdf = 1   ! iso-neutral lateral physics
154      IF( ln_traldf_hor .AND. ln_sco )   nzdf = 1   ! horizontal lateral physics in s-coordinate
155      IF( ln_zdfexp .AND. nzdf == 1 )   CALL ctl_stop( 'tra_zdf : If using the rotation of lateral mixing operator',   &
156            &                         ' GLS or TKE scheme, the implicit scheme is required, set ln_zdfexp = .false.' )
157            !
158      IF(lwp) THEN
159         WRITE(numout,*)
160         WRITE(numout,*) 'tra_zdf_init : vertical tracer physics scheme'
161         WRITE(numout,*) '~~~~~~~~~~~'
162         IF( nzdf ==  0 )   WRITE(numout,*) '      ===>>   Explicit time-splitting scheme'
163         IF( nzdf ==  1 )   WRITE(numout,*) '      ===>>   Implicit (euler backward) scheme'
164      ENDIF
165      !
166   END SUBROUTINE tra_zdf_init
167
168   !!==============================================================================
169END MODULE trazdf
Note: See TracBrowser for help on using the repository browser.