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/NERC/dev_r5589_marine_glacier_termini/NEMOGCM/NEMO/OPA_SRC/TRA – NEMO

source: branches/NERC/dev_r5589_marine_glacier_termini/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90 @ 5605

Last change on this file since 5605 was 5605, checked in by mathiot, 9 years ago

Marine glacier termini: initial commit

  • Property svn:keywords set to Id
File size: 12.2 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   !!                 ! 1996-01  (G. Madec)  statement function for e3
9   !!                 ! 1997-05  (G. Madec)  macro-tasked on jk-slab
10   !!                 ! 1998-07  (M. Imbard, G. Madec) ORCA version
11   !!            7.0  ! 2001-02  (M. Imbard)  cofdis, Original code
12   !!            8.1  ! 2001-02  (G. Madec, E. Durand)  cleaning
13   !!  NEMO      1.0  ! 2002-08  (G. Madec, E. Durand)  free form + modules
14   !!            3.2  ! 2009-08  (G. Madec, C. Talandier)  DOCTOR norm for namelist parameter
15   !!            3.3  ! 2010-06  (C. Ethe, G. Madec) merge TRA-TRC
16   !!            3.4  ! 2011-04  (G. Madec, C. Ethe) Merge of dtatem and dtasal + suppression of CPP keys
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   USE in_out_manager ! I/O manager
34   USE lib_mpp        ! MPP library
35   USE prtctl         ! Print control
36   USE wrk_nemo       ! Memory allocation
37   USE timing         ! Timing
38   USE iom
39
40   IMPLICIT NONE
41   PRIVATE
42
43   PUBLIC   tra_dmp      ! routine called by step.F90
44   PUBLIC   tra_dmp_init ! routine called by opa.F90
45
46   !                               !!* Namelist namtra_dmp : T & S newtonian damping *
47   ! nn_zdmp and cn_resto are public as they are used by C1D/dyndmp.F90
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
53
54   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   strdmp   !: damping salinity trend (psu/s)
55   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ttrdmp   !: damping temperature trend (Celcius/s)
56   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   resto    !: restoring coeff. on T and S (s-1)
57
58   !! * Substitutions
59#  include "domzgr_substitute.h90"
60#  include "vectopt_loop_substitute.h90"
61   !!----------------------------------------------------------------------
62   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
63   !! $Id$
64   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
65   !!----------------------------------------------------------------------
66CONTAINS
67
68   INTEGER FUNCTION tra_dmp_alloc()
69      !!----------------------------------------------------------------------
70      !!                ***  FUNCTION tra_dmp_alloc  ***
71      !!----------------------------------------------------------------------
72      ALLOCATE( strdmp(jpi,jpj,jpk) , ttrdmp(jpi,jpj,jpk), resto(jpi,jpj,jpk), STAT= tra_dmp_alloc )
73      !
74      IF( lk_mpp            )   CALL mpp_sum ( tra_dmp_alloc )
75      IF( tra_dmp_alloc > 0 )   CALL ctl_warn('tra_dmp_alloc: allocation of arrays failed')
76      !
77   END FUNCTION tra_dmp_alloc
78
79
80   SUBROUTINE tra_dmp( kt )
81      !!----------------------------------------------------------------------
82      !!                   ***  ROUTINE tra_dmp  ***
83      !!                 
84      !! ** Purpose :   Compute the tracer trend due to a newtonian damping
85      !!      of the tracer field towards given data field and add it to the
86      !!      general tracer trends.
87      !!
88      !! ** Method  :   Newtonian damping towards t_dta and s_dta computed
89      !!      and add to the general tracer trends:
90      !!                     ta = ta + resto * (t_dta - tb)
91      !!                     sa = sa + resto * (s_dta - sb)
92      !!         The trend is computed either throughout the water column
93      !!      (nlmdmp=0) or in area of weak vertical mixing (nlmdmp=1) or
94      !!      below the well mixed layer (nlmdmp=2)
95      !!
96      !! ** Action  : - (ta,sa)   tracer trends updated with the damping trend
97      !!----------------------------------------------------------------------
98      !
99      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
100      !!
101      INTEGER  ::   ji, jj, jk   ! dummy loop indices
102      REAL(wp) ::   zta, zsa             ! local scalars
103      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  zts_dta 
104      !!----------------------------------------------------------------------
105      !
106      IF( nn_timing == 1 )  CALL timing_start( 'tra_dmp')
107      !
108      CALL wrk_alloc( jpi, jpj, jpk, jpts,  zts_dta )
109      !
110      !                           !==   input T-S data at kt   ==!
111      CALL dta_tsd( kt, zts_dta )            ! read and interpolates T-S data at kt
112      !
113      SELECT CASE ( nn_zdmp )     !==    type of damping   ==!
114      !
115      CASE( 0 )                   !==  newtonian damping throughout the water column  ==!
116          resto = 0.0_wp                              ! need to be restore before submissionto the trunk
117          !WHERE (un(3:11,3:7,:) .GE. 1.e-2)
118          !   resto(3:11,3:7,:) = 1._wp/1440._wp
119          !END WHERE
120          WHERE (un(12,3:7,:) .GE. 1.e-2)
121             resto(12,3:7,:) = 1._wp/1440._wp
122          END WHERE
123         DO jk = 1, jpkm1
124            DO jj = 2, jpjm1
125               DO ji = fs_2, fs_jpim1   ! vector opt.
126                  zta = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
127                  zsa = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
128                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) + zta
129                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) + zsa
130                  strdmp(ji,jj,jk) = zsa           ! save the trend (used in asmtrj)
131                  ttrdmp(ji,jj,jk) = zta     
132               END DO
133            END DO
134         END DO
135         !
136      CASE ( 1 )                  !==  no damping in the turbocline (avt > 5 cm2/s)  ==!
137         DO jk = 1, jpkm1
138            DO jj = 2, jpjm1
139               DO ji = fs_2, fs_jpim1   ! vector opt.
140                  IF( avt(ji,jj,jk) <= 5.e-4_wp ) THEN
141                     zta = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
142                     zsa = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
143                  ELSE
144                     zta = 0._wp
145                     zsa = 0._wp 
146                  ENDIF
147                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) + zta
148                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) + zsa
149                  strdmp(ji,jj,jk) = zsa           ! save the salinity trend (used in asmtrj)
150                  ttrdmp(ji,jj,jk) = zta
151               END DO
152            END DO
153         END DO
154         !
155      CASE ( 2 )                  !==  no damping in the mixed layer   ==!
156         DO jk = 1, jpkm1
157            DO jj = 2, jpjm1
158               DO ji = fs_2, fs_jpim1   ! vector opt.
159                  IF( fsdept(ji,jj,jk) >= hmlp (ji,jj) ) THEN
160                     zta = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
161                     zsa = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
162                  ELSE
163                     zta = 0._wp
164                     zsa = 0._wp 
165                  ENDIF
166                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) + zta
167                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) + zsa
168                  strdmp(ji,jj,jk) = zsa           ! save the salinity trend (used in asmtrj)
169                  ttrdmp(ji,jj,jk) = zta
170               END DO
171            END DO
172         END DO
173         !
174      END SELECT
175      !
176      IF( l_trdtra )   THEN       ! trend diagnostic
177         CALL trd_tra( kt, 'TRA', jp_tem, jptra_dmp, ttrdmp )
178         CALL trd_tra( kt, 'TRA', jp_sal, jptra_dmp, strdmp )
179      ENDIF
180      !                           ! Control print
181      IF(ln_ctl)   CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' dmp  - Ta: ', mask1=tmask,   &
182         &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
183      !
184      CALL wrk_dealloc( jpi, jpj, jpk, jpts,  zts_dta )
185      !
186      IF( nn_timing == 1 )  CALL timing_stop( 'tra_dmp')
187      !
188   END SUBROUTINE tra_dmp
189
190
191   SUBROUTINE tra_dmp_init
192      !!----------------------------------------------------------------------
193      !!                  ***  ROUTINE tra_dmp_init  ***
194      !!
195      !! ** Purpose :   Initialization for the newtonian damping
196      !!
197      !! ** Method  :   read the namtra_dmp namelist and check the parameters
198      !!----------------------------------------------------------------------
199      NAMELIST/namtra_dmp/ ln_tradmp, nn_zdmp, cn_resto
200      INTEGER ::  ios         ! Local integer for output status of namelist read
201      INTEGER :: imask        ! File handle
202      !!
203      !!----------------------------------------------------------------------
204      !
205      REWIND( numnam_ref )   ! Namelist namtra_dmp in reference namelist : T & S relaxation
206      READ  ( numnam_ref, namtra_dmp, IOSTAT = ios, ERR = 901)
207901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in reference namelist', lwp )
208      !
209      REWIND( numnam_cfg )   ! Namelist namtra_dmp in configuration namelist : T & S relaxation
210      READ  ( numnam_cfg, namtra_dmp, IOSTAT = ios, ERR = 902 )
211902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in configuration namelist', lwp )
212      IF(lwm) WRITE ( numond, namtra_dmp )
213
214      IF(lwp) THEN                 !Namelist print
215         WRITE(numout,*)
216         WRITE(numout,*) 'tra_dmp_init : T and S newtonian relaxation'
217         WRITE(numout,*) '~~~~~~~'
218         WRITE(numout,*) '   Namelist namtra_dmp : set relaxation parameters'
219         WRITE(numout,*) '      Apply relaxation   or not       ln_tradmp = ', ln_tradmp
220         WRITE(numout,*) '      mixed layer damping option      nn_zdmp   = ', nn_zdmp
221         WRITE(numout,*) '      Damping file name               cn_resto  = ', cn_resto
222         WRITE(numout,*)
223      ENDIF
224
225      IF( ln_tradmp) THEN
226         !
227         !Allocate arrays
228         IF( tra_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'tra_dmp_init: unable to allocate arrays' )
229
230         !Check values of nn_zdmp
231         SELECT CASE (nn_zdmp)
232         CASE ( 0 )  ; IF(lwp) WRITE(numout,*) '   tracer damping as specified by mask'
233         CASE ( 1 )  ; IF(lwp) WRITE(numout,*) '   no tracer damping in the turbocline'
234         CASE ( 2 )  ; IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed layer'
235         END SELECT
236
237         !TG: Initialisation of dtatsd - Would it be better to have dmpdta routine
238         !so can damp to something other than intitial conditions files?
239         IF( .NOT.ln_tsd_tradmp ) THEN
240            CALL ctl_warn( 'tra_dmp_init: read T-S data not initialized, we force ln_tsd_tradmp=T' )
241            CALL dta_tsd_init( ld_tradmp=ln_tradmp )        ! forces the initialisation of T-S data
242         ENDIF
243
244         !initialise arrays - Are these actually used anywhere else?
245         strdmp(:,:,:) = 0._wp
246         ttrdmp(:,:,:) = 0._wp
247
248         !Read in mask from file
249! need to be restore before submission to the trunk
250!         CALL iom_open ( cn_resto, imask)
251!         CALL iom_get  ( imask, jpdom_autoglo, 'resto', resto)
252!         CALL iom_close( imask )
253          resto = 0.0_wp
254          WHERE (un(2:10,2,:) .LE. 1.e-3)
255             resto(2:10,2,:) = 1._wp/86400._wp
256          END WHERE
257       ENDIF
258
259   END SUBROUTINE tra_dmp_init
260
261END MODULE tradmp
Note: See TracBrowser for help on using the repository browser.