slow_terms.F90 4.78 KB
Newer Older
kbk's avatar
kbk committed
1
!$Id: slow_terms.F90,v 1.7 2006-03-01 15:54:08 kbk Exp $
gotm's avatar
gotm committed
2 3 4 5
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
6
! !ROUTINE: slow_terms - calculation of slow terms \label{sec-slow-terms}
gotm's avatar
gotm committed
7 8 9 10 11
!
! !INTERFACE:
   subroutine slow_terms
!
! !DESCRIPTION:
12 13 14 15 16 17 18 19 20 21
!
! Here, the calculation of the so-called slow terms (which are the 
! interaction terms between the barotropic and the baroclinic mode) is
! completed. The mathematical form of these slow terms is given by 
! equations (\ref{Slowfirst}) - (\ref{Slowlast}), see section
! \ref{SectionVerticalIntegrated}.
! These calculations have been prepared in the routines 
! {\tt slow\_bottom\_friction}, {\tt slow\_advection} and
! {\tt slow\_diffusion}.

gotm's avatar
gotm committed
22 23 24
!
! !USES:
   use domain, only: iimin,iimax,jjmin,jjmax,kmax,HU,HV,au,av
25 26 27 28 29 30
   use variables_2d, only: Uint,Vint,UEx,VEx,Slru,Slrv,SlUx,SlVx,ru,rv
   use variables_3d, only: kumin,kvmin,uu,vv,huo,hun,hvo,hvn
   use variables_3d, only: ssuo,ssun,ssvo,ssvn,uuEx,vvEx,rru,rrv
#ifndef NO_BAROCLINIC
   use variables_3d, only: idpdx,idpdy
#endif
gotm's avatar
gotm committed
31 32 33 34 35 36 37 38
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
kbk's avatar
kbk committed
39 40 41
! !REVISION HISTORY:
!  Original author(s): Hans Burchard & Karsten Bolding
!
gotm's avatar
gotm committed
42
! !LOCAL VARIABLES:
kbk's avatar
kbk committed
43
   integer                   :: i,j,k
gotm's avatar
gotm committed
44 45 46 47 48 49 50 51 52
!EOP
!-----------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'slow_terms() # ',Ncall
#endif

kbk's avatar
kbk committed
53
   if (kmax .gt. 1) then
gotm's avatar
gotm committed
54

55 56
      do j=jjmin,jjmax
         do i=iimin,iimax
kbk's avatar
kbk committed
57
            if (au(i,j) .ge. 1) then
gotm's avatar
gotm committed
58
               SlUx(i,j)=-UEx(i,j)
59
            end if
gotm's avatar
gotm committed
60 61 62 63 64 65
         end do
      end do

      do k=1,kmax
         do j=jjmin,jjmax
            do i=iimin,iimax
kbk's avatar
kbk committed
66 67
               if (au(i,j) .ge. 1) then
                  if (k .ge. kumin(i,j)) then
68 69 70
#ifdef NO_BAROCLINIC
                     SlUx(i,j)=SlUx(i,j)+uuEx(i,j,k)
#else
gotm's avatar
gotm committed
71
                     SlUx(i,j)=SlUx(i,j)+uuEx(i,j,k)-idpdx(i,j,k)
72
#endif
gotm's avatar
gotm committed
73 74 75 76 77 78
                  end if
               end if
            end do
         end do
      end do

79 80
      do j=jjmin,jjmax
         do i=iimin,iimax
kbk's avatar
kbk committed
81
            if (av(i,j) .ge. 1) then
gotm's avatar
gotm committed
82
               SlVx(i,j)=-VEx(i,j)
83
            end if
gotm's avatar
gotm committed
84 85 86 87 88 89
         end do
      end do

      do k=1,kmax
         do j=jjmin,jjmax
            do i=iimin,iimax
kbk's avatar
kbk committed
90 91
               if (av(i,j) .ge. 1) then
                  if (k .ge. kvmin(i,j)) then
