variables_2d.F90 10.4 KB
Newer Older
gotm's avatar
gotm committed
1 2 3 4 5 6 7 8 9 10 11 12
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !MODULE: variables_2d - global variables for 2D model
!
! !INTERFACE:
   module variables_2d
!
! !DESCRIPTION:
!  This modules contains declarations for all variables related to 2D
!  hydrodynamical calculations. Information about the calculation domain
hb's avatar
hb committed
13
!  is included from the {\tt domain} module.
gotm's avatar
gotm committed
14
!  The module contains public subroutines to initialise and cleanup.
hb's avatar
hb committed
15 16 17
!  Depending whether the compiler option {STATIC} is set or not,
!  memory for 2D variables is statically or dynamically allocated, see
!  {\tt PUBLIC DATA MEMBERS}.
gotm's avatar
gotm committed
18 19
!
! !USES:
20
   use domain, only: imin,imax,jmin,jmax
gotm's avatar
gotm committed
21 22 23
   IMPLICIT NONE
!
! !PUBLIC DATA MEMBERS:
Knut's avatar
Knut committed
24
   integer, parameter                  :: rk = kind(_ONE_)
Knut's avatar
Knut committed
25
   REALTYPE,dimension(:,:),pointer     :: zo,z
Knut's avatar
Knut committed
26 27
   logical                             :: do_numerical_analyses_2d=.false.

gotm's avatar
gotm committed
28
#ifdef STATIC
gotm's avatar
gotm committed
29
#include "static_2d.h"
gotm's avatar
gotm committed
30
#else
gotm's avatar
gotm committed
31
#include "dynamic_declarations_2d.h"
gotm's avatar
gotm committed
32
#endif
Knut's avatar
Knut committed
33

Knut's avatar
Knut committed
34 35
   REALTYPE,dimension(:,:),pointer     :: numdis_2d=>null()
   REALTYPE,dimension(:,:),allocatable :: numdis_2d_old,phydis_2d
Knut's avatar
Knut committed
36

kbk's avatar
kbk committed
37 38
   integer                             :: size2d_field
   integer                             :: mem2d
gotm's avatar
gotm committed
39
!
kbk's avatar
kbk committed
40 41 42
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
gotm's avatar
gotm committed
43 44 45 46 47 48 49 50
!EOP
!-----------------------------------------------------------------------

   contains

!-----------------------------------------------------------------------
!BOP
!
hb's avatar
hb committed
51
! !IROUTINE: init_variables_2d - initialise 2D related stuff.
gotm's avatar
gotm committed
52 53 54 55 56 57
!
! !INTERFACE:
   subroutine init_variables_2d(runtype)
   IMPLICIT NONE
!
! !DESCRIPTION:
58 59
!  Allocates memory (unless {\tt STATIC} is set) for 2D related fields,
!  by an include statement. Furthermore all public 2D variables are
hb's avatar
hb committed
60 61 62 63 64 65
!  initialised to zero. Those are listed in table \ref{table_2d_variables}
!  on page \pageref{table_2d_variables}.
!
!  \begin{table}[h]
!  \begin{center}
!  \begin{tabular}{lll}
66 67 68 69 70
! {\tt z } & sea surface elevation in T-point & [m] \\
! {\tt U } & $x$ component of transport in U-point & [m$^2$s$^{-1}$] \\
! {\tt DU } & water depth in U-point & [m] \\
! {\tt fU } & Coriolis term for $V$-equation in V-point & [m$^2$s$^{-2}$] \\
! {\tt SlUx } & slow term for $U$-equation in U-point & [m$^2$s$^{-2}$] \\
hb's avatar
hb committed
71
! {\tt Slru } &slow bottom friction for $U$-equation in U-point &
72 73 74 75 76
! [m$^2$s$^{-2}$]\\
! {\tt V } & $y$ component of transport in V-point & [m$^2$s$^{-1}$]\\
! {\tt DV } & water depth in V-point & [m] \\
! {\tt fV } &  Coriolis term for $U$-equation in U-point & [m$^2$s$^{-2}$]\\
! {\tt SlVx } & slow term for $V$-equation in V-point & [m$^2$s$^{-2}$] \\
hb's avatar
hb committed
77
! {\tt Slrv } &slow bottom friction for $V$-equation in V-point &
78 79 80 81 82 83 84 85
! [m$^2$s$^{-2}$]\\
! {\tt Uint } & $x$-component of mean transport in U-point & [m$^2$s$^{-1}$]\\
! {\tt Vint } & $y$-component of mean transport in V-point & [m$^2$s$^{-1}$]\\
! {\tt UEx } & sum of explicit terms for for $U$-equation in U-point & [m$^2$s$^{-2}$]\\
! {\tt VEx } &sum of explicit terms for for $V$-equation in V-point & [m$^2$s$^{-2}$]\\
! {\tt ru } & bottom friction for $U$-equation in U-point & [m$^2$s$^{-2}$]\\
! {\tt rv } &bottom friction for $V$-equation in V-point & [m$^2$s$^{-2}$]\\
! {\tt res\_du } & residual depth in U-point & [m]\\
hb's avatar
hb committed
86
! {\tt res\_u } & $x$-component of residual transport in U-point &
87 88
! [m$^2$s$^{-1}$]\\
! {\tt res\_dv } & residual depth in V-point & [m] \\
hb's avatar
hb committed
89
! {\tt res\_v } &$y$-component of residual transport in V-point &
90
! [m$^2$s$^{-1}$]\\
hb's avatar
hb committed
91
! \end{tabular}
92
! \caption{Public 2D variables.}
hb's avatar
hb committed
93 94 95
! \label{table_2d_variables}
! \end{center}
! \end{table}
gotm's avatar
gotm committed
96 97
!
! !INPUT PARAMETERS:
kbk's avatar
kbk committed
98
   integer, intent(in)                 :: runtype
