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 @ 247

Last change on this file since 247 was 247, checked in by opalod, 19 years ago

CL : Add CVS Header and CeCILL licence information

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