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.
sshwzv.F90 in branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN – NEMO

source: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90 @ 2633

Last change on this file since 2633 was 2633, checked in by trackstand2, 13 years ago

Renamed wrk_use => wrk_in_use and wrk_release => wrk_not_released

  • Property svn:keywords set to Id
File size: 18.4 KB
Line 
1MODULE sshwzv   
2   !!==============================================================================
3   !!                       ***  MODULE  sshwzv  ***
4   !! Ocean dynamics : sea surface height and vertical velocity
5   !!==============================================================================
6   !! History :  3.1  !  2009-02  (G. Madec, M. Leclair)  Original code
7   !!            3.3  !  2010-04  (M. Leclair, G. Madec)  modified LF-RA
8   !!             -   !  2010-05  (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface
9   !!             -   !  2010-09  (D.Storkey and E.O'Dea) bug fixes for BDY module
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   ssh_wzv        : after ssh & now vertical velocity
14   !!   ssh_nxt        : filter ans swap the ssh arrays
15   !!----------------------------------------------------------------------
16   USE oce             ! ocean dynamics and tracers variables
17   USE dom_oce         ! ocean space and time domain variables
18   USE sbc_oce         ! surface boundary condition: ocean
19   USE domvvl          ! Variable volume
20   USE divcur          ! hor. divergence and curl      (div & cur routines)
21   USE iom             ! I/O library
22   USE restart         ! only for lrst_oce
23   USE in_out_manager  ! I/O manager
24   USE prtctl          ! Print control
25   USE phycst
26   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
27   USE obc_par         ! open boundary cond. parameter
28   USE obc_oce
29   USE bdy_oce
30   USE diaar5, ONLY :   lk_diaar5
31   USE iom
32   USE sbcrnf, ONLY  : h_rnf, nk_rnf  ! River runoff
33#if defined key_agrif
34   USE agrif_opa_update
35   USE agrif_opa_interp
36#endif
37#if defined key_asminc   
38   USE asminc          ! Assimilation increment
39#endif
40
41   IMPLICIT NONE
42   PRIVATE
43
44   PUBLIC   ssh_wzv    ! called by step.F90
45   PUBLIC   ssh_nxt    ! called by step.F90
46
47   !! * Substitutions
48#  include "domzgr_substitute.h90"
49#  include "vectopt_loop_substitute.h90"
50   !!----------------------------------------------------------------------
51   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
52   !! $Id$
53   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
54   !!----------------------------------------------------------------------
55
56CONTAINS
57
58   SUBROUTINE ssh_wzv( kt ) 
59      !!----------------------------------------------------------------------
60      !!                ***  ROUTINE ssh_wzv  ***
61      !!                   
62      !! ** Purpose :   compute the after ssh (ssha), the now vertical velocity
63      !!              and update the now vertical coordinate (lk_vvl=T).
64      !!
65      !! ** Method  : - Using the incompressibility hypothesis, the vertical
66      !!      velocity is computed by integrating the horizontal divergence 
67      !!      from the bottom to the surface minus the scale factor evolution.
68      !!        The boundary conditions are w=0 at the bottom (no flux) and.
69      !!
70      !! ** action  :   ssha    : after sea surface height
71      !!                wn      : now vertical velocity
72      !!                sshu_a, sshv_a, sshf_a  : after sea surface height (lk_vvl=T)
73      !!                hu, hv, hur, hvr        : ocean depth and its inverse at u-,v-points
74      !!
75      !! Reference  : Leclair, M., and G. Madec, 2009, Ocean Modelling.
76      !!----------------------------------------------------------------------
77      USE oce, ONLY :   z3d => ta   ! use ta as 3D workspace
78      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
79      USE wrk_nemo, ONLY: zhdiv => wrk_2d_1, z2d => wrk_2d_2
80      !!
81      INTEGER, INTENT(in) ::   kt   ! time step
82      !!
83      INTEGER  ::   ji, jj, jk      ! dummy loop indices
84      REAL(wp) ::   zcoefu, zcoefv, zcoeff      ! temporary scalars
85      REAL(wp) ::   z2dt, z1_2dt, z1_rau0       ! temporary scalars
86      !!----------------------------------------------------------------------
87
88      IF(wrk_in_use(2, 1,2))THEN
89         CALL ctl_stop('ssh_wzv: requested workspace arrays unavailable.')
90         RETURN
91      END IF
92
93      IF( kt == nit000 ) THEN
94         !
95         IF(lwp) WRITE(numout,*)
96         IF(lwp) WRITE(numout,*) 'ssh_wzv : after sea surface height and now vertical velocity '
97         IF(lwp) WRITE(numout,*) '~~~~~~~ '
98         !
99         wn(:,:,jpk) = 0.e0                   ! bottom boundary condition: w=0 (set once for all)
100         !
101         IF( lk_vvl ) THEN                    ! before and now Sea SSH at u-, v-, f-points (vvl case only)
102            DO jj = 1, jpjm1
103               DO ji = 1, jpim1                    ! caution: use of Vector Opt. not possible
104                  zcoefu = 0.5  * umask(ji,jj,1) / ( e1u(ji,jj) * e2u(ji,jj) )
105                  zcoefv = 0.5  * vmask(ji,jj,1) / ( e1v(ji,jj) * e2v(ji,jj) )
106                  zcoeff = 0.25 * umask(ji,jj,1) * umask(ji,jj+1,1)
107                  sshu_b(ji,jj) = zcoefu * ( e1t(ji  ,jj) * e2t(ji  ,jj) * sshb(ji  ,jj)     &
108                     &                     + e1t(ji+1,jj) * e2t(ji+1,jj) * sshb(ji+1,jj) )
109                  sshv_b(ji,jj) = zcoefv * ( e1t(ji,jj  ) * e2t(ji,jj  ) * sshb(ji,jj  )     &
110                     &                     + e1t(ji,jj+1) * e2t(ji,jj+1) * sshb(ji,jj+1) )
111                  sshu_n(ji,jj) = zcoefu * ( e1t(ji  ,jj) * e2t(ji  ,jj) * sshn(ji  ,jj)     &
112                     &                     + e1t(ji+1,jj) * e2t(ji+1,jj) * sshn(ji+1,jj) )
113                  sshv_n(ji,jj) = zcoefv * ( e1t(ji,jj  ) * e2t(ji,jj  ) * sshn(ji,jj  )     &
114                     &                     + e1t(ji,jj+1) * e2t(ji,jj+1) * sshn(ji,jj+1) )
115               END DO
116            END DO
117            CALL lbc_lnk( sshu_b, 'U', 1. )   ;   CALL lbc_lnk( sshu_n, 'U', 1. )
118            CALL lbc_lnk( sshv_b, 'V', 1. )   ;   CALL lbc_lnk( sshv_n, 'V', 1. )
119            DO jj = 1, jpjm1
120               DO ji = 1, jpim1      ! NO Vector Opt.
121                  sshf_n(ji,jj) = 0.5  * umask(ji,jj,1) * umask(ji,jj+1,1)                   &
122                       &               / ( e1f(ji,jj  ) * e2f(ji,jj  ) )                     &
123                       &               * ( e1u(ji,jj  ) * e2u(ji,jj  ) * sshu_n(ji,jj  )     &
124                       &                 + e1u(ji,jj+1) * e2u(ji,jj+1) * sshu_n(ji,jj+1) )
125               END DO
126            END DO
127            CALL lbc_lnk( sshf_n, 'F', 1. )
128         ENDIF
129         !
130      ENDIF
131
132      !                                           !------------------------------------------!
133      IF( lk_vvl ) THEN                           !  Regridding: Update Now Vertical coord.  !   (only in vvl case)
134         !                                        !------------------------------------------!
135         DO jk = 1, jpkm1
136            fsdept(:,:,jk) = fsdept_n(:,:,jk)         ! now local depths stored in fsdep. arrays
137            fsdepw(:,:,jk) = fsdepw_n(:,:,jk)
138            fsde3w(:,:,jk) = fsde3w_n(:,:,jk)
139            !
140            fse3t (:,:,jk) = fse3t_n (:,:,jk)         ! vertical scale factors stored in fse3. arrays
141            fse3u (:,:,jk) = fse3u_n (:,:,jk)
142            fse3v (:,:,jk) = fse3v_n (:,:,jk)
143            fse3f (:,:,jk) = fse3f_n (:,:,jk)
144            fse3w (:,:,jk) = fse3w_n (:,:,jk)
145            fse3uw(:,:,jk) = fse3uw_n(:,:,jk)
146            fse3vw(:,:,jk) = fse3vw_n(:,:,jk)
147         END DO
148         !
149         hu(:,:) = hu_0(:,:) + sshu_n(:,:)            ! now ocean depth (at u- and v-points)
150         hv(:,:) = hv_0(:,:) + sshv_n(:,:)
151         !                                            ! now masked inverse of the ocean depth (at u- and v-points)
152         hur(:,:) = umask(:,:,1) / ( hu(:,:) + 1.e0 - umask(:,:,1) )
153         hvr(:,:) = vmask(:,:,1) / ( hv(:,:) + 1.e0 - vmask(:,:,1) )
154         !
155      ENDIF
156      !
157      CALL div_cur( kt )                              ! Horizontal divergence & Relative vorticity
158      !
159      z2dt = 2. * rdt                                 ! set time step size (Euler/Leapfrog)
160      IF( neuler == 0 .AND. kt == nit000 )   z2dt =rdt
161
162      !                                           !------------------------------!
163      !                                           !   After Sea Surface Height   !
164      !                                           !------------------------------!
165      zhdiv(:,:) = 0.e0
166      DO jk = 1, jpkm1                                 ! Horizontal divergence of barotropic transports
167        zhdiv(:,:) = zhdiv(:,:) + fse3t(:,:,jk) * hdivn(:,:,jk)
168      END DO
169      !                                                ! Sea surface elevation time stepping
170      ! In forward Euler time stepping case, the same formulation as in the leap-frog case can be used
171      ! because emp_b field is initialized with the vlaues of emp field. Hence, 0.5 * ( emp + emp_b ) = emp
172      z1_rau0 = 0.5 / rau0
173      ssha(:,:) = (  sshb(:,:) - z2dt * ( z1_rau0 * ( emp_b(:,:) + emp(:,:) ) + zhdiv(:,:) )  ) &
174      &                      * tmask(:,:,1)
175
176#if defined key_agrif
177      CALL agrif_ssh(kt)
178#endif
179#if defined key_obc
180      IF( Agrif_Root() ) THEN
181         ssha(:,:) = ssha(:,:) * obctmsk(:,:)
182         CALL lbc_lnk( ssha, 'T', 1. )                ! absolutly compulsory !! (jmm)
183      ENDIF
184#endif
185#if defined key_bdy
186      ssha(:,:) = ssha(:,:) * bdytmask(:,:)
187      CALL lbc_lnk( ssha, 'T', 1. ) 
188#endif
189
190      !                                                ! Sea Surface Height at u-,v- and f-points (vvl case only)
191      IF( lk_vvl ) THEN                                ! (required only in key_vvl case)
192         DO jj = 1, jpjm1
193            DO ji = 1, jpim1      ! NO Vector Opt.
194               sshu_a(ji,jj) = 0.5  * umask(ji,jj,1) / ( e1u(ji  ,jj) * e2u(ji  ,jj) )                   &
195                  &                                  * ( e1t(ji  ,jj) * e2t(ji  ,jj) * ssha(ji  ,jj)     &
196                  &                                    + e1t(ji+1,jj) * e2t(ji+1,jj) * ssha(ji+1,jj) )
197               sshv_a(ji,jj) = 0.5  * vmask(ji,jj,1) / ( e1v(ji,jj  ) * e2v(ji,jj  ) )                   &
198                  &                                  * ( e1t(ji,jj  ) * e2t(ji,jj  ) * ssha(ji,jj  )     &
199                  &                                    + e1t(ji,jj+1) * e2t(ji,jj+1) * ssha(ji,jj+1) )
200            END DO
201         END DO
202         ! Boundaries conditions
203         CALL lbc_lnk( sshu_a, 'U', 1. )
204         CALL lbc_lnk( sshv_a, 'V', 1. )
205      ENDIF
206! Include the IAU weighted SSH increment
207#if defined key_asminc
208      IF( ( lk_asminc ).AND.( ln_sshinc ).AND.( ln_asmiau ) ) THEN
209         CALL ssh_asm_inc( kt )
210         ssha(:,:) = ssha(:,:) + z2dt * ssh_iau(:,:)
211      ENDIF
212#endif
213
214      !                                           !------------------------------!
215      !                                           !     Now Vertical Velocity    !
216      !                                           !------------------------------!
217      z1_2dt = 1.e0 / z2dt
218      DO jk = jpkm1, 1, -1                             ! integrate from the bottom the hor. divergence
219         ! - ML - need 3 lines here because replacement of fse3t by its expression yields too long lines otherwise
220         wn(:,:,jk) = wn(:,:,jk+1) -    fse3t_n(:,:,jk) * hdivn(:,:,jk)        &
221            &                      - (  fse3t_a(:,:,jk) - fse3t_b(:,:,jk) )    &
222            &                         * tmask(:,:,jk) * z1_2dt
223#if defined key_bdy
224         wn(:,:,jk) = wn(:,:,jk) * bdytmask(:,:)
225#endif
226      END DO
227
228      !                                           !------------------------------!
229      !                                           !           outputs            !
230      !                                           !------------------------------!
231      CALL iom_put( "woce", wn                    )   ! vertical velocity
232      CALL iom_put( "ssh" , sshn                  )   ! sea surface height
233      CALL iom_put( "ssh2", sshn(:,:) * sshn(:,:) )   ! square of sea surface height
234      IF( lk_diaar5 ) THEN                            ! vertical mass transport & its square value
235         ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
236         z2d(:,:) = rau0 * e1t(:,:) * e2t(:,:)
237         DO jk = 1, jpk
238            z3d(:,:,jk) = wn(:,:,jk) * z2d(:,:)
239         END DO
240         CALL iom_put( "w_masstr" , z3d                     ) 
241         CALL iom_put( "w_masstr2", z3d(:,:,:) * z3d(:,:,:) )
242      ENDIF
243      !
244      IF(ln_ctl)   CALL prt_ctl( tab2d_1=ssha, clinfo1=' ssha  - : ', mask1=tmask, ovlap=1 )
245      !
246      IF(wrk_not_released(2, 1,2))THEN
247         CALL ctl_stop('ssh_wzv: failed to release workspace arrays.')
248      END IF
249      !
250   END SUBROUTINE ssh_wzv
251
252
253   SUBROUTINE ssh_nxt( kt )
254      !!----------------------------------------------------------------------
255      !!                    ***  ROUTINE ssh_nxt  ***
256      !!
257      !! ** Purpose :   achieve the sea surface  height time stepping by
258      !!              applying Asselin time filter and swapping the arrays
259      !!              ssha  already computed in ssh_wzv 
260      !!
261      !! ** Method  : - apply Asselin time fiter to now ssh (excluding the forcing
262      !!              from the filter, see Leclair and Madec 2010) and swap :
263      !!                sshn = ssha + atfp * ( sshb -2 sshn + ssha )
264      !!                            - atfp * rdt * ( emp_b - emp ) / rau0
265      !!                sshn = ssha
266      !!
267      !! ** action  : - sshb, sshn   : before & now sea surface height
268      !!                               ready for the next time step
269      !!
270      !! Reference  : Leclair, M., and G. Madec, 2009, Ocean Modelling.
271      !!----------------------------------------------------------------------
272      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
273      !!
274      INTEGER  ::   ji, jj   ! dummy loop indices
275      REAL(wp) ::   zec      ! temporary scalar
276      !!----------------------------------------------------------------------
277
278      IF( kt == nit000 ) THEN
279         IF(lwp) WRITE(numout,*)
280         IF(lwp) WRITE(numout,*) 'ssh_nxt : next sea surface height (Asselin time filter + swap)'
281         IF(lwp) WRITE(numout,*) '~~~~~~~ '
282      ENDIF
283
284      !                       !--------------------------!
285      IF( lk_vvl ) THEN       !  Variable volume levels  !
286         !                    !--------------------------!
287         !
288         ! ssh at t-, u-, v, f-points
289         !===========================
290         IF( neuler == 0 .AND. kt == nit000 ) THEN      ! Euler time-stepping at first time-step : no filter
291            sshn  (:,:) = ssha  (:,:)                        ! now <-- after  (before already = now)
292            sshu_n(:,:) = sshu_a(:,:)
293            sshv_n(:,:) = sshv_a(:,:)
294            DO jj = 1, jpjm1
295               DO ji = 1, jpim1      ! NO Vector Opt.
296                  sshf_n(ji,jj) = 0.5  * umask(ji,jj,1) * umask(ji,jj+1,1)                   &
297                     &               / ( e1f(ji,jj  ) * e2f(ji,jj  ) )                     &
298                     &               * ( e1u(ji,jj  ) * e2u(ji,jj  ) * sshu_n(ji,jj  )     &
299                     &                 + e1u(ji,jj+1) * e2u(ji,jj+1) * sshu_n(ji,jj+1) )
300               END DO
301            END DO
302            ! Boundaries conditions
303            CALL lbc_lnk( sshf_n, 'F', 1. )
304         ELSE                                           ! Leap-Frog time-stepping: Asselin filter + swap
305            zec = atfp * rdt / rau0
306            DO jj = 1, jpj
307               DO ji = 1, jpi                                ! before <-- now filtered
308                  sshb  (ji,jj) = sshn  (ji,jj) + atfp * ( sshb(ji,jj) - 2 * sshn(ji,jj) + ssha(ji,jj) )   &
309                     &                          - zec  * ( emp_b(ji,jj) - emp(ji,jj) ) * tmask(ji,jj,1)
310                  sshn  (ji,jj) = ssha  (ji,jj)              ! now <-- after
311                  sshu_n(ji,jj) = sshu_a(ji,jj)
312                  sshv_n(ji,jj) = sshv_a(ji,jj)
313               END DO
314            END DO
315            DO jj = 1, jpjm1
316               DO ji = 1, jpim1      ! NO Vector Opt.
317                  sshf_n(ji,jj) = 0.5  * umask(ji,jj,1) * umask(ji,jj+1,1)                 &
318                     &               / ( e1f(ji,jj  ) * e2f(ji,jj  ) )                     &
319                     &               * ( e1u(ji,jj  ) * e2u(ji,jj  ) * sshu_n(ji,jj  )     &
320                     &                 + e1u(ji,jj+1) * e2u(ji,jj+1) * sshu_n(ji,jj+1) )
321               END DO
322            END DO
323            ! Boundaries conditions
324            CALL lbc_lnk( sshf_n, 'F', 1. )
325            DO jj = 1, jpjm1
326               DO ji = 1, jpim1      ! NO Vector Opt.
327                  sshu_b(ji,jj) = 0.5  * umask(ji,jj,1) / ( e1u(ji  ,jj) * e2u(ji  ,jj) )                   &
328                     &                                  * ( e1t(ji  ,jj) * e2t(ji  ,jj) * sshb(ji  ,jj)     &
329                     &                                    + e1t(ji+1,jj) * e2t(ji+1,jj) * sshb(ji+1,jj) )
330                  sshv_b(ji,jj) = 0.5  * vmask(ji,jj,1) / ( e1v(ji,jj  ) * e2v(ji,jj  ) )                   &
331                     &                                  * ( e1t(ji,jj  ) * e2t(ji,jj  ) * sshb(ji,jj  )     &
332                     &                                    + e1t(ji,jj+1) * e2t(ji,jj+1) * sshb(ji,jj+1) )
333               END DO
334            END DO
335            ! Boundaries conditions
336            CALL lbc_lnk( sshu_b, 'U', 1. )
337            CALL lbc_lnk( sshv_b, 'V', 1. )
338         ENDIF
339         !                    !--------------------------!
340      ELSE                    !        fixed levels      !
341         !                    !--------------------------!
342         !
343         ! ssh at t-point only
344         !====================
345         IF( neuler == 0 .AND. kt == nit000 ) THEN      ! Euler time-stepping at first time-step : no filter
346            sshn(:,:) = ssha(:,:)                            ! now <-- after  (before already = now)
347            !
348         ELSE                                           ! Leap-Frog time-stepping: Asselin filter + swap
349            DO jj = 1, jpj
350               DO ji = 1, jpi                                ! before <-- now filtered
351                  sshb(ji,jj) = sshn(ji,jj) + atfp * ( sshb(ji,jj) - 2 * sshn(ji,jj) + ssha(ji,jj) )
352                  sshn(ji,jj) = ssha(ji,jj)                  ! now <-- after
353               END DO
354            END DO
355         ENDIF
356         !
357      ENDIF
358      !
359      ! Update velocity at AGRIF zoom boundaries
360#if defined key_agrif
361      IF ( .NOT.Agrif_Root() ) CALL Agrif_Update_Dyn( kt )
362#endif
363      !
364      IF(ln_ctl)   CALL prt_ctl( tab2d_1=sshb, clinfo1=' sshb  - : ', mask1=tmask, ovlap=1 )
365      !
366   END SUBROUTINE ssh_nxt
367
368   !!======================================================================
369END MODULE sshwzv
Note: See TracBrowser for help on using the repository browser.