gotm's avatar
gotm committed
99
!
Knut's avatar
Knut committed
100 101
! !LOCAL VARIABLES:
   integer                   :: rc
gotm's avatar
gotm committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
!EOP
!-------------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'init_variables_2d() # ',Ncall
#endif

   LEVEL2 'init_variables_2d'
   size2d_field=((imax+HALO)-(imin+HALO)+1)*((jmax+HALO)-(jmin+HALO)+1)
   mem2d=n2d_fields*size2d_field*REAL_SIZE

!  Allocates memory for the public data members - if not static
#ifndef STATIC
gotm's avatar
gotm committed
117
#include "dynamic_allocations_2d.h"
gotm's avatar
gotm committed
118 119
#endif

120
   zo => t_zo ; z => t_z
gotm's avatar
gotm committed
121

122
#ifdef USE_BREAKS
123
   break_stat = 0
124 125
#endif

Knut's avatar
Knut committed
126
   z  = -9999._rk ; zo =_ZERO_
127

Knut's avatar
Knut committed
128 129
   zub=_ZERO_ ; zub0=_ZERO_
   zvb=_ZERO_ ; zvb0=_ZERO_
130

Knut's avatar
Knut committed
131 132
   U = _ZERO_; DU = _ZERO_; Uint = _ZERO_; UEx = _ZERO_
   V = _ZERO_; DV = _ZERO_; Vint = _ZERO_; VEx = _ZERO_
133
   velx = -9999.0 ; vely = -9999.0
kbk's avatar
kbk committed
134

bjb's avatar
bjb committed
135 136
   ru = _ZERO_; ruu=_ZERO_; Uinto=_ZERO_
   rv = _ZERO_; rvv=_ZERO_; Vinto=_ZERO_
137

bjb's avatar
bjb committed
138 139 140 141 142 143 144
   res_du = _ZERO_; res_u = _ZERO_
   res_dv = _ZERO_; res_v = _ZERO_

   SlUx=_ZERO_; Slru=_ZERO_
   SlVx=_ZERO_; Slrv=_ZERO_

   fwf     = _ZERO_
kbk's avatar
kbk committed
145
   fwf_int = _ZERO_
kbk's avatar
kbk committed
146

bjb's avatar
bjb committed
147 148 149 150 151
   EWbdy=_ZERO_
   ENbdy=_ZERO_
   EEbdy=_ZERO_
   ESbdy=_ZERO_

gotm's avatar
gotm committed
152 153 154 155 156 157 158 159
#ifdef DEBUG
   write(debug,*) 'Leaving init_variables_2d()'
   write(debug,*)
#endif
   return
   end subroutine init_variables_2d
!EOC

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: postinit_variables_2d - re-initialise some 2D stuff.
!
! !INTERFACE:
   subroutine postinit_variables_2d()
   IMPLICIT NONE
!
! !DESCRIPTION:
!
! !LOCAL VARIABLES:
   integer                   :: rc
!
!EOP
!-----------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'postinit_variables_2d() # ',Ncall
#endif

   if (do_numerical_analyses_2d) then
      allocate(phydis_2d(E2DFIELD),stat=rc)
      if (rc /= 0) stop 'postinit_2d: Error allocating memory (phydis_2d)'
      phydis_2d = _ZERO_
      allocate(numdis_2d(E2DFIELD),stat=rc)
      if (rc /= 0) stop 'postinit_2d: Error allocating memory (numdis_2d)'
      numdis_2d = _ZERO_
#ifdef _NUMERICAL_ANALYSES_OLD_
      allocate(numdis_2d_old(E2DFIELD),stat=rc)
      if (rc /= 0) stop 'postinit_2d: Error allocating memory (numdis_2d_old)'
      numdis_2d_old = _ZERO_
#endif
   end if


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

Knut's avatar
Knut committed
206 207 208 209 210 211 212 213 214 215 216
!-----------------------------------------------------------------------
!BOP
!
! !ROUTINE: register_2d_variables() - register GETM variables.
!
! !INTERFACE:
   subroutine register_2d_variables(fm)
