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

source: branches/UKMO/r8395_India_uncoupled/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90 @ 11080

Last change on this file since 11080 was 11080, checked in by jcastill, 5 years ago

Latest changes from Jason

File size: 12.4 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 surface pressure gradient
12   !!   dyn_spg_init: 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_exp     ! surface pressure gradient     (dyn_spg_exp routine)
21   USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
22   USE sbctide        !
23   USE updtide        !
24   USE trd_oce        ! trends: ocean variables
25   USE trddyn         ! trend manager: dynamics
26   !
27   USE prtctl         ! Print control                     (prt_ctl routine)
28   USE in_out_manager ! I/O manager
29   USE lib_mpp        ! MPP library
30   USE wrk_nemo       ! Memory Allocation
31   USE timing         ! Timing
32
33   IMPLICIT NONE
34   PRIVATE
35
36   PUBLIC   dyn_spg        ! routine called by step module
37   PUBLIC   dyn_spg_init   ! routine called by opa module
38
39   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_...
40
41   LOGICAL, PUBLIC ::  ln_ulimit
42   REAL(wp), PUBLIC :: cn_ulimit,cnn_ulimit
43
44   !                       ! Parameter to control the surface pressure gradient scheme
45   INTEGER, PARAMETER ::   np_TS  = 1   ! split-explicit time stepping (Time-Splitting)
46   INTEGER, PARAMETER ::   np_EXP = 0   !       explicit time stepping
47   INTEGER, PARAMETER ::   np_NO  =-1   ! no surface pressure gradient, no scheme
48
49   !! * Substitutions
50#  include "vectopt_loop_substitute.h90"
51   !!----------------------------------------------------------------------
52   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
53   !! $Id$
54   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
55   !!----------------------------------------------------------------------
56CONTAINS
57
58   SUBROUTINE dyn_spg( kt )
59      !!----------------------------------------------------------------------
60      !!                  ***  ROUTINE dyn_spg  ***
61      !!
62      !! ** Purpose :   compute surface pressure gradient including the
63      !!              atmospheric pressure forcing (ln_apr_dyn=T).
64      !!
65      !! ** Method  :   Two schemes:
66      !!              - explicit       : the spg is evaluated at now
67      !!              - split-explicit : 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      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      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
87         CALL wrk_alloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
88         ztrdu(:,:,:) = ua(:,:,:)
89         ztrdv(:,:,:) = va(:,:,:)
90      ENDIF
91      !
92      IF(      ln_apr_dyn                                                &   ! atmos. pressure
93         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. ln_tide) )   &   ! tide potential (no time slitting)
94         .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
95         !
96         DO jj = 2, jpjm1
97            DO ji = fs_2, fs_jpim1   ! vector opt.
98               spgu(ji,jj) = 0._wp
99               spgv(ji,jj) = 0._wp
100            END DO
101         END DO         
102         !
103         IF( ln_apr_dyn .AND. .NOT.ln_dynspg_ts ) THEN   !==  Atmospheric pressure gradient (added later in time-split case) ==!
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) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
108                     &                      + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
109                  spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
110                     &                      + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
111               END DO
112            END DO
113         ENDIF
114         !
115         !                                    !==  tide potential forcing term  ==!
116         IF( .NOT.ln_dynspg_ts .AND. ( ln_tide_pot .AND. ln_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
117            !
118            CALL upd_tide( kt )                      ! update tide potential
119            !
120            DO jj = 2, jpjm1                         ! add tide potential forcing
121               DO ji = fs_2, fs_jpim1   ! vector opt.
122                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
123                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
124               END DO
125            END DO
126         ENDIF
127         !
128         IF( nn_ice_embd == 2 ) THEN          !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
129            CALL wrk_alloc( jpi,jpj,   zpice )
130            !                                           
131            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
132            zgrau0r     = - grav * r1_rau0
133            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
134            DO jj = 2, jpjm1
135               DO ji = fs_2, fs_jpim1   ! vector opt.
136                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
137                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
138               END DO
139            END DO
140            !
141            CALL wrk_dealloc( jpi,jpj,   zpice )         
142         ENDIF
143         !
144         DO jk = 1, jpkm1                    !== Add all terms to the general trend
145            DO jj = 2, jpjm1
146               DO ji = fs_2, fs_jpim1   ! vector opt.
147                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
148                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
149               END DO
150            END DO
151         END DO   
152         !
153!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
154         !   
155      ENDIF
156      !
157      SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
158      CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt )              ! explicit
159      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
160      END SELECT
161      !                   
162      IF( l_trddyn )   THEN                  ! save the surface pressure gradient trends for further diagnostics
163         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
164         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
165         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
166         CALL wrk_dealloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
167      ENDIF
168      !                                      ! print mean trends (used for debugging)
169      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
170         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
171      !
172      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg')
173      !
174   END SUBROUTINE dyn_spg
175
176
177   SUBROUTINE dyn_spg_init
178      !!---------------------------------------------------------------------
179      !!                  ***  ROUTINE dyn_spg_init  ***
180      !!               
181      !! ** Purpose :   Control the consistency between namelist options for
182      !!              surface pressure gradient schemes
183      !!----------------------------------------------------------------------
184      INTEGER ::   ioptio, ios   ! local integers
185      !
186      NAMELIST/namdyn_spg/ ln_dynspg_exp       , ln_dynspg_ts,   &
187      &                    ln_bt_fw, ln_bt_av  , ln_bt_auto  ,   &
188      &                    nn_baro , rn_bt_cmax, nn_bt_flt   ,   &
189                           ln_ulimit, cn_ulimit, cnn_ulimit
190      !!----------------------------------------------------------------------
191      !
192      IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
193      !
194      REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
195      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
196901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
197      !
198      REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
199      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
200902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
201      IF(lwm) WRITE ( numond, namdyn_spg )
202      !
203      IF(lwp) THEN             ! Namelist print
204         WRITE(numout,*)
205         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
206         WRITE(numout,*) '~~~~~~~~~~~'
207         WRITE(numout,*) '     Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
208         WRITE(numout,*) '     Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
209         WRITE(numout,*) '     Limit velocities                       ln_ulimit     = ', ln_ulimit
210         WRITE(numout,*) '     Limit velocities      max inverse Courant number     = ', cn_ulimit
211         WRITE(numout,*) '     Limit velocities   multiplier for divergant flow     = ', cnn_ulimit
212      ENDIF
213      !                          ! Control of surface pressure gradient scheme options
214                                     nspg =  np_NO    ;   ioptio = 0
215      IF( ln_dynspg_exp ) THEN   ;   nspg =  np_EXP   ;   ioptio = ioptio + 1   ;   ENDIF
216      IF( ln_dynspg_ts  ) THEN   ;   nspg =  np_TS    ;   ioptio = ioptio + 1   ;   ENDIF
217      !
218      IF( ioptio  > 1 )   CALL ctl_stop( 'Choose only one surface pressure gradient scheme' )
219      IF( ioptio == 0 )   CALL ctl_warn( 'NO surface pressure gradient trend in momentum Eqs.' )
220      IF( ln_dynspg_exp .AND. ln_isfcav )   &
221           &   CALL ctl_stop( ' dynspg_exp not tested with ice shelf cavity ' )
222      !
223      IF(lwp) THEN
224         WRITE(numout,*)
225         IF( nspg == np_EXP )   WRITE(numout,*) '      ===>>   explicit free surface'
226         IF( nspg == np_TS  )   WRITE(numout,*) '      ===>>   free surface with time splitting scheme'
227         IF( nspg == np_NO  )   WRITE(numout,*) '      ===>>   No surface surface pressure gradient trend in momentum Eqs.'
228      ENDIF
229      !
230      IF( nspg == np_TS ) THEN   ! split-explicit scheme initialisation
231         CALL dyn_spg_ts_init          ! do it first: set nn_baro used to allocate some arrays later on
232         IF( dyn_spg_ts_alloc() /= 0  )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays' )
233         IF( neuler/=0 .AND. ln_bt_fw )   CALL ts_rst( nit000, 'READ' )
234      ENDIF
235      !
236      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_init')
237      !
238   END SUBROUTINE dyn_spg_init
239
240  !!======================================================================
241END MODULE dynspg
Note: See TracBrowser for help on using the repository browser.