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 branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90 @ 5845

Last change on this file since 5845 was 5845, checked in by gm, 8 years ago

#1613: vvl by default: suppression of domzgr_substitute.h90

  • Property svn:keywords set to Id
File size: 17.5 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 
14   !!----------------------------------------------------------------------
15   !!   trc_dmp      : update the tracer trend with the internal damping
16   !!   trc_dmp_init : initialization, namlist read, parameters control
17   !!----------------------------------------------------------------------
18   USE oce_trc         ! ocean dynamics and tracers variables
19   USE trc             ! ocean passive tracers variables
20   USE trcdta
21   USE tradmp
22   USE prtctl_trc      ! Print control for debbuging
23   USE trdtra
24   USE trd_oce
25   USE iom
26
27   IMPLICIT NONE
28   PRIVATE
29
30   PUBLIC trc_dmp     
31   PUBLIC trc_dmp_clo   
32   PUBLIC trc_dmp_alloc 
33   PUBLIC trc_dmp_ini   
34
35   INTEGER , PUBLIC ::   nn_zdmp_tr    ! = 0/1/2 flag for damping in the mixed layer
36   CHARACTER(LEN=200) , PUBLIC :: cn_resto_tr    !File containing restoration coefficient
37
38   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   restotr   ! restoring coeff. on tracers (s-1)
39
40   INTEGER, PARAMETER           ::   npncts   = 5        ! number of closed sea
41   INTEGER, DIMENSION(npncts)   ::   nctsi1, nctsj1      ! south-west closed sea limits (i,j)
42   INTEGER, DIMENSION(npncts)   ::   nctsi2, nctsj2      ! north-east closed sea limits (i,j)
43
44   !! * Substitutions
45#  include "vectopt_loop_substitute.h90"
46   !!----------------------------------------------------------------------
47   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
48   !! $Id$
49   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
50   !!----------------------------------------------------------------------
51CONTAINS
52
53   INTEGER FUNCTION trc_dmp_alloc()
54      !!----------------------------------------------------------------------
55      !!                   ***  ROUTINE trc_dmp_alloc  ***
56      !!----------------------------------------------------------------------
57      ALLOCATE( restotr(jpi,jpj,jpk) , STAT=trc_dmp_alloc )
58      !
59      IF( trc_dmp_alloc /= 0 )   CALL ctl_warn('trc_dmp_alloc: failed to allocate array')
60      !
61   END FUNCTION trc_dmp_alloc
62
63
64   SUBROUTINE trc_dmp( kt )
65      !!----------------------------------------------------------------------
66      !!                   ***  ROUTINE trc_dmp  ***
67      !!                 
68      !! ** Purpose :   Compute the passive tracer trend due to a newtonian damping
69      !!      of the tracer field towards given data field and add it to the
70      !!      general tracer trends.
71      !!
72      !! ** Method  :   Newtonian damping towards trdta computed
73      !!      and add to the general tracer trends:
74      !!                     trn = tra + restotr * (trdta - trb)
75      !!         The trend is computed either throughout the water column
76      !!      (nlmdmptr=0) or in area of weak vertical mixing (nlmdmptr=1) or
77      !!      below the well mixed layer (nlmdmptr=2)
78      !!
79      !! ** Action  : - update the tracer trends tra with the newtonian
80      !!                damping trends.
81      !!              - save the trends ('key_trdmxl_trc')
82      !!----------------------------------------------------------------------
83      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
84      !
85      INTEGER  ::   ji, jj, jk, jn, jl   ! dummy loop indices
86      CHARACTER (len=22) :: charout
87      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztrtrd
88      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta   ! 3D  workspace
89      !!----------------------------------------------------------------------
90      !
91      IF( nn_timing == 1 )  CALL timing_start('trc_dmp')
92      !
93      IF( l_trdtrc )   CALL wrk_alloc( jpi, jpj, jpk, ztrtrd )   ! temporary save of trends
94      !
95      IF( nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
96         !
97         CALL wrk_alloc( jpi, jpj, jpk, ztrcdta )    ! Memory allocation
98         !                                                          ! ===========
99         DO jn = 1, jptra                                           ! tracer loop
100            !                                                       ! ===========
101            IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn)    ! save trends
102            !
103            IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
104               !
105               jl = n_trc_index(jn) 
106               CALL trc_dta( kt, sf_trcdta(jl),rf_trfac(jl) )   ! read tracer data at nit000
107               ztrcdta(:,:,:) = sf_trcdta(jl)%fnow(:,:,:)
108               !
109               SELECT CASE ( nn_zdmp_tr )
110               !
111               CASE( 0 )                !==  newtonian damping throughout the water column  ==!
112                  DO jk = 1, jpkm1
113                     DO jj = 2, jpjm1
114                        DO ji = fs_2, fs_jpim1   ! vector opt.
115                           tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - trb(ji,jj,jk,jn) )
116                        END DO
117                     END DO
118                  END DO
119                  !
120               CASE ( 1 )                !==  no damping in the turbocline (avt > 5 cm2/s)  ==!
121                  DO jk = 1, jpkm1
122                     DO jj = 2, jpjm1
123                        DO ji = fs_2, fs_jpim1   ! vector opt.
124                           IF( avt(ji,jj,jk) <= 5.e-4_wp )  THEN
125                              tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - trb(ji,jj,jk,jn) )
126                           ENDIF
127                        END DO
128                     END DO
129                  END DO
130                  !
131               CASE ( 2 )               !==  no damping in the mixed layer   ==!
132                  DO jk = 1, jpkm1
133                     DO jj = 2, jpjm1
134                        DO ji = fs_2, fs_jpim1   ! vector opt.
135                           IF( gdept_n(ji,jj,jk) >= hmlp (ji,jj) ) THEN
136                              tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - trb(ji,jj,jk,jn) )
137                           END IF
138                        END DO
139                     END DO
140                  END DO
141                 
142               END SELECT
143               !
144            ENDIF
145            !
146            IF( l_trdtrc ) THEN
147               ztrtrd(:,:,:) = tra(:,:,:,jn) -  ztrtrd(:,:,:)
148               CALL trd_tra( kt, 'TRC', jn, jptra_dmp, ztrtrd )
149            END IF
150            !                                                       ! ===========
151         END DO                                                     ! tracer loop
152         !                                                          ! ===========
153         CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta )
154      ENDIF
155      !
156      IF( l_trdtrc )  CALL wrk_dealloc( jpi, jpj, jpk, ztrtrd )
157      !                                          ! print mean trends (used for debugging)
158      IF( ln_ctl ) THEN
159         WRITE(charout, FMT="('dmp ')")
160         CALL prt_ctl_trc_info(charout)
161         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
162      ENDIF
163      !
164      IF( nn_timing == 1 )  CALL timing_stop('trc_dmp')
165      !
166   END SUBROUTINE trc_dmp
167
168
169   SUBROUTINE trc_dmp_ini
170      !!----------------------------------------------------------------------
171      !!                  ***  ROUTINE trc_dmp_ini  ***
172      !!
173      !! ** Purpose :   Initialization for the newtonian damping
174      !!
175      !! ** Method  :   read the nammbf namelist and check the parameters
176      !!              called by trc_dmp at the first timestep (nittrc000)
177      !!----------------------------------------------------------------------
178      !
179      INTEGER ::  ios                 ! Local integer output status for namelist read
180      INTEGER :: imask  !local file handle
181      !
182      NAMELIST/namtrc_dmp/ nn_zdmp_tr , cn_resto_tr
183      !!----------------------------------------------------------------------
184
185      IF( nn_timing == 1 )  CALL timing_start('trc_dmp_init')
186      !
187
188      REWIND( numnat_ref )              ! Namelist namtrc_dmp in reference namelist : Passive tracers newtonian damping
189      READ  ( numnat_ref, namtrc_dmp, IOSTAT = ios, ERR = 909)
190909   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dmp in reference namelist', lwp )
191
192      REWIND( numnat_cfg )              ! Namelist namtrc_dmp in configuration namelist : Passive tracers newtonian damping
193      READ  ( numnat_cfg, namtrc_dmp, IOSTAT = ios, ERR = 910)
194910   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dmp in configuration namelist', lwp )
195      IF(lwm) WRITE ( numont, namtrc_dmp )
196
197      IF(lwp) THEN                       ! Namelist print
198         WRITE(numout,*)
199         WRITE(numout,*) 'trc_dmp : Passive tracers newtonian damping'
200         WRITE(numout,*) '~~~~~~~'
201         WRITE(numout,*) '   Namelist namtrc_dmp : set damping parameter'
202         WRITE(numout,*) '      mixed layer damping option     nn_zdmp_tr = ', nn_zdmp_tr, '(zoom: forced to 0)'
203         WRITE(numout,*) '      Restoration coeff file    cn_resto_tr = ', cn_resto_tr
204      ENDIF
205      !
206      IF( lzoom .AND. .NOT.lk_c1d )   nn_zdmp_tr = 0           ! restoring to climatology at closed north or south boundaries
207      SELECT CASE ( nn_zdmp_tr )
208      CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping throughout the water column'
209      CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the turbocline (avt > 5 cm2/s)'
210      CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed layer'
211      CASE DEFAULT
212         WRITE(ctmp1,*) 'bad flag value for nn_zdmp_tr = ', nn_zdmp_tr
213         CALL ctl_stop(ctmp1)
214      END SELECT
215
216      IF( .NOT.lk_c1d ) THEN
217         IF( .NOT. ln_tradmp )   &
218            &   CALL ctl_stop( 'passive trace damping need ln_tradmp to compute damping coef.' )
219         !
220         !                          ! Read damping coefficients from file
221         !Read in mask from file
222         CALL iom_open ( cn_resto_tr, imask)
223         CALL iom_get  ( imask, jpdom_autoglo, 'resto', restotr)
224         CALL iom_close( imask )
225         !
226      ENDIF
227      IF( nn_timing == 1 )  CALL timing_stop('trc_dmp_init')
228      !
229   END SUBROUTINE trc_dmp_ini
230
231   SUBROUTINE trc_dmp_clo( kt )
232      !!---------------------------------------------------------------------
233      !!                  ***  ROUTINE trc_dmp_clo  ***
234      !!
235      !! ** Purpose :   Closed sea domain initialization
236      !!
237      !! ** Method  :   if a closed sea is located only in a model grid point
238      !!                we restore to initial data
239      !!
240      !! ** Action  :   nctsi1(), nctsj1() : south-west closed sea limits (i,j)
241      !!                nctsi2(), nctsj2() : north-east Closed sea limits (i,j)
242      !!----------------------------------------------------------------------
243      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
244      !
245      INTEGER :: ji , jj, jk, jn, jl, jc                     ! dummy loop indicesa
246      INTEGER :: isrow                                      ! local index
247      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta       ! 3D  workspace
248
249      !!----------------------------------------------------------------------
250
251      IF( kt == nit000 ) THEN
252         ! initial values
253         nctsi1(:) = 1  ;  nctsi2(:) = 1
254         nctsj1(:) = 1  ;  nctsj2(:) = 1
255
256         ! set the closed seas (in data domain indices)
257         ! -------------------
258
259         IF( cp_cfg == "orca" ) THEN
260            !
261            SELECT CASE ( jp_cfg )
262            !                                           ! =======================
263            CASE ( 1 )                                  ! eORCA_R1 configuration
264            !                                           ! =======================
265            isrow = 332 - jpjglo
266            !
267                                                        ! Caspian Sea
268            nctsi1(1)   = 332  ; nctsj1(1)   = 243 - isrow
269            nctsi2(1)   = 344  ; nctsj2(1)   = 275 - isrow
270            !                                       
271            !                                           ! =======================
272            CASE ( 2 )                                  !  ORCA_R2 configuration
273               !                                        ! =======================
274               !                                            ! Caspian Sea
275               nctsi1(1)   =  11  ;  nctsj1(1)   = 103
276               nctsi2(1)   =  17  ;  nctsj2(1)   = 112
277               !                                            ! Great North American Lakes
278               nctsi1(2)   =  97  ;  nctsj1(2)   = 107
279               nctsi2(2)   = 103  ;  nctsj2(2)   = 111
280               !                                            ! Black Sea 1 : west part of the Black Sea
281               nctsi1(3)   = 174  ;  nctsj1(3)   = 107
282               nctsi2(3)   = 181  ;  nctsj2(3)   = 112
283              !                                            ! Black Sea 2 : est part of the Black Sea
284               nctsi1(4)   =   2  ;  nctsj1(4)   = 107
285               nctsi2(4)   =   6  ;  nctsj2(4)   = 112
286               !                                            ! Baltic Sea
287               nctsi1(5)   =  145 ;  nctsj1(5)   = 116
288               nctsi2(5)   =  150 ;  nctsj2(5)   = 126
289               !                                        ! =======================
290            CASE ( 4 )                                  !  ORCA_R4 configuration
291               !                                        ! =======================
292               !                                            ! Caspian Sea
293               nctsi1(1)   =  4  ;  nctsj1(1)   = 53
294               nctsi2(1)   =  4  ;  nctsj2(1)   = 56
295               !                                            ! Great North American Lakes
296               nctsi1(2)   = 49  ;  nctsj1(2)   = 55
297               nctsi2(2)   = 51  ;  nctsj2(2)   = 56
298               !                                            ! Black Sea
299               nctsi1(3)   = 88  ;  nctsj1(3)   = 55
300               nctsi2(3)   = 91  ;  nctsj2(3)   = 56
301               !                                            ! Baltic Sea
302               nctsi1(4)   = 75  ;  nctsj1(4)   = 59
303               nctsi2(4)   = 76  ;  nctsj2(4)   = 61
304               !                                        ! =======================
305            CASE ( 025 )                                ! ORCA_R025 configuration
306               !                                        ! =======================
307                                                     ! Caspian + Aral sea
308               nctsi1(1)   = 1330 ; nctsj1(1)   = 645
309               nctsi2(1)   = 1400 ; nctsj2(1)   = 795
310               !                                        ! Azov Sea
311               nctsi1(2)   = 1284 ; nctsj1(2)   = 722
312               nctsi2(2)   = 1304 ; nctsj2(2)   = 747
313               !
314            END SELECT
315            !
316         ENDIF
317         !
318
319         ! convert the position in local domain indices
320         ! --------------------------------------------
321         DO jc = 1, npncts
322            nctsi1(jc)   = mi0( nctsi1(jc) )
323            nctsj1(jc)   = mj0( nctsj1(jc) )
324
325            nctsi2(jc)   = mi1( nctsi2(jc) )
326            nctsj2(jc)   = mj1( nctsj2(jc) )
327         END DO
328         !
329      ENDIF
330
331      ! Restore close seas values to initial data
332      IF( ln_trcdta .AND. nb_trcdta > 0 )  THEN   ! Initialisation of tracer from a file that may also be used for damping
333         !
334         IF(lwp)  WRITE(numout,*)
335         IF(lwp)  WRITE(numout,*) ' trc_dmp_clo : Restoring of nutrients on close seas at time-step kt = ', kt
336         IF(lwp)  WRITE(numout,*)
337         !
338         CALL wrk_alloc( jpi, jpj, jpk, ztrcdta )   ! Memory allocation
339         !
340         DO jn = 1, jptra
341            IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
342                jl = n_trc_index(jn)
343                CALL trc_dta( kt, sf_trcdta(jl),rf_trfac(jl) )   ! read tracer data at nit000
344                ztrcdta(:,:,:) = sf_trcdta(jl)%fnow(:,:,:)
345                DO jc = 1, npncts
346                   DO jk = 1, jpkm1
347                      DO jj = nctsj1(jc), nctsj2(jc)
348                         DO ji = nctsi1(jc), nctsi2(jc)
349                            trn(ji,jj,jk,jn) = ztrcdta(ji,jj,jk) * tmask(ji,jj,jk)
350                            trb(ji,jj,jk,jn) = trn(ji,jj,jk,jn)
351                         ENDDO
352                      ENDDO
353                   ENDDO
354                ENDDO
355             ENDIF
356          ENDDO
357          CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta )
358      ENDIF
359      !
360   END SUBROUTINE trc_dmp_clo
361
362
363#else
364   !!----------------------------------------------------------------------
365   !!  Dummy module :                                     No passive tracer
366   !!----------------------------------------------------------------------
367CONTAINS
368   SUBROUTINE trc_dmp( kt )        ! Empty routine
369      INTEGER, INTENT(in) :: kt
370      WRITE(*,*) 'trc_dmp: You should not have seen this print! error?', kt
371   END SUBROUTINE trc_dmp
372#endif
373
374
375   !!======================================================================
376END MODULE trcdmp
Note: See TracBrowser for help on using the repository browser.