!
! !DESCRIPTION:
!
! !USES:
217
   use field_manager
Knut's avatar
Knut committed
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
   type (type_field_manager) :: fm
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Jorn Bruggeman
!
! !LOCAL VARIABLES:
   logical :: used
!EOP
!-----------------------------------------------------------------------
!BOC
   LEVEL2 'register_2d_variables()'

!D(E2DFIELD)
!DU,DV
!z(E2DFIELD)
!zo(E2DFIELD)
!U(E2DFIELD)
!V(E2DFIELD)
!UEx(E2DFIELD)
!VEx(E2DFIELD)
!fU(E2DFIELD)
!fV(E2DFIELD)
!ru(E2DFIELD)
!rv(E2DFIELD)
!Uint(E2DFIELD)
!Vint(E2DFIELD)
!Uinto(E2DFIELD)
!Vinto(E2DFIELD)
!res_du(E2DFIELD)
!res_u(E2DFIELD)
!res_dv(E2DFIELD)
!res_v(E2DFIELD)
!kbk
!SlUx(E2DFIELD)
!SlVx(E2DFIELD)
!Slru(E2DFIELD)
!Slrv(E2DFIELD)
!zub(E2DFIELD)
!zvb(E2DFIELD)
!zub0(E2DFIELD)
!zvb0(E2DFIELD)
!An(E2DFIELD)
!AnX(E2DFIELD)
!fwf(E2DFIELD)
!fwf_int(E2DFIELD)
!EWbdy(jmax),ENbdy(imax),EEbdy(jmax),ESbdy(imax)


!  category - 2d
   call fm%register('z', 'm', 'sea surface elevation', standard_name='sea surface elevation', fill_value=-9999.0_rk, data2d=z(_2D_W_), category="2d", part_of_state=.true.)
   call fm%register('zo', 'm', 'sea surface elevation', standard_name='sea surface elevation', fill_value=-9999.0_rk, data2d=zo(_2D_W_), category="2d", output_level=output_level_debug)
   call fm%register('D', 'm', 'water depth', standard_name='water depth', fill_value=-10009.0_rk, data2d=D(_2D_W_), category="2d", part_of_state=.true.)
   call fm%register('U', 'm2/s', 'transport in local x-direction', standard_name='', data2d=U(_2D_W_), category='2d', output_level=output_level_debug, part_of_state=.true.)
   call fm%register('V', 'm2/s', 'transport in local y-direction', standard_name='', data2d=V(_2D_W_), category='2d', output_level=output_level_debug, part_of_state=.true.)
Knut's avatar
Knut committed
275 276
   call fm%register('velx', 'm/s', 'velocity in global x-direction', standard_name='', data2d=velx(_2D_W_), category='2d', fill_value=-9999.0_rk, output_level=output_level_debug)
   call fm%register('vely', 'm/s', 'velocity in global y-direction', standard_name='', data2d=vely(_2D_W_), category='2d', fill_value=-9999.0_rk, output_level=output_level_debug)
Knut's avatar
Knut committed
277

278 279 280 281 282
   if (do_numerical_analyses_2d) then
      call fm%register('numdis_2d', 'W/kg', 'numerical dissipation', standard_name='', category='2d', output_level=output_level_debug)
      call fm%register('phydis_2d', 'W/kg', 'physical dissipation' , standard_name='', category='2d', output_level=output_level_debug)
   end if

Knut's avatar
Knut committed
283 284 285 286
   return
   end subroutine register_2d_variables
!EOC

287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
!-----------------------------------------------------------------------
!BOP
!
! !ROUTINE: finalize_register_2d_variables() - send optional variables.
!
! !INTERFACE:
   subroutine finalize_register_2d_variables(fm)
!
! !DESCRIPTION:
!
! !USES:
   use field_manager
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
   type (type_field_manager) :: fm
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Jorn Bruggeman
!
! !LOCAL VARIABLES:
!EOP
!-----------------------------------------------------------------------
!BOC
   LEVEL1 'finalize_register_2d_variables()'

   if (do_numerical_analyses_2d) then
      call fm%send_data('numdis_2d', numdis_2d(_2D_W_))
      call fm%send_data('phydis_2d', phydis_2d(_2D_W_))
   end if

   return
   end subroutine finalize_register_2d_variables
!EOC

gotm's avatar
gotm committed
322 323 324 325 326 327 328 329 330 331
!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: clean_variables_2d - cleanup after 2D run.
!
! !INTERFACE:
   subroutine clean_variables_2d()
   IMPLICIT NONE
!
! !DESCRIPTION:
hb's avatar
hb committed
332
!  This routine is currently empty.
gotm's avatar
gotm committed
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
!
! !LOCAL VARIABLES:
!
!EOP
!-----------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'clean_variables_2d() # ',Ncall
#endif

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

!-----------------------------------------------------------------------

   end module variables_2d

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