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/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps_rewrite_time_filterswap/src/TOP/TRP – NEMO

source: NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps_rewrite_time_filterswap/src/TOP/TRP/trcdmp.F90 @ 11434

Last change on this file since 11434 was 10985, checked in by acc, 5 years ago

2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps : interface changes to tra and trc routines for design compliance and consistency. Fully SETTE tested (non-AGRIF, only)

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