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/NERC/dev_r5107_NOC_MEDUSA/NEMOGCM/NEMO/OPA_SRC/DYN – NEMO

source: branches/NERC/dev_r5107_NOC_MEDUSA/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90 @ 5715

Last change on this file since 5715 was 5715, checked in by acc, 9 years ago

Branch NERC/dev_r5107_NOC_MEDUSA. Complete reset of svn keyword properties in a desperate attempt to make fcm_make behave.

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   !!----------------------------------------------------------------------
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, nn_isf ! surface boundary condition: ocean
28   USE sbcrnf          ! river runoff
29   USE sbcisf          ! ice shelf
30   USE cla             ! cross land advection             (cla_div routine)
31   USE in_out_manager  ! I/O manager
32   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
33   USE lib_mpp         ! MPP library
34   USE wrk_nemo        ! Memory Allocation
35   USE timing          ! Timing
36
37   IMPLICIT NONE
38   PRIVATE
39
40   PUBLIC   div_cur    ! routine called by step.F90 and istate.F90
41
42   !! * Substitutions
43#  include "domzgr_substitute.h90"
44#  include "vectopt_loop_substitute.h90"
45   !!----------------------------------------------------------------------
46   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
47   !! $Id$
48   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
49   !!----------------------------------------------------------------------
50CONTAINS
51
52#if defined key_noslip_accurate
53   !!----------------------------------------------------------------------
54   !!   'key_noslip_accurate'   2nd order interior + 4th order at the coast
55   !!----------------------------------------------------------------------
56
57   SUBROUTINE div_cur( kt )
58      !!----------------------------------------------------------------------
59      !!                  ***  ROUTINE div_cur  ***
60      !!
61      !! ** Purpose :   compute the horizontal divergence and the relative
62      !!              vorticity at before and now time-step
63      !!
64      !! ** Method  : I.  divergence :
65      !!         - save the divergence computed at the previous time-step
66      !!      (note that the Asselin filter has not been applied on hdivb)
67      !!         - compute the now divergence given by :
68      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
69      !!      correct hdiv with runoff inflow (div_rnf), ice shelf melting (div_isf)
70      !!      and cross land flow (div_cla)
71      !!              II. vorticity :
72      !!         - save the curl computed at the previous time-step
73      !!            rotb = rotn
74      !!      (note that the Asselin time filter has not been applied to rotb)
75      !!         - compute the now curl in tensorial formalism:
76      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
77      !!         - Coastal boundary condition: 'key_noslip_accurate' defined,
78      !!      the no-slip boundary condition is computed using Schchepetkin
79      !!      and O'Brien (1996) scheme (i.e. 4th order at the coast).
80      !!      For example, along east coast, the one-sided finite difference
81      !!      approximation used for di[v] is:
82      !!         di[e2v vn] =  1/(e1f*e2f) * ( (e2v vn)(i) + (e2v vn)(i-1) + (e2v vn)(i-2) )
83      !!
84      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
85      !!              - update rotb , rotn , the before & now rel. vorticity
86      !!----------------------------------------------------------------------
87      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
88      !
89      INTEGER ::   ji, jj, jk, jl           ! dummy loop indices
90      INTEGER ::   ii, ij, ijt, iju, ierr   ! local integer
91      REAL(wp) ::  zraur, zdep              ! local scalar
92      REAL(wp), POINTER,  DIMENSION(:,:) ::   zwu   ! specific 2D workspace
93      REAL(wp), POINTER,  DIMENSION(:,:) ::   zwv   ! specific 2D workspace
94      !!----------------------------------------------------------------------
95      !
96      IF( nn_timing == 1 )  CALL timing_start('div_cur')
97      !
98      CALL wrk_alloc( jpi  , jpj+2, zwu               )
99      CALL wrk_alloc( jpi+4, jpj  , zwv, kjstart = -1 )
100      !
101      IF( kt == nit000 ) THEN
102         IF(lwp) WRITE(numout,*)
103         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and relative vorticity'
104         IF(lwp) WRITE(numout,*) '~~~~~~~   NOT optimal for auto-tasking case'
105      ENDIF
106
107      !                                                ! ===============
108      DO jk = 1, jpkm1                                 ! Horizontal slab
109         !                                             ! ===============
110         !
111         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
112         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
113         !
114         !                                             ! --------
115         ! Horizontal divergence                       !   div
116         !                                             ! --------
117         DO jj = 2, jpjm1
118            DO ji = fs_2, fs_jpim1   ! vector opt.
119               hdivn(ji,jj,jk) =   &
120                  (  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)       &
121                   + 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)  )    &
122                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
123            END DO
124         END DO
125
126         IF( .NOT. AGRIF_Root() ) THEN
127            IF ((nbondi ==  1).OR.(nbondi == 2)) hdivn(nlci-1 , :     ,jk) = 0.e0      ! east
128            IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2      , :     ,jk) = 0.e0      ! west
129            IF ((nbondj ==  1).OR.(nbondj == 2)) hdivn(:      ,nlcj-1 ,jk) = 0.e0      ! north
130            IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(:      ,2      ,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)  ) * 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      END DO                                           !   End of slab
227      !                                                ! ===============
228
229      IF( ln_rnf      )   CALL sbc_rnf_div( hdivn )          ! runoffs   (update hdivn field)
230      IF( ln_divisf .AND. (nn_isf /= 0) )   CALL sbc_isf_div( hdivn )          ! ice shelf (update hdivn field)
231      IF( nn_cla == 1 )   CALL cla_div    ( kt )             ! Cross Land Advection (Update Hor. divergence)
232     
233      ! 4. Lateral boundary conditions on hdivn and rotn
234      ! ---------------------------------=======---======
235      CALL lbc_lnk( hdivn, 'T', 1. )   ;   CALL lbc_lnk( rotn , 'F', 1. )    ! lateral boundary cond. (no sign change)
236      !
237      CALL wrk_dealloc( jpi  , jpj+2, zwu               )
238      CALL wrk_dealloc( jpi+4, jpj  , zwv, kjstart = -1 )
239      !
240      IF( nn_timing == 1 )  CALL timing_stop('div_cur')
241      !
242   END SUBROUTINE div_cur
243   
244#else
245   !!----------------------------------------------------------------------
246   !!   Default option                           2nd order centered schemes
247   !!----------------------------------------------------------------------
248
249   SUBROUTINE div_cur( kt )
250      !!----------------------------------------------------------------------
251      !!                  ***  ROUTINE div_cur  ***
252      !!                   
253      !! ** Purpose :   compute the horizontal divergence and the relative
254      !!      vorticity at before and now time-step
255      !!
256      !! ** Method  : - Divergence:
257      !!      - save the divergence computed at the previous time-step
258      !!      (note that the Asselin filter has not been applied on hdivb)
259      !!      - compute the now divergence given by :
260      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
261      !!      correct hdiv with runoff inflow (div_rnf) and cross land flow (div_cla)
262      !!              - Relavtive Vorticity :
263      !!      - save the curl computed at the previous time-step (rotb = rotn)
264      !!      (note that the Asselin time filter has not been applied to rotb)
265      !!      - compute the now curl in tensorial formalism:
266      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
267      !!      Note: Coastal boundary condition: lateral friction set through
268      !!      the value of fmask along the coast (see dommsk.F90) and shlat
269      !!      (namelist parameter)
270      !!
271      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
272      !!              - update rotb , rotn , the before & now rel. vorticity
273      !!----------------------------------------------------------------------
274      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
275      !
276      INTEGER  ::   ji, jj, jk    ! dummy loop indices
277      REAL(wp) ::   zraur, zdep   ! local scalars
278      !!----------------------------------------------------------------------
279      !
280      IF( nn_timing == 1 )  CALL timing_start('div_cur')
281      !
282      IF( kt == nit000 ) THEN
283         IF(lwp) WRITE(numout,*)
284         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and'
285         IF(lwp) WRITE(numout,*) '~~~~~~~   relative vorticity'
286      ENDIF
287
288      !                                                ! ===============
289      DO jk = 1, jpkm1                                 ! Horizontal slab
290         !                                             ! ===============
291         !
292         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
293         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
294         !
295         !                                             ! --------
296         ! Horizontal divergence                       !   div
297         !                                             ! --------
298         DO jj = 2, jpjm1
299            DO ji = fs_2, fs_jpim1   ! vector opt.
300               hdivn(ji,jj,jk) =   &
301                  (  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)       &
302                   + 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)  )    &
303                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
304            END DO 
305         END DO 
306
307         IF( .NOT. AGRIF_Root() ) THEN
308            IF ((nbondi ==  1).OR.(nbondi == 2)) hdivn(nlci-1 , :     ,jk) = 0.e0      ! east
309            IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2      , :     ,jk) = 0.e0      ! west
310            IF ((nbondj ==  1).OR.(nbondj == 2)) hdivn(:      ,nlcj-1 ,jk) = 0.e0      ! north
311            IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(:      ,2      ,jk) = 0.e0      ! south
312         ENDIF
313
314         !                                             ! --------
315         ! relative vorticity                          !   rot
316         !                                             ! --------
317         DO jj = 1, jpjm1
318            DO ji = 1, fs_jpim1   ! vector opt.
319               rotn(ji,jj,jk) = (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
320                  &              - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) &
321                  &           * fmask(ji,jj,jk) / ( e1f(ji,jj) * e2f(ji,jj) )
322            END DO
323         END DO
324         !                                             ! ===============
325      END DO                                           !   End of slab
326      !                                                ! ===============
327
328      IF( ln_rnf      )   CALL sbc_rnf_div( hdivn )                            ! runoffs (update hdivn field)
329      IF( ln_divisf .AND. (nn_isf .GT. 0) )   CALL sbc_isf_div( hdivn )          ! ice shelf (update hdivn field)
330      IF( nn_cla == 1 )   CALL cla_div    ( kt )             ! Cross Land Advection (update hdivn field)
331      !
332      CALL lbc_lnk( hdivn, 'T', 1. )   ;   CALL lbc_lnk( rotn , 'F', 1. )     ! lateral boundary cond. (no sign change)
333      !
334      IF( nn_timing == 1 )  CALL timing_stop('div_cur')
335      !
336   END SUBROUTINE div_cur
337   
338#endif
339   !!======================================================================
340END MODULE divcur
Note: See TracBrowser for help on using the repository browser.