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

source: branches/2013/dev_MERGE_2013/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90 @ 4487

Last change on this file since 4487 was 4487, checked in by acc, 10 years ago

#1223 fix surface pressure gradient typo error in dynspg.F90 for the case of tidal potential forcing with dynspg_flt

  • Property svn:keywords set to Id
File size: 13.9 KB
Line 
1MODULE dynspg
2   !!======================================================================
3   !!                       ***  MODULE  dynspg  ***
4   !! Ocean dynamics:  surface pressure gradient control
5   !!======================================================================
6   !! History :  1.0  ! 2005-12  (C. Talandier, G. Madec, V. Garnier)  Original code
7   !!            3.2  ! 2009-07  (R. Benshila)  Suppression of rigid-lid option
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   dyn_spg     : update the dynamics trend with the lateral diffusion
12   !!   dyn_spg_ctl : initialization, namelist read, and parameters control
13   !!----------------------------------------------------------------------
14   USE oce            ! ocean dynamics and tracers variables
15   USE dom_oce        ! ocean space and time domain variables
16   USE c1d            ! 1D vertical configuration
17   USE phycst         ! physical constants
18   USE sbc_oce        ! surface boundary condition: ocean
19   USE sbcapr         ! surface boundary condition: atmospheric pressure
20   USE dynspg_oce     ! surface pressure gradient variables
21   USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
22   USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
23   USE dynspg_flt     ! surface pressure gradient     (dyn_spg_flt routine)
24   USE dynadv         ! dynamics: vector invariant versus flux form
25   USE dynhpg, ONLY: ln_dynhpg_imp
26   USE sbctide
27   USE updtide
28   USE trdmod         ! ocean dynamics trends
29   USE trdmod_oce     ! ocean variables trends
30   USE prtctl         ! Print control                     (prt_ctl routine)
31   USE in_out_manager ! I/O manager
32   USE lib_mpp        ! MPP library
33   USE solver          ! solver initialization
34   USE wrk_nemo        ! Memory Allocation
35   USE timing          ! Timing
36
37
38   IMPLICIT NONE
39   PRIVATE
40
41   PUBLIC   dyn_spg        ! routine called by step module
42   PUBLIC   dyn_spg_init   ! routine called by opa module
43
44   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_...
45
46   !! * Substitutions
47#  include "domzgr_substitute.h90"
48#  include "vectopt_loop_substitute.h90"
49   !!----------------------------------------------------------------------
50   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
51   !! $Id$
52   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
53   !!----------------------------------------------------------------------
54CONTAINS
55
56   SUBROUTINE dyn_spg( kt, kindic )
57      !!----------------------------------------------------------------------
58      !!                  ***  ROUTINE dyn_spg  ***
59      !!
60      !! ** Purpose :   achieve the momentum time stepping by computing the
61      !!              last trend, the surface pressure gradient including the
62      !!              atmospheric pressure forcing (ln_apr_dyn=T), and performing
63      !!              the Leap-Frog integration.
64      !!gm              In the current version only the filtered solution provide
65      !!gm            the after velocity, in the 2 other (ua,va) are still the trends
66      !!
67      !! ** Method  :   Three schemes:
68      !!              - explicit computation      : the spg is evaluated at now
69      !!              - filtered computation      : the Roulet & madec (2000) technique is used
70      !!              - split-explicit computation: a time splitting technique is used
71      !!
72      !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied
73      !!             as the gradient of the inverse barometer ssh:
74      !!                apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb]
75      !!                apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb]
76      !!             Note that as all external forcing a time averaging over a two rdt
77      !!             period is used to prevent the divergence of odd and even time step.
78      !!
79      !! N.B. : When key_esopa is used all the scheme are tested, regardless
80      !!        of the physical meaning of the results.
81      !!----------------------------------------------------------------------
82      !
83      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
84      INTEGER, INTENT(  out) ::   kindic   ! solver flag
85      !
86      INTEGER  ::   ji, jj, jk                             ! dummy loop indices
87      REAL(wp) ::   z2dt, zg_2, zintp, zgrau0r             ! temporary scalar
88      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
89      REAL(wp), POINTER, DIMENSION(:,:)   ::  zpice
90      !!----------------------------------------------------------------------
91      !
92      IF( nn_timing == 1 )  CALL timing_start('dyn_spg')
93      !
94
95!!gm NOTA BENE : the dynspg_exp and dynspg_ts should be modified so that
96!!gm             they return the after velocity, not the trends (as in trazdf_imp...)
97!!gm             In this case, change/simplify dynnxt
98
99
100      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
101         CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
102         ztrdu(:,:,:) = ua(:,:,:)
103         ztrdv(:,:,:) = va(:,:,:)
104      ENDIF
105
106      IF(      ln_apr_dyn                                                &   ! atmos. pressure
107         .OR.  ( .NOT.lk_dynspg_ts .AND. (ln_tide_pot .AND. lk_tide) )   &   ! tide potential (no time slitting)
108         .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
109         !
110         DO jj = 2, jpjm1
111            DO ji = fs_2, fs_jpim1   ! vector opt.
112               spgu(ji,jj) = 0._wp
113               spgv(ji,jj) = 0._wp
114            END DO
115         END DO         
116         !
117         IF( ln_apr_dyn .AND. (.NOT. lk_dynspg_ts) ) THEN                    !==  Atmospheric pressure gradient (added later in time-split case) ==!
118            zg_2 = grav * 0.5
119            DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
120               DO ji = fs_2, fs_jpim1   ! vector opt.
121                  spgu(ji,jj) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
122                     &                      + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) /e1u(ji,jj)
123                  spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
124                     &                      + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) /e2v(ji,jj)
125               END DO
126            END DO
127         ENDIF
128         !
129         !                                    !==  tide potential forcing term  ==!
130         IF( .NOT.lk_dynspg_ts .AND. ( ln_tide_pot .AND. lk_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
131            !
132            CALL upd_tide( kt )                      ! update tide potential
133            !
134            DO jj = 2, jpjm1                         ! add tide potential forcing
135               DO ji = fs_2, fs_jpim1   ! vector opt.
136                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) / e1u(ji,jj)
137                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) / e2v(ji,jj)
138               END DO
139            END DO
140         ENDIF
141         !
142         IF( nn_ice_embd == 2 ) THEN          !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
143            CALL wrk_alloc( jpi, jpj, zpice )
144            !                                           
145            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
146            zgrau0r     = - grav * r1_rau0
147            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
148            DO jj = 2, jpjm1
149               DO ji = fs_2, fs_jpim1   ! vector opt.
150                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) / e1u(ji,jj)
151                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) / e2v(ji,jj)
152               END DO
153            END DO
154            !
155            CALL wrk_dealloc( jpi, jpj, zpice )         
156         ENDIF
157         !
158         DO jk = 1, jpkm1                     !== Add all terms to the general trend
159            DO jj = 2, jpjm1
160               DO ji = fs_2, fs_jpim1   ! vector opt.
161                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
162                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
163               END DO
164            END DO
165         END DO         
166      ENDIF
167
168      SELECT CASE ( nspg )                       ! compute surf. pressure gradient trend and add it to the general trend
169      !                                                     
170      CASE (  0 )   ;   CALL dyn_spg_exp( kt )              ! explicit
171      CASE (  1 )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
172      CASE (  2 )   ;   CALL dyn_spg_flt( kt, kindic )      ! filtered
173      !                                                   
174      CASE ( -1 )                                ! esopa: test all possibility with control print
175                        CALL dyn_spg_exp( kt )
176                        CALL prt_ctl( tab3d_1=ua, clinfo1=' spg0 - Ua: ', mask1=umask, &
177         &                            tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
178                        CALL dyn_spg_ts ( kt )
179                        CALL prt_ctl( tab3d_1=ua, clinfo1=' spg1 - Ua: ', mask1=umask, &
180         &                           tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
181                        CALL dyn_spg_flt( kt, kindic )
182                        CALL prt_ctl( tab3d_1=ua, clinfo1=' spg2 - Ua: ', mask1=umask, &
183         &                            tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
184      END SELECT
185      !                   
186      IF( l_trddyn )   THEN                      ! save the surface pressure gradient trends for further diagnostics
187         SELECT CASE ( nspg )
188         CASE ( 0, 1 )
189            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
190            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
191         CASE( 2 )
192            z2dt = 2. * rdt
193            IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt
194            ztrdu(:,:,:) = ( ua(:,:,:) - ub(:,:,:) ) / z2dt - ztrdu(:,:,:)
195            ztrdv(:,:,:) = ( va(:,:,:) - vb(:,:,:) ) / z2dt - ztrdv(:,:,:)
196         END SELECT
197         CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_spg, 'DYN', kt )
198         !
199         CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
200      ENDIF
201      !                                          ! print mean trends (used for debugging)
202      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
203         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
204      !
205      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg')
206      !
207   END SUBROUTINE dyn_spg
208
209
210   SUBROUTINE dyn_spg_init
211      !!---------------------------------------------------------------------
212      !!                  ***  ROUTINE dyn_spg_init  ***
213      !!               
214      !! ** Purpose :   Control the consistency between cpp options for
215      !!              surface pressure gradient schemes
216      !!----------------------------------------------------------------------
217      INTEGER ::   ioptio
218      !!----------------------------------------------------------------------
219      !
220      IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
221      !
222      IF(lwp) THEN             ! Control print
223         WRITE(numout,*)
224         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
225         WRITE(numout,*) '~~~~~~~~~~~'
226         WRITE(numout,*) '     Explicit free surface                  lk_dynspg_exp = ', lk_dynspg_exp
227         WRITE(numout,*) '     Free surface with time splitting       lk_dynspg_ts  = ', lk_dynspg_ts
228         WRITE(numout,*) '     Filtered free surface cst volume       lk_dynspg_flt = ', lk_dynspg_flt
229      ENDIF
230
231      IF( lk_dynspg_ts ) CALL dyn_spg_ts_init( nit000 )
232      ! (do it now, to set nn_baro, used to allocate some arrays later on)
233      !                        ! allocate dyn_spg arrays
234      IF( lk_dynspg_ts ) THEN
235         IF( dynspg_oce_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_oce arrays')
236         IF( dyn_spg_ts_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays')
237      ENDIF
238
239      !                        ! Control of surface pressure gradient scheme options
240      ioptio = 0
241      IF(lk_dynspg_exp)   ioptio = ioptio + 1
242      IF(lk_dynspg_ts )   ioptio = ioptio + 1
243      IF(lk_dynspg_flt)   ioptio = ioptio + 1
244      !
245      IF( ( ioptio > 1 .AND. .NOT. lk_esopa ) .OR. ( ioptio == 0 .AND. .NOT. lk_c1d ) )   &
246           &   CALL ctl_stop( ' Choose only one surface pressure gradient scheme with a key cpp' )
247      !
248      IF( lk_esopa     )   nspg = -1
249      IF( lk_dynspg_exp)   nspg =  0
250      IF( lk_dynspg_ts )   nspg =  1
251      IF( lk_dynspg_flt)   nspg =  2
252      !
253      IF( lk_esopa     )   nspg = -1
254      !
255      IF(lwp) THEN
256         WRITE(numout,*)
257         IF( nspg == -1 )   WRITE(numout,*) '     ESOPA test All scheme used'
258         IF( nspg ==  0 )   WRITE(numout,*) '     explicit free surface'
259         IF( nspg ==  1 )   WRITE(numout,*) '     free surface with time splitting scheme'
260         IF( nspg ==  2 )   WRITE(numout,*) '     filtered free surface'
261      ENDIF
262
263#if defined key_dynspg_flt || defined key_esopa
264      CALL solver_init( nit000 )   ! Elliptic solver initialisation
265#endif
266
267      !                        ! Control of timestep choice
268      IF( lk_dynspg_ts .OR. lk_dynspg_exp ) THEN
269         IF( nn_cla == 1 )   CALL ctl_stop( 'Crossland advection not implemented for this free surface formulation' )
270      ENDIF
271
272      !               ! Control of hydrostatic pressure choice
273      IF( lk_dynspg_ts .AND. ln_dynhpg_imp ) THEN
274         CALL ctl_stop( 'Semi-implicit hpg not compatible with time splitting' )
275      ENDIF
276      !
277      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_init')
278      !
279   END SUBROUTINE dyn_spg_init
280
281  !!======================================================================
282END MODULE dynspg
Note: See TracBrowser for help on using the repository browser.