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 trunk/NEMO/OPA_SRC/DYN – NEMO

source: trunk/NEMO/OPA_SRC/DYN/divcur.F90 @ 503

Last change on this file since 503 was 455, checked in by opalod, 18 years ago

nemo_v1_update_048:RB: reorganization of dynamics part, in addition change atsk to jki, suppress dynhpg_atsk.F90 dynzdf_imp_atsk.F90 dynzdf_iso.F90

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.2 KB
Line 
1MODULE divcur
2   !!==============================================================================
3   !!                       ***  MODULE  divcur  ***
4   !! Ocean diagnostic variable : horizontal divergence and relative vorticity
5   !!==============================================================================
6
7   !!----------------------------------------------------------------------
8   !!   div_cur    : Compute the horizontal divergence and relative
9   !!                vorticity fields
10   !!----------------------------------------------------------------------
11   !! * Modules used
12   USE oce             ! ocean dynamics and tracers
13   USE dom_oce         ! ocean space and time domain
14   USE in_out_manager  ! I/O manager
15   USE obc_oce         ! ocean lateral open boundary condition
16   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
17
18   IMPLICIT NONE
19   PRIVATE
20
21   !! * Accessibility
22   PUBLIC div_cur    ! routine called by step.F90 and istate.F90
23
24   !! * Substitutions
25#  include "domzgr_substitute.h90"
26#  include "vectopt_loop_substitute.h90"
27   !!----------------------------------------------------------------------
28   !!   OPA 9.0 , LOCEAN-IPSL (2005)
29   !! $Header$
30   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
31   !!----------------------------------------------------------------------
32
33CONTAINS
34
35#if defined key_noslip_accurate
36   !!----------------------------------------------------------------------
37   !!   'key_noslip_accurate'                     2nd order centered scheme
38   !!                                                4th order at the coast
39   !!----------------------------------------------------------------------
40
41   SUBROUTINE div_cur( kt )
42      !!----------------------------------------------------------------------
43      !!                  ***  ROUTINE div_cur  ***
44      !!
45      !! ** Purpose :   compute the horizontal divergence and the relative
46      !!      vorticity at before and now time-step
47      !!
48      !! ** Method  :
49      !!      I.  divergence :
50      !!         - save the divergence computed at the previous time-step
51      !!      (note that the Asselin filter has not been applied on hdivb)
52      !!         - compute the now divergence given by :
53      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
54      !!      Note: if lk_zco=T, e3u=e3v=e3t, they are simplified in the
55      !!      above expression
56      !!         - apply lateral boundary conditions on hdivn
57      !!      II. vorticity :
58      !!         - save the curl computed at the previous time-step
59      !!            rotb = rotn
60      !!      (note that the Asselin time filter has not been applied to rotb)
61      !!         - compute the now curl in tensorial formalism:
62      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
63      !!         - apply lateral boundary conditions on rotn through a call
64      !!      of lbc_lnk routine.
65      !!         - Coastal boundary condition: 'key_noslip_accurate' defined,
66      !!      the no-slip boundary condition is computed using Schchepetkin
67      !!      and O'Brien (1996) scheme (i.e. 4th order at the coast).
68      !!      For example, along east coast, the one-sided finite difference
69      !!      approximation used for di[v] is:
70      !!         di[e2v vn] =  1/(e1f*e2f)
71      !!                    * ( (e2v vn)(i) + (e2v vn)(i-1) + (e2v vn)(i-2) )
72      !!
73      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
74      !!              - update rotb , rotn , the before & now rel. vorticity
75      !!
76      !! History :
77      !!   8.2  !  00-03  (G. Madec)  no slip accurate
78      !!   9.0  !  03-08  (G. Madec)  merged of cur and div, free form, F90
79      !!----------------------------------------------------------------------
80      !! * Arguments
81      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
82     
83      !! * Local declarations
84      INTEGER ::   ji, jj, jk     ! dummy loop indices
85      INTEGER ::   ii, ij, jl     ! temporary integer
86      INTEGER ::   ijt, iju       ! temporary integer
87      REAL(wp) ::   zdiv, zdju
88      REAL(wp), DIMENSION(   jpi  ,1:jpj+2) ::   zwu   ! workspace
89      REAL(wp), DIMENSION(-1:jpi+2,  jpj  ) ::   zwv   ! workspace
90      !!----------------------------------------------------------------------
91
92      IF( kt == nit000 ) THEN
93         IF(lwp) WRITE(numout,*)
94         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and relative vorticity'
95         IF(lwp) WRITE(numout,*) '~~~~~~~   NOT optimal for auto-tasking case'
96      ENDIF
97
98      !                                                ! ===============
99      DO jk = 1, jpkm1                                 ! Horizontal slab
100         !                                             ! ===============
101
102         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
103         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
104
105         !                                             ! --------
106         ! Horizontal divergence                       !   div
107         !                                             ! --------
108         DO jj = 2, jpjm1
109            DO ji = fs_2, fs_jpim1   ! vector opt.
110#if defined key_zco
111               hdivn(ji,jj,jk) = (  e2u(ji,jj) * un(ji,jj,jk) - e2u(ji-1,jj  ) * un(ji-1,jj  ,jk)      &
112                  &               + e1v(ji,jj) * vn(ji,jj,jk) - e1v(ji  ,jj-1) * vn(ji  ,jj-1,jk)  )   &
113                  &            / ( e1t(ji,jj) * e2t(ji,jj) )
114#else
115               hdivn(ji,jj,jk) =   &
116                  (  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)       &
117                   + 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)  )    &
118                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
119#endif
120            END DO
121         END DO
122
123#if defined key_obc
124         ! open boundaries (div must be zero behind the open boundary)
125         !  mpp remark: The zeroing of hdivn can probably be extended to 1->jpi/jpj for the correct row/column
126         IF( lp_obc_east  )   hdivn(nie0p1:nie1p1,nje0  :nje1  ,jk) = 0.e0      ! east
127         IF( lp_obc_west  )   hdivn(niw0  :niw1  ,njw0  :njw1  ,jk) = 0.e0      ! west
128         IF( lp_obc_north )   hdivn(nin0  :nin1  ,njn0p1:njn1p1,jk) = 0.e0      ! north
129         IF( lp_obc_south )   hdivn(nis0  :nis1  ,njs0  :njs1  ,jk) = 0.e0      ! south
130#endif         
131
132         !                                             ! --------
133         ! relative vorticity                          !   rot
134         !                                             ! --------
135         ! contravariant velocity (extended for lateral b.c.)
136         ! inside the model domain
137         DO jj = 1, jpj
138            DO ji = 1, jpi
139               zwu(ji,jj) = e1u(ji,jj) * un(ji,jj,jk)
140               zwv(ji,jj) = e2v(ji,jj) * vn(ji,jj,jk)
141            END DO 
142         END DO 
143 
144         ! East-West boundary conditions
145         IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6) THEN
146            zwv(  0  ,:) = zwv(jpi-2,:)
147            zwv( -1  ,:) = zwv(jpi-3,:)
148            zwv(jpi+1,:) = zwv(  3  ,:)
149            zwv(jpi+2,:) = zwv(  4  ,:)
150         ELSE
151            zwv(  0  ,:) = 0.e0
152            zwv( -1  ,:) = 0.e0
153            zwv(jpi+1,:) = 0.e0
154            zwv(jpi+2,:) = 0.e0
155         ENDIF
156
157         ! North-South boundary conditions
158         IF( nperio == 3 .OR. nperio == 4 ) THEN
159            ! north fold ( Grid defined with a T-point pivot) ORCA 2 degre
160            zwu(jpi,jpj+1) = 0.e0
161            zwu(jpi,jpj+2) = 0.e0
162            DO ji = 1, jpi-1
163               iju = jpi - ji + 1
164               zwu(ji,jpj+1) = - zwu(iju,jpj-3)
165               zwu(ji,jpj+2) = - zwu(iju,jpj-4)
166            END DO
167         ELSEIF( nperio == 5 .OR. nperio == 6 ) THEN
168            ! north fold ( Grid defined with a F-point pivot) ORCA 0.5 degre\
169            zwu(jpi,jpj+1) = 0.e0
170            zwu(jpi,jpj+2) = 0.e0
171            DO ji = 1, jpi-1
172               iju = jpi - ji
173               zwu(ji,jpj  ) = - zwu(iju,jpj-1)
174               zwu(ji,jpj+1) = - zwu(iju,jpj-2)
175               zwu(ji,jpj+2) = - zwu(iju,jpj-3)
176            END DO
177            DO ji = -1, jpi+2
178               ijt = jpi - ji + 1
179               zwv(ji,jpj) = - zwv(ijt,jpj-2)
180            END DO
181            DO ji = jpi/2+1, jpi+2
182               ijt = jpi - ji + 1
183               zwv(ji,jpjm1) = - zwv(ijt,jpjm1)
184            END DO
185         ELSE
186            ! closed
187            zwu(:,jpj+1) = 0.e0
188            zwu(:,jpj+2) = 0.e0
189         ENDIF
190
191         ! relative vorticity (vertical component of the velocity curl)
192         DO jj = 1, jpjm1
193            DO ji = 1, fs_jpim1   ! vector opt.
194               rotn(ji,jj,jk) = (  zwv(ji+1,jj  ) - zwv(ji,jj)      &
195                                 - zwu(ji  ,jj+1) + zwu(ji,jj)  )   &
196                              * fmask(ji,jj,jk) / ( e1f(ji,jj)*e2f(ji,jj) )
197            END DO
198         END DO
199
200         ! second order accurate scheme along straight coast
201         DO jl = 1, npcoa(1,jk)
202            ii = nicoa(jl,1,jk)
203            ij = njcoa(jl,1,jk)
204            rotn(ii,ij,jk) = 1. / ( e1f(ii,ij) * e2f(ii,ij) )   &
205                           * ( + 4. * zwv(ii+1,ij) - zwv(ii+2,ij) + 0.2 * zwv(ii+3,ij) )
206         END DO
207         DO jl = 1, npcoa(2,jk)
208            ii = nicoa(jl,2,jk)
209            ij = njcoa(jl,2,jk)
210            rotn(ii,ij,jk) = 1./(e1f(ii,ij)*e2f(ii,ij))   &
211               *(-4.*zwv(ii,ij)+zwv(ii-1,ij)-0.2*zwv(ii-2,ij))
212         END DO
213         DO jl = 1, npcoa(3,jk)
214            ii = nicoa(jl,3,jk)
215            ij = njcoa(jl,3,jk)
216            rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) )   &
217               * ( +4. * zwu(ii,ij+1) - zwu(ii,ij+2) + 0.2 * zwu(ii,ij+3) )
218         END DO
219         DO jl = 1, npcoa(4,jk)
220            ii = nicoa(jl,4,jk)
221            ij = njcoa(jl,4,jk)
222            rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) )   &
223               * ( -4. * zwu(ii,ij) + zwu(ii,ij-1) - 0.2 * zwu(ii,ij-2) )
224         END DO
225
226         !                                             ! ===============
227      END DO                                           !   End of slab
228      !                                                ! ===============
229     
230      ! 4. Lateral boundary conditions on hdivn and rotn
231      ! ---------------------------------=======---======
232      CALL lbc_lnk( hdivn, 'T', 1. )     ! T-point, no sign change
233      CALL lbc_lnk( rotn , 'F', 1. )     ! F-point, no sign change
234
235   END SUBROUTINE div_cur
236   
237#else
238   !!----------------------------------------------------------------------
239   !!   Default option                           2nd order centered schemes
240   !!----------------------------------------------------------------------
241
242   SUBROUTINE div_cur( kt )
243      !!----------------------------------------------------------------------
244      !!                  ***  ROUTINE div_cur  ***
245      !!                   
246      !! ** Purpose :   compute the horizontal divergence and the relative
247      !!      vorticity at before and now time-step
248      !!
249      !! ** Method  : - Divergence:
250      !!      - save the divergence computed at the previous time-step
251      !!      (note that the Asselin filter has not been applied on hdivb)
252      !!      - compute the now divergence given by :
253      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
254      !!      Note: if lk_zco=T, e3u=e3v=e3t, they are simplified in the
255      !!      above expression
256      !!      - apply lateral boundary conditions on hdivn
257      !!              - Relavtive Vorticity :
258      !!      - save the curl computed at the previous time-step (rotb = rotn)
259      !!      (note that the Asselin time filter has not been applied to rotb)
260      !!      - compute the now curl in tensorial formalism:
261      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
262      !!      - apply lateral boundary conditions on rotn through a call to
263      !!      routine lbc_lnk routine.
264      !!      Note: Coastal boundary condition: lateral friction set through
265      !!      the value of fmask along the coast (see dommsk.F90) and shlat
266      !!      (namelist parameter)
267      !!
268      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
269      !!              - update rotb , rotn , the before & now rel. vorticity
270      !!
271      !! History :
272      !!   1.0  !  87-06  (P. Andrich, D. L Hostis)  Original code
273      !!   4.0  !  91-11  (G. Madec)
274      !!   6.0  !  93-03  (M. Guyon)  symetrical conditions
275      !!   7.0  !  96-01  (G. Madec)  s-coordinates
276      !!   8.0  !  97-06  (G. Madec)  lateral boundary cond., lbc
277      !!   8.1  !  97-08  (J.M. Molines)  Open boundaries
278      !!   9.0  !  02-09  (G. Madec, E. Durand)  Free form, F90
279      !!----------------------------------------------------------------------
280      !! * Arguments
281      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
282     
283      !! * Local declarations
284      INTEGER  ::   ji, jj, jk          ! dummy loop indices
285      !!----------------------------------------------------------------------
286
287      IF( kt == nit000 ) THEN
288         IF(lwp) WRITE(numout,*)
289         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and'
290         IF(lwp) WRITE(numout,*) '~~~~~~~   relative vorticity'
291      ENDIF
292
293      !                                                ! ===============
294      DO jk = 1, jpkm1                                 ! Horizontal slab
295         !                                             ! ===============
296
297         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
298         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
299
300         !                                             ! --------
301         ! Horizontal divergence                       !   div
302         !                                             ! --------
303         DO jj = 2, jpjm1
304            DO ji = fs_2, fs_jpim1   ! vector opt.
305#if defined key_zco
306               hdivn(ji,jj,jk) = (  e2u(ji,jj) * un(ji,jj,jk) - e2u(ji-1,jj  ) * un(ji-1,jj  ,jk)      &
307                  &               + e1v(ji,jj) * vn(ji,jj,jk) - e1v(ji  ,jj-1) * vn(ji  ,jj-1,jk)  )   & 
308                  / ( e1t(ji,jj) * e2t(ji,jj) )
309#else
310               hdivn(ji,jj,jk) =   &
311                  (  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)       &
312                   + 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)  )    &
313                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
314#endif
315            END DO 
316         END DO 
317
318#if defined key_obc
319         ! open boundaries (div must be zero behind the open boundary)
320         !  mpp remark: The zeroing of hdivn can probably be extended to 1->jpi/jpj for the correct row/column
321         IF( lp_obc_east  )   hdivn(nie0p1:nie1p1,nje0  :nje1  ,jk) = 0.e0      ! east
322         IF( lp_obc_west  )   hdivn(niw0  :niw1  ,njw0  :njw1  ,jk) = 0.e0      ! west
323         IF( lp_obc_north )   hdivn(nin0  :nin1  ,njn0p1:njn1p1,jk) = 0.e0      ! north
324         IF( lp_obc_south )   hdivn(nis0  :nis1  ,njs0  :njs1  ,jk) = 0.e0      ! south
325#endif         
326         !                                             ! --------
327         ! relative vorticity                          !   rot
328         !                                             ! --------
329         DO jj = 1, jpjm1
330            DO ji = 1, fs_jpim1   ! vector opt.
331               rotn(ji,jj,jk) = (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
332                  &              - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) &
333                  &           * fmask(ji,jj,jk) / ( e1f(ji,jj) * e2f(ji,jj) )
334            END DO
335         END DO
336         !                                             ! ===============
337      END DO                                           !   End of slab
338      !                                                ! ===============
339     
340      ! 4. Lateral boundary conditions on hdivn and rotn
341      ! ---------------------------------=======---======
342      CALL lbc_lnk( hdivn, 'T', 1. )       ! T-point, no sign change
343      CALL lbc_lnk( rotn , 'F', 1. )       ! F-point, no sign change
344
345   END SUBROUTINE div_cur
346   
347#endif
348   !!======================================================================
349END MODULE divcur
Note: See TracBrowser for help on using the repository browser.