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

source: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90 @ 2398

Last change on this file since 2398 was 2398, checked in by rblod, 13 years ago

Correct compilation error for dynspg

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