gotm.F90 5.42 KB
Newer Older
kbk's avatar
kbk committed
1
!$Id: gotm.F90,v 1.9 2005-09-23 11:26:55 kbk Exp $
gotm's avatar
gotm committed
2 3 4 5 6 7 8 9 10 11 12 13
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: gotm() - a wrapper to call GOTM.
!
! !INTERFACE:
   subroutine gotm()
!
! !DESCRIPTION:
!
! !USES:
14
   use halo_zones, only: update_3d_halo,wait_halo,H_TAG
gotm's avatar
gotm committed
15
   use domain, only: iimin,iimax,jjmin,jjmax,kmax,az,min_depth,crit_depth
16
   use variables_2d, only: D,zub,zvb,z
17 18 19 20
   use variables_3d, only: dt,kmin,ho,hn,tke,eps,SS,num,taus,taub
#ifndef NO_BAROCLINIC
   use variables_3d, only: NN,nuh
#endif
21
   use variables_3d, only: avmback,avhback
22
   use turbulence, only: do_turbulence,cde
gotm's avatar
gotm committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36
   use turbulence, only: tke1d => tke, eps1d => eps, L1d => L
   use turbulence, only: num1d => num, nuh1d => nuh
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
!  $Log: gotm.F90,v $
kbk's avatar
kbk committed
37 38 39 40
!  Revision 1.9  2005-09-23 11:26:55  kbk
!  support for GOTM v3.2 and above
!
!  Revision 1.8  2004/08/06 15:14:35  hb
41 42 43
!  num and nuh now properly initialised and no gotm call for CONSTANT_VISCOSITY
!
!  Revision 1.7  2003/12/17 10:22:41  kbk
44 45 46
!  now compiles with -DNO_BAROCLINIC and -DNO_3D
!
!  Revision 1.6  2003/12/16 15:58:54  kbk
47 48 49
!  back ground viscosity and diffusivity (manuel)
!
!  Revision 1.5  2003/05/05 15:51:57  kbk
50 51 52
!  proper update of halo zones for num and nuh
!
!  Revision 1.4  2003/04/23 12:16:34  kbk
kbk's avatar
kbk committed
53 54 55
!  cleaned code + TABS to spaces
!
!  Revision 1.3  2003/04/07 13:36:38  kbk
56
!  parallel support, cleaned code + NO_3D, NO_BAROCLINIC
gotm's avatar
gotm committed
57 58 59
!
!  Revision 1.1.1.1  2002/05/02 14:00:54  gotm
!  recovering after CVS crash
gotm's avatar
gotm committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
!
!  Revision 1.11  2001/10/23 07:06:43  bbh
!  PARABOLIC VISCOSITY --> PARABOLIC_VISCOSITY
!
!  Revision 1.10  2001/10/23 07:05:11  bbh
!  Parabolic viscosity - -DPARABOLIC_VISCOSITY
!
!  Revision 1.8  2001/09/09 20:11:46  bbh
!  Buoyancy production has now right sign
!
!  Revision 1.7  2001/08/27 11:50:17  bbh
!  TVD-advection for momentum added, some bugs removed
!
!  Revision 1.6  2001/07/26 12:54:11  bbh
!  Testing advection schems - using ifdef HAIDVOGEL_TEST
!
!  Revision 1.5  2001/06/22 08:19:10  bbh
!  Compiler options such as USE_MASK and OLD_DRY deleted.
!  Open and passive boundary for z created.
!  Various inconsistencies removed.
!  wait_halo added.
!  Checked loop boundaries
!
!  Revision 1.4  2001/05/21 13:07:19  bbh
!  dt and cnpar is in variables_3d.F90
!
!  Revision 1.3  2001/05/20 07:49:22  bbh
!  Also diffusivities + partial fix of z0b
!
!  Revision 1.2  2001/05/03 20:12:31  bbh
!  Use of variables_3d
!
!  Revision 1.1.1.1  2001/04/17 08:43:08  bbh
!  initial import into CVS
!
!
! !LOCAL VARIABLES:
kbk's avatar
kbk committed
97 98 99 100 101
   integer                   :: i,j,k
   REALTYPE                  :: u_taus,u_taub,z0s,z0b
   REALTYPE                  :: h(0:kmax),dry,zz
   REALTYPE                  :: P(0:kmax),B(0:kmax)
   REALTYPE                  :: NN1d(0:kmax),SS1d(0:kmax)
kbk's avatar
kbk committed
102 103 104
#ifndef GOTM_3_0
   REALTYPE                  :: xP(0:kmax)
