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/2017/dev_r7881_no_wrk_alloc/NEMOGCM/NEMO/OPA_SRC/TRA – NEMO

source: branches/2017/dev_r7881_no_wrk_alloc/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90 @ 7910

Last change on this file since 7910 was 7910, checked in by timgraham, 7 years ago

All wrk_alloc removed

  • Property svn:keywords set to Id
File size: 10.9 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 timing         ! Timing
38   USE iom
39
40   IMPLICIT NONE
41   PRIVATE
42
43   PUBLIC   tra_dmp        ! called by step.F90
44   PUBLIC   tra_dmp_init   ! called by nemogcm.F90
45
46   !                                           !!* Namelist namtra_dmp : T & S newtonian damping *
47   LOGICAL            , PUBLIC ::   ln_tradmp   !: internal damping flag
48   INTEGER            , PUBLIC ::   nn_zdmp     !: = 0/1/2 flag for damping in the mixed layer
49   CHARACTER(LEN=200) , PUBLIC ::   cn_resto    !: name of netcdf file containing restoration coefficient field
50   !
51   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   resto    !: restoring coeff. on T and S (s-1)
52
53   !! * Substitutions
54#  include "vectopt_loop_substitute.h90"
55   !!----------------------------------------------------------------------
56   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
57   !! $Id$
58   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
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      IF( lk_mpp            )   CALL mpp_sum ( 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 )
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      !
94      INTEGER ::   ji, jj, jk, jn   ! dummy loop indices
95      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts) ::  zts_dta, ztrdts
96      !!----------------------------------------------------------------------
97      !
98      IF( nn_timing == 1 )   CALL timing_start('tra_dmp')
99      !
100      IF( l_trdtra )   THEN                    !* Save ta and sa trends
101         ztrdts(:,:,:,:) = tsa(:,:,:,:) 
102      ENDIF
103      !                           !==  input T-S data at kt  ==!
104      CALL dta_tsd( kt, zts_dta )            ! read and interpolates T-S data at kt
105      !
106      SELECT CASE ( nn_zdmp )     !==  type of damping  ==!
107      !
108      CASE( 0 )                        !*  newtonian damping throughout the water column  *!
109         DO jn = 1, jpts
110            DO jk = 1, jpkm1
111               DO jj = 2, jpjm1
112                  DO ji = fs_2, fs_jpim1   ! vector opt.
113                     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) )
114                  END DO
115               END DO
116            END DO
117         END DO
118         !
119      CASE ( 1 )                       !*  no damping in the turbocline (avt > 5 cm2/s)  *!
120         DO jk = 1, jpkm1
121            DO jj = 2, jpjm1
122               DO ji = fs_2, fs_jpim1   ! vector opt.
123                  IF( avt(ji,jj,jk) <= 5.e-4_wp ) THEN
124                     tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem)   &
125                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
126                     tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal)   &
127                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
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_n(ji,jj,jk) >= hmlp (ji,jj) ) THEN
138                     tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem)   &
139                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
140                     tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal)   &
141                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
142                  ENDIF
143               END DO
144            END DO
145         END DO
146         !
147      END SELECT
148      !
149      IF( l_trdtra )   THEN       ! trend diagnostic
150         ztrdts(:,:,:,:) = tsa(:,:,:,:) - ztrdts(:,:,:,:)
151         CALL trd_tra( kt, 'TRA', jp_tem, jptra_dmp, ztrdts(:,:,:,jp_tem) )
152         CALL trd_tra( kt, 'TRA', jp_sal, jptra_dmp, ztrdts(:,:,:,jp_sal) )
153      ENDIF
154      !                           ! Control print
155      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' dmp  - Ta: ', mask1=tmask,   &
156         &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
157      !
158      !
159      IF( nn_timing == 1 )   CALL timing_stop('tra_dmp')
160      !
161   END SUBROUTINE tra_dmp
162
163
164   SUBROUTINE tra_dmp_init
165      !!----------------------------------------------------------------------
166      !!                  ***  ROUTINE tra_dmp_init  ***
167      !!
168      !! ** Purpose :   Initialization for the newtonian damping
169      !!
170      !! ** Method  :   read the namtra_dmp namelist and check the parameters
171      !!----------------------------------------------------------------------
172      INTEGER ::   ios, imask   ! local integers
173      !
174      NAMELIST/namtra_dmp/ ln_tradmp, nn_zdmp, cn_resto
175      !!----------------------------------------------------------------------
176      !
177      REWIND( numnam_ref )   ! Namelist namtra_dmp in reference namelist : T & S relaxation
178      READ  ( numnam_ref, namtra_dmp, IOSTAT = ios, ERR = 901)
179901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in reference namelist', lwp )
180      !
181      REWIND( numnam_cfg )   ! Namelist namtra_dmp in configuration namelist : T & S relaxation
182      READ  ( numnam_cfg, namtra_dmp, IOSTAT = ios, ERR = 902 )
183902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in configuration namelist', lwp )
184      IF(lwm) WRITE ( numond, namtra_dmp )
185      !
186      IF(lwp) THEN                  ! Namelist print
187         WRITE(numout,*)
188         WRITE(numout,*) 'tra_dmp_init : T and S newtonian relaxation'
189         WRITE(numout,*) '~~~~~~~~~~~~'
190         WRITE(numout,*) '   Namelist namtra_dmp : set relaxation parameters'
191         WRITE(numout,*) '      Apply relaxation   or not       ln_tradmp = ', ln_tradmp
192         WRITE(numout,*) '      mixed layer damping option      nn_zdmp   = ', nn_zdmp
193         WRITE(numout,*) '      Damping file name               cn_resto  = ', cn_resto
194         WRITE(numout,*)
195      ENDIF
196      !
197      IF( ln_tradmp) THEN
198         !                          ! Allocate arrays
199         IF( tra_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'tra_dmp_init: unable to allocate arrays' )
200         !
201         SELECT CASE (nn_zdmp)      ! Check values of nn_zdmp
202         CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping as specified by mask'
203         CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixing layer (kz > 5 cm2/s)'
204         CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed  layer'
205         CASE DEFAULT
206            CALL ctl_stop('tra_dmp_init : wrong value of nn_zdmp')
207         END SELECT
208         !
209         !!TG: Initialisation of dtatsd - Would it be better to have dmpdta routine
210         !    so can damp to something other than intitial conditions files?
211         !!gm: In principle yes. Nevertheless, we can't anticipate demands that have never been formulated.
212         IF( .NOT.ln_tsd_tradmp ) THEN
213            IF(lwp) WRITE(numout,*)
214            IF(lwp) WRITE(numout, *)  '   read T-S data not initialized, we force ln_tsd_tradmp=T'
215            CALL dta_tsd_init( ld_tradmp=ln_tradmp )        ! forces the initialisation of T-S data
216         ENDIF
217         !                          ! Read in mask from file
218         CALL iom_open ( cn_resto, imask)
219         CALL iom_get  ( imask, jpdom_autoglo, 'resto', resto )
220         CALL iom_close( imask )
221      ENDIF
222      !
223   END SUBROUTINE tra_dmp_init
224
225   !!======================================================================
226END MODULE tradmp
Note: See TracBrowser for help on using the repository browser.