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 NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/DYN – NEMO

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/DYN/dynspg.F90 @ 12205

Last change on this file since 12205 was 12205, checked in by acc, 4 years ago

2019/dev_r11943_MERGE_2019: Merge in dev_r11879_ENHANCE-05_SimonM-Harmonic_Analysis. SETTE tested

  • Property svn:keywords set to Id
File size: 12.7 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 sbc_ice , ONLY : snwice_mass, snwice_mass_b
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 tide_mod       !
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 timing         ! Timing
31
32   IMPLICIT NONE
33   PRIVATE
34
35   PUBLIC   dyn_spg        ! routine called by step module
36   PUBLIC   dyn_spg_init   ! routine called by opa module
37
38   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_...
39
40   !                       ! Parameter to control the surface pressure gradient scheme
41   INTEGER, PARAMETER ::   np_TS  = 1   ! split-explicit time stepping (Time-Splitting)
42   INTEGER, PARAMETER ::   np_EXP = 0   !       explicit time stepping
43   INTEGER, PARAMETER ::   np_NO  =-1   ! no surface pressure gradient, no scheme
44   !
45   REAL(wp) ::   zt0step !   Time of day at the beginning of the time step
46
47   !! * Substitutions
48#  include "vectopt_loop_substitute.h90"
49   !!----------------------------------------------------------------------
50   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
51   !! $Id$
52   !! Software governed by the CeCILL license (see ./LICENSE)
53   !!----------------------------------------------------------------------
54CONTAINS
55
56   SUBROUTINE dyn_spg( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa )
57      !!----------------------------------------------------------------------
58      !!                  ***  ROUTINE dyn_spg  ***
59      !!
60      !! ** Purpose :   compute surface pressure gradient including the
61      !!              atmospheric pressure forcing (ln_apr_dyn=T).
62      !!
63      !! ** Method  :   Two schemes:
64      !!              - explicit       : the spg is evaluated at now
65      !!              - split-explicit : a time splitting technique is used
66      !!
67      !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied
68      !!             as the gradient of the inverse barometer ssh:
69      !!                apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb]
70      !!                apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb]
71      !!             Note that as all external forcing a time averaging over a two rdt
72      !!             period is used to prevent the divergence of odd and even time step.
73      !!----------------------------------------------------------------------
74      INTEGER                             , INTENT( in )  ::  kt                  ! ocean time-step index
75      INTEGER                             , INTENT( in )  ::  Kbb, Kmm, Krhs, Kaa ! ocean time level indices
76      REAL(wp), DIMENSION(jpi,jpj,jpk,jpt), INTENT(inout) ::  puu, pvv            ! ocean velocities and RHS of momentum equation
77      REAL(wp), DIMENSION(jpi,jpj,jpt)    , INTENT(inout) ::  pssh, puu_b, pvv_b  ! SSH and barotropic velocities at main time levels
78      !
79      INTEGER  ::   ji, jj, jk                   ! dummy loop indices
80      REAL(wp) ::   z2dt, zg_2, zintp, zgrau0r, zld   ! local scalars
81      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   zpice
82      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrdu, ztrdv
83      !!----------------------------------------------------------------------
84      !
85      IF( ln_timing )   CALL timing_start('dyn_spg')
86      !
87      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
88         ALLOCATE( ztrdu(jpi,jpj,jpk) , ztrdv(jpi,jpj,jpk) ) 
89         ztrdu(:,:,:) = puu(:,:,:,Krhs)
90         ztrdv(:,:,:) = pvv(:,:,:,Krhs)
91      ENDIF
92      !
93      IF(      ln_apr_dyn                                                &   ! atmos. pressure
94         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. ln_tide) )   &   ! tide potential (no time slitting)
95         .OR.  ln_ice_embd ) THEN                                            ! embedded sea-ice
96         !
97         DO jj = 2, jpjm1
98            DO ji = fs_2, fs_jpim1   ! vector opt.
99               spgu(ji,jj) = 0._wp
100               spgv(ji,jj) = 0._wp
101            END DO
102         END DO         
103         !
104         IF( ln_apr_dyn .AND. .NOT.ln_dynspg_ts ) THEN   !==  Atmospheric pressure gradient (added later in time-split case) ==!
105            zg_2 = grav * 0.5
106            DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
107               DO ji = fs_2, fs_jpim1   ! vector opt.
108                  spgu(ji,jj) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
109                     &                                + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
110                  spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
111                     &                                + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
112               END DO
113            END DO
114         ENDIF
115         !
116         !                                    !==  tide potential forcing term  ==!
117         IF( .NOT.ln_dynspg_ts .AND. ( ln_tide_pot .AND. ln_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
118            !
119            ! Update tide potential at the beginning of current time step
120            zt0step = REAL(nsec_day, wp)-0.5_wp*rdt
121            CALL upd_tide(zt0step, Kmm)
122            !
123            DO jj = 2, jpjm1                         ! add tide potential forcing
124               DO ji = fs_2, fs_jpim1   ! vector opt.
125                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
126                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
127               END DO
128            END DO
129            !
130            IF (ln_scal_load) THEN
131               zld = rn_scal_load * grav
132               DO jj = 2, jpjm1                    ! add scalar approximation for load potential
133                  DO ji = fs_2, fs_jpim1   ! vector opt.
134                     spgu(ji,jj) = spgu(ji,jj) + zld * ( pssh(ji+1,jj,Kmm) - pssh(ji,jj,Kmm) ) * r1_e1u(ji,jj)
135                     spgv(ji,jj) = spgv(ji,jj) + zld * ( pssh(ji,jj+1,Kmm) - pssh(ji,jj,Kmm) ) * r1_e2v(ji,jj)
136                  END DO
137               END DO
138            ENDIF
139         ENDIF
140         !
141         IF( ln_ice_embd ) THEN              !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
142            ALLOCATE( zpice(jpi,jpj) )
143            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
144            zgrau0r     = - grav * r1_rau0
145            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
146            DO jj = 2, jpjm1
147               DO ji = fs_2, fs_jpim1   ! vector opt.
148                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
149                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
150               END DO
151            END DO
152            DEALLOCATE( zpice )         
153         ENDIF
154         !
155         DO jk = 1, jpkm1                    !== Add all terms to the general trend
156            DO jj = 2, jpjm1
157               DO ji = fs_2, fs_jpim1   ! vector opt.
158                  puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) + spgu(ji,jj)
159                  pvv(ji,jj,jk,Krhs) = pvv(ji,jj,jk,Krhs) + spgv(ji,jj)
160               END DO
161            END DO
162         END DO   
163         !
164!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
165         !   
166      ENDIF
167      !
168      SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
169      CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt,      Kmm,       puu, pvv, Krhs )                    ! explicit
170      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa ) ! time-splitting
171      END SELECT
172      !                   
173      IF( l_trddyn )   THEN                  ! save the surface pressure gradient trends for further diagnostics
174         ztrdu(:,:,:) = puu(:,:,:,Krhs) - ztrdu(:,:,:)
175         ztrdv(:,:,:) = pvv(:,:,:,Krhs) - ztrdv(:,:,:)
176         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt, Kmm )
177         DEALLOCATE( ztrdu , ztrdv ) 
178      ENDIF
179      !                                      ! print mean trends (used for debugging)
180      IF(ln_ctl)   CALL prt_ctl( tab3d_1=puu(:,:,:,Krhs), clinfo1=' spg  - Ua: ', mask1=umask, &
181         &                       tab3d_2=pvv(:,:,:,Krhs), clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
182      !
183      IF( ln_timing )   CALL timing_stop('dyn_spg')
184      !
185   END SUBROUTINE dyn_spg
186
187
188   SUBROUTINE dyn_spg_init
189      !!---------------------------------------------------------------------
190      !!                  ***  ROUTINE dyn_spg_init  ***
191      !!               
192      !! ** Purpose :   Control the consistency between namelist options for
193      !!              surface pressure gradient schemes
194      !!----------------------------------------------------------------------
195      INTEGER ::   ioptio, ios   ! local integers
196      !
197      NAMELIST/namdyn_spg/ ln_dynspg_exp       , ln_dynspg_ts,   &
198      &                    ln_bt_fw, ln_bt_av  , ln_bt_auto  ,   &
199      &                    nn_baro , rn_bt_cmax, nn_bt_flt, rn_bt_alpha
200      !!----------------------------------------------------------------------
201      !
202      IF(lwp) THEN
203         WRITE(numout,*)
204         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
205         WRITE(numout,*) '~~~~~~~~~~~~'
206      ENDIF
207      !
208      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
209901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist' )
210      !
211      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
212902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist' )
213      IF(lwm) WRITE ( numond, namdyn_spg )
214      !
215      IF(lwp) THEN             ! Namelist print
216         WRITE(numout,*) '   Namelist : namdyn_spg                    '
217         WRITE(numout,*) '      Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
218         WRITE(numout,*) '      Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
219      ENDIF
220      !                          ! Control of surface pressure gradient scheme options
221                                     nspg =  np_NO    ;   ioptio = 0
222      IF( ln_dynspg_exp ) THEN   ;   nspg =  np_EXP   ;   ioptio = ioptio + 1   ;   ENDIF
223      IF( ln_dynspg_ts  ) THEN   ;   nspg =  np_TS    ;   ioptio = ioptio + 1   ;   ENDIF
224      !
225      IF( ioptio  > 1 )   CALL ctl_stop( 'Choose only one surface pressure gradient scheme' )
226      IF( ioptio == 0 )   CALL ctl_warn( 'NO surface pressure gradient trend in momentum Eqs.' )
227      IF( ln_dynspg_exp .AND. ln_isfcav )   &
228           &   CALL ctl_stop( ' dynspg_exp not tested with ice shelf cavity ' )
229      !
230      IF(lwp) THEN
231         WRITE(numout,*)
232         IF( nspg == np_EXP )   WRITE(numout,*) '   ==>>>   explicit free surface'
233         IF( nspg == np_TS  )   WRITE(numout,*) '   ==>>>   free surface with time splitting scheme'
234         IF( nspg == np_NO  )   WRITE(numout,*) '   ==>>>   No surface surface pressure gradient trend in momentum Eqs.'
235      ENDIF
236      !
237      IF( nspg == np_TS ) THEN   ! split-explicit scheme initialisation
238         CALL dyn_spg_ts_init          ! do it first: set nn_baro used to allocate some arrays later on
239      ENDIF
240      !
241   END SUBROUTINE dyn_spg_init
242
243  !!======================================================================
244END MODULE dynspg
Note: See TracBrowser for help on using the repository browser.