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/2015/dev_r5847_MERCATOR9_solveur_simplification/NEMOGCM/NEMO/OPA_SRC/DYN – NEMO

source: branches/2015/dev_r5847_MERCATOR9_solveur_simplification/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90 @ 5869

Last change on this file since 5869 was 5869, checked in by jchanut, 8 years ago

Free surface simplification #1620. Step 2: suppress implicit pressure gradient

  • Property svn:keywords set to Id
File size: 11.7 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 dynadv         ! dynamics: vector invariant versus flux form
24   USE sbctide
25   USE updtide
26   USE trd_oce        ! trends: ocean variables
27   USE trddyn         ! trend manager: dynamics
28   !
29   USE prtctl         ! Print control                     (prt_ctl routine)
30   USE in_out_manager ! I/O manager
31   USE lib_mpp        ! MPP library
32   USE wrk_nemo       ! Memory Allocation
33   USE timing         ! Timing
34
35
36   IMPLICIT NONE
37   PRIVATE
38
39   PUBLIC   dyn_spg        ! routine called by step module
40   PUBLIC   dyn_spg_init   ! routine called by opa module
41
42   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_...
43
44   !! * Substitutions
45#  include "domzgr_substitute.h90"
46#  include "vectopt_loop_substitute.h90"
47   !!----------------------------------------------------------------------
48   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
49   !! $Id$
50   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
51   !!----------------------------------------------------------------------
52CONTAINS
53
54   SUBROUTINE dyn_spg( kt )
55      !!----------------------------------------------------------------------
56      !!                  ***  ROUTINE dyn_spg  ***
57      !!
58      !! ** Purpose :   achieve the momentum time stepping by computing the
59      !!              last trend, the surface pressure gradient including the
60      !!              atmospheric pressure forcing (ln_apr_dyn=T), and performing
61      !!              the Leap-Frog integration.
62      !!gm              In the current version only the filtered solution provide
63      !!gm            the after velocity, in the 2 other (ua,va) are still the trends
64      !!
65      !! ** Method  :   Three schemes:
66      !!              - explicit computation      : the spg is evaluated at now
67      !!              - filtered computation      : the Roulet & madec (2000) technique is used
68      !!              - split-explicit computation: a time splitting technique is used
69      !!
70      !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied
71      !!             as the gradient of the inverse barometer ssh:
72      !!                apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb]
73      !!                apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb]
74      !!             Note that as all external forcing a time averaging over a two rdt
75      !!             period is used to prevent the divergence of odd and even time step.
76      !!----------------------------------------------------------------------
77      !
78      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
79      !
80      INTEGER  ::   ji, jj, jk                             ! dummy loop indices
81      REAL(wp) ::   z2dt, zg_2, zintp, zgrau0r             ! temporary scalar
82      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
83      REAL(wp), POINTER, DIMENSION(:,:)   ::  zpice
84      !!----------------------------------------------------------------------
85      !
86      IF( nn_timing == 1 )  CALL timing_start('dyn_spg')
87      !
88
89!!gm NOTA BENE : the dynspg_exp and dynspg_ts should be modified so that
90!!gm             they return the after velocity, not the trends (as in trazdf_imp...)
91!!gm             In this case, change/simplify dynnxt
92
93
94      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
95         CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
96         ztrdu(:,:,:) = ua(:,:,:)
97         ztrdv(:,:,:) = va(:,:,:)
98      ENDIF
99
100      IF(      ln_apr_dyn                                                &   ! atmos. pressure
101         .OR.  ( .NOT.lk_dynspg_ts .AND. (ln_tide_pot .AND. lk_tide) )   &   ! tide potential (no time slitting)
102         .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
103         !
104         DO jj = 2, jpjm1
105            DO ji = fs_2, fs_jpim1   ! vector opt.
106               spgu(ji,jj) = 0._wp
107               spgv(ji,jj) = 0._wp
108            END DO
109         END DO         
110         !
111         IF( ln_apr_dyn .AND. (.NOT. lk_dynspg_ts) ) THEN                    !==  Atmospheric pressure gradient (added later in time-split case) ==!
112            zg_2 = grav * 0.5
113            DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
114               DO ji = fs_2, fs_jpim1   ! vector opt.
115                  spgu(ji,jj) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
116                     &                      + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
117                  spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
118                     &                      + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
119               END DO
120            END DO
121         ENDIF
122         !
123         !                                    !==  tide potential forcing term  ==!
124         IF( .NOT.lk_dynspg_ts .AND. ( ln_tide_pot .AND. lk_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
125            !
126            CALL upd_tide( kt )                      ! update tide potential
127            !
128            DO jj = 2, jpjm1                         ! add tide potential forcing
129               DO ji = fs_2, fs_jpim1   ! vector opt.
130                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
131                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
132               END DO
133            END DO
134         ENDIF
135         !
136         IF( nn_ice_embd == 2 ) THEN          !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
137            CALL wrk_alloc( jpi, jpj, zpice )
138            !                                           
139            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
140            zgrau0r     = - grav * r1_rau0
141            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
142            DO jj = 2, jpjm1
143               DO ji = fs_2, fs_jpim1   ! vector opt.
144                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
145                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
146               END DO
147            END DO
148            !
149            CALL wrk_dealloc( jpi, jpj, zpice )         
150         ENDIF
151         !
152         DO jk = 1, jpkm1                     !== Add all terms to the general trend
153            DO jj = 2, jpjm1
154               DO ji = fs_2, fs_jpim1   ! vector opt.
155                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
156                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
157               END DO
158            END DO
159         END DO   
160         
161!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
162             
163      ENDIF
164
165      SELECT CASE ( nspg )                       ! compute surf. pressure gradient trend and add it to the general trend
166      !                                                     
167      CASE (  0 )   ;   CALL dyn_spg_exp( kt )              ! explicit
168      CASE (  1 )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
169      !                                                   
170      END SELECT
171      !                   
172      IF( l_trddyn )   THEN                      ! save the surface pressure gradient trends for further diagnostics
173         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
174         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
175         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
176         !
177         CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
178      ENDIF
179      !                                          ! print mean trends (used for debugging)
180      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
181         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
182      !
183      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg')
184      !
185   END SUBROUTINE dyn_spg
186
187
188   SUBROUTINE dyn_spg_init
189      !!---------------------------------------------------------------------
190      !!                  ***  ROUTINE dyn_spg_init  ***
191      !!               
192      !! ** Purpose :   Control the consistency between cpp options for
193      !!              surface pressure gradient schemes
194      !!----------------------------------------------------------------------
195      INTEGER ::   ioptio
196      !!----------------------------------------------------------------------
197      !
198      IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
199      !
200      IF(lwp) THEN             ! Control print
201         WRITE(numout,*)
202         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
203         WRITE(numout,*) '~~~~~~~~~~~'
204         WRITE(numout,*) '     Explicit free surface                  lk_dynspg_exp = ', lk_dynspg_exp
205         WRITE(numout,*) '     Free surface with time splitting       lk_dynspg_ts  = ', lk_dynspg_ts
206      ENDIF
207
208      IF( lk_dynspg_ts ) CALL dyn_spg_ts_init( nit000 )
209      ! (do it now, to set nn_baro, used to allocate some arrays later on)
210      !                        ! allocate dyn_spg arrays
211      IF( lk_dynspg_ts ) THEN
212         IF( dynspg_oce_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_oce arrays')
213         IF( dyn_spg_ts_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays')
214         IF ((neuler/=0).AND.(ln_bt_fw)) CALL ts_rst( nit000, 'READ' )
215      ENDIF
216
217      !                        ! Control of surface pressure gradient scheme options
218      ioptio = 0
219      IF(lk_dynspg_exp)   ioptio = ioptio + 1
220      IF(lk_dynspg_ts )   ioptio = ioptio + 1
221      !
222      IF(  ioptio > 1  .OR. ( ioptio == 0 .AND. .NOT. lk_c1d ) )   &
223           &   CALL ctl_stop( ' Choose only one surface pressure gradient scheme with a key cpp' )
224      IF( ( lk_dynspg_ts .OR. lk_dynspg_exp ) .AND. ln_isfcav )   &
225           &   CALL ctl_stop( ' dynspg_ts and dynspg_exp not tested with ice shelf cavity ' )
226      !
227      IF( lk_dynspg_exp)   nspg =  0
228      IF( lk_dynspg_ts )   nspg =  1
229
230      !
231      IF(lwp) THEN
232         WRITE(numout,*)
233         IF( nspg ==  0 )   WRITE(numout,*) '     explicit free surface'
234         IF( nspg ==  1 )   WRITE(numout,*) '     free surface with time splitting scheme'
235      ENDIF
236      !
237      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_init')
238      !
239   END SUBROUTINE dyn_spg_init
240
241  !!======================================================================
242END MODULE dynspg
Note: See TracBrowser for help on using the repository browser.