142
General Estuarine Transport Model Source Code and Test Case Documentation Hans Burchard 1,2 , Karsten Bolding 3 and Lars Umlauf 1 1: Baltic Sea Research Institute Warnem¨ unde, Germany 2: Bolding & Burchard Hydrodynamics, Rostock, Germany 3: Bolding & Burchard Hydrodynamics, Asperup, Denmark Version pre 1.6 March 19, 2010

Getm Doc Stable

Embed Size (px)

Citation preview

Page 1: Getm Doc Stable

General Estuarine Transport Model

Source Code and Test Case

Documentation

Hans Burchard1,2, Karsten Bolding3

and Lars Umlauf1

1: Baltic Sea Research Institute Warnemunde, Germany

2: Bolding & Burchard Hydrodynamics, Rostock, Germany3: Bolding & Burchard Hydrodynamics, Asperup, Denmark

Version pre 1.6

March 19, 2010

Page 2: Getm Doc Stable

2

Page 3: Getm Doc Stable

Contents

1 What’s new 7

2 Introduction 92.1 What is GETM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2 A short history of GETM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3 The physical equations behind GETM 113.1 Hydrodynamic equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3.1.1 Three-dimensional momentum equations . . . . . . . . . . . . . . . . . . . . 113.1.2 Kinematic boundary conditions and surface elevation equation . . . . . . . 123.1.3 Dynamic boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . 123.1.4 Lateral boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.2 GETM as slice model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

4 Transformations 134.1 General vertical coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2 Layer-integrated equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184.3 Horizontal curvilinear coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

5 Discretisation 215.1 Mode splitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.2 Spatial discretisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225.3 Lateral boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255.4 Bed friction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285.5 Drying and flooding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

6 Introduction to 2d module 316.1 Vertically integrated mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316.2 Module m2d - depth integrated hydrodynamical model (2D) (Source File: m2d.F90) 34

6.2.1 init 2d - initialise 2D related stuff. . . . . . . . . . . . . . . . . . . . . . . . 346.2.2 integrate 2d - sequence of calls to do 2D model integration . . . . . . . . . 356.2.3 clean 2d - cleanup after 2D run. . . . . . . . . . . . . . . . . . . . . . . . . 36

6.3 Module variables 2d - global variables for 2D model (Source File: variables 2d.F90) 376.3.1 init variables 2d - initialise 2D related stuff. . . . . . . . . . . . . . . . . . . 376.3.2 clean variables 2d - cleanup after 2D run. . . . . . . . . . . . . . . . . . . . 386.3.3 momentum - 2D-momentum for all interior points. . . . . . . . . . . . . . . 396.3.4 umomentum - 2D-momentum for all interior points. . . . . . . . . . . . . . 406.3.5 vmomentum - 2D-momentum for all interior points. . . . . . . . . . . . . . 416.3.6 uv advect - 2D advection of momentum . . . . . . . . . . . . . . . . . . . . 42

6.4 uv diffusion - 2D diffusion of momentum (Source File: uv diffusion.F90) . . . . . . 456.4.1 bottom friction - calculates the 2D bottom friction. . . . . . . . . . . . . . 476.4.2 sealevel - using the cont. eq. to get the sealevel. . . . . . . . . . . . . . . . 486.4.3 sealevel nan check - Sweep the sealevel (z) for NaN values . . . . . . . . . . 486.4.4 sealevel nandum. Helper routine to spot NaNs . . . . . . . . . . . . . . . . 496.4.5 depth update - adjust the depth to new elevations. . . . . . . . . . . . . . . 506.4.6 uv depths - calculate depths in u and v points. . . . . . . . . . . . . . . . . 506.4.7 update 2d bdy - update 2D boundaries every time step. . . . . . . . . . . . 51

6.5 cfl check - check for explicit barotropic time step. (Source File: cfl check.F90) . . . 536.5.1 have bdy - checks whether this node has boundaries. . . . . . . . . . . . . . 54

3

Page 4: Getm Doc Stable

6.6 do residual - barotropic residual currents. (Source File: residual.F90) . . . . . . . . 55

7 Introduction to 3d module 577.1 Overview over 3D routines in GETM . . . . . . . . . . . . . . . . . . . . . . . . . . 577.2 Tracer equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.3 Equation of state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607.4 Module m3d - 3D model component (Source File: m3d.F90) . . . . . . . . . . . . . 61

7.4.1 init 3d - initialise 3D related stuff . . . . . . . . . . . . . . . . . . . . . . . 627.4.2 integrate 3d - calls to do 3D model integration . . . . . . . . . . . . . . . . 637.4.3 clean 3d - cleanup after 3D run . . . . . . . . . . . . . . . . . . . . . . . . 64

7.5 Module variables 3d - global 3D related variables (Source File: variables 3d.F90) . 657.5.1 init variables 3d - initialise 3D related stuff . . . . . . . . . . . . . . . . . . 677.5.2 clean variables 3d - cleanup after 3D run. . . . . . . . . . . . . . . . . . . . 67

7.6 coordinates - defines the vertical coordinate (Source File: coordinates.F90) . . . . . 687.7 equidistant and zoomed sigma-coordinates (Source File: sigma coordinates.F90) . 707.8 general vertical coordinates (Source File: general coordinates.F90) . . . . . . . . . 727.9 hybrid vertical coordinates - (z-sigma) (Source File: hybrid coordinates.F90) . . . 747.10 adaptive vertical coordinates (Source File: adaptive coordinates.F90) . . . . . . . . 757.11 hcc check - hydrostatic consistency criteria (Source File: hcc check.F90) . . . . . . 767.12 uu momentum 3d - x-momentum eq. (Source File: uu momentum 3d.F90) . . . . 777.13 vv momentum 3d - y-momentum eq. (Source File: vv momentum 3d.F90) . . . . . 797.14 ww momentum 3d - continuity eq. (Source File: ww momentum 3d.F90) . . . . . 817.15 uv advect 3d - 3D momentum advection (Source File: uv advect 3d.F90) . . . . . 827.16 uv diffusion 3d - hor. momentum diffusion (Source File: uv diffusion 3d.F90) . . . 867.17 bottom friction 3d - bottom friction (Source File: bottom friction 3d.F90) . . . . . 887.18 Module internal pressure (Source File: internal pressure.F90) . . . . . . . . . . . . 89

7.18.1 init internal pressure - initialising internal pressure gradient . . . . . . . . . 907.18.2 do internal pressure - internal pressure gradient . . . . . . . . . . . . . . . . 90

7.19 ip blumberg mellor - (Source File: ip blumberg mellor.F90) . . . . . . . . . . . . . 927.20 ip blumberg mellor lin (Source File: ip blumberg mellor lin.F90) . . . . . . . . . . 937.21 ip z interpol (Source File: ip z interpol.F90) . . . . . . . . . . . . . . . . . . . . . 947.22 ip song wright (Source File: ip song wright.F90) . . . . . . . . . . . . . . . . . . . 957.23 ip chu fan (Source File: ip chu fan.F90) . . . . . . . . . . . . . . . . . . . . . . . . 967.24 Module 3D advection (Source File: advection 3d.F90) . . . . . . . . . . . . . . . . 97

7.24.1 init advection 3d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 987.24.2 do advection 3d - 3D advection schemes . . . . . . . . . . . . . . . . . . . 987.24.3 upstream adv - 3D upstream advection . . . . . . . . . . . . . . . . . . . . 1007.24.4 upstream 2dh adv - 2D upstream advection . . . . . . . . . . . . . . . . . . 1017.24.5 u split adv - 1D x-advection . . . . . . . . . . . . . . . . . . . . . . . . . . 1037.24.6 v split adv - 1D y-advection . . . . . . . . . . . . . . . . . . . . . . . . . . 1057.24.7 w split adv - 1D z-advection . . . . . . . . . . . . . . . . . . . . . . . . . . 1067.24.8 w split it adv - iterated 1D z-advection . . . . . . . . . . . . . . . . . . . . 1077.24.9 fct 2dh adv - 2D flux-corrected transport . . . . . . . . . . . . . . . . . . . 108

7.25 Module temperature (Source File: temperature.F90) . . . . . . . . . . . . . . . . . 1107.25.1 init temperature - initialisation of temperature . . . . . . . . . . . . . . . . 1107.25.2 do temperature - temperature equation . . . . . . . . . . . . . . . . . . . . 111

7.26 Module Salinity (Source File: salinity.F90) . . . . . . . . . . . . . . . . . . . . . . . 1137.26.1 init salinity - initialisation of salinity . . . . . . . . . . . . . . . . . . . . . . 1137.26.2 do salinity - salinity equation . . . . . . . . . . . . . . . . . . . . . . . . . 114

7.27 Module suspended matter (Source File: spm.F90) . . . . . . . . . . . . . . . . . . 116

4

Page 5: Getm Doc Stable

7.27.1 init spm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1177.27.2 do spm - suspended matter equation . . . . . . . . . . . . . . . . . . . . . 118

7.28 Module eqstate (Source File: eqstate.F90) . . . . . . . . . . . . . . . . . . . . . . . 1207.28.1 init eqstate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1207.28.2 do eqstate - equation of state . . . . . . . . . . . . . . . . . . . . . . . . . 121

7.29 ss nn - calculates shear and buoyancy frequency (Source File: ss nn.F90) . . . . . 1227.30 stresses 3d - bottom and surface stresses (Source File: stresses 3d.F90) . . . . . . . 1247.31 gotm - a wrapper to call GOTM (Source File: gotm.F90) . . . . . . . . . . . . . . 1257.32 Module rivers (Source File: rivers.F90) . . . . . . . . . . . . . . . . . . . . . . . . . 126

7.32.1 init rivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1277.32.2 init rivers bio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1287.32.3 do rivers - updating river points . . . . . . . . . . . . . . . . . . . . . . . . 1287.32.4 clean rivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

7.33 Module bdy 3d - 3D boundary conditions (Source File: bdy 3d.F90) . . . . . . . . 1307.33.1 init bdy 3d - initialising 3D boundary conditions . . . . . . . . . . . . . . . 1307.33.2 do bdy 3d - updating 3D boundary conditions . . . . . . . . . . . . . . . . 131

7.34 slow bottom friction - slow bed friction (Source File: slow bottom friction.F90) . . 1327.35 slow advection - slow advection terms (Source File: slow advection.F90) . . . . . . 1337.36 slow diffusion - slow diffusion terms (Source File: slow diffusion.F90) . . . . . . . . 1347.37 slow terms - calculation of slow terms (Source File: slow terms.F90) . . . . . . . . 1357.38 start macro - initialise the macro loop (Source File: start macro.F90) . . . . . . . 1367.39 stop macro - terminates the macro loop (Source File: stop macro.F90) . . . . . . . 137

Bibliography 139

5

Page 6: Getm Doc Stable

6

Page 7: Getm Doc Stable

1 What’s new

• 2006-03-27: v1.5.0

– Support for the Fortran XLF-compiler

7

Page 8: Getm Doc Stable

8

Page 9: Getm Doc Stable

2 Introduction

2.1 What is GETM?

2.2 A short history of GETM

The idea for GETM was born in May 1997 in Arcachon, France during a workshop of the PhaSEproject which was sponsored by the European Community in the framework of the MAST-IIIprogramme. It was planned to set up an idealised numerical model for the Eastern Scheldt,The Netherlands for simulating the effect of vertical mixing of nutrients on filter feeder growthrates. A discussion between the first author of this report, Peter Herman (NIOO, Yerseke, TheNetherlands) and Walter Eifler (JRC Ispra, Italy) had the result that the associated processeswere inherently three-dimensional (in space), and thus, only a three-dimensional model could givesatisfying answers. Now the question arose, which numerical model to use. An old wadden seamodel by Burchard (1995) including a two-equation turbulence model was written in z-coordinateswith fixed geopotential layers (which could be added or removed for rising and sinking sea surfaceelevation, respectively) had proven to be too noisy for the applications in mind. Furthermore, thestep-like bottom approximation typical for such models did not seem to be sufficient. Other PublicDomain models did not allow for drying and flooding of inter-tidal flats, such as the PrincetonOcean Model (POM). There was thus the need for a new model. Most of the ingredients werehowever already there. The first author of this report had already written a k-ε turbulence model,see Burchard and Baumert (1995), the forerunner of GOTM. A two-dimensional code for generalvertical coordinates had been written as well, see Burchard and Petersen (1997). And the firstauthor of this report had already learned a lot about mode splitting models from Jean-MarieBeckers (University of Liege, Belgium). Back from Arcachon in Ispra, Italy at the Joint ResearchCentre of the European Community, the model was basically written during six weeks, after whichan idealised tidal simulation for the Sylt-Rømø Bight in the wadden sea area between Germanyand Denmark could be successfully simulated, see Burchard (1998). By that time this model hadthe little attractive name MUDFLAT which at least well accounted for the models ability to dryand flood inter-tidal flats. At the end of the PhaSE project in 1999, the idealised simulation ofmussel growth in the Eastern Scheldt could be finished (not yet published, pers. comm. FrancoisLamy and Peter Herman).

In May 1998 the second author of this report joined the development of MUDFLAT. He firstfully rewrote the model from a one-file FORTRAN77 code to a modular FORTRAN90/95 code,made the interface to GOTM (such that the original k-ε model was not used any more), integratedthe netCDF-library into the model, and prepared the parallelisation of the model. And a newname was created, GETM, General Estuarine Transport Model. As already in GOTM, the word”General” does not imply that the model is general, but indicates the motivation to make it moreand more general.

At that time, GETM has actually been applied for simulating currents inside the Mururoa atollin the Pacific Ocean, see Mathieu et al. (2001).

During the year 2001, GETM was then extended by the authors of this report to be a fullybaroclinic model with transport of active and passive tracers, calculation of density, internal pres-sure gradient and stratification, surface heat and momentum fluxes and so forth. During a stay ofthe first author at the Universite Catholique de Louvain, Institut d’Astronomie et de GeophysiqueGeorge Lemaıtre, Belgium (we are grateful to Eric Deleersnijder for this invitation and manydiscussions) the high-order advection schemes have been written. During another invitation toBelgium, this time to the GHER at the Universite de Liege, the first author had the opportunityto discuss numerical details of GETM with Jean-Marie Beckers, who originally motivated us to usethe mode splitting technique.

9

Page 10: Getm Doc Stable

The typical challenging application in mind of the authors was always a simulation of thetidal Elbe, where baroclinicity and drying and flooding of inter-tidal flats play an important role.Furthermore, the tidal Elbe is long, narrow and bended, such that the use of Cartesian coordinateswould require an indexing of the horizontal fields, see e.g. Duwe (1988). Thus, the use of curvi-linear coordinates which follow the course of the river has already been considered for a longtime. However, the extensions just listed above, give the model also the ability to simulate shelfsea processes in fully baroclinic mode, such that the name General Estuarine Transport Model isalready a bit too restrictive.

10

Page 11: Getm Doc Stable

3 The physical equations behind GETM

3.1 Hydrodynamic equations

3.1.1 Three-dimensional momentum equations

For geophysical coastal sea and ocean dynamics, usually the three-dimensional hydrostatic equa-tions of motion with the Boussinesq approximation and the eddy viscosity assumption are used(Bryan (1969), Cox (1984), Blumberg and Mellor (1987), Haidvogel and Beckmann (1999), Kan-tha and Clayson (2000b)). In the flux form, the dynamic equations of motion for the horizontalvelocity components can be written in Cartesian coordinates as:

∂tu + ∂z(uw) − ∂z ((νt + ν)∂zu)

(

∂x(u2) + ∂y(uv) − ∂x

(

2AMh ∂xu

)

− ∂y

(

AMh (∂yu + ∂xv)

)

−fv −∫ ζ

z

∂xb dz′)

= −g∂xζ,

(1)

∂tv + ∂z(vw) − ∂z ((νt + ν)∂zv)

(

∂x(vu) + ∂y(v2) − ∂y

(

2AMh ∂yv

)

− ∂x

(

AMh (∂yu + ∂xv)

)

+fu −∫ ζ

z

∂xb dz′)

= −g∂yζ.

(2)

The vertical velocity is calculated by means of the incompressibility condition:

∂xu + ∂yv + ∂zw = 0. (3)

Here, u, v and w are the ensemble averaged velocity components with respect to the x, y and zdirection, respectively. The vertical coordinate z ranges from the bottom −H(x, y) to the surfaceζ(t, x, y) with t denoting time. νt is the vertical eddy viscosity, ν the kinematic viscosity, f theCoriolis parameter, and g is the gravitational acceleration. The horizontal mixing is parameterisedby terms containing the horizontal eddy viscosity AM

h , see Blumberg and Mellor (1987). Thebuoyancy b is defined as

b = −gρ− ρ0

ρ0(4)

with the density ρ and a reference density ρ0. The last term on the left hand sides of equations(1) and (2) are the internal (due to density gradients) and the terms on the right hand sides arethe external (due to surface slopes) pressure gradients. In the latter, the deviation of surfacedensity from reference density is neglected (see Burchard and Petersen (1997)). The derivation ofequations (1) - (3) has been shown in numerous publications, see e.g. Pedlosky (1987), Haidvogeland Beckmann (1999), Burchard (2002b).

In hydrostatic 3D models, the vertical velocity is calculated by means of equation (3) velocityequation. Due to this, mass conservation and free surface elevation can easily be obtained.

Drying and flooding of mud-flats is already incorporated in the physical equations by multiply-ing some terms with the non-dimensional number α which equals unity in regions where a critical

11

Page 12: Getm Doc Stable

water depth Dcrit is exceeded and approaches zero when the water depth D tends to a minimumvalue Dmin:

α = min

{

1,D − Dmin

Dcrit − Dmin

}

. (5)

Thus, α = 1 for D ≥ Dcrit, such that the usual momentum equation results except for veryshallow water, where simplified physics are considered with a balance between tendency, frictionand external pressure gradient. In a typical wadden sea application, Dcrit is of the order of 0.1 mand Dmin of the order of 0.02 m (see Burchard (1998), Burchard et al. (2004)).

3.1.2 Kinematic boundary conditions and surface elevation equation

At the surface and at the bottom, kinematic boundary conditions result from the requirement thatthe particles at the boundaries are moving along these boundaries:

w = ∂tζ + u∂xζ + v∂yζ for z = ζ, (6)

w = −u∂xH − v∂yH for z = −H. (7)

3.1.3 Dynamic boundary conditions

At the bottom boundaries, no-slip conditions are prescribed for the horizontal velocity components:

u = 0, v = 0. (8)

With (7), also w = 0 holds at the bottom. It should be noted already here, that the bottomboundary condition (8) is generally not directly used in numerical ocean models, since the near-bottom values of the horizontal velocity components are not located at the bed, but half a gridbox above it. Instead, a logarithmic velocity profile is assumed in the bottom layer, leading to aquadratic friction law, see section 7.17.

At the surface, the dynamic boundary conditions read:

(νt + ν)∂zu = ατxs ,

(νt + ν)∂zv = ατys ,

(9)

The surface stresses (normalised by the reference density) τxs and τy

s are calculated as functionsof wind speed, wind direction, surface roughness etc. Also here, the drying parameter α is includedin order to provide an easy handling of drying and flooding.

3.1.4 Lateral boundary conditions

Let G denote the lateral boundary of the model domain with the closed land boundary Gc andthe open boundary Go such that Gc ∪Go = G and Gc ∩Go = ∅. Let further ~u = (u, v) denote thehorizontal velocity vector and ~un = (−v, u) its normal vector. At closed boundaries, the flow mustbe parallel to the boundary:

~un · ~∇Gc = 0 (10)

with ~∇ = (∂x, ∂y) being the gradient operator.

12

Page 13: Getm Doc Stable

For an eastern or a western closed boundary with ~∇Gc = (0, 1) this has the consequence that

u = 0 and, equivalently, for a southern or a northern closed boundary with ~∇Gc = (1, 0) this hasthe consequence that v = 0.

At open boundaries, the velocity gradients across the boundary vanish:

~∇nu · ~∇Go = 0, ~∇nv · ~∇Go = 0, (11)

with ~∇n = (−∂y, ∂x) being the operator normal to the gradient operator.For an eastern or a western open boundary with this has the consequence that ∂xu = ∂xv = 0

and, equivalently, for a southern or a northern open boundary this has the consequence that∂yu = ∂yv = 0.

At so-called forced open boundaries, the sea surface elevation ζ is prescribed. At passive openboundaries, it is assumed that the curvature of the surface elevation normal to the boundary is zero,with the consequence that the spatial derivatives of the surface slopes normal to the boundariesvanish.

3.2 GETM as slice model

By chosing the compiler option SLICE_MODEL it is possible to operate GETM as a two-dimensionalvertical (xz-)model under the assumption that all gradients in y-direction vanish. In order to doso, a bathymetry file with a width of 4 grid points has to be generated, with the outer (j = 1,j = 4) bathymetry values set to land, and the two inner ones being independent on j. The compileroption SLICE_MODEL then sets the transports, velocities, and sea surface elevations such that theyare independent of y, i.e. they are forced to be identical for the same j-index. Especially, theV -transports and velocities in the walls (j = 1, j = 3) are set to the calculated value at indexj = 2.

4 Transformations

4.1 General vertical coordinates

As a preparation of the discretisation, the physical space is vertically divided into N layers. This isdone by introducing internal surfaces zk, k = 1, . . . , N − 1 which do not intersect, each dependingon the horizontal position (x, y) and time t. Let

−H(x, y) = z0(x, y) < z1(x, y, t) < · · · < zN−1(x, y, t) < zN (x, y, t) = ζ(x, y, t) (12)

define the local layer depths hk with

hk = zk − zk−1. (13)

for 1 ≤ k ≤ N . For simplicity, the argument (x, y, t) is omitted in most of the cases.The most simple layer distribution is given by the so-called σ transformation (see Phillips

(1957) for a first application in meteorology and Freeman et al. (1972) for a first application inhydrodynamics) with

σk =k

N− 1 (14)

and

zk = Dσk (15)

13

Page 14: Getm Doc Stable

for 0 ≤ k ≤ N .The σ-coordinates can also be refined towards the surface and the bed:

βk =tanh ((dl + du)(1 + σk) − dl) + tanh(dl)

tanh(dl) + tanh(du)− 1, k = 0, . . . , N (16)

such that z-levels are obtained as follows:

zk = Dβk (17)

for 0 ≤ k ≤ N .The grid is refined towards the surface for du > 0 and refined towards the bottom for dl > 0.

When both, du and dl are larger than zero, then refinement towards surface and bed is obtained.For du = dl = 0 the σ-transformation (14) with βk = σk is retained. Figure 1 shows four examplesfor vertical layer distributions obtained with the σ-transformation.

Due to the fact that all layer thicknesses are proportional to the water depth, the equidistant andalso the non-equidistant σ-transformations, (14) and (16), have however one striking disadvantage.In order to sufficiently resolve the mixed layer also in deep water, many layers have to be locatednear the surface. The same holds for the bottom boundary layer. This problem of σ-coordinateshas been discussed by several authors (see e.g. Deleersnijder and Ruddick (1992), de Kok (1992),Gerdes (1993), Song and Haidvogel (1994), Burchard and Petersen (1997)) who suggested methodsfor generalised vertical coordinates not resulting in layer thicknesses not proportional to the waterdepth.

The generalised vertical coordinate introduced here is a generalisation of the so-called mixed-layer transformation suggested by Burchard and Petersen (1997). It is a hybrid coordinate whichinterpolates between the equidistant and the non-equidistant σ-transformations given by (14) and(16). The weight for the interpolation depends on the ratio of a critical water depth Dγ (belowwhich equidistant σ-coordinates are used) and the actual water depth:

zk = D (αγσk + (1 − αγ)βk) (18)

with

αγ = min

(

(βk − βk−1) − Dγ

D (σk − σk−1)

(βk − βk−1) − (σk − σk−1), 1

)

. (19)

and σk from (14) and βk from (16).For inserting k = N in (19) and dl = 0 and du > 0 in (16), the mixed layer transformation

of Burchard and Petersen (1997) is retained, see the upper two panels in figure 2. Depending onthe values for Dγ and du, some near-surface layer thicknesses will be constant in time and space,allowing for a good vertical resolution in the surface mixed layer.

The same is obtained for the bottom with the following settings: k = 1, dl > 0 and du = 0,see the lower two panels in figure 2. This is recommended for reproducing sedimentation dynamicsand other benthic processes. For dl = du > 0 and k = 1 or k = N a number of layers near thesurface and near the bottom can be fixed to constant thickness. Intermediate states are obtainedby intermediate settings, see figure 3. Some pathological settings are also possible, such as k = 1,dl = 1.5 and du = 5, see figure 4.

The strong potential of the general vertical coordinates concept is the extendibility towardsvertically adaptive grids. Since the layers may be redistributed after every baroclinic time step,one could adapt the coordinate distribution to the internal dynamics of the flow. One could forexample concentrate more layers at vertical locations of high stratification and shear, or forcecertain layer interfaces towards certain isopycnals, or approximate Lagrangian vertical coordinates

14

Page 15: Getm Doc Stable

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

σ-coordinates, du = 0, dl = 0

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

σ-coordinates, du = 1.5, dl = 0

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

σ-coordinates, du = 0, dl = 1.5

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

σ-coordinates, du = 1.5, dl = 1.5

Figure 1: σ-transformation with four different zooming options. The plots show the vertical layerdistribution for a cross section through the North Sea from Scarborough in England to Esbjerg inDenmark. The shallow area at about x = 100 nm is the Doggerbank.

15

Page 16: Getm Doc Stable

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

upper γ-coordinates, du = 1.5, dl = 0

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

upper γ-coordinates, du = 5, dl = 0

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

lower γ-coordinates, du = 0, dl = 1.5

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

lower γ-coordinates, du = 0, dl = 5

Figure 2: Boundary layer transformation (or γ transformation) with concentration of layers in thesurface mixed layer (upper two panels) and with concentration of layers in the bottom mixed layer(lower two panels). The critical depth Dγ is here set to 20 m, such that at all shallower depthsthe equidistant σ-transformation is used. The same underlying bathymetry as in figure 1 has beenused.

16

Page 17: Getm Doc Stable

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

upper γ-coordinates, du = 5, dl = 1.5

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

lower γ-coordinates, du = 1.5, dl = 5

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

symmetric γ-coordinates, du = 1.5, dl = 1.5

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

symmetric γ-coordinates, du = 5, dl = 5

Figure 3: Boundary layer transformation (or γ transformation) with concentration of layers inboth, the surface mixed layer and the bottom mixed layer. Four different realisations are shown.The critical depth Dγ is here set to 20 m, such that at all shallower depths the equidistant σ-transformation is used. The same underlying bathymetry as in figure 1 has been used.

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

upper γ-coordinates, du = 1.5, dl = 5

-60

-50

-40

-30

-20

-10

0

0 50 100 150 200 250x / nm

z/

m

lower γ-coordinates, du = 5, dl = 1.5

Figure 4: Two pathological examples for the boundary layer transformation. The critical depthDγ is here set to 20 m, such that at all shallower depths the equidistant σ-transformation is used.The same underlying bathymetry as in figure 1 has been used.

17

Page 18: Getm Doc Stable

by minimising the vertical advection through layer interfaces. The advantages of this concept haverecently been demonstrated for one-dimensional water columns by Burchard and Beckers (2004).The three-dimensional generalisation of this concept of adaptive grids for GETM is currently underdevelopment.

4.2 Layer-integrated equations

There are two different ways to derive the layer-integrated equations. Burchard and Petersen(1997) transform first the equations into general vertical coordinate form (see Deleersnijder andRuddick (1992)) and afterwards integrate the transformed equations over constant intervals in thetransformed space. Lander et al. (1994) integrate the equations in the Cartesian space over surfaceszk by considering the Leibniz rule

∫ zk

zk−1

∂xf dz = ∂x

∫ zk

zk−1

