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.
divcur.F90 in branches/UKMO/dev_r5518_obs_oper_update/NEMOGCM/NEMO/OPA_SRC/DYN – NEMO

source: branches/UKMO/dev_r5518_obs_oper_update/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90 @ 7960

Last change on this file since 7960 was 7960, checked in by jwhile, 7 years ago

Updated namelist_ref and 2nd attemp at updating SVN keywords

File size: 16.5 KB
Line 
1MODULE divcur
2   !!==============================================================================
3   !!                       ***  MODULE  divcur  ***
4   !! Ocean diagnostic variable : horizontal divergence and relative vorticity
5   !!==============================================================================
6   !! History :  OPA  ! 1987-06  (P. Andrich, D. L Hostis)  Original code
7   !!            4.0  ! 1991-11  (G. Madec)
8   !!            6.0  ! 1993-03  (M. Guyon)  symetrical conditions
9   !!            7.0  ! 1996-01  (G. Madec)  s-coordinates
10   !!            8.0  ! 1997-06  (G. Madec)  lateral boundary cond., lbc
11   !!            8.1  ! 1997-08  (J.M. Molines)  Open boundaries
12   !!            8.2  ! 2000-03  (G. Madec)  no slip accurate
13   !!  NEMO      1.0  ! 2002-09  (G. Madec, E. Durand)  Free form, F90
14   !!             -   ! 2005-01  (J. Chanut) Unstructured open boundaries
15   !!             -   ! 2003-08  (G. Madec)  merged of cur and div, free form, F90
16   !!             -   ! 2005-01  (J. Chanut, A. Sellar) unstructured open boundaries
17   !!            3.3  ! 2010-09  (D.Storkey and E.O'Dea) bug fixes for BDY module
18   !!             -   ! 2010-10  (R. Furner, G. Madec) runoff and cla added directly here
19   !!            3.6  ! 2014-11  (P. Mathiot)          isf            added directly here
20   !!----------------------------------------------------------------------
21
22   !!----------------------------------------------------------------------
23   !!   div_cur    : Compute the horizontal divergence and relative
24   !!                vorticity fields
25   !!----------------------------------------------------------------------
26   USE oce             ! ocean dynamics and tracers
27   USE dom_oce         ! ocean space and time domain
28   USE sbc_oce, ONLY : ln_rnf, nn_isf ! surface boundary condition: ocean
29   USE sbcrnf          ! river runoff
30   USE sbcisf          ! ice shelf
31   USE cla             ! cross land advection             (cla_div routine)
32   USE in_out_manager  ! I/O manager
33   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
34   USE lib_mpp         ! MPP library
35   USE wrk_nemo        ! Memory Allocation
36   USE timing          ! Timing
37
38   IMPLICIT NONE
39   PRIVATE
40
41   PUBLIC   div_cur    ! routine called by step.F90 and istate.F90
42
43   !! * Substitutions
44#  include "domzgr_substitute.h90"
45#  include "vectopt_loop_substitute.h90"
46   !!----------------------------------------------------------------------
47   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
48   !! $Id$
49   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
50   !!----------------------------------------------------------------------
51CONTAINS
52
53#if defined key_noslip_accurate
54   !!----------------------------------------------------------------------
55   !!   'key_noslip_accurate'   2nd order interior + 4th order at the coast
56   !!----------------------------------------------------------------------
57
58   SUBROUTINE div_cur( kt )
59      !!----------------------------------------------------------------------
60      !!                  ***  ROUTINE div_cur  ***
61      !!
62      !! ** Purpose :   compute the horizontal divergence and the relative
63      !!              vorticity at before and now time-step
64      !!
65      !! ** Method  : I.  divergence :
66      !!         - save the divergence computed at the previous time-step
67      !!      (note that the Asselin filter has not been applied on hdivb)
68      !!         - compute the now divergence given by :
69      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
70      !!      correct hdiv with runoff inflow (div_rnf), ice shelf melting (div_isf)
71      !!      and cross land flow (div_cla)
72      !!              II. vorticity :
73      !!         - save the curl computed at the previous time-step
74      !!            rotb = rotn
75      !!      (note that the Asselin time filter has not been applied to rotb)
76      !!         - compute the now curl in tensorial formalism:
77      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
78      !!         - Coastal boundary condition: 'key_noslip_accurate' defined,
79      !!      the no-slip boundary condition is computed using Schchepetkin
80      !!      and O'Brien (1996) scheme (i.e. 4th order at the coast).
81      !!      For example, along east coast, the one-sided finite difference
82      !!      approximation used for di[v] is:
83      !!         di[e2v vn] =  1/(e1f*e2f) * ( (e2v vn)(i) + (e2v vn)(i-1) + (e2v vn)(i-2) )
84      !!
85      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
86      !!              - update rotb , rotn , the before & now rel. vorticity
87      !!----------------------------------------------------------------------
88      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
89      !
90      INTEGER ::   ji, jj, jk, jl           ! dummy loop indices
91      INTEGER ::   ii, ij, ijt, iju, ierr   ! local integer
92      REAL(wp) ::  zraur, zdep              ! local scalar
93      REAL(wp), POINTER,  DIMENSION(:,:) ::   zwu   ! specific 2D workspace
94      REAL(wp), POINTER,  DIMENSION(:,:) ::   zwv   ! specific 2D workspace
95      !!----------------------------------------------------------------------
96      !
97      IF( nn_timing == 1 )  CALL timing_start('div_cur')
98      !
99      CALL wrk_alloc( jpi  , jpj+2, zwu               )
100      CALL wrk_alloc( jpi+4, jpj  , zwv, kistart = -1 )
101      !
102      IF( kt == nit000 ) THEN
103         IF(lwp) WRITE(numout,*)
104         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and relative vorticity'
105         IF(lwp) WRITE(numout,*) '~~~~~~~   NOT optimal for auto-tasking case'
106      ENDIF
107
108      !                                                ! ===============
109      DO jk = 1, jpkm1                                 ! Horizontal slab
110         !                                             ! ===============
111         !
112         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
113         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
114         !
115         !                                             ! --------
116         ! Horizontal divergence                       !   div
117         !                                             ! --------
118         DO jj = 2, jpjm1
119            DO ji = fs_2, fs_jpim1   ! vector opt.
120               hdivn(ji,jj,jk) =   &
121                  (  e2u(ji,jj)*fse3u(ji,jj,jk) * un(ji,jj,jk) - e2u(ji-1,jj  )*fse3u(ji-1,jj  ,jk) * un(ji-1,jj  ,jk)       &
122                   + e1v(ji,jj)*fse3v(ji,jj,jk) * vn(ji,jj,jk) - e1v(ji  ,jj-1)*fse3v(ji  ,jj-1,jk) * vn(ji  ,jj-1,jk)  )    &
123                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
124            END DO
125         END DO
126
127         IF( .NOT. AGRIF_Root() ) THEN
128            IF ((nbondi ==  1).OR.(nbondi == 2)) hdivn(nlci-1 , :     ,jk) = 0.e0      ! east
129            IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2      , :     ,jk) = 0.e0      ! west
130            IF ((nbondj ==  1).OR.(nbondj == 2)) hdivn(:      ,nlcj-1 ,jk) = 0.e0      ! north
131            IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(:      ,2      ,jk) = 0.e0      ! south
132         ENDIF
133
134         !                                             ! --------
135         ! relative vorticity                          !   rot
136         !                                             ! --------
137         ! contravariant velocity (extended for lateral b.c.)
138         ! inside the model domain
139         DO jj = 1, jpj
140            DO ji = 1, jpi
141               zwu(ji,jj) = e1u(ji,jj) * un(ji,jj,jk)
142               zwv(ji,jj) = e2v(ji,jj) * vn(ji,jj,jk)
143            END DO 
144         END DO 
145 
146         ! East-West boundary conditions
147         IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6) THEN
148            zwv(  0  ,:) = zwv(jpi-2,:)
149            zwv( -1  ,:) = zwv(jpi-3,:)
150            zwv(jpi+1,:) = zwv(  3  ,:)
151            zwv(jpi+2,:) = zwv(  4  ,:)
152         ELSE
153            zwv(  0  ,:) = 0.e0
154            zwv( -1  ,:) = 0.e0
155            zwv(jpi+1,:) = 0.e0
156            zwv(jpi+2,:) = 0.e0
157         ENDIF
158
159         ! North-South boundary conditions
160         IF( nperio == 3 .OR. nperio == 4 ) THEN
161            ! north fold ( Grid defined with a T-point pivot) ORCA 2 degre
162            zwu(jpi,jpj+1) = 0.e0
163            zwu(jpi,jpj+2) = 0.e0
164            DO ji = 1, jpi-1
165               iju = jpi - ji + 1
166               zwu(ji,jpj+1) = - zwu(iju,jpj-3)
167               zwu(ji,jpj+2) = - zwu(iju,jpj-4)
168            END DO
169         ELSEIF( nperio == 5 .OR. nperio == 6 ) THEN
170            ! north fold ( Grid defined with a F-point pivot) ORCA 0.5 degre\
171            zwu(jpi,jpj+1) = 0.e0
172            zwu(jpi,jpj+2) = 0.e0
173            DO ji = 1, jpi-1
174               iju = jpi - ji
175               zwu(ji,jpj  ) = - zwu(iju,jpj-1)
176               zwu(ji,jpj+1) = - zwu(iju,jpj-2)
177               zwu(ji,jpj+2) = - zwu(iju,jpj-3)
178            END DO
179            DO ji = -1, jpi+2
180               ijt = jpi - ji + 1
181               zwv(ji,jpj) = - zwv(ijt,jpj-2)
182            END DO
183            DO ji = jpi/2+1, jpi+2
184               ijt = jpi - ji + 1
185               zwv(ji,jpjm1) = - zwv(ijt,jpjm1)
186            END DO
187         ELSE
188            ! closed
189            zwu(:,jpj+1) = 0.e0
190            zwu(:,jpj+2) = 0.e0
191         ENDIF
192
193         ! relative vorticity (vertical component of the velocity curl)
194         DO jj = 1, jpjm1
195            DO ji = 1, fs_jpim1   ! vector opt.
196               rotn(ji,jj,jk) = (  zwv(ji+1,jj  ) - zwv(ji,jj)      &
197                  &              - zwu(ji  ,jj+1) + zwu(ji,jj)  ) * fmask(ji,jj,jk) / ( e1f(ji,jj)*e2f(ji,jj) )
198            END DO
199         END DO
200
201         ! second order accurate scheme along straight coast
202         DO jl = 1, npcoa(1,jk)
203            ii = nicoa(jl,1,jk)
204            ij = njcoa(jl,1,jk)
205            rotn(ii,ij,jk) = 1. / ( e1f(ii,ij) * e2f(ii,ij) )   &
206                           * ( + 4. * zwv(ii+1,ij) - zwv(ii+2,ij) + 0.2 * zwv(ii+3,ij) )
207         END DO
208         DO jl = 1, npcoa(2,jk)
209            ii = nicoa(jl,2,jk)
210            ij = njcoa(jl,2,jk)
211            rotn(ii,ij,jk) = 1./(e1f(ii,ij)*e2f(ii,ij))   &
212               *(-4.*zwv(ii,ij)+zwv(ii-1,ij)-0.2*zwv(ii-2,ij))
213         END DO
214         DO jl = 1, npcoa(3,jk)
215            ii = nicoa(jl,3,jk)
216            ij = njcoa(jl,3,jk)
217            rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) )   &
218               * ( +4. * zwu(ii,ij+1) - zwu(ii,ij+2) + 0.2 * zwu(ii,ij+3) )
219         END DO
220         DO jl = 1, npcoa(4,jk)
221            ii = nicoa(jl,4,jk)
222            ij = njcoa(jl,4,jk)
223            rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) )   &
224               * ( -4. * zwu(ii,ij) + zwu(ii,ij-1) - 0.2 * zwu(ii,ij-2) )
225         END DO
226         !                                             ! ===============
227      END DO                                           !   End of slab
228      !                                                ! ===============
229
230      IF( ln_rnf      )   CALL sbc_rnf_div( hdivn )          ! runoffs   (update hdivn field)
231      IF( ln_divisf .AND. (nn_isf /= 0) )   CALL sbc_isf_div( hdivn )          ! ice shelf (update hdivn field)
232      IF( nn_cla == 1 )   CALL cla_div    ( kt )             ! Cross Land Advection (Update Hor. divergence)
233     
234      ! 4. Lateral boundary conditions on hdivn and rotn
235      ! ---------------------------------=======---======
236      CALL lbc_lnk( hdivn, 'T', 1. )   ;   CALL lbc_lnk( rotn , 'F', 1. )    ! lateral boundary cond. (no sign change)
237      !
238      CALL wrk_dealloc( jpi  , jpj+2, zwu               )
239      CALL wrk_dealloc( jpi+4, jpj  , zwv, kistart = -1 )
240      !
241      IF( nn_timing == 1 )  CALL timing_stop('div_cur')
242      !
243   END SUBROUTINE div_cur
244   
245#else
246   !!----------------------------------------------------------------------
247   !!   Default option                           2nd order centered schemes
248   !!----------------------------------------------------------------------
249
250   SUBROUTINE div_cur( kt )
251      !!----------------------------------------------------------------------
252      !!                  ***  ROUTINE div_cur  ***
253      !!                   
254      !! ** Purpose :   compute the horizontal divergence and the relative
255      !!      vorticity at before and now time-step
256      !!
257      !! ** Method  : - Divergence:
258      !!      - save the divergence computed at the previous time-step
259      !!      (note that the Asselin filter has not been applied on hdivb)
260      !!      - compute the now divergence given by :
261      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
262      !!      correct hdiv with runoff inflow (div_rnf) and cross land flow (div_cla)
263      !!              - Relavtive Vorticity :
264      !!      - save the curl computed at the previous time-step (rotb = rotn)
265      !!      (note that the Asselin time filter has not been applied to rotb)
266      !!      - compute the now curl in tensorial formalism:
267      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
268      !!      Note: Coastal boundary condition: lateral friction set through
269      !!      the value of fmask along the coast (see dommsk.F90) and shlat
270      !!      (namelist parameter)
271      !!
272      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
273      !!              - update rotb , rotn , the before & now rel. vorticity
274      !!----------------------------------------------------------------------
275      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
276      !
277      INTEGER  ::   ji, jj, jk    ! dummy loop indices
278      REAL(wp) ::   zraur, zdep   ! local scalars
279      !!----------------------------------------------------------------------
280      !
281      IF( nn_timing == 1 )  CALL timing_start('div_cur')
282      !
283      IF( kt == nit000 ) THEN
284         IF(lwp) WRITE(numout,*)
285         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and'
286         IF(lwp) WRITE(numout,*) '~~~~~~~   relative vorticity'
287      ENDIF
288
289      !                                                ! ===============
290      DO jk = 1, jpkm1                                 ! Horizontal slab
291         !                                             ! ===============
292         !
293         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
294         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
295         !
296         !                                             ! --------
297         ! Horizontal divergence                       !   div
298         !                                             ! --------
299         DO jj = 2, jpjm1
300            DO ji = fs_2, fs_jpim1   ! vector opt.
301               hdivn(ji,jj,jk) =   &
302                  (  e2u(ji,jj)*fse3u(ji,jj,jk) * un(ji,jj,jk) - e2u(ji-1,jj)*fse3u(ji-1,jj,jk) * un(ji-1,jj,jk)       &
303                   + e1v(ji,jj)*fse3v(ji,jj,jk) * vn(ji,jj,jk) - e1v(ji,jj-1)*fse3v(ji,jj-1,jk) * vn(ji,jj-1,jk)  )    &
304                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
305            END DO 
306         END DO 
307
308         IF( .NOT. AGRIF_Root() ) THEN
309            IF ((nbondi ==  1).OR.(nbondi == 2)) hdivn(nlci-1 , :     ,jk) = 0.e0      ! east
310            IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2      , :     ,jk) = 0.e0      ! west
311            IF ((nbondj ==  1).OR.(nbondj == 2)) hdivn(:      ,nlcj-1 ,jk) = 0.e0      ! north
312            IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(:      ,2      ,jk) = 0.e0      ! south
313         ENDIF
314
315         !                                             ! --------
316         ! relative vorticity                          !   rot
317         !                                             ! --------
318         DO jj = 1, jpjm1
319            DO ji = 1, fs_jpim1   ! vector opt.
320               rotn(ji,jj,jk) = (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
321                  &              - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) &
322                  &           * fmask(ji,jj,jk) / ( e1f(ji,jj) * e2f(ji,jj) )
323            END DO
324         END DO
325         !                                             ! ===============
326      END DO                                           !   End of slab
327      !                                                ! ===============
328
329      IF( ln_rnf      )   CALL sbc_rnf_div( hdivn )                            ! runoffs (update hdivn field)
330      IF( ln_divisf .AND. (nn_isf .GT. 0) )   CALL sbc_isf_div( hdivn )          ! ice shelf (update hdivn field)
331      IF( nn_cla == 1 )   CALL cla_div    ( kt )             ! Cross Land Advection (update hdivn field)
332      !
333      CALL lbc_lnk( hdivn, 'T', 1. )   ;   CALL lbc_lnk( rotn , 'F', 1. )     ! lateral boundary cond. (no sign change)
334      !
335      IF( nn_timing == 1 )  CALL timing_stop('div_cur')
336      !
337   END SUBROUTINE div_cur
338   
339#endif
340   !!======================================================================
341END MODULE divcur
Note: See TracBrowser for help on using the repository browser.