92 93 94
#ifdef NO_BAROCLINIC
                     SlVx(i,j)=SlVx(i,j)+vvEx(i,j,k)
#else
gotm's avatar
gotm committed
95
                     SlVx(i,j)=SlVx(i,j)+vvEx(i,j,k)-idpdy(i,j,k)
96
#endif
gotm's avatar
gotm committed
97
                  end if
98
               end if
gotm's avatar
gotm committed
99 100 101 102 103 104 105 106 107
            end do
         end do
      end do

   else

      do k=1,kmax
         do j=jjmin,jjmax
            do i=iimin,iimax
kbk's avatar
kbk committed
108 109
               if (au(i,j) .ge. 1) then
                  if (k .ge. kumin(i,j)) then
110 111 112
#ifdef NO_BAROCLINIC
                     SlUx(i,j)= _ZERO_
#else
gotm's avatar
gotm committed
113
                     SlUx(i,j)=-idpdx(i,j,k)
114
#endif
gotm's avatar
gotm committed
115 116 117 118 119 120 121 122 123
                  end if
               end if
            end do
         end do
      end do

      do k=1,kmax
         do j=jjmin,jjmax
            do i=iimin,iimax
kbk's avatar
kbk committed
124
               if (av(i,j) .ge. 1) then
gotm's avatar
gotm committed
125
                  if (k.ge.kvmin(i,j)) then
126 127 128
#ifdef NO_BAROCLINIC
                     SlVx(i,j)= _ZERO_
#else
gotm's avatar
gotm committed
129
                     SlVx(i,j)=-idpdy(i,j,k)
130
#endif
gotm's avatar
gotm committed
131
                  end if
132
               end if
gotm's avatar
gotm committed
133 134 135 136 137 138 139
            end do
         end do
      end do
   endif

   do j=jjmin,jjmax
      do i=iimin,iimax
kbk's avatar
kbk committed
140
         if (au(i,j) .ge. 1) then
141
            k=kumin(i,j)
kbk's avatar
kbk committed
142
            if (kmax .gt. 1) then
gotm's avatar
gotm committed
143
#ifdef NO_SLR
144 145
               STDERR 'NO_SLR U'
               Slru(i,j)= _ZERO_
gotm's avatar
gotm committed
146
#else
kbk's avatar
kbk committed
147 148
               Slru(i,j)=-Uint(i,j)/(0.5*(ssuo(i,j)+ssun(i,j))         &
                                       +HU(i,j))*ru(i,j)               &
149
                     +uu(i,j,k)/(0.5*(huo(i,j,k)+hun(i,j,k)))*rru(i,j)
gotm's avatar
gotm committed
150
#endif
151 152 153
            else
               Slru(i,j)= _ZERO_
            end if
gotm's avatar
gotm committed
154 155 156 157 158 159
         end if
      end do
   end do

   do j=jjmin,jjmax
      do i=iimin,iimax
kbk's avatar
kbk committed
160
         if (av(i,j) .ge. 1) then
gotm's avatar
gotm committed
161
            k=kvmin(i,j)
kbk's avatar
kbk committed
162
            if (kmax .gt. 1) then
gotm's avatar
gotm committed
163 164
#ifdef NO_SLR
               STDERR 'NO_SLR V'
kbk's avatar
kbk committed
165
               Slrv(i,j)= _ZERO_
gotm's avatar
gotm committed
166
#else
kbk's avatar
kbk committed
167 168
               Slrv(i,j)=-Vint(i,j)/(0.5*(ssvo(i,j)+ssvn(i,j))         &
                                    +HV(i,j))*rv(i,j)                  &
gotm's avatar
gotm committed
169 170 171
                  +vv(i,j,k)/(0.5*(hvo(i,j,k)+hvn(i,j,k)))*rrv(i,j)
#endif
            else
172
               Slrv(i,j)=_ZERO_
kbk's avatar
kbk committed
173
            end if
gotm's avatar
gotm committed
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
         end if
      end do
   end do

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

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