f dz − f(zk)∂xzk + f(zk−1)∂xzk−1 (20)

for any function f . For the vertical staggering of the layer notation see figure 8.More details about the layer integration are given in Burchard and Petersen (1997).With the further definitions of layer integrated transport,

pk :=

∫ zk

zk−1

u dz, qk :=

∫ zk

zk−1

v dz, (21)

layer mean velocities,

uk :=pk

hk, vk :=

qk

hk, (22)

and layer averaged tracer concentrations and buoyancy,

cik :=

1

hk

∫ zk

zk−1

ci dz, bk :=1

hk

∫ zk

zk−1

b dz, (23)

and the grid related vertical velocity,

wk := (w − u∂xz − v∂yz)z=zk, (24)

the continuity equation (3) has the layer-integrated form:

∂thk + ∂xpk + ∂yqk + wk − wk−1 = 0. (25)

It should be noted that the grid related velocity is located on the layer interfaces. After this,the layer-integrated momentum equations read as:

∂tpk + wkuk − wk−1uk−1 − τxk + τx

k−1

{

∂x(ukpk) + ∂y(vkpk)

−∂x

(

2AMk hk∂xuk

)

− ∂y

(

AMk hk(∂yuk + ∂xvk)

)

− fqk

−hk

1

2hN (∂∗

xb)N +

N−1∑

j=k

1

2(hj + hj+1)(∂

∗xb)j

}

= −ghk∂xζ,

(26)

18

Page 19: Getm Doc Stable

∂tqk + wkvk − wk−1vk−1 − τyk + τy

k−1

{

∂x(ukqk) + ∂y(vkqk)

−∂y

(

2AMk hk∂yvk

)

− ∂x

(

AMk hk(∂yuk + ∂xvk)

)

+ fpk

−hk

1

2hN(∂∗

yb)N +N−1∑

j=k

1

2(hj + hj+1)(∂

∗yb)j

}

= −ghk∂yζ

(27)

with suitably chosen advective horizontal velocities uk and vk (see section 7.15) on page 82, theshear stresses

τxk = (νt∂zu)k , (28)

and

τyk = (νt∂zv)k , (29)

and the horizontal buoyancy gradients

(∂∗xb)k =

1

2(∂xbk+1 + ∂xbk) − ∂xzk

bk+1 − bk12 (hk+1 + hk)

(30)

and

(∂∗yb)k =

1

2(∂ybk+1 + ∂ybk) − ∂yzk

bk+1 − bk12 (hk+1 + hk)

. (31)

The layer integration of the pressure gradient force is discussed in detail by Burchard andPetersen (1997).

A conservative formulation can be derived for the recalculation of the physical vertical velocityw which is convenient in the discrete space if w is evaluated at the layer centres (see Deleersnijderand Ruddick (1992)):

wk =1

hk

(

∂t(hkzk−1/2) + ∂x(pkzk−1/2) + ∂y(qkzk−1/2) + wkzk − wk−1zk−1

)

. (32)

It should be mentioned that w only needs to be evaluated for post-processing reasons.

For the layer-integrated tracer concentrations, we obtain the following expression:

∂t(hkcik) + ∂x(pkci

k) + ∂y(qkcik) + (wk + ws

k)cik − (wk−1 + ws

k−1)cik−1

−(ν′t∂zc

i)k + (ν′t∂zc

i)k−1 − ∂x

(

ATk hk∂xci

k

)

− ∂y

(

ATk hk∂yci

k

)

= Qik.

(33)

It should be noted that the ”horizontal” diffusion does no longer occur along geopotential sur-faces but along horizontal coordinate lines. The properly transformed formulation would includesome cross-diagonal terms which may lead to numerical instabilities due to violation of mono-tonicity. For an in-depth discussion of this problem, see Beckers et al. (1998) and Beckers et al.(2000).

19

Page 20: Getm Doc Stable

4.3 Horizontal curvilinear coordinates

In this section, the layer-integrated equations from section 4 are transformed to horizontal orthog-onal curvilinear coordinates. Similarly to general coordinates in the vertical, these allow for muchmore flexibility when optimising horizontal grids to coast-lines and bathymetry. Furthermore, thistype of coordinates system includes spherical coordinates as a special case. The derivation of thetransformed equations is carried out here according to Haidvogel and Beckmann (1999), see alsoArakawa and Lamb (1977).

A rectangular domain with non-dimensional side lengths and with local Cartesian coordinatesX and Y is mapped to a physical domain with four corners in such a way that the local coordinatesof the physical space, (ξx, ξy) are orthogonal to each others everywhere:

X → ξx, Y → ξy. (34)

The infinitesimal increments in the physical space, d ξx and d ξy are related to the infinitesimalincrements in the transformed space, dX and dY by so-called metric coefficients m(x, y) andn(x, y):

d ξx =

(

1

m

)

dX , d ξy =

(

1

n

)

dY. (35)

These metric coefficients have the physical unit of [m−1]. With m = n =const, Cartesiancoordinates are retained, and with

m =1

rE cosφ, n =

1

rE, (36)

spherical coordinates with X = λ and Y = φ are retained (with the Earth’s radius rE , longitudeλ and latitude φ).

With these notations, the layer-integrated equations (25), (26), and (27) given in section 4 canbe formulated as follows:

Continuity equation:

∂t

(

hk

mn

)

+ ∂X

(pk

n

)

+ ∂Y

(qk

m

)

+wk − wk−1

mn= 0. (37)

Momentum in ξx direction:

∂t

( pk

mn

)

+wkuk − wk−1uk−1

mn− τX

k − τXk−1

mn

{

∂X

(ukpk

n

)

+ ∂Y

(vkpk

m

)

− qk

(

f

mn+ vk∂X

(

1

n

)

− uk∂Y

(

1

m

))

−∂X

(

2AMk hk

nm∂Xuk

)

− ∂Y

(

AMk hk

m(n∂Yuk + m∂X vk)

)

−hk

n

1

2hN (∂∗

X b)N +

N−1∑

j=k

1

2(hj + hj+1)(∂

∗X b)j

}

= −ghk

n∂X ζ.

(38)

20

Page 21: Getm Doc Stable

Momentum in ξy direction:

∂t

( qk

mn

)

+wkvk − wk−1vk−1

mn−

τYk − τY

k−1

mn

{

∂X

(ukqk

n

)

+ ∂Y

(vkqk

m

)

+ pk

(

f

mn+ vk∂X

(

1

n

)

− uk∂Y

(

1

m

))

−∂Y

(

2AMk hk

mn∂Yvk

)

− ∂X

(

AMk hk

n(n∂Yuk + m∂X vk)

)

−hk

m

1

2hN (∂∗

Yb)N +

N−1∑

j=k

1

2(hj + hj+1)(∂

∗Yb)j

}

= −ghk

m∂Yζ.

(39)

In (38) and (39), the velocity and momentum components uk and pk are now pointing into theξx-direction and vk and qk are pointing into the ξy-direction. The stresses τX

k and τYk are related to

these directions as well. In order to account for this rotation of the velocity and momentum vectors,the rotational terms due to the Coriolis rotation are extended by terms related to the gradients ofthe metric coefficients. This rotation is here not considered for the horizontal diffusion terms inorder not to unnecessarily complicate the equations. Instead we use the simplified formulation byKantha and Clayson (2000b), who argue that it does not make sense to use complex formulationsfor minor processes with highly empirical parameterisations.

Finally, the tracer equation is of the following form after the transformation to curvilinearcoordinates:

∂t

(

hkcik

mn

)

+ ∂X

(

pkcik

n

)

+ ∂Y

(

qkcik

m

)

+wk ci

k − wk−1cik−1

mn

− (ν′t∂zc

i)k − (ν′t∂zc

i)k−1

mn

−∂X

(

ATk hk

nm∂X ci

k

)

− ∂Y

(

ATk hk

mn∂Yci

k

)

=Qi

k

mn.

(40)

5 Discretisation

5.1 Mode splitting

The external system consisting of the surface elevation equation (56) and the transport equations(60) and (61) underlies a strict time step constraint if the discretisation is carried out explicitly:

∆t <

[

1

2

(

1

∆x+

1

∆y

)

2gD

]−1

. (41)

In contrast to that, the time step of the internal system is only depending on the Courantnumber for advection,

∆t < min

{

∆x

umax,

∆y

vmax

}

, (42)

21

Page 22: Getm Doc Stable

which in the case of sub-critical flow is a much weaker constraint. In order not to punish thewhole model with a small time step resulting from the external system, two different approachesof mode splitting have been developed in the past.

The first approach, in which the external mode is calculated implicitly, has been proposedby Madala and Piacsek (1977). This method is numerically stable (if advection is absent) forunconditionally long time steps. The temporal approximation is of second order if semi-implicittreatment is chosen. In such models, the external and internal mode are generally calculated withthe same time steps (see e.g. Backhaus (1985)). The introduction of interactions terms like (62) -(69) is thus not necessary in such models.

Another approach is to use different time steps for the internal (macro times steps ∆t) and theexternal mode (micro time steps ∆tm). One of the first free surface models which has adopted thismethod is the Princeton Ocean Model (POM), see Blumberg and Mellor (1987). This method hasthe disadvantage that interaction terms are needed for the external mode and that the consistencybetween internal and external mode is difficult to obtain. The advantage of this method is that thefree surface elevation is temporally well resolved which is a major requirement for models includingflooding and drying. That is the reason why this method is adopted here.

The micro time step ∆tm has to be an integer fraction M of the macro time step ∆t. ∆tm islimited by the speed of the surface waves (41), ∆t is limited by the current speed (42). The timestepping principle is shown in figure 5. The vertically integrated transports are averaged over eachmacro time step:

Un+1/2i,j =

1

M

n+(M−0.5)/M∑

l=n+0.5/M

U li,j (43)

and

Vn+1/2i,j =

1

M

n+(M−0.5)/M∑

l=n+0.5/M

V li,j (44)

such that

ζn+1i,j − ζn

i,j

∆t= −

Un+1/2i,j − U

n+1/2i−1,j

∆x−

Vn+1/2i,j − V

n+1/2i,j−1

∆y. (45)

5.2 Spatial discretisation

For the spatial discretisation, a staggered C-grid is used, see Arakawa and Lamb (1977). The gridconsists of prism-shaped finite volumes with the edges aligned with coordinates. The referencegrid for the tracer points (from now on denoted by T-points) is shown in figures 6 and 8. Thevelocity points are located such that the corresponding velocity components are centralised on thesurfaces of the T-point reference box, the u-velocity points (from now on U-points) at the westernand eastern surfaces, the v-velocity points (from now on V-points) at the southern and northernsurfaces and the w-velocity points (from now on W-points) at the lower and upper surfaces. Theindexing is carried out with i-indices in eastern (X -) direction, with j-indices in northern (Y-)direction and with k-indices in upward (z-) direction, such that each grid point is identified by atriple (i, j, k). A T-point and the corresponding eastern U-point, the northern V-point and theabove W-point have always the same index, see figures 6 and 8. The different grid points cover thefollowing index ranges:

22

Page 23: Getm Doc Stable

n+1n+1/2nn-1/2n-1

Micro

Macro

ζ

u,v,w,U,V

U,V

ζ

Macro time step

Micro time step

Figure 5: Sketch explaining the organisation of the time stepping.

?????

?????

?????

?????

?????

?????

++++

++++

++++

++++

++++

++++

����

����

����

����

����

����

����

uuuuu

uuuuu

uuuuu

uuuuu

uuuuu

uuuuu

uuuuu

! i" jFigure 6: Layout of the model horizontal model grid in Cartesian coordinates. Shown are thereference boxes for the T-points. The following symbols are used: +: T-points; ×: U-points; ⋆:V-points; •: X-points. The inserted box denotes grid points with the same index (i, j).

23

Page 24: Getm Doc Stable

(xi−1,j , yi−1,j)(xi,j , yi,j)

(xi,j−1, yi,j−1)

(xi−1,j−1, yi−1,j−1)

Figure 7: Grid layout and indexing of corner points for curvilinear grids.

T-points: 1 ≤ i ≤ imax, 1 ≤ j ≤ jmax, 1 ≤ k ≤ kmax

U-points: 0 ≤ i ≤ imax, 1 ≤ j ≤ jmax, 1 ≤ k ≤ kmax

V-points: 1 ≤ i ≤ imax, 0 ≤ j ≤ jmax, 1 ≤ k ≤ kmax

W-points: 1 ≤ i ≤ imax, 1 ≤ j ≤ jmax, 0 ≤ k ≤ kmax

(46)

On the T-points, all tracers such as temperature T , salinity S, the general tracers ci and thedensity are located. All turbulent quantities such as eddy viscosity νt and eddy diffusivity ν′

t arelocated on the W-points.

For curvilinear grids, several arrays for spatial increments ∆x and ∆y have to be defined:

24

Page 25: Getm Doc Stable

∆xci,j =

12 (Xi,j−1 + Xi,j − Xi−1,j−1 − Xi−1,j)

∆xui,j =

14 (Xi+1,j−1 + Xi+1,j − Xi−1,j−1 − Xi−1,j)

∆xvi,j = ||Xi,j − Xi−1,j ||

∆x+i,j =

12 (Xi+1,j − Xi−1,j)

∆yci,j =

12 (Xi−1,j + Xi,j − Xi−1,j−1 − Xi,j−1)

∆yui,j = ||Xi,j − Xi,j−1||

∆yvi,j =

14 (Xi−1,j+1 + Xi,j+1 − Xi−1,j−1 − Xi,j−1)

∆y+i,j =

12 (Xi,j+1 − Xi,j−1)

(47)

where ||Xi,j − Xi−1,j || =(

(xi,j − xi−1,j)2 + (yi,j − yi−1,j)

2)1/2

. The superscripts c, u, v, + in(47) indicate whether a ∆x or ∆y is centrered at a T-, U-, V-, or X-point, respectively. For thelocations of the corner points Xi,j = (xi,j , yi,j), see figure 7.

5.3 Lateral boundary conditions

Usually, a land mask is defined on the horizontal numerical grid. This mask is denoted by az forT-points, au for U-points and av for V-points with az, au, and av being integer fields. A T-pointis either a land point (az = 0) or a water point (az > 0). All U- and V-points surrounding a landpoint are defined as closed boundary and masked out: au = 0 and av = 0. The velocities on suchclosed boundaries are always set to 0.

Open boundaries are defined by az > 1 for T-points. Forced boundary points are marked byaz = 2 and passive boundary points by az = 3. All other T-points are characterised by az = 1. Forvelocity points, three different types are defined at the open boundaries. U-points are classified byau = 3 if both the T-points east and west are open boundary points and by au = 2 if one adjacentT-point is an open boundary point and the other an open water point with az = 1. The same iscarried out for V-points: They are classified by av = 3 if both the T-points south and north areopen boundary points and by av = 2 if one adjacent T-point is an open boundary point and theother an open water point with az = 1. U-points which are adjacent to T-points with az = 2 andwhich are not denoted by au = 2 or au = 3 are the external U-points and are denoted by au = 4.The same holds for V-points: Those which are adjacent to T-points with az = 2 and which are notdenoted by av = 2 or av = 3 are the external V-points and are denoted by av = 4.

For a simple example of grid point classification, see figure 9.

When the barotropic boundary forcing is carried out by means of prescribed surface elevationsonly, then the surface elevation ζ is prescribed in all T-points with az = 2. For passive boundaryconditions (az = 3), where the curvature of the surface elevation is zero normal to the boundary,the surface slope is simply extrapolated to the boundary points. For a boundary point (i, j) at thewestern boundary this results e.g. in the following calculation for the boundary point:

ζi,j = ζi+1,j + (ζi+1,j − ζi+2,j) = 2ζi+1,j − ζi+2,j . (48)

25

Page 26: Getm Doc Stable

44444 44444 44444

44444

44444

44444++++ ++++ ++++ +++

+++++

++++

���� ���� ���� ���� ����

����

����

eeeee eeeee eeeee eeeee

eeeee

eeeee

eeeee

! i" kFigure 8: Layout of the model vertical model grid through the U-points. Shown are the referenceboxes for the T-points. The following symbols are used: +: T-points; ×: U-points; △: W-points;◦: Xu-points. The inserted box denotes grid points with the same index (i, k). The grid in the(j, k)-plane through the V-points is equivalent.

26

Page 27: Getm Doc Stable

2

2

2

2

0

2

1

1

1

0

2

1

1

1

0

2

1

1

1

0

0

0

0

0

0

4

4

4

4

0

3

2

2

2

0

3

1

1

1

0

3

1

1

1

0

0

0

0

0

0

0

0

0

0

0

4

3

3

3

0

0

4

2

1

1

0

0 0

4

2

1

1

0

0

4

2

1

1

0

0

0

0

0

0

0

0

Figure 9: Classification of grid points for a simple 5 × 5 configuration (imax = jmax = 5). Onthe locations for T-, U- and V-points, the values of az, au, and av, respectively, are written. Thenorthern and eastern boundaries are closed and the western and southern boundaries are open andforced.

27

Page 28: Getm Doc Stable

5.4 Bed friction

As already mentioned earlier in section 3.1.3, caution is needed when discretising the bottomboundary conditions for momentum, (8). They are an example for a physical condition whichhas to be modified for the numerical discretisation, since the discrete velocity point nearest tothe bottom is half a grid box away from the point where the boundary condition is defined.Furthermore, due to the logarithmic law, high velocity gradients are typical near the bed. Simplysetting the discrete bottom velocity to zero, would therefore lead to large discretisation errors.Instead, a flux condition using bottom stresses is derived from the law of the wall.

For the determination of the normalised bottom stresses

τxb

ρ0= ubx

∗ ub∗, (49)

τyb

ρ0= uby

∗ ub∗ (50)

with the friction velocities ub∗ =

τb/ρ0 with τb =√

(τxb )2 + (τy

b )2, assumptions about thestructure of velocity inside the discrete bottom layer have to be made. We use here the logarithmicprofile

u(z′)

u∗

=1

κln

(

z′ + zb0

zb0

)

, (51)

with the bottom roughness length zb0, the von Karman constant κ = 0.4 and the distance from

the bed, z′. Therefore, estimates for the velocities in the centre of the bottom layer can be achievedby:

ub =ubx∗

κln

(

0.5h1 + zb0

zb0

)

, (52)

vb =uby∗

κln

(

0.5h1 + zb0

zb0

)

. (53)

For h1 → 0, the original Dirichlet-type no-slip boundary conditions (8) are retained. Anotherpossibility would be to specify the bottom velocities ub and vb such that they are equal to the layer-averaged log-law velocities (see Baumert and Radach (1992)). The calculation of this is howeverslightly more time consuming and does not lead to a higher accuracy.

5.5 Drying and flooding

The main requirement for drying and flooding is that the vertically integrated fluxes U and V arecontrolled such that at no point a negative water depth occurs. It is clear that parts of the physicswhich play an important role in very shallow water of a few centimetres depth like non-hydrostaticeffects are not included in the equations. However, the model is designed in a way that the controlof U and V in very shallow water is mainly motivated by the physics included in the equationsrather than by defining complex drying and flooding algorithms. It is assumed that the majorprocess in this situation is a balance between pressure gradient and bottom friction. Therefore, inthe case of very shallow water, all other terms are multiplied with the non-dimensional factor αwhich approaches zero when a minimum water depth is reached.

By using formulation (70) for calculating the bottom drag coefficient R, it is guaranteed that Ris exponentially growing if the water depth approaches very small values. This slows the flow down

28

Page 29: Getm Doc Stable

Virtual sea surface elevation

Actual sea surface elevation

Bathymetry approximation

��−Hi,j

ζi,j@@

−Hi,j + Hmin

ζi+1,j

ζi+1,j

−Hi+1,j

Figure 10: Sketch explaining the principle of pressure gradient minimisation during drying andflooding over sloping bathymetry.

29

Page 30: Getm Doc Stable

when the water depth in a velocity point is sinking and also allows for flooding without furthermanipulation.

In this context, one important question is how to calculated the depth in the velocity points,Hu and Hv, since this determines how shallow the water in the velocity points may become onsloping beaches. In ocean models, usually, the depth in the velocity points is calculated as themean of depths in adjacent elevation points (T-points):

Hui,j =

1

2(Hi,j + Hi+1,j) , Hv

i,j =1

2(Hi,j + Hi,j+1) . (54)

Other models which deal with drying and flooding such as the models of Duwe (1988) andCasulli and Cattani (1994) use the minimum of the adjacent depths in the T-points:

Hui,j = min{Hi,j , Hi+1,j}, Hv

i,j = min{Hi,j, Hi,j+1}. (55)

This guarantees that all depths in the velocity points around a T-point are not deeper than thedepth in the T-point. Thus, when the T-point depth is approaching the minimum depth, then alldepths in the velocity points are also small and the friction coefficient correspondingly large.

Each of the methods has however drawbacks: When the mean is taken as in (54), the risk ofnegative water depths is relatively big, and thus higher values of Dmin have to be chosen. Whenthe minimum is taken, large mud-flats might need unrealistically long times for drying since allthe water volume has to flow through relatively shallow velocity boxes. Also, velocities in theseshallow boxes tend to be relatively high in order to provide sufficient transports. This might leadto numerical instabilities.

Therefore, GETM has both options, (54) and (55) and the addition of various other options suchas depth depending weighting of the averaging can easily be added. These options are controlledby the GETM variable vel_depth_method, see section 6.4.6 (subroutine uv_depths) documentedon page 50.

If a pressure point is dry (i.e. its bathymetry value is higher than a neighbouring sea surfaceelevation), the pressure gradient would be unnaturally high with the consequence of unwanted flowacceleration. Therefore this pressure gradient will be manipulated such that (only for the pressuregradient calculation) a virtual sea surface elevation ζ is assumed (see figure 10). In the situationshown in figure 10, the left pressure point is dry, and the sea surface elevation there is for numericalreasons even slightly below the critical value −Hi,j +Hmin. In order not to let more water flow outof the left cell, the pressure gradient between the two boxes shown is calculated with a manipulatedsea surface elevation on the right, ζi+1,j .

See also Burchard et al. (2004) for a description of drying and flooding numerics in GETM.

30

Page 31: Getm Doc Stable

6 Introduction to 2d module

In the 2D module of GETM the vertically integrated mode is calculated, which is basically the ver-tically integrated momentum equations and the sea surface elevation equation. For the momentumequations, interaction terms with the baroclinic three-dimentional mode need to be considered.Those terms are here called the slow terms.

6.1 Vertically integrated mode

In order to provide the splitting of the model into an internal and an external mode, the continuityequation and the momentum equations are vertically integrated. The vertical integral of thecontinuity equation together with the kinematic boundary conditions (6) and (7) gives the seasurface elevation equation:

∂tζ = −∂xU − ∂yV. (56)

with

U =

∫ ζ

−H

u dz, V =

∫ ζ

−H

v dz. (57)

Integrating the momentum equations (1) and (2) vertically results in:

∂tU + τxb + α

(∫ ζ

−H

(

∂xu2 + ∂y(uv))

dz

−τxs −

∫ ζ

−H

(

∂x

(

2AMh ∂xu

)

− ∂y

(

AMh (∂yu + ∂xv)

) )

dz

−fV −∫ ζ

−H

∫ ζ

z

∂xb dz′ dz

)

= −gD∂xζ

(58)

and

∂tV + τyb + α

(∫ ζ

−H

(

∂x(uv) + ∂yv2)

) dz

−τys −

∫ ζ

−H

(

∂y

(

2AMh ∂yv

)

− ∂x

(

AMh (∂yu + ∂xv)

) )

dz

+fU −∫ ζ

−H

∫ ζ

z

∂yb dz′ dz

)

= −gD∂yζ.

(59)

Here, τxb and τy

b are bottom stresses. Their calculation is discussed in section 7.17. As a firstpreparation for the mode splitting, these integrals of the momentum equations can be formallyrewritten as

31

Page 32: Getm Doc Stable

∂tU +R

D2U√

U2 + V 2 + SxF + α

(

∂x

(

U2

D

)

+ ∂y

(

UV

D

)

−τxs − ∂x

(

2AMh D∂x

(

U

D

))

− ∂y

(

AMh D

(

∂y

(

U

D

)

+ ∂x

(

V

D

)))

−fV + SxA − Sx

D + SxB

)

= −gD∂xζ

(60)

and

∂tV +R

D2V√

U2 + V 2 + SyF + α

(

∂xUV

D+ ∂y

V 2

D

−τys − ∂x

(

AMh D

(

∂y

(

U

D

)

+ ∂x

(

V

D

)))

− ∂y

(

2AMh D∂y

(

V

D

))

+fU + SyA − Sy

D + SyB

)

= −gD∂yζ

(61)

with the so-called slow terms for bottom friction

SxF = τx

b − R

D2U√

U2 + V 2, (62)

SyF = τy

b − R

D2V√

U2 + V 2, (63)

horizontal advection

SxA =

∫ ζ

−H

(

∂xu2 + ∂y(uv))

dz − ∂x

(

U2

D

)

− ∂y

(

UV

D

)

, (64)

SyA =

∫ ζ

−H

(

∂x(uv) + ∂yv2)

dz − ∂x

(

UV

D

)

− ∂y

(

fracV 2D)

, (65)

horizontal diffusion

SxD =

∫ ζ

−H

(

∂x

(

2AMh ∂xu

)

− ∂y

(

AMh (∂yu + ∂xv)

) )

dz

−∂x

(

2AMh D∂x

(

U

D

))

− ∂y

(

AMh D

(

∂y

(

U

D

)

+ ∂x

(

V

D

)))

,

(66)

SyD =

∫ ζ

−H

(

∂y

(

2AMh ∂yv

)

− ∂x

(

AMh (∂yu + ∂xv)

) )

dz

−∂y

(

2AMh D∂y

(

V

D

))

− ∂x

(

AMh D

(

∂y

(

U

D

)

+ ∂x

(

V

D

)))

,

(67)

and internal pressure gradients

SxB = −

∫ ζ

−H

∫ ζ

z

∂xb dz′ dz (68)

32

Page 33: Getm Doc Stable

and

SyB = −

∫ ζ

−H

∫ ζ

z

∂yb dz′ dz. (69)

The drag coefficient R for the external mode is calculated as (this logarithmic dependence ofthe bottom drag from the water depth and the bottom roughness parameter z0

b is discussed indetail by Burchard and Bolding (2002)):

R =

κ

ln(

D2

+zb0

zb0

)

2

. (70)

It should be noted that for numerical reasons, an additional explicit damping has been imple-mented into GETM. This method is based on diffusion of horizontal transports and is describedin section 6.4 on page 45.

33

Page 34: Getm Doc Stable

6.2 Module m2d - depth integrated hydrodynamical model (2D) (SourceFile: m2d.F90)

INTERFACE:

module m2d

DESCRIPTION:

This module contains declarations for all variables related to 2D hydrodynamical calculations.Information about the calculation domain is included from the domain module. The modulecontains public subroutines for initialisation, integration and clean up of the 2D model component.The actual calculation routines are called in integrate_2d and are linked in from the librarylib2d.a.

USES:

use time, only: julianday,secondsofdayuse parameters, only: avmmoluse domain, only: imin,imax,jmin,jmax,az,au,av,H,HU,HV,min_depthuse domain, only: z0_method,z0_const,z0use halo_zones, only : update_2d_halo,wait_halouse halo_zones, only : U_TAG,V_TAG,H_TAGuse variables_2dIMPLICIT NONE

PUBLIC DATA MEMBERS:

logical :: have_boundariesREALTYPE :: dtm,Am=-_ONE_,An=-_ONE_integer :: MM=1,residual=-1integer :: sealevel_check=0logical :: bdy2d=.false.integer :: bdyfmt_2d,bdytype,bdyramp_2d=-1character(len=PATH_MAX) :: bdyfile_2dREAL_4B :: bdy_old(1500)REAL_4B :: bdy_new(1500)REAL_4B :: bdy_data(1500)REAL_4B, allocatable :: bdy_times(:)integer, parameter :: comm_method=-1

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

