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.
dyndmp.F90 in branches/2014/dev_r4650_UKMO11_restart_functionality/NEMOGCM/NEMO/OPA_SRC/C1D – NEMO

source: branches/2014/dev_r4650_UKMO11_restart_functionality/NEMOGCM/NEMO/OPA_SRC/C1D/dyndmp.F90 @ 5208

Last change on this file since 5208 was 5208, checked in by davestorkey, 9 years ago

Merge in changes from trunk up to 5021.

File size: 12.3 KB
Line 
1MODULE dyndmp
2   !!======================================================================
3   !!                       ***  MODULE  dyndmp  ***
4   !! Ocean dynamics: internal restoring trend on momentum (U and V current)
5   !!======================================================================
6   !! History :  3.5  ! 2013-08  (D. Calvert)  Original code
7   !!----------------------------------------------------------------------
8
9   !!----------------------------------------------------------------------
10   !!   dyn_dmp_alloc : allocate dyndmp arrays
11   !!   dyn_dmp_init  : namelist read, parameter control and resto coeff.
12   !!   dyn_dmp       : update the momentum trend with the internal damping
13   !!----------------------------------------------------------------------
14   USE oce            ! ocean: variables
15   USE dom_oce        ! ocean: domain variables
16   USE c1d            ! 1D vertical configuration
17   USE tradmp         ! ocean: internal damping
18   USE zdf_oce        ! ocean: vertical physics
19   USE phycst         ! physical constants
20   USE dtauvd         ! data: U & V current
21   USE zdfmxl         ! vertical physics: mixed layer depth
22   USE in_out_manager ! I/O manager
23   USE lib_mpp        ! MPP library
24   USE prtctl         ! Print control
25   USE wrk_nemo       ! Memory allocation
26   USE timing         ! Timing
27
28   IMPLICIT NONE
29   PRIVATE
30
31   PUBLIC   dyn_dmp_init ! routine called by nemogcm.F90
32   PUBLIC   dyn_dmp      ! routine called by step_c1d.F90
33
34   LOGICAL, PUBLIC ::   ln_dyndmp           ! Flag for Newtonian damping
35
36   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  utrdmp    ! damping U current trend (m/s2)
37   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  vtrdmp    ! damping V current trend (m/s2)
38   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  resto_uv  ! restoring coeff. on U & V current
39
40   !! * Substitutions
41#  include "domzgr_substitute.h90"
42#  include "vectopt_loop_substitute.h90"
43   !!----------------------------------------------------------------------
44   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
45   !! $Id: dyndmp.F90 3294 2012-01-28 16:44:18Z rblod $
46   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
47   !!----------------------------------------------------------------------
48CONTAINS
49
50   INTEGER FUNCTION dyn_dmp_alloc()
51      !!----------------------------------------------------------------------
52      !!                ***  FUNCTION dyn_dmp_alloc  ***
53      !!----------------------------------------------------------------------
54      ALLOCATE( utrdmp(jpi,jpj,jpk), vtrdmp(jpi,jpj,jpk), resto_uv(jpi,jpj,jpk), STAT= dyn_dmp_alloc )
55      !
56      IF( lk_mpp            )   CALL mpp_sum ( dyn_dmp_alloc )
57      IF( dyn_dmp_alloc > 0 )   CALL ctl_warn('dyn_dmp_alloc: allocation of arrays failed')
58      !
59   END FUNCTION dyn_dmp_alloc
60
61
62   SUBROUTINE dyn_dmp_init
63      !!----------------------------------------------------------------------
64      !!                  ***  ROUTINE dyn_dmp_init  ***
65      !!
66      !! ** Purpose :   Initialization for the Newtonian damping
67      !!
68      !! ** Method  : - read the ln_dyndmp parameter from the namc1d_dyndmp namelist
69      !!              - allocate damping arrays
70      !!              - check the parameters of the namtra_dmp namelist
71      !!              - calculate damping coefficient
72      !!----------------------------------------------------------------------
73      NAMELIST/namc1d_dyndmp/ ln_dyndmp
74      INTEGER :: ios
75      !!----------------------------------------------------------------------
76
77      REWIND( numnam_ref )              ! Namelist namc1d_dyndmp in reference namelist :
78      READ  ( numnam_ref, namc1d_dyndmp, IOSTAT = ios, ERR = 901)
79901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namc1d_dyndmp in reference namelist', lwp )
80
81      REWIND( numnam_cfg )              ! Namelist namc1d_dyndmp in configuration namelist : Parameters of the run
82      READ  ( numnam_cfg, namc1d_dyndmp, IOSTAT = ios, ERR = 902 )
83902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namc1d_dyndmp in configuration namelist', lwp )
84      IF(lwm) WRITE ( numond, namc1d_dyndmp )
85
86      IF(lwp) THEN                           ! control print
87         WRITE(numout,*)
88         WRITE(numout,*) 'dyn_dmp_init : U and V current Newtonian damping'
89         WRITE(numout,*) '~~~~~~~~~~~~'
90         WRITE(numout,*) '   Namelist namc1d_dyndmp : Set damping flag'
91         WRITE(numout,*) '      add a damping term or not       ln_dyndmp = ', ln_dyndmp
92         WRITE(numout,*) '   Namelist namtra_dmp    : Set damping parameters'
93         WRITE(numout,*) '      horizontal damping option       nn_hdmp   = ', nn_hdmp
94         WRITE(numout,*) '      mixed layer damping option      nn_zdmp   = ', nn_zdmp, '(non-C1D zoom: forced to 0)'
95         WRITE(numout,*) '      surface time scale (days)       rn_surf   = ', rn_surf
96         WRITE(numout,*) '      bottom time scale (days)        rn_bot    = ', rn_bot
97         WRITE(numout,*) '      depth of transition (meters)    rn_dep    = ', rn_dep
98         WRITE(numout,*) '      create a damping.coeff file     nn_file   = ', nn_file
99         WRITE(numout,*)
100      ENDIF
101
102      IF( ln_dyndmp ) THEN
103         !                                   !==   allocate the data arrays   ==!
104         IF( dyn_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'dyn_dmp_init: unable to allocate arrays' )
105         !
106#if ! defined key_c1d
107         SELECT CASE ( nn_hdmp )             !==   control print of horizontal option   ==!
108         CASE (  -1  )   ;   IF(lwp) WRITE(numout,*) '   momentum damping in the Med & Red seas only'
109         CASE ( 1:90 )   ;   IF(lwp) WRITE(numout,*) '   momentum damping poleward of', nn_hdmp, ' degrees'
110         CASE DEFAULT
111            WRITE(ctmp1,*) '          bad flag value for nn_hdmp = ', nn_hdmp
112            CALL ctl_stop(ctmp1)
113         END SELECT
114         !
115#endif
116         SELECT CASE ( nn_zdmp )             !==   control print of vertical option   ==!
117         CASE ( 0    )   ;   IF(lwp) WRITE(numout,*) '   momentum damping throughout the water column'
118         CASE ( 1    )   ;   IF(lwp) WRITE(numout,*) '   no momentum damping in the turbocline (avt > 5 cm2/s)'
119         CASE ( 2    )   ;   IF(lwp) WRITE(numout,*) '   no momentum damping in the mixed layer'
120         CASE DEFAULT
121            WRITE(ctmp1,*) '          bad flag value for nn_zdmp = ', nn_zdmp
122            CALL ctl_stop(ctmp1)
123         END SELECT
124         !
125         IF( .NOT. ln_uvd_dyndmp ) THEN      ! force the initialization of U & V current data for damping
126            CALL ctl_warn( 'dyn_dmp_init: U & V current read data not initialized, we force ln_uvd_dyndmp=T' )
127            CALL dta_uvd_init( ld_dyndmp=ln_dyndmp )
128         ENDIF
129         !
130         utrdmp(:,:,:) = 0._wp               ! internal damping trends
131         vtrdmp(:,:,:) = 0._wp
132         !                                   !==   Damping coefficients calculation:                           ==!
133         !                                   !==   use tradmp.F90 subroutines dtacof, dtacof_zoom and cofdis   ==!
134         !                                   !!!   NOTE: these need to be altered for use in this module if
135         !                                   !!!       they are to be used outside the C1D context
136         !                                   !!!       (use of U,V grid variables)
137         IF( lzoom .AND. .NOT. lk_c1d ) THEN   ;   CALL dtacof_zoom( resto_uv )
138         ELSE               ;   CALL dtacof( nn_hdmp, rn_surf, rn_bot, rn_dep, nn_file, 'DYN', resto_uv )
139         ENDIF
140         !
141      ENDIF
142      !
143   END SUBROUTINE dyn_dmp_init
144
145
146   SUBROUTINE dyn_dmp( kt )
147      !!----------------------------------------------------------------------
148      !!                   ***  ROUTINE dyn_dmp  ***
149      !!                 
150      !! ** Purpose :   Compute the momentum trends due to a newtonian damping
151      !!      of the ocean velocities towards the given data and add it to the
152      !!      general momentum trends.
153      !!
154      !! ** Method  :   Compute Newtonian damping towards u_dta and v_dta
155      !!      and add to the general momentum trends:
156      !!                     ua = ua + resto_uv * (u_dta - ub)
157      !!                     va = va + resto_uv * (v_dta - vb)
158      !!      The trend is computed either throughout the water column
159      !!      (nn_zdmp=0), where the vertical mixing is weak (nn_zdmp=1) or
160      !!      below the well mixed layer (nn_zdmp=2)
161      !!
162      !! ** Action  : - (ua,va)   momentum trends updated with the damping trend
163      !!----------------------------------------------------------------------
164      INTEGER, INTENT(in) ::   kt                        ! ocean time-step index
165      !!
166      INTEGER  ::   ji, jj, jk                           ! dummy loop indices
167      REAL(wp) ::   zua, zva                             ! local scalars
168      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  zuv_dta  ! Read in data
169      !!----------------------------------------------------------------------
170      !
171      IF( nn_timing == 1 )  CALL timing_start( 'dyn_dmp' )
172      !
173      CALL wrk_alloc( jpi, jpj, jpk, 2,  zuv_dta )
174      !
175      !                           !==   read and interpolate U & V current data at kt   ==!
176      CALL dta_uvd( kt, zuv_dta ) !!! NOTE: This subroutine must be altered for use outside
177                                  !!!       the C1D context (use of U,V grid variables)
178      !
179      SELECT CASE ( nn_zdmp )     !==   Calculate/add Newtonian damping to the momentum trend   ==!
180      !
181      CASE( 0 )                   ! Newtonian damping throughout the water column
182         DO jk = 1, jpkm1
183            DO jj = 2, jpjm1
184               DO ji = fs_2, fs_jpim1   ! vector opt.
185                  zua = resto_uv(ji,jj,jk) * ( zuv_dta(ji,jj,jk,1) - ub(ji,jj,jk) )
186                  zva = resto_uv(ji,jj,jk) * ( zuv_dta(ji,jj,jk,2) - vb(ji,jj,jk) )
187                  ua(ji,jj,jk) = ua(ji,jj,jk) + zua
188                  va(ji,jj,jk) = va(ji,jj,jk) + zva
189                  utrdmp(ji,jj,jk) = zua           ! save the trends
190                  vtrdmp(ji,jj,jk) = zva     
191               END DO
192            END DO
193         END DO
194         !
195      CASE ( 1 )                  ! no damping above the turbocline (avt > 5 cm2/s)
196         DO jk = 1, jpkm1
197            DO jj = 2, jpjm1
198               DO ji = fs_2, fs_jpim1   ! vector opt.
199                  IF( avt(ji,jj,jk) <= 5.e-4_wp ) THEN
200                     zua = resto_uv(ji,jj,jk) * ( zuv_dta(ji,jj,jk,1) - ub(ji,jj,jk) )
201                     zva = resto_uv(ji,jj,jk) * ( zuv_dta(ji,jj,jk,2) - vb(ji,jj,jk) )
202                  ELSE
203                     zua = 0._wp
204                     zva = 0._wp 
205                  ENDIF
206                  ua(ji,jj,jk) = ua(ji,jj,jk) + zua
207                  va(ji,jj,jk) = va(ji,jj,jk) + zva
208                  utrdmp(ji,jj,jk) = zua           ! save the trends
209                  vtrdmp(ji,jj,jk) = zva
210               END DO
211            END DO
212         END DO
213         !
214      CASE ( 2 )                  ! no damping in the mixed layer
215         DO jk = 1, jpkm1
216            DO jj = 2, jpjm1
217               DO ji = fs_2, fs_jpim1   ! vector opt.
218                  IF( fsdept(ji,jj,jk) >= hmlp (ji,jj) ) THEN
219                     zua = resto_uv(ji,jj,jk) * ( zuv_dta(ji,jj,jk,1) - ub(ji,jj,jk) )
220                     zva = resto_uv(ji,jj,jk) * ( zuv_dta(ji,jj,jk,2) - vb(ji,jj,jk) )
221                  ELSE
222                     zua = 0._wp
223                     zva = 0._wp 
224                  ENDIF
225                  ua(ji,jj,jk) = ua(ji,jj,jk) + zua
226                  va(ji,jj,jk) = va(ji,jj,jk) + zva
227                  utrdmp(ji,jj,jk) = zua           ! save the trends
228                  vtrdmp(ji,jj,jk) = zva
229               END DO
230            END DO
231         END DO
232         !
233      END SELECT
234      !
235!!gm      !                           ! Trend diagnostic
236!!gm      IF( l_trddyn )   CALL trd_mod( utrdmp, vtrdmp, jpdyn_trd_dat, 'DYN', kt )
237      !
238      !                           ! Control print
239      IF( ln_ctl   )   CALL prt_ctl( tab3d_1=ua(:,:,:), clinfo1=' dmp  - Ua: ', mask1=umask,   &
240         &                           tab3d_2=va(:,:,:), clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
241      !
242      CALL wrk_dealloc( jpi, jpj, jpk, 2,  zuv_dta )
243      !
244      IF( nn_timing == 1 )  CALL timing_stop( 'dyn_dmp')
245      !
246   END SUBROUTINE dyn_dmp
247
248   !!======================================================================
249END MODULE dyndmp
Note: See TracBrowser for help on using the repository browser.