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/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN – NEMO

source: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynspg.F90 @ 14644

Last change on this file since 14644 was 14644, checked in by sparonuz, 3 years ago

Merge trunk -r14642:HEAD

  • Property svn:keywords set to Id
File size: 13.1 KB
RevLine 
[358]1MODULE dynspg
2   !!======================================================================
3   !!                       ***  MODULE  dynspg  ***
4   !! Ocean dynamics:  surface pressure gradient control
5   !!======================================================================
[1566]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
[14007]8   !!            4.2  ! 2020-12  (G. Madec, E. Clementi) add Bernoulli Head for
9   !!                            wave coupling
[503]10   !!----------------------------------------------------------------------
[358]11
12   !!----------------------------------------------------------------------
[14072]13   !!   dyn_spg     : update the dynamics trend with surface pressure gradient
[5930]14   !!   dyn_spg_init: initialization, namelist read, and parameters control
[358]15   !!----------------------------------------------------------------------
16   USE oce            ! ocean dynamics and tracers variables
17   USE dom_oce        ! ocean space and time domain variables
[4245]18   USE c1d            ! 1D vertical configuration
[2715]19   USE phycst         ! physical constants
[2528]20   USE sbc_oce        ! surface boundary condition: ocean
[9019]21   USE sbc_ice , ONLY : snwice_mass, snwice_mass_b
[2528]22   USE sbcapr         ! surface boundary condition: atmospheric pressure
[14007]23   USE sbcwave,  ONLY : bhd_wave
[358]24   USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
25   USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
[12377]26   USE tide_mod       !
[4990]27   USE trd_oce        ! trends: ocean variables
28   USE trddyn         ! trend manager: dynamics
29   !
[358]30   USE prtctl         ! Print control                     (prt_ctl routine)
31   USE in_out_manager ! I/O manager
[2715]32   USE lib_mpp        ! MPP library
[4990]33   USE timing         ! Timing
[358]34
35   IMPLICIT NONE
36   PRIVATE
37
[2528]38   PUBLIC   dyn_spg        ! routine called by step module
39   PUBLIC   dyn_spg_init   ! routine called by opa module
[358]40
[14072]41   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_...
[358]42
[6140]43   !                       ! Parameter to control the surface pressure gradient scheme
44   INTEGER, PARAMETER ::   np_TS  = 1   ! split-explicit time stepping (Time-Splitting)
45   INTEGER, PARAMETER ::   np_EXP = 0   !       explicit time stepping
46   INTEGER, PARAMETER ::   np_NO  =-1   ! no surface pressure gradient, no scheme
[12377]47   !
48   REAL(wp) ::   zt0step !   Time of day at the beginning of the time step
[6140]49
[358]50   !! * Substitutions
[12377]51#  include "do_loop_substitute.h90"
[14219]52#  include "single_precision_substitute.h90"
[358]53   !!----------------------------------------------------------------------
[9598]54   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
[14072]55   !! $Id$
[10068]56   !! Software governed by the CeCILL license (see ./LICENSE)
[358]57   !!----------------------------------------------------------------------
58CONTAINS
59
[14644]60   SUBROUTINE dyn_spg( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa, k_only_ADV )
[358]61      !!----------------------------------------------------------------------
62      !!                  ***  ROUTINE dyn_spg  ***
63      !!
[14072]64      !! ** Purpose :   compute surface pressure gradient including the
[6140]65      !!              atmospheric pressure forcing (ln_apr_dyn=T).
[1566]66      !!
[5930]67      !! ** Method  :   Two schemes:
[6140]68      !!              - explicit       : the spg is evaluated at now
69      !!              - split-explicit : a time splitting technique is used
[1566]70      !!
[14072]71      !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied
[2528]72      !!             as the gradient of the inverse barometer ssh:
[12489]73      !!                apgu = - 1/rho0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb]
74      !!                apgv = - 1/rho0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb]
75      !!             Note that as all external forcing a time averaging over a two rn_Dt
[2528]76      !!             period is used to prevent the divergence of odd and even time step.
[358]77      !!----------------------------------------------------------------------
[12377]78      INTEGER                             , INTENT( in )  ::  kt                  ! ocean time-step index
79      INTEGER                             , INTENT( in )  ::  Kbb, Kmm, Krhs, Kaa ! ocean time level indices
[14219]80      REAL(dp), DIMENSION(jpi,jpj,jpk,jpt), INTENT(inout) ::  puu, pvv            ! ocean velocities and RHS of momentum equation
81      REAL(dp), DIMENSION(jpi,jpj,jpt)    , INTENT(inout) :: pssh                 ! SSH
82      REAL(wp), DIMENSION(jpi,jpj,jpt)    , INTENT(inout) :: puu_b, pvv_b         !barotropic velocities at main time levels
[14644]83      INTEGER , OPTIONAL                  , INTENT( in )  ::  k_only_ADV          ! only Advection in the RHS
[2715]84      !
[9019]85      INTEGER  ::   ji, jj, jk                   ! dummy loop indices
[12489]86      REAL(wp) ::   z2dt, zg_2, zintp, zgrho0r, zld   ! local scalars
[14064]87      REAL(wp)             , DIMENSION(jpi,jpj) ::   zpgu, zpgv   ! 2D workspace
88      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     ::   zpice
[14219]89      REAL(dp), ALLOCATABLE, DIMENSION(:,:,:)   ::   ztrdu, ztrdv
[358]90      !!----------------------------------------------------------------------
[3294]91      !
[9019]92      IF( ln_timing )   CALL timing_start('dyn_spg')
[3294]93      !
[358]94      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
[14072]95         ALLOCATE( ztrdu(jpi,jpj,jpk) , ztrdv(jpi,jpj,jpk) )
[12377]96         ztrdu(:,:,:) = puu(:,:,:,Krhs)
97         ztrdv(:,:,:) = pvv(:,:,:,Krhs)
[358]98      ENDIF
[6140]99      !
[4292]100      IF(      ln_apr_dyn                                                &   ! atmos. pressure
[7646]101         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. ln_tide) )   &   ! tide potential (no time slitting)
[14644]102         .OR.  ln_ice_embd                                               &   ! embedded sea-ice
103         .OR.  ( ln_wave .and. ln_bern_srfc ) ) THEN                         ! depth-independent Bernoulli head
[4292]104         !
[13295]105         DO_2D( 0, 0, 0, 0 )
[14064]106            zpgu(ji,jj) = 0._wp
107            zpgv(ji,jj) = 0._wp
[12377]108         END_2D
[4292]109         !
[6140]110         IF( ln_apr_dyn .AND. .NOT.ln_dynspg_ts ) THEN   !==  Atmospheric pressure gradient (added later in time-split case) ==!
[4292]111            zg_2 = grav * 0.5
[13497]112            DO_2D( 0, 0, 0, 0 )                       ! gradient of Patm using inverse barometer ssh
[14064]113               zpgu(ji,jj) = zpgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
[12377]114                  &                                + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
[14064]115               zpgv(ji,jj) = zpgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
[12377]116                  &                                + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
117            END_2D
[4292]118         ENDIF
119         !
120         !                                    !==  tide potential forcing term  ==!
[7646]121         IF( .NOT.ln_dynspg_ts .AND. ( ln_tide_pot .AND. ln_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
[4292]122            !
[12377]123            ! Update tide potential at the beginning of current time step
[12489]124            zt0step = REAL(nsec_day, wp)-0.5_wp*rn_Dt
[12377]125            CALL upd_tide(zt0step, Kmm)
[4292]126            !
[13497]127            DO_2D( 0, 0, 0, 0 )                      ! add tide potential forcing
[14064]128               zpgu(ji,jj) = zpgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
129               zpgv(ji,jj) = zpgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
[12377]130            END_2D
[9023]131            !
132            IF (ln_scal_load) THEN
133               zld = rn_scal_load * grav
[13497]134               DO_2D( 0, 0, 0, 0 )                   ! add scalar approximation for load potential
[14064]135                  zpgu(ji,jj) = zpgu(ji,jj) + zld * ( pssh(ji+1,jj,Kmm) - pssh(ji,jj,Kmm) ) * r1_e1u(ji,jj)
136                  zpgv(ji,jj) = zpgv(ji,jj) + zld * ( pssh(ji,jj+1,Kmm) - pssh(ji,jj,Kmm) ) * r1_e2v(ji,jj)
[12377]137               END_2D
[9023]138            ENDIF
[4292]139         ENDIF
140         !
[9019]141         IF( ln_ice_embd ) THEN              !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
142            ALLOCATE( zpice(jpi,jpj) )
[4292]143            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
[12489]144            zgrho0r     = - grav * r1_rho0
145            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrho0r
[13295]146            DO_2D( 0, 0, 0, 0 )
[14064]147               zpgu(ji,jj) = zpgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
148               zpgv(ji,jj) = zpgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
[12377]149            END_2D
[14072]150            DEALLOCATE( zpice )
[4292]151         ENDIF
152         !
[14007]153         IF( ln_wave .and. ln_bern_srfc ) THEN          !== Add J terms: depth-independent Bernoulli head
154            DO_2D( 0, 0, 0, 0 )
[14064]155               zpgu(ji,jj) = zpgu(ji,jj) + ( bhd_wave(ji+1,jj) - bhd_wave(ji,jj) ) / e1u(ji,jj)   !++ bhd_wave from wave model in m2/s2 [BHD parameters in WW3]
156               zpgv(ji,jj) = zpgv(ji,jj) + ( bhd_wave(ji,jj+1) - bhd_wave(ji,jj) ) / e2v(ji,jj)
[14007]157            END_2D
158         ENDIF
159         !
[13497]160         DO_3D( 0, 0, 0, 0, 1, jpkm1 )       !== Add all terms to the general trend
[14064]161            puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) + zpgu(ji,jj)
162            pvv(ji,jj,jk,Krhs) = pvv(ji,jj,jk,Krhs) + zpgv(ji,jj)
[12377]163         END_3D
[6140]164         !
[4990]165!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
[14072]166         !
[3625]167      ENDIF
[6140]168      !
169      SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
[12377]170      CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt,      Kmm,       puu, pvv, Krhs )                    ! explicit
[14644]171      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa, k_only_ADV ) ! time-splitting
[358]172      END SELECT
[14072]173      !
[6140]174      IF( l_trddyn )   THEN                  ! save the surface pressure gradient trends for further diagnostics
[12377]175         ztrdu(:,:,:) = puu(:,:,:,Krhs) - ztrdu(:,:,:)
176         ztrdv(:,:,:) = pvv(:,:,:,Krhs) - ztrdv(:,:,:)
177         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt, Kmm )
[14072]178         DEALLOCATE( ztrdu , ztrdv )
[358]179      ENDIF
[6140]180      !                                      ! print mean trends (used for debugging)
[14219]181      IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab3d_1=CASTWP(puu(:,:,:,Krhs)), clinfo1=' spg  - Ua: ', mask1=umask, &
182         &                                  tab3d_2=CASTWP(pvv(:,:,:,Krhs)), clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
[503]183      !
[9019]184      IF( ln_timing )   CALL timing_stop('dyn_spg')
[2715]185      !
[358]186   END SUBROUTINE dyn_spg
187
188
[2528]189   SUBROUTINE dyn_spg_init
[358]190      !!---------------------------------------------------------------------
[2528]191      !!                  ***  ROUTINE dyn_spg_init  ***
[14072]192      !!
193      !! ** Purpose :   Control the consistency between namelist options for
[1566]194      !!              surface pressure gradient schemes
[358]195      !!----------------------------------------------------------------------
[6140]196      INTEGER ::   ioptio, ios   ! local integers
[5930]197      !
[6140]198      NAMELIST/namdyn_spg/ ln_dynspg_exp       , ln_dynspg_ts,   &
199      &                    ln_bt_fw, ln_bt_av  , ln_bt_auto  ,   &
[12489]200      &                    nn_e , rn_bt_cmax, nn_bt_flt, rn_bt_alpha
[358]201      !!----------------------------------------------------------------------
[3294]202      !
[9169]203      IF(lwp) THEN
204         WRITE(numout,*)
205         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
206         WRITE(numout,*) '~~~~~~~~~~~~'
207      ENDIF
208      !
[5930]209      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
[11536]210901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist' )
[6140]211      !
[5930]212      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
[11536]213902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist' )
[5930]214      IF(lwm) WRITE ( numond, namdyn_spg )
215      !
216      IF(lwp) THEN             ! Namelist print
[9169]217         WRITE(numout,*) '   Namelist : namdyn_spg                    '
218         WRITE(numout,*) '      Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
219         WRITE(numout,*) '      Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
[358]220      ENDIF
[6140]221      !                          ! Control of surface pressure gradient scheme options
[6981]222                                     nspg =  np_NO    ;   ioptio = 0
[6140]223      IF( ln_dynspg_exp ) THEN   ;   nspg =  np_EXP   ;   ioptio = ioptio + 1   ;   ENDIF
224      IF( ln_dynspg_ts  ) THEN   ;   nspg =  np_TS    ;   ioptio = ioptio + 1   ;   ENDIF
[1566]225      !
[6140]226      IF( ioptio  > 1 )   CALL ctl_stop( 'Choose only one surface pressure gradient scheme' )
227      IF( ioptio == 0 )   CALL ctl_warn( 'NO surface pressure gradient trend in momentum Eqs.' )
228      IF( ln_dynspg_exp .AND. ln_isfcav )   &
229           &   CALL ctl_stop( ' dynspg_exp not tested with ice shelf cavity ' )
[1566]230      !
231      IF(lwp) THEN
[358]232         WRITE(numout,*)
[9190]233         IF( nspg == np_EXP )   WRITE(numout,*) '   ==>>>   explicit free surface'
234         IF( nspg == np_TS  )   WRITE(numout,*) '   ==>>>   free surface with time splitting scheme'
235         IF( nspg == np_NO  )   WRITE(numout,*) '   ==>>>   No surface surface pressure gradient trend in momentum Eqs.'
[358]236      ENDIF
[1566]237      !
[6140]238      IF( nspg == np_TS ) THEN   ! split-explicit scheme initialisation
[12489]239         CALL dyn_spg_ts_init          ! do it first: set nn_e used to allocate some arrays later on
[6140]240      ENDIF
241      !
[2528]242   END SUBROUTINE dyn_spg_init
[358]243
244  !!======================================================================
245END MODULE dynspg
Note: See TracBrowser for help on using the repository browser.