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 @ 5868

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

Free surface simplification #1620. Step 1: suppress filtered free surface

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