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 NEMO/trunk/src/TOP/TRP – NEMO

source: NEMO/trunk/src/TOP/TRP/trcdmp.F90 @ 13286

Last change on this file since 13286 was 13286, checked in by smasson, 4 years ago

trunk: merge extra halos branch in trunk, see #2366

  • Property svn:keywords set to Id
File size: 18.6 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 trdtra
23   USE trd_oce
24   !
25   USE iom
26   USE prtctl          ! Print control for debbuging
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC trc_dmp     
32   PUBLIC trc_dmp_clo   
33   PUBLIC trc_dmp_alloc 
34   PUBLIC trc_dmp_ini   
35
36   INTEGER            , PUBLIC ::   nn_zdmp_tr    !: = 0/1/2 flag for damping in the mixed layer
37   CHARACTER(LEN=200) , PUBLIC ::   cn_resto_tr   !: File containing restoration coefficient
38
39   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   restotr   ! restoring coeff. on tracers (s-1)
40
41   INTEGER, PARAMETER         ::   npncts = 8       ! number of closed sea
42   INTEGER, DIMENSION(npncts) ::   nctsi1, nctsj1   ! south-west closed sea limits (i,j)
43   INTEGER, DIMENSION(npncts) ::   nctsi2, nctsj2   ! north-east closed sea limits (i,j)
44
45   !! * Substitutions
46#  include "do_loop_substitute.h90"
47#  include "domzgr_substitute.h90"
48   !!----------------------------------------------------------------------
49   !! NEMO/TOP 4.0 , NEMO Consortium (2018)
50   !! $Id$
51   !! Software governed by the CeCILL license (see ./LICENSE)
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, Kbb, Kmm, ptr, Krhs )
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      !!                     tr(Kmm) = tr(Krhs) + restotr * (trdta - tr(Kbb))
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 tr(:,:,:,:,Krhs) with the newtonian
82      !!                damping trends.
83      !!              - save the trends ('key_trdmxl_trc')
84      !!----------------------------------------------------------------------
85      INTEGER,                                    INTENT(in   ) :: kt              ! ocean time-step index
86      INTEGER,                                    INTENT(in   ) :: Kbb, Kmm, Krhs  ! time level indices
87      REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,jpt), INTENT(inout) :: ptr             ! passive tracers and RHS of tracer equation
88      !
89      INTEGER ::   ji, jj, jk, jn, jl   ! dummy loop indices
90      CHARACTER (len=22) ::   charout
91      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrtrd
92      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrcdta   ! 3D  workspace
93      !!----------------------------------------------------------------------
94      !
95      IF( ln_timing )   CALL timing_start('trc_dmp')
96      !
97      IF( l_trdtrc )   ALLOCATE( ztrtrd(jpi,jpj,jpk) )   ! temporary save of trends
98      !
99      IF( nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
100         !
101         ALLOCATE( ztrcdta(jpi,jpj,jpk) )    ! Memory allocation
102         !                                                          ! ===========
103         DO jn = 1, jptra                                           ! tracer loop
104            !                                                       ! ===========
105            IF( l_trdtrc ) ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs)    ! save trends
106            !
107            IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
108               !
109               jl = n_trc_index(jn) 
110               CALL trc_dta( kt, Kmm, sf_trcdta(jl), rf_trfac(jl), ztrcdta )   ! read tracer data at nit000
111               !
112               SELECT CASE ( nn_zdmp_tr )
113               !
114               CASE( 0 )                !==  newtonian damping throughout the water column  ==!
115                  DO_3D_00_00( 1, jpkm1 )
116                     ptr(ji,jj,jk,jn,Krhs) = ptr(ji,jj,jk,jn,Krhs) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - ptr(ji,jj,jk,jn,Kbb) )
117                  END_3D
118                  !
119               CASE ( 1 )                !==  no damping in the turbocline (avt > 5 cm2/s)  ==!
120                  DO_3D_00_00( 1, jpkm1 )
121                     IF( avt(ji,jj,jk) <= avt_c )  THEN
122                        ptr(ji,jj,jk,jn,Krhs) = ptr(ji,jj,jk,jn,Krhs) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - ptr(ji,jj,jk,jn,Kbb) )
123                     ENDIF
124                  END_3D
125                  !
126               CASE ( 2 )               !==  no damping in the mixed layer   ==!
127                  DO_3D_00_00( 1, jpkm1 )
128                     IF( gdept(ji,jj,jk,Kmm) >= hmlp (ji,jj) ) THEN
129                        ptr(ji,jj,jk,jn,Krhs) = ptr(ji,jj,jk,jn,Krhs) + restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - ptr(ji,jj,jk,jn,Kbb) )
130                     END IF
131                  END_3D
132                 
133               END SELECT
134               !
135            ENDIF
136            !
137            IF( l_trdtrc ) THEN
138               ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs) -  ztrtrd(:,:,:)
139               CALL trd_tra( kt, Kmm, Krhs, 'TRC', jn, jptra_dmp, ztrtrd )
140            END IF
141            !                                                       ! ===========
142         END DO                                                     ! tracer loop
143         !                                                          ! ===========
144         DEALLOCATE( ztrcdta )
145      ENDIF
146      !
147      IF( l_trdtrc )  DEALLOCATE( ztrtrd )
148      !                                          ! print mean trends (used for debugging)
149      IF( sn_cfctl%l_prttrc ) THEN
150         WRITE(charout, FMT="('dmp ')")
151         CALL prt_ctl_info( charout, cdcomp = 'top' )
152         CALL prt_ctl( tab4d_1=ptr(:,:,:,:,Krhs), mask1=tmask, clinfo=ctrcnm, clinfo3='trd' )
153      ENDIF
154      !
155      IF( ln_timing )   CALL timing_stop('trc_dmp')
156      !
157   END SUBROUTINE trc_dmp
158
159
160   SUBROUTINE trc_dmp_ini
161      !!----------------------------------------------------------------------
162      !!                  ***  ROUTINE trc_dmp_ini  ***
163      !!
164      !! ** Purpose :   Initialization for the newtonian damping
165      !!
166      !! ** Method  :   read the nammbf namelist and check the parameters
167      !!              called by trc_dmp at the first timestep (nittrc000)
168      !!----------------------------------------------------------------------
169      INTEGER ::   ios, imask  ! local integers
170      !!
171      NAMELIST/namtrc_dmp/ nn_zdmp_tr , cn_resto_tr
172      !!----------------------------------------------------------------------
173      !
174      READ  ( numnat_ref, namtrc_dmp, IOSTAT = ios, ERR = 909)
175909   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_dmp in reference namelist' )
176      READ  ( numnat_cfg, namtrc_dmp, IOSTAT = ios, ERR = 910)
177910   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_dmp in configuration namelist' )
178      IF(lwm) WRITE ( numont, namtrc_dmp )
179
180      IF(lwp) THEN                       ! Namelist print
181         WRITE(numout,*)
182         WRITE(numout,*) 'trc_dmp : Passive tracers newtonian damping'
183         WRITE(numout,*) '~~~~~~~'
184         WRITE(numout,*) '   Namelist namtrc_dmp : set damping parameter'
185         WRITE(numout,*) '      mixed layer damping option     nn_zdmp_tr  = ', nn_zdmp_tr, '(zoom: forced to 0)'
186         WRITE(numout,*) '      Restoration coeff file         cn_resto_tr = ', cn_resto_tr
187      ENDIF
188      !                          ! Allocate arrays
189      IF( trc_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'trc_dmp_ini: unable to allocate arrays' )
190      !
191      SELECT CASE ( nn_zdmp_tr )
192      CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '      ===>>   tracer damping throughout the water column'
193      CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '      ===>>   no tracer damping in the turbocline (avt > 5 cm2/s)'
194      CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '      ===>>   no tracer damping in the mixed layer'
195      CASE DEFAULT
196         WRITE(ctmp1,*) 'bad flag value for nn_zdmp_tr = ', nn_zdmp_tr
197         CALL ctl_stop(ctmp1)
198      END SELECT
199
200      IF( .NOT.lk_c1d ) THEN
201         IF( .NOT.ln_tradmp )   &
202            &   CALL ctl_stop( 'passive tracer damping need ln_tradmp to compute damping coef.' )
203         !
204         !                          ! Read damping coefficients from file
205         !Read in mask from file
206         CALL iom_open ( cn_resto_tr, imask)
207         CALL iom_get  ( imask, jpdom_auto, 'resto', restotr)
208         CALL iom_close( imask )
209         !
210      ENDIF
211      !
212   END SUBROUTINE trc_dmp_ini
213
214
215   SUBROUTINE trc_dmp_clo( kt, Kbb, Kmm )
216      !!---------------------------------------------------------------------
217      !!                  ***  ROUTINE trc_dmp_clo  ***
218      !!
219      !! ** Purpose :   Closed sea domain initialization
220      !!
221      !! ** Method  :   if a closed sea is located only in a model grid point
222      !!                we restore to initial data
223      !!
224      !! ** Action  :   nctsi1(), nctsj1() : south-west closed sea limits (i,j)
225      !!                nctsi2(), nctsj2() : north-east Closed sea limits (i,j)
226      !!----------------------------------------------------------------------
227      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
228      INTEGER, INTENT( in ) ::   Kbb, Kmm     ! time level indices
229      !
230      INTEGER :: ji , jj, jk, jn, jl, jc                    ! dummy loop indicesa
231      INTEGER :: isrow                                      ! local index
232      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta       ! 3D  workspace
233      !!----------------------------------------------------------------------
234
235      IF( kt == nit000 ) THEN
236         ! initial values
237         nctsi1(:) = 1  ;  nctsi2(:) = 1
238         nctsj1(:) = 1  ;  nctsj2(:) = 1
239
240         ! set the closed seas (in data domain indices)
241         ! -------------------
242
243         IF( cn_cfg == "orca" .OR. cn_cfg == "ORCA") THEN
244            !
245            SELECT CASE ( nn_cfg )
246            !                                           ! =======================
247            CASE ( 1 )                                  ! eORCA_R1 configuration
248               !                                        ! =======================
249               !
250               isrow = 332 - (Nj0glo + 1)   ! was 332 - jpjglo -> jpjglo_old_version = Nj0glo + 1
251               !
252               nctsi1(1)   = 333  ; nctsj1(1)   = 243 - isrow   ! Caspian Sea
253               nctsi2(1)   = 342  ; nctsj2(1)   = 274 - isrow
254               !                                       
255               nctsi1(2)   = 198  ; nctsj1(2)   = 258 - isrow   ! Lake Superior
256               nctsi2(2)   = 204  ; nctsj2(2)   = 262 - isrow
257               !                                         
258               nctsi1(3)   = 201  ; nctsj1(3)   = 250 - isrow   ! Lake Michigan
259               nctsi2(3)   = 203  ; nctsj2(3)   = 256 - isrow
260               !                                       
261               nctsi1(4)   = 204  ; nctsj1(4)   = 252 - isrow   ! Lake Huron
262               nctsi2(4)   = 209  ; nctsj2(4)   = 256 - isrow
263               !                                       
264               nctsi1(5)   = 206  ; nctsj1(5)   = 249 - isrow   ! Lake Erie
265               nctsi2(5)   = 209  ; nctsj2(5)   = 251 - isrow
266               !                                       
267               nctsi1(6)   = 210  ; nctsj1(6)   = 252 - isrow   ! Lake Ontario
268               nctsi2(6)   = 212  ; nctsj2(6)   = 252 - isrow
269               !                                       
270               nctsi1(7)   = 321  ; nctsj1(7)   = 180 - isrow   ! Victoria Lake
271               nctsi2(7)   = 322  ; nctsj2(7)   = 189 - isrow
272               !                                       
273               nctsi1(8)   = 297  ; nctsj1(8)   = 270 - isrow   ! Baltic Sea
274               nctsi2(8)   = 308  ; nctsj2(8)   = 293 - isrow
275               !
276               !                                        ! =======================
277            CASE ( 2 )                                  !  ORCA_R2 configuration
278               !                                        ! =======================
279               !                                     
280               nctsi1(1)   =  11  ;  nctsj1(1)   = 103       ! Caspian Sea
281               nctsi2(1)   =  17  ;  nctsj2(1)   = 112
282               !                                     
283               nctsi1(2)   =  97  ;  nctsj1(2)   = 107       ! Great North American Lakes
284               nctsi2(2)   = 103  ;  nctsj2(2)   = 111
285               !                                     
286               nctsi1(3)   = 174  ;  nctsj1(3)   = 107       ! Black Sea 1 : west part of the Black Sea
287               nctsi2(3)   = 181  ;  nctsj2(3)   = 112
288              !                                     
289               nctsi1(4)   =   2  ;  nctsj1(4)   = 107       ! Black Sea 2 : est part of the Black Sea
290               nctsi2(4)   =   6  ;  nctsj2(4)   = 112
291               !                                     
292               nctsi1(5)   =  145 ;  nctsj1(5)   = 116       ! Baltic Sea
293               nctsi2(5)   =  150 ;  nctsj2(5)   = 126
294               !
295               !                                        ! =======================
296            CASE ( 4 )                                  !  ORCA_R4 configuration
297               !                                        ! =======================
298               !                                   
299               nctsi1(1)   =  4  ;  nctsj1(1)   = 53         ! Caspian Sea
300               nctsi2(1)   =  4  ;  nctsj2(1)   = 56
301               !                                   
302               nctsi1(2)   = 49  ;  nctsj1(2)   = 55         ! Great North American Lakes
303               nctsi2(2)   = 51  ;  nctsj2(2)   = 56
304               !                                   
305               nctsi1(3)   = 88  ;  nctsj1(3)   = 55         ! Black Sea
306               nctsi2(3)   = 91  ;  nctsj2(3)   = 56
307               !                                   
308               nctsi1(4)   = 75  ;  nctsj1(4)   = 59         ! Baltic Sea
309               nctsi2(4)   = 76  ;  nctsj2(4)   = 61
310               !
311               !                                        ! =======================
312            CASE ( 025 )                                ! ORCA_R025 configuration
313               !                                        ! =======================
314               !                                   
315               nctsi1(1)   = 1330 ; nctsj1(1)   = 645        ! Caspian + Aral sea
316               nctsi2(1)   = 1400 ; nctsj2(1)   = 795
317               !                                   
318               nctsi1(2)   = 1284 ; nctsj1(2)   = 722        ! Azov Sea
319               nctsi2(2)   = 1304 ; nctsj2(2)   = 747
320               !
321            END SELECT
322            !
323         ENDIF
324         !
325         nctsi1(:) = nctsi1(:) + nn_hls - 1   ;   nctsi2(:) = nctsi2(:) + nn_hls - 1   ! -1 as x-perio included in old input files
326         nctsj1(:) = nctsj1(:) + nn_hls       ;   nctsj2(:) = nctsj2(:) + nn_hls
327         !
328         ! convert the position in local domain indices
329         ! --------------------------------------------
330         DO jc = 1, npncts
331            nctsi1(jc)   = mi0( nctsi1(jc) )
332            nctsj1(jc)   = mj0( nctsj1(jc) )
333            !
334            nctsi2(jc)   = mi1( nctsi2(jc) )
335            nctsj2(jc)   = mj1( nctsj2(jc) )
336         END DO
337         !
338      ENDIF
339
340      ! Restore close seas values to initial data
341      IF( ln_trcdta .AND. nb_trcdta > 0 )  THEN   ! Initialisation of tracer from a file that may also be used for damping
342         !
343         IF(lwp)  WRITE(numout,*)
344         IF(lwp)  WRITE(numout,*) ' trc_dmp_clo : Restoring of nutrients on close seas at time-step kt = ', kt
345         IF(lwp)  WRITE(numout,*)
346         !
347         ALLOCATE( ztrcdta(jpi,jpj,jpk) )   ! Memory allocation
348         !
349         DO jn = 1, jptra
350            IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
351                jl = n_trc_index(jn)
352                CALL trc_dta( kt, Kmm, sf_trcdta(jl), rf_trfac(jl), ztrcdta )   ! read tracer data at nit000
353                DO jc = 1, npncts
354                   DO jk = 1, jpkm1
355                      DO jj = nctsj1(jc), nctsj2(jc)
356                         DO ji = nctsi1(jc), nctsi2(jc)
357                            tr(ji,jj,jk,jn,Kmm) = ztrcdta(ji,jj,jk)
358                            tr(ji,jj,jk,jn,Kbb) = tr(ji,jj,jk,jn,Kmm)
359                         END DO
360                      END DO
361                   END DO
362                END DO
363             ENDIF
364          END DO
365          DEALLOCATE( ztrcdta )
366      ENDIF
367      !
368   END SUBROUTINE trc_dmp_clo
369 
370#else
371   !!----------------------------------------------------------------------
372   !!  Dummy module :                                     No passive tracer
373   !!----------------------------------------------------------------------
374CONTAINS
375   SUBROUTINE trc_dmp( kt )        ! Empty routine
376      INTEGER, INTENT(in) :: kt
377      WRITE(*,*) 'trc_dmp: You should not have seen this print! error?', kt
378   END SUBROUTINE trc_dmp
379#endif
380
381   !!======================================================================
382END MODULE trcdmp
Note: See TracBrowser for help on using the repository browser.