depth_update.F90 3.38 KB
Newer Older
kbk's avatar
kbk committed
1
!$Id: depth_update.F90,v 1.9 2006-03-01 15:54:07 kbk Exp $
gotm's avatar
gotm committed
2 3 4 5 6 7 8 9 10 11 12
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: depth_update - adjust the depth to new elevations.
!
! !INTERFACE:
   subroutine depth_update
!
! !DESCRIPTION:
!
hb's avatar
hb committed
13 14 15 16 17 18 19 20 21 22 23
! This routine which is called at every micro time step updates all
! necessary depth related information. These are the water depths in the
! T-, U- and V-points, {\tt D}, {\tt DU} and {\tt DV}, respectively,
! the sea surface elevation in the U- and V-points, {\tt zu} and {\tt zv},
! respectively, and the drying value $\alpha$ defined in equation (\ref{alpha})
! on page \pageref{alpha} in the T-, the U- and the V-points
! ({\tt dry\_z}, {\tt dry\_u} and {\tt dry\_v}).
!
! When working with the option {\tt SLICE\_MODEL}, the water depths in the
! V-points are mirrored from $j=2$ to $j=1$ and $j=3$.
!
gotm's avatar
gotm committed
24
! !USES:
kbk's avatar
kbk committed
25 26 27
   use domain, only: imin,imax,jmin,jmax,H,HU,HV,min_depth,crit_depth
   use domain, only: az,au,av,dry_z,dry_u,dry_v
   use variables_2d, only: D,z,zo,DU,zu,DV,zv
gotm's avatar
gotm committed
28 29 30 31 32 33 34 35
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
kbk's avatar
kbk committed
36 37 38
! !REVISION HISTORY:
!  Original author(s): Hans Burchard & Karsten Bolding
!
gotm's avatar
gotm committed
39
! !LOCAL VARIABLES:
kbk's avatar
kbk committed
40 41
   integer                   :: i,j
   REALTYPE                  :: d1,d2,x
gotm's avatar
gotm committed
42 43 44 45 46 47 48 49 50
!EOP
!-----------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'depth_update() # ',Ncall
#endif

kbk's avatar
kbk committed
51
#undef USE_MASK
gotm's avatar
gotm committed
52

53 54 55
!  Depth in elevation points
   D = z+H

gotm's avatar
gotm committed
56
!  U-points
kbk's avatar
kbk committed
57 58
   do j=jmin-HALO,jmax+HALO
      do i=imin-HALO,imax+HALO-1
kbk's avatar
kbk committed
59 60 61
#ifdef USE_MASK
         if(au(i,j) .gt. 0) then
#endif
gotm's avatar
gotm committed
62 63
         x=max(0.25*(zo(i,j)+zo(i+1,j)+z(i,j)+z(i+1,j)),-HU(i,j)+min_depth)
         zu(i,j) = x
kbk's avatar
kbk committed
64 65 66 67
         DU(i,j) = x+HU(i,j)
#ifdef USE_MASK
         end if
#endif
gotm's avatar
gotm committed
68 69 70 71
      end do
   end do

!  V-points
kbk's avatar
kbk committed
72 73
   do j=jmin-HALO,jmax+HALO-1
      do i=imin-HALO,imax+HALO
kbk's avatar
kbk committed
74 75 76
#ifdef USE_MASK
         if(av(i,j) .gt. 0) then
#endif
gotm's avatar
gotm committed
77 78
         x = max(0.25*(zo(i,j)+zo(i,j+1)+z(i,j)+z(i,j+1)),-HV(i,j)+min_depth)
         zv(i,j) = x
kbk's avatar
kbk committed
79 80 81 82
         DV(i,j) = x+HV(i,j)
#ifdef USE_MASK
         end if
#endif
gotm's avatar
gotm committed
83 84 85
      end do
   end do

kbk's avatar
kbk committed
86 87 88 89 90 91 92 93 94 95 96
   d1 = 2*min_depth
   d2 = crit_depth-2*min_depth
   where (az .gt. 0)
      dry_z = max(_ZERO_,min(_ONE_,(D-d1/2.)/d2))
   end where
   where (au .gt. 0)
      dry_u = max(_ZERO_,min(_ONE_,(DU-d1)/d2))
   end where
   where (av .gt. 0)
      dry_v = max(_ZERO_,min(_ONE_,(DV-d1)/d2))
   end where
gotm's avatar
gotm committed
97

98 99 100 101 102 103 104
#ifdef SLICE_MODEL
   do i=imin,imax
      DV(i,1)=DV(i,2)
      DV(i,3)=DV(i,2)
   end do
#endif

kbk's avatar
kbk committed
105
#ifdef DEBUG
gotm's avatar
gotm committed
106 107 108 109
   do j=jmin,jmax
      do i=imin,imax

         if(D(i,j) .le. _ZERO_ .and. az(i,j) .gt. 0) then
kbk's avatar
kbk committed
110
            STDERR 'depth_update: D  ',i,j,H(i,j),D(i,j)
gotm's avatar
gotm committed
111 112 113
         end if

         if(DU(i,j) .le. _ZERO_ .and. au(i,j) .gt. 0) then
kbk's avatar
kbk committed
114
            STDERR 'depth_update: DU ',i,j,HU(i,j),DU(i,j)
gotm's avatar
gotm committed
115 116 117
         end if

         if(DV(i,j) .le. _ZERO_ .and. av(i,j) .gt. 0) then
kbk's avatar
kbk committed
118
            STDERR 'depth_update: DV ',i,j,HV(i,j),DV(i,j)
gotm's avatar
gotm committed
119 120 121 122
         end if

      end do
   end do
kbk's avatar
kbk committed
123
#endif
gotm's avatar
gotm committed
124 125 126 127 128 129 130 131 132 133 134 135

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

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