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.
trcdmp.F90 in trunk/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90 @ 3294

Last change on this file since 3294 was 3294, checked in by rblod, 12 years ago

Merge of 3.4beta into the trunk

  • Property svn:keywords set to Id
File size: 10.7 KB
Line 
1MODULE trcdmp
2   !!======================================================================
3   !!                       ***  MODULE  trcdmp  ***
4   !! Ocean physics: internal restoring trend on passive tracers
5   !!======================================================================
6   !! History :  OPA  !  1991-03  (O. Marti, G. Madec)  Original code
7   !!                 !  1996-01  (G. Madec) statement function for e3
8   !!                 !  1997-05  (H. Loukos)  adapted for passive tracers
9   !!    NEMO    9.0  !  2004-03  (C. Ethe)    free form + modules
10   !!            3.2  !  2007-02  (C. Deltel)  Diagnose ML trends for passive tracers
11   !!            3.3  !  2010-06  (C. Ethe, G. Madec) merge TRA-TRC
12   !!----------------------------------------------------------------------
13#if  defined key_top && defined key_trcdmp 
14   !!----------------------------------------------------------------------
15   !!   key_trcdmp                                         internal damping
16   !!----------------------------------------------------------------------
17   !!   trc_dmp      : update the tracer trend with the internal damping
18   !!   trc_dmp_init : initialization, namlist read, parameters control
19   !!----------------------------------------------------------------------
20   USE oce_trc         ! ocean dynamics and tracers variables
21   USE trc             ! ocean passive tracers variables
22   USE trcnam_trp      ! passive tracers transport namelist variables
23   USE trcdta
24   USE tradmp
25   USE prtctl_trc      ! Print control for debbuging
26   USE trdtra
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC trc_dmp            ! routine called by step.F90
32   PUBLIC trc_dmp_alloc      ! routine called by nemogcm.F90
33
34   LOGICAL , PUBLIC, PARAMETER ::   lk_trcdmp = .TRUE.   !: internal damping flag
35
36   !                                !!* Namelist namtrc_dmp : passive tracer newtonian damping *
37   INTEGER  ::   nn_hdmp_tr =   -1   ! = 0/-1/'latitude' for damping over passive tracer
38   INTEGER  ::   nn_zdmp_tr =    0   ! = 0/1/2 flag for damping in the mixed layer
39   REAL(wp) ::   rn_surf_tr =   50.  ! surface time scale for internal damping        [days]
40   REAL(wp) ::   rn_bot_tr  =  360.  ! bottom time scale for internal damping         [days]
41   REAL(wp) ::   rn_dep_tr  =  800.  ! depth of transition between rn_surf and rn_bot [meters]
42   INTEGER  ::   nn_file_tr =    2   ! = 1 create a damping.coeff NetCDF file
43
44   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   restotr   ! restoring coeff. on tracers (s-1)
45
46   !! * Substitutions
47#  include "top_substitute.h90"
48   !!----------------------------------------------------------------------
49   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
50   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/TOP_SRC/TRP/trcdmp.F90,v 1.11 2006/09/01 14:03:49 opalod Exp $
51   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
52   !!----------------------------------------------------------------------
53CONTAINS
54
55   INTEGER FUNCTION trc_dmp_alloc()
56      !!----------------------------------------------------------------------
57      !!                   ***  ROUTINE trc_dmp_alloc  ***
58      !!----------------------------------------------------------------------
59      ALLOCATE( restotr(jpi,jpj,jpk) , STAT=trc_dmp_alloc )
60      !
61      IF( trc_dmp_alloc /= 0 )   CALL ctl_warn('trc_dmp_alloc: failed to allocate array')
62      !
63   END FUNCTION trc_dmp_alloc
64
65
66   SUBROUTINE trc_dmp( kt )
67      !!----------------------------------------------------------------------
68      !!                   ***  ROUTINE trc_dmp  ***
69      !!                 
70      !! ** Purpose :   Compute the passive tracer trend due to a newtonian damping
71      !!      of the tracer field towards given data field and add it to the
72      !!      general tracer trends.
73      !!
74      !! ** Method  :   Newtonian damping towards trdta computed
75      !!      and add to the general tracer trends:
76      !!                     trn = tra + restotr * (trdta - trb)
77      !!         The trend is computed either throughout the water column
78      !!      (nlmdmptr=0) or in area of weak vertical mixing (nlmdmptr=1) or
79      !!      below the well mixed layer (nlmdmptr=2)
80      !!
81      !! ** Action  : - update the tracer trends tra with the newtonian
82      !!                damping trends.
83      !!              - save the trends ('key_trdmld_trc')
84      !!----------------------------------------------------------------------
85      !!
86      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
87      !!
88      INTEGER  ::   ji, jj, jk, jn       ! dummy loop indices
89      REAL(wp) ::   ztra                 ! temporary scalars
90      CHARACTER (len=22) :: charout
91      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztrtrd
92      !!----------------------------------------------------------------------
93      !
94      IF( nn_timing == 1 )  CALL timing_start('trc_dmp')
95      !
96      ! 0. Initialization (first time-step only)
97      !    --------------
98      IF( kt == nittrc000 ) CALL trc_dmp_init
99
100      IF( l_trdtrc )   CALL wrk_alloc( jpi, jpj, jpk, ztrtrd )   ! temporary save of trends
101
102      ! 1. Newtonian damping trends on tracer fields
103      ! --------------------------------------------
104      ! Initialize the input fields for newtonian damping
105      CALL trc_dta( kt )
106      !                                                          ! ===========
107      DO jn = 1, jptra                                           ! tracer loop
108         !                                                       ! ===========
109         IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)    ! save trends
110
111         IF( lutini(jn) ) THEN
112            !
113            SELECT CASE ( nn_zdmp_trc )
114            !
115            CASE( 0 )                !==  newtonian damping throughout the water column  ==!
116               DO jk = 1, jpkm1
117                  DO jj = 2, jpjm1
118                     DO ji = fs_2, fs_jpim1   ! vector opt.
119                        ztra = restotr(ji,jj,jk) * ( trdta(ji,jj,jk,jn) - trb(ji,jj,jk,jn) )
120                        tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
121                     END DO
122                  END DO
123               END DO
124            !
125            CASE ( 1 )                !==  no damping in the turbocline (avt > 5 cm2/s)  ==!
126               DO jk = 1, jpkm1
127                  DO jj = 2, jpjm1
128                     DO ji = fs_2, fs_jpim1   ! vector opt.
129                        IF( avt(ji,jj,jk) <= 5.e-4 )  THEN
130                           ztra = restotr(ji,jj,jk) * ( trdta(ji,jj,jk,jn) - trb(ji,jj,jk,jn) )
131                           tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
132                        ENDIF
133                     END DO
134                  END DO
135               END DO
136            !
137            CASE ( 2 )               !==  no damping in the mixed layer   ==!
138               DO jk = 1, jpkm1
139                  DO jj = 2, jpjm1
140                     DO ji = fs_2, fs_jpim1   ! vector opt.
141                        IF( fsdept(ji,jj,jk) >= hmlp (ji,jj) ) THEN
142                           ztra = restotr(ji,jj,jk,jn) * ( trdta(ji,jj,jk,jn) - trb(ji,jj,jk,jn) )
143                           tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
144                        END IF
145                     END DO
146                  END DO
147               END DO
148           
149            END SELECT
150            !
151         ENDIF
152         !
153         IF( l_trdtrc ) THEN
154            ztrtrd(:,:,:) = tra(:,:,:,jn) -  ztrtrd(:,:,:)
155            CALL trd_tra( kt, 'TRC', jn, jptra_trd_dmp, ztrtrd )
156         END IF
157         !                                                       ! ===========
158      END DO                                                     ! tracer loop
159      !                                                          ! ===========
160      IF( l_trdtrc )  CALL wrk_dealloc( jpi, jpj, jpk, ztrtrd )
161      !                                          ! print mean trends (used for debugging)
162      IF( ln_ctl )   THEN
163         WRITE(charout, FMT="('dmp ')") ;  CALL prt_ctl_trc_info(charout)
164                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
165      ENDIF
166      !
167      IF( nn_timing == 1 )  CALL timing_stop('trc_dmp')
168      !
169   END SUBROUTINE trc_dmp
170
171
172   SUBROUTINE trc_dmp_init
173      !!----------------------------------------------------------------------
174      !!                  ***  ROUTINE trc_dmp_init  ***
175      !!
176      !! ** Purpose :   Initialization for the newtonian damping
177      !!
178      !! ** Method  :   read the nammbf namelist and check the parameters
179      !!              called by trc_dmp at the first timestep (nittrc000)
180      !!----------------------------------------------------------------------
181      !
182      IF( nn_timing == 1 )  CALL timing_start('trc_dmp_init')
183      !
184      SELECT CASE ( nn_hdmp_tr )
185      CASE (  -1  )   ;   IF(lwp) WRITE(numout,*) '   tracer damping in the Med & Red seas only'
186      CASE ( 1:90 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping poleward of', nn_hdmp_tr, ' degrees'
187      CASE DEFAULT
188         WRITE(ctmp1,*) '          bad flag value for nn_hdmp_tr = ', nn_hdmp_tr
189         CALL ctl_stop(ctmp1)
190      END SELECT
191
192      SELECT CASE ( nn_zdmp_tr )
193      CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping throughout the water column'
194      CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the turbocline (avt > 5 cm2/s)'
195      CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed layer'
196      CASE DEFAULT
197         WRITE(ctmp1,*) 'bad flag value for nn_zdmp_tr = ', nn_zdmp_tr
198         CALL ctl_stop(ctmp1)
199      END SELECT
200
201      IF( .NOT. lk_dtatrc )   &
202         &   CALL ctl_stop( 'no passive tracer data define key_dtatrc' )
203
204      IF( .NOT. lk_tradmp )   &
205         &   CALL ctl_stop( 'passive trace damping need key_tradmp to compute damping coef.' )
206      !
207      !                          ! Damping coefficients initialization
208      IF( lzoom ) THEN   ;   CALL dtacof_zoom( restotr )
209      ELSE               ;   CALL dtacof( nn_hdmp_tr, rn_surf_tr, rn_bot_tr, rn_dep_tr,  &
210                             &            nn_file_tr, 'TRC'     , restotr                )
211      ENDIF
212      !
213      IF( nn_timing == 1 )  CALL timing_stop('trc_dmp_init')
214      !
215   END SUBROUTINE trc_dmp_init
216#else
217   !!----------------------------------------------------------------------
218   !!   Default key                                     NO internal damping
219   !!----------------------------------------------------------------------
220   LOGICAL , PUBLIC, PARAMETER ::   lk_trcdmp = .FALSE.    !: internal damping flag
221CONTAINS
222   SUBROUTINE trc_dmp( kt )        ! Empty routine
223      INTEGER, INTENT(in) :: kt
224      WRITE(*,*) 'trc_dmp: You should not have seen this print! error?', kt
225   END SUBROUTINE trc_dmp
226#endif
227   !!======================================================================
228END MODULE trcdmp
Note: See TracBrowser for help on using the repository browser.