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/UKMO/NEMO_4.0_momentum_trends/src/OCE/DYN – NEMO

source: NEMO/branches/UKMO/NEMO_4.0_momentum_trends/src/OCE/DYN/dynspg.F90 @ 11613

Last change on this file since 11613 was 11613, checked in by davestorkey, 4 years ago

UKMO/NEMO_4.0_momentum_trends branch : first set of code changes.

File size: 12.4 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
[9019]19   USE sbc_ice , ONLY : snwice_mass, snwice_mass_b
[2528]20   USE sbcapr         ! surface boundary condition: atmospheric pressure
[358]21   USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
22   USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
[6140]23   USE sbctide        !
24   USE updtide        !
[4990]25   USE trd_oce        ! trends: ocean variables
26   USE trddyn         ! trend manager: dynamics
27   !
[358]28   USE prtctl         ! Print control                     (prt_ctl routine)
29   USE in_out_manager ! I/O manager
[2715]30   USE lib_mpp        ! MPP library
[4990]31   USE timing         ! Timing
[358]32
33   IMPLICIT NONE
34   PRIVATE
35
[2528]36   PUBLIC   dyn_spg        ! routine called by step module
37   PUBLIC   dyn_spg_init   ! routine called by opa module
[358]38
[6140]39   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_...
[358]40
[6140]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
[358]46   !! * Substitutions
47#  include "vectopt_loop_substitute.h90"
48   !!----------------------------------------------------------------------
[9598]49   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
[10888]50   !! $Id$
[10068]51   !! Software governed by the CeCILL license (see ./LICENSE)
[358]52   !!----------------------------------------------------------------------
53CONTAINS
54
[5930]55   SUBROUTINE dyn_spg( kt )
[358]56      !!----------------------------------------------------------------------
57      !!                  ***  ROUTINE dyn_spg  ***
58      !!
[6140]59      !! ** Purpose :   compute surface pressure gradient including the
60      !!              atmospheric pressure forcing (ln_apr_dyn=T).
[1566]61      !!
[5930]62      !! ** Method  :   Two schemes:
[6140]63      !!              - explicit       : the spg is evaluated at now
64      !!              - split-explicit : a time splitting technique is used
[1566]65      !!
[2528]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.
[358]72      !!----------------------------------------------------------------------
[9019]73      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
[2715]74      !
[9019]75      INTEGER  ::   ji, jj, jk                   ! dummy loop indices
[9023]76      REAL(wp) ::   z2dt, zg_2, zintp, zgrau0r, zld   ! local scalars
[9019]77      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   zpice
78      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrdu, ztrdv
[358]79      !!----------------------------------------------------------------------
[3294]80      !
[9019]81      IF( ln_timing )   CALL timing_start('dyn_spg')
[3294]82      !
[11613]83      IF( l_trddyn .AND. nspg == np_EXP )   THEN                      ! temporary save of ta and sa trends
[9019]84         ALLOCATE( ztrdu(jpi,jpj,jpk) , ztrdv(jpi,jpj,jpk) ) 
[7753]85         ztrdu(:,:,:) = ua(:,:,:)
86         ztrdv(:,:,:) = va(:,:,:)
[358]87      ENDIF
[6140]88      !
[4292]89      IF(      ln_apr_dyn                                                &   ! atmos. pressure
[7646]90         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. ln_tide) )   &   ! tide potential (no time slitting)
[9019]91         .OR.  ln_ice_embd ) THEN                                            ! embedded sea-ice
[4292]92         !
93         DO jj = 2, jpjm1
[2528]94            DO ji = fs_2, fs_jpim1   ! vector opt.
[4292]95               spgu(ji,jj) = 0._wp
96               spgv(ji,jj) = 0._wp
[2528]97            END DO
[4292]98         END DO         
99         !
[6140]100         IF( ln_apr_dyn .AND. .NOT.ln_dynspg_ts ) THEN   !==  Atmospheric pressure gradient (added later in time-split case) ==!
[4292]101            zg_2 = grav * 0.5
102            DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
[2528]103               DO ji = fs_2, fs_jpim1   ! vector opt.
[4292]104                  spgu(ji,jj) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
[9019]105                     &                                + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
[4292]106                  spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
[9019]107                     &                                + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
[2528]108               END DO
109            END DO
[4292]110         ENDIF
111         !
112         !                                    !==  tide potential forcing term  ==!
[7646]113         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]114            !
115            CALL upd_tide( kt )                      ! update tide potential
116            !
117            DO jj = 2, jpjm1                         ! add tide potential forcing
118               DO ji = fs_2, fs_jpim1   ! vector opt.
[5836]119                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
120                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
[4292]121               END DO
[3625]122            END DO
[9023]123            !
124            IF (ln_scal_load) THEN
125               zld = rn_scal_load * grav
126               DO jj = 2, jpjm1                    ! add scalar approximation for load potential
127                  DO ji = fs_2, fs_jpim1   ! vector opt.
128                     spgu(ji,jj) = spgu(ji,jj) + zld * ( sshn(ji+1,jj) - sshn(ji,jj) ) * r1_e1u(ji,jj)
129                     spgv(ji,jj) = spgv(ji,jj) + zld * ( sshn(ji,jj+1) - sshn(ji,jj) ) * r1_e2v(ji,jj)
130                  END DO
131               END DO
132            ENDIF
[4292]133         ENDIF
134         !
[9019]135         IF( ln_ice_embd ) THEN              !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
136            ALLOCATE( zpice(jpi,jpj) )
[4292]137            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
138            zgrau0r     = - grav * r1_rau0
[7753]139            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
[3625]140            DO jj = 2, jpjm1
141               DO ji = fs_2, fs_jpim1   ! vector opt.
[5836]142                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
143                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
[4292]144               END DO
145            END DO
[9019]146            DEALLOCATE( zpice )         
[4292]147         ENDIF
148         !
[6140]149         DO jk = 1, jpkm1                    !== Add all terms to the general trend
[4292]150            DO jj = 2, jpjm1
151               DO ji = fs_2, fs_jpim1   ! vector opt.
[3625]152                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
153                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
154               END DO
155            END DO
[4990]156         END DO   
[6140]157         !
[4990]158!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
[6140]159         !   
[3625]160      ENDIF
[6140]161      !
162      SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
163      CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt )              ! explicit
164      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
[358]165      END SELECT
[503]166      !                   
[11613]167      IF( l_trddyn .AND. nspg == np_EXP )   THEN     ! save the surface pressure gradient trends for further diagnostics
[7753]168         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
169         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
[4990]170         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
[11613]171         ! In this case we also need to finalise the write-out of the PVO 3D diagnostic with zero correction
172         ztrdu(:,:,1) = 0._wp
173         ztrdv(:,:,1) = 0._wp
174         CALL trd_dyn( ztrdu(:,:,1), ztrdv(:,:,1), jpdyn_pvo, kt )
[9019]175         DEALLOCATE( ztrdu , ztrdv ) 
[358]176      ENDIF
[6140]177      !                                      ! print mean trends (used for debugging)
[358]178      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
179         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
[503]180      !
[9019]181      IF( ln_timing )   CALL timing_stop('dyn_spg')
[2715]182      !
[358]183   END SUBROUTINE dyn_spg
184
185
[2528]186   SUBROUTINE dyn_spg_init
[358]187      !!---------------------------------------------------------------------
[2528]188      !!                  ***  ROUTINE dyn_spg_init  ***
[358]189      !!               
[5930]190      !! ** Purpose :   Control the consistency between namelist options for
[1566]191      !!              surface pressure gradient schemes
[358]192      !!----------------------------------------------------------------------
[6140]193      INTEGER ::   ioptio, ios   ! local integers
[5930]194      !
[6140]195      NAMELIST/namdyn_spg/ ln_dynspg_exp       , ln_dynspg_ts,   &
196      &                    ln_bt_fw, ln_bt_av  , ln_bt_auto  ,   &
[9023]197      &                    nn_baro , rn_bt_cmax, nn_bt_flt, rn_bt_alpha
[358]198      !!----------------------------------------------------------------------
[3294]199      !
[9169]200      IF(lwp) THEN
201         WRITE(numout,*)
202         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
203         WRITE(numout,*) '~~~~~~~~~~~~'
204      ENDIF
205      !
[5930]206      REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
207      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
[6140]208901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
209      !
[5930]210      REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
211      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
[9168]212902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
[5930]213      IF(lwm) WRITE ( numond, namdyn_spg )
214      !
215      IF(lwp) THEN             ! Namelist print
[9169]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
[358]219      ENDIF
[6140]220      !                          ! Control of surface pressure gradient scheme options
[6981]221                                     nspg =  np_NO    ;   ioptio = 0
[6140]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
[1566]224      !
[6140]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 ' )
[1566]229      !
230      IF(lwp) THEN
[358]231         WRITE(numout,*)
[9190]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.'
[358]235      ENDIF
[1566]236      !
[6140]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      !
[2528]241   END SUBROUTINE dyn_spg_init
[358]242
243  !!======================================================================
244END MODULE dynspg
Note: See TracBrowser for help on using the repository browser.