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.
bdyvol.F90 in branches/UKMO/r5518_amm15_test/NEMOGCM/NEMO/OPA_SRC/BDY – NEMO

source: branches/UKMO/r5518_amm15_test/NEMOGCM/NEMO/OPA_SRC/BDY/bdyvol.F90 @ 7144

Last change on this file since 7144 was 7144, checked in by jcastill, 8 years ago

Remove svn keywords

File size: 8.7 KB
RevLine 
[911]1MODULE bdyvol
[1125]2   !!======================================================================
[911]3   !!                       ***  MODULE  bdyvol  ***
4   !! Ocean dynamic :  Volume constraint when unstructured boundary
[3294]5   !!                  and filtered free surface are used
[1125]6   !!======================================================================
7   !! History :  1.0  !  2005-01  (J. Chanut, A. Sellar)  Original code
8   !!             -   !  2006-01  (J. Chanut) Bug correction
9   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
[3294]10   !!            3.4  !  2011     (D. Storkey) rewrite in preparation for OBC-BDY merge
[1125]11   !!----------------------------------------------------------------------
[5930]12#if   defined key_bdy
[1125]13   !!----------------------------------------------------------------------
[5930]14   !!   'key_bdy'      unstructured open boundary conditions
[1125]15   !!----------------------------------------------------------------------
[911]16   USE oce             ! ocean dynamics and tracers
[5836]17   USE bdy_oce         ! ocean open boundary conditions
18   USE sbc_oce         ! ocean surface boundary conditions
[911]19   USE dom_oce         ! ocean space and time domain
20   USE phycst          ! physical constants
[5836]21   USE sbcisf          ! ice shelf
22   !
23   USE in_out_manager  ! I/O manager
[911]24   USE lib_mpp         ! for mppsum
[5836]25   USE timing          ! Timing
26   USE lib_fortran     ! Fortran routines library
[911]27
28   IMPLICIT NONE
29   PRIVATE
30
[5930]31   PUBLIC bdy_vol     
[911]32
33   !! * Substitutions
34#  include "domzgr_substitute.h90"
[1125]35   !!----------------------------------------------------------------------
[5836]36   !! NEMO/OPA 3.6 , NEMO Consortium (2014)
[7144]37   !! $Id$
[2528]38   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
[1125]39   !!----------------------------------------------------------------------
[911]40CONTAINS
41
[1125]42   SUBROUTINE bdy_vol( kt )
43      !!----------------------------------------------------------------------
[911]44      !!                      ***  ROUTINE bdyvol  ***
45      !!
[5930]46      !! ** Purpose :   This routine controls the volume of the system.
47      !!      A correction velocity is calculated
[911]48      !!      to correct the total transport through the unstructured OBC.
49      !!      The total depth used is constant (H0) to be consistent with the
50      !!      linear free surface coded in OPA 8.2
51      !!
[1125]52      !! ** Method  :   The correction velocity (zubtpecor here) is defined calculating
[911]53      !!      the total transport through all open boundaries (trans_bdy) minus
[1125]54      !!      the cumulate E-P flux (z_cflxemp) divided by the total lateral
[911]55      !!      surface (bdysurftot) of the unstructured boundary.
[1125]56      !!         zubtpecor = [trans_bdy - z_cflxemp ]*(1./bdysurftot)
57      !!      with z_cflxemp => sum of (Evaporation minus Precipitation)
[911]58      !!                       over all the domain in m3/s at each time step.
[1125]59      !!      z_cflxemp < 0 when precipitation dominate
60      !!      z_cflxemp > 0 when evaporation dominate
[911]61      !!
62      !!      There are 2 options (user's desiderata):
63      !!         1/ The volume changes according to E-P, this is the default
64      !!            option. In this case the cumulate E-P flux are setting to
[1125]65      !!            zero (z_cflxemp=0) to calculate the correction velocity. So
[911]66      !!            it will only balance the flux through open boundaries.
[2528]67      !!            (set nn_volctl to 0 in tne namelist for this option)
[911]68      !!         2/ The volume is constant even with E-P flux. In this case
69      !!            the correction velocity must balance both the flux
70      !!            through open boundaries and the ones through the free
71      !!            surface.
[2528]72      !!            (set nn_volctl to 1 in tne namelist for this option)
[1125]73      !!----------------------------------------------------------------------
74      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
[911]75      !!
[1125]76      INTEGER  ::   ji, jj, jk, jb, jgrd
[3294]77      INTEGER  ::   ib_bdy, ii, ij
[2528]78      REAL(wp) ::   zubtpecor, z_cflxemp, ztranst
[3294]79      TYPE(OBC_INDEX), POINTER :: idx
[911]80      !!-----------------------------------------------------------------------------
[5836]81      !
82      IF( nn_timing == 1 )   CALL timing_start('bdy_vol')
83      !
[2528]84      IF( ln_vol ) THEN
[5836]85      !
[911]86      IF( kt == nit000 ) THEN
[1125]87         IF(lwp) WRITE(numout,*)
[911]88         IF(lwp) WRITE(numout,*)'bdy_vol : Correction of velocities along unstructured OBC'
89         IF(lwp) WRITE(numout,*)'~~~~~~~'
90      END IF 
91
[1125]92      ! Calculate the cumulate surface Flux z_cflxemp (m3/s) over all the domain
93      ! -----------------------------------------------------------------------
[5836]94!!gm replace these lines :
95      z_cflxemp = SUM ( ( emp(:,:)-rnf(:,:)+fwfisf(:,:) ) * bdytmask(:,:) * e1e2t(:,:) ) / rau0
[2528]96      IF( lk_mpp )   CALL mpp_sum( z_cflxemp )     ! sum over the global domain
[5836]97!!gm   by :
98!!gm      z_cflxemp = glob_sum(  ( emp(:,:)-rnf(:,:)+fwfisf(:,:) ) * bdytmask(:,:) * e1e2t(:,:)  ) / rau0
99!!gm
[911]100
[2528]101      ! Transport through the unstructured open boundary
102      ! ------------------------------------------------
[5836]103      zubtpecor = 0._wp
[3294]104      DO ib_bdy = 1, nb_bdy
105         idx => idx_bdy(ib_bdy)
[5836]106         !
[3294]107         jgrd = 2                               ! cumulate u component contribution first
108         DO jb = 1, idx%nblenrim(jgrd)
109            DO jk = 1, jpkm1
110               ii = idx%nbi(jb,jgrd)
111               ij = idx%nbj(jb,jgrd)
[4292]112               zubtpecor = zubtpecor + idx%flagu(jb,jgrd) * ua(ii,ij, jk) * e2u(ii,ij) * fse3u(ii,ij,jk)
[3294]113            END DO
[1125]114         END DO
[3294]115         jgrd = 3                               ! then add v component contribution
116         DO jb = 1, idx%nblenrim(jgrd)
117            DO jk = 1, jpkm1
118               ii = idx%nbi(jb,jgrd)
119               ij = idx%nbj(jb,jgrd)
[4292]120               zubtpecor = zubtpecor + idx%flagv(jb,jgrd) * va(ii,ij, jk) * e1v(ii,ij) * fse3v(ii,ij,jk) 
[3294]121            END DO
[1125]122         END DO
[5836]123         !
[911]124      END DO
125      IF( lk_mpp )   CALL mpp_sum( zubtpecor )   ! sum over the global domain
126
[1125]127      ! The normal velocity correction
128      ! ------------------------------
[2528]129      IF( nn_volctl==1 ) THEN   ;   zubtpecor = ( zubtpecor - z_cflxemp) / bdysurftot 
[5836]130      ELSE                      ;   zubtpecor =   zubtpecor             / bdysurftot
[911]131      END IF
132
[1125]133      ! Correction of the total velocity on the unstructured boundary to respect the mass flux conservation
134      ! -------------------------------------------------------------
[5836]135      ztranst = 0._wp
[3294]136      DO ib_bdy = 1, nb_bdy
137         idx => idx_bdy(ib_bdy)
[5836]138         !
[3294]139         jgrd = 2                               ! correct u component
140         DO jb = 1, idx%nblenrim(jgrd)
141            DO jk = 1, jpkm1
142               ii = idx%nbi(jb,jgrd)
143               ij = idx%nbj(jb,jgrd)
[4292]144               ua(ii,ij,jk) = ua(ii,ij,jk) - idx%flagu(jb,jgrd) * zubtpecor * umask(ii,ij,jk)
145               ztranst = ztranst + idx%flagu(jb,jgrd) * ua(ii,ij,jk) * e2u(ii,ij) * fse3u(ii,ij,jk)
[3294]146            END DO
[1125]147         END DO
[3294]148         jgrd = 3                              ! correct v component
149         DO jb = 1, idx%nblenrim(jgrd)
150            DO jk = 1, jpkm1
151               ii = idx%nbi(jb,jgrd)
152               ij = idx%nbj(jb,jgrd)
[4292]153               va(ii,ij,jk) = va(ii,ij,jk) -idx%flagv(jb,jgrd) * zubtpecor * vmask(ii,ij,jk)
154               ztranst = ztranst + idx%flagv(jb,jgrd) * va(ii,ij,jk) * e1v(ii,ij) * fse3v(ii,ij,jk)
[3294]155            END DO
[1125]156         END DO
[5836]157         !
[911]158      END DO
159      IF( lk_mpp )   CALL mpp_sum( ztranst )   ! sum over the global domain
160 
[1125]161      ! Check the cumulated transport through unstructured OBC once barotropic velocities corrected
162      ! ------------------------------------------------------
[911]163      IF( lwp .AND. MOD( kt, nwrite ) == 0) THEN
[1125]164         IF(lwp) WRITE(numout,*)
165         IF(lwp) WRITE(numout,*)'bdy_vol : time step :', kt
166         IF(lwp) WRITE(numout,*)'~~~~~~~ '
167         IF(lwp) WRITE(numout,*)'          cumulate flux EMP             =', z_cflxemp  , ' (m3/s)'
168         IF(lwp) WRITE(numout,*)'          total lateral surface of OBC  =', bdysurftot, '(m2)'
169         IF(lwp) WRITE(numout,*)'          correction velocity zubtpecor =', zubtpecor , '(m/s)'
170         IF(lwp) WRITE(numout,*)'          cumulated transport ztranst   =', ztranst   , '(m3/s)'
[911]171      END IF 
[1125]172      !
[3294]173      IF( nn_timing == 1 ) CALL timing_stop('bdy_vol')
174      !
[2528]175      END IF ! ln_vol
[5836]176      !
[911]177   END SUBROUTINE bdy_vol
178
179#else
[1125]180   !!----------------------------------------------------------------------
181   !!   Dummy module                   NO Unstruct Open Boundary Conditions
182   !!----------------------------------------------------------------------
[911]183CONTAINS
[1125]184   SUBROUTINE bdy_vol( kt )        ! Empty routine
185      WRITE(*,*) 'bdy_vol: You should not have seen this print! error?', kt
[911]186   END SUBROUTINE bdy_vol
187#endif
188
[1125]189   !!======================================================================
[911]190END MODULE bdyvol
Note: See TracBrowser for help on using the repository browser.