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.
tradmp.F90 in NEMO/trunk/src/OCE/TRA – NEMO

source: NEMO/trunk/src/OCE/TRA/tradmp.F90 @ 15074

Last change on this file since 15074 was 15023, checked in by gsamson, 3 years ago

merge ticket2680_C1D_PAPA branch back into the trunk; see ticket #2680 for details

  • Property svn:keywords set to Id
File size: 12.0 KB
Line 
1MODULE tradmp
2   !!======================================================================
3   !!                       ***  MODULE  tradmp  ***
4   !! Ocean physics: internal restoring trend on active tracers (T and S)
5   !!======================================================================
6   !! History :  OPA  ! 1991-03  (O. Marti, G. Madec)  Original code
7   !!                 ! 1992-06  (M. Imbard)  doctor norme
8   !!                 ! 1998-07  (M. Imbard, G. Madec) ORCA version
9   !!            7.0  ! 2001-02  (M. Imbard)  add distance to coast, Original code
10   !!            8.1  ! 2001-02  (G. Madec, E. Durand)  cleaning
11   !!  NEMO      1.0  ! 2002-08  (G. Madec, E. Durand)  free form + modules
12   !!            3.2  ! 2009-08  (G. Madec, C. Talandier)  DOCTOR norm for namelist parameter
13   !!            3.3  ! 2010-06  (C. Ethe, G. Madec) merge TRA-TRC
14   !!            3.4  ! 2011-04  (G. Madec, C. Ethe) Merge of dtatem and dtasal + suppression of CPP keys
15   !!            3.6  ! 2015-06  (T. Graham)  read restoring coefficient in a file
16   !!            3.7  ! 2015-10  (G. Madec)  remove useless trends arrays
17   !!----------------------------------------------------------------------
18
19   !!----------------------------------------------------------------------
20   !!   tra_dmp_alloc : allocate tradmp arrays
21   !!   tra_dmp       : update the tracer trend with the internal damping
22   !!   tra_dmp_init  : initialization, namlist read, parameters control
23   !!----------------------------------------------------------------------
24   USE oce            ! ocean: variables
25   USE dom_oce        ! ocean: domain variables
26   USE trd_oce        ! trends: ocean variables
27   USE trdtra         ! trends manager: tracers
28   USE zdf_oce        ! ocean: vertical physics
29   USE phycst         ! physical constants
30   USE dtatsd         ! data: temperature & salinity
31   USE zdfmxl         ! vertical physics: mixed layer depth
32   !
33   USE in_out_manager ! I/O manager
34   USE iom            ! XIOS
35   USE lib_mpp        ! MPP library
36   USE prtctl         ! Print control
37   USE timing         ! Timing
38
39   IMPLICIT NONE
40   PRIVATE
41
42   PUBLIC   tra_dmp        ! called by step.F90
43   PUBLIC   tra_dmp_init   ! called by nemogcm.F90
44
45   !                                           !!* Namelist namtra_dmp : T & S newtonian damping *
46   LOGICAL            , PUBLIC ::   ln_tradmp   !: internal damping flag
47   INTEGER            , PUBLIC ::   nn_zdmp     !: = 0/1/2 flag for damping in the mixed layer
48   CHARACTER(LEN=200) , PUBLIC ::   cn_resto    !: name of netcdf file containing restoration coefficient field
49   !
50   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   resto    !: restoring coeff. on T and S (s-1)
51
52   !! * Substitutions
53#  include "do_loop_substitute.h90"
54#  include "domzgr_substitute.h90"
55   !!----------------------------------------------------------------------
56   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
57   !! $Id$
58   !! Software governed by the CeCILL license (see ./LICENSE)
59   !!----------------------------------------------------------------------
60CONTAINS
61
62   INTEGER FUNCTION tra_dmp_alloc()
63      !!----------------------------------------------------------------------
64      !!                ***  FUNCTION tra_dmp_alloc  ***
65      !!----------------------------------------------------------------------
66      ALLOCATE( resto(jpi,jpj,jpk), STAT= tra_dmp_alloc )
67      !
68      CALL mpp_sum ( 'tradmp', tra_dmp_alloc )
69      IF( tra_dmp_alloc > 0 )   CALL ctl_warn('tra_dmp_alloc: allocation of arrays failed')
70      !
71   END FUNCTION tra_dmp_alloc
72
73
74   SUBROUTINE tra_dmp( kt, Kbb, Kmm, pts, Krhs )
75      !!----------------------------------------------------------------------
76      !!                   ***  ROUTINE tra_dmp  ***
77      !!
78      !! ** Purpose :   Compute the tracer trend due to a newtonian damping
79      !!      of the tracer field towards given data field and add it to the
80      !!      general tracer trends.
81      !!
82      !! ** Method  :   Newtonian damping towards t_dta and s_dta computed
83      !!      and add to the general tracer trends:
84      !!                     ta = ta + resto * (t_dta - tb)
85      !!                     sa = sa + resto * (s_dta - sb)
86      !!         The trend is computed either throughout the water column
87      !!      (nlmdmp=0) or in area of weak vertical mixing (nlmdmp=1) or
88      !!      below the well mixed layer (nlmdmp=2)
89      !!
90      !! ** Action  : - tsa: tracer trends updated with the damping trend
91      !!----------------------------------------------------------------------
92      INTEGER,                                   INTENT(in   ) :: kt              ! ocean time-step index
93      INTEGER,                                   INTENT(in   ) :: Kbb, Kmm, Krhs  ! time level indices
94      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts,jpt), INTENT(inout) :: pts             ! active tracers and RHS of tracer equation
95      !
96      INTEGER ::   ji, jj, jk, jn   ! dummy loop indices
97      REAL(wp), DIMENSION(A2D(nn_hls),jpk,jpts)     ::  zts_dta
98      REAL(wp), DIMENSION(:,:,:)  , ALLOCATABLE ::  zwrk
99      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::  ztrdts
100      !!----------------------------------------------------------------------
101      !
102      IF( ln_timing )   CALL timing_start('tra_dmp')
103      !
104      IF( l_trdtra .OR. iom_use('hflx_dmp_cea') .OR. iom_use('sflx_dmp_cea') ) THEN   !* Save ta and sa trends
105         ALLOCATE( ztrdts(A2D(nn_hls),jpk,jpts) )
106         DO jn = 1, jpts
107            DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk )
108               ztrdts(ji,jj,jk,jn) = pts(ji,jj,jk,jn,Krhs)
109            END_3D
110         END DO
111      ENDIF
112      !                           !==  input T-S data at kt  ==!
113      CALL dta_tsd( kt, zts_dta )            ! read and interpolates T-S data at kt
114      !
115      SELECT CASE ( nn_zdmp )     !==  type of damping  ==!
116      !
117      CASE( 0 )                        !*  newtonian damping throughout the water column  *!
118         DO jn = 1, jpts
119            DO_3D( 0, 0, 0, 0, 1, jpkm1 )
120               pts(ji,jj,jk,jn,Krhs) = pts(ji,jj,jk,jn,Krhs)           &
121                  &                  + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jn) - pts(ji,jj,jk,jn,Kbb) )
122            END_3D
123         END DO
124         !
125      CASE ( 1 )                       !*  no damping in the turbocline (avt > 5 cm2/s)  *!
126         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
127            IF( avt(ji,jj,jk) <= avt_c ) THEN
128               pts(ji,jj,jk,jp_tem,Krhs) = pts(ji,jj,jk,jp_tem,Krhs)   &
129                  &                      + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - pts(ji,jj,jk,jp_tem,Kbb) )
130               pts(ji,jj,jk,jp_sal,Krhs) = pts(ji,jj,jk,jp_sal,Krhs)   &
131                  &                      + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - pts(ji,jj,jk,jp_sal,Kbb) )
132            ENDIF
133         END_3D
134         !
135      CASE ( 2 )                       !*  no damping in the mixed layer   *!
136         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
137            IF( gdept(ji,jj,jk,Kmm) >= hmlp (ji,jj) ) THEN
138               pts(ji,jj,jk,jp_tem,Krhs) = pts(ji,jj,jk,jp_tem,Krhs)   &
139                  &                      + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - pts(ji,jj,jk,jp_tem,Kbb) )
140               pts(ji,jj,jk,jp_sal,Krhs) = pts(ji,jj,jk,jp_sal,Krhs)   &
141                  &                      + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - pts(ji,jj,jk,jp_sal,Kbb) )
142            ENDIF
143         END_3D
144         !
145      END SELECT
146      !
147      ! outputs (clem trunk)
148      IF( iom_use('hflx_dmp_cea') .OR. iom_use('sflx_dmp_cea') ) THEN
149         ALLOCATE( zwrk(A2D(nn_hls),jpk) )          ! Needed to handle expressions containing e3t when using key_qco or key_linssh
150         zwrk(:,:,:) = 0._wp
151
152         IF( iom_use('hflx_dmp_cea') ) THEN
153            DO_3D( 0, 0, 0, 0, 1, jpk )
154               zwrk(ji,jj,jk) = ( pts(ji,jj,jk,jp_tem,Krhs) - ztrdts(ji,jj,jk,jp_tem) ) * e3t(ji,jj,jk,Kmm)
155            END_3D
156            CALL iom_put('hflx_dmp_cea', SUM( zwrk(:,:,:), dim=3 ) * rcp * rho0 ) ! W/m2
157         ENDIF
158         IF( iom_use('sflx_dmp_cea') ) THEN
159            DO_3D( 0, 0, 0, 0, 1, jpk )
160               zwrk(ji,jj,jk) = ( pts(ji,jj,jk,jp_sal,Krhs) - ztrdts(ji,jj,jk,jp_sal) ) * e3t(ji,jj,jk,Kmm)
161            END_3D
162            CALL iom_put('sflx_dmp_cea', SUM( zwrk(:,:,:), dim=3 ) * rho0 )       ! g/m2/s
163         ENDIF
164
165         DEALLOCATE( zwrk )
166      ENDIF
167      !
168      IF( l_trdtra )   THEN       ! trend diagnostic
169         ztrdts(:,:,:,:) = pts(:,:,:,:,Krhs) - ztrdts(:,:,:,:)
170         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_dmp, ztrdts(:,:,:,jp_tem) )
171         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_dmp, ztrdts(:,:,:,jp_sal) )
172         DEALLOCATE( ztrdts )
173      ENDIF
174      !                           ! Control print
175      IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab3d_1=pts(:,:,:,jp_tem,Krhs), clinfo1=' dmp  - Ta: ', mask1=tmask,   &
176         &                                  tab3d_2=pts(:,:,:,jp_sal,Krhs), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
177      !
178      IF( ln_timing )   CALL timing_stop('tra_dmp')
179      !
180   END SUBROUTINE tra_dmp
181
182
183   SUBROUTINE tra_dmp_init
184      !!----------------------------------------------------------------------
185      !!                  ***  ROUTINE tra_dmp_init  ***
186      !!
187      !! ** Purpose :   Initialization for the newtonian damping
188      !!
189      !! ** Method  :   read the namtra_dmp namelist and check the parameters
190      !!----------------------------------------------------------------------
191      INTEGER ::   ios, imask   ! local integers
192      !
193      NAMELIST/namtra_dmp/ ln_tradmp, nn_zdmp, cn_resto
194      !!----------------------------------------------------------------------
195      !
196      READ  ( numnam_ref, namtra_dmp, IOSTAT = ios, ERR = 901)
197901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_dmp in reference namelist' )
198      !
199      READ  ( numnam_cfg, namtra_dmp, IOSTAT = ios, ERR = 902 )
200902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_dmp in configuration namelist' )
201      IF(lwm) WRITE ( numond, namtra_dmp )
202      !
203      IF(lwp) THEN                  ! Namelist print
204         WRITE(numout,*)
205         WRITE(numout,*) 'tra_dmp_init : T and S newtonian relaxation'
206         WRITE(numout,*) '~~~~~~~~~~~~'
207         WRITE(numout,*) '   Namelist namtra_dmp : set relaxation parameters'
208         WRITE(numout,*) '      Apply relaxation   or not       ln_tradmp   = ', ln_tradmp
209         WRITE(numout,*) '         mixed layer damping option      nn_zdmp  = ', nn_zdmp
210         WRITE(numout,*) '         Damping file name               cn_resto = ', cn_resto
211         WRITE(numout,*)
212      ENDIF
213      !
214      IF( ln_tradmp ) THEN
215         !                          ! Allocate arrays
216         IF( tra_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'tra_dmp_init: unable to allocate arrays' )
217         !
218         SELECT CASE (nn_zdmp)      ! Check values of nn_zdmp
219         CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping as specified by mask'
220         CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixing layer (kz > 5 cm2/s)'
221         CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed  layer'
222         CASE DEFAULT
223            CALL ctl_stop('tra_dmp_init : wrong value of nn_zdmp')
224         END SELECT
225         !
226         !!TG: Initialisation of dtatsd - Would it be better to have dmpdta routine
227         !    so can damp to something other than intitial conditions files?
228         !!gm: In principle yes. Nevertheless, we can't anticipate demands that have never been formulated.
229         IF( .NOT.ln_tsd_dmp ) THEN
230            IF(lwp) WRITE(numout,*)
231            IF(lwp) WRITE(numout, *)  '   read T-S data not initialized, we force ln_tsd_dmp=T'
232            CALL dta_tsd_init( ld_tradmp=ln_tradmp )        ! forces the initialisation of T-S data
233         ENDIF
234         !                          ! Read in mask from file
235         CALL iom_open ( cn_resto, imask)
236         CALL iom_get  ( imask, jpdom_auto, 'resto', resto )
237         CALL iom_close( imask )
238      ENDIF
239      !
240   END SUBROUTINE tra_dmp_init
241
242   !!======================================================================
243END MODULE tradmp
Note: See TracBrowser for help on using the repository browser.