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

source: branches/2014/dev_r4621_NOC4_BDY_VERT_INTERP/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90 @ 6079

Last change on this file since 6079 was 6079, checked in by jamesharle, 8 years ago

merge to trunk@5936

  • Property svn:keywords set to Id
File size: 12.1 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   !!            3.7  ! 2015-11  (J. Chanut) Suppression of filtered free surface
9   !!----------------------------------------------------------------------
10
11   !!----------------------------------------------------------------------
12   !!   dyn_spg     : update the dynamics trend with surface pressure gradient
13   !!   dyn_spg_init: initialization, namelist read, and parameters control
14   !!----------------------------------------------------------------------
15   USE oce            ! ocean dynamics and tracers variables
16   USE dom_oce        ! ocean space and time domain variables
17   USE c1d            ! 1D vertical configuration
18   USE phycst         ! physical constants
19   USE sbc_oce        ! surface boundary condition: ocean
20   USE sbcapr         ! surface boundary condition: atmospheric pressure
21   USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
22   USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
23   USE sbctide
24   USE updtide
25   USE trd_oce        ! trends: ocean variables
26   USE trddyn         ! trend manager: dynamics
27   !
28   USE prtctl         ! Print control                     (prt_ctl routine)
29   USE in_out_manager ! I/O manager
30   USE lib_mpp        ! MPP library
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 ln_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 )
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  :   Two schemes:
65      !!              - explicit computation      : the spg is evaluated at now
66      !!              - split-explicit computation: a time splitting technique is used
67      !!
68      !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied
69      !!             as the gradient of the inverse barometer ssh:
70      !!                apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb]
71      !!                apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb]
72      !!             Note that as all external forcing a time averaging over a two rdt
73      !!             period is used to prevent the divergence of odd and even time step.
74      !!----------------------------------------------------------------------
75      !
76      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
77      !
78      INTEGER  ::   ji, jj, jk                             ! dummy loop indices
79      REAL(wp) ::   z2dt, zg_2, zintp, zgrau0r             ! temporary scalar
80      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
81      REAL(wp), POINTER, DIMENSION(:,:)   ::  zpice
82      !!----------------------------------------------------------------------
83      !
84      IF( nn_timing == 1 )  CALL timing_start('dyn_spg')
85      !
86
87!!gm NOTA BENE : the dynspg_exp and dynspg_ts should be modified so that
88!!gm             they return the after velocity, not the trends (as in trazdf_imp...)
89!!gm             In this case, change/simplify dynnxt
90
91
92      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
93         CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
94         ztrdu(:,:,:) = ua(:,:,:)
95         ztrdv(:,:,:) = va(:,:,:)
96      ENDIF
97
98      IF(      ln_apr_dyn                                                &   ! atmos. pressure
99         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. lk_tide) )   &   ! tide potential (no time slitting)
100         .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
101         !
102         DO jj = 2, jpjm1
103            DO ji = fs_2, fs_jpim1   ! vector opt.
104               spgu(ji,jj) = 0._wp
105               spgv(ji,jj) = 0._wp
106            END DO
107         END DO         
108         !
109         IF( ln_apr_dyn .AND. (.NOT. ln_dynspg_ts) ) THEN                    !==  Atmospheric pressure gradient (added later in time-split case) ==!
110            zg_2 = grav * 0.5
111            DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
112               DO ji = fs_2, fs_jpim1   ! vector opt.
113                  spgu(ji,jj) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
114                     &                      + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
115                  spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
116                     &                      + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
117               END DO
118            END DO
119         ENDIF
120         !
121         !                                    !==  tide potential forcing term  ==!
122         IF( .NOT.ln_dynspg_ts .AND. ( ln_tide_pot .AND. lk_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
123            !
124            CALL upd_tide( kt )                      ! update tide potential
125            !
126            DO jj = 2, jpjm1                         ! add tide potential forcing
127               DO ji = fs_2, fs_jpim1   ! vector opt.
128                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
129                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
130               END DO
131            END DO
132         ENDIF
133         !
134         IF( nn_ice_embd == 2 ) THEN          !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
135            CALL wrk_alloc( jpi, jpj, zpice )
136            !                                           
137            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
138            zgrau0r     = - grav * r1_rau0
139            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
140            DO jj = 2, jpjm1
141               DO ji = fs_2, fs_jpim1   ! vector opt.
142                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
143                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
144               END DO
145            END DO
146            !
147            CALL wrk_dealloc( jpi, jpj, zpice )         
148         ENDIF
149         !
150         DO jk = 1, jpkm1                     !== Add all terms to the general trend
151            DO jj = 2, jpjm1
152               DO ji = fs_2, fs_jpim1   ! vector opt.
153                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
154                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
155               END DO
156            END DO
157         END DO   
158         
159!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
160             
161      ENDIF
162
163      SELECT CASE ( nspg )                       ! compute surf. pressure gradient trend and add it to the general trend
164      !                                                     
165      CASE (  0 )   ;   CALL dyn_spg_exp( kt )              ! explicit
166      CASE (  1 )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
167      !                                                   
168      END SELECT
169      !                   
170      IF( l_trddyn )   THEN                      ! save the surface pressure gradient trends for further diagnostics
171         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
172         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
173         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
174         !
175         CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
176      ENDIF
177      !                                          ! print mean trends (used for debugging)
178      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
179         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
180      !
181      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg')
182      !
183   END SUBROUTINE dyn_spg
184
185
186   SUBROUTINE dyn_spg_init
187      !!---------------------------------------------------------------------
188      !!                  ***  ROUTINE dyn_spg_init  ***
189      !!               
190      !! ** Purpose :   Control the consistency between namelist options for
191      !!              surface pressure gradient schemes
192      !!----------------------------------------------------------------------
193      INTEGER ::   ioptio, ios
194      !
195      NAMELIST/namdyn_spg/ ln_dynspg_exp, ln_dynspg_ts, &
196      &                    ln_bt_fw, ln_bt_av, ln_bt_auto, &
197      &                    nn_baro, rn_bt_cmax, nn_bt_flt
198      !!----------------------------------------------------------------------
199      !
200      IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
201      !
202      REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
203      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
204901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
205
206      REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
207      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
208902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
209      IF(lwm) WRITE ( numond, namdyn_spg )
210      !
211      IF(lwp) THEN             ! Namelist print
212         WRITE(numout,*)
213         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
214         WRITE(numout,*) '~~~~~~~~~~~'
215         WRITE(numout,*) '     Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
216         WRITE(numout,*) '     Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
217      ENDIF
218
219      IF( ln_dynspg_ts ) THEN
220         CALL dyn_spg_ts_init( nit000  ) ! do it first, to set nn_baro, used to allocate some arrays later on
221         !                               ! allocate dyn_spg arrays
222         IF( dyn_spg_ts_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays')
223         IF ((neuler/=0).AND.(ln_bt_fw)) CALL ts_rst( nit000, 'READ' )
224      ENDIF
225
226      !                        ! Control of surface pressure gradient scheme options
227      ioptio = 0
228      IF(ln_dynspg_exp)   ioptio = ioptio + 1
229      IF(ln_dynspg_ts )   ioptio = ioptio + 1
230      !
231      IF(  ioptio > 1  .OR. ( ioptio == 0 .AND. .NOT. lk_c1d ) )   &
232           &   CALL ctl_stop( ' Choose only one surface pressure gradient scheme' )
233      IF( ln_dynspg_ts .AND. ln_isfcav )   &
234           &   CALL ctl_stop( ' dynspg_ts not tested with ice shelf cavity ' )
235      !
236      IF( ln_dynspg_exp)   nspg =  0
237      IF( ln_dynspg_ts )   nspg =  1
238      !
239      IF(lwp) THEN
240         WRITE(numout,*)
241         IF( nspg ==  0 )   WRITE(numout,*) '     explicit free surface'
242         IF( nspg ==  1 )   WRITE(numout,*) '     free surface with time splitting scheme'
243      ENDIF
244      !
245      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_init')
246      !
247   END SUBROUTINE dyn_spg_init
248
249  !!======================================================================
250END MODULE dynspg
Note: See TracBrowser for help on using the repository browser.