6.2.1 init 2d - initialise 2D related stuff.

INTERFACE:

subroutine init_2d(runtype,timestep,hotstart)IMPLICIT NONE

34

Page 35: Getm Doc Stable

INPUT PARAMETERS:

integer, intent(in) :: runtypeREALTYPE, intent(in) :: timesteplogical, intent(in) :: hotstart

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

DESCRIPTION:

Here, the m2d namelist is read from getm.inp, and the check for the fulfilment of the CFL criteriumfor shallow water theory cfl_check is called. A major part of this subroutine deals then with thesetting of local bathymetry values and initial surface elevations in u- and v-points, also by calls tothe subroutines uv_depths and depth_update.

LOCAL VARIABLES:

integer :: rcinteger :: i,jinteger :: vel_depth_method=0namelist /m2d/ &

MM,vel_depth_method,Am,An,residual,sealevel_check, &bdy2d,bdyfmt_2d,bdyramp_2d,bdyfile_2d

6.2.2 integrate 2d - sequence of calls to do 2D model integration

INTERFACE:

subroutine integrate_2d(runtype,loop,tausx,tausy,airp)IMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: runtype,loopREALTYPE, intent(in) :: tausx(E2DFIELD)REALTYPE, intent(in) :: tausy(E2DFIELD)REALTYPE, intent(in) :: airp(E2DFIELD)

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

DESCRIPTION:

Here, all 2D related subroutines are called. The major calls and their meaning are:

35

Page 36: Getm Doc Stable

call update_2d_bdy read in new lateral boundary conditionscall bottom_friction update bottom frictioncall uv_advect calculate 2D advection termscall uv_diffusion calculate 2D diffusion termscall momentum iterate 2D momemtum equationscall sealevel update sea surface elevationcall depth_update update water depthscall do_residual calculate intermdediate values for residual currents

It should be noted that some of these calls may be excluded for certain compiler options set in theMakefile of the application.

LOCAL VARIABLES:

6.2.3 clean 2d - cleanup after 2D run.

INTERFACE:

subroutine clean_2d()IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

DESCRIPTION:

This routine executes a final call to do_residual where the residual current calculations are fin-ished.

LOCAL VARIABLES:

36

Page 37: Getm Doc Stable

6.3 Module variables 2d - global variables for 2D model (Source File:variables 2d.F90)

INTERFACE:

module variables_2d

DESCRIPTION:

This modules contains declarations for all variables related to 2D hydrodynamical calculations.Information about the calculation domain is included from the domain module. The modulecontains public subroutines to initialise and cleanup. Depending whether the compiler optionSTATIC is set or not, memory for 2D variables is statically or dynamically allocated, see PUBLICDATA MEMBERS.

USES:

use domain, only: imin,imax,jmin,jmax,H,HU,HV,min_depthIMPLICIT NONE

PUBLIC DATA MEMBERS:

#ifdef STATIC#include "static_2d.h"#else#include "dynamic_declarations_2d.h"#endif

integer :: size2d_fieldinteger :: mem2d

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

integer :: rc

6.3.1 init variables 2d - initialise 2D related stuff.

INTERFACE:

subroutine init_variables_2d(runtype)IMPLICIT NONE

DESCRIPTION:

Allocates memory (unless STATIC is set) for 2D related fields, by an include statement. Furthermoreall public 2D variables are initialised to zero. Those are listed in table 1 on page 38.

INPUT PARAMETERS:

integer, intent(in) :: runtype

INPUT/OUTPUT PARAMETERS:

37

Page 38: Getm Doc Stable

z sea surface elevation in T-point [m]zu sea surface elevation in U-point [m]zv sea surface elevation in V-point [m]U x component of transport in U-point [m2s−1]DU water depth in U-point [m]fU Coriolis term for V -equation in V-point [m2s−2]SlUx slow term for U -equation in U-point [m2s−2]Slru slow bottom friction for U -equation in U-point [m2s−2]V y component of transport in V-point [m2s−1]DV water depth in V-point [m]fV Coriolis term for U -equation in U-point [m2s−2]SlVx slow term for V -equation in V-point [m2s−2]Slrv slow bottom friction for V -equation in V-point [m2s−2]Uint x-component of mean transport in U-point [m2s−1]Vint y-component of mean transport in V-point [m2s−1]UEx sum of explicit terms for for U -equation in U-point [m2s−2]VEx sum of explicit terms for for V -equation in V-point [m2s−2]ru bottom friction for U -equation in U-point [m2s−2]rv bottom friction for V -equation in V-point [m2s−2]res_du residual depth in U-point [m]res_u x-component of residual transport in U-point [m2s−1]res_dv residual depth in V-point [m]res_v y-component of residual transport in V-point [m2s−1]surfdiv divergence of surface currents in T-point [s−1]

Table 1: Public 2D variables.

OUTPUT PARAMETERS:

LOCAL VARIABLES:

6.3.2 clean variables 2d - cleanup after 2D run.

INTERFACE:

subroutine clean_variables_2d()IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

38

Page 39: Getm Doc Stable

OUTPUT PARAMETERS:

DESCRIPTION:

This routine is currently empty.

LOCAL VARIABLES:

6.3.3 momentum - 2D-momentum for all interior points.

INTERFACE:

subroutine momentum(n,tausx,tausy,airp)

DESCRIPTION:

This small routine calls the U -equation and the V -equation in an alternating sequence (UVVU-UVVUUVVU), in order to provide higher accuracy and energy conservation for the explicit nu-merical treatment of the Coriolis term.

USES:

use domain, only: imin,imax,jmin,jmaxIMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: nREALTYPE, intent(in) :: tausx(E2DFIELD)REALTYPE, intent(in) :: tausy(E2DFIELD)REALTYPE, intent(in) :: airp(E2DFIELD)

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

logical :: ufirst=.false.

39

Page 40: Getm Doc Stable

6.3.4 umomentum - 2D-momentum for all interior points.

INTERFACE:

subroutine umomentum(tausx,airp)

DESCRIPTION:

Here, the vertically integrated U -momentum equation (60) given on page 32 including a number ofslow terms is calculated. One slight modification is that for better stability of drying and floodingprocesses the slow friction term Sx

F is now also multiplied with the parameter α defined in eq. (5).Furthermore, the horizontal pressure gradient ∂∗

xζ is modified in order to support drying andflooding, see figure 10 on page 29 and the explanations in section 5.5. ∂∗

xζ is now also consideringthe atmospheric pressure gradient at sea surface height.For numerical stability reasons, the U -momentum equation is here discretised in time such thatthe bed friction is treated explicitely:

Un+1 =Un − ∆tm(gD∂∗

xζ + α(− τsx

ρ0

− fV n + UEx + SxA − Sx

D + SxB + Sx

F ))

1 + ∆tmR

D2

(Un)2 + (V n)2, (71)

with UEx combining advection and diffusion of U , see routines uv_advect (section 6.3.6 on page42) and uv_diffusion (section 6.4 on page 45). The slow terms are calculated in the routineslow_terms documented in section 7.37 on page 135. In (71), Un+1 denotes the transport on thenew and Un and V n the transports on the old time level.The Coriolis term fU for the subsequent V -momentum is also calculated here, by directly inter-polating the U -transports to the V-points or by a method suggested by Espelid et al. (2000) whichtakes the varying water depths into account.Some provisions for proper behaviour of the U -transports when GETM runs as slice model aremade as well, see section 3.2 on page 13.

USES:

use parameters, only: g,rho_0use domain, only: imin,imax,jmin,jmaxuse domain, only: H,au,av,min_depth,dry_u,Cori,corv

#if defined(SPHERICAL) || defined(CURVILINEAR)use domain, only: dxu,arvd1,dxc,dyxuse variables_2d, only: V

#elseuse domain, only: dx

#endifuse m2d, only: dtmuse variables_2d, only: D,z,UEx,U,DU,fV,SlUx,SlRu,ru,fU,DVuse halo_zones, only : update_2d_halo,wait_halo,U_TAGIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: tausx(E2DFIELD),airp(E2DFIELD)

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

40

Page 41: Getm Doc Stable

LOCAL VARIABLES:

integer :: i,jREALTYPE :: zx(E2DFIELD)REALTYPE :: Slr(E2DFIELD),tausu(E2DFIELD)REALTYPE :: zp,zm,Uloc,UoldREALTYPE :: gamma=rho_0*gREALTYPE :: cord_curv=_ZERO_

6.3.5 vmomentum - 2D-momentum for all interior points.

INTERFACE:

subroutine vmomentum(tausy,airp)

DESCRIPTION:

Here, the vertically integrated V -momentum equation (61) given on page 32 including a number ofslow terms is calculated. One slight modification is that for better stability of drying and floodingprocesses the slow friction term Sy

F is now also multiplied with the parameter α defined in eq. (5).Furthermore, the horizontal pressure gradient ∂∗

yζ is modified in order to support drying andflooding, see figure 10 on page 29 and the explanations in section 5.5. ∂∗

yζ is now also consideringthe atmospheric pressure gradient at sea surface height.For numerical stability reasons, the V -momentum equation is here discretised in time such thatthe bed friction is treated explicitely:

V n+1 =V n − ∆tm(gD∂∗

yζ + α(− τsy

ρ0

+ fUn + VEx + SyA − Sy

D + SyB + Sy

F ))

1 + ∆tmRD2

(Un)2

+ (V n)2

, (72)

with VEx combining advection and diffusion of V , see routines uv_advect (section 6.3.6 on page42) and uv_diffusion (section 6.4 on page 45). The slow terms are calculated in the routineslow_terms documented in section 7.37 on page 135. In (72), V n+1 denotes the transport on thenew and Un and V n the transports on the old time level.The Coriolis term fV for the subsequent U -momentum is also calculated here, by directly inter-polating the U -transports to the U-points or by a method suggested by Espelid et al. (2000) whichtakes the varying water depths into account.Some provisions for proper behaviour of the V -transports when GETM runs as slice model aremade as well, see section 3.2 on page 13.

USES:

use parameters, only: g,rho_0use domain, only: imin,imax,jmin,jmaxuse domain, only: H,au,av,min_depth,dry_v,Cori,coru

#if defined(SPHERICAL) || defined(CURVILINEAR)use domain, only: dyv,arud1,dxx,dycuse m2d, only: U

#elseuse domain, only: dy

#endif

41

Page 42: Getm Doc Stable

use m2d, only: dtmuse variables_2d, only: D,z,VEx,V,DV,fU,SlVx,SlRv,rv,fV,DUuse halo_zones, only : update_2d_halo,wait_halo,V_TAGIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: tausy(E2DFIELD),airp(E2DFIELD)

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,jREALTYPE :: zy(E2DFIELD)REALTYPE :: Slr(E2DFIELD),tausv(E2DFIELD)REALTYPE :: zp,zm,VlocREALTYPE :: gamma=rho_0*gREALTYPE :: cord_curv=_ZERO_

6.3.6 uv advect - 2D advection of momentum

INTERFACE:

subroutine uv_advect

DESCRIPTION:

The advective terms in the vertically integrated momentum equation are discretised in a momentum-conservative form. This is carried out here for the advective terms in the U -equation (60) and theV -equation (61) (after applying the curvilinear coordinate transformationand multiplying theseequations with mn).First advection term in (60):

(

mn ∂X

(

U2

Dn

))

i,j

12 (Ui+1,j + Ui,j)ui+1,j∆yc

i+1,j − 12 (Ui,j + Ui−1,j)ui,j∆yc

i,j

∆xui,j∆yu

i,j

(73)

For the upwind scheme used here, the inter-facial velocities which are defined on T-points are herecalculated as:

ui,j =

Ui−1,j

Dui−1,j

for 12 (Ui,j + Ui−1,j) > 0

Ui,j

Dui,j

else.

(74)

42

Page 43: Getm Doc Stable

Second advection term in (60):(

mn ∂Yy

(

UV

Dm

))

i,j,k

12 (Vi+1,j + Vi,j)ui,j∆x+

i,j − 12 (Vi+1,j−1 + Vi,j−1)ui,j−1∆x+

i,j−1

∆xui,j∆yu

i,j

(75)

For the upwind scheme used here, the inter-facial velocities which are defined on X-points are herecalculated as:

ui,j =

Ui,j

Dui,j

for 12 (Vi+1,j,k + Vi,j,k) > 0

Ui,j+1

Dui,j+1

else.

(76)

First advection term in (61):(

mn ∂X

(

UV

Dn

))

i,j,k

12 (Ui,j+1 + Ui,j)vi,j∆y+

i,j − 12 (Ui−1,j+1 + Ui−1,j)vi−1,j∆y+

i−1,j

∆xvi,j∆yv

i,j

(77)

For the upwind scheme used here, the interfacial velocities which are defined on X-points are herecalculated as:

vi,j =

Vi,j

Dvi,j

for 12 (Ui+1,j + Ui,j) > 0

Vi+1,j

Dvi+1,j

else.

(78)

Second advection term in (61):(

mn ∂Y

(

V 2

Dm

))

i,j,k

12 (Vi,j+1 + Vi,j)vi,j+1∆xc

i,j+1 − 12 (Vi,j + Vi,j−1)vi,j∆xc

i,j

∆xvi,j∆yv

i,j

(79)

For the upwind scheme used here, the interfacial velocities which are defined on T-points are herecalculated as:

vi,j =

Vi,j−1

Dvi,j−1

for 12 (Vi,j + Vi,j−1) > 0

Vi,j

Dvi,j

else.

(80)

When working with the option SLICE_MODEL, the calculation of all gradients in y-direction issuppressed.

USES:

43

Page 44: Getm Doc Stable

use domain, only: imin,imax,jmin,jmax,az,au,av,axuse domain, only: ioff,joff

#if defined(SPHERICAL) || defined(CURVILINEAR)use domain, only: dyc,arud1,dxx,dyx,arvd1,dxc

#elseuse domain, only: dx,dy,ard1

#endifuse variables_2d, only: U,DU,UEx,V,DV,VEx,PPIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,ii,jj

44

Page 45: Getm Doc Stable

6.4 uv diffusion - 2D diffusion of momentum (Source File: uv diffusion.F90)

INTERFACE:

subroutine uv_diffusion(Am,An)

DESCRIPTION:

Here, the diffusion terms for the vertically integrated transports are calculated by means of centraldifferences, following the finite volume approach. They are added to the advection terms into theterms UEx and VEx for the U - and the V -equation, respectively. The physical diffusion with thegiven eddy viscosity coefficient AM

h is based on velocity gradients, whereas an additional numericaldamping of the barotropic mode is based on gradients of the transports with the damping coefficientAN

h , see the example given as equations (89) and (90).First diffusion term in (60):

(

mn ∂X

(

2AMh D∂X

(

U

D

)

+ ANh ∂XU

))

i,j

≈FDxx

i+1,j −FDxxi,j

∆xui,j∆yu

i,j

(81)

with diffusive fluxes

FDxxi,j =

(

2AMh Di,j

(

Ui,j

Dui,j

− Ui−1,j

Dui−1,j

)

+ ANh (Ui,j − Ui−1,j)

)

∆yci,j

∆xci,j

. (82)

Second diffusion term in (60):

(

mn ∂Y

(

AMh D

(

∂Y

(

U

D

)

+ ∂X

(

V

D

))

+ ANh ∂YU

))

i,j

≈FDxy

i,j −FDxyi,j−1

∆xxi,j∆yx

i,j

(83)

with diffusive fluxes

FDxyi,j = AM

h

1

2

(

Dui,j + Du

i,j+1

)

∆xxi,j

((

Ui,j+1

Dui,j+1

− Ui,j

Dui,j

)

1

∆yxi,j

+

(

Vi+1,j

Dvi+1,j

− Vi,j

Dvi,j

)

1

∆xxi,j

)

+ANh (Ui,j+1 − Ui,j)

∆xxi,j

∆yxi,j

.

(84)First diffusion term in (61):

(

mn ∂X

(

AMh D

(

∂Y

(

U

D

)

+ ∂X

(

V

D

))

+ ANh ∂XV

))

i,j

≈FDyx

i,j −FDyxi−1,j

∆xxi,j∆yx

i,j

(85)

with diffusive fluxes

FDyxi,j = AM

h

1

2

(

Dvi,j + Dv

i+1,j

)

∆yxi,j

((

Ui,j+1

Dui,j+1

− Ui,j

Dui,j

)

1

∆yxi,j

+

(

Vi+1,j

Dvi+1,j

− Vi,j

Dvi,j

)

1

∆xxi,j

)

+ANh (Vi+1,j − Vi,j)

∆yxi,j

∆xxi,j

.

(86)

45

Page 46: Getm Doc Stable

Second diffusion term in (61):

(

mn ∂Y

(

2AMh D∂Y

(

V

D

)

+ ANh ∂YV

))

i,j

≈FDyy

i,j+1 −FDyyi,j

∆xvi,j∆yv

i,j

(87)

with diffusive fluxes

FDyyi,j =

(

2AMh Di,j

(

Vi,j

Dvi,j

− Vi,j−1

Dvi,j−1

)

+ ANh (Vi,j − Vi,j−1)

)

∆xci,j

∆yci,j

. (88)

The role of the additional diffusion of U and V with the diffusion coefficient ANh is best demon-

strated by means of a simplified set of vertically integrated equations:

∂tη = −∂xU − ∂yV

∂tU = −gD∂xη + ANh (∂xxU + ∂yyU)

∂tV = −gD∂yη + ANh (∂xxV + ∂yyV ) ,

(89)

which can be transformed into an equation for ∂tη by derivation of the η-equation with respectto t, of the U -equation with respect to x and the V -equation with respect to y and subsequentelimination of U and V :

∂t (∂tη) = gD (∂xxη + ∂yyη) + ANh (∂xx (∂tη) + ∂yy (∂tη)) , (90)

which can be interpreted as a wave equation with a damping on ∂tη. This introduces an explicitdamping of free surface elevation oscillations in a momentum-conservative manner. Hydrodynamicmodels with implicit treatment of the barotropic mode do not need to apply this method due to theimplicit damping of those models, see e.g. Backhaus (1985). The implementation of this explicitdamping described here has been suggested by Jean-Marie Beckers, Liege (Belgium).When working with the option SLICE_MODEL, the calculation of all gradients in y-direction issuppressed.

USES:

use domain, only: imin,imax,jmin,jmax,az,au,av,ax#if defined(SPHERICAL) || defined(CURVILINEAR)

use domain, only: dyc,arud1,dxx,dyx,arvd1,dxc#else

use domain, only: dx,dy,ard1#endif

use variables_2d, only: D,U,DU,UEx,V,DV,VEx,PPIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: Am,An

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

46

Page 47: Getm Doc Stable

REVISION HISTORY:

Original author(s): Hans Burchard

LOCAL VARIABLES:

integer :: i,j

6.4.1 bottom friction - calculates the 2D bottom friction.

INTERFACE:

subroutine bottom_friction(runtype)

DESCRIPTION:

In this routine the bottom friction for the external (vertically integrated) mode is calculated. Thisis done separately for the U -equation in the U-points and for the V -equation in the V-points. Thedrag coefficient R for the external mode is given in eq. (70) on page 33. For runtype=1 (onlyvertically integrated calculations), the bottom roughness length is depending on the bed frictionvelocity ub

∗ and the molecular viscosity ν:

zb0 = 0.1

ν

ub∗

+(

zb0

)

min, (91)

see e.g. Kagan (1995), i.e. the given roughness may be increased by viscous effects. After this,the drag coefficient is multiplied by the absolute value of the local velocity, which is alculated bydividing the local transports by the local water depths and by properly interpolating these velocitiesto the U- and V-points. The resulting fields are ru, representing R

√u2 + v2 on the U-points and

rv, representing this quantity on the V-points.

USES:

use parameters, only: kappa,avmmoluse domain, only: imin,imax,jmin,jmax,au,av,min_depthuse variables_2dIMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: runtype

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

integer :: i,jREALTYPE :: uloc(E2DFIELD),vloc(E2DFIELD)REALTYPE :: HH(E2DFIELD),fricvel(E2DFIELD)

47

Page 48: Getm Doc Stable

6.4.2 sealevel - using the cont. eq. to get the sealevel.

INTERFACE:

subroutine sealevel

DESCRIPTION:

Here, the sea surface elevation is iterated according to the vertically integrated continuity equationgiven in (56) on page 31.When working with the option SLICE_MODEL, the elevations at j = 2 are copied to j = 3.

USES:

use domain, only: imin,imax,jmin,jmax,az,H#if defined(SPHERICAL) || defined(CURVILINEAR)

use domain, only : arcd1,dxv,dyu#else

use domain, only : dx,dy,ard1#endif

use m2d, only: dtmuse variables_2d, only: z,zo,U,Vuse halo_zones, only : update_2d_halo,wait_halo,z_TAGIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,jREALTYPE :: kk

6.4.3 sealevel nan check - Sweep the sealevel (z) for NaN values

INTERFACE:

subroutine sealevel_nan_check

DESCRIPTION:

The sea surface elevation (2d) variable is sweeped scanning for not-a-number (NaN). NaN valuesindicate that the integration has become unstable and that it really should be stopped. First time a

48

Page 49: Getm Doc Stable

NaN value is found, a warning is issued and possibly the code is stopped. After the first encounter,the sweep is suspended.The behaviour of this routine is controlled by the sealevel_check parameter in the m2d namelist.

USES:

use domain, only: imin,imax,jmin,jmaxuse m2d, only: sealevel_checkuse variables_2d, only: zuse exceptions, only: getm_errorIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Bjarne B\"uchmann

LOCAL VARIABLES:

integer, save :: Ncall = 0integer, save :: can_check = 0integer, save :: have_warned = 0integer :: num_naninteger :: i,j,inan,jnan, idumREALTYPE :: ahuge,zdum

6.4.4 sealevel nandum. Helper routine to spot NaNs

INTERFACE:

subroutine sealevel_nandum(a,b,idum)

USES:

INPUT PARAMETERS:

REALTYPE, intent(in) :: a,b

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

integer, intent(out) :: idum

DESCRIPTION:

This routine is a kind of dummy routine primarily to provide a means to spot NaN values. Outputis 1 or 2, based on which is smaller (a or b, respectively). The default is 2, and the idea is that”imin=2”should be returned also if a is NaN. If b=HUGE(b), then this provides a means to detectif a is a denormal number.

49

Page 50: Getm Doc Stable

6.4.5 depth update - adjust the depth to new elevations.

INTERFACE:

subroutine depth_update

DESCRIPTION:

This routine which is called at every micro time step updates all necessary depth related informa-tion. These are the water depths in the T-, U- and V-points, D, DU and DV, respectively, the seasurface elevation in the U- and V-points, zu and zv, respectively, and the drying value α definedin equation (5) on page 12 in the T-, the U- and the V-points (dry_z, dry_u and dry_v).When working with the option SLICE_MODEL, the water depths in the V-points are mirrored fromj = 2 to j = 1 and j = 3.

USES:

use domain, only: imin,imax,jmin,jmax,H,HU,HV,min_depth,crit_depthuse domain, only: az,au,av,dry_z,dry_u,dry_vuse variables_2d, only: D,z,zo,DU,zu,DV,zvIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,jREALTYPE :: d1,d2,x

6.4.6 uv depths - calculate depths in u and v points.

INTERFACE:

subroutine uv_depths(vel_depth_method)

DESCRIPTION:

In this routine which is called once during the model initialisation, the bathymetry value in theU- and the V-points are calculated from the bathymetry values in the T-points. The interpolationdepends on the value which is given to vel_depth_method:

50

Page 51: Getm Doc Stable

Hui,j =

1

2(Hi,j + Hi+1,j) , for vel_depth_method= 0,

min {Hi,j + Hi+1,j} , for vel_depth_method= 1,

min {Hi,j + Hi+1,j} , for vel_depth_method= 2 and min{Hi,ji, Hi+1,j} < Dcrit

1

2(Hi,j + Hi+1,j) , for vel_depth_method= 2 and min{Hi,j , Hi+1,j} ≥ Dcrit

(92)The calculation of Hv

i,j is done accordingly.The options 1 and 2 for vel_depth_method may help to stabilise calculations when drying andflooding is involved.

USES:

use exceptionsuse domain, only: imin,imax,jmin,jmax,az,au,av,H,HU,HVuse variables_2d, only: DU,DVIMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: vel_depth_method

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,jREALTYPE :: d_crit=2.0

6.4.7 update 2d bdy - update 2D boundaries every time step.

INTERFACE:

subroutine update_2d_bdy(loop,bdyramp)

DESCRIPTION:

In this routine sea surface elevation boundary conditions are read in from a file, interpolated tothe actual time step, and distributed to the open boundary grid boxes. Only for a special test case(SYLT_TEST), ascii data reading is supported. For a few special simple cases, analytical calculationof boundary elevations is supported. The generic way is reading in boundary data from a netcdffile, which is managed in get_2d_bdy via get_2d_bdy_ncdf.

USES:

51

Page 52: Getm Doc Stable

use domain, only: NWB,NNB,NEB,NSB,H,min_depth,imin,imax,jmin,jmax,azuse domain, only: wi,wfj,wlj,nj,nfi,nli,ei,efj,elj,sj,sfi,sliuse domain, only: bdy_index,nsbvuse m2d, only: dtm,bdyfmt_2d,bdy_datause variables_2d, only: zIMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: loop,bdyramp

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

logical, save :: first=.true.REALTYPE, save :: time_array(1000),zbo(1000),zbn(1000)REALTYPE, save :: t,t1,t2REALTYPE :: a,amp,ratio,facinteger :: i,j,k,l,nREALTYPE, parameter :: FOUR=4.*_ONE_

52

Page 53: Getm Doc Stable

6.5 cfl check - check for explicit barotropic time step. (Source File:cfl check.F90)

INTERFACE:

subroutine cfl_check()

DESCRIPTION:

This routine loops over all horizontal grid points and calculated the maximum time step accordingto the shallow water criterium by Beckers and Deleersnijder (1993):

∆tmax = mini,j

∆xi,j∆yi,j√2ci,j

∆x2i,j + ∆y2

i,j

(93)

with the local Courant number

ci,j =√

gHi,j , (94)

where g is the gravitational acceleration and Hi,j is the local bathymetry value. In case that thechosen micro time step ∆tm is larger than ∆tmax, the program will be aborted. In any the CFLdiagnostics will be written to standard output.

USES:

use parameters, only: guse domain, only: imin,imax,jmin,jmax,H,az

#if defined(SPHERICAL) || defined(CURVILINEAR)use domain, only: dyc,dxc

#elseuse domain, only: dy,dx

#endifuse m2d, only: dtmIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

integer :: pos(2),max_pos(2),rc,i,jREALTYPE :: h_max=-99.,c,max_dt,dttlogical, dimension(:,:), allocatable :: lmask

53

Page 54: Getm Doc Stable

6.5.1 have bdy - checks whether this node has boundaries.

INTERFACE:

subroutine have_bdy

DESCRIPTION:

This routine which is called in domain.F90 checks whether the present node has open lateralboundaries. The integer field bdy_index is then set accordingly.

USES:

use domainuse m2d, only: have_boundariesIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

integer :: i,j,k,ninteger :: nbdyinteger :: f,l

54

Page 55: Getm Doc Stable

6.6 do residual - barotropic residual currents. (Source File: residual.F90)

INTERFACE:

subroutine do_residual(finish)

DESCRIPTION:

Here, the residual transports and depths are integrated up every time step. At the end of thesimulation, the Eulerian residual currents are calculated from:

ures =

∫ t1

t0

U dτ

∫ t1

t0

Du dτ

, vres =

∫ t1

t0

V dτ

∫ t1

t0

Dv dτ

, (95)

where t0 is the time when the residual calculation begins (to be chosen from namelist) and t1 isthe finishing time of the model simulation.

USES:

