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/UKMO/dev_r5518_amm15_test/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: branches/UKMO/dev_r5518_amm15_test/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90 @ 5886

Last change on this file since 5886 was 5886, checked in by jgraham, 8 years ago

Removed keywords

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