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.
dynspg_flt.F90 in branches/TAM_V3_0/NEMO/OPA_SRC/DYN – NEMO

source: branches/TAM_V3_0/NEMO/OPA_SRC/DYN/dynspg_flt.F90 @ 1884

Last change on this file since 1884 was 1884, checked in by rblod, 14 years ago

Light adaptation of NEMO direct model routine to handle TAM

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 23.7 KB
Line 
1MODULE dynspg_flt
2   !!======================================================================
3   !!                   ***  MODULE  dynspg_flt  ***
4   !! Ocean dynamics:  surface pressure gradient trend
5   !!======================================================================
6   !! History    8.0  !  98-05  (G. Roullet)  free surface
7   !!                 !  98-10  (G. Madec, M. Imbard)  release 8.2
8   !!            8.5  !  02-08  (G. Madec)  F90: Free form and module
9   !!            " "  !  02-11  (C. Talandier, A-M Treguier) Open boundaries
10   !!            9.0  !  04-08  (C. Talandier) New trends organization
11   !!            " "  !  05-11  (V. Garnier) Surface pressure gradient organization
12   !!            " "  !  06-07  (S. Masson)  distributed restart using iom
13   !!            " "  !  05-01  (J.Chanut, A.Sellar) Calls to BDY routines.
14   !!----------------------------------------------------------------------
15#if defined key_dynspg_flt   ||   defined key_esopa 
16   !!----------------------------------------------------------------------
17   !!   'key_dynspg_flt'                              filtered free surface
18   !!----------------------------------------------------------------------
19   !!----------------------------------------------------------------------
20   !!   dyn_spg_flt  : update the momentum trend with the surface pressure
21   !!                  gradient in the filtered free surface case with
22   !!                  vector optimization
23   !!   flt_rst      : read/write the time-splitting restart fields in the ocean restart file
24   !!----------------------------------------------------------------------
25   USE oce             ! ocean dynamics and tracers
26   USE dom_oce         ! ocean space and time domain
27   USE zdf_oce         ! ocean vertical physics
28   USE sbc_oce         ! surface boundary condition: ocean
29   USE obc_oce         ! Lateral open boundary condition
30   USE sol_oce         ! ocean elliptic solver
31   USE phycst          ! physical constants
32   USE domvvl          ! variable volume
33   USE solver          ! solver initialization
34   USE solpcg          ! preconditionned conjugate gradient solver
35   USE solsor          ! Successive Over-relaxation solver
36   USE solfet          ! FETI solver
37   USE obcdyn          ! ocean open boundary condition (obc_dyn routines)
38   USE obcvol          ! ocean open boundary condition (obc_vol routines)
39   USE bdy_oce         ! Unstructured open boundaries condition
40   USE bdydyn          ! Unstructured open boundaries condition (bdy_dyn routine)
41   USE bdyvol          ! Unstructured open boundaries condition (bdy_vol routine)
42   USE cla_dynspg      ! cross land advection
43   USE in_out_manager  ! I/O manager
44   USE lib_mpp         ! distributed memory computing library
45   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
46   USE prtctl          ! Print control
47   USE solmat          ! matrix construction for elliptic solvers
48   USE agrif_opa_interp
49   USE iom
50   USE restart         ! only for lrst_oce
51
52   IMPLICIT NONE
53   PRIVATE
54
55   PUBLIC dyn_spg_flt  ! routine called by step.F90
56   PUBLIC flt_rst      ! routine called by istate.F90
57
58   !! * Substitutions
59#  include "domzgr_substitute.h90"
60#  include "vectopt_loop_substitute.h90"
61   !!----------------------------------------------------------------------
62   !!   OPA 9.0 , LOCEAN-IPSL (2005)
63   !! $Id$
64   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
65   !!----------------------------------------------------------------------
66
67CONTAINS
68
69   SUBROUTINE dyn_spg_flt( kt, kindic )
70      !!----------------------------------------------------------------------
71      !!                  ***  routine dyn_spg_flt  ***
72      !!
73      !! ** Purpose :   Compute the now trend due to the surface pressure
74      !!      gradient in case of filtered free surface formulation  and add
75      !!      it to the general trend of momentum equation.
76      !!
77      !! ** Method  :   Filtered free surface formulation. The surface
78      !!      pressure gradient is given by:
79      !!         spgu = 1/rau0 d/dx(ps) =  1/e1u di( sshn + rnu btda )
80      !!         spgv = 1/rau0 d/dy(ps) =  1/e2v dj( sshn + rnu btda )
81      !!      where sshn is the free surface elevation and btda is the after
82      !!      of the free surface elevation
83      !!       -1- compute the after sea surface elevation from the kinematic
84      !!      surface boundary condition:
85      !!              zssha = sshb + 2 rdt ( wn - emp )
86      !!           Time filter applied on now sea surface elevation to avoid
87      !!      the divergence of two consecutive time-steps and swap of free
88      !!      surface arrays to start the next time step:
89      !!              sshb = sshn + atfp * [ sshb + zssha - 2 sshn ]
90      !!              sshn = zssha
91      !!       -2- evaluate the surface presure trend (including the addi-
92      !!      tional force) in three steps:
93      !!        a- compute the right hand side of the elliptic equation:
94      !!            gcb = 1/(e1t e2t) [ di(e2u spgu) + dj(e1v spgv) ]
95      !!         where (spgu,spgv) are given by:
96      !!            spgu = vertical sum[ e3u (ub+ 2 rdt ua ) ]
97      !!                 - grav 2 rdt hu /e1u di[sshn + emp]
98      !!            spgv = vertical sum[ e3v (vb+ 2 rdt va) ]
99      !!                 - grav 2 rdt hv /e2v dj[sshn + emp]
100      !!         and define the first guess from previous computation :
101      !!            zbtd = btda
102      !!            btda = 2 zbtd - btdb
103      !!            btdb = zbtd
104      !!        b- compute the relative accuracy to be reached by the
105      !!         iterative solver
106      !!        c- apply the solver by a call to sol... routine
107      !!       -3- compute and add the free surface pressure gradient inclu-
108      !!      ding the additional force used to stabilize the equation.
109      !!
110      !! ** Action : - Update (ua,va) with the surf. pressure gradient trend
111      !!
112      !! References : Roullet and Madec 1999, JGR.
113      !!---------------------------------------------------------------------
114      !! * Modules used
115      USE oce    , ONLY :   zub   => ta,             &  ! ta used as workspace
116                            zvb   => sa                 ! sa   "          "
117
118      INTEGER, INTENT( in )  ::   kt         ! ocean time-step index
119      INTEGER, INTENT( out ) ::   kindic     ! solver convergence flag (<0 if not converge)
120      !!                                   
121      INTEGER  ::   ji, jj, jk                          ! dummy loop indices
122      REAL(wp) ::   z2dt, z2dtg, zraur, znugdt,      &  ! temporary scalars
123         &          znurau, zgcb, zbtd,              &  !   "          "
124         &          ztdgu, ztdgv                        !   "          "
125      !! Variable volume
126      REAL(wp), DIMENSION(jpi,jpj)     ::  &
127         zsshub, zsshua, zsshvb, zsshva, zssha          ! 2D workspace
128      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  &            ! 3D workspace
129         zfse3ub, zfse3ua, zfse3vb, zfse3va             ! 3D workspace
130      !!----------------------------------------------------------------------
131      !
132      IF( kt == nit000 ) THEN
133         IF(lwp) WRITE(numout,*)
134         IF(lwp) WRITE(numout,*) 'dyn_spg_flt : surface pressure gradient trend'
135         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   (free surface constant volume case)'
136       
137         ! set to zero free surface specific arrays
138         spgu(:,:) = 0.e0                     ! surface pressure gradient (i-direction)
139         spgv(:,:) = 0.e0                     ! surface pressure gradient (j-direction)
140         CALL solver_init( nit000 )           ! Elliptic solver initialisation
141
142         ! read filtered free surface arrays in restart file
143         ! when using agrif, sshn, gcx have to be read in istate
144         IF (.NOT. lk_agrif) CALL flt_rst( nit000, 'READ' )       ! read or initialize the following fields:
145         !                                                        ! gcx, gcxb, sshb, sshn
146      ENDIF
147
148      ! Local constant initialization
149      z2dt = 2. * rdt                                       ! time step: leap-frog
150      IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt       ! time step: Euler if restart from rest
151      IF( neuler == 0 .AND. kt == nit000+1 ) CALL sol_mat(kt)
152      z2dtg  = grav * z2dt
153      zraur  = 1. / rauw
154      znugdt =  rnu * grav * z2dt
155      znurau =  znugdt * zraur
156
157      !! Explicit physics with thickness weighted updates
158      IF( lk_vvl ) THEN          ! variable volume
159
160         DO jj = 1, jpjm1
161            DO ji = 1,jpim1
162
163               ! Sea Surface Height at u-point before
164               zsshub(ji,jj) = 0.5 * umask(ji,jj,1) / ( e1u(ji,jj) * e2u(ji,jj) )  & 
165                  &          * ( e1t(ji  ,jj) * e2t(ji  ,jj) * sshb(ji  ,jj)       &
166                  &            + e1t(ji+1,jj) * e2t(ji+1,jj) * sshb(ji+1,jj) )
167
168               ! Sea Surface Height at v-point before
169               zsshvb(ji,jj) = 0.5 * vmask(ji,jj,1) / ( e1v(ji,jj) * e2v(ji,jj) )  &
170                  &          * ( e1t(ji,jj  ) * e2t(ji,jj  ) * sshb(ji,jj  )       &
171                  &            + e1t(ji,jj+1) * e2t(ji,jj+1) * sshb(ji,jj+1) )
172
173               ! Sea Surface Height at u-point after
174               zsshua(ji,jj) = 0.5 * umask(ji,jj,1) / ( e1u(ji,jj) * e2u(ji,jj) )  &
175                  &          * ( e1t(ji  ,jj) * e2t(ji  ,jj) * ssha(ji  ,jj)       &
176                  &            + e1t(ji+1,jj) * e2t(ji+1,jj) * ssha(ji+1,jj) )
177
178               ! Sea Surface Height at v-point after
179               zsshva(ji,jj) = 0.5 * vmask(ji,jj,1) / ( e1v(ji,jj) * e2v(ji,jj) )  &
180                  &          * ( e1t(ji,jj  ) * e2t(ji,jj  ) * ssha(ji,jj  )       &
181                  &            + e1t(ji,jj+1) * e2t(ji,jj+1) * ssha(ji,jj+1) )
182
183            END DO
184         END DO
185
186         ! Boundaries conditions
187         CALL lbc_lnk( zsshub, 'U', 1. )    ;    CALL lbc_lnk( zsshvb, 'V', 1. )
188         CALL lbc_lnk( zsshua, 'U', 1. )    ;    CALL lbc_lnk( zsshva, 'V', 1. )
189
190         ! Scale factors at before and after time step
191         ! -------------------------------------------
192         CALL dom_vvl_sf( zsshub, 'U', zfse3ub ) ;    CALL dom_vvl_sf( zsshua, 'U', zfse3ua )
193         CALL dom_vvl_sf( zsshvb, 'V', zfse3vb ) ;    CALL dom_vvl_sf( zsshva, 'V', zfse3va )
194
195
196         ! Thickness weighting
197         ! -------------------
198         DO jk = 1, jpkm1
199            DO jj = 1, jpj
200               DO ji = 1, jpi
201                  ua(ji,jj,jk) = ua(ji,jj,jk) * fse3u(ji,jj,jk)
202                  va(ji,jj,jk) = va(ji,jj,jk) * fse3v(ji,jj,jk)
203
204                  zub(ji,jj,jk) = ub(ji,jj,jk) * zfse3ub(ji,jj,jk)
205                  zvb(ji,jj,jk) = vb(ji,jj,jk) * zfse3vb(ji,jj,jk)
206               END DO
207            END DO
208         END DO
209
210         ! Evaluate the masked next velocity (effect of the additional force not included)
211         DO jk = 1, jpkm1
212            DO jj = 2, jpjm1
213               DO ji = fs_2, fs_jpim1   ! vector opt.
214                  ua(ji,jj,jk) = ( zub(ji,jj,jk) + z2dt * ua(ji,jj,jk) ) /zfse3ua(ji,jj,jk) * umask(ji,jj,jk)
215                  va(ji,jj,jk) = ( zvb(ji,jj,jk) + z2dt * va(ji,jj,jk) ) /zfse3va(ji,jj,jk) * vmask(ji,jj,jk)
216               END DO
217            END DO
218         END DO
219
220      ELSE                       ! fixed volume
221
222         ! Surface pressure gradient (now)
223         DO jj = 2, jpjm1
224            DO ji = fs_2, fs_jpim1   ! vector opt.
225               spgu(ji,jj) = - grav * ( sshn(ji+1,jj) - sshn(ji,jj) ) / e1u(ji,jj)
226               spgv(ji,jj) = - grav * ( sshn(ji,jj+1) - sshn(ji,jj) ) / e2v(ji,jj)
227            END DO
228         END DO 
229
230         ! Add the surface pressure trend to the general trend
231         DO jk = 1, jpkm1
232            DO jj = 2, jpjm1
233               DO ji = fs_2, fs_jpim1   ! vector opt.
234                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
235                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
236               END DO
237            END DO
238         END DO
239
240         ! Evaluate the masked next velocity (effect of the additional force not included)
241         DO jk = 1, jpkm1
242            DO jj = 2, jpjm1
243               DO ji = fs_2, fs_jpim1   ! vector opt.
244                  ua(ji,jj,jk) = ( ub(ji,jj,jk) + z2dt * ua(ji,jj,jk) ) * umask(ji,jj,jk)
245                  va(ji,jj,jk) = ( vb(ji,jj,jk) + z2dt * va(ji,jj,jk) ) * vmask(ji,jj,jk)
246               END DO
247            END DO
248         END DO
249
250      ENDIF
251
252#if defined key_obc
253      CALL obc_dyn( kt )      ! Update velocities on each open boundary with the radiation algorithm
254#  if defined key_pomme_r025
255      IF( nbit_cmp == 0 )  CALL obc_vol( kt )  ! Correction of the barotropic componant velocity to control the volume of the system
256#  else
257      CALL obc_vol( kt )  ! Correction of the barotropic componant velocity to control the volume of the system
258#  endif
259#endif
260#if defined key_bdy
261      ! Update velocities on unstructured boundary using the Flow Relaxation Scheme
262      CALL bdy_dyn_frs( kt )
263
264      IF (ln_bdy_vol) THEN
265      ! Correction of the barotropic component velocity to control the volume of the system
266        CALL bdy_vol( kt )
267      ENDIF
268#endif
269#if defined key_agrif
270      CALL Agrif_dyn( kt )    ! Update velocities on each coarse/fine interfaces
271#endif
272#if defined key_orca_r2
273      IF( n_cla == 1 )   CALL dyn_spg_cla( kt )      ! Cross Land Advection (update (ua,va))
274#endif
275
276      ! compute the next vertically averaged velocity (effect of the additional force not included)
277      ! ---------------------------------------------
278      DO jj = 2, jpjm1
279         DO ji = fs_2, fs_jpim1   ! vector opt.
280            spgu(ji,jj) = 0.e0
281            spgv(ji,jj) = 0.e0
282         END DO
283      END DO
284
285      ! vertical sum
286!CDIR NOLOOPCHG
287      IF( lk_vopt_loop ) THEN          ! vector opt., forced unroll
288         DO jk = 1, jpkm1
289            DO ji = 1, jpij
290               spgu(ji,1) = spgu(ji,1) + fse3u(ji,1,jk) * ua(ji,1,jk)
291               spgv(ji,1) = spgv(ji,1) + fse3v(ji,1,jk) * va(ji,1,jk)
292            END DO
293         END DO
294      ELSE                        ! No  vector opt.
295         DO jk = 1, jpkm1
296            DO jj = 2, jpjm1
297               DO ji = 2, jpim1
298                  spgu(ji,jj) = spgu(ji,jj) + fse3u(ji,jj,jk) * ua(ji,jj,jk)
299                  spgv(ji,jj) = spgv(ji,jj) + fse3v(ji,jj,jk) * va(ji,jj,jk)
300               END DO
301            END DO
302         END DO
303      ENDIF
304
305      ! transport: multiplied by the horizontal scale factor
306      DO jj = 2, jpjm1
307         DO ji = fs_2, fs_jpim1   ! vector opt.
308            spgu(ji,jj) = spgu(ji,jj) * e2u(ji,jj)
309            spgv(ji,jj) = spgv(ji,jj) * e1v(ji,jj)
310         END DO
311      END DO
312
313      ! Boundary conditions on (spgu,spgv)
314      CALL lbc_lnk( spgu, 'U', -1. )
315      CALL lbc_lnk( spgv, 'V', -1. )
316
317      IF( lk_vvl ) CALL sol_mat( kt )
318
319      ! Right hand side of the elliptic equation and first guess
320      ! -----------------------------------------------------------
321      DO jj = 2, jpjm1
322         DO ji = fs_2, fs_jpim1   ! vector opt.
323            ! Divergence of the after vertically averaged velocity
324            zgcb =  spgu(ji,jj) - spgu(ji-1,jj)   &
325                  + spgv(ji,jj) - spgv(ji,jj-1)
326            gcb(ji,jj) = gcdprc(ji,jj) * zgcb
327            ! First guess of the after barotropic transport divergence
328            zbtd = gcx(ji,jj)
329            gcx (ji,jj) = 2. * zbtd   - gcxb(ji,jj)
330            gcxb(ji,jj) =      zbtd
331         END DO
332      END DO
333      ! applied the lateral boundary conditions
334      IF( nsolv == 2 .AND. MAX( jpr2di, jpr2dj ) > 0 ) CALL lbc_lnk_e( gcb, c_solver_pt, 1. )   
335
336#if defined key_agrif
337      IF( .NOT. AGRIF_ROOT() ) THEN
338         ! add contribution of gradient of after barotropic transport divergence
339         IF( nbondi == -1 .OR. nbondi == 2 )   gcb(3     ,:) =   &
340            &    gcb(3     ,:) - znugdt * z2dt * laplacu(2     ,:) * gcdprc(3     ,:) * hu(2     ,:) * e2u(2     ,:)
341         IF( nbondi ==  1 .OR. nbondi == 2 )   gcb(nlci-2,:) =   &
342            &    gcb(nlci-2,:) + znugdt * z2dt * laplacu(nlci-2,:) * gcdprc(nlci-2,:) * hu(nlci-2,:) * e2u(nlci-2,:)
343         IF( nbondj == -1 .OR. nbondj == 2 )   gcb(:     ,3) =   &
344            &    gcb(:,3     ) - znugdt * z2dt * laplacv(:,2     ) * gcdprc(:,3     ) * hv(:,2     ) * e1v(:,2     )
345         IF( nbondj ==  1 .OR. nbondj == 2 )   gcb(:,nlcj-2) =   &
346            &    gcb(:,nlcj-2) + znugdt * z2dt * laplacv(:,nlcj-2) * gcdprc(:,nlcj-2) * hv(:,nlcj-2) * e1v(:,nlcj-2)
347      ENDIF
348#endif
349
350
351      ! Relative precision (computation on one processor)
352      ! ------------------
353      rnorme =0.
354      rnorme = SUM( gcb(1:jpi,1:jpj) * gcdmat(1:jpi,1:jpj) * gcb(1:jpi,1:jpj) * bmask(:,:) )
355      IF( lk_mpp )   CALL mpp_sum( rnorme )   ! sum over the global domain
356
357      epsr = eps * eps * rnorme
358      ncut = 0
359      ! if rnorme is 0, the solution is 0, the solver is not called
360      IF( rnorme == 0.e0 ) THEN
361         gcx(:,:) = 0.e0
362         res   = 0.e0
363         niter = 0
364         ncut  = 999
365      ENDIF
366
367      ! Evaluate the next transport divergence
368      ! --------------------------------------
369      !    Iterarive solver for the elliptic equation (except IF sol.=0)
370      !    (output in gcx with boundary conditions applied)
371      kindic = 0
372      IF( ncut == 0 ) THEN
373         IF( nsolv == 1 ) THEN         ! diagonal preconditioned conjuguate gradient
374            CALL sol_pcg( kindic )
375         ELSEIF( nsolv == 2 ) THEN     ! successive-over-relaxation
376            CALL sol_sor( kindic )
377         ELSEIF( nsolv == 3 ) THEN     ! FETI solver
378            CALL sol_fet( kindic )
379         ELSE                          ! e r r o r in nsolv namelist parameter
380            WRITE(ctmp1,*) ' ~~~~~~~~~~~                not = ', nsolv
381            CALL ctl_stop( ' dyn_spg_flt : e r r o r, nsolv = 1, 2 or 3', ctmp1 )
382         ENDIF
383      ENDIF
384
385      ! Transport divergence gradient multiplied by z2dt
386      ! --------------------------------------------====
387      DO jj = 2, jpjm1
388         DO ji = fs_2, fs_jpim1   ! vector opt.
389            ! trend of Transport divergence gradient
390            ztdgu = znugdt * (gcx(ji+1,jj  ) - gcx(ji,jj) ) / e1u(ji,jj)
391            ztdgv = znugdt * (gcx(ji  ,jj+1) - gcx(ji,jj) ) / e2v(ji,jj)
392            ! multiplied by z2dt
393#if defined key_obc
394            ! caution : grad D = 0 along open boundaries
395            spgu(ji,jj) = z2dt * ztdgu * obcumask(ji,jj)
396            spgv(ji,jj) = z2dt * ztdgv * obcvmask(ji,jj)
397#elif defined key_bdy
398            ! caution : grad D = 0 along open boundaries
399            ! Remark: The filtering force could be reduced here in the FRS zone
400            !         by multiplying spgu/spgv by (1-alpha) ?? 
401            spgu(ji,jj) = z2dt * ztdgu * bdyumask(ji,jj)
402            spgv(ji,jj) = z2dt * ztdgv * bdyvmask(ji,jj)           
403#else
404            spgu(ji,jj) = z2dt * ztdgu
405            spgv(ji,jj) = z2dt * ztdgv
406#endif
407         END DO
408      END DO
409
410#if defined key_agrif     
411      IF( .NOT. Agrif_Root() ) THEN
412         ! caution : grad D (fine) = grad D (coarse) at coarse/fine interface
413         IF( nbondi == -1 .OR. nbondi == 2 ) spgu(2     ,:) = znugdt * z2dt * laplacu(2     ,:) * umask(2     ,:,1)
414         IF( nbondi ==  1 .OR. nbondi == 2 ) spgu(nlci-2,:) = znugdt * z2dt * laplacu(nlci-2,:) * umask(nlci-2,:,1)
415         IF( nbondj == -1 .OR. nbondj == 2 ) spgv(:,2     ) = znugdt * z2dt * laplacv(:,2     ) * vmask(:     ,2,1)
416         IF( nbondj ==  1 .OR. nbondj == 2 ) spgv(:,nlcj-2) = znugdt * z2dt * laplacv(:,nlcj-2) * vmask(:,nlcj-2,1)
417      ENDIF
418#endif     
419      ! 7.  Add the trends multiplied by z2dt to the after velocity
420      ! -----------------------------------------------------------
421      !     ( c a u t i o n : (ua,va) here are the after velocity not the
422      !                       trend, the leap-frog time stepping will not
423      !                       be done in dynnxt.F90 routine)
424      DO jk = 1, jpkm1
425         DO jj = 2, jpjm1
426            DO ji = fs_2, fs_jpim1   ! vector opt.
427               ua(ji,jj,jk) = (ua(ji,jj,jk) + spgu(ji,jj)) * umask(ji,jj,jk)
428               va(ji,jj,jk) = (va(ji,jj,jk) + spgv(ji,jj)) * vmask(ji,jj,jk)
429            END DO
430         END DO
431      END DO
432
433      ! Sea surface elevation time stepping
434      ! -----------------------------------
435      IF( lk_vvl ) THEN   ! after free surface elevation
436         zssha(:,:) = ssha(:,:)
437      ELSE
438         zssha(:,:) = sshb(:,:) + z2dt * ( wn(:,:,1) - emp(:,:) * zraur ) * tmask(:,:,1)
439      ENDIF
440#if defined key_obc
441# if defined key_agrif
442      IF ( Agrif_Root() ) THEN
443# endif
444         zssha(:,:)=zssha(:,:)*obctmsk(:,:)
445         CALL lbc_lnk(zssha,'T',1.)  ! absolutly compulsory !! (jmm)
446# if defined key_agrif
447      ENDIF
448# endif
449#endif
450
451      IF( neuler == 0 .AND. kt == nit000 ) THEN      ! Euler (forward) time stepping, no time filter
452         ! swap of arrays
453         sshb(:,:) = sshn (:,:)
454         sshn(:,:) = zssha(:,:)
455      ELSE                                           ! Leap-frog time stepping and time filter
456         ! time filter and array swap
457         sshb(:,:) = atfp * ( sshb(:,:) + zssha(:,:) ) + atfp1 * sshn(:,:)
458         sshn(:,:) = zssha(:,:)
459      ENDIF
460
461      ! write filtered free surface arrays in restart file
462      ! --------------------------------------------------
463      IF( lrst_oce ) CALL flt_rst( kt, 'WRITE' )
464
465      ! print sum trends (used for debugging)
466      IF(ln_ctl)     CALL prt_ctl( tab2d_1=sshn, clinfo1=' spg  - ssh: ', mask1=tmask )
467      !
468   END SUBROUTINE dyn_spg_flt
469
470
471   SUBROUTINE flt_rst( kt, cdrw )
472     !!---------------------------------------------------------------------
473     !!                   ***  ROUTINE ts_rst  ***
474     !!
475     !! ** Purpose : Read or write filtered free surface arrays in restart file
476     !!----------------------------------------------------------------------
477     INTEGER         , INTENT(in) ::   kt         ! ocean time-step
478     CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
479     !!----------------------------------------------------------------------
480
481     IF( TRIM(cdrw) == 'READ' ) THEN
482        IF( iom_varid( numror, 'gcx', ldstop = .FALSE. ) > 0 ) THEN
483! Caution : extra-hallow
484! gcx and gcxb are defined as: DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)
485           CALL iom_get( numror, jpdom_autoglo, 'gcx' , gcx (1:jpi,1:jpj) )
486           CALL iom_get( numror, jpdom_autoglo, 'gcxb', gcxb(1:jpi,1:jpj) )
487           CALL iom_get( numror, jpdom_autoglo, 'sshb', sshb(:,:)         )
488           CALL iom_get( numror, jpdom_autoglo, 'sshn', sshn(:,:)         )
489           IF( neuler == 0 ) THEN
490              sshb(:,:) = sshn(:,:)
491              gcxb(:,:) = gcx (:,:)
492           ENDIF
493        ELSE
494           gcx (:,:) = 0.e0
495           gcxb(:,:) = 0.e0
496           IF( nn_rstssh == 1 ) THEN 
497              sshb(:,:) = 0.e0
498              sshn(:,:) = 0.e0
499           ENDIF
500        ENDIF
501     ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
502! Caution : extra-hallow
503! gcx and gcxb are defined as: DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)
504        CALL iom_rstput( kt, nitrst, numrow, 'gcx' , gcx( 1:jpi,1:jpj) )
505        CALL iom_rstput( kt, nitrst, numrow, 'gcxb', gcxb(1:jpi,1:jpj) )
506        CALL iom_rstput( kt, nitrst, numrow, 'sshb', sshb(:,:)         )
507        CALL iom_rstput( kt, nitrst, numrow, 'sshn', sshn(:,:)         )
508     ENDIF
509     !
510   END SUBROUTINE flt_rst
511
512#else
513   !!----------------------------------------------------------------------
514   !!   Default case :   Empty module   No standart free surface cst volume
515   !!----------------------------------------------------------------------
516CONTAINS
517   SUBROUTINE dyn_spg_flt( kt, kindic )       ! Empty routine
518      WRITE(*,*) 'dyn_spg_flt: You should not have seen this print! error?', kt, kindic
519   END SUBROUTINE dyn_spg_flt
520   SUBROUTINE flt_rst    ( kt, cdrw )         ! Empty routine
521      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
522      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
523      WRITE(*,*) 'flt_rst: You should not have seen this print! error?', kt, cdrw
524   END SUBROUTINE flt_rst
525#endif
526   
527   !!======================================================================
528END MODULE dynspg_flt
Note: See TracBrowser for help on using the repository browser.