use variables_2d, only: u,v,res_du,res_u,res_dv,res_v,du,dvIMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: finish

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

55

Page 56: Getm Doc Stable

56

Page 57: Getm Doc Stable

7 Introduction to 3d module

7.1 Overview over 3D routines in GETM

This module contains the physical core of GETM. All three-dimensional equations are iteratedhere, which are currently the equations for

quantity description unit variable routine name pagepk layer-int. u-transport m2s−1 uu uu_momentum 77qk layer-int. v-transport m2s−1 vv vv_momentum 79θ potential temperature ◦C T do_temperature 111S salinity psu S do_salinity 114C suspended matter kgm−3 spm do_spm 118

The vertical grid for GETM, i.e. the layer thicknesses in all U-, V- and T-points, are defined in theroutine coordinates, see section 7.6 on page 7.6.The grid-related vertical velocity wk is calculated directly from the layer-integrated continuityequation (25) which here done in the routine ww_momentum described on page 81.The physics of the horizontal momentum equations is given in section 3.1.1, and their trans-formation to general vertical coordinates in section 4.2. Their numerical treatment will be dis-cussed in the routines for the individual terms, see below. The forcing terms of the horizontalmomentum equations are calculated in various routines, such as uv_advect_3d for the three-dimensional advection (which in turn calls advection_3d in case that higher order positive def-inite advection schemes are chosen for the momentum equation), uv_diffusion_3d.F90 for thehorizontal diffusion, bottom_friction_3d for the bottom friction applied to the lowest layer, andinternal_pressure for the calculation of the internal pressure gradients.The major tracer equations in any ocean model are those for potential temperature and salinity.They are calculated in the routines do_temperature and do_salinity. A further hard-codedtracer equation is the suspended matter equation, see do_spm.In the near future (the present text is typed in February 2006), a general interface to the bio-geochemical module of GOTM (also not yet released) will be available. This allow to add tracerequations of arbitrary complexity to GETM, ranging from completely passive tracer equations tocomplex ecosystem models such as ERSEM (Baretta et al. (1995)). The interfacing between thisso-called GOTM-BIO to GETM is made in a similar manner than the interfacing between GETMand the GOTM turbulence module described in gotm on page 125. The basic structure of GOTM-BIO has been recently presented by Burchard et al. (2006). Some more details about the tracerequations currently included in GETM is given in section 7.2.The entire turbulence model, which basically provides eddy viscosity νt and eddy diffusivity ν′

tis provided from the General Ocean Turbulence Model (GOTM, see Umlauf et al. (2005) for thesource code documentation and http://www.gotm.net download of source code, docomentationand test scenarios). The turbulence module of GOTM (which is a complete one-dimensional watercolumn model) is coupled to GETM via the interfacing routine gotm described in section gotm on

page 125. Major input to the turbulence model are the shear squared M2 = (∂zu)2

+ (∂zu)2

andthe buoyancy frequency squared N2 = ∂zb with the buoyancy b from (4). Those are calculatedand interpolated to the T-points where the turbulence model columns are located in the routiness_nn described on page 122.The surface and bottom stresses which need to be passed to the turbulence module as well, areinterpolated to T-points in the routine stresses_3d, see page 124.The module rivers (see section 7.32 on page 126) organises the riverine input of fresh water fromany number of rivers.Three-dimensional boundary conditions for temperature and salinity are provided by means of themodule bdy-3d, see section 7.33 described on page 130.The remaining routines in the module 3d deal with the coupling of the external and the internal

57

Page 58: Getm Doc Stable

mode. The basic idea of the mode splitting has already been discussed in section 5.1. The con-sistency of the two modes is given through the so-called slow terms, which are mode interactionterms resulting from subtracting vertically integrated equations with parameterised advection, dif-fusion, bottom friction and internal pressure gradient from vertically integrated equations withexplicit vertical resolution of these processes. These slow terms which are updated every macrotime step only (that is why we call them slow terms) need to be considered for the external modeincluded in module 2d. Those slow terms are calculated here in the 3d module in the routinesslow_bottom_friction, slow_advection and slow_diffusion, and they are added together inslow_terms, see the descriptions in sections 7.34, 7.35,7.36 and 7.37 on pages 132, 133,134 and135, respectively.One other important measure of coupling the two modes is to add to all calculated u- and v-velocity profiles the difference between their vertical integral and the time-average of the verticallyintegrated transport from the previous set of micro time steps. This shifting is done in the routinesuu_momentum_3d and vv_momentum_3d and the time-average of the vertically integrated transportis updated in the 2d module in the routine m2d and divided by the number of micro time stepsper macro time step in start_macro. Further basic calculations performed in start_macro (seedescription in section 7.38 on page 136) are the updates of the old and new sea surface elevationswith respect to the actual macro time step. The routine stop_macro (see description in section7.39 on page 137) which called at the end of each macro time step simply resets the variables forthe time-averaged transports to zero.

7.2 Tracer equations

The general conservation equation for tracers ci with 1 ≤ i ≤ Nc (with Nc being the number of trac-ers), which can e.g. be temperature, salinity, nutrients, phytoplankton, zoo-plankton, suspendedmatter, chemical concentrations etc. is given as:

∂tci + ∂x(uci) + ∂y(vci) + ∂z((w + αwi

s)ci) − ∂z(ν

′t∂zc

i)

−∂x(ATh ∂xci) − ∂y(AT

h ∂yci) = Qi.(96)

Here, ν′t denotes the vertical eddy diffusivity and AT

h the horizontal diffusivity. Vertical migrationof concentration with migration velocity wi

s (positive for upward motion) is considered as well. Thiscould be i.e. settling of suspended matter or active migration of phytoplankton. In order to avoidstability problems with vertical advection when intertidal flats are drying, the settling of SPM islinearly reduced towards zero when the water depth is between the critical and the minimum waterdepth. This is done by means of multiplication of the settling velocity with α, (see the definitionin equation (5)). Qi denotes all internal sources and sinks of the tracer ci. This might e.g. be forthe temperature equation the heating of water due to absorption of solar radiation in the watercolumn.Surface of bottom boundary conditions for tracers are usually given by prescribed fluxes:

ν′t∂zc

i = F is for z = ζ (97)

and

ν′t∂zc

i = −F ib for z = −H, (98)

with surface and bottom fluxes Fns and Fn

b directed into the domain, respectively.At open lateral boundaries, the tracers cn are prescribed for the horizontal velocity normal to theopen boundary flowing into the domain. In case of outflow, a zero-gradient condition is used.All tracer equations except those for temperature, salinity and suspended matter will be treatedin the future by means of GOTM-BIO.The two most important tracer equations which are hard-coded in GETM are the transport equa-tions for potential temperature θ in ◦C and salinity S in psu (practical salinity units):

58

Page 59: Getm Doc Stable

∂tθ + ∂x(uθ) + ∂y(vθ) + ∂z(wθ) − ∂z(ν′t∂zθ)

−∂x(Aθh∂xθ) − ∂y(Aθ

h∂yθ) =∂zI

c′pρ0,

(99)

∂tS + ∂x(uS) + ∂y(vS) + ∂z(wS) − ∂z(ν′t∂zS)

−∂x(ASh∂xS) − ∂y(AS

h∂yS) = 0.(100)

On the right hand side of the temperature equation (99) is a source term for absorption of solar ra-diation with the solar radiation at depth z, I, and the specific heat capacity of water, c′p. Accordingto Paulson and Simpson (1977) the radiation I in the upper water column may be parameterisedby

I(z) = I0

(

ae−η1z + (1 − a)e−η2z)

. (101)

Here, I0 is the albedo corrected radiation normal to the sea surface. The weighting parameter aand the attenuation lengths for the longer and the shorter fraction of the short-wave radiation,η1 and η2, respectively, depend on the turbidity of the water. Jerlov (1968) defined 6 differentclasses of water from which Paulson and Simpson (1977) calculated weighting parameter a andattenuation coefficients η1 and η2.At the surface, flux boundary conditions for T and S have to be prescribed. For the potentialtemperature, it is of the following form:

ν′t∂zT =

Qs + Ql + Qb

c′pρ0, for z = ζ, (102)

with the sensible heat flux, Qs, the latent heat flux, Ql and the long wave back radiation, Qb. Here,the Kondo (1975) bulk formulae have been used for calculating the momentum and temperaturesurface fluxes due to air-sea interactions. In the presence of sea ice, these air-sea fluxes have tobe considerably changed, see e.g. Kantha and Clayson (2000b). Since there is no sea-ice modelcoupled to GETM presently, the surface heat flux is limited to positive values, when the sea surfacetemperature Ts reaches the freezing point

Tf = −0.0575 Ss + 1.710523 · 10−3 S1.5s − 2.154996 · 10−4 S2

s ≈ −0.0575 Ss (103)

with the sea surface salinity Ss, see e.g. Kantha and Clayson (2000a):

Qsurf =

Qs + Ql + Qb, for Ts > Tf ,

max{0, Qs + Ql + Qb}, else.(104)

For the surface freshwater flux, which defines the salinity flux, the difference between evapora-tion QE (from bulk formulae) and precipitation QP (from observations or atmospheric models) iscalculated:

ν′t∂zS =

S(QE − QP )

ρ0(0), for z = ζ, (105)

where ρ0(0) is the density of freshwater at sea surface temperature. In the presence of sea-ice,the calculation of freshwater flux is more complex, see e.g. Large et al. (1994). However, for manyshort term calculations, the freshwater flux can often be neglected compared to the surface heatflux.A complete revision of the surface flux calculation is currently under development. It will be theidea to have the same surface flux calculations for GOTM and GETM. In addition to the older

59

Page 60: Getm Doc Stable

bulk formulae by Kondo (1975) we will also implement the more recent formlations by Fairall et al.(1996).Heat and salinity fluxes at the bottom are set to zero.

7.3 Equation of state

The coupling between the potential temperature and salinity equations and the momentum equa-tions is due to an algebraic equation of state:

ρ = ρ(θ, S, p0) (106)

with p0 = gρ0(ζ − z) being the hydrostatic reference pressure. In order to obtain potential densityfrom the equation of state, p0 needs to be set to zero, which is the default in GETM.Currently the equation of state by Fofonoff and Millard (1983) is implemented into GETM, butthe more recent and more consistent equation of state by Jackett et al. (2005) which is alreadycontained in GOTM will be added as an option in the near future.For the equation of state, also linearised version are implemented into GETM, for details, seesection 7.28 on page 120.For convinient use in other subroutines the buoyancy b as defined in (4 is calculated and stored inthe GETM variable tt buoy.

60

Page 61: Getm Doc Stable

7.4 Module m3d - 3D model component (Source File: m3d.F90)

INTERFACE:

module m3d

DESCRIPTION:

This module contains declarations for all variables related to 3D hydrodynamical calculations.Information about the calculation domain is included from the domain module. The modulecontains public subroutines for initialisation, integration and clean up of the 3D model component.The m3d module is initialised in the routine init_3d, see section 7.4.1 described on page 62. Theactual calculation routines are called in integrate_3d (see section 7.4.2 on page 63). and arelinked in from the library lib3d.a. After the simulation, the module is closed in clean_3d, seesection 7.4.3 on page 64.

USES:

use exceptionsuse parameters, only: avmmoluse domain, only: maxdepth,vert_cord,azuse m2d, only: Amuse variables_2d, only: D,z,UEx,VEx

#ifndef NO_BAROCLINICuse temperature,only: init_temperature, do_temperatureuse salinity, only: init_salinity, do_salinityuse eqstate, only: init_eqstate, do_eqstateuse internal_pressure, only: init_internal_pressure, do_internal_pressureuse internal_pressure, only: ip_method

#endif#ifdef GETM_BIO

use bio, only: bio_calcuse getm_bio, only: do_getm_bio

#endifuse variables_3duse advection_3d, only: init_advection_3duse bdy_3d, only: init_bdy_3d, do_bdy_3dNecessary to use halo_zones because update_3d_halos() have been moved outtemperature.F90 and salinity.F90 - should be changed at a later stageuse halo_zones, only: update_3d_halo,wait_halo,D_TAG

IMPLICIT NONE

PUBLIC DATA MEMBERS:

integer :: M=1REALTYPE :: cord_relax=_ZERO_logical :: calc_temp=.true.logical :: calc_salt=.true.logical :: bdy3d=.false.integer :: bdyfmt_3d,bdyramp_3dcharacter(len=PATH_MAX) :: bdyfile_3dREALTYPE :: ip_fac=_ONE_integer :: vel_check=0REALTYPE :: min_vel=-4.,max_vel=4.

61

Page 62: Getm Doc Stable

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

integer :: vel_hor_adv=1,vel_ver_adv=1,vel_adv_split=0#ifdef NO_BAROCLINIC

integer :: ip_method#endif

integer :: ip_ramp=-1

7.4.1 init 3d - initialise 3D related stuff

INTERFACE:

subroutine init_3d(runtype,timestep,hotstart)IMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: runtypeREALTYPE, intent(in) :: timesteplogical, intent(in) :: hotstart

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

DESCRIPTION:

Here, the m3d namelist is read from getm.inp, and the initialisation of variables is called (see routineinit_variables described on page 67). Furthermore, a number of consistency checks are made forthe choices of the momentum advection schemes. When higher-order advection schemes are chosenfor the momentum advection, the compiler option UV_TVD has to be set. Here, the macro timestep ∆t is calculated from the micro time step ∆tm and the split factor M. Then, in order to havethe vertical coordinate system present already here, coordinates (see page 68) needs to be called,in order to enable proper interpolation of initial values for potential temperature θ and salinityS for cold starts. Those initial values are afterwards read in via the routines init_temperature(page 110) and init_salinity (page 113). Finally, in order to prepare for the first time step,the momentum advection and internal pressure gradient routines are initialised and the internalpressure gradient routine is called.

LOCAL VARIABLES:

integer :: rcNAMELIST /m3d/ &

M,cnpar,cord_relax, &bdy3d,bdyfmt_3d,bdyramp_3d,bdyfile_3d, &vel_hor_adv,vel_ver_adv,vel_adv_split, &calc_temp,calc_salt, &avmback,avhback,ip_method,ip_ramp, &vel_check,min_vel,max_vel

62

Page 63: Getm Doc Stable

7.4.2 integrate 3d - calls to do 3D model integration

INTERFACE:

subroutine integrate_3d(runtype,n)IMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: runtype,n

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

DESCRIPTION:

This is a wrapper routine to call all 3D related subroutines. The call position for the coordinatesroutine depends on the compiler option MUDFLAT: If it is defined, then the call to coordinatesconstruction is made such that drying and flooding is stable. If MUDFLAT is not defined, then theadaptive grids with Lagrangian component which are currently under development are supported.Both, drying and flooding and Lagrangian coordinates does not go together yet. The call sequenceis as follows:

start_macro initialising a 3d step see page 136do_bdy_3d boundary conditions for θ and S see page 131coordinates layer heights (MUTFLAT defined) see page 68bottom_friction_3d bottom friction see page 88do_internal_pressure internal pressure gradient see page 90uu_momentum_3d layer-integrated u-velocity see page 77vv_momentum_3d layer-integrated v-velocity see page 79coordinates layer heights (MUTFLAT not defined) see page 68ww_momentum_3d grid-related vertical velocity see page 81uv_advect_3d momentum advection see page 82uv_diffusion_3d momentum diffusion see page 86stresses_3d stresses (for GOTM) see page 124ss_nn shear and stratification (for GOTM) see page 122gotm interface and call to GOTM see page 125do_temperature potential temperature equation see page 111do_salinity salinity equation see page 114do_eqstate equation of state see page 121do_spm suspended matter equation see page 118do_getm_bio call to GOTM-BIO (not yet released)slow_bottom_friction slow bottom friction see page 132slow_advection slow advection terms see page 133slow_diffusion slow diffusion terms see page 134slow_terms sum of slow terms see page 135stop_macro finishing a 3d step see page 137

Several calls are only executed for certain compiler options. At each time step the call sequencefor the horizontal momentum equations is changed in order to allow for higher order accuracy forthe Coriolis rotation.

63

Page 64: Getm Doc Stable

LOCAL VARIABLES:

logical, save :: ufirst=.true.

7.4.3 clean 3d - cleanup after 3D run

INTERFACE:

subroutine clean_3d()IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

DESCRIPTION:

Here, a call to the routine clean_variables_3d which howewer does not do anything yet.

LOCAL VARIABLES:

64

Page 65: Getm Doc Stable

7.5 Module variables 3d - global 3D related variables (Source File: vari-ables 3d.F90)

INTERFACE:

module variables_3d

DESCRIPTION:

This modules contains declarations for all variables related to 3D hydrodynamical calculations.Information about the calculation domain is included from the domain module. The variables areeither statically defined in static_3d.h or dynamically allocated in dynamic_declarations_3d.h.The variables which need to be declared have the following dimensions, units and meanings:

kmin 2D [-] lowest index in T-pointkumin 2D [-] lowest index in U-pointkvmin 2D [-] lowest index in V-pointkmin_pmz 2D [-] lowest index in T-point (poor man’s z-coordinate)kumin_pmz 2D [-] lowest index in U-point (poor man’s z-coordinate)kvmin_pmz 2D [-] lowest index in V-point (poor man’s z-coordinate)uu 3D [m2s−1] layer integrated u transport pk

vv 3D [m2s−1] layer integrated v transport qk

ww 3D [m s−1] grid-related vertical velocity wk

ho 3D [m] old layer height in T-pointhn 3D [m] new layer height in T-pointhuo 3D [m] old layer height in U-pointhun 3D [m] new layer height in U-pointhvo 3D [m] old layer height in V-pointhvn 3D [m] new layer height in V-pointhcc 3D [-] hydrostatic consistency index in T-pointsuuEx 3D [m2s−2] sum of advection and diffusion for u-equationvvEx 3D [m2s−2] sum of advection and diffusion for v-equationnum 3D [m2s−1] eddy viscosity on w-points νt

nuh 3D [m2s−1] eddy diffusivity on w-points ν′t

tke 3D [m2s−2] turbulent kinetic energy keps 3D [m2s−3] turbulent dissipation rate εSS 3D [s−2] shear-frequency squared M2

NN 3D [s−2] Brunt-Vaisala frequency squaredN2

S 3D [psu] salinity ST 3D [◦C] potential temperature θrad 3D [Wm−2] Short wave penetrationrho 3D [kgm−3] density rhobuoy 3D [m s−2] buoyancy bidpdx 3D [m2s−2] x-component of internal pressure gradientidpdy 3D [m2s−2] y-component of internal pressure gradientspm 3D [kgm−3] suspended matter concentrationspm_ws 3D [m s−1] settling velocity of suspended matterspm_pool 2D [kgm−2] bottom pool of suspended matteruadv 3D [m s−1] interpolated x-component of momentum advection velocityvadv 3D [m s−1] interpolated y-component of momentum advection velocity

65

Page 66: Getm Doc Stable

wadv 3D [m s−1] interpolated vertical component of momentum advection velocityhuadv 3D [m] interpolated height of advective flux layer (x-component)hvadv 3D [m] interpolated height of advective flux layer (y-component)hoadv 3D [m] old height of advective finite volume cellhnadv 3D [m] new height of advective finite volume cellsseo 2D [m] sea surface elevation before macro time step (T-point)ssen 2D [m] sea surface elevation after macro time step (T-point)ssuo 2D [m] sea surface elevation before macro time step (U-point)ssun 2D [m] sea surface elevation after macro time step (U-point)ssvo 2D [m] sea surface elevation before macro time step (V-point)ssvn 2D [m] sea surface elevation after macro time step (V-point)rru 2D [m s−1] drag coefficient times curret speed in U-pointrrv 2D [m s−1] drag coefficient times curret speed in V-pointtaus 2D [m2s−2] normalised surface stress (T-point)taub 2D [m2s−2] normalised bottom stress (T-point)

It should be noted that depending on compiler options and runtype not all these variables aredefined.The module contains public subroutines to initialise (see init_variables_3d) and cleanup (seeclean_variables_3d).

USES:

use domain, only: iimin,iimax,jjmin,jjmax,kmaxIMPLICIT NONE

PUBLIC DATA MEMBERS:

REALTYPE :: dt,cnpar=0.9REALTYPE :: avmback=_ZERO_,avhback=_ZERO_character(len=64) :: adv_schemes(7)

#ifdef STATIC#include "static_3d.h"#else#include "dynamic_declarations_3d.h"#endif

#ifdef GETM_BIOREALTYPE, allocatable :: cc3d(:,:,:,:)REALTYPE, allocatable :: ws3d(:,:,:,:)

#endifinteger :: size3d_fieldinteger :: mem3d

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

66

Page 67: Getm Doc Stable

7.5.1 init variables 3d - initialise 3D related stuff

INTERFACE:

subroutine init_variables_3d(runtype)IMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: runtype

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

DESCRIPTION:

Dynamic allocation of memory for 3D related fields via dynamic_allocations_3d.h (unless thecompiler option STATIC is set). Furthermore, most variables are initialised here.

LOCAL VARIABLES:

integer :: rc

7.5.2 clean variables 3d - cleanup after 3D run.

INTERFACE:

subroutine clean_variables_3d()IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

DESCRIPTION:

This routine cleans up after a 3D integrationby doing nothing so far.

LOCAL VARIABLES:

67

Page 68: Getm Doc Stable

7.6 coordinates - defines the vertical coordinate (Source File: coordi-nates.F90)

INTERFACE:

subroutine coordinates(cord_type,cord_relax,maxdepth)

DESCRIPTION:

Here, the vertical layer distribution in T-, U- and V-points is updated during every macro timestep. This is done for the old and the new layer thicknesses at every point. Calculation of the layerdistribution in the U- and V-points is done indepently from the calculation in the T-points, sincedifferent methods for the calculation of the bathymetry values in the U- and V-points are possible,see routine uv_depths described on page 50.Here, three different methods for the vertical layer distribution are coded:

1. Classical σ coordinates where layer interfaces for each layer index have a fixed relative positionσk in the water column, which may be even equidistant or non-equidistant, see equations(14) and (16). The surface and bottom zooming factors du and dl are read in via thedomain namelist in getm.inp as ddu and ddl. In the first call to coordinates, the relativeinterface positions dga are calculated as a one-dimensional vector (in case of non-equidistantσ coordinates), and those are then multiplied with the water depths in all T-, U- and V-pointsto get the layer thicknesses.

2. Also z- (i.e. geopotential) coordinates are enabled in GETM in principle. However, they maynot yet work and need further development. First of all, fixed z-levels are defined by meansof zooming factors and the maximum water depth Hmax:

zk = Hmax

(

tanh ((dl + du)(1 + σk) − dl) + tanh(dl)

tanh(dl) + tanh(du)− 1

)

, k = 0, . . . , N (107)

Then, layers are from the surface down filled into the T-point water column locally. Whenthe last layer is shallower than hnmin (hard coded as local variable), the two last layers arecombined. The index of the lowest layer is then stored in the integer field kmin_pmz. layerthicknesses in U- and V-points are then taken as the minimum values of adjacent thicknessesin T-points, and bottom indices kumin_pmz and kvmin_pmz are taken as the maximum ofadjacent kmin_pmz indices.

3. The third and so far most powerful method are the genral vertical coordinates, discussed insection 4.1, see equations (14) - (19), which is basically an interpolation between equidistantand non-equaidistant σ coordinates. During the first call, a three-dimensional field ggacontaining the relative interface positions is calculated, which further down used togetherwith the actual water depth in the T-, U- and V-points for calculating the updated old andnew layer thicknesses.

A fourth option will soon be the adaptive grids which have been conceptionally developed byBurchard and Beckers (2004).

USES:

IMPLICIT NONE

INPUT PARAMETERS:

68

Page 69: Getm Doc Stable

integer, intent(in) :: cord_typeREALTYPE, intent(in) :: cord_relaxREALTYPE, intent(in) :: maxdepth

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

logical, save :: first=.true.

69

Page 70: Getm Doc Stable

7.7 equidistant and zoomed sigma-coordinates (Source File: sigma coordinates.F90)

INTERFACE:

subroutine sigma_coordinates(first)

DESCRIPTION:

Here, the vertical layer distribution in T-, U- and V-points is updated during every macro timestep. This is done for the old and the new layer thicknesses at every point. Calculation of the layerdistribution in the U- and V-points is done indepently from the calculation in the T-points, sincedifferent methods for the calculation of the bathymetry values in the U- and V-points are possible,see routine uv_depths described on page 50.Here, three different methods for the vertical layer distribution are coded:

1. Classical σ coordinates where layer interfaces for each layer index have a fixed relative positionσk in the water column, which may be even equidistant or non-equidistant, see equations(14) and (16). The surface and bottom zooming factors du and dl are read in via thedomain namelist in getm.inp as ddu and ddl. In the first call to coordinates, the relativeinterface positions dga are calculated as a one-dimensional vector (in case of non-equidistantσ coordinates), and those are then multiplied with the water depths in all T-, U- and V-pointsto get the layer thicknesses.

2. Also z- (i.e. geopotential) coordinates are enabled in GETM in principle. However, they maynot yet work and need further development. First of all, fixed z-levels are defined by meansof zooming factors and the maximum water depth Hmax:

zk = Hmax

(

tanh ((dl + du)(1 + σk) − dl) + tanh(dl)

tanh(dl) + tanh(du)− 1

)

, k = 0, . . . , N (108)

Then, layers are from the surface down filled into the T-point water column locally. Whenthe last layer is shallower than hnmin (hard coded as local variable), the two last layers arecombined. The index of the lowest layer is then stored in the integer field kmin_pmz. layerthicknesses in U- and V-points are then taken as the minimum values of adjacent thicknessesin T-points, and bottom indices kumin_pmz and kvmin_pmz are taken as the maximum ofadjacent kmin_pmz indices.

3. The third and so far most powerful method are the genral vertical coordinates, discussed insection 4.1, see equations (14) - (19), which is basically an interpolation between equidistantand non-equaidistant σ coordinates. During the first call, a three-dimensional field ggacontaining the relative interface positions is calculated, which further down used togetherwith the actual water depth in the T-, U- and V-points for calculating the updated old andnew layer thicknesses.

A fourth option will soon be the adaptive grids which have been conceptionally developed byBurchard and Beckers (2004).

USES:

use domain, only: iimin,iimax,jjmin,jjmax,kmax,H,HU,HVuse domain, only: ga,ddu,ddluse variables_3d, only: kmin,kumin,kvmin,ho,hn,huo,hun,hvo,hvnuse variables_3d, only: sseo,ssen,ssuo,ssun,ssvo,ssvnIMPLICIT NONE

70

Page 71: Getm Doc Stable

INPUT PARAMETERS:

logical, intent(in) :: first

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,k,rcREALTYPE :: kmaxm1logical, save :: equiv_sigma=.false.REALTYPE, save, dimension(:), allocatable :: dga

71

Page 72: Getm Doc Stable

7.8 general vertical coordinates (Source File: general coordinates.F90)

INTERFACE:

subroutine general_coordinates(first,cord_relax,maxdepth)

DESCRIPTION:

Here, the vertical layer distribution in T-, U- and V-points is updated during every macro timestep. This is done for the old and the new layer thicknesses at every point. Calculation of the layerdistribution in the U- and V-points is done indepently from the calculation in the T-points, sincedifferent methods for the calculation of the bathymetry values in the U- and V-points are possible,see routine uv_depths described on page 50.Here, three different methods for the vertical layer distribution are coded:

1. Classical σ coordinates where layer interfaces for each layer index have a fixed relative positionσk in the water column, which may be even equidistant or non-equidistant, see equations(14) and (16). The surface and bottom zooming factors du and dl are read in via thedomain namelist in getm.inp as ddu and ddl. In the first call to coordinates, the relativeinterface positions dga are calculated as a one-dimensional vector (in case of non-equidistantσ coordinates), and those are then multiplied with the water depths in all T-, U- and V-pointsto get the layer thicknesses.

2. Also z- (i.e. geopotential) coordinates are enabled in GETM in principle. However, they maynot yet work and need further development. First of all, fixed z-levels are defined by meansof zooming factors and the maximum water depth Hmax:

zk = Hmax

(

tanh ((dl + du)(1 + σk) − dl) + tanh(dl)

tanh(dl) + tanh(du)− 1

)

, k = 0, . . . , N (109)

Then, layers are from the surface down filled into the T-point water column locally. Whenthe last layer is shallower than hnmin (hard coded as local variable), the two last layers arecombined. The index of the lowest layer is then stored in the integer field kmin_pmz. layerthicknesses in U- and V-points are then taken as the minimum values of adjacent thicknessesin T-points, and bottom indices kumin_pmz and kvmin_pmz are taken as the maximum ofadjacent kmin_pmz indices.

3. The third and so far most powerful method are the genral vertical coordinates, discussed insection 4.1, see equations (14) - (19), which is basically an interpolation between equidistantand non-equaidistant σ coordinates. During the first call, a three-dimensional field ggacontaining the relative interface positions is calculated, which further down used togetherwith the actual water depth in the T-, U- and V-points for calculating the updated old andnew layer thicknesses.

A fourth option will soon be the adaptive grids which have been conceptionally developed byBurchard and Beckers (2004).

USES:

use domain, only: ga,ddu,ddl,d_gamma,gamma_surfuse domain, only: iimin,iimax,jjmin,jjmax,kmax,H,HU,HV,az,au,av,min_depthuse variables_3d, only: dt,kmin,kumin,kvmin,ho,hn,huo,hun,hvo,hvnuse variables_3d, only: sseo,ssen,ssuo,ssun,ssvo,ssvnIMPLICIT NONE

72

Page 73: Getm Doc Stable

INPUT PARAMETERS:

logical, intent(in) :: firstREALTYPE, intent(in) :: cord_relaxREALTYPE, intent(in) :: maxdepth

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,k,rc,kkREALTYPE :: alphaREALTYPE :: HH,zz,rREALTYPE, save, dimension(:), allocatable :: dga,be,sigREALTYPE, save, dimension(:,:,:), allocatable :: gga

73

Page 74: Getm Doc Stable

7.9 hybrid vertical coordinates - (z-sigma) (Source File: hybrid coordinates.F90)

INTERFACE:

subroutine hybrid_coordinates(first)

DESCRIPTION:

For Hans to do

USES:

#if 0use domain, only: iimin,iimax,jjmin,jjmax,kmax,H,HU,HV,az,au,av,min_depthuse domain, only: ga,ddu,ddl,d_gamma,gamma_surfuse variables_3d, only: dt,kmin,kumin,kvmin,ho,hn,huo,hun,hvo,hvnuse variables_3d, only: sseo,ssen,ssuo,ssun,ssvo,ssvn

#endifIMPLICIT NONE

INPUT PARAMETERS:

logical, intent(in) :: first

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

#if 0integer :: i,j,k,rc,kkREALTYPE, save, dimension(:), allocatable :: dga,be,sig,zlevREALTYPE, save, dimension(:,:,:), allocatable :: gga

#endif

74

Page 75: Getm Doc Stable

7.10 adaptive vertical coordinates (Source File: adaptive coordinates.F90)

INTERFACE:

subroutine adaptive_coordinates(first)

DESCRIPTION:

For Richard to do

USES:

IMPLICIT NONE

INPUT PARAMETERS:

logical, intent(in) :: first

REVISION HISTORY:

Original author(s): Richard Hofmeister and Hans Burchard

LOCAL VARIABLES:

75

Page 76: Getm Doc Stable

7.11 hcc check - hydrostatic consistency criteria (Source File: hcc check.F90)

INTERFACE:

subroutine hcc_check()

DESCRIPTION:

This diagnostic routine calculates the hydrostatic consistency hc in each T-point and each layer.hc is defined as:

hci,j,k = max

{

|∂xzk|∆x

12 (hi,j,k + hi+1,j,k)

, |∂yzk|∆y

12 (hi,j,k + hi,j+1,k)

}

. (110)

For the numerical calculation it is used here that ∆x and ∆y can be cancelled out each. For hc ≤ 1,the grid box is hydrostatically consistent, else it is called hydrostatically inconsistent. In the lattercase, numerical problems can be expected for terrain-following coordinates when stratification isstrong.hc is stored in the 3d netcdf output file.

USES:

use domain, only: imin,imax,jmin,jmax,az,au,av,HU,HVuse domain, only: iimin,iimax,jjmin,jjmax,kmaxuse variables_3d, only: hn,hun,hvn,hccIMPLICIT NONE

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

integer :: i,j,kREALTYPE :: du1,du2,dv1,dv2REALTYPE :: x,y

76

Page 77: Getm Doc Stable

7.12 uu momentum 3d - x-momentum eq. (Source File: uu momentum 3d.F90)

INTERFACE:

subroutine uu_momentum_3d(n,bdy3d)

DESCRIPTION:

Here, the budget equation for layer-averaged momentum in eastern direction, pk, is calculated.The physical equation is given as equation (1), the layer-integrated equation as (26), and aftercurvilinear transformation as (38). In this routine, first the Coriolis rotation term, fqk is calculated,either as direct transport averaging, or following Espelid et al. (2000) by using velocity averages(in case the compiler option NEW_CORI is set).As a next step, explicit forcing terms (advection, diffusion, internal pressure gradient, surfacestresses) are added up (into the variable ex(k)), the eddy viscosity is horizontally interpolated tothe U-point, and the barotropic pressure gradient is calculated (the latter includes the pressuregradient correction for drying points, see section 5.5). Afterwards, the matrix is set up for eachwater column, and it is solved by means of a tri-diagonal matrix solver.Finally, the new velocity profile is shifted such that its vertical integral is identical to the timeintegral of the vertically integrated transport. If the compiler option MUDFLAT is defined, thisfitting of profiles is made with respect to the new surface elevation, otherwise to the old surfaceelevation.When GETM is run as a slice model (compiler option SLICE_MODEL is activated), the result forj = 2 is copied to j = 3.

USES:

use exceptionsuse parameters, only: g,avmmol,rho_0use domain, only: imin,jmin,imax,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmax,H,HU,min_depthuse domain, only: dry_u,coru,au,av,az,ax

#if defined CURVILINEAR || defined SPHERICALuse domain, only: dxu,arud1,dxx,dyc,dyx,dxc

#elseuse domain, only: dx,dy

#endifuse variables_2d, only: Uint,Duse bdy_3d, only: do_bdy_3duse variables_3d, only: dt,cnpar,kumin,uu,vv,huo,hun,hvo,uuEx,ww,hvnuse variables_3d, only: num,nuh,sseo,ssun,rruuse variables_3d, only: ssuo

#ifndef NO_BAROCLINICuse variables_3d, only: idpdx

#endif#ifdef UV_TVD

use variables_3d, only: uadv,vadv,wadv,huadv,hvadv,hoadv,hnadv#endif

use halo_zones, only: update_3d_halo,wait_halo,U_TAGuse meteo, only: tausx,airpuse m3d, only: ip_facuse m3d, only: vel_check,min_vel,max_velIMPLICIT NONE

INPUT PARAMETERS:

77

Page 78: Getm Doc Stable

integer, intent(in) :: nlogical, intent(in) :: bdy3d

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,k,rcREALTYPE :: dif(1:kmax-1)REALTYPE :: auxn(1:kmax-1),auxo(1:kmax-1)REALTYPE :: a1(0:kmax),a2(0:kmax)REALTYPE :: a3(0:kmax),a4(0:kmax)REALTYPE :: Res(0:kmax),ex(0:kmax)REALTYPE :: zp,zm,zx,ResInt,Diff,VlocREALTYPE :: gamma=g*rho_0REALTYPE :: cord_curv=_ZERO_integer :: status

78

Page 79: Getm Doc Stable

7.13 vv momentum 3d - y-momentum eq. (Source File: vv momentum 3d.F90)

INTERFACE:

subroutine vv_momentum_3d(n,bdy3d)

DESCRIPTION:

Here, the budget equation for layer-averaged momentum in eastern direction, qk, is calculated.The physical equation is given as equation (2), the layer-integrated equation as (27), and aftercurvilinear transformation as (39). In this routine, first the Coriolis rotation term, fpk is calculated,either as direct transport averaging, or following Espelid et al. (2000) by using velocity averages(in case the compiler option NEW_CORI is set).As a next step, explicit forcing terms (advection, diffusion, internal pressure gradient, surfacestresses) are added up (into the variable ex(k)), the eddy viscosity is horizontally interpolated tothe V-point, and the barotropic pressure gradient is calculated (the latter includes the pressuregradient correction for drying points, see section 5.5). Afterwards, the matrix is set up for eachwater column, and it is solved by means of a tri-diagonal matrix solver.Finally, the new velocity profile is shifted such that its vertical integral is identical to the timeintegral of the vertically integrated transport. If the compiler option MUDFLAT is defined, thisfitting of profiles is made with respect to the new surface elevation, otherwise to the old surfaceelevation.When GETM is run as a slice model (compiler option SLICE_MODEL is activated), the result forj = 2 is copied to j = 1 and j = 3. If the compiler option XZ_PLUME_TEST is set, a slope of yslopefor bottom and isopycnals into the y-direction is prescribed, which has to be hard-coded as localvariable.

USES:

use exceptionsuse parameters, only: g,avmmol,rho_0use domain, only: imin,jmin,imax,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmax,H,HV,min_depthuse domain, only: dry_v,corv,au,av,az,ax

#if defined CURVILINEAR || defined SPHERICALuse domain, only: dyv,arvd1,dxc,dyx,dyc,dxx

#elseuse domain, only: dx,dy

#endifuse variables_2d, only: Vint,Duse bdy_3d, only: do_bdy_3duse variables_3d, only: dt,cnpar,kvmin,uu,vv,huo,hvo,hvn,vvEx,ww,hunuse variables_3d, only: num,nuh,sseo,ssvn,rrvuse variables_3d, only: ssvo

#ifdef XZ_PLUME_TESTuse variables_3d, only: buoy

#endif#ifndef NO_BAROCLINIC

use variables_3d, only: idpdy#endif#ifdef UV_TVD

use variables_3d, only: uadv,vadv,wadv,huadv,hvadv,hoadv,hnadv#endif

use halo_zones, only: update_3d_halo,wait_halo,V_TAGuse meteo, only: tausy,airp

79

Page 80: Getm Doc Stable

use m3d, only: ip_facuse m3d, only: vel_check,min_vel,max_velIMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: nlogical, intent(in) :: bdy3d

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,k,rcREALTYPE :: dif(1:kmax-1)REALTYPE :: auxn(1:kmax-1),auxo(1:kmax-1),fuu(1:kmax)REALTYPE :: a1(0:kmax),a2(0:kmax)REALTYPE :: a3(0:kmax),a4(0:kmax)REALTYPE :: Res(0:kmax),ex(0:kmax)REALTYPE :: zp,zm,zy,ResInt,Diff,UlocREALTYPE :: gamma=g*rho_0REALTYPE :: cord_curv=_ZERO_

#ifdef XZ_PLUME_TESTREALTYPE :: yslope=0.001

#endifinteger :: status

80

Page 81: Getm Doc Stable

7.14 ww momentum 3d - continuity eq. (Source File: ww momentum 3d.F90)

INTERFACE:

subroutine ww_momentum_3d()

DESCRIPTION:

Here, the local continuity equation is calculated in order to obtain the grid-related vertical velocitywk. An layer-integrated equation for this quantity is given as equation (25) which has been derivedfrom the differential formulation (3).Since the kinematic boundary condition must hold (and is used for the derivation of (25)), the grid-related vertical velocity at the surface muzst be zero, i.e. wkmax

= 0. This is a good consistence checkfor the mode splitting, since this is only fulfilled if the vertically integrated continuity equation(which is the sea surface elevation equation calculated on the micro time step) and this localcontinuity equation are compatible.The physical vertical velocity is then recalculated from the grid-related vertical velocity by meansof (32), ... which should soon be coded in the routine tow in the directory futils.

USES:

use domain, only: iimin,iimax,jjmin,jjmax,kmax#if defined(SPHERICAL) || defined(CURVILINEAR)

use domain, only: arcd1,dxv,dyu#else

use domain, only: dx,dy,ard1#endif

use variables_3d, only: dt,kmin,uu,vv,ww,ho,hn#define CALC_HALO_WW

#ifndef CALC_HALO_WWuse domain, only: azuse halo_zones, only: update_3d_halo,wait_halo,z_TAG

#endifIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

REALTYPE :: dtm1integer :: i,j,k

81

Page 82: Getm Doc Stable

7.15 uv advect 3d - 3D momentum advection (Source File: uv advect 3d.F90)

INTERFACE:

subroutine uv_advect_3d(hor_adv,ver_adv,adv_split)

DESCRIPTION:

For the discretisation of the momentum advection terms, two conceptionally different methodshave been implemented in GETM. The first is the straight-forward multidimensional advectionscheme, which is here realised as the first-order upwind scheme, see paragraph Multidimensionalapproach on page 82.In order to make use of the higher-order directional-split methods for tracers (see section 7.24.2),an alternative method is implemented, in which the complete advection step is first made, and thenthe resulting advection terms, which are needed for the calculation of the slow terms, see equations(64) and (65)) are calculated from this (see paragraph Directional-split approach on page 84).The choice which of the two methods to be used is made by means of the compiler option UV_TVDwhich has to be set in the Makefile of the application in order to activate the more accuratebut computationally more demanding high-order directional-split method. The effect of hih-orderadvaction can be impressively studied by means of the freshwater lense test case described in detailby Burchard and Bolding (2002).When working with the option SLICE_MODEL, the calculation of all gradients in y-direction issuppressed.

Multidimensional approach The advective terms in the momentum equation are discretised ina momentum-conservative form. This is carried out here for the advective terms in the u-equation(38) and the v-equation (39) (after multiplying these equations with mn).First advection term in (38):

(

mn ∂X

(ukpk

n

))

i,j,k≈

12 (pi+1,j,k + pi,j,k)ui+1,j,k∆yc

i+1,j − 12 (pi,j,k + pi−1,j,k)ui,j,k∆yc

i,j

∆xui,j∆yu

i,j

(111)

For an upwind scheme, the inter-facial velocities which are defined on T-points are here calculatedas:

ui,j,k =

ui−1,j,k for 12 (pi,j,k + pi−1,j,k) > 0

ui,j,k else.(112)

Second advection term in (38):(

mn ∂Yy(vkpk

m

))

i,j,k≈

12 (qi+1,j,k + qi,j,k)ui,j,k∆x+

i,j − 12 (qi+1,j−1,k + qi,j−1,k)ui,j−1,k∆x+

i,j−1

∆xui,j∆yu

i,j

(113)

For an upwind scheme, the inter-facial velocities which are defined on X-points are here calculatedas:

ui,j,k =

ui,j,k for 12 (qi+1,j,k + qi,j,k) > 0

ui,j+1,k else.(114)

82

Page 83: Getm Doc Stable

First advection term in (39):

(

mn ∂X

(vkqk

n

))

i,j,k≈

12 (pi,j+1,k + pi,j,k)vi,j,k∆y+

i,j − 12 (pi−1,j+1,k + pi−1,j,k)vi−1,j,k∆y+

i−1,j

∆xvi,j∆yv

i,j

(115)

For an upwind scheme, the interfacial velocities which are defined on X-points are here calculatedas:

vi,j,k =

vi,j,k for 12 (pi+1,j,k + pi,j,k) > 0

vi+1,j,k else.(116)

Second advection term in (39):

(

mn ∂Y

(vkqk

m

))

i,j,k≈

12 (qi,j+1,k + qi,j,k)vi,j+1,k∆xc

i,j+1 − 12 (qi,j,k + qi,j−1,k)vi,j,k∆xc

i,j

∆xvi,j∆yv

i,j

(117)

For an upwind scheme, the interfacial velocities which are defined on T-points are here calculatedas:

vi,j,k =

vi,j−1,k for 12 (qi,j,k + qi,j−1,k) > 0

vi,j,k else.(118)

The vertical advection terms in equations (38) and (39) can be discretised in an upstream schemeas well.Vertical advective flux in (38):

(wkuk)i,j ≈ 1

2(wi+1,j,k + wi,j,k)ui,j,k (119)

with

ui,j,k =

ui,j,k for 12 (wi+1,j,k + wi,j,k) > 0,

ui,j,k+1 else.(120)

Vertical advective flux in (39):

(wkvk)i,j ≈ 1

2(wi,j+1,k + wi,j,k)vi,j,k (121)

with

vi,j,k =

vi,j,k for 12 (wi,j+1,k + wi,j,k) > 0,

vi,j,k+1 else.(122)

83

Page 84: Getm Doc Stable

Directional-split approach Multidimensional treatment of advective terms in three-dimensionalmodels is often quite unhandy, especially when higher-order advection schemes are needed. On theother hand, directional-split methods (which update the advected fields in each directional stepand then ”forget” the advection terms) as discussed in section 7.24.2 on page 98, cannot directlybe used for momentum advection when the models are based on mode splitting as e.g. GETM.The reason for this is that the three-dimensional advection terms are also needed for calculatingthe slow terms of the barotropic (external) mode, see equations (64) and (65).The procedure suggested here is as follows. First, the pure momentum advection equations areformally solved with the directional-split method described in section 7.24.2:

∂tpk + ∂x(ukpk) + ∂y(vkpk) + wkuk − wk−1uk−1 = 0, (123)

∂tqk + ∂x(ukqk) + ∂y(vkqk) + wkvk − wk−1vk−1 = 0. (124)

The new solutions pi,j,k and qi,j,k are however not further used, but instead the resulting advectiveterms −(pi,j,k − pi,j,k)/∆t and −(qi,j,k − qi,j,k)/∆t are later applied to the momentum equations(together with other processes such as horizontal diffusion, pressure gradients, etc.) and also usedfor the calculation of the slow terms in (64) and (65).With this method, all higher-order directional-split advection schemes are now available for themomentum advection. The advective fluxes needed for this have to be averaged from the conser-vative advective fluxes resulting from the continuity equation Continuity will still be retained dueto the linearity of the continuity equation.! USES:

use domain, only: iimin,iimax,jjmin,jjmax,kmax,az,au,av,ax#if defined(SPHERICAL) || defined(CURVILINEAR)

use domain, only: dyc,arud1,dxx,dyx,arvd1,dxc#else

use domain, only: dx,dy,ard1#endif

use variables_3d, only: dt,kumin,kvmin,uu,vv,ww,hun,hvn,huo,hvo,uuEx,vvEx#ifdef UV_TVD

use variables_3d, only: uadv,vadv,wadv,huadv,hvadv,hoadv,hnadv#endif

use advection_3d, only: do_advection_3duse halo_zones, only: update_3d_halo,wait_halo,U_TAG,V_TAG

IMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: hor_adv,ver_adv,adv_split

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

84

Page 85: Getm Doc Stable

integer :: i,j,k,rcREALTYPE :: PP(iimin-1:iimax+1,jjmin-1:jjmax+1,1:kmax)REALTYPE :: www(0:kmax)

#ifdef UV_TVDinteger :: azadv(I2DFIELD),auadv(I2DFIELD),avadv(I2DFIELD)REALTYPE :: dxuadv(I2DFIELD),dxvadv(I2DFIELD),area_inv(I2DFIELD)REALTYPE :: dyuadv(I2DFIELD),dyvadv(I2DFIELD)REALTYPE :: AH=_ZERO_

#endif

85

Page 86: Getm Doc Stable

7.16 uv diffusion 3d - hor. momentum diffusion (Source File: uv diffusion 3d.F90)

INTERFACE:

subroutine uv_diffusion_3d(Am)

DESCRIPTION:

Here, the horizontal diffusion terms are discretised in momentum-conserving form as well. Forsimplicity, this shown here for these terms as they appear in equations (38) and (39), i.e. withoutmultiplying them by mn.First horizontal diffusion term in (38):

∂X

(

2AMhk

nm∂Xuk

)

i,j,k

2AMi+1,j,k∆yc

i+1,jhci+1,j,k

ui+1,j,k − ui,j,k

∆xci+1,j

− 2AMi,j,k∆yc

i,jhci,j,k

ui,j,k − ui−1,j,k

∆xci,j

(125)

Second horizontal diffusion term in (38):

∂Y

(

AMhk

m(n∂Yuk + m∂X vk)

)

i,j,k

1

4

(

AMi+1,j+1,k + AM

i,j+1,k + AMi,j,k + AM

i+1,j,k

)

h+i,j,k∆x+

i,j

×(

ui,j+1,k − ui,j,k

∆y+i,j

− vi+1,j,k − vi,j,k

∆x+i,j

)

−1

4

(

AMi+1,j,k + AM

i,j,k + AMi,j−1,k + AM

i+1,j−1,k

)

h+i,j−1,k∆x+

i,j−1

×(

ui,j,k − ui,j−1,k

∆y+i,j−1

− vi+1,j−1,k − vi,j−1,k

∆x+i,j−1

)

(126)

First horizontal diffusion term in (39):

∂Y

(

2AMhk

mn∂Yvk

)

i,j,k

2AMi,j+1,k∆xc

i,j+1hci,j+1,k

vi,j+1,k − vi,j,k

∆yci,j+1

− 2AMi,j,k∆xc

i,jhci,j,k

vi,j,k − vi,j−1,k

∆yci,j

(127)

86

Page 87: Getm Doc Stable

Second horizontal diffusion term in (39):

∂X

(

AMhk

n(n∂Yuk + m∂X vk)

)

i,j,k

1

4

(

AMi+1,j+1,k + AM

i,j+1,k + AMi,j,k + AM

i+1,j,k

)

h+i,j,k∆x+

i,j

×(

ui,j+1,k − ui,j,k

∆y+i,j

− vi+1,j,k − vi,j,k

∆x+i,j

)

−1

4

(

AMi,j+1,k + AM

i−1,j+1,k + AMi−1,j,k + AM

i,j,k

)

h+i−1,j,k∆x+

i−1,j

×(

ui−1,j+1,k − ui−1,j,k

∆y+i−1,j

− vi,j,k − vi−1,j,k

∆x+i−1,j

)

(128)

It is assumed here that the horizontal momentum diffusivities AMi,j,k are located on the T-points.

For the case of a slice model simulation (compiler option SLICE_MODEL activated) the diffusivefluxes in y-direction are set to zero.

USES:

use domain, only: iimin,iimax,jjmin,jjmax,kmax,az,au,av,ax#if defined(SPHERICAL) || defined(CURVILINEAR)

use domain, only: dyc,arud1,dxx,dyx,arvd1,dxc#else

use domain, only: dx,dy,ard1#endif

use variables_3d, only: kumin,kvmin,uu,vv,ww,hn,hun,hvn,uuEx,vvExIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: Am

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,k,ii,jj,kkREALTYPE :: PP(iimin-1:iimax+1,jjmin-1:jjmax+1,1:kmax)REALTYPE :: www(0:kmax)

87

Page 88: Getm Doc Stable

7.17 bottom friction 3d - bottom friction (Source File: bottom friction 3d.F90)

INTERFACE:

subroutine bottom_friction_3d

DESCRIPTION:

Based on the assumption that the velocity distribution in the bottom layer is logarithmic, theproduct of the drag coefficient with the absolute value of the current speed in the bottom layer,

r√

u2b + v2

b (129)

with the velocity components of the bottom layer, ub and vb, and the drag coefficient

r =

κ

ln(

0.5h1+zb0

zb0

)

2

, (130)

is calculated and provided as output parameters rru (for U-points) and rrv (for V-points). Thelayer height h1 in (130) is set to the thickness of the bottom layer in the respective U- or V-point.There are some experimental options for the interested user included here. It is possible to changethe interpolation of u to V-points and of v to U-points from velocity-based interpolation (as donepresently) to transport-based averaging (commented out). Furthermore, the user may activate someoutcommented lines which allow the consideration of flow-depending bottom roughness length zb

0according to (91), see page 47.For a derivation of (130), see section 5.4 on page 28.

USES:

use parameters, only: kappa,avmmoluse domain, only: iimin,iimax,jjmin,jjmax,kmax,au,av,min_depthuse variables_2d, only: zub,zvb,zub0,zvb0use variables_3d, only: kumin,kvmin,uu,vv,huo,hun,hvo,hvn,rru,rrvIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,kkREALTYPE :: r,hh,fricvellogical, save :: first=.true.REALTYPE :: uuloc(I2DFIELD)REALTYPE :: uvloc(I2DFIELD)REALTYPE :: vuloc(I2DFIELD)REALTYPE :: vvloc(I2DFIELD)

88

Page 89: Getm Doc Stable

7.18 Module internal pressure (Source File: internal pressure.F90)

INTERFACE:

module internal_pressure

DESCRIPTION:

In GETM, various methods are provided for the calculation of the internal pressure gradients termsin x- and y-direction. These terms which appear as layer-integrated terms in the equations for thelayer-integrated momentum are for the eastward momentum pk (see equation (26)):

hk

1

2hN (∂∗

xb)N +N−1∑

j=k

1

2(hj + hj+1)(∂

∗xb)j

(131)

and for the northward layer-integrated momentum qk (see equation (27)):

hk

1

2hN (∂∗

yb)N +

N−1∑

j=k

1

2(hj + hj+1)(∂

∗yb)j

(132)

The major problem is how to calculate the horizontal (with respect to isogeopotentials) buoyancygradients ∂∗

xb and ∂∗yb, which need to be defined at the interfaces positioned vertically between two

velocity points.The methods for calculating the internal pressure gradient included in GETM are currently:

1. Method by Mellor et al. (1994), see routine ip_blumberg_mellor

2. Modified Mellor et al. (1994) method, exact for linear density profiles with z-dependenceonly, see routine ip_blumberg_mellor_lin

3. Calculation by mean of linear interpolation to z-levels, see routine ip_z_interpol

4. Method by Song (1998), see routine ip_song_wright

5. Method by Chu and Fan (2003), see routine ip_chu_fan

It is possible, by setting the compiler option SUBSTR_INI_PRESS, to substract the initial pressuregradient from all pressure gradients. This is only advisable for strong stratification without anyinitial internal pressure gradients. In this case any non-zero values of the resulting numerical initialpressure gradient are due to discretisation errors.

USES:

use exceptionsuse domain, only: iimin,iimax,jjmin,jjmax,kmax,az,au,av,H,HU,HV

#if defined(SPHERICAL) || defined(CURVILINEAR)use domain, only: dxu,dyv

#elseuse domain, only: dx,dy

#endifuse variables_3d, only: kmin,hn,hun,hvn,idpdx,idpdy,buoyIMPLICIT NONE

PUBLIC DATA MEMBERS:

89

Page 90: Getm Doc Stable

public init_internal_pressure, do_internal_pressureinteger, public :: ip_method=1

#ifdef STATICREALTYPE :: zz(I3DFIELD)

#ifdef SUBSTR_INI_PRESSREALTYPE :: idpdx0(I3DFIELD),idpdy0(I3DFIELD)

#endif#else

REALTYPE, allocatable :: zz(:,:,:)#ifdef SUBSTR_INI_PRESS

REALTYPE, allocatable :: idpdx0(:,:,:),idpdy0(:,:,:)#endif#endif!PRIVATE DATA MEMBERS:integer, private, parameter :: BLUMBERG_MELLOR=1integer, private, parameter :: BLUMBERG_MELLOR_LIN=2integer, private, parameter :: Z_INTERPOL=3integer, private, parameter :: SONG_WRIGHT=4integer, private, parameter :: CHU_FAN=5

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

7.18.1 init internal pressure - initialising internal pressure gradient

INTERFACE:

subroutine init_internal_pressure()IMPLICIT NONE

DESCRIPTION:

Here, some necessary memory is allocated (in case of the compiler option STATIC), and informationis written to the log-file of the simulation.!LOCAL VARIABLES integer :: rc

7.18.2 do internal pressure - internal pressure gradient

INTERFACE:

subroutine do_internal_pressure()

DESCRIPTION:

Here, the chosen internal pressure gradient method is selected and (in case that the compileroption SUBSTR_INI_PRESS is set), the initial pressure is calculated and subtracted from the updatedinternal pressure gradient.If GETM is executed as slice model (compiler option SLICE_MODEL is set, the internal pressuregradient for j = 2 is copied to j = 3.

USES:

90

Page 91: Getm Doc Stable

IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,j,klogical, save :: first=.true.

91

Page 92: Getm Doc Stable

7.19 ip blumberg mellor - (Source File: ip blumberg mellor.F90)

INTERFACE:

subroutine ip_blumberg_mellor()

DESCRIPTION:

Here, the internal part of the pressure gradient is discretised according to Mellor et al. (1994). Thecrucial part of this term, which is (∂∗

xb)k (in the case of the u-equation), is discretised between twovertically adjacent velocity points:

1

2(hi,j,k + hi,j,k+1) (m ∂∗

X b)i,j,k

≈ 1

2(hu

i,j,k + hui,j,k+1)

12 (bi+1,j,k+1 + bi+1,j,k) − 1

2 (bi,j,k+1 + bi,j,k)

∆xui,j

−zi

i+1,j,k − zii,j,k

∆xui,j

(

1

2(bi+1,j,k+1 + bi,j,k+1) −

1

2(bi+1,j,k + bi,j,k)

)

,

(133)

where zii,j,k is the z-coordinate of the interface in the T-point above the grid box with the index

(i, j, k).The discretisation of (∂∗

yb)k for the v-equation is done accordingly.In this routine, as a first step, the interface heights are calculated in the T-points, in order to allowfor the calculation of the coordinate slopes in the U- and V-points. In a second step, the expression(133) equivalent formulation for the y-direction are integrated up downwards, beginning from thesurface.

USES:

use internal_pressureIMPLICIT NONE

REVISION HISTORY:

Original author(s): Hans Burchard, Adolf Stips, Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,kREALTYPE :: dxm1,dym1REALTYPE :: grdl,grdu,buoyl,buoyu,prgr,dxz,dyz

92

Page 93: Getm Doc Stable

7.20 ip blumberg mellor lin (Source File: ip blumberg mellor lin.F90)

INTERFACE:

subroutine ip_blumberg_mellor_lin()

DESCRIPTION:

Here, the internal pressure gradient calculation is carried out on the basis of the same buoyancystencil than in the method according to Mellor et al. (1994) (see routine ip_blumberg_mellor),but in such a way that the pressure gradient numerically vanishes for linear stratification withouthorizontal gradients.

1

2(hi,j,k + hi,j,k+1) (m ∂∗

X b)i,j,k

≈ 1

2(hu

i,j,k + hui,j,k+1)

[

12 (bi+1,j,k+1 + bi+1,j,k) − 1

2 (bi,j,k+1 + bi,j,k)

∆xui,j

−1

2

(

12 (zc

i+1,j,k+1 + zci+1,j,k) − 1

2 (zci,j,k+1 + zc

i,j,k)

∆xui,j

)

1

2

(

bi+1,j,k+1 − bi+1,j,k

zci+1,j,k+1 − zc

i+1,j,k

+bi,j,k+1 − bi,j,k

zci,j,k+1 − zc

i,j,k

)]

,

(134)

where zci,j,k is the z-coordinate of the centre of the grid box with the index (i, j, k).

The discretisation of (∂∗yb)k for the v-equation is done accordingly.

USES:

use internal_pressureuse variables_3d, only: kumin_pmz,kvmin_pmzIMPLICIT NONE

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,kREALTYPE :: dxm1,dym1REALTYPE :: prgr,dxzu,dxzl,dyzu,dyzlREALTYPE :: dzr2,dzr1,dxru,dxrl,dyru,dyrl,aa,bb,cc

93

Page 94: Getm Doc Stable

7.21 ip z interpol (Source File: ip z interpol.F90)

INTERFACE:

subroutine ip_z_interpol()

DESCRIPTION:

Here, the horizontal gradients of buoyancy, (∂∗xb)k and (∂∗

yb)k, are directly calculated in z-coordinatesby linearly interpolating the buoyancies in the vertical to the evaluation point (which is the in-terface vertically located between the velocity points). In the case that extrapolations becomenecessary near the sloping surface (or more likely) near the sloping bottom, then the last regularbuoyancy value (surface value or bottom value) is used.

USES:

use internal_pressureIMPLICIT NONE

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,kREALTYPE :: dxm1,dym1REALTYPE :: grdl,grdu,buoyl,prgr,dxz,dyzinteger :: kplus,kminusREALTYPE :: zx(kmax)REALTYPE :: buoyplus,buoyminus

94

Page 95: Getm Doc Stable

7.22 ip song wright (Source File: ip song wright.F90)

INTERFACE:

subroutine ip_song_wright()

DESCRIPTION:

Here, the pressure gradient is calculating according to an energy-conserving method suggested bySong (1998), which for the pressure gradient in x-direction looks as:

1

2(hi,j,k + hi,j,k+1) (m ∂∗

X b)i,j,k

≈14 (bi+1,j,k+1 + bi+1,j,k)(hc

i+1,j,k+1 + hci+1,j,k) − 1

4 (bi,j,k+1 + bi,j,k)(hci,j,k+1 + hc

i,j,k)

∆xui,j

−[

1

2(bi+1,j,k+1 + bi,j,k+1)

zci+1,j,k+1 − zc

i,j,k+1

∆xui,j

−1

2(bi+1,j,k + bi,j,k)

zci+1,j,k − zc

i,j,k

∆xui,j

]

,

(135)

where zci,j,k is the z-coordinate of the centre of the grid box with the index (i, j, k).

The discretisation of (∂∗yb)k for the v-equation is done accordingly.

USES:

use internal_pressureIMPLICIT NONE

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,kREALTYPE :: dxm1,dym1REALTYPE :: grdl,grdu,buoyl,buoyu,prgr,dxz,dyz

95

Page 96: Getm Doc Stable

7.23 ip chu fan (Source File: ip chu fan.F90)

INTERFACE:

subroutine ip_chu_fan()

DESCRIPTION:

This routine calculates the internal pressure gradient based on the classical approach by Melloret al. (1994), extended by the hydrostatic extension by Chu and Fan (2003).

USES:

use internal_pressureIMPLICIT NONE

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding & Adolf Stips

LOCAL VARIABLES:

integer :: i,j,kREALTYPE :: dxm1,dym1,x,y,x1,y1,hcREALTYPE :: grdl,grdu,buoyl,buoyu,prgr,dxz,dyz

96

Page 97: Getm Doc Stable

7.24 Module 3D advection (Source File: advection 3d.F90)

INTERFACE:

module advection_3d

DESCRIPTION:

This module do advection of scalars. The module follows the same convention as the othermodules in ’getm’. The module is initialised by calling ’init advection 3d()’. In the time-loop’do advection 3d’ is called. ’do advection 3d’ is a wrapper routine which - dependent on the ac-tual advection scheme chosen - makes calls to the appropriate subroutines, which may be done asone-step or multiple-step schemes. The actual subroutines are coded in external FORTRAN files.New advection schemes are easily implemented - at least from a program point of view - since onlythis module needs to be changed. Additional work arrays can easily be added following the stencilgiven below. To add a new advection scheme three things must be done:

1. define a unique constant to identify the scheme (see e.g. UPSTREAM and TVD)

2. adopt the select case in do_advection_3d and

3. write the actual subroutine.

USES:

use domain, only: imin,imax,jmin,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmaxuse halo_zones, only: update_3d_halo,wait_halo,D_TAGIMPLICIT NONEprivate

PUBLIC DATA MEMBERS:

public init_advection_3d, do_advection_3d#ifdef STATIC

REALTYPE, public :: cu(I3DFIELD)REALTYPE, public :: hi(I3DFIELD)REALTYPE, public :: hio(I3DFIELD)

#elseREALTYPE, public, dimension(:,:,:), allocatable :: hi,hio,cu

#endifinteger, public, parameter :: UPSTREAM=1,UPSTREAM_SPLIT=2,P2=3integer, public, parameter :: Superbee=4,MUSCL=5,P2_PDM=6,FCT=7REALTYPE, public, parameter :: one6th=1./6.REALTYPE, public, parameter :: ONE=_ONE_,TWO=2.*_ONE_

!PRIVATE DATA MEMBERS:

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

integer :: advection_method

97

Page 98: Getm Doc Stable

7.24.1 init advection 3d

INTERFACE:

subroutine init_advection_3d(method)

DESCRIPTION:

Here, memory for some variables is allocated, which are then initialised to zero.!USES IMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: method

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: rc

7.24.2 do advection 3d - 3D advection schemes

INTERFACE:

subroutine do_advection_3d(dt,f,uu,vv,ww,hun,hvn,ho,hn, &delxu,delxv,delyu,delyv,area_inv, &az,au,av,hor_adv,ver_adv,adv_split,AH)

DESCRIPTION:

Here, advection terms for all three-dimensional state variables are calculated by means of a finite-volume approach (an exception is the possibility to directly calculate the momentum advection bya one-step three-dimensional upstream scheme, see uv_advection_3d) and the advection step iscarried out as a fractional advection time step. Those 3D variables may be defined on T-, U-, V-and W-points. The latter option is interesting for turbulent quantities, but is not coded yet. Insidethis advection routine, it does not matter, wehre the advected variable is located on the grid. Allfinite volume fluxes and geometric coefficients need to be calculated before advection_3d is called.Originally, this 3D advection routine has been written for tracer equations. There, after multiplyingthe layer-integrated and transformed to curvilinear coordinates tracer equation (40) with mn, theadvective terms in this equation are discretised as follows.First advection term in (40):

(

mn ∂X

(pkck

n

))

i,j≈

pi,j,k cui,j,k∆yu

i,j − pi−1,j,k cui−1,j,k∆yu

i−1,j

∆xci,j∆yc

i,j

(136)

Second advection term in (40):

(

mn ∂Y

(qkck

m

))

i,j≈

qi,j,k cvi,j,k∆yv

i,j − qi,j−1,k cvi,j−1,k∆yv

i,j−1

∆xci,j∆yc

i,j

(137)

98

Page 99: Getm Doc Stable

Vertical advective fluxes in (40):(wk ck)i,j ≈ wi,j,k cw

i,j,k. (138)

The interfacial concentrations ci,j,k are calculated according to upwind or higher order directionalsplit schemes, which are discussed in detail below and in sections 7.24.3 - 7.24.9.However, as said above, in the same way these routines may be applied to quantities on U-, V-,and W-points, if the transports and geometric coefficients are properly calculated.There are various combinations of advection schemes possible. The first selection is whether aone-step 3D first-order upstream method is cosen, or a fractional step method.The next selection is (if a fractional step method is selected) how to do the fractional steps (selectionon adv_split). There are different options,

1. directional split with subsequent full steps in x-, y- and z-direction,

2. split with subsequent half steps in x-, and y-direction, a full step in z-direction, and halfsteps in y- and x-direction.

3. directional split into a 2D horizontal step and a 1D vertical step.

For the 1D directional-split schemes, first-order upstream, ULTIMATE QUICKEST, and the TotalVariation Diminishing (TVD) schemes Superbee, MUSCL, and P2PDM are available.For the 2D horizontal step, an upstream scheme and a Flux-Corrected Transport (FCT) schemehave been coded.If the compiler option ITERATE_VERT_ADV is chosen, the vertical advection is iterated as manytimes with reduced time step that the CFL criterium for vertical advection is fulfilled, see theroutine w_split_it_adv.With the compiler option SLICE_MODEL, the advection in y-direction is not executed.

USES:

IMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: uu(I3DFIELD) ! layer-integrated x-transportREALTYPE, intent(in) :: vv(I3DFIELD) ! layer-integrated y-transportREALTYPE, intent(in) :: ww(I3DFIELD) ! grid-related vertical velocityREALTYPE, intent(in) :: ho(I3DFIELD) ! old height of finite volume boxREALTYPE, intent(in) :: hn(I3DFIELD) ! new height of finite volume boxREALTYPE, intent(in) :: hun(I3DFIELD) ! height of x-interfacesREALTYPE, intent(in) :: hvn(I3DFIELD) ! height of y-interfacesREALTYPE, intent(in) :: delxu(I2DFIELD) ! dx centered on u-transport pt.REALTYPE, intent(in) :: delxv(I2DFIELD) ! length of y-interfaceREALTYPE, intent(in) :: delyu(I2DFIELD) ! length of u-interfaceREALTYPE, intent(in) :: delyv(I2DFIELD) ! dy centered on v-transport pt.REALTYPE, intent(in) :: area_inv(I2DFIELD) ! inverse of horizontal box areaREALTYPE, intent(in) :: dt ! advection time stepREALTYPE, intent(in) :: AH ! constant horizontal diffusivityinteger, intent(in) :: az(E2DFIELD) ! mask for box centre (1: water)integer, intent(in) :: au(E2DFIELD) ! mask for u-transport (1: water)integer, intent(in) :: av(E2DFIELD) ! mask for v-transport (1: water)integer, intent(in) :: hor_adv ! selection for horizontal schemeinteger, intent(in) :: ver_adv ! selection for vertical schemeinteger, intent(in) :: adv_split ! selection for split mode

INPUT/OUTPUT PARAMETERS:

99

Page 100: Getm Doc Stable

REALTYPE, intent(inout) :: f(I3DFIELD)

OUTPUT PARAMETERS:

LOCAL VARIABLES:

REALTYPE, parameter :: a1=0.5*ONE,a2=ONEinteger :: k

7.24.3 upstream adv - 3D upstream advection

INTERFACE:

subroutine upstream_adv(dt,f,uu,vv,ww,ho,hn, &delxv,delyu,delxu,delyv,area_inv,az,AH)

DESCRIPTION:

Here the advection terms (136), (137) and (138) are calculated by a upstream scheme and theadvection is done in one single time step.This means that the variable to advect is approximated at the interfaces as:

cui,j,k =

ci,j,k for pi,j,k ≥ 0,

ci+1,j,k else,(139)

cvi,j,k =

ci,j,k for qi,j,k ≥ 0,

ci,j+1,k else,(140)

and

cwi,j,k =

ci,j,k for wi,j,k ≥ 0,

ci,j,k+1 else.(141)

It should be noted that the quantities pi,j,k, qi,j,k, wi,j,k are defined relative to the finite volumebox, and may (if ci,j,k defines velocities) be calculated by means of interpolation.Then, the one-step scheme is executed as follows:

hni,j,kcn

i,j,k = hoi,j,kco

i,j,k

−∆t

(

pi,j,k cui,j,k∆yu

i,j − pi−1,j,k cui−1,j,k∆yu

i−1,j

∆xci,j∆yc

i,j

+qi,j,k cv

i,j,k∆yvi,j − qi,j−1,k cv

i,j−1,k∆yvi,j−1

∆xci,j∆yc

i,j

+wi,j,k cwi,j,k − wi,j,k−1c

wi,j,k−1

)

,

(142)with the suffices n and o denoting new and old values, respectively.

USES:

100

Page 101: Getm Doc Stable

use domain, only: imin,imax,jmin,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmaxuse advection_3d, only: cuIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: uu(I3DFIELD),vv(I3DFIELD)REALTYPE, intent(in) :: ww(I3DFIELD)REALTYPE, intent(in) :: ho(I3DFIELD),hn(I3DFIELD)REALTYPE, intent(in) :: delxv(I2DFIELD),delyu(I2DFIELD)REALTYPE, intent(in) :: delxu(I2DFIELD),delyv(I2DFIELD)REALTYPE, intent(in) :: area_inv(I2DFIELD),dt,AHinteger, intent(in) :: az(E2DFIELD)

INPUT/OUTPUT PARAMETERS:

REALTYPE, intent(inout) :: f(I3DFIELD)

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: rc,i,ii,j,jj,k,kk#ifdef USE_ALLOCATED_ARRAYS

REALTYPE, dimension(:,:,:), allocatable :: adv#else

REALTYPE :: adv(I3DFIELD)#endif

7.24.4 upstream 2dh adv - 2D upstream advection

INTERFACE:

subroutine upstream_2dh_adv(dt,f,uu,vv,ho,hn,hun,hvn, &delxv,delyu,delxu,delyv,area_inv,az,AH)

DESCRIPTION:

In this routine, the first-order upstream advection scheme is applied for the two horizontal directionsin one step. The scheme should be positive definite and of high resolution. In order to remove trun-cation errors which might in Wadden Sea applications cause non-monotonicity, a truncation of over-and undershoots is carried out at the end of this subroutine. Such two-dimensional schemes areadvantageous in Wadden Sea applications, since one-dimensional directional-split schemes mightcompute negative intermediate depths.Before or after this 2D-horizontal advection is executed, a 1D vertical advection step, possibly withanother scheme, needs to be carried out.The advection terms are calculated according to (136) and (137) and the interface fluxes are againcalculated according to (139) and (140).

101

Page 102: Getm Doc Stable

However, here in contrast to the one-step advection scheme with (142) implemented in upstream_adv,first the complete horizontal and then the complete vertical advection needs to be executed. Forconsistency and conservation reasons, a partial step for the continuity equation needs to be executedas well. This is done as follows:

hni,j,kcn

i,j,k = hoi,j,kco

i,j,k

−∆t

(

pi,j,k cui,j,k∆yu

i,j − pi−1,j,k cui−1,j,k∆yu

i−1,j

∆xci,j∆yc

i,j

+qi,j,k cv

i,j,k∆yvi,j − qi,j−1,k cv

i,j−1,k∆yvi,j−1

∆xci,j∆yc

i,j

)

,

(143)with the layer height changes

hni,j,k = ho

i,j,k − ∆t

(

pi,j,k∆yui,j − pi−1,j,k∆yu

i−1,j

∆xci,j∆yc

i,j

+qi,j,k∆yv

i,j − qi,j−1,k∆yvi,j−1

∆xci,j∆yc

i,j

)

. (144)

Here, n and o denote values before and after this operation, respectively, n denote intermediatevalues when the 1D advection step comes after this and o denotes intermediate values when the1D advection step came before this.

USES:

use domain, only: imin,imax,jmin,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmaxuse advection_3d, only: hi,hioIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: uu(I3DFIELD),vv(I3DFIELD)REALTYPE, intent(in) :: ho(I3DFIELD),hn(I3DFIELD)REALTYPE, intent(in) :: hun(I3DFIELD),hvn(I3DFIELD)REALTYPE, intent(in) :: delxv(I2DFIELD),delyu(I2DFIELD)REALTYPE, intent(in) :: delxu(I2DFIELD),delyv(I2DFIELD)REALTYPE, intent(in) :: area_inv(I2DFIELD),dt,AHinteger, intent(in) :: az(E2DFIELD)

INPUT/OUTPUT PARAMETERS:

REALTYPE, intent(inout) :: f(I3DFIELD)

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: rc,i,j,k,ii,jj#ifdef USE_ALLOCATED_ARRAYS

REALTYPE, dimension(:,:,:), allocatable :: flx,flyREALTYPE, dimension(:,:,:), allocatable :: cmin,cmax

#elseREALTYPE :: flx(I3DFIELD),fly(I3DFIELD)REALTYPE :: cmin(I3DFIELD),cmax(I3DFIELD)

#endif

102

Page 103: Getm Doc Stable

7.24.5 u split adv - 1D x-advection

INTERFACE:

subroutine u_split_adv(dt,f,uu,hun, &delxu,delyu,area_inv,au,splitfac,method,az,AH)

DESCRIPTION:

Here, the x-directional split 1D advection step is executed with a number of options for the numer-ical scheme. The basic advection equation is accompanied by an fractional step for the continuityequation and both equations look as follows:

hni,j,kcn

i,j,k = hoi,j,kco

i,j,k − ∆tpi,j,k cu

i,j,k∆yui,j − pi−1,j,kcu

i−1,j,k∆yui−1,j

∆xci,j∆yc

i,j

, (145)

with the 1D continuity equation

hni,j,k = ho

i,j,k − ∆tpi,j,k∆yu

i,j − pi−1,j,k∆yui−1,j

∆xci,j∆yc

i,j

(146)

Here, n and o denote values before and after this operation, respectively, n denote intermediatevalues when other 1D advection steps come after this and o denotes intermediate values when other1D advection steps came before this. Furthermore, when this x-directional split step is repeatedduring the total time step (Strang splitting), the time step ∆t denotes a fraction of the full timestep.The interfacial fluxes cu

i,j,k are calculated by means of monotone Total Variation Diminishing

(TVD), the first-order monotone upstream and the (non-monotone) unlimited third-order polyno-mial scheme according to:

ci,j,k =

(

ci,j,k + 12 c+

i,j,k(1 − |Ci,j,k|)(ci+1,j,k − ci,j,k))

for pi,j,k ≥ 0,

(

ci+1,j,k + 12 c−i,j,k(1 − |Ci,j,k|)(ci,j,k − ci+1,j,k)

)

else,

(147)

with the Courant number Ci,j,k = ui,j,k∆t/∆x and

c+i,j,k = αi,j,k + βi,j,kr+

i,j,k, c−i,j,k = αi,j,k + βi,j,kr−i,j,k, (148)

where

αi,j,k =1

2+

1

6(1 − 2|Ci,j,k|), βi,j,k =

1

2− 1

6(1 − 2|Ci,j,k|), (149)

and

r+i,j,k =

ci,j,k − ci−1,j,k

ci+1,j,k − ci,j,k, r+

i,j,k =ci+2,j,k − ci+1,j,k

ci+1,j,k − ci,j,k. (150)

It should be noted that by formulation (147) this so-called P2 scheme is cast into the so-calledLax-Wendroff form, which would be recovered for c+

i,j,k = c−i,j,k = 1.

In order to obtain a monotonic and positive scheme, the factors c+i,j,k are limited in the following

way:

c+i,j,k → max

[

0, min

(

c+i,j,k,

2

1 − |Ci,j,k|,

2r+i,j,k

|Ci,j,k|

)]

, (151)

103

Page 104: Getm Doc Stable

and, equivalently, for c−i,j,k. This so-called PDM-limiter has been described in detail by Leonard

(1991), who named the PDM-limited P2 scheme also ULTIMATE QUICKEST (quadratic upstreaminterpolation for convective kinematics with estimated stream terms).Some simpler limiters which do not exploit the third-order polynomial properties of the discretisa-tion (147) have been listed by Zalezak (1987). Among those are the MUSCL scheme by van Leer(1979),

c+i,j,k → max

[

0, min

(

2, 2r+i,j,k,

1 + r+i,j,k

2

)]

, (152)

and the Superbee scheme by Roe (1985),

c+i,j,k → max

[

0, min(1, 2r+i,j,k), min(r+

i,j,k, 2)]

. (153)

The selector for the schemes is method:

method = UPSTREAM_SPLIT: first-order upstream (monotone)method = P2: third-order polynomial (non-monotone)method = P2_PDM: third-order ULTIMATE-QUICKEST (monotone)method = MUSCL: second-order TVD (monotone)method = Superbee: second-order TVD (monotone)

Furthermore, the horizontal diffusion in y-direction with the constant diffusion coefficient AH iscarried out here by means of a central difference second-order scheme.

USES:

use domain, only: imin,imax,jmin,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmaxuse advection_3d, only: hi,hio,cuuse advection_3d, only: UPSTREAM_SPLIT,P2,SUPERBEE,MUSCL,P2_PDMuse advection_3d, only: ONE,TWO,ONE6THIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: uu(I3DFIELD),hun(I3DFIELD)REALTYPE, intent(in) :: delxu(I2DFIELD),delyu(I2DFIELD)REALTYPE, intent(in) :: area_inv(I2DFIELD),dtinteger, intent(in) :: au(E2DFIELD), az(E2DFIELD)REALTYPE, intent(in) :: splitfacinteger, intent(in) :: methodREALTYPE, intent(in) :: AH

INPUT/OUTPUT PARAMETERS:

REALTYPE, intent(inout) :: f(I3DFIELD)

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

104

Page 105: Getm Doc Stable

integer :: i,ii,j,jj,k,kkREALTYPE :: c,alpha,beta,x,r,Phi,limit,fu,fc,fd

7.24.6 v split adv - 1D y-advection

INTERFACE:

subroutine v_split_adv(dt,f,vv,hvn, &delxv,delyv,area_inv,av,splitfac,method,az,AH)

DESCRIPTION:

Here, the y-directional split 1D advection step is executed with a number of options for the numer-ical scheme. The basic advection equation is accompanied by an fractional step for the continuityequation and both equations look as follows:

hni,j,kcn

i,j,k = hoi,j,kco

i,j,k − ∆tqi,j,k cv

i,j,k∆yvi,j − qi,j−1,k cv

i,j−1,k∆yvi,j−1

∆xci,j∆yc

i,j

, (154)

with the 1D continuity equation

hni,j,k = ho

i,j,k − ∆tqi,j,k∆yv

i,j − qi,j−1,k∆yvi,j−1

∆xci,j∆yc

i,j

. (155)

Here, n and o denote values before and after this operation, respectively, n denote intermediatevalues when other 1D advection steps come after this and o denotes intermediate values when other1D advection steps came before this. Furthermore, when this y-directional split step is repeatedduring the total time step (Strang splitting), the time step ∆t denotes a fraction of the full timestep.The interfacial fluxes cv

i,j,k are calculated by means of monotone and non-monotone schemes whichare described in detail in u_split_adv, see section 7.24.5 on page 103.Furthermore, the horizontal diffusion in y-direction with the constant diffusion coefficient AH iscarried out here by means of a central difference second-order scheme.

USES:

use domain, only: imin,imax,jmin,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmaxuse advection_3d, only: hi,hio,cuuse advection_3d, only: UPSTREAM_SPLIT,P2,SUPERBEE,MUSCL,P2_PDMuse advection_3d, only: ONE,TWO,ONE6THIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: vv(I3DFIELD),hvn(I3DFIELD)REALTYPE, intent(in) :: delxv(I2DFIELD),delyv(I2DFIELD)REALTYPE, intent(in) :: area_inv(I2DFIELD),dtinteger, intent(in) :: av(E2DFIELD),az(E2DFIELD)REALTYPE, intent(in) :: splitfacinteger, intent(in) :: methodREALTYPE, intent(in) :: AH

INPUT/OUTPUT PARAMETERS:

105

Page 106: Getm Doc Stable

REALTYPE, intent(inout) :: f(I3DFIELD)

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,ii,j,jj,k,kkREALTYPE :: c,alpha,beta,x,r,Phi,limit,fu,fc,fd

7.24.7 w split adv - 1D z-advection

INTERFACE:

subroutine w_split_adv(dt,f,ww,az,splitfac,method)

DESCRIPTION:

Here, the z-directional split 1D advection step is executed with a number of options for the numer-ical scheme. The basic advection equation is accompanied by an fractional step for the continuityequation and both equations look as follows:

hni,j,kcn

i,j,k = hoi,j,kco

i,j,k − ∆t(

wi,j,k cwi,j,k − wi,j,k−1c

wi,j,k−1

)

, (156)

with the 1D continuity equation

hni,j,k = ho

i,j,k − ∆t(

wi,j,k−wi,j,k−1

)

. (157)

Here, n and o denote values before and after this operation, respectively, n denote intermediatevalues when other 1D advection steps come after this and o denotes intermediate values when other1D advection steps came before this.The interfacial fluxes cw

i,j,k are calculated by means of monotone and non-monotone schemes whichare described in detail in u_split_adv, see section 7.24.5 on page 103.

USES:

use domain, only: imin,imax,jmin,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmaxuse advection_3d, only: hi,hio,cuuse advection_3d, only: UPSTREAM_SPLIT,P2,SUPERBEE,MUSCL,P2_PDMuse advection_3d, only: ONE,TWO,ONE6THIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE , intent(in) :: ww(I3DFIELD),dtinteger , intent(in) :: az(E2DFIELD)REALTYPE, intent(in) :: splitfacinteger, intent(in) :: method

INPUT/OUTPUT PARAMETERS:

106

Page 107: Getm Doc Stable

REALTYPE, intent(inout) :: f(I3DFIELD)

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,ii,j,jj,k,kkREALTYPE :: c,alpha,beta,x,r,Phi,limit,fu,fc,fd

7.24.8 w split it adv - iterated 1D z-advection

INTERFACE:

subroutine w_split_it_adv(dt,f,ww,az,splitfac,method)

DESCRIPTION:

Here, the same one-dimensional advection step as in w_split_adv (see section 7.24.7 on page 106)is applied, but with an iteration in time in case that the vertical Courant number exceeds unity atany interface of the water column under calculation.The number of time steps is calculated as

N∆t

i,j = maxk

{int (Ci,j,k + 1)} , (158)

with the Courant number

Ci,j,k = |wi,j,k|∆t

12

(

hni,j,k + hn

i,j,k+1

) (159)

and the truncation function int.After the number of iterations N∆t

i,j is calculated, the vertical advection step is calculated N∆t

i,j

with a time step of ∆t/N∆t

i,j . By doing so, it is avoided that the model blows up due to violationof the CFL criterium, which could happen fast in case of high vertical resolution together withprocesses such as upwelling or fast sinking material. The good thing about this procedure is thatonly the water column is punished by higher numerical load in which the potential violation of theCFL criterium occurs.

USES:

use domain, only: imin,imax,jmin,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmaxuse advection_3d, only: hi,hio,cuuse advection_3d, only: UPSTREAM_SPLIT,P2,SUPERBEE,MUSCL,P2_PDMuse advection_3d, only: ONE,TWO,ONE6THIMPLICIT NONE

INPUT PARAMETERS:

107

Page 108: Getm Doc Stable

REALTYPE , intent(in) :: ww(I3DFIELD),dtinteger , intent(in) :: az(E2DFIELD)REALTYPE, intent(in) :: splitfacinteger, intent(in) :: method

INPUT/OUTPUT PARAMETERS:

REALTYPE, intent(inout) :: f(I3DFIELD)

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,ii,j,jj,k,kk,itREALTYPE :: c,alpha,beta,x,r,Phi,limit,fu,fc,fd,cmaxlogical :: READY

7.24.9 fct 2dh adv - 2D flux-corrected transport

INTERFACE:

subroutine fct_2dh_adv(dt,f,uu,vv,ho,hn,hun,hvn, &delxv,delyu,delxu,delyv,area_inv,az,AH)

DESCRIPTION:

In this routine, the flux corrected transport advection scheme by Zalezak (1979) is applied for thetwo horizontal directions in one step. For details of this type of operator splitting, see the routineupstream_2dh_adv (see section 7.24.4 on page 101).The monotone low-order flux is the first-order upstream scheme, the high-order flux is the third-order ULTIMATE QUICKEST scheme by Leonard et al. (1995). The scheme should thus bepositive definite and of high resolution. In order to remove truncation errors which might inWadden Sea applications cause non-monotonicity, a truncation of over- and undershoots is carriedout at the end of this subroutine. Such two-dimensional schemes are advantageous in Wadden Seaapplications, since one-dimensional directioal-split schemes might compute negative intermediate

USES:

use domain, only: imin,imax,jmin,jmaxuse domain, only: iimin,iimax,jjmin,jjmax,kmaxuse advection_3d, only: hi,hioIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: uu(I3DFIELD),vv(I3DFIELD)REALTYPE, intent(in) :: ho(I3DFIELD),hn(I3DFIELD)REALTYPE, intent(in) :: hun(I3DFIELD),hvn(I3DFIELD)REALTYPE, intent(in) :: delxv(I2DFIELD),delyu(I2DFIELD)REALTYPE, intent(in) :: delxu(I2DFIELD),delyv(I2DFIELD)REALTYPE, intent(in) :: area_inv(I2DFIELD),dt,AHinteger, intent(in) :: az(E2DFIELD)

108

Page 109: Getm Doc Stable

INPUT/OUTPUT PARAMETERS:

REALTYPE, intent(inout) :: f(I3DFIELD)

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: rc,i,ii,j,jj,k,kk#ifdef USE_ALLOCATED_ARRAYS

REALTYPE, dimension(:,:,:), allocatable :: flx,flyREALTYPE, dimension(:,:,:), allocatable :: fhx,fhyREALTYPE, dimension(:,:,:), allocatable :: fiREALTYPE, dimension(:,:,:), allocatable :: rp,rmREALTYPE, dimension(:,:,:), allocatable :: cmin,cmax

#elseREALTYPE :: flx(I3DFIELD),fly(I3DFIELD)REALTYPE :: fhx(I3DFIELD),fhy(I3DFIELD)REALTYPE :: fi(I3DFIELD)REALTYPE :: rp(I3DFIELD),rm(I3DFIELD)REALTYPE :: cmin(I3DFIELD),cmax(I3DFIELD)

#endifREALTYPE :: CNW,CW,CSW,CSSW,CWW,CSWW,CC,CSREALTYPE :: uuu,vvv,x,CExx,Cl,Cu,fac

109

Page 110: Getm Doc Stable

7.25 Module temperature (Source File: temperature.F90)

INTERFACE:

module temperature

DESCRIPTION:

In this module, the temperature equation is processed by reading in the namelist temp and ini-tialising the temperature field (this is done in init_temperature), and calculating the advection-diffusion-equation, which includes penetrating short-wave radiation as source term (see do_temperature).

USES:

use exceptionsuse domain, only: imin,jmin,imax,jmax,H,azuse domain, only: iimin,jjmin,iimax,jjmax,kmaxuse variables_3d, only: T,rad,hn,adv_schemes,kmin,A,g1,g2use halo_zones, only: update_3d_halo,wait_halo,D_TAGIMPLICIT NONEprivate

PUBLIC DATA MEMBERS:

public init_temperature, do_temperature!PRIVATE DATA MEMBERS:integer :: temp_method=1,temp_format=2character(len=PATH_MAX) :: temp_file="t_and_s.nc"character(len=32) :: temp_name=’temp’REALTYPE :: temp_const=20.integer :: temp_hor_adv=1,temp_ver_adv=1integer :: temp_adv_split=0REALTYPE :: temp_AH=-1.integer :: attenuation_method=0,jerlov=1character(len=PATH_MAX) :: attenuation_file="attenuation.nc"REALTYPE :: A_const=0.58,g1_const=0.35,g2_const=23.0integer :: temp_check=0REALTYPE :: min_temp=-2.,max_temp=35.

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

7.25.1 init temperature - initialisation of temperature

INTERFACE:

subroutine init_temperature(adv_method)

110

Page 111: Getm Doc Stable

DESCRIPTION:

Here, the temperature equation is initialised. First, the namelist temp is read from getm.inp. Then,depending on the temp_method, the temperature field is read from a hotstart file (temp_method=0),initialised with a constant value (temp_method=1), initialised and interpolated with horizontallyhomogeneous temperature from a given temperature profile (temp_method=2), or read in andinterpolated from a 3D netCDF field (temp_method=3). Finally, a number of sanity checks areperformed for the chosen temperature advection schemes.

USES:

IMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: adv_method

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: k,i,j,ninteger, parameter :: nmax=10000REALTYPE :: zlev(nmax),prof(nmax)integer :: temp_field_no=1namelist /temp/ &

temp_method,temp_const,temp_file, &temp_format,temp_name,temp_field_no, &temp_hor_adv,temp_ver_adv,temp_adv_split,temp_AH, &attenuation_method,attenuation_file,jerlov, &A_const,g1_const,g2_const, &temp_check,min_temp,max_temp

7.25.2 do temperature - temperature equation

INTERFACE:

subroutine do_temperature(n)

DESCRIPTION:

Here, one time step for the temperature equation is performed. First, preparations for the call tothe advection schemes are made, i.e. calculating the necessary metric coefficients. After the call tothe advection schemes, which actually perform the advection (and horizontal diffusion) step as anoperational split step, the solar radiation at the interfaces (rad(k)) is calculated from given surfaceradiation (swr_loc) by means of a double exponential approach, see equation (101) on page 59).Furthermore, the surface heat flux sfl_loc is given a value. The sea surface temperature is limitedby the freezing point temperature (as a most primitive sea ice model). The next step is to set upthe tri-diagonal matrix for calculating the new temperature by means of a semi-implicit central

111

Page 112: Getm Doc Stable

scheme for the vertical diffusion. Source terms which appear on the right hand sides are due tothe divergence of the solar radiation at the interfaces. The subroutine is completed by solving thetri-diagonal linear equation by means of a tri-diagonal solver.

USES:

use advection_3d, only: do_advection_3duse variables_3d, only: dt,cnpar,hn,ho,nuh,uu,vv,ww,hun,hvn,Suse domain, only: iimin,iimax,jjmin,jjmax,kmax,az,au,avuse meteo, only: swr,shfuse parameters, only: rho_0,cp

#if defined(SPHERICAL) || defined(CURVILINEAR)use domain, only: dxu,dxv,dyu,dyv,arcd1

#elseuse domain, only: dx,dy,ard1

#endifuse parameters, only: avmoltIMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: n

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,j,k,rcREALTYPE :: Res(0:kmax)REALTYPE :: auxn(1:kmax-1),auxo(1:kmax-1)REALTYPE :: a1(0:kmax),a2(0:kmax)REALTYPE :: a3(0:kmax),a4(0:kmax)REALTYPE :: delxu(I2DFIELD),delxv(I2DFIELD)REALTYPE :: delyu(I2DFIELD),delyv(I2DFIELD)REALTYPE :: area_inv(I2DFIELD)REALTYPE :: swr_loc,shf_locREALTYPE :: zz,rad1d(0:1000)integer :: status

112

Page 113: Getm Doc Stable

7.26 Module Salinity (Source File: salinity.F90)

INTERFACE:

module salinity

DESCRIPTION:

In this module, the salinity equation is processed by reading in the namelist salt and initialisingthe salinity field (this is done in init_salinity), and calculating the advection-diffusion-equation(see do_salinity).

USES:

use exceptionsuse domain, only: imin,jmin,imax,jmax,ioff,joff

#ifdef HAIDVOGEL_TESTuse domain, only: iextr,jextr

#endifuse domain, only: iimin,jjmin,iimax,jjmax,kmaxuse domain, only: H,azuse variables_3d, only: S,hn,adv_schemes,kminuse halo_zones, only: update_3d_halo,wait_halo,D_TAGIMPLICIT NONEprivate

PUBLIC DATA MEMBERS:

public init_salinity, do_salinity!PRIVATE DATA MEMBERS:integer :: salt_method=1,salt_format=2character(len=PATH_MAX) :: salt_file="t_and_s.nc"character(len=32) :: salt_name=’salt’REALTYPE :: salt_const=35.integer :: salt_hor_adv=1,salt_ver_adv=1integer :: salt_adv_split=0REALTYPE :: salt_AH=-_ONE_integer :: salt_check=0REALTYPE :: min_salt=0.,max_salt=40.

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

7.26.1 init salinity - initialisation of salinity

INTERFACE:

subroutine init_salinity(adv_method)

113

Page 114: Getm Doc Stable

DESCRIPTION:

Here, the salinity equation is initialised. First, the namelist salt is read from getm.inp. Then,depending on the salt_method, the salinity field is read from a hotstart file (salt_method=0),initialised with a constant value (salt_method=1), initialised and interpolated with horizontallyhomogeneous salinity from a given salinity profile (salt_method=2), or read in and interpolatedfrom a 3D netCDF field (salt_method=3). Finally, a number of sanity checks are performed forthe chosen salinity advection schemes.Apart from this, there are various options for specific initial conditions which are selected by meansof compiler options.

USES:

#ifdef FRESHWATER_LENSE_TESTuse domain, only: dx

#endifIMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: adv_method

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,j,k,n#ifdef PECS_TEST

integer :: cc(1:30)#endif#ifdef FRESHWATER_LENSE_TEST

INTEGER :: ic,jcREALTYPE :: dist

#endifinteger, parameter :: nmax=100REALTYPE :: zlev(nmax),prof(nmax)integer :: salt_field_no=1NAMELIST /salt/ &

salt_method,salt_const,salt_file, &salt_format,salt_name,salt_field_no, &salt_hor_adv,salt_ver_adv,salt_adv_split,salt_AH, &salt_check,min_salt,max_salt

7.26.2 do salinity - salinity equation

INTERFACE:

subroutine do_salinity(n)

114

Page 115: Getm Doc Stable

DESCRIPTION:

Here, one time step for the salinity equation is performed. First, preparations for the call to theadvection schemes are made, i.e. calculating the necessary metric coefficients. After the call tothe advection schemes, which actually perform the advection (and horizontal diffusion) step asan operational split step, the tri-diagonal matrix for calculating the new salinity by means of asemi-implicit central scheme for the vertical diffusion is set up. There are no source terms on theright hand sides. The subroutine is completed by solving the tri-diagonal linear equation by meansof a tri-diagonal solver.Also here, there are some specific options for single test cases selected by compiler options.

USES:

use advection_3d, only: do_advection_3duse variables_3d, only: dt,cnpar,hn,ho,nuh,uu,vv,ww,hun,hvnuse domain, only: iimin,iimax,jjmin,jjmax,kmax,az,au,av

#if defined(SPHERICAL) || defined(CURVILINEAR)use domain, only: dxu,dxv,dyu,dyv,arcd1

#elseuse domain, only: dx,dy,ard1

#endifuse parameters, only: avmolsIMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: n

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,j,k,rcREALTYPE :: Res(0:kmax)REALTYPE :: auxn(1:kmax-1),auxo(1:kmax-1)REALTYPE :: a1(0:kmax),a2(0:kmax)REALTYPE :: a3(0:kmax),a4(0:kmax)

#ifdef FRESHWATER_LENSE_TESTREALTYPE :: SRelax

#endif#ifdef SALTWEDGE_TEST

REALTYPE :: SRelax,kk#endifREALTYPE :: delxu(I2DFIELD),delxv(I2DFIELD)REALTYPE :: delyu(I2DFIELD),delyv(I2DFIELD)REALTYPE :: area_inv(I2DFIELD)integer :: status

115

Page 116: Getm Doc Stable

7.27 Module suspended matter (Source File: spm.F90)

INTERFACE:

module suspended_matter

DESCRIPTION:

This model for Suspended Particulate Matter (SPM) considers a single class of non-cohesive SPMparticles that do not interact with the mean flow (no density effect of SPM is taken into accountby default). The concentration C of SPM is modelled with the tracer equation. At the bottom,the net SPM flux is the residual of erosion and sedimentation fluxes:

−wsC − ∂z(ν′t∂zC) = Fe − Fs, (160)

where erosion and sedimentation fluxes are modelled following Krone (1962) as functions of thebottom shear stress τb. The erosion flux is only non-zero when the bottom shear stress exceeds acritical shear stress τce:

Fe =

ce

ρ0(|τb| − τce), for B > 0 and |τb| > τce

0, else

(161)

with ce erosion constant with units kg sm−4 and the fluff layer SPM content B (see below). Thesedimentation flux is only non-zero for bottom shear stresses smaller than a critical shear stressτcs. This flux is limited by the near bottom concentration Cb:

Fs =wsCb

τcs(τcs − |τb|). (162)

Critical shear stresses for erosion and sedimentation (τce and τcs have as units Nm−2). However,the SPM flux between the water column and the bed may be switched off by setting spm_methodin spm.inp to zero. A pool B of non-dynamic particulate matter (fluff layer) is assumed in orderto take into account the effects of depletion of erodible material at the bottom. A horizontallyhomogeneous distribution with B = B0 kgm−2 is initially assumed. Sedimentation and erosion filland empty this pool, respectively:

∂t(B) = Fs − Fe (163)

and the erosion flux is constricted by the availability of SPM from the pool (see eq. (161)). Theerosion and sedimentation fluxes are discretised using the quasi-implicit Patankar (1980) approach,which guarantees positivity of SPM, but only in the diffusion step, negative values might appearafter the advection step, although these negative values should be small. The settling of SPM islinearly reduced towards zero when the water depth is between the critical and the minimum waterdepth. This is done by means of multiplication of the settling velocity with α, (see the definitionin equation (5)).It is possible to take into account the impact of sediments on density by setting spm_dens to .true.The modified density is computed as:

ρ = ρT,S,p +

(

1 − ρT,S,p

ρspm

)

C. (164)

USES:

116

Page 117: Getm Doc Stable

use exceptionsuse domain, only: imin,jmin,imax,jmax,ioff,joffuse domain, only: iimin,jjmin,iimax,jjmax,kmax

#ifdef TRACER_POSITIVEuse m2d, only : z,D

#endifuse domain, only: H,azuse parameters, only: rho_0,guse variables_3d, only: hn,taub,adv_schemes,spm,spm_ws,spm_pooluse halo_zones, only: update_3d_halo,wait_halo,D_TAGIMPLICIT NONEprivate

PUBLIC DATA MEMBERS:

public init_spm, do_spmlogical, public :: spm_calc=.false.logical, public :: spm_save=.true.logical, public :: spm_hotstart=.false.

!PRIVATE DATA MEMBERS:integer :: spm_method=1integer :: spm_init_method=1, spm_format=2character(len=PATH_MAX) :: spm_file="spm.nc"character(len=32) :: spm_name=’spm’integer :: spm_hor_adv=1,spm_ver_adv=1,spm_adv_split=0REALTYPE :: spm_AH = -_ONE_REALTYPE :: spm_const= _ZERO_REALTYPE :: spm_init= _ZERO_integer :: spm_ws_method = 0REALTYPE :: spm_ws_const=0.001REALTYPE :: spm_erosion_const, spm_tauc_sedimentationREALTYPE :: spm_tauc_erosion, spm_pool_initREALTYPE :: spm_porosity=_ZERO_REALTYPE :: spm_rho= 2650.logical :: spm_dens=.false.For erosion-sedimentation fluxREALTYPE :: Erosion_flux , Sedimentation_fluxlogical :: erosed_flux =.false.

For flocculation (not yet in namelist)REALTYPE :: spm_gellingC=0.08 !(g/l or kg/m3)REALTYPE :: spm_part_density=2650. !(g/l or kg/m3)integer :: spm_mfloc=4

REVISION HISTORY:

Original author(s): Manuel Ruiz Villarreal, Karsten Boldingand Hans Burchard

7.27.1 init spm

INTERFACE:

subroutine init_spm(nml_file,runtype)

117

Page 118: Getm Doc Stable

DESCRIPTION:

Here, the suspended matter equation is initialised. First, the namelist spm is read from getm.inp.Then, depending on the spm_init_method, the suspended matter field is read from a hotstart file(spm_init_method=0), initialised with a constant value (spm_init_method=1), initialised and in-terpolated with horizontally homogeneous suspended matter from a given suspended matter profile(spm_init_method=2), or read in and interpolated from a 3D netCDF field (spm_init_method=3).Then, some specifications for the SPM bottom pool are given, such as that there should be no initialSPM pool on tidal flats.As the next step, a number of sanity checks is performed for the chosen suspended matter advectionschemes.Finally, the settling velocity is directly prescibed or calculated by means of the Zanke (1977)formula.

USES:

For initialization of spm in intertidal flatsuse domain,only: min_depthIMPLICIT NONE

INPUT PARAMETERS:

character(len=*), intent(in) :: nml_filelogical :: hotstart_spminteger, intent(in) :: runtype

REVISION HISTORY:

See revision for the module

LOCAL VARIABLES:

integer :: i,j,k,ninteger :: rcinteger, parameter :: nmax=100REALTYPE :: zlev(nmax),prof(nmax)No initial pool of spm at intertidal flatslogical :: intertidal_spm0=.false.namelist /spm_nml/ spm_calc,spm_save,spm_method,spm_init_method, &

spm_const,spm_format,spm_file,spm_name, &spm_hor_adv, spm_ver_adv,spm_adv_split, &spm_AH,spm_ws_method,spm_ws_const, &spm_erosion_const, spm_tauc_sedimentation, &spm_tauc_erosion, spm_porosity, spm_pool_init, &spm_rho,spm_dens

7.27.2 do spm - suspended matter equation

INTERFACE:

subroutine do_spm()

DESCRIPTION:

118

Page 119: Getm Doc Stable

Here, one time step for the suspended matter equation is performed. First, preparations for thecall to the advection schemes are made, i.e. calculating the necessary metric coefficients and therelevant vertical velocity, which is here composed of the grid-related vertical flow velocity and thesettling velocity. Some lines of code allow here for consideration of flocculation processes. Afterthe call to the advection schemes, which actually perform the advection (and horizontal diffusion)step as an operational split step, the fluxes between bottom SPM pool and the suspended matterin the water column are calculated. Afterwards, the tri-diagonal matrix for calculating the newsuspended matter by means of a semi-implicit central scheme for the vertical diffusion is set up.There are no source terms on the right hand sides. The subroutine is completed by solving thetri-diagonal linear equation by means of a tri-diagonal solver.Optionally, the density of the sediment-laden water may be corrected by the sediment density, seeeq. (164).Finally, some special settings for single test cases are made via compiler options.

USES:

use advection_3d, only: do_advection_3duse variables_3d, only: dt,cnpar,hun,hvn,ho,nuh,uu,vv,ww

#ifndef NO_BAROCLINICuse variables_3d, only: rho

#endifuse domain, only: au,av

#if defined(SPHERICAL) || defined(CURVILINEAR)use domain, only: dxu,dxv,dyu,dyv,arcd1

#ifdef ELBE_TESTuse domain, only :dxc

#endif#else

use domain, only: dx,dy,ard1#endif

use domain, only: dry_zIMPLICIT NONE

LOCAL VARIABLES:

integer :: i,j,k,rcREALTYPE :: spmtotREALTYPE :: Res(0:kmax)REALTYPE :: auxn(1:kmax-1),auxo(1:kmax-1)REALTYPE :: a1(0:kmax),a2(0:kmax)REALTYPE :: a3(0:kmax),a4(0:kmax)REALTYPE :: delxu(I2DFIELD),delxv(I2DFIELD)REALTYPE :: delyu(I2DFIELD),delyv(I2DFIELD)REALTYPE :: area_inv(I2DFIELD)REALTYPE :: bed_fluxREALTYPE :: cREALTYPE :: volCmud,volCpartinteger :: k2logical :: patankar=.true.

#ifdef TRACER_POSITIVElogical :: kk

#endifREALTYPE, allocatable, dimension (:,:,:) :: ww_aux

119

Page 120: Getm Doc Stable

7.28 Module eqstate (Source File: eqstate.F90)

INTERFACE:

module eqstate

DESCRIPTION:

Documentation will follow when the equation of state calculations are updated. The idea is to usethe respective routines from GOTM.

USES:

use parameters, only: g,rho_0IMPLICIT NONE

PUBLIC DATA MEMBERS:

public init_eqstate, do_eqstate!PRIVATE DATA MEMBERS:integer :: eqstate_method=1REALTYPE :: T0 = 10., S0 = 33.75, p0 = 0.REALTYPE :: dtr0 = -0.17, dsr0 = 0.78

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

7.28.1 init eqstate

INTERFACE:

subroutine init_eqstate()IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

DESCRIPTION:

Reads the namelist and makes calls to the init functions of the various model components.

LOCAL VARIABLES:

namelist /eqstate/ eqstate_method,T0,S0,p0,dtr0,dsr0

120

Page 121: Getm Doc Stable

7.28.2 do eqstate - equation of state

INTERFACE:

subroutine do_eqstate()

DESCRIPTION:

Here, the equation of state is calculated for every 3D grid point.

USES:

use domain, only: iimin,iimax,jjmin,jjmax,kmax,azuse variables_3d, only: T,S,rho,buoyIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,j,kREALTYPE :: xREALTYPE :: KKREALTYPE :: T1,T2,T3,T4,T5,S1,S15,S2,S3,p2

121

Page 122: Getm Doc Stable

7.29 ss nn - calculates shear and buoyancy frequency (Source File: ss nn.F90)

INTERFACE:

subroutine ss_nn()

DESCRIPTION:

Here, the shear frequency squared, M2 = (∂zu)2

+ (∂zv)2, and the buoyancy frequency squared,

N2 = ∂zb, with buoyancy b from (4) are calculated. For both calculations, two alternative methodsare coded. The two straight-forward methods which are explained first, do both have the disad-vantage of generating numerical instabilities. The straight-forward way for calculating M2 is asfollows:

(M2)i,j,k ≈ 1

2

((

ui,j,k+1 − ui,j,k12 (hu

i,j,k+1 + hui,j,k)

)2

+

(

ui−1,j,k+1 − ui−1,j,k12 (hu

i−1,j,k+1 + hui−1,j,k)

)2

+

(

vi,j,k+1 − vi,j,k12 (hv

i,j,k+1 + hvi,j,k)

)2

+

(

vi,j−1,k+1 − vi,j−1,k12 (hv

i,j−1,k+1 + hvi,j−1,k)

)2)(165)

Burchard (2002a) developed a new scheme, which guarantees that the mean kinetic energy which isdissipated from the mean flow equals the shear production of turbulent kinetic energy. Therefore,this scheme should be numerically more stable than (165):

(M2)i,j,k ≈ 1

2

(

12 (νi,j,k + νi+1,j,k)(ui,j,k+1 − ui,j,k)2

12 (hu

i,j,k+1 + hui,j,k)

+12 (νi−1,j,k + νi,j,k)(ui−1,j,k+1 − ui−1,j,k)2

12 (hu

i−1,j,k+1 + hui−1,j,k)

+12 (νi,j,k + νi,j+1,k)(vi,j,k+1 − vi,j,k)2

12 (hv

i,j,k+1 + hvi,j,k)

+12 (νi,j−1,k + νi,j,k)(vi,j−1,k+1 − vi,j−1,k)2

12 (hv

i,j−1,k+1 + hvi,j−1,k)

)

·(

1

2

(

hci,j,k + hc

i,j,k+1

)

νi,j,k

)−1

(166)

The straight-forward discretisation of N2 is given by

(N2)i,j,k ≈ bi,j,k+1 − bi,j,k12 (ht

i,j,k+1 + hti,j,k)

. (167)

In some cases, together with the straight-forward discretisation of the shear squared, (165), thisdid not produce stable numerical results. The reason for this might be that the velocities involvedin the calculation for the shear squared do depend on the buoyancies in the two neighbouringT-points such that the straight-forward method (167) leads to an inconsistency. However, otherexperiments with the energy-conserving discretisation of the shear stress squared, (166) and thestraight-forward discretisation of N2, (167), produced numerically stable results.Most stable results have been obtained with a weighted average for the N2 calculation:

122

Page 123: Getm Doc Stable

(N2)i,j,k ≈ 1

6

(

2bi,j,k+1 − bi,j,k

12 (ht

i,j,k+1 + hti,j,k)

+bi+1,j,k+1 − bi+1,j,k

12 (ht

i+1,j,k+1 + hti+1,j,k)

+bi−1,j,k+1 − bi−1,j,k

12 (ht

i−1,j,k+1 + hti−1,j,k)

+bi,j+1,k+1 − bi,j+1,k

12 (ht

i,j+1,k+1 + hti,j+1,k)

+bi,j−1,k+1 − bi,j−1,k

12 (ht

i,j−1,k+1 + hti,j−1,k)

)

.

(168)

These stability issues need to be further investigated in the future.

USES:

use domain, only: iimin,iimax,jjmin,jjmax,kmax,au,av,azuse variables_3d, only: kmin,kumin,hn,uu,hun,kvmin,vv,hvn,SS,num

#ifndef NO_BAROCLINICuse variables_3d, only: NN,buoy

#endifIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,k,nbREALTYPE :: dz,NNc,NNe,NNw,NNn,NNs

123

Page 124: Getm Doc Stable

7.30 stresses 3d - bottom and surface stresses (Source File: stresses 3d.F90)

INTERFACE:

subroutine stresses_3d

DESCRIPTION:

As preparation of the call to do_turbulence in the routine gotm, see section 7.31, the normalisedsurface and bottom stresses, τs/ρ0 (variable taus) and τb/ρ0 (variable taub), respectively, arecalculated and interpolated to the T-points. Input parameters to this routine are rru and tt rrv,which contain r

√u2 + v2 for the U- and V-points, respectively. The modules of the surface and

bottom stress vectors are calculated then by means of taking the square root of the sum of thesquares of the stess components.

USES:

use parameters, only: rho_0use domain, only: az,au,av,iimin,iimax,jjmin,jjmaxuse variables_3d, only: kumin,kvmin,uu,vv,hun,hvn,rru,rrv,taus,taubuse meteo, only: tausx,tausyuse halo_zones, only : update_2d_halo,wait_halo,z_TAGIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,k1,k2,k3,k4

124

Page 125: Getm Doc Stable

7.31 gotm - a wrapper to call GOTM (Source File: gotm.F90)

INTERFACE:

subroutine gotm()

DESCRIPTION:

Here, the turbulence module of the General Ocean Turbulence Model (GOTM, see www.gotm.netand Umlauf et al. (2005)) is called. First, all necessary parameters are transformed to suit with a1D water column model, i.e., 3D fields are transformed to a vertical vector, 2D horizontal fields areconverted to a scalar. The transformed 3D fields are the layer heights hn → h, the shear squared SS→ SS1d, the buoyancy frequency squared NN → NN1d, the turbulent kinetic energy tke → tke1d,the dissipation rate eps → eps1d (from which the integral length scale L1d is calculated), the eddyviscosity num → num1d, and the eddy diffusivity nuh → nuh1d. The scalars are the surface andbottom friction velocities, u_taus and u_taub, respectively, the surface roughness parameter z0s(which is currently hard-coded), and the bottom roughess parameter z0b. Then, the GOTMturbulence module do_turbulence is called with all the transformed parameters discussed above.Finally, the vertical vectors tke1d, eps1d, num1d and nuh1d are transformed back to 3D fields.There are furthermore a number of compiler options provided, e.g. for an older GOTM version,for barotropic calcuations, and for simple parabolic viscosity profiles circumventing the GOTMturbulence module.

USES:

use halo_zones, only: update_3d_halo,wait_halo,H_TAGuse domain, only: iimin,iimax,jjmin,jjmax,kmax,az,min_depth,crit_depthuse variables_2d, only: D,zub,zvb,zuse variables_3d, only: dt,kmin,ho,hn,tke,eps,SS,num,taus,taub

#ifndef NO_BAROCLINICuse variables_3d, only: NN,nuh

#endifuse variables_3d, only: avmback,avhbackuse turbulence, only: do_turbulence,cdeuse turbulence, only: tke1d => tke, eps1d => eps, L1d => Luse turbulence, only: num1d => num, nuh1d => nuhIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

integer :: i,j,kREALTYPE :: u_taus,u_taub,z0s,z0bREALTYPE :: h(0:kmax),dry,zzREALTYPE :: NN1d(0:kmax),SS1d(0:kmax)REALTYPE :: xP(0:kmax)

125

Page 126: Getm Doc Stable

7.32 Module rivers (Source File: rivers.F90)

INTERFACE:

module rivers

DESCRIPTION:

This module includes support for river input. Rivers are treated the same way as meteorology,i.e. as external module to the hydrodynamic model itself. The module follows the same schemeas all other modules, i.e. init_rivers sets up necessary information, and do_rivers updates therelevant variables. do_river is called in getm/integration.F90 between the 2d and 3d routinesas it only updates the sea surface elevation (in 2d) and sea surface elevation, and optionally salinityand temperature (in 3d). At present the momentum of the river water is not include, the modelhowever has a direct response to the river water because of the pressure gradient introduced.

USES:

use domain, only: iimin,jjmin,iimax,jjmax,ioff,joff#if defined(SPHERICAL) || defined(CURVILINEAR)

use domain, only: H,az,kmax,arcd1#else

use domain, only: H,az,kmax,ard1#endif

use m2d, only: dtmuse variables_2d, only: z

#ifndef NO_BAROCLINICuse m3d, only: calc_salt,calc_tempuse variables_3d, only: hn,ssen,T,S

#endif#ifdef GETM_BIO

use bio, only: bio_calcuse bio_var, only: numcuse variables_3d, only: cc3d

#endifIMPLICIT NONEprivate

PUBLIC DATA MEMBERS:

public init_rivers, do_rivers, clean_rivers#ifdef GETM_BIO

public init_rivers_bio#endif

integer, public :: river_method=0,nriver=0,rriver=0logical,public :: use_river_temp = .false.logical,public :: use_river_salt = .false.character(len=64), public :: river_data="rivers.nc"character(len=64), public, allocatable :: river_name(:)character(len=64), public, allocatable :: real_river_name(:)integer, public, allocatable :: ok(:)REALTYPE, public, allocatable :: river_flow(:)REALTYPE, public, allocatable :: river_salt(:)REALTYPE, public, allocatable :: river_temp(:)REALTYPE, public :: river_factor= _ONE_

126

Page 127: Getm Doc Stable

REALTYPE, public,parameter :: temp_missing=-9999.0REALTYPE, public,parameter :: salt_missing=-9999.0integer, public, allocatable :: river_split(:)

#ifdef GETM_BIOREALTYPE, public, allocatable :: river_bio(:,:)REALTYPE, public, parameter :: bio_missing=-9999.0

#endif!PRIVATE DATA MEMBERS:integer :: river_format=2character(len=64) :: river_info="riverinfo.dat"integer, allocatable :: ir(:),jr(:)REALTYPE, allocatable :: irr(:)REALTYPE, allocatable :: macro_height(:)REALTYPE, allocatable :: flow_fraction(:)

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

7.32.1 init rivers

INTERFACE:

subroutine init_rivers

DESCRIPTION:

First of all, the namelist rivers is read from getm.F90 and a number of vectors with the length ofnriver (number of rivers) is allocated. Then, by looping over all rivers, the ascii file river_infois read, and checked for consistency. The number of used rivers rriver is calculated and it ischecked whether they are on land (which gives a warning) or not. When a river name occurs morethan once in river_info, it means that its runoff is split among several grid boxed (for wide rivermouths).

USES:

IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

127

Page 128: Getm Doc Stable

integer :: i,j,n,nn,ni,rc,minteger :: unit = 25 ! kbklogical :: outsideREALTYPE :: areaNAMELIST /rivers/ &

river_method,river_info,river_format,river_data,river_factor, &use_river_salt,use_river_temp

7.32.2 init rivers bio

INTERFACE:

subroutine init_rivers_bio()

DESCRIPTION:

First, memory for storing the biological loads from rivers is allocated. The variable - river_bio -is initialised to - bio_missing.

USES:

IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: rc

7.32.3 do rivers - updating river points

INTERFACE:

subroutine do_rivers(do_3d)

DESCRIPTION:

Here, the temperature, salinity, sea surface elevation and layer heights are updated in the riverinflow grid boxes. Temperature and salinity are mixed with riverine values proportional to the oldvolume and the river inflow volume at that time step, sea surface elevation is simply increased bythe inflow volume divided by the grid box area, and the layer heights are increased proportionally.

USES:

128

Page 129: Getm Doc Stable

IMPLICIT NONE

INPUT PARAMETERS:

logical, intent(in) :: do_3d

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,j,k,m,nREALTYPE :: rvol,heightREALTYPE :: svol,tvol,vol

7.32.4 clean rivers

INTERFACE:

subroutine clean_rivers

DESCRIPTION:

This routine closes the river handling by writing the integrated river run-off for each river tostandard output.

USES:

IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,j,nREALTYPE :: tot=_ZERO_

129

Page 130: Getm Doc Stable

7.33 Module bdy 3d - 3D boundary conditions (Source File: bdy 3d.F90)

INTERFACE:

module bdy_3d

DESCRIPTION:

Here, the three-dimensional boundary conditions for temperature and salinity are handled.

USES:

use halo_zones, only : H_TAG,U_TAG,V_TAGuse domain, only: imin,jmin,imax,jmax,H,az,au,avuse domain, only: iimin,jjmin,iimax,jjmax,kmaxuse domain, only: nsbv,NWB,NNB,NEB,NSB,bdy_indexuse domain, only: wi,wfj,wlj,nj,nfi,nli,ei,efj,elj,sj,sfi,sliuse variables_3dIMPLICIT NONEprivate

PUBLIC DATA MEMBERS:

public init_bdy_3d, do_bdy_3dREALTYPE, public, allocatable :: S_bdy(:,:),T_bdy(:,:)

!PRIVATE DATA MEMBERS:

REVISION HISTORY:

Original author(s): Karsten Bolding & Hans Burchard

LOCAL VARIABLES:

7.33.1 init bdy 3d - initialising 3D boundary conditions

INTERFACE:

subroutine init_bdy_3d()

DESCRIPTION:

Here, the necessary fields S_bdy and T_bdy for salinity and temperature, respectively, are allocated.

USES:

IMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: rc,i,j,k,n

130

Page 131: Getm Doc Stable

7.33.2 do bdy 3d - updating 3D boundary conditions

INTERFACE:

subroutine do_bdy_3d(tag,field)

DESCRIPTION:

Here, the boundary conditions for salinity and temperature are copied to the boundary points andrelaxed to the near boundary points by means of the flow relaxation scheme by Martinsen andEngedahl (1987).

USES:

IMPLICIT NONE

INPUT PARAMETERS:

integer, intent(in) :: tag

INPUT/OUTPUT PARAMETERS:

REALTYPE, intent(inout) :: field(I3DFIELD)

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,j,k,l,n,ii,jjREALTYPE :: sp(1:4),rat

131

Page 132: Getm Doc Stable

7.34 slow bottom friction - slow bed friction (Source File: slow bottom friction.F90)

INTERFACE:

subroutine slow_bottom_friction

DESCRIPTION:

This routine basically calculates the bed friction, as it would come out if the vertically and macrotimestep averaged velocity would be used. The output of this subroutine is thus R

√u2 + v2 on the

U-points (see variable ruu) and on the V-points (see rvv) with the vertically and macro timestepaveraged velocity components on the old time step, u and v, which are in the code denoted by Uiand Vi, respectively. The drag coefficient R is given by eq. (70) on page 33. The results for thevariables ruu and rvv will then be used in the routine slow_terms described on page 135 for thecalculation of the slow terms Sx

F and SyF , see section 6.1.

USES:

use parameters, only: kappause domain, only: iimin,iimax,jjmin,jjmax,HU,HV,min_depth,au,avuse variables_2d, only: zub,zvb,ru,rv,Uinto,Vintouse variables_3d, only: ssuo,ssun,ssvo,ssvnIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,jREALTYPE :: uloc,vloc,HHlogical,save :: first=.true.REALTYPE :: Ui(I2DFIELD)REALTYPE :: Vi(I2DFIELD)REALTYPE :: ruu(I2DFIELD)REALTYPE :: rvv(I2DFIELD)

132

Page 133: Getm Doc Stable

7.35 slow advection - slow advection terms (Source File: slow advection.F90)

INTERFACE:

subroutine slow_advection

DESCRIPTION:

Here, the calculation of the advective slow terms SxA and Sy

A (see eqs. (64) and (65)) is prepared.This routine basically repeats the calculations made in the routine uv_advect, see section 6.3.6,but this time based on the macro time step averaged and vertically integrated transports Uint andVint. The calculations of Sx

A and SyA are then completed in the routine slow_terms, see section

7.37 on page 135.

USES:

use domain, only: iimin,iimax,jjmin,jjmax,HU,HV,az,au,av,axuse domain, only: H,min_depth

#if defined(SPHERICAL) || defined(CURVILINEAR)use domain, only: dyc,arud1,dxx,dyx,arvd1,dxc

#elseuse domain, only: dx,dy,ard1

#endifuse variables_2d, only: UEx,VEx,Uint,Vint,PPuse variables_3d, only: ssun,ssvnIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,ii,jjREALTYPE :: DUi(I2DFIELD)REALTYPE :: DVi(I2DFIELD)

133

Page 134: Getm Doc Stable

7.36 slow diffusion - slow diffusion terms (Source File: slow diffusion.F90)

INTERFACE:

subroutine slow_diffusion(AM)

DESCRIPTION:

Here, the calculation of the diffusive slow terms SxD and Sy

D (see eqs. (66) and (66)) is prepared.This routine basically repeats the calculations made in the routine uv_iondvect, see section 6.3.6,but this time based on the macro time step averaged and vertically integrated transports Uint andVint. However, the damping of the external mode, as described in (89) and (90) is not consideredhere. The calculations of Sx

D and SyD are then completed in the routine slow_terms, see section

7.37 on page 135.

USES:

use domain, only: iimin,iimax,jjmin,jjmax,az,au,av,ax,H,HU,HV#if defined(SPHERICAL) || defined(CURVILINEAR)

use domain, only: dyc,arud1,dxx,dyx,arvd1,dxc#else

use domain, only: dx,dy,ard1#endif

use variables_2d, only: D,U,V,UEx,VEx,Uint,Vint,PPuse variables_3d, only: ssen,ssun,ssvnIMPLICIT NONE

INPUT PARAMETERS:

REALTYPE, intent(in) :: AM

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

LOCAL VARIABLES:

integer :: i,j,ii,jjREALTYPE :: Di(iimin-1:iimax+1,jjmin-1:jjmax+1)REALTYPE :: DUi(iimin-1:iimax+1,jjmin-1:jjmax+1)REALTYPE :: DVi(iimin-1:iimax+1,jjmin-1:jjmax+1)

134

Page 135: Getm Doc Stable

7.37 slow terms - calculation of slow terms (Source File: slow terms.F90)

INTERFACE:

subroutine slow_terms

DESCRIPTION:

Here, the calculation of the so-called slow terms (which are the interaction terms between thebarotropic and the baroclinic mode) is completed. The mathematical form of these slow termsis given by equations (62) - (69), see section 6.1. These calculations have been prepared in theroutines slow_bottom_friction, slow_advection and slow_diffusion.

USES:

use domain, only: iimin,iimax,jjmin,jjmax,kmax,HU,HV,au,avuse variables_2d, only: Uint,Vint,UEx,VEx,Slru,Slrv,SlUx,SlVx,ru,rvuse variables_3d, only: kumin,kvmin,uu,vv,huo,hun,hvo,hvnuse variables_3d, only: ssuo,ssun,ssvo,ssvn,uuEx,vvEx,rru,rrv

#ifndef NO_BAROCLINICuse variables_3d, only: idpdx,idpdy

#endifIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,j,k

135

Page 136: Getm Doc Stable

7.38 start macro - initialise the macro loop (Source File: start macro.F90)

INTERFACE:

subroutine start_macro()

DESCRIPTION:

This routine needs to be called from m3d at the beginning of each macro time step. Here, thesea surface elevations at the before and after the macro time step are updated at the T-, U- andV-points.the sea surface elevations at the before and after the macro time step are updated at theT-, U- and V-points, their notation is sseo, ssen, ssuo, ssun, ssvo and ssvn, where e, u and vstand for T-, U- and V-point and o and n for old and new, respectively, see also the description ofvariables_3d in section 7.5 on page 65.Furthermore, the vertically integrated transports Uint and Vint are here divided by the numberof micro time steps per macro time step, M, in order to obtain the time-averaged transports.

USES:

use domain, only: iimin,iimax,jjmin,jjmax,H,HU,HV,min_depthuse m2d, only: z,Uint,Vintuse m3d, only: Muse variables_3d, only: sseo,ssen,ssuo,ssun,ssvo,ssvnIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

integer :: i,jREALTYPE :: split

136

Page 137: Getm Doc Stable

7.39 stop macro - terminates the macro loop (Source File: stop macro.F90)

INTERFACE:

subroutine stop_macro

DESCRIPTION:

This routine should be called from m3d at the end of each macro time step in order to copy thevertically interated and temporally averaged transports to old values Uinto and Vinto, and toreinitialise the transports Uint and Vint to zero.

USES:

use variables_2d, only: Uint,Uinto,Vint,VintoIMPLICIT NONE

INPUT PARAMETERS:

INPUT/OUTPUT PARAMETERS:

OUTPUT PARAMETERS:

REVISION HISTORY:

Original author(s): Hans Burchard & Karsten Bolding

LOCAL VARIABLES:

137

Page 138: Getm Doc Stable

138

Page 139: Getm Doc Stable

References

Arakawa, A., and V. R. Lamb, Computational design of the basic dynamical processes of the UCLAGeneral Circulation Model, Meth. Comput. Phys., pp. 173–263, 1977.

Backhaus, J. O., A three-dimensional model for the simulation of shelf sea dynamics, Dt. Hydrogr.Z., 38 , 165–187, 1985.

Baretta, J. W., W. Ebenhoh, and P. Ruardij, The European Regional Seas Ecosystem Model, acomplex marine ecosystem model, Neth. J. Sea Res., 33 , 233–246, 1995.

Baumert, H., and G. Radach, Hysteresis of turbulent kinetic energy in nonrotational tidal flows:A model study, J. Geophys. Res., 97 , 3669–3677, 1992.

Beckers, J.-M., and E. Deleersnijder, Stability of a FBTCS scheme applied to the propagation ofshallow-water inertia-gravity waves on various space grids, J. Computat. Phys., 108 , 95–104,1993.

Beckers, J.-M., H. Burchard, J.-M. Campin, E. Deleersnijder, and P.-P. Mathieu, Another reasonwhy simple discretizations of rotated diffusion operators cause problems in ocean models. Com-ments on the paper isoneutral diffusion in a z-coordinate ocean model by Griffies et al., J. Phys.Oceanogr., 28 , 1552–1559, 1998.

Beckers, J.-M., H. Burchard, E. Deleersnijder, and P.-P. Mathieu, On the numerical discretisationof rotated diffusion operators in ocean models, Monthly Weather Review , 128 , 2711–2733, 2000.

Blumberg, A. F., and G. L. Mellor, A description of a coastal ocean circulation model, in Threedimensional ocean models , edited by N. S. Heaps, pp. 1–16, American Geophysical Union, Wash-ington, D.C., 1987.

Bryan, K., A numerical model for the study of the world ocean, J. Computat. Phys., 4 , 347–376,1969.

Burchard, H., Turbulenzmodellierung mit Anwendungen auf thermische Deckschichten im Meerund Stromungen in Wattengebieten, Ph.D. thesis, Institut fur Meereskunde, Universitat Ham-burg, 1995, published as: Report 95/E/30, GKSS Research Centre.

Burchard, H., Presentation of a new numerical model for turbulent flow in estuaries, in Hydroin-formatics ’98 , edited by V. Babovic and L. C. Larsen, pp. 41–48, Balkema, Rotterdam, 1998,Proceedings of the third International Conference on Hydroinformatics, Copenhagen, Denmark,24-26 August 1998.

Burchard, H., Energy-conserving discretisation of turbulent shear and buoyancy production, OceanModelling, 4 , 347–361, 2002a.

Burchard, H., Applied turbulence modelling in marine waters, vol. 100 of Lecture Notes in EarthSciences , Springer, Berlin, Heidelberg, New York, 2002b.

Burchard, H., and H. Baumert, On the performance of a mixed-layer model based on the k-εturbulence closure, J. Geophys. Res., 100 , 8523–8540, 1995.

Burchard, H., and J.-M. Beckers, Non-uniform adaptive vertical grids in one-dimensional numericalocean models, Ocean Modelling, 6 , 51–81, 2004.

Burchard, H., and K. Bolding, GETM – a general estuarine transport model. Scientific documen-tation, Tech. Rep. EUR 20253 EN , European Commission, 2002.

Burchard, H., and O. Petersen, Hybridisation between σ and z coordinates for improving theinternal pressure gradient calculation in marine models with steep bottom slopes, Int. J. Numer.Meth. Fluids, 25 , 1003–1023, 1997.

139

Page 140: Getm Doc Stable

Burchard, H., K. Bolding, and M. R. Villarreal, Three-dimensional modelling of estuarine turbiditymaxima in a tidal estuary, Ocean Dynamics , 54 , 250–265, 2004.

Burchard, H., K. Bolding, W. Kuhn, A. Meister, T. Neumann, and L. Umlauf, Description of aflexible and extendable physical-biogeochemical model system for the water column, J. Mar.Sys., 2006, in print.

Casulli, V., and E. Cattani, Stability, accuracy and efficiency of a semi-implicit method for three-dimensional shallow water flow, Computers Math. Appl., 27 , 99–112, 1994.

Chu, P. C., and C. Fan, Hydrostatic correction for reducing horizontal pressure gradient errors insigma coordinate models, J. Geophys. Res., 108 , 3206, doi: 10.1029/2002JC001,668, 2003.

Cox, M. D., A primitive equation, 3-dimensional model for the ocean, Tech. Rep. 1 , GeophysicalFluid Dynamics Laboratory, University of Princeton, Princeton, N. J., 1984, 75 pp.

de Kok, J. M., A 3D finite difference model for the computation of near- and far-field transport ofsuspended matter near a river mouth, Cont. Shelf Res., 12 , 625–642, 1992.

Deleersnijder, E., and K. G. Ruddick, A generalized vertical coordinate for 3D marine problems,Bulletin de la Societe Royale des Sciences de Liege, 61 , 489–502, 1992.

Duwe, K., Modellierung der Brackwasserdynamik eines Tideastuars am Beispiel der Unterelbe,Ph.D. thesis, Universitat Hamburg, 1988, published in: Hydromod Publ. No. 1, Wedel, Hamburg.

Espelid, T. O., J. Berntsen, and K. Barthel, Conservation of energy for schemes applied to thepropagation of shallow-water inertia-gravity waves in regions with varying depth, Int. J. Numer.Meth. Engng, 49 , 1521–1545, 2000.

Fairall, C. W., E. F. Bradley, D. P. Rogers, J. B. Edson, and G. S. Young, Bulk parameterizationof air-sea fluxes for Tropical Ocean-Global Atmosphere Coupled-Ocean Atmosphere ResponseExperiment, J. Geophys. Res., 101 , 3747–3764, 1996.

Fofonoff, N. P., and R. C. Millard, Algorithms for the computation of fundamental properties ofseawater, Unesco technical papers in marine sciences , 44 , 1–53, 1983.

Freeman, N. G., A. M. Hale, and M. B. Danard, A modified sigma equations’ approach to thenumerical modeling of Great Lakes hydrodynamics, J. Geophys. Res., 77 , 1050–1060, 1972.

Gerdes, R., A primitive equation ocean circulation model using a general vertical coordinate trans-formation. 1. Description and testing of the model, J. Geophys. Res., 98 , 14,683–14,701, 1993.

Haidvogel, D. B., and A. Beckmann, Numerical Ocean Circulation Modelling, vol. 2 of Series onEnvironmental Science and Management , Imperial College Press, London, 1999.

Jackett, D. R., T. J. McDougall, R. Feistel, D. G. Wright, and S. M. Griffies, Updated algorithms fordensity, potential temperature, conservative temperature and freezing temperature of seawater,Journal of Atmospheric and Oceanic Technology, 2005, submitted.

Jerlov, N. G., Optical oceanography, Elsevier, 1968.

Kagan, B. A., Ocean-atmosphere interaction and climate modelling, Cambridge University Press,Cambridge, 1995.

Kantha, L. H., and C. A. Clayson, Small-scale processes in geophysical fluid flows, vol. 67 ofInternational Geophysics Series, Academic Press, 2000a.

Kantha, L. H., and C. A. Clayson, Numerical models of oceans and oceanic processes, vol. 66 ofInternational Geophysics Series, Academic Press, 2000b.

140

Page 141: Getm Doc Stable

Kondo, J., Air-sea bulk transfer coefficients in diabatic conditions, Bound. Layer Meteor., 9 , 91–112, 1975.

Krone, R. B., Flume studies of the transport of sediment in estuarial shoaling processes, Tech. rep.,Hydraulic Eng. Lab. US Army Corps of Eng., 1962.

Lander, J. W. M., P. A. Blokland, and J. M. de Kok, The three-dimensional shallow water modelTRIWAQ with a flexible vertical grid definition, Tech. Rep. RIKZ/OS-96.104x, SIMONA re-port 96-01 , National Institute for Coastal and Marine Management / RIKZ, The Hague, TheNetherlands, 1994.

Large, W. G., J. C. McWilliams, and S. C. Doney, Oceanic vertical mixing : a review and a modelwith nonlocal boundary layer parameterisation, Rev. Geophys., 32 , 363–403, 1994.

Leonard, B. P., The ULTIMATE conservative difference scheme applied to unsteady one-dimensional advection, Comput. Meth. Appl. Mech. Eng., 88 , 17–74, 1991.

Leonard, B. P., M. K. MacVean, and A. P. Lock, The flux integral method for multidimensionalconvection and diffusion, App. Math. Modelling, 19 , 333–342, 1995.

Madala, R. V., and S. A. Piacsek, A semi-implicit numerical model for baroclinic oceans, J. Com-putat. Phys., 23 , 167–178, 1977.

Martinsen, E. A., and H. Engedahl, Implementation and testing of a lateral boundary scheme asan open boundary condition in a barotropic ocean model, Coastal Engineering, 11 , 603–627,1987.

Mathieu, P.-P., E. Deleersnijder, B. Cushman-Roisin, J.-M. Beckers, and K. Bolding, The role oftopography in small well-mixed bays, with application to the lagoon of Mururoa, Cont. ShelfRes., 2001, accepted for publication.

Mellor, G. L., T. Ezer, and L.-Y. Oey, The pressure gradient conundrum of sigma coordinate oceanmodels, Journal of Atmospheric and Oceanic Technology, 11 , 1126–1134, 1994.

Patankar, S. V., Numerical Heat Transfer and Fluid Flow , McGraw-Hill, New York, 1980.

Paulson, C. A., and J. J. Simpson, Irradiance measurements in the upper ocean, J. Phys. Oceanogr.,7 , 952–956, 1977.

Pedlosky, J., Geophysical fluid mechanics, 2. ed., Springer, New York, 1987.

Phillips, N. A., A coordinate system having some special advantages for numerical forecasting, J.Meteorol., 14 , 184–185, 1957.

Roe, P. L., Some contributions to the modeling of discontinuous flows, Lect. Notes Appl. Math.,22 , 163–193, 1985.

Song, Y., A general pressure gradient formulation for ocean models. Part I: Scheme design anddiagnostic analysis, Monthly Weather Review , 126 , 3213–3230, 1998.

Song, Y., and D. B. Haidvogel, A semi-implicit ocean circulation model using a generalisedtopography-following coordinate, J. Computat. Phys., 115 , 228–244, 1994.

Umlauf, L., H. Burchard, and K. Bolding, General Ocean Turbulence Model. Source code docu-mentation, Tech. Rep. 63 , Baltic Sea Research Institute Warnemunde, Warnemunde, Germany,2005.

van Leer, B., Toward the ultimate conservative difference scheme. V: A second order sequel toGodunov’s method, J. Computat. Phys., 32 , 101–136, 1979.

141

Page 142: Getm Doc Stable

Zalezak, S. T., Fully multidimensional flux-corrected transport algorithms for fluids, J. Computat.Phys., 31 , 335–362, 1979.

Zalezak, S. T., A preliminary comparison of modern shock-capturing schemes: linear advec-tion, in Advances in computer methods for partial differential equations , edited by R. V. aandR. S. Stepleman, pp. 15–22, Publ. IMACS, 1987.

Zanke, U., Berechnung der Sinkgeschwindigkeiten von Sedimenten, Mitteilungen des Franzius-Institutes , 46 , 231–245, 1977.

142