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/2013/dev_r3853_CNRS9_ConfSetting/NEMOGCM/NEMO/OPA_SRC/DYN – NEMO

source: branches/2013/dev_r3853_CNRS9_ConfSetting/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90 @ 3973

Last change on this file since 3973 was 3973, checked in by clevy, 11 years ago

Configuration setting/Step3, see ticket:#1074

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