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

source: branches/2016/dev_r6519_HPC_4/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90 @ 6748

Last change on this file since 6748 was 6748, checked in by mocavero, 8 years ago

GYRE hybrid parallelization

  • Property svn:keywords set to Id
File size: 12.3 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   !                       ! Parameter to control the surface pressure gradient scheme
42   INTEGER, PARAMETER ::   np_TS  = 1   ! split-explicit time stepping (Time-Splitting)
43   INTEGER, PARAMETER ::   np_EXP = 0   !       explicit time stepping
44   INTEGER, PARAMETER ::   np_NO  =-1   ! no surface pressure gradient, no scheme
45
46   !! * Substitutions
47#  include "vectopt_loop_substitute.h90"
48   !!----------------------------------------------------------------------
49   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
50   !! $Id$
51   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
52   !!----------------------------------------------------------------------
53CONTAINS
54
55   SUBROUTINE dyn_spg( kt )
56      !!----------------------------------------------------------------------
57      !!                  ***  ROUTINE dyn_spg  ***
58      !!
59      !! ** Purpose :   compute surface pressure gradient including the
60      !!              atmospheric pressure forcing (ln_apr_dyn=T).
61      !!
62      !! ** Method  :   Two schemes:
63      !!              - explicit       : the spg is evaluated at now
64      !!              - split-explicit : a time splitting technique is used
65      !!
66      !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied
67      !!             as the gradient of the inverse barometer ssh:
68      !!                apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb]
69      !!                apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb]
70      !!             Note that as all external forcing a time averaging over a two rdt
71      !!             period is used to prevent the divergence of odd and even time step.
72      !!----------------------------------------------------------------------
73      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
74      !
75      INTEGER  ::   ji, jj, jk                             ! dummy loop indices
76      REAL(wp) ::   z2dt, zg_2, zintp, zgrau0r             ! temporary scalar
77      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
78      REAL(wp), POINTER, DIMENSION(:,:)   ::  zpice
79      !!----------------------------------------------------------------------
80      !
81      IF( nn_timing == 1 )  CALL timing_start('dyn_spg')
82      !
83      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
84         CALL wrk_alloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
85!$OMP PARALLEL WORKSHARE
86         ztrdu(:,:,:) = ua(:,:,:)
87         ztrdv(:,:,:) = va(:,:,:)
88!$OMP END PARALLEL WORKSHARE
89      ENDIF
90      !
91      IF(      ln_apr_dyn                                                &   ! atmos. pressure
92         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. lk_tide) )   &   ! tide potential (no time slitting)
93         .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
94         !
95!$OMP PARALLEL DO schedule(static) private(jj, ji)
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!$OMP PARALLEL DO schedule(static) private(jj, ji)
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. lk_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
118            !
119            CALL upd_tide( kt )                      ! update tide potential
120            !
121!$OMP PARALLEL DO schedule(static) private(jj, ji)
122            DO jj = 2, jpjm1                         ! add tide potential forcing
123               DO ji = fs_2, fs_jpim1   ! vector opt.
124                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
125                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
126               END DO
127            END DO
128         ENDIF
129         !
130         IF( nn_ice_embd == 2 ) THEN          !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
131            CALL wrk_alloc( jpi,jpj,   zpice )
132            !                                           
133            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
134            zgrau0r     = - grav * r1_rau0
135            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
136!$OMP PARALLEL DO schedule(static) private(jj, ji)
137            DO jj = 2, jpjm1
138               DO ji = fs_2, fs_jpim1   ! vector opt.
139                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
140                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
141               END DO
142            END DO
143            !
144            CALL wrk_dealloc( jpi,jpj,   zpice )         
145         ENDIF
146         !
147!$OMP PARALLEL DO schedule(static) private(jk, jj, ji)
148         DO jk = 1, jpkm1                    !== Add all terms to the general trend
149            DO jj = 2, jpjm1
150               DO ji = fs_2, fs_jpim1   ! vector opt.
151                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
152                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
153               END DO
154            END DO
155         END DO   
156         !
157!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
158         !   
159      ENDIF
160      !
161      SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
162      CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt )              ! explicit
163      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
164      END SELECT
165      !                   
166      IF( l_trddyn )   THEN                  ! save the surface pressure gradient trends for further diagnostics
167!$OMP PARALLEL WORKSHARE
168         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
169         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
170!$OMP END PARALLEL WORKSHARE
171         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
172         CALL wrk_dealloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
173      ENDIF
174      !                                      ! print mean trends (used for debugging)
175      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
176         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
177      !
178      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg')
179      !
180   END SUBROUTINE dyn_spg
181
182
183   SUBROUTINE dyn_spg_init
184      !!---------------------------------------------------------------------
185      !!                  ***  ROUTINE dyn_spg_init  ***
186      !!               
187      !! ** Purpose :   Control the consistency between namelist options for
188      !!              surface pressure gradient schemes
189      !!----------------------------------------------------------------------
190      INTEGER ::   ioptio, ios   ! local integers
191      !
192      NAMELIST/namdyn_spg/ ln_dynspg_exp       , ln_dynspg_ts,   &
193      &                    ln_bt_fw, ln_bt_av  , ln_bt_auto  ,   &
194      &                    nn_baro , rn_bt_cmax, nn_bt_flt
195      !!----------------------------------------------------------------------
196      !
197      IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
198      !
199      REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
200      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
201901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
202      !
203      REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
204      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
205902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
206      IF(lwm) WRITE ( numond, namdyn_spg )
207      !
208      IF(lwp) THEN             ! Namelist print
209         WRITE(numout,*)
210         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
211         WRITE(numout,*) '~~~~~~~~~~~'
212         WRITE(numout,*) '     Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
213         WRITE(numout,*) '     Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
214      ENDIF
215      !                          ! Control of surface pressure gradient scheme options
216      ;                              nspg =  np_NO    ;   ioptio = 0
217      IF( ln_dynspg_exp ) THEN   ;   nspg =  np_EXP   ;   ioptio = ioptio + 1   ;   ENDIF
218      IF( ln_dynspg_ts  ) THEN   ;   nspg =  np_TS    ;   ioptio = ioptio + 1   ;   ENDIF
219      !
220      IF( ioptio  > 1 )   CALL ctl_stop( 'Choose only one surface pressure gradient scheme' )
221      IF( ioptio == 0 )   CALL ctl_warn( 'NO surface pressure gradient trend in momentum Eqs.' )
222      IF( ln_dynspg_exp .AND. ln_isfcav )   &
223           &   CALL ctl_stop( ' dynspg_exp not tested with ice shelf cavity ' )
224      !
225      IF(lwp) THEN
226         WRITE(numout,*)
227         IF( nspg == np_EXP )   WRITE(numout,*) '     explicit free surface'
228         IF( nspg == np_TS  )   WRITE(numout,*) '     free surface with time splitting scheme'
229         IF( nspg == np_NO  )   WRITE(numout,*) '     No surface surface pressure gradient trend in momentum Eqs.'
230      ENDIF
231      !
232      IF( nspg == np_TS ) THEN   ! split-explicit scheme initialisation
233         CALL dyn_spg_ts_init          ! do it first: set nn_baro used to allocate some arrays later on
234         IF( dyn_spg_ts_alloc() /= 0  )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays' )
235         IF( neuler/=0 .AND. ln_bt_fw )   CALL ts_rst( nit000, 'READ' )
236      ENDIF
237      !
238      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_init')
239      !
240   END SUBROUTINE dyn_spg_init
241
242  !!======================================================================
243END MODULE dynspg
Note: See TracBrowser for help on using the repository browser.