uv_depths.F90 3.66 KB
Newer Older
kbk's avatar
kbk committed
1
!$Id: uv_depths.F90,v 1.12 2006-03-01 15:54:07 kbk Exp $
gotm's avatar
gotm committed
2 3 4 5
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
hb's avatar
hb committed
6
! !IROUTINE: uv_depths - calculate depths in u and v points.\label{sec-uv-depth}
gotm's avatar
gotm committed
7 8
!
! !INTERFACE:
9
   subroutine uv_depths(vel_depth_method)
gotm's avatar
gotm committed
10 11 12
!
! !DESCRIPTION:
!
hb's avatar
hb committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
! In this routine which is called once during the model initialisation,
! the bathymetry value in the U- and the V-points are calculated from the
! bathymetry values in the T-points. The interpolation depends on the value
! which is given to {\tt vel\_depth\_method}:
!
! \begin{equation}
! H^u_{i,j} = \left\{
! \begin{array}{ll}
! \displaystyle
! \frac12 \left(H_{i,j}+H_{i+1,j}\right), & 
! \displaystyle
! \mbox{ for {\tt vel\_depth\_method}} =0, \\ \\ 
! \displaystyle
! \min\left\{H_{i,j}+H_{i+1,j}\right\}, & 
! \displaystyle
! \mbox{ for {\tt vel\_depth\_method}} =1, \\ \\ 
! \displaystyle
! \min\left\{H_{i,j}+H_{i+1,j}\right\}, & 
! \displaystyle
! \mbox{ for {\tt vel\_depth\_method}} =2 \mbox{ and } \min\{H_{i,j}i,H_{i+1,j}\}<D_{crit} \\ \\ 
! \displaystyle
! \frac12 \left(H_{i,j}+H_{i+1,j}\right), & 
! \displaystyle
! \mbox{ for {\tt vel\_depth\_method}} =2 \mbox{ and } \min\{H_{i,j},H_{i+1,j}\}\geq D_{crit} \\ \\ 
! \end{array}
! \right.
! \end{equation}
!
! The calculation of $H^v_{i,j}$ is done accordingly.
!
! The options 1 and 2 for {\tt vel\_depth\_method} may help to stabilise
! calculations when drying and flooding is involved.
!
gotm's avatar
gotm committed
46
! !USES:
47
   use exceptions
kbk's avatar
kbk committed
48 49
   use domain, only: imin,imax,jmin,jmax,az,au,av,H,HU,HV
   use variables_2d, only: DU,DV
gotm's avatar
gotm committed
50 51 52
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
53
   integer, intent(in)                 :: vel_depth_method
gotm's avatar
gotm committed
54 55 56 57 58
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
kbk's avatar
kbk committed
59 60 61
! !REVISION HISTORY:
!  Original author(s): Hans Burchard & Karsten Bolding
!
gotm's avatar
gotm committed
62
! !LOCAL VARIABLES:
kbk's avatar
kbk committed
63
   integer                   :: i,j
64
   REALTYPE                  :: d_crit=2.0 
gotm's avatar
gotm committed
65 66 67 68 69 70 71 72 73 74
!
!EOP
!-----------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(0,*) 'uv_depths() # ',Ncall
#endif

kbk's avatar
kbk committed
75 76
   do j=jmin-HALO,jmax+HALO
      do i=imin-HALO,imax+HALO-1
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
         select case (vel_depth_method)
            case (0)
               HU(i,j)=0.5*(H(i,j)+H(i+1,j))
            case (1)
               HU(i,j)=min(H(i,j),H(i+1,j))
            case (2)
               if (H(i,j) .lt. d_crit .or. H(i+1,j) .lt. d_crit) then
                  HU(i,j)=min(H(i,j),H(i+1,j))
               else
                  HU(i,j)=0.5*(H(i,j)+H(i+1,j))
               end if
            case default
               call getm_error("uv_depths()", &
                               "vel_depth_method must be 0, 1 or 2")
         end select
kbk's avatar
kbk committed
92 93
      end do
   end do
94

kbk's avatar
kbk committed
95 96
   do j=jmin-HALO,jmax+HALO-1
      do i=imin-HALO,imax+HALO
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
         select case (vel_depth_method)
            case (0)
               HV(i,j)=0.5*(H(i,j)+H(i,j+1))
            case (1)
               HV(i,j)=min(H(i,j),H(i,j+1))
            case (2)
               if (H(i,j) .lt. d_crit .or. H(i,j+1) .lt. d_crit) then
                  HV(i,j)=min(H(i,j),H(i,j+1))
               else
                  HV(i,j)=0.5*(H(i,j)+H(i,j+1))
               end if
            case default
               call getm_error("uv_depths()", &
                               "vel_depth_method must be 0, 1 or 2")
         end select
gotm's avatar
gotm committed
112 113 114 115 116 117 118 119 120 121 122 123 124 125
      end do
   end do

#ifdef DEBUG
   write(0,*) 'Leaving uv_depths()'
   write(0,*)
#endif
   return
   end subroutine uv_depths
!EOC

!-----------------------------------------------------------------------
! Copyright (C) 2001 - Hans Burchard and Karsten Bolding               !
!-----------------------------------------------------------------------