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 branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/OPA_SRC/TRA – NEMO

source: branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90 @ 7037

Last change on this file since 7037 was 7037, checked in by mocavero, 8 years ago

ORCA2_LIM_PISCES hybrid version update

  • Property svn:keywords set to Id
File size: 11.4 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 c1d            ! 1D vertical configuration
27   USE trd_oce        ! trends: ocean variables
28   USE trdtra         ! trends manager: tracers
29   USE zdf_oce        ! ocean: vertical physics
30   USE phycst         ! physical constants
31   USE dtatsd         ! data: temperature & salinity
32   USE zdfmxl         ! vertical physics: mixed layer depth
33   !
34   USE in_out_manager ! I/O manager
35   USE lib_mpp        ! MPP library
36   USE prtctl         ! Print control
37   USE wrk_nemo       ! Memory allocation
38   USE timing         ! Timing
39   USE iom
40
41   IMPLICIT NONE
42   PRIVATE
43
44   PUBLIC   tra_dmp        ! called by step.F90
45   PUBLIC   tra_dmp_init   ! called by nemogcm.F90
46
47   !                                           !!* Namelist namtra_dmp : T & S newtonian damping *
48   LOGICAL            , PUBLIC ::   ln_tradmp   !: internal damping flag
49   INTEGER            , PUBLIC ::   nn_zdmp     !: = 0/1/2 flag for damping in the mixed layer
50   CHARACTER(LEN=200) , PUBLIC ::   cn_resto    !: name of netcdf file containing restoration coefficient field
51   !
52   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   resto    !: restoring coeff. on T and S (s-1)
53
54   !! * Substitutions
55#  include "vectopt_loop_substitute.h90"
56   !!----------------------------------------------------------------------
57   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
58   !! $Id$
59   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
60   !!----------------------------------------------------------------------
61CONTAINS
62
63   INTEGER FUNCTION tra_dmp_alloc()
64      !!----------------------------------------------------------------------
65      !!                ***  FUNCTION tra_dmp_alloc  ***
66      !!----------------------------------------------------------------------
67      ALLOCATE( resto(jpi,jpj,jpk), STAT= tra_dmp_alloc )
68      !
69      IF( lk_mpp            )   CALL mpp_sum ( tra_dmp_alloc )
70      IF( tra_dmp_alloc > 0 )   CALL ctl_warn('tra_dmp_alloc: allocation of arrays failed')
71      !
72   END FUNCTION tra_dmp_alloc
73
74
75   SUBROUTINE tra_dmp( kt )
76      !!----------------------------------------------------------------------
77      !!                   ***  ROUTINE tra_dmp  ***
78      !!                 
79      !! ** Purpose :   Compute the tracer trend due to a newtonian damping
80      !!      of the tracer field towards given data field and add it to the
81      !!      general tracer trends.
82      !!
83      !! ** Method  :   Newtonian damping towards t_dta and s_dta computed
84      !!      and add to the general tracer trends:
85      !!                     ta = ta + resto * (t_dta - tb)
86      !!                     sa = sa + resto * (s_dta - sb)
87      !!         The trend is computed either throughout the water column
88      !!      (nlmdmp=0) or in area of weak vertical mixing (nlmdmp=1) or
89      !!      below the well mixed layer (nlmdmp=2)
90      !!
91      !! ** Action  : - tsa: tracer trends updated with the damping trend
92      !!----------------------------------------------------------------------
93      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
94      !
95      INTEGER ::   ji, jj, jk, jn   ! dummy loop indices
96      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  zts_dta, ztrdts
97      !!----------------------------------------------------------------------
98      !
99      IF( nn_timing == 1 )   CALL timing_start('tra_dmp')
100      !
101      CALL wrk_alloc( jpi,jpj,jpk,jpts,   zts_dta )
102      IF( l_trdtra )   THEN                    !* Save ta and sa trends
103         CALL wrk_alloc( jpi,jpj,jpk,jpts,   ztrdts ) 
104!$OMP PARALLEL WORKSHARE
105         ztrdts(:,:,:,:) = tsa(:,:,:,:) 
106!$OMP END PARALLEL WORKSHARE
107      ENDIF
108      !                           !==  input T-S data at kt  ==!
109      CALL dta_tsd( kt, zts_dta )            ! read and interpolates T-S data at kt
110      !
111      SELECT CASE ( nn_zdmp )     !==  type of damping  ==!
112      !
113      CASE( 0 )                        !*  newtonian damping throughout the water column  *!
114         DO jn = 1, jpts
115!$OMP PARALLEL DO schedule(static) private(jk, jj, ji)
116            DO jk = 1, jpkm1
117               DO jj = 2, jpjm1
118                  DO ji = fs_2, fs_jpim1   ! vector opt.
119                     tsa(ji,jj,jk,jn) = tsa(ji,jj,jk,jn) + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jn) - tsb(ji,jj,jk,jn) )
120                  END DO
121               END DO
122            END DO
123         END DO
124         !
125      CASE ( 1 )                       !*  no damping in the turbocline (avt > 5 cm2/s)  *!
126!$OMP PARALLEL DO schedule(static) private(jk, jj, ji)
127         DO jk = 1, jpkm1
128            DO jj = 2, jpjm1
129               DO ji = fs_2, fs_jpim1   ! vector opt.
130                  IF( avt(ji,jj,jk) <= 5.e-4_wp ) THEN
131                     tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem)   &
132                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
133                     tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal)   &
134                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
135                  ENDIF
136               END DO
137            END DO
138         END DO
139         !
140      CASE ( 2 )                       !*  no damping in the mixed layer   *!
141!$OMP PARALLEL DO schedule(static) private(jk, jj, ji)
142         DO jk = 1, jpkm1
143            DO jj = 2, jpjm1
144               DO ji = fs_2, fs_jpim1   ! vector opt.
145                  IF( gdept_n(ji,jj,jk) >= hmlp (ji,jj) ) THEN
146                     tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem)   &
147                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
148                     tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal)   &
149                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
150                  ENDIF
151               END DO
152            END DO
153         END DO
154         !
155      END SELECT
156      !
157      IF( l_trdtra )   THEN       ! trend diagnostic
158!$OMP PARALLEL WORKSHARE
159         ztrdts(:,:,:,:) = tsa(:,:,:,:) - ztrdts(:,:,:,:)
160!$OMP END PARALLEL WORKSHARE
161         CALL trd_tra( kt, 'TRA', jp_tem, jptra_dmp, ztrdts(:,:,:,jp_tem) )
162         CALL trd_tra( kt, 'TRA', jp_sal, jptra_dmp, ztrdts(:,:,:,jp_sal) )
163         CALL wrk_dealloc( jpi,jpj,jpk,jpts,   ztrdts ) 
164      ENDIF
165      !                           ! Control print
166      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' dmp  - Ta: ', mask1=tmask,   &
167         &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
168      !
169      CALL wrk_dealloc( jpi,jpj,jpk,jpts,   zts_dta )
170      !
171      IF( nn_timing == 1 )   CALL timing_stop('tra_dmp')
172      !
173   END SUBROUTINE tra_dmp
174
175
176   SUBROUTINE tra_dmp_init
177      !!----------------------------------------------------------------------
178      !!                  ***  ROUTINE tra_dmp_init  ***
179      !!
180      !! ** Purpose :   Initialization for the newtonian damping
181      !!
182      !! ** Method  :   read the namtra_dmp namelist and check the parameters
183      !!----------------------------------------------------------------------
184      INTEGER ::   ios, imask   ! local integers
185      !
186      NAMELIST/namtra_dmp/ ln_tradmp, nn_zdmp, cn_resto
187      !!----------------------------------------------------------------------
188      !
189      REWIND( numnam_ref )   ! Namelist namtra_dmp in reference namelist : T & S relaxation
190      READ  ( numnam_ref, namtra_dmp, IOSTAT = ios, ERR = 901)
191901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in reference namelist', lwp )
192      !
193      REWIND( numnam_cfg )   ! Namelist namtra_dmp in configuration namelist : T & S relaxation
194      READ  ( numnam_cfg, namtra_dmp, IOSTAT = ios, ERR = 902 )
195902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in configuration namelist', lwp )
196      IF(lwm) WRITE ( numond, namtra_dmp )
197      !
198      IF(lwp) THEN                  ! Namelist print
199         WRITE(numout,*)
200         WRITE(numout,*) 'tra_dmp_init : T and S newtonian relaxation'
201         WRITE(numout,*) '~~~~~~~~~~~'
202         WRITE(numout,*) '   Namelist namtra_dmp : set relaxation parameters'
203         WRITE(numout,*) '      Apply relaxation   or not       ln_tradmp = ', ln_tradmp
204         WRITE(numout,*) '      mixed layer damping option      nn_zdmp   = ', nn_zdmp
205         WRITE(numout,*) '      Damping file name               cn_resto  = ', cn_resto
206         WRITE(numout,*)
207      ENDIF
208      !
209      IF( ln_tradmp) THEN
210         !                          ! Allocate arrays
211         IF( tra_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'tra_dmp_init: unable to allocate arrays' )
212         !
213         SELECT CASE (nn_zdmp)      ! Check values of nn_zdmp
214         CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping as specified by mask'
215         CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixing layer (kz > 5 cm2/s)'
216         CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed  layer'
217         CASE DEFAULT
218            CALL ctl_stop('tra_dmp_init : wrong value of nn_zdmp')
219         END SELECT
220         !
221         !!TG: Initialisation of dtatsd - Would it be better to have dmpdta routine
222         !    so can damp to something other than intitial conditions files?
223         !!gm: In principle yes. Nevertheless, we can't anticipate demands that have never been formulated.
224         IF( .NOT.ln_tsd_tradmp ) THEN
225            IF(lwp) WRITE(numout,*)
226            IF(lwp) WRITE(numout, *)  '   read T-S data not initialized, we force ln_tsd_tradmp=T'
227            CALL dta_tsd_init( ld_tradmp=ln_tradmp )        ! forces the initialisation of T-S data
228         ENDIF
229         !                          ! Read in mask from file
230         CALL iom_open ( cn_resto, imask)
231         CALL iom_get  ( imask, jpdom_autoglo, 'resto', resto )
232         CALL iom_close( imask )
233      ENDIF
234      !
235   END SUBROUTINE tra_dmp_init
236
237   !!======================================================================
238END MODULE tradmp
Note: See TracBrowser for help on using the repository browser.