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/2017/dev_r7881_no_wrk_alloc/NEMOGCM/NEMO/OPA_SRC/DYN – NEMO

source: branches/2017/dev_r7881_no_wrk_alloc/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90 @ 7910

Last change on this file since 7910 was 7910, checked in by timgraham, 7 years ago

All wrk_alloc removed

  • Property svn:keywords set to Id
File size: 11.7 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
[503]8   !!----------------------------------------------------------------------
[358]9
10   !!----------------------------------------------------------------------
[5930]11   !!   dyn_spg     : update the dynamics trend with surface pressure gradient
12   !!   dyn_spg_init: initialization, namelist read, and parameters control
[358]13   !!----------------------------------------------------------------------
14   USE oce            ! ocean dynamics and tracers variables
15   USE dom_oce        ! ocean space and time domain variables
[4245]16   USE c1d            ! 1D vertical configuration
[2715]17   USE phycst         ! physical constants
[2528]18   USE sbc_oce        ! surface boundary condition: ocean
19   USE sbcapr         ! surface boundary condition: atmospheric pressure
[358]20   USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
21   USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
[6140]22   USE sbctide        !
23   USE updtide        !
[4990]24   USE trd_oce        ! trends: ocean variables
25   USE trddyn         ! trend manager: dynamics
26   !
[358]27   USE prtctl         ! Print control                     (prt_ctl routine)
28   USE in_out_manager ! I/O manager
[2715]29   USE lib_mpp        ! MPP library
[4990]30   USE timing         ! Timing
[358]31
32   IMPLICIT NONE
33   PRIVATE
34
[2528]35   PUBLIC   dyn_spg        ! routine called by step module
36   PUBLIC   dyn_spg_init   ! routine called by opa module
[358]37
[6140]38   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_...
[358]39
[6140]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
[358]45   !! * Substitutions
46#  include "vectopt_loop_substitute.h90"
47   !!----------------------------------------------------------------------
[1566]48   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
[1152]49   !! $Id$
[2715]50   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
[358]51   !!----------------------------------------------------------------------
52CONTAINS
53
[5930]54   SUBROUTINE dyn_spg( kt )
[358]55      !!----------------------------------------------------------------------
56      !!                  ***  ROUTINE dyn_spg  ***
57      !!
[6140]58      !! ** Purpose :   compute surface pressure gradient including the
59      !!              atmospheric pressure forcing (ln_apr_dyn=T).
[1566]60      !!
[5930]61      !! ** Method  :   Two schemes:
[6140]62      !!              - explicit       : the spg is evaluated at now
63      !!              - split-explicit : a time splitting technique is used
[1566]64      !!
[2528]65      !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied
66      !!             as the gradient of the inverse barometer ssh:
67      !!                apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb]
68      !!                apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb]
69      !!             Note that as all external forcing a time averaging over a two rdt
70      !!             period is used to prevent the divergence of odd and even time step.
[358]71      !!----------------------------------------------------------------------
[1566]72      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
[2715]73      !
[2528]74      INTEGER  ::   ji, jj, jk                             ! dummy loop indices
[3625]75      REAL(wp) ::   z2dt, zg_2, zintp, zgrau0r             ! temporary scalar
[7910]76      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  ztrdu, ztrdv
77      REAL(wp), DIMENSION(jpi,jpj)   ::  zpice
[358]78      !!----------------------------------------------------------------------
[3294]79      !
80      IF( nn_timing == 1 )  CALL timing_start('dyn_spg')
81      !
[358]82      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
[7753]83         ztrdu(:,:,:) = ua(:,:,:)
84         ztrdv(:,:,:) = va(:,:,:)
[358]85      ENDIF
[6140]86      !
[4292]87      IF(      ln_apr_dyn                                                &   ! atmos. pressure
[7646]88         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. ln_tide) )   &   ! tide potential (no time slitting)
[4292]89         .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
90         !
91         DO jj = 2, jpjm1
[2528]92            DO ji = fs_2, fs_jpim1   ! vector opt.
[4292]93               spgu(ji,jj) = 0._wp
94               spgv(ji,jj) = 0._wp
[2528]95            END DO
[4292]96         END DO         
97         !
[6140]98         IF( ln_apr_dyn .AND. .NOT.ln_dynspg_ts ) THEN   !==  Atmospheric pressure gradient (added later in time-split case) ==!
[4292]99            zg_2 = grav * 0.5
100            DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
[2528]101               DO ji = fs_2, fs_jpim1   ! vector opt.
[4292]102                  spgu(ji,jj) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
[5836]103                     &                      + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
[4292]104                  spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
[5836]105                     &                      + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
[2528]106               END DO
107            END DO
[4292]108         ENDIF
109         !
110         !                                    !==  tide potential forcing term  ==!
[7646]111         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]112            !
113            CALL upd_tide( kt )                      ! update tide potential
114            !
115            DO jj = 2, jpjm1                         ! add tide potential forcing
116               DO ji = fs_2, fs_jpim1   ! vector opt.
[5836]117                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
118                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
[4292]119               END DO
[3625]120            END DO
[4292]121         ENDIF
122         !
123         IF( nn_ice_embd == 2 ) THEN          !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
124            !                                           
125            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
126            zgrau0r     = - grav * r1_rau0
[7753]127            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
[3625]128            DO jj = 2, jpjm1
129               DO ji = fs_2, fs_jpim1   ! vector opt.
[5836]130                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
131                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
[4292]132               END DO
133            END DO
134            !
135         ENDIF
136         !
[6140]137         DO jk = 1, jpkm1                    !== Add all terms to the general trend
[4292]138            DO jj = 2, jpjm1
139               DO ji = fs_2, fs_jpim1   ! vector opt.
[3625]140                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
141                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
142               END DO
143            END DO
[4990]144         END DO   
[6140]145         !
[4990]146!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
[6140]147         !   
[3625]148      ENDIF
[6140]149      !
150      SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
151      CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt )              ! explicit
152      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
[358]153      END SELECT
[503]154      !                   
[6140]155      IF( l_trddyn )   THEN                  ! save the surface pressure gradient trends for further diagnostics
[7753]156         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
157         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
[4990]158         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
[358]159      ENDIF
[6140]160      !                                      ! print mean trends (used for debugging)
[358]161      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
162         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
[503]163      !
[3294]164      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg')
[2715]165      !
[358]166   END SUBROUTINE dyn_spg
167
168
[2528]169   SUBROUTINE dyn_spg_init
[358]170      !!---------------------------------------------------------------------
[2528]171      !!                  ***  ROUTINE dyn_spg_init  ***
[358]172      !!               
[5930]173      !! ** Purpose :   Control the consistency between namelist options for
[1566]174      !!              surface pressure gradient schemes
[358]175      !!----------------------------------------------------------------------
[6140]176      INTEGER ::   ioptio, ios   ! local integers
[5930]177      !
[6140]178      NAMELIST/namdyn_spg/ ln_dynspg_exp       , ln_dynspg_ts,   &
179      &                    ln_bt_fw, ln_bt_av  , ln_bt_auto  ,   &
180      &                    nn_baro , rn_bt_cmax, nn_bt_flt
[358]181      !!----------------------------------------------------------------------
[3294]182      !
183      IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
184      !
[5930]185      REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
186      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
[6140]187901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
188      !
[5930]189      REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
190      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
[6140]191902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
[5930]192      IF(lwm) WRITE ( numond, namdyn_spg )
193      !
194      IF(lwp) THEN             ! Namelist print
[358]195         WRITE(numout,*)
[2528]196         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
[358]197         WRITE(numout,*) '~~~~~~~~~~~'
[5930]198         WRITE(numout,*) '     Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
199         WRITE(numout,*) '     Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
[358]200      ENDIF
[6140]201      !                          ! Control of surface pressure gradient scheme options
[6981]202                                     nspg =  np_NO    ;   ioptio = 0
[6140]203      IF( ln_dynspg_exp ) THEN   ;   nspg =  np_EXP   ;   ioptio = ioptio + 1   ;   ENDIF
204      IF( ln_dynspg_ts  ) THEN   ;   nspg =  np_TS    ;   ioptio = ioptio + 1   ;   ENDIF
[1566]205      !
[6140]206      IF( ioptio  > 1 )   CALL ctl_stop( 'Choose only one surface pressure gradient scheme' )
207      IF( ioptio == 0 )   CALL ctl_warn( 'NO surface pressure gradient trend in momentum Eqs.' )
208      IF( ln_dynspg_exp .AND. ln_isfcav )   &
209           &   CALL ctl_stop( ' dynspg_exp not tested with ice shelf cavity ' )
[1566]210      !
211      IF(lwp) THEN
[358]212         WRITE(numout,*)
[7646]213         IF( nspg == np_EXP )   WRITE(numout,*) '      ===>>   explicit free surface'
214         IF( nspg == np_TS  )   WRITE(numout,*) '      ===>>   free surface with time splitting scheme'
215         IF( nspg == np_NO  )   WRITE(numout,*) '      ===>>   No surface surface pressure gradient trend in momentum Eqs.'
[358]216      ENDIF
[1566]217      !
[6140]218      IF( nspg == np_TS ) THEN   ! split-explicit scheme initialisation
219         CALL dyn_spg_ts_init          ! do it first: set nn_baro used to allocate some arrays later on
220         IF( dyn_spg_ts_alloc() /= 0  )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays' )
221         IF( neuler/=0 .AND. ln_bt_fw )   CALL ts_rst( nit000, 'READ' )
222      ENDIF
223      !
[3294]224      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_init')
225      !
[2528]226   END SUBROUTINE dyn_spg_init
[358]227
228  !!======================================================================
229END MODULE dynspg
Note: See TracBrowser for help on using the repository browser.