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

source: branches/2013/dev_r3987_UKMO6_C1D/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90 @ 4144

Last change on this file since 4144 was 4144, checked in by rfurner, 10 years ago

Commit for 2013 changes; see #1085

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