#endif
kbk's avatar
kbk committed
105 106 107
   logical, save             :: first=.true.
   integer, save             :: n = 0
   integer                   :: kk
gotm's avatar
gotm committed
108 109 110 111 112 113 114 115 116 117
!
!EOP
!-----------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'gotm() # ',Ncall
#endif

kbk's avatar
kbk committed
118 119 120
#ifndef GOTM_3_0
   xP = _ZERO_
#endif
121 122
   do j=jjmin,jjmax
      do i=iimin,iimax
gotm's avatar
gotm committed
123 124 125

         if (az(i,j) .eq. 1 ) then

gotm's avatar
gotm committed
126 127
            u_taus = sqrt(taus(i,j))
            u_taub = sqrt(taub(i,j))
gotm's avatar
gotm committed
128

gotm's avatar
gotm committed
129 130
            h = hn(i,j,:)
            SS1d = SS(i,j,:)
131
#ifndef NO_BAROCLINIC
gotm's avatar
gotm committed
132
            NN1d = NN(i,j,:)
133
#endif
gotm's avatar
gotm committed
134

gotm's avatar
gotm committed
135
            P  = num(i,j,:)*SS1d
136
#ifndef NO_BAROCLINIC
gotm's avatar
gotm committed
137
            B  = -nuh(i,j,:)*NN1d
138
#endif
gotm's avatar
gotm committed
139

gotm's avatar
gotm committed
140 141 142 143
            tke1d=tke(i,j,:)
            eps1d=eps(i,j,:)
            L1d=cde*tke1d**1.5/eps1d
            num1d=num(i,j,:)
144
#ifndef NO_BAROCLINIC
gotm's avatar
gotm committed
145
            nuh1d=nuh(i,j,:)
146
#endif
gotm's avatar
gotm committed
147

gotm's avatar
gotm committed
148
            z0s = 0.1
kbk's avatar
kbk committed
149
            z0b=0.5*(max(zub(i-1,j),zub(i,j))+max(zvb(i,j-1),zvb(i,j)))
150
            if (z0s .gt. D(i,j)/10.) z0s=D(i,j)/10.
gotm's avatar
gotm committed
151 152

#ifdef PARABOLIC_VISCOSITY
gotm's avatar
gotm committed
153 154 155
            zz = _ZERO_
            do k=1,kmax-1
               zz=zz+hn(i,j,k)
kbk's avatar
kbk committed
156 157 158 159
               tke1d(k)=max(1.e-10,3.333333*u_taub**2*(1.-zz/D(i,j)))
               L1d(k)=0.4*(zz+z0b)*sqrt(1.-zz/D(i,j))
               eps1d(k)=0.16431677*tke1d(k)**1.5/L1d(k)
               num1d(k)=0.09*tke1d(k)**2/eps1d(k)
160
#ifndef NO_BAROCLINIC
kbk's avatar
kbk committed
161
               nuh1d(k)=num1d(k)
162
#endif
kbk's avatar
kbk committed
163
            end do
gotm's avatar
gotm committed
164
#else
kbk's avatar
kbk committed
165
#ifdef GOTM_3_0
kbk's avatar
kbk committed
166 167
            call do_turbulence(kmax,dt,D(i,j),u_taus,u_taub,z0s,z0b,h, &
                               NN1d,SS1d,P,B)
kbk's avatar
kbk committed
168 169 170 171
#else
            call do_turbulence(kmax,dt,D(i,j),u_taus,u_taub,z0s,z0b,h, &
                               NN1d,xP)
#endif
gotm's avatar
gotm committed
172 173
#endif

gotm's avatar
gotm committed
174 175
            tke(i,j,:) = tke1d
            eps(i,j,:) = eps1d
176
            num(i,j,:) = num1d + avmback
177
#ifndef NO_BAROCLINIC
178
            nuh(i,j,:) = nuh1d + avhback
179
#endif
gotm's avatar
gotm committed
180 181 182
         end if
      end do
   end do
183
   
184 185
   call update_3d_halo(num,num,az,iimin,jjmin,iimax,jjmax,kmax,H_TAG)
   call wait_halo(H_TAG)
186
#ifndef NO_BAROCLINIC
187 188
   call update_3d_halo(nuh,nuh,az,iimin,jjmin,iimax,jjmax,kmax,H_TAG)
   call wait_halo(H_TAG)
189 190
#endif

gotm's avatar
gotm committed
191 192 193 194 195 196 197 198 199 200 201 202

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

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