m3d.F90 16.5 KB
Newer Older
1
!$Id: m3d.F90,v 1.27 2006-01-29 20:32:33 hb Exp $
gotm's avatar
gotm committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !MODULE: m3d - 3D model component
!
! !INTERFACE:
   module m3d
!
! !DESCRIPTION:
!  This modules contains declarations for all variables related to 3D
!  hydrodynamical calculations. Information about the calculation domain
!  is included from the \emph{domain.F90} module.
!  The module contains public subroutines for initialisation, integration
!  and clean up of the 3D model component.
!  The actual calculation routines are called in integrate\_3d and is linked
!  in from the library lib3d.a.
!
! !USES:
21
   use exceptions
gotm's avatar
gotm committed
22
   use parameters, only: avmmol
kbk's avatar
kbk committed
23
   use domain, only: maxdepth,vert_cord
kbk's avatar
kbk committed
24
   use m2d, only: Am
kbk's avatar
kbk committed
25
   use variables_2d, only: D,z,UEx,VEx
kbk's avatar
kbk committed
26
#ifndef NO_BAROCLINIC
gotm's avatar
gotm committed
27 28
   use temperature,only: init_temperature, do_temperature
   use salinity,   only: init_salinity, do_salinity
kbk's avatar
kbk committed
29
   use eqstate,    only: init_eqstate, do_eqstate
30 31
   use internal_pressure, only: init_internal_pressure, do_internal_pressure
   use internal_pressure, only: ip_method
kbk's avatar
kbk committed
32
#endif
kbk's avatar
kbk committed
33
#ifdef SPM
kbk's avatar
kbk committed
34
   use suspended_matter, only: init_spm, do_spm
35 36 37 38
#endif
#ifdef GETM_BIO
   use bio, only: bio_calc
   use getm_bio, only: init_getm_bio, do_getm_bio
kbk's avatar
kbk committed
39
#endif
40
   use variables_3d
gotm's avatar
gotm committed
41
   use advection_3d, only: init_advection_3d
kbk's avatar
kbk committed
42
   use bdy_3d, only: init_bdy_3d, do_bdy_3d
kbk's avatar
kbk committed
43

gotm's avatar
gotm committed
44 45 46
   IMPLICIT NONE
!
! !PUBLIC DATA MEMBERS:
kbk's avatar
kbk committed
47
   integer                             :: M=1
48
   REALTYPE                            :: cord_relax=_ZERO_
kbk's avatar
kbk committed
49 50 51
   logical                             :: calc_temp=.true.
   logical                             :: calc_salt=.true.
   logical                             :: calc_spm=.false.
kbk's avatar
kbk committed
52
   logical                             :: hotstart_spm=.false.
kbk's avatar
kbk committed
53 54 55
   logical                             :: bdy3d=.false.
   integer                             :: bdyfmt_3d,bdyramp_3d
   character(len=PATH_MAX)             :: bdyfile_3d
gotm's avatar
gotm committed
56 57 58 59 60
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
!  $Log: m3d.F90,v $
61 62 63
!  Revision 1.27  2006-01-29 20:32:33  hb
!  Small LaTeX corrections to source code documentation
!
kbk's avatar
kbk committed
64 65 66 67
!  Revision 1.26  2006-01-27 16:07:56  kbk
!  now works with -DNO_BAROCLINIC
!
!  Revision 1.25  2005/09/23 11:27:10  kbk
68 69 70
!  support for biology via GOTMs biology modules
!
!  Revision 1.24  2005/04/25 07:55:50  kbk
71 72 73
!  use more general frame for error handling - Umlauf
!
!  Revision 1.23  2004/08/09 07:48:07  kbk
74 75 76
!  checking for negative avmback and avhback
!
!  Revision 1.22  2004/08/06 15:14:35  hb
77 78 79
!  num and nuh now properly initialised and no gotm call for CONSTANT_VISCOSITY
!
!  Revision 1.21  2004/07/29 19:48:44  hb
hb's avatar
hb committed
80 81 82
!  num, nuh now initialised with _ZERO_
!
!  Revision 1.20  2004/07/28 14:58:18  hb
83 84 85
!  Changing subroutine calling order via MUDFLAT
!
!  Revision 1.19  2004/06/15 08:25:57  kbk
kbk's avatar
kbk committed
86 87 88
!  added supoort for spm - Ruiz
!
!  Revision 1.18  2004/05/04 09:23:51  kbk
89 90 91
!  hydrostatic consistency criteria stored in .3d.nc file
!
!  Revision 1.17  2004/04/23 09:03:59  kbk
kbk's avatar
kbk committed
92
!  reverted to pre-adaptive grid version
hb's avatar
hb committed
93 94
!
!  Revision 1.15  2004/04/20 16:49:37  hb
95 96 97
!  call to coordinates moved for better consistency (see JMB)
!
!  Revision 1.14  2004/04/06 12:42:50  kbk
98 99 100
!  internal pressure calculations now uses wrapper
!
!  Revision 1.13  2004/01/08 10:23:20  kbk
101 102 103
!  NN not needed for barotropic runs, NO_SUSP_MATTER works
!
!  Revision 1.12  2004/01/06 15:04:00  kbk
104 105 106
!  FCT advection + split of advection_3d.F90 + extra adv. input checks
!
!  Revision 1.11  2004/01/05 13:23:27  kbk
kbk's avatar
kbk committed
107 108 109
!  Poor Man's Z-coordinates
!
!  Revision 1.10  2004/01/02 13:54:24  kbk
110 111 112
!  read equation of state info from namelist - Ruiz
!
!  Revision 1.9  2003/12/16 17:02:44  kbk
kbk's avatar
kbk committed
113 114 115
!  removed TABS - 0. -> _ZERO_
!
!  Revision 1.8  2003/12/16 15:58:54  kbk
116 117 118
!  back ground viscosity and diffusivity (manuel)
!
!  Revision 1.7  2003/09/12 16:23:38  kbk
119 120 121
!  fixed order of use statement - now compiles on with IFC 7.1
!
!  Revision 1.6  2003/08/28 15:13:57  kbk
kbk's avatar
kbk committed
122 123 124
!  explicit set UEx and VEx to 0
!
!  Revision 1.5  2003/04/23 12:16:34  kbk
kbk's avatar
kbk committed
125 126 127
!  cleaned code + TABS to spaces
!
!  Revision 1.4  2003/04/07 16:28:34  kbk
kbk's avatar
kbk committed
128
!  parallel support
gotm's avatar
gotm committed
129 130 131
!
!  Revision 1.1.1.1  2002/05/02 14:00:51  gotm
!  recovering after CVS crash
gotm's avatar
gotm committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
!
!  Revision 1.30  2001/10/26 09:13:24  bbh
!  Only call slow_diffusion() if Am > 0.
!
!  Revision 1.29  2001/10/23 12:38:58  bbh
!  Forgot cord_relax in one call to coordinates()
!
!  Revision 1.28  2001/10/23 07:53:10  bbh
!  spm -> suspended_matter
!
!  Revision 1.27  2001/10/23 07:05:11  bbh
!  Parabolic viscosity - -DPARABOLIC_VISCOSITY
!
!  Revision 1.26  2001/10/22 11:16:09  bbh
!  Added support for particulate suspended matter - no IO yet
!
!  Revision 1.25  2001/10/22 09:26:41  bbh
!  Added cord_relax
!
!  Revision 1.24  2001/10/22 08:48:30  bbh
!  Am moved from paramters.F90 to m2d.F90
!
!  Revision 1.23  2001/10/12 11:39:20  bbh
!  TVD moved out of ??_momentum_3d.F90 and into uv_advect_3d.F90
!
!  Revision 1.22  2001/10/12 08:49:56  bbh
!  Support for horizontal diffusion
!
!  Revision 1.21  2001/09/19 13:07:00  bbh
!  Moved advection related 3D fields to global allocation
!
!  Revision 1.20  2001/09/03 20:14:03  bbh
!  Fixed reading of vel_{hor,vel,strang
!
!  Revision 1.19  2001/09/03 20:04:21  bbh
!  Allow individual advection settings for momentum, salinity and temperature
!
!  Revision 1.18  2001/09/03 13:02:52  bbh
!  Small changes due to NOMADS
!
!  Revision 1.17  2001/08/31 15:39:49  bbh
!  ifdef for CONSTANCE added
!
!  Revision 1.16  2001/08/30 08:56:26  bbh
!  Preparing for 3D boundary conditions
!
!  Revision 1.15  2001/08/29 12:08:05  bbh
!  temp_adv and salt_adv needs to be public
!
!  Revision 1.14  2001/08/29 11:21:46  bbh
!  namelists read in salinity and temperature + initialisation
!
!  Revision 1.13  2001/08/27 11:51:45  bbh
!  TVD-advection for momentum added, some bugs removed
!
!  Revision 1.12  2001/08/01 08:31:22  bbh
!  CURVILINEAR now implemented
!
!  Revision 1.11  2001/07/26 13:46:06  bbh
!  Included info for salinity and temperature in namelist
!
!  Revision 1.10  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.9  2001/05/25 19:36:36  bbh
!  Added call to eqstate
!
!  Revision 1.8  2001/05/21 13:07:19  bbh
!  dt and cnpar is in variables_3d.F90
!
!  Revision 1.7  2001/05/20 07:51:40  bbh
!  Internal pressure included
!
!  Revision 1.6  2001/05/18 08:17:49  bbh
!  Tidying up initialization of salinity and temperature
!
!  Revision 1.5  2001/05/15 11:47:57  bbh
!  Added update_3d_halo for initial S and T
!
!  Revision 1.4  2001/05/10 11:30:16  bbh
!  Added further support for baroclinicity
!
!  Revision 1.3  2001/05/03 20:12:31  bbh
!  Use of variables_3d
!
!  Revision 1.2  2001/04/24 08:39:21  bbh
!  Included runtype as argument to integrate_3d
!
!  Revision 1.1.1.1  2001/04/17 08:43:08  bbh
!  initial import into CVS
!
! !LOCAL VARIABLES:
228
   integer         :: vel_hor_adv=1,vel_ver_adv=1,vel_adv_split=0
kbk's avatar
kbk committed
229 230 231
#ifdef NO_BAROCLINIC
   integer         :: ip_method
#endif
gotm's avatar
gotm committed
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
!EOP
!-----------------------------------------------------------------------

   contains

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: init_3d - initialise 3D relatedstuff.
!
! !INTERFACE:
   subroutine init_3d(runtype,timestep,hotstart)
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
kbk's avatar
kbk committed
247 248 249
   integer, intent(in)                 :: runtype
   REALTYPE, intent(in)                :: timestep
   logical, intent(in)                 :: hotstart
gotm's avatar
gotm committed
250 251 252 253 254 255 256 257 258 259 260 261 262
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
! !DESCRIPTION:
!  Allocates memiory for 3D related fields.
!
! !REVISION HISTORY:
!
!  22Apr99   Karsten Bolding & Hans Burchard  Initial code.
!
! !LOCAL VARIABLES:
263
   integer         :: rc
kbk's avatar
kbk committed
264 265 266
   NAMELIST /m3d/ &
             M,cnpar,cord_relax,                        &
             bdy3d,bdyfmt_3d,bdyramp_3d,bdyfile_3d,     &
267
             vel_hor_adv,vel_ver_adv,vel_adv_split,     &
268
             calc_temp,calc_salt,calc_spm,              &
269
             avmback,avhback,ip_method
gotm's avatar
gotm committed
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
!
!EOP
!-------------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'init_3d() # ',Ncall
#endif

   LEVEL1 'init_3d'
!  Read 3D-model specific things from the namelist.
   read(NAMLST,m3d)
!   rewind(NAMLST)

285 286 287 288 289 290 291 292 293
   if (avmback .lt. _ZERO_) then
      LEVEL2 "setting avmback to 0."
      avmback = _ZERO_
   end if
   if (avhback .lt. _ZERO_) then
      LEVEL2 "setting avhback to 0."
      avhback = _ZERO_
   end if

kbk's avatar
kbk committed
294 295 296 297
#ifndef SPM
   if(calc_spm) stop 'To use SPM you have to recompile with -DSPM'
#endif

298 299 300 301
#ifndef GETM_BIO
!KBK   if(bio_calc) stop 'To use BIO you have to recompile with -DBIO'
#endif

gotm's avatar
gotm committed
302 303 304
! Allocates memory for the public data members - if not static
   call init_variables_3d(runtype)

305 306 307 308 309
!  Sanity checks for advection specifications
   LEVEL2 'vel_hor_adv=   ',vel_hor_adv
   LEVEL2 'vel_ver_adv=   ',vel_ver_adv
   LEVEL2 'vel_adv_split= ',vel_adv_split
   if(vel_hor_adv .gt. 1) then
gotm's avatar
gotm committed
310 311 312
#ifndef UV_TVD
      STDERR 'To run the model with higher order advection for momentum'
      STDERR 'you need to re-compile the model with the option -DUV_TVD.'
313
      call getm_error("init_3d()","GETM needs recompilation")
gotm's avatar
gotm committed
314
#endif
315 316 317 318 319 320
   else
      vel_adv_split=-1
      if(vel_ver_adv .ne. 1) then
         LEVEL2 "setting vel_ver_adv to 1 - since vel_hor_adv is 1"
         vel_ver_adv=1
      end if
gotm's avatar
gotm committed
321
   end if
322 323 324 325 326 327 328 329 330 331 332 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 360 361 362 363 364 365 366 367 368 369 370 371
   LEVEL2 "horizontal: ",trim(adv_schemes(vel_hor_adv))," of momentum"
   LEVEL2 "vertical:   ",trim(adv_schemes(vel_ver_adv))," of momentum"

   select case (vel_adv_split)
      case (-1)
      case (0)
         select case (vel_hor_adv)
            case (2,3,4,5,6)
            case default
               call getm_error("init_3d()", &
                    "vel_adv_split=0: vel_hor_adv not valid (2-6)")
         end select
         select case (vel_ver_adv)
            case (2,3,4,5,6)
            case default
               call getm_error("init_3d()", &
                    "vel_adv_split=0: vel_ver_adv not valid (2-6)")
         end select
         LEVEL2 "1D split --> full u, full v, full w"
      case (1)
         select case (vel_hor_adv)
            case (2,3,4,5,6)
            case default
               call getm_error("init_3d()", &
                    "vel_adv_split=1: vel_hor_adv not valid (2-6)")
         end select
         select case (vel_ver_adv)
            case (2,3,4,5,6)
            case default
               call getm_error("init_3d()", &
                    "vel_adv_split=1: vel_ver_adv not valid (2-6)")
         end select
         LEVEL2 "1D split --> half u, half v, full w, half v, half u"
      case (2)
         select case (vel_hor_adv)
            case (2,7)
            case default
               call getm_error("init_3d()", &
                    "vel_adv_split=2: vel_hor_adv not valid (2,7)")
         end select
         select case (vel_ver_adv)
            case (2,3,4,5,6)
            case default
               call getm_error("init_3d()", &
                    "vel_adv_split=2: vel_ver_adv not valid (2-6)")
         end select
         LEVEL2 "2D-hor, 1D-vert split --> full uv, full w"
      case default
   end select

gotm's avatar
gotm committed
372
   dt = M*timestep
373 374 375 376 377 378 379 380

#ifdef CONSTANT_VISCOSITY
   num=avmback
   nuh=avhback
#else
   num=1.e-15
   nuh=1.e-15
#endif
gotm's avatar
gotm committed
381 382

!  Needed for interpolation of temperature and salinity
kbk's avatar
kbk committed
383
   if (.not. hotstart) then
gotm's avatar
gotm committed
384
      call start_macro()
kbk's avatar
kbk committed
385
      call coordinates(vert_cord,cord_relax,maxdepth)
386
      call hcc_check()
kbk's avatar
kbk committed
387
   end if
gotm's avatar
gotm committed
388

kbk's avatar
kbk committed
389
#ifndef NO_BAROCLINIC
gotm's avatar
gotm committed
390
   if (runtype .eq. 3 .or. runtype .eq. 4) then
gotm's avatar
gotm committed
391
      T = _ZERO_ ; S = _ZERO_ ; rho = _ZERO_
gotm's avatar
gotm committed
392 393
      if(calc_temp) call init_temperature(1)
      if(calc_salt) call init_salinity(1)
kbk's avatar
kbk committed
394
   end if
395
#endif
kbk's avatar
kbk committed
396

397
#ifndef NO_BAROCLINIC
kbk's avatar
kbk committed
398
    if (runtype .eq. 3 .or. runtype .eq. 4) then
399
      call init_eqstate()
gotm's avatar
gotm committed
400 401 402
#ifndef PECS
      call do_eqstate()
#endif
403 404
      if (runtype .ge. 3) call init_internal_pressure()
      if (runtype .eq. 3) call do_internal_pressure()
gotm's avatar
gotm committed
405 406 407 408
      if (runtype .eq. 4) then
         call init_advection_3d(2)
      end if
   end if
kbk's avatar
kbk committed
409
#endif
410

kbk's avatar
kbk committed
411 412
#ifdef SPM
      if(calc_spm)  call init_spm(hotstart_spm,runtype)
413 414 415 416 417 418
      if(runtype .ne. 4) call init_advection_3d(2)
#endif

#ifdef GETM_BIO
!KBK      if(bio_calc) call init_getm_bio()
      call init_getm_bio()
kbk's avatar
kbk committed
419
#endif
gotm's avatar
gotm committed
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440

   if (bdy3d) call init_bdy_3d()

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

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: integrate_3d - sequence of calls to do 3D model integration
!
! !INTERFACE:
   subroutine integrate_3d(runtype,n)
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
kbk's avatar
kbk committed
441
   integer, intent(in)                 :: runtype,n
gotm's avatar
gotm committed
442 443 444 445 446 447 448
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
! !DESCRIPTION:
! A wrapper to call all 3D related subroutines in one subroutine.
449 450
! if the compiler option {\tt MUDFLAT} is defined, then the sequence of 
! velocity equations
451
! and coordinate construction is made such that drying and flooding
452
! is stable. If {\tt MUDFLAT} is not defined, then adaptive grids with
453
! Lagrangian component are supported. Both, drying and flooding and
454
! Lagrangian coordinates does not go together.
gotm's avatar
gotm committed
455 456 457 458 459
!
! !REVISION HISTORY:
!  See log for module
!
! !LOCAL VARIABLES:
kbk's avatar
kbk committed
460
  logical, save              :: ufirst=.true.
gotm's avatar
gotm committed
461 462 463 464 465 466 467 468 469 470
!
!EOP
!-------------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'integrate_3d() # ',Ncall
#endif
   call start_macro()
kbk's avatar
kbk committed
471
#ifndef NO_BAROCLINIC
gotm's avatar
gotm committed
472
   if (bdy3d) call do_bdy_3d(0,T)
kbk's avatar
kbk committed
473
#endif
474 475 476
#ifdef MUDFLAT
   call coordinates(vert_cord,cord_relax,maxdepth)
#endif
gotm's avatar
gotm committed
477
#ifndef NO_BOTTFRIC
kbk's avatar
kbk committed
478
   if (kmax .gt. 1) then
gotm's avatar
gotm committed
479 480 481 482
      call bottom_friction_3d()
   end if
#endif
   SS = _ZERO_
kbk's avatar
kbk committed
483
#ifndef NO_BAROCLINIC
gotm's avatar
gotm committed
484
   NN = _ZERO_
485
   if (runtype .eq. 4) call do_internal_pressure()
kbk's avatar
kbk committed
486
#endif
487 488
   huo=hun
   hvo=hvn
gotm's avatar
gotm committed
489 490 491 492 493 494 495 496 497
   if (ufirst) then
      call uu_momentum_3d(bdy3d)
      call vv_momentum_3d(bdy3d)
      ufirst=.false.
   else
      call vv_momentum_3d(bdy3d)
      call uu_momentum_3d(bdy3d)
      ufirst=.true.
   end if
498
#ifndef MUDFLAT
499
   call coordinates(vert_cord,cord_relax,maxdepth)
500
#endif
gotm's avatar
gotm committed
501 502 503 504
   if (kmax .gt. 1) then
      call ww_momentum_3d()
   end if
#ifndef NO_ADVECT
kbk's avatar
kbk committed
505
   if (kmax .gt. 1) then
506
      call uv_advect_3d(vel_hor_adv,vel_ver_adv,vel_adv_split)
gotm's avatar
gotm committed
507 508 509 510 511 512 513
      if (Am .gt. _ZERO_) then
         call uv_diffusion_3d(Am)  ! Must be called after uv_advect_3d
      end if
   end if
#else
   STDERR 'NO_ADVECT 3D'
#endif
kbk's avatar
kbk committed
514 515

   if (kmax .gt. 1) then
516
#ifndef NO_BOTTFRIC
gotm's avatar
gotm committed
517
      call stresses_3d()
518 519
#endif
#ifndef CONSTANT_VISCOSITY
gotm's avatar
gotm committed
520 521 522 523 524
#ifndef PARABOLIC_VISCOSITY
      call ss_nn()
#endif
      call gotm()
#endif
525
   end if
kbk's avatar
kbk committed
526
#ifndef NO_BAROCLINIC
kbk's avatar
kbk committed
527
   if(runtype .eq. 4) then        ! prognostic T and S
gotm's avatar
gotm committed
528 529
      if (calc_temp) call do_temperature(n)
      if (calc_salt) call do_salinity(n)
kbk's avatar
kbk committed
530
   end if
531
#endif
kbk's avatar
kbk committed
532

533 534
#ifndef NO_BAROCLINIC
   if(runtype .eq. 4) then
gotm's avatar
gotm committed
535 536 537 538
#ifndef PECS
      call do_eqstate()
#endif
   end if
kbk's avatar
kbk committed
539
#endif
gotm's avatar
gotm committed
540

kbk's avatar
kbk committed
541
#ifdef SPM
542 543 544 545 546
   if (calc_spm) call do_spm()
#endif

#ifdef GETM_BIO
   if (bio_calc) call do_getm_bio(dt)
kbk's avatar
kbk committed
547 548
#endif

kbk's avatar
kbk committed
549
   UEx=_ZERO_ ; VEx=_ZERO_
kbk's avatar
kbk committed
550
   if (kmax .gt. 1) then
gotm's avatar
gotm committed
551
#ifndef NO_BOTTFRIC
kbk's avatar
kbk committed
552
      call slow_bottom_friction()
gotm's avatar
gotm committed
553 554 555
#endif
#ifndef NO_ADVECT
#ifndef UV_ADV_DIRECT
kbk's avatar
kbk committed
556 557 558 559
      call slow_advection()
      if (Am .gt. _ZERO_) then
         call slow_diffusion(Am) ! Has to be called after slow_advection.
      end if
gotm's avatar
gotm committed
560 561 562
#endif
#endif
   end if
gotm's avatar
gotm committed
563

gotm's avatar
gotm committed
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
   call slow_terms()
   call stop_macro()

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

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: clean_3d - cleanup after 3D run.
!
! !INTERFACE:
   subroutine clean_3d()
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
!
! !INPUT/OUTPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
! !DESCRIPTION:
!  This routine cleans up after a 3D integration. Close open files etc.
!
! !REVISION HISTORY:
!  22Nov Author name Initial code
!
! !LOCAL VARIABLES:
!
!EOP
!-----------------------------------------------------------------------
!BOC
#ifdef DEBUG
   integer, save :: Ncall = 0
   Ncall = Ncall+1
   write(debug,*) 'clean_3d() # ',Ncall
#endif

   call clean_variables_3d()

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

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

   end module m3d

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