49
Formulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K. Dewar and P. D. Killworth January 27, 2006 Contents 1 Introduction 2 2 Quasi-Geostrophic equations 2 3 Mixed layers 6 3.1 Mixed layer stress .......... 6 3.2 Mixed layer evolution ........ 9 4 Flux between layers 9 4.1 Incoming solar flux .......... 10 4.2 Radiative fluxes ............ 10 4.3 Sensible and latent heat flux ..... 10 4.4 Entrainment heat flux ........ 11 5 Layer equations 12 5.1 QG layers ............... 13 5.2 Ocean mixed layer .......... 14 5.3 Atmosphere mixed layer ....... 14 5.4 Convection .............. 14 6 Mean state 15 7 Final equation set 15 8 Numerical formulation 19 8.1 Discretisation in space and time . . . 19 8.2 Effect of the Laplacian operator on a Fourier component .......... 19 8.3 Numerical decomposition into modes 21 8.4 Solution of the modified Helmholtz equation ................ 22 8.5 Integration routines ......... 24 8.6 Diffusive timescales .......... 24 9 Users’ guide 25 9.1 Components of the code ....... 25 9.2 Compiling the code .......... 25 9.3 Structure of the code ......... 27 9.3.1 Input files ........... 27 9.3.2 Program structure ...... 28 9.3.3 Output files .......... 28 9.3.4 Location of variables ..... 30 9.3.5 Diagnostics .......... 30 9.3.6 Test programs ........ 30 9.3.7 Standard cases ........ 31 9.3.8 Possible problems ...... 31 9.3.9 Feedback ........... 32 9.4 Changes Log ............. 32 9.4.1 Changes from v1.3 to v1.3.1 . 32 9.4.2 Changes from v1.2 to v1.3 . . 33 9.4.3 Changes from v1.1 to v1.2 . . 33 A Writing radiation as a perturbation to mean state 34 A.1 Functional form of radiation para- meters ................. 34 A.2 Rules for linearising ......... 34 A.3 Calculations .............. 35 B Constraints on mass and momentum 38 B.1 Atmospheric momentum constraints 38 B.1.1 The continuous case ..... 39 B.1.2 The discrete case ....... 39 B.2 Ocean constraints ........... 42 B.2.1 Box ocean case ........ 42 B.2.2 Channel ocean case ...... 43 C Application of pressure derivative boundary conditions 44 D Starting at radiative equilibrium 45 E Energy 46 F Partially coupled experiments 48 1

Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Formulation and users’ guide for Q-GCM.

Version 1.3.1

A. McC. Hogg, J. R. Blundell, W. K. Dewar and P. D. Killworth

January 27, 2006

Contents

1 Introduction 2

2 Quasi-Geostrophic equations 2

3 Mixed layers 63.1 Mixed layer stress . . . . . . . . . . 63.2 Mixed layer evolution . . . . . . . . 9

4 Flux between layers 94.1 Incoming solar flux . . . . . . . . . . 104.2 Radiative fluxes . . . . . . . . . . . . 104.3 Sensible and latent heat flux . . . . . 104.4 Entrainment heat flux . . . . . . . . 11

5 Layer equations 125.1 QG layers . . . . . . . . . . . . . . . 135.2 Ocean mixed layer . . . . . . . . . . 145.3 Atmosphere mixed layer . . . . . . . 145.4 Convection . . . . . . . . . . . . . . 14

6 Mean state 15

7 Final equation set 15

8 Numerical formulation 198.1 Discretisation in space and time . . . 198.2 Effect of the Laplacian operator on a

Fourier component . . . . . . . . . . 198.3 Numerical decomposition into modes 218.4 Solution of the modified Helmholtz

equation . . . . . . . . . . . . . . . . 228.5 Integration routines . . . . . . . . . 248.6 Diffusive timescales . . . . . . . . . . 24

9 Users’ guide 259.1 Components of the code . . . . . . . 259.2 Compiling the code . . . . . . . . . . 25

9.3 Structure of the code . . . . . . . . . 279.3.1 Input files . . . . . . . . . . . 279.3.2 Program structure . . . . . . 289.3.3 Output files . . . . . . . . . . 289.3.4 Location of variables . . . . . 309.3.5 Diagnostics . . . . . . . . . . 309.3.6 Test programs . . . . . . . . 309.3.7 Standard cases . . . . . . . . 319.3.8 Possible problems . . . . . . 319.3.9 Feedback . . . . . . . . . . . 32

9.4 Changes Log . . . . . . . . . . . . . 329.4.1 Changes from v1.3 to v1.3.1 . 329.4.2 Changes from v1.2 to v1.3 . . 339.4.3 Changes from v1.1 to v1.2 . . 33

A Writing radiation as a perturbation tomean state 34A.1 Functional form of radiation para-

meters . . . . . . . . . . . . . . . . . 34A.2 Rules for linearising . . . . . . . . . 34A.3 Calculations . . . . . . . . . . . . . . 35

B Constraints on mass and momentum 38B.1 Atmospheric momentum constraints 38

B.1.1 The continuous case . . . . . 39B.1.2 The discrete case . . . . . . . 39

B.2 Ocean constraints . . . . . . . . . . . 42B.2.1 Box ocean case . . . . . . . . 42B.2.2 Channel ocean case . . . . . . 43

C Application of pressure derivativeboundary conditions 44

D Starting at radiative equilibrium 45

E Energy 46

F Partially coupled experiments 48

1

Page 2: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

1 Introduction

In this document we describe the formulation of an intermediate complexity mid-latitude coupledclimate model. The model uses quasi-geostrophic (QG) dynamics in both ocean and atmosphereso that the momentum equations can be solved quickly, while non-linear dynamics and highresolution in the ocean can be retained.

Quasi-geostrophy is known to be a robust approximation to ocean and atmosphere mesoscaledynamics, explicitly involves relative vorticity and eddies, and is much more dynamically trans-parent than the primitive equations. Further, such a model stands on some twenty odd years ofexperimentation in ocean-only and atmosphere-only settings and thus represents a logical nextstep in the continued use of quasi-geostrophy for process modelling.

However, QG models are not naturally suited to be run in coupled scenarios because of thepoor representation of vertical fluxes of heat, and advection of temperature. An exception isECBilt (Opsteegh et al., 1998), a 3 layer QG atmosphere model which has been coupled toan ocean model; however the evolution of temperature at the ocean-atmosphere boundary andrepresentation of diabatic processes is oversimplified. Kravtsov and Robertson (2002) describea coupled QG model which includes an oceanic mixed layer to better represent ocean heattransport.

We extend this concept by including mixed layers in both ocean and atmosphere componentsof a layered QG model. The mixed layers allow the communication of stress and the flux ofheat between ocean and atmosphere. The coupling of an atmosphere QG model to an oceanQG model then involves the connection of two symmetric models which use the same equationsbut different governing parameters. In this way we can model a channel atmosphere coupled toa box or channel ocean, and use this model to simulate a mid-latitude climate system drivenby latitudinal variation of incoming radiation. A two layer version of the Quasi-GeostrophicCoupled Model (Q-GCM) is shown schematically in figure 1.

This document describes version 1.3.1 of Q-GCM. The first version of the code was outlinedin Hogg et al. (2003b) and Hogg et al. (2003a). Version 1.2 of Q-GCM was used for systematicocean-only (Hogg et al., 2005) and coupled climate (Hogg et al., 2006) studies. The currentversion of the model will be used for complementary studies on the southern ocean climatesystem.

2 Quasi-Geostrophic equations

Begin with the equations for conservation of momentum in a rotating fluid,

ut + uux + vuy + wuz − fv = −px + Kuxx + Kuyy + Kuzz, (2.1a)

vt + uvx + vvy + wvz + fu = −py + Kvxx + Kvyy + Kvzz, (2.1b)

wt + uwx + vwy + wwz = −pz − g + Kwxx + Kwyy + Kwzz, (2.1c)

where we have used u = (u, v, w) for velocity, and subscripts to represent partial derivatives.The pressure p has been rescaled by mean density ρ and we represent viscosity using a constantdiffusion coefficient K. The Coriolis parameter has been represented by f and gravitationalacceleration by g. The other equations required here are the continuity equation

ux + vy + wz = 0, (2.2)

and the mass conservation equation which we write as

ρt + uρx + vρy + wρz = KHρxx + KHρyy + KV ρzz. (2.3)

2

Page 3: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

2000 3000 4000 5000 6000 7000-4

-2

0

2

4

6

8

10Z

(km

)

Y (km)

OCEAN LAYER 1OCEAN MIXED LAYER

OCEAN LAYER 2

ATMOSPHEREMIXED LAYER

ATMOSPHERE LAYER 1

ATMOSPHERE LAYER 2

INCOMING SOLARRADIATION

HEAT DISTRIBUTED INTERNALLY BYRADIATION AND

ENTRAINMENT

WIND STRESSLEADS TO EKMAN

PUMPING

EKMAN PUMPING

QUASI-GEOSTROPHICDYNAMICS

QUASI-GEOSTROPHICDYNAMICS

ENTRAINMENT

Figure 1: Schematic of (a two-layer version of) the Quasi-Geostrophic Coupled Model. This meridionalslice through the model shows the interface dividing the two QG dynamical layers in both the ocean andthe atmosphere. The mixed layers, shown by the shading which represents temperature, act to distributeheat and momentum between the two domains. The model is driven by latitudinally varying solar forcing,and by redistribution of heat by longwave radiation in the atmosphere.

To derive the quasi-geostrophic equations which govern the model dynamics, we simplify(2.1)–(2.3). This could be done rigorously by first non-dimensionalising, and then by scalingaway less important terms, but it will suffice for now to do this informally. We begin by assuming,for the purposes of finding the zeroth order equations, that

1. Vertical velocity is small compared with horizontal velocities;

2. The Coriolis parameter is represented by the frozen β-plane approximation f(y) = f0 +β(y − y0) where f0 represents the zeroth order effect of rotation at the central latitude ofthe domain (i.e. y = y0);

3. Diffusion of momentum is dominated by pressure gradients.

The zeroth order equations in which pressure balances rotation are then

f0av1 = ap1x, (2.4a)

f0au1 = −ap1y, (2.4b)

3

Page 4: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

ap1z = −g, (2.4c)

and the continuity equation isau1x + av1y = 0 (2.5)

which is automatically satisfied by (2.4a) and (2.4b). Vorticity is given by

av1x − au1y =∇2

Hap1

f0. (2.6)

The notation used here indicates that we are referring to layer 1 (subscript 1) in the atmosphere(superscript a). Subscript m is used to represent the mixed layer. The same notation is usedfor quantities which refer to interface properties, with the ocean-atmosphere boundary definedas interface 0. In the atmosphere (ocean), interface k is defined to be on the upper (lower)boundary of layer k (that is, in both domains we number away from the ocean-atmosphereboundary).

We can now compute the first order quantities (signified by ∗ in the equations below) for thehorizontal momentum and continuity equations which include zeroth order horizontal velocityterms and first order pressure and rotation terms,

au1t + au1au1x + av1

au1y − f0av1

∗ − β(y − y0)av1 = −ap1∗x − aA4∇4

Hau1, (2.7a)

av1t + au1av1x + av1

av1y + f0au1

∗ + β(y − y0)au1 = −ap1∗y − aA4∇4

Hav1, (2.7b)

au1∗x + av1

∗y + aw1

∗z = 0, (2.8)

where we have introduced a fourth-order horizontal viscosity scheme (the coefficient aA4 is posit-ive for energy dissipation). First order pressure terms can be eliminated by cross-differentiating(2.7a) and (2.7b), giving

au1ty + (au1au1x)y + (av1

au1y)y − f0av1

∗y − (β(y − y0)av1)y + aA4∇4

Hau1y

= av1tx + (au1av1x)x + (av1

av1y)x + f0au1

∗x + (β(y − y0)au1)x + aA4∇4

Hav1x, (2.9)

and rearranging:(∇2

Hap1

f0+ β(y − y0)

)t

+(

au1

[∇2

Hap1

f0+ β(y − y0)

])x

+(

av1

[∇2

Hap1

f0+ β(y − y0)

])y

+

(au1x + av1y)(∇2

Hap1

f0+ β(y − y0)

)+ f0(au1

∗x + av1

∗y) = −aA4∇4

H

(∇2

Hap1

f0

)(2.10)

Insert (2.5) and (2.8) to eliminate zeroth order divergence terms and first order velocities, leavingan equation which depends only upon zeroth order terms(

∇2H

ap1

f0+ β(y − y0)

)t

+(

au1

[∇2

Hap1

f0+ β(y − y0)

])x

+(

av1

[∇2

Hap1

f0+ β(y − y0)

])y

=

f0aw1

∗z −

aA4

f0∇6

Hap1. (2.11)

We now integrate (2.11) over the layer depth. Note that it is assumed that ap1, au1 and av1

are effectively layer-averaged quantities, so that integration between zero and aH1 simply gives(∇2

Hap1

f0

)t

+(

au1∇2

Hap1

f0

)x

+(

av1

(∇2

Hap1

f0+ β(y − y0)

))y

=

f0(aw1∗ − awm

∗)aH1

−aA4

f0∇6

Hap1, (2.12)

4

Page 5: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

which is an equation for the evolution of potential vorticity in the layer. Evaluation of verticalvelocity at the layer boundaries (aw1

∗ and awm∗) requires knowledge of the flux between layers

(which we call e for net entrainment velocity through the boundary of the layer). Verticalvelocity is a first order quantity and thus incorporates variable layer thickness ah1, giving

aw1∗ = ah1t + (au1

ah1)x + (av1ah1)y + ae1. (2.13)

The lower boundary of the atmosphere is solid; however vertical velocity due to Ekman pumping(derived below) makes a contribution; awm

∗ = awek. We can now write an equation for the lowestatmospheric layer dynamics,

aq1t + (au1aq1)x + (av1

aq1)y =f0(ae1 − awek)

aH1−

aA4

f0∇6

Hap1, (2.14)

where layer potential vorticity is defined as

aq1 ≡∇2

Hap1

f0+ β(y − y0)−

f0aη1

aH1+

f0aD

aH1, (2.15)

and the perturbation interface height, aη1 ≡ ah1 − aH1 =ap1−ap2

ag′1. Here we have introduced

the bottom topography aD(x, y) which is assumed to be small compared with the unperturbedlayer thickness aH1, for consistency with the quasigeostrophic scaling. Equivalent equations canbe derived for each layer in the model. For other layers in the N -layer atmosphere these are:

aqkt + (aukaqk)x + (avk

aqk)y =f0

aHk(aek − aek−1)−

aA4

f0∇6

Hapk, (2.16)

where aeN ≡ 0, and

aqk ≡∇2

Hapk

f0+ β(y − y0)−

f0

aHk(aηk − aηk−1), for k = 2, N, (2.17)

aηk =apk − apk+1

ag′k, for k = 1, N − 1, (2.18)

aηN ≡ 0. (2.19)

For an N -layer ocean, the equations are

oqkt + (oukoqk)x + (ovk

oqk)y =f0

oHk(oek−1 − oek) +

oA2

f0∇4

Hopk −

oA4

f0∇6

Hopk, for k = 1, N (2.20)

where a Laplacian diffusion term is included, the vertical velocities at the top and bottom ofthe ocean are given by oe0 ≡ owek and oeN ≡ δek

2|f0|∇2H

opN as will be discussed in §3.1, and

oqk ≡∇2

Hopk

f0+ β(y − y0) +

f0

oHk(oηk − oηk−1), for k = 1, N − 1, (2.21)

oqN ≡∇2

HopN

f0+ β(y − y0)−

f0

oHN

oηN−1 +f0

oDoHN

, (2.22)

oηk = −opk − opk+1

og′k, for k = 1, N − 1, (2.23)

oη0 ≡ 0.

5

Page 6: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

All of the model equations can be written more generally in vector form

qt + (uq)x + (vq)y = Be +A2

f0∇4

Hp− A4

f0∇6

Hp, (2.24)

f0q− f0β(y − y0) = ∇2Hp− f2

0 Ap + f0D̃, (2.25)

where D̃ is the dynamic topography which is rescaled by f0 and the inverse of layer thickness(see 5.8, 5.9), aA2 ≡ 0, A is an N ×N matrix containing the coefficients of the η contribution tovorticity, which has the same structure for the ocean and atmosphere, while B is an N ×N + 1matrix containing the coefficients of the forcing terms, which differs only by a sign between thetwo cases (see §5.1 for details of the matrices and vectors). Note that e is a vector of lengthN + 1 which is yet to be determined.

The boundary conditions in the model are applied to the pressure field. In the case of thefinite box ocean the boundary pressure is given by

opk = ofk(t), (2.26)

where the function ofk(t) is determined by constraints on mass (see section B.2.1), and is constantaround the boundary. For the atmosphere, or the cyclic ocean case, the east and west boundariesare periodic, and pressure on the north and south boundaries satisfies a more complicated mixedcondition derived using both mass and momentum constraints, after McWilliams (1977) (seesections B.1.2 and B.2.2). The values on the north and south boundaries will differ. As theseare mixed conditions rather than simply specified values of pressure, they do not amount to asimple flux condition.

Boundary conditions are also required for the derivatives of pressure on all solid boundaries,and in all cases we use another form of mixed condition, applied to the normal derivatives,following Haidvogel et al. (1992). For the north and south boundaries of the atmosphere, theseare written as

apknn = −aαbc

∆apkn, (2.27)

apk4n = −aαbc

∆apk3n, (2.28)

where the nondimensional coefficient αbc is zero for free slip and infinite for no-slip boundaryconditions (although, in practice, αbc > 2 is a good approximation to no-slip), ∆ is the horizontalgrid spacing and subscript n denotes the outward normal derivative. Again, the east and westboundaries are periodic. The cyclic ocean case is handled in the same way as the atmosphere.For the finite box ocean, (2.27) and (2.28) are also applied to the west and east boundaries.

3 Mixed layers

Quasi-geostrophy describes, to first order, the dynamics of both ocean and atmosphere, butcannot handle the fluxes of heat and momentum between these two domains which are requiredfor a coupled model. Q-GCM avoids this difficulty by embedding mixed layers within layer 1 ofboth ocean and atmosphere. In its current form the mixed layers do not include parameterisationof humidity in the atmosphere or salinity in the ocean, and therefore exchanges of these quantitiesare not modelled. Nonetheless, the most fundamental processes – transfer of momentum fromatmosphere to ocean, and flux of heat in both directions – are included.

3.1 Mixed layer stress

We first derive the stress at the ocean-atmosphere interface by finding the atmospheric mixedlayer velocities. The distinction between mixed layer and layer 1 velocities is that the mixed layer

6

Page 7: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

is thin enough that the vertical flux of horizontal momentum is significant. The zeroth ordermomentum equations can be found by including the vertical flux of momentum by a dynamicstress (rescaled by mean density aρ)

−f0avm = −ap1x + aτx

z , (3.1a)

f0aum = −ap1y + aτy

z . (3.1b)

Assuming a fixed atmospheric mixed layer thickness and zero stress at the upper boundary ofthe mixed layer, we substitute (2.4a,b) and integrate over mixed layer depth aHm to give

avm = av1 +aτx

aHmf0, (3.2a)

aum = au1 −aτy

aHmf0, (3.2b)

where it is implied that stress is a layer-averaged quantity. We assume stress is a quadraticfunction of the ageostrophic mixed layer velocity (Pedlosky, 1987),

(aτx, aτy) = CD|aum|(aum, avm), (3.3)

CD being a dimensionless drag coefficient. Substituting (3.3) into (3.2a,b) gives

avm = av1 +CD|aum|aum

aHmf0, (3.4a)

aum = au1 −CD|aum|avm

aHmf0. (3.4b)

which allows us to write, with some algebraic manipulation,

avm =[

av1 +CD|aum|au1

aHmf0

][1 +

(CD|aum|aHmf0

)2]−1

, (3.5a)

aum =[

au1 −CD|aum|av1

aHmf0

][1 +

(CD|aum|aHmf0

)2]−1

, (3.5b)

allowing direct calculation of stress provided one knows

|aum| ≡√

aum2 + avm

2 =aHm|f0|√

2 CD

√√√√−1 +

√1 + 4

(CD|au1|aHmf0

)2

. (3.6)

A second distinction between mixed layer and layer 1 velocities exists because the ageo-strophic mixed layer velocities have a divergent component which produces vertical Ekmanvelocities. Ekman pumping is calculated using the continuity equation (2.2) integrated from 0to aHm,

awek = −aHmaumx − aHm

avmy, (3.7)

where we use awm(0) = 0 and awm(aHm) = awek. Substitute velocity from (3.2a,b), giving

awek =aτy

x − aτxy

f0, (3.8)

the familiar expression for Ekman velocity as a function of stress.

7

Page 8: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

The ocean mixed layer is essentially an inversion of the atmospheric mixed layer. Thedifference here is that stress in the oceanic mixed layer is passive, depending entirely on windstress and the atmosphere to ocean density ratio,

oτ =aρoρ

aτ . (3.9)

oτ is obtained by interpolation from aτ , and Ekman pumping in the ocean surface layer issimilarly obtained by interpolation from awek:

owek =aρoρ

awek. (3.10)

(Note that this produces a smoother owek field than taking the curl of the interpolated oτ ).It is relevant at this stage to note that momentum must also be lost from the ocean, and that

this occurs via drag due to a no-slip condition at the ocean floor. We calculate this by assumingan Ekman layer of prescribed thickness δek =

√K/|f0| and proceed as above. In this case there

is no need to calculate stress explicitly, and so we determine the Ekman pumping directly frompressure. Velocity in the Ekman layer will be given by

ovN =opN x

f0+

τx

δekf0, (3.11a)

ouN = −opN y

f0− τy

δekf0. (3.11b)

We use linear stress,

(τx, τy) =K

δek(ouN , ovN ), (3.12)

so thatovN =

opN x

f0+ sgn(f0)ouN , (3.13a)

ouN = −opN y

f0− sgn(f0)ovN . (3.13b)

Combining these two we can write separate equations for each component of velocity,

ovN =opN x

2f0−

opN y

2|f0|, (3.14a)

ouN = −opN y

2f0−

opN x

2|f0|. (3.14b)

These can be substituted into (2.2), which is then integrated across the Ekman layer:

owN =δek

2|f0|∇2

HopN . (3.15)

This vertical velocity on the lower boundary of the ocean alters the vertical velocity in oceanlayer N but has no impact on the heat flux (as there is no temperature gradient).

8

Page 9: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

3.2 Mixed layer evolution

The mixed layers also act to transfer heat between atmosphere and ocean. To allow this, weneed to explicitly calculate the evolution of temperature in the mixed layers. As before weintegrate over the mixed layer thickness, but for the purposes of temperature evolution we allowperturbations aηm = ahm − aHm to mixed layer height in the atmosphere only. The variablemixed layer height is needed in the atmosphere because of an observed instability which occursdue to large vertical heat transports in regions where there is a coherent pattern of upwellingand cold mixed layer temperatures.

To find the evolution of mixed layer height, we again integrate the continuity equation, thistime from 0 to ahm,

awm(ahm) = −ahmaumx − ahm

avmy. (3.16)

Now we write an equation for the mixed layer height, analogous to (2.13),awm(ahm) = ahmt + aum

ahmx + avmahmy + aem. (3.17)

Combining these gives the evolution equation for mixed layer height, which implicitly includesthe Ekman divergence terms,

ahmt + (aumahm)x + (avm

ahm)y = −aem. (3.18)

This equation is solved with ahm = aHm on the north and south boundaries.The evolution of mixed layer temperature comes from a heat equation,

aTmt + aumaTmx + avm

aTmy + awmaTmz = aK2∇2

HaTm − aK4∇4

HaTm −

aFz

aρaCp, (3.19)

where aCp is the specific heat capacity and aK2 a diffusion coefficient. This equation includes afourth-order diffusion term with positive coefficient aK4 for numerical stability. We have chosento retain the horizontal diffusion terms, while writing the vertical diffusion as the vertical gradientof a flux aF of heat energy. Note that flux is defined positive upwards so that a positive fluxgradient will act to cool the layer in a stably stratified fluid. Integrate (3.19) between 0 andahm,

aTmt +(aumaTm)x +(avm

aTm)y +awek

aTm

aHm= aK2∇2

HaTm−aK4∇4

HaTm +

−aFm + aF0aρaCp

ahm. (3.20)

The fluxes at the top of the mixed layer (aFm) and at the surface (aF0) are derived in §4 below.There is no heat flux on the north and south boundaries.

In the ocean, we use a constant thickness mixed layer, and the equivalent equation to (3.20)is

oTmt + (oumoTm)x + (ovm

oTm)y −owek

oTm

oHm= oK2∇2

HoTm− oK4∇4

HoTm +

−oF0 + oFmoρoCp

oHm. (3.21)

The default boundary conditions for the ocean mixed layer evolution are zero heat flux. However,provision is made for constant temperature boundary conditions on the equatorward meridionalboundary, the value of the temperature there being determined from radiative balance. Thiscondition is necessary because advection and diffusion of warm tropical water from that boundaryare not explicitly included in the model. A similar boundary condition is not required on thepoleward meridional boundary because convection is active there.

4 Flux between layers

Q-GCM includes flux of heat between each layer due to a number of different processes. Wederive each case below, and write heat flux as the superposition of a mean and a first orderperturbation quantity, so that fluxes are linearised about a mean state in which the model is inradiative balance.

9

Page 10: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

4.1 Incoming solar flux

The incoming solar radiation is written as a heat flux Fs. The atmosphere is transparent toincoming shortwave radiation which is deposited directly in the oceanic mixed layer. Over land,incoming shortwave is absorbed by the land and immediately re-emitted as longwave radiationinto the atmospheric mixed layer. Heat flux is defined so that positive fluxes denote an upwardsmovement of heat energy, so that the mean incoming radiation, Fs, is defined negative. Wethus divide the radiation into a mean and a y-dependent part which integrates to zero over thedomain,

Fs(y) = Fs +F ′

s

2sin(

π(y − y0)aY

), (4.1)

where aY is the latitudinal atmospheric domain size. The magnitude of F ′s is defined in

input.params, and it has the same sign as f0 (i.e. positive for northern hemisphere casesand negative for southern hemisphere cases).

4.2 Radiative fluxes

Each atmospheric layer, and the oceanic mixed layer, radiates and absorbs heat dependingupon its temperature and optical depth. The emitted longwave radiation is either absorbed,transmitted or partially transmitted by neighbouring layers. The equations describing radiativeflux from each layer are given below, in the form of a mean part plus linear perturbations. Theconstant coefficients governing the linear response of the model are derived in appendix A.

Oceanic Mixed Layer absorbs all downgoing longwave radiation (as well as incoming short-wave radiation) which passes through the atmospheric mixed layer. Emits radiation ac-cording to

F ↑0 ≈ F ↑

0 + D↑0oTm

′. (4.2)

Atmospheric Mixed Layer absorbs all downgoing and upgoing longwave radiation. Linear-ised radiation is written

F ↑m ≈ F ↑

m + B↑m

aηm + C↑m

aD + D↑m

aTm′, (4.3)

F ↓m ≈ F ↓

m + D↓m

aTm′. (4.4)

Atmospheric QG layers have a more complicated radiation balance, as partial absorption ofincoming radiation and partial emission of the incoming radiation occur:

F ↑k ≈ F ↑

k +min(k,N−1)∑

i=1

A↑k,i

aηi + B↑kaηm + C↑

kaD + D↑

kaTm

′ for k = 1, N, (4.5)

F ↓k ≈ F ↓

k +N−1∑

i=max(k−1,1)

A↓k,i

aηi + B↓kaηm + C↓

kaD for k = 1, N. (4.6)

4.3 Sensible and latent heat flux

Sensible and latent heat flux from the oceanic to the atmospheric mixed layer is represented by

Fλ = λ(oTm − aTm), (4.7)

or in perturbation formFλ = Fλ + λ(oTm

′ − aTm′), (4.8)

whereFλ = λ(oTm − aTm). (4.9)

10

Page 11: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

4.4 Entrainment heat flux

The QG layers have constant (but different) potential temperatures. Therefore, the combinedheat content of any two layers can only change when the interface dividing the layers changesits height. The entrainment aei therefore implies a vertical heat flux between layers i and i + 1.This heat flux is written as a double-sided flux (see McDougall and Dewar, 1998), so that in theatmosphere

aF e+i − aF e−

i = −aρaCpaei∆a

i T, (4.10)

where ∆ai T is the change in temperature across the interface and aF e+

i (aF e−i ) is the heat flux

on the upper (lower) side of interface i. This allows a divergence of heat flux at the interface,but not within the layers.

In the atmosphere we assume no entrainment at the top of the domain:

aF e−N = 0. (4.11)

The heat conservation equation in any layer is

aF e−i + F ↑

i + F ↓i+1 = aF e+

i−1 + F ↑i−1 + F ↓

i , (4.12)

allowing calculation of entrainment at the interface i by combining the equations for layers iand i + 1;

aei =aF e+

i−1 + F ↑i−1 + F ↓

i − aF e−i+1 − F ↑

i+1 − F ↓i+2

aρaCp∆ai T

. (4.13)

In the 2 layer case this equation is conclusive, since aF e+m = 0 (see below) and aF e−

N = 0 (becauseit is at the top of the atmosphere), so that we can write the equation for ae1 explicitly. Formore layers we have insufficient constraints to determine entrainment everywhere. Therefore,on the basis that most convection and vertical heat transport occurs in the lower atmosphere,we assume that all entrainment occurs at the lowest interface, or in other words

ae1 =F ↑

m + F ↓1 − F ↑

NaρaCp∆a

1T. (4.14)

aei = 0, i > 1. (4.15)

The additional assumption (4.15) implies (from 4.10) that the interfacial temperature differences∆a

i T are irrelevant for i > 1, and thus that the atmospheric layer temperatures aTi for i > 2have no thermodynamic significance. Their only role then lies in determining the linear responsecoefficients in the radiative model (see equations A.24 to A.51). All radiation in the atmosphereis therefore encapsulated in (4.14), which we now rewrite explicitly in terms of the radiationparameters used in (4.3), (4.5) and (4.6):

ae1 =1

aρaCp∆a1T

[N−1∑i=1

(A↓

1,i −A↑N,i

)aη1 +

(B↑

m + B↓1 −B↑

N

)aηm+

(C↑

m + C↓1 − C↑

N

)aD +

(D↑

m −D↑N

)aTm

′]. (4.16)

At the mixed layer interface we assume that entrainment is maintained by turbulence oneither side of the interface. In other words, assume

aF e+m = Fx −

aρaCpaµ1

aH1 − ahm, (4.17)

aF e−m = Fx −

aρaCpaµm

ahm, (4.18)

11

Page 12: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

where Fx is an export heat flux (a constant added heat flux), and

aµ1

aH1 − aHm=

aµm

aHm. (4.19)

We linearise the above equations to give

aF e+m = Fx −

aρaCpaµ1

aH1 − aHm, (4.20)

aF e−m = aF e−

m −aρaCp

aµm

aHm

(1−

aηm

aHm

). (4.21)

Thenaem ≈

aφm

aρaCp∆amT

aηm, (4.22)

whereaφm ≡

aρaCpaµm

aHm2 . (4.23)

In the model we then use the perturbation forcing

aF e−m = aF e−

m + aφmaηm (4.24)

aF e+m = aF e−

m . (4.25)

In the ocean we assume that the deep layers do not exchange heat so that

oF e−1 = 0, (4.26)

and heat flux between other layers is zero,

oek = 0, k > 1. (4.27)

Again, the additional assumption (4.27) implies that the interfacial temperature differences ∆oi T

are irrelevant for i > 1, as therefore are the oceanic layer temperatures oTi for i > 2. From(4.10) we write

oF e+1 = −oρoCp

oe1∆o1T. (4.28)

In the oceanic mixed layer, where there is no variation in mixed layer depth, entrainment issolely driven by Ekman pumping,

oem = owek. (4.29)

Using a centred difference model for entrainment there, we find

oF e+m = −0.5oρoCp∆o

mT owek, (4.30)

oF e−m = 0.5oρoCp∆o

mT owek. (4.31)

Therefore we can writeoe1 = −∆o

mT

2∆o1T

owek. (4.32)

A constant offset is added to oe1 to ensure its area integral is zero (see appendix B.2).

5 Layer equations

We are now in a position to put together equations for each layer. A schematic of the modelwhich includes radiative fluxes, entrainment velocities and momentum coupling is shown infigure 1.

12

Page 13: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

5.1 QG layers

The QG equations are written from (2.24) and (2.25) as follows,

qt + (uq)x + (vq)y = Be +A2

f0∇4

Hp− A4

f0∇6

Hp, (5.1)

which can also be written as

qt =1f0

J(q,p) + Be +A2

f0∇4

Hp− A4

f0∇6

Hp, (5.2)

where J is the Jacobian,J(q,p) = qxpy − qypx,

andf0q− f0β(y − y0) = ∇2

Hp− f20 Ap + f0D̃. (5.3)

For both ocean and atmosphere we can write

A =

1H1g′1

−1H1g′1

−1H2g′1

1H2

(1g′2

+ 1g′1

)−1

H2g′2· · ·

· · ·−1

HN g′N−1

1HN g′N−1

(5.4)

while B differs from atmosphere to ocean,

oB = f0

1

H1

−1H11

H2

−1H2

· ·· ·

1HN

−1HN

(5.5)

and aB = −oB. Note that B is a N ×N + 1 matrix which produces two forcing terms on eachlayer, one at the top and one at the bottom. The entrainment vectors are given by

oe =

owek

− ∆omT

2∆o1T

owek

0··

δek2|f0|∇

2H

opN

(5.6)

and

ae =

awek

F ↑m+F ↓

1 −F ↑N

aρaCp∆a1T

0··0

. (5.7)

The entrainment equations will be altered if convection occurs. The dynamic topography vectorsare simply

aD̃ =

f0

aDaH1

0··0

, (5.8)

13

Page 14: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

and

oD̃ =

00··

f0oD

oHN

. (5.9)

5.2 Ocean mixed layer

From (3.21),

oTmt + (oumoTm)x + (ovm

oTm)y −owek

oTm

oHm= oK2∇2

HoTm − oK4∇4

HoTm +

oF0 + oF e+m

oρoCpoHm

, (5.10)

where total oceanic mixed layer forcing is given by

oF0 = −Fλ − F ↑0 − F ↓

m − Fs, (5.11)

and we have retained the entrainment flux as a separate term in (5.10). Note that the advectiveterms here use the mixed layer velocity which is modified by stress, rather than the geostrophicvelocity used in (5.1).

5.3 Atmosphere mixed layer

From (3.18) we getahmt + (aum

ahm)x + (avmahm)y = −aem. (5.12)

Note that ahm is constrained to prevent very small values occurring: when ahm becomes smallerthan a critical value, it is reset to the critical value, and aTm adjusted accordingly to conserveheat. Equation (2.3) gives

aTmt +(aumaTm)x +(avm

aTm)y +awek

aTm

aHm= aK2∇2

HaTm−aK4∇4

HaTm +

−aFm + aF0aρaCp

ahm, (5.13)

where atmospheric mixed layer forcing above and below the mixed layer are respectively givenby

aFm = F ↑m + F ↓

1 + aF e−m (5.14)

aF0 =

{F ↓

m + Fλ + F ↑0 over ocean,

− F ′s over land.

(5.15)

5.4 Convection

Convection will occur when unstable stratification forms and will act to change temperature inthe mixed layers in a way which conserves heat. In the atmosphere, when aTm exceeds aT1 weadjust the layer 1 entrainment as follows,

δae1 =ahm(aT1 − aTm)

2∆at∆a1T

, (5.16)

and set aTm = aT1. Here we use ∆at to represent the atmosphere timestep.Likewise, in the ocean, when oTm < oT1 we alter layer 1 entrainment by

δoe1 =−oHm(oT1 − oTm)

2∆ot∆o1T

, (5.17)

and set oTm = oT1.

14

Page 15: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

6 Mean state

The mean state is defined by the solution of the above equations when Fs = Fs. In thisstate there will be no motion, so that pressure gradients, vorticity gradients and entrainmentdisappear. Our full equation set then reduces to a radiation balance between the atmosphereand the oceanic mixed layer. From (5.7) we get a heat balance in the upper atmosphere

aF e+m + F ↓

1 + F ↑m − F ↑

N = 0, (6.1)

(5.13) gives us the heat balance in the atmospheric mixed layer

−F ↑m − F ↓

1 − aF e−m + [F ↓

m + Fλ + F ↑0 ] = 0, (6.2)

and (5.10) can be used for the heat balance in the ocean mixed layer,

−Fλ − F ↑0 − F ↓

m − Fs + oF e+m = 0, (6.3)

where oF e+m = 0 and aem = 0. These equations can be manipulated to write

F ↑N = −Fs, (6.4)

which yields aTm provided one has knowledge of temperature, transmissivity and layer heightin the atmosphere. Equation (6.3) can be written as a quartic equation in oTm to give oceanicmixed layer temperature. The value of aφm is prescribed, and export heat fluxes are adjustedto satisfy (6.2).

7 Final equation set

The full set of equations is now written in the order in which they are solved in the model. Theequation numbers used here are referred to in comments in the code. Specified parameters fortwo standard configurations (the finite box ocean and channel ocean cases) are shown in table1, while tables 2 and 3 show atmospheric and oceanic parameters which are common to both ofthese configurations.

At the start of each ocean timestep we find the atmospheric stress from (3.3), (3.5a) and(3.5b):

(aτx, aτy) =CD|aum|

χ

(au1 −

CD|aum|aHmf0

av1,av1 −

CD|aum|aHmf0

au1

), (7.1)

where

(au1,av1) =

1f0

(−ap1y,ap1x) , (7.2)

|aum| =aHm|f0|√

2 CD

√√√√−1 +

√1 + 4

(CD|au1|aHmf0

)2

, (7.3)

and

χ ≡ 1 +(

CD|aum|aHmf0

)2

. (7.4)

We find the ocean stress from (3.9),oτ =

aρoρ

aτ , (7.5)

15

Page 16: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

Parameters Box Ocean Channel Ocean DescriptionaX × aY 15360× 7680 km 23040× 7200 km Atmosphere domain sizeoX × oY 3840× 4800 km 23040× 3000 km Ocean domain size

∆ax 120 km 120 km Atmosphere horizontal grid spacing∆ox 10 km 15 km Ocean horizontal grid spacing∆at 5 min 5 min Atmosphere Timestep∆ot 30 min 30 min Ocean Timestepδek 1 m 2 m Bottom Ekman layer thickness

oαbc 0.5 5.0 Ocean mixed BC coefficientFs -210 W/m2 -210 W/m2 Mean incoming radiation|F ′

s| 80 W/m2 70 W/m2 Amp. of variable incoming radiationf0 1× 10−4 s−1 − 1.2× 10−4 s−1 Mean Coriolis parameterβ 2× 10−11 (ms)−1 1.3× 10−11 (ms)−1 Coriolis parameter gradient

ordk (51, 32) km (42, 26) km Ocean baroclinic Rossby radii (derived)ardk (465, 243) km (388, 203) km Atmos baroclinic Rossby radii (derived)

Table 1: Standard Q-GCM parameters for the box ocean and channel ocean cases.

Parameters Value DescriptionaHk (2000, 3000, 4000) m Layer heightsaHm 1000 m Mean mixed layer height

aHmmin 100 m Minimum mixed layer heightaTk (330, 340, 350) K Potential temperature structureaρ 1 kg/m3 Density

aCp 1000 J/kg/K Specific heat capacityag′k (1.2, 0.4) m/s2 Reduced gravityCD 1.3× 10−3 Drag coefficientaA4 2× 1014 m4/s Horizontal viscosity coefficientaαbc 1 Mixed boundary condition coefficientXC 1 Coupling coefficient (see appendix F)aK2 2.7× 104 m2/s Horizontal temperature diffusion coefficientaK4 3× 1014 m4/s Horizontal 4th order diffusion coefficientKη 2× 105 m2/s Horizontal diffusion coefficient for aηmaφm 0.15 W/m3 Relaxation rate for mixed layer heightσ 5.6704× 10−8 W/m2/K4 Stefan–Boltzmann constantγ 0.01 K/m Adiabatic lapse rateλ 35 W/m2/K Sensible and latent heat flux coefficientzm 200 m Optical depth in the mixed layerzk (30 000, 30 000, 40 000) m Optical depths

Table 2: Standard atmospheric parameters for Q-GCM.

by interpolation onto the oceanic pressure grid and multiplication by the density ratio aρ/oρ.The atmospheric Ekman velocity can then be calculated (naturally on the temperature grid,and then averaged onto the pressure grid) from (3.8)

awek =1f0

(aτyx − aτx

y ). (7.6)

16

Page 17: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

Parameters Value DescriptionoHk (300, 1100, 2600) m Layer heightsoHm 100 m Mixed layer height (fixed)oTk (278, 268, 258) K Potential temperature structureoρ 1000 kg/m3 Density

oCp 4000 J/kg/K Specific heat capacityog′k (0.05, 0.025) m/s2 Reduced gravityoA2 0 m2/s Laplacian horizontal viscosity coefficientoA4 2.0× 1010 m4/s Biharmonic horizontal viscosity coefficientYC 1 Coupling coefficient (see appendix F)oK2 380 m2/s Horizontal temperature diffusion coefficientoK4 4× 1010 m4/s Horizontal 4th order diffusion coefficient

Table 3: Standard oceanic parameters for Q-GCM.

Ocean Ekman velocity is interpolated from atmospheric values using (3.10)

owek =aρoρ

awek. (7.7)

Note that the interpolation is done onto the pressure grid, and then averaged onto the temper-ature grid. The radiative fluxes at the atmospheric mixed layer boundaries are determined atthis stage from (5.13)

aFm =N−1∑i=1

A↓1,i

aηi + (aφm + B↑m + B↓

1)aηm + (C↑m + C↓

1 )aD + D↑m

aTm′, (7.8)

aF0 =

{D↓

maTm

′ + D↑0oTm

′ + λ(oTm′ − aTm

′) over ocean,− F ′

s over land.(7.9)

In the ocean,oF0 = D↓

maTm

′ + D↑0oTm

′ + λ(oTm′ − aTm

′) + F ′s. (7.10)

The next stage is to determine the evolution of the oceanic mixed layer using (5.10),

oTmt′ = −(oum

oTm′)x − (ovm

oTm′)y + oK2∇2

HoTm

′−

oK4∇4H

oTm′ +

owek(oT1 + oTm′)

2oHm−

oF0oρoCp

oHm(7.11)

where(oum, ovm) =

1f0

(−op1y,op1x) +

1f0

oHm(oτy,−oτx).

(see Appendix F for a possible modification to this equation for partially coupled simulations).Note here that oceanic layer temperatures are defined relative to oTm so that terms includingthe mean temperature disappear. The entrainment at the interface between layers 1 and 2 iswritten as,

oe1 = −∆omT

2∆o1T

owek (7.12)

After timestepping (7.11), if oTm < oT1, convection will occur. This requires a correction to theinterfacial entrainment which is handled by adding

δoe1 =−oHm(oT1 − oTm)

2∆ot∆o1T

(7.13)

17

Page 18: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

to the existing entrainment oe1. We then correct mixed layer temperature by setting oTm = oT1,and add a constant offset to oe1 to ensure zero net heat flux in the ocean.

Next we are in a position to step the QG equations in all parts of the domain except for theboundaries using (5.2)

qt =1f0

J(q,p) +A2

f0∇4

Hp− A4

f0∇6

Hp + Be, (7.14)

Note that the vorticity evolution equation does not apply on boundary points, and that theboundary conditions we use are formulated in terms of pressure. Pressure is determined fromthe updated vorticity by inverting (5.3),

f0q− f0β(y − y0) = ∇2Hp− f2

0 Ap + f0D̃. (7.15)

This is done by a modal decomposition, using the eigenmodes of the A matrix defined by (5.4).The techniques and routines used for the modal decomposition are described in §8.3. Thedecomposition allows direct solution for modal pressure from modal vorticity using a Helmholtzsolver (see §8.4 for details). It is at this time that the ocean mass constraints are included(see Appendix B.2). Layer pressures are recovered from modal pressures. Boundary values ofvorticity are recovered from the pressure field using mixed boundary conditions (see AppendixC).

We are then ready to timestep the atmosphere internal points. As in the ocean case we beginby calculating (7.6) on the temperature grid, and from (5.12) and (5.13) we get

ahmt = −(aumahm)x − (avm

ahm)y + Kη∇2H

ahm −aφm

aηm

aρaCp∆amT

, (7.16)

where an extra diffusive term has been added for numerical stability, and mixed layer thicknessis constrained not to fall below a specified minimum value. The temperature evolution is givenby

aTmt′ = −(aum

aTm′)x − (avm

aTm′)y + aK2∇2

HaTm

′−

aK4∇4H

aTm′ −

awekaTm

aHm+−aFm + aF0

aρaCpahm

. (7.17)

Entrainment at the top of layer 1 in the atmosphere comprises the entire radiation scheme in asingle equation:

ae1 =1

aρaCp∆a1T

[N−1∑i=1

(A↓

1,i −A↑N,i

)aηi +

(B↑

m + B↓1 −B↑

N

)aηm+

(C↑

m + C↓1 − C↑

N

)aD +

(D↑

m −D↑N

)aTm

′]. (7.18)

Convection will occur if, after timestepping, aTm′ > aT1, in which case we adjust the entrainment

at the top of layer 1 by adding

δae1 =ahm(aT1 − aTm)

2∆at∆a1T

(7.19)

and then set the temperature to be aTm′ = aT1.

Finally we step the atmosphere QG equations (7.14). As before, the pressures are found bywriting the vorticity in modal form (see §8.3), using a Helmholtz solver, and then applying themomentum conditions described in Appendix B.1. Layer pressures are recovered from modalpressures, and boundary values of vorticity found from the pressure field.

18

Page 19: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

8 Numerical formulation

Having derived the continuous equations which are the basis of the model, we must now formulatefinite approximations to them in order to produce a computable solution. This section gives abrief account of the numerical methods used.

8.1 Discretisation in space and time

The domains are constructed so that there is an integral number ndxr of ocean gridlengths withineach atmosphere gridlength, and the ocean occupies an integral number (nxaooc, nyaooc) ofatmosphere gridlengths in each direction (see figure 2). The other major difference between theatmosphere and ocean is that atmospheric velocities are much higher, and therefore, despite thelarger grid cells, the atmosphere requires a smaller timestep. There are nstr atmosphere timesteps within each ocean timestep. To conserve heat and momentum, forcing terms cannot bere-computed every atmosphere timestep: instead these terms are computed before each oceantimestep, and are held constant during the nstr atmosphere timesteps.

Both atmosphere and ocean variables are discretised horizontally on an Arakawa C-grid(Arakawa and Lamb, 1977) as shown in figure 2. The grid is Cartesian, with the same resolutionin both x- and y-directions. Pressure and vorticity are tabulated at the same points (referredto consistently as p points), and temperature and mixed layer thickness are tabulated at thetemperature (T) points. These are the prognostic fields; other quantities can be diagnosed fromthem at the appropriate gridpoints as required. When it is necessary to interpolate quantitiesfrom the coarse atmospheric grid to the finer oceanic grid, we use a simple and efficient bilinearinterpolation scheme which is conservative between p grids.

The advective terms in mixed layer evolution equations such as (7.11), (7.16) and (7.17)are formulated in the usual manner for C-grid models, in which the advective velocities arecomputed at the centres of the faces of the cell containing a T gridpoint. This ensures that theadvection scheme is conservative, and that unlike some more sophisticated advection schemesthere is no implicit diffusion; it is all explicit. The quantity being advected is approximated bythe average of its values on either side of the face.

The exception to this is the advection of vorticity in equation (7.14). Here we use a higherorder (9-point) Arakawa Jacobian (Arakawa and Lamb, 1981) with superior conservation prop-erties: it conserves both energy and enstrophy.

The timestepping of the evolution equations uses a leapfrog scheme, which is second orderin time. Occasional averaging of the two time levels carried by the program is performed, tosuppress the computational mode which is inevitable with this scheme.

8.2 Effect of the Laplacian operator on a Fourier component

This section considers the effect of the ∂2

∂x2 operator on a single Fourier component; the resultswill prove useful in a couple of later sections. Consider a one-dimensional Fourier expansion(the extension to two dimensions is straightforward):

p(x) =∑

k

p̃ke2πikx. (8.1)

In the continuous case, applying the second derivative operator gives

d2p

dx2=∑

k

−p̃k(2πk)2e2πikx. (8.2)

In the finite difference case, d2pdx2 at x is given by the centred-difference approximation

d2p

dx2=

p(x + dx)− 2p(x) + p(x− dx)dx2

. (8.3)

19

Page 20: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

LAND OCEAN

Figure 2: Cutaway section showing the grid used in the implementation of the model near the land-oceanboundary with 8 ocean gridlengths to every atmosphere gridlength. The atmosphere grid is the largergrid, with • showing the pressure grid points and × showing the temperature gridpoints. The oceanpressure gridpoints are at the vertices of the grid shown, and ocean temperature points indicated by ·.

where dx is the gridspacing. Substituting (8.1) and simplifying somewhat gives

d2p

dx2=∑

k

p̃k

(e2πikdx + e−2πikdx − 2

dx2

)e2πikx, (8.4)

i.e.d2p

dx2=∑

k

p̃k

(2cos(2πkdx)− 2

dx2

)e2πikx, (8.5)

which, using some familiar trigonometric identities, reduces to:

d2p

dx2=∑

k

−p̃k

(2sin(πkdx)

dx

)2

e2πikx. (8.6)

So the finite difference result (8.6) is similar to the continuous result (8.2), but with the replace-ment

πk ⇒ sin(πkdx)dx

, (8.7)

in the Fourier coefficient. For small k (well-resolved wavelengths) these are equivalent.

20

Page 21: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

8.3 Numerical decomposition into modes

For both ocean and atmosphere the relationship between pressure and vorticity can be writtenin vector form as in (5.3), where A is the tridiagonal matrix given by (5.4). To decompose thelayer quantities into modes we suppose that A has left eigenvectors Lm, right eigenvectors Rm

and eigenvalues λm , where m is the eigenmode number, ranging from 1 to N . Then

ARm = λmRm

LTmA = λmLT

m

for each mode m. It can be shown that Lm and Rm are orthogonal, i.e LTm · Rn = 0 unless

m = n. Note that since A is nonsymmetric Lm 6= Rm in general.From the particular structure of A, it follows that the eigenvalues will all be real, and for

the sign of A chosen in (5.3) λm ≥ 0. The dimensions of λm are 1/c2m, where cm is a phasespeed

in m s−1. One of the eigenmodes will have λm = 0; we call this the barotropic mode. We orderthe remaining N − 1 modes with λm increasing (cm decreasing); these are the baroclinic modes.

The eigenvalues and eigenvectors of A can be computed using standard linear algebra meth-ods (see e.g. Golub and van Loan, 1983), and this is done in subroutine eigmod. We choose touse routines from the package LAPACK for portability. We can then use the eigenmodes of Ato separate the set of equations (7.15) into an easily soluble set, as follows:

Expand the pressure vector p in terms of the right eigenvectors Rn

p =∑

n

p̂nRn. (8.8)

Premultiply (8.8) by LTm, then

LTm · p =

∑n

p̂nLTmRn = p̂mLT

m ·Rm, (8.9)

by orthogonality, so thatp̂m = Cl2mp, (8.10)

where Cl2m(m, k) = LTm(k)

LTm·Rm

is an N ×N matrix used to convert from layer to modal amplitudes.We also require a matrix Cm2l for converting from modal to layer amplitudes. Clearly from

(8.8) Cm2l(k,m) = Rm(k). It follows that the product of the matrices Cm2l and Cl2m is theidentity matrix, as required for consistency. This can be confirmed (to machine precision) bysubroutine eigmod. Note that for reasons of runtime efficiency the program carries the transposesof Cl2m and Cm2l.

Substitute the expansion (8.8) into the vector equation (7.15):

f0(q− D̃− β(y − y0)) = ∇2H

∑m

p̂mRm − f20

∑m

p̂mλmRm, (8.11)

where the quantity f20 λm has dimensions 1/rm

2, where rm is a deformation radius (which isinfinite for the barotropic mode). So we have

f0(q− D̃− β(y − y0)) =∑m

(∇2

H − 1rm

2

)p̂mRm. (8.12)

Premultiplying by LTk , summing over the layers (k), and dividing by the dot product, we obtain

the equation for the amplitude of each mode:(∇2

H − 1rm

2

)p̂m = f0

∑k

Cl2m(m, k)(qk − D̃k − β(y − y0)). (8.13)

So we need to solve a two-dimensional modified Helmholtz equation with a known RHS foreach modal amplitude p̂m, using the method given in section 8.4, and convert these to layeramplitudes using (8.8).

21

Page 22: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

8.4 Solution of the modified Helmholtz equation

Most of the equations which constitute the model define one variable explicitly in terms ofother variables or their derivatives. The exceptions are the modified Helmholtz equations (8.13)which define pressures implicitly in terms of vorticities, subject to suitable boundary conditions.We require a computationally efficient solution method for such equations. Write the generalinhomogeneous Helmholtz equation as(

∇2H − 1

rm2

)p = R (8.14)

where the right hand side R(x, y) is a known function and rm is the Rossby radius for a givenmode. The barotropic mode is a special case for which rm is infinite, and (8.14) reduces toPoisson’s equation.

We will consider the solution to (8.14) in a channel periodic in x (the atmospheric and cyclicocean cases). The method carries over to the finite box ocean with simple modifications to bediscussed later. Assume the pressure p(x, y) and the right hand side R(x, y) are tabulated on aregular grid at positions xi = (i− 1)dx (M points), yj = ys + (j − 1)dy (N points), so that R isan M ×N matrix Rij . Expand p and R as one-dimensional Fourier series in the x-direction ateach of the (N − 2) values yj within the domain (i.e. not including the zonal boundaries j = 1and j = N):

pij =∑

k

p̃k,je2πikxi . (8.15)

We can use a Fast Fourier Transform (FFT) routine to efficiently compute the array of coefficientsR̃k,j from the known Rij . The particular ordering of the values of k in the transform vectordepends on the FFT package used, so we ignore such details in this general account.

Then from (8.6)∂2pij

∂x2 =∑

k

−p̃k,j

(2sin(πkdx)

dx

)2

e2πikxi . (8.16)

∂2pij

∂y2 at y = yj is given by the usual centred difference approximation (8.3)

∂2pij

∂y2 =∑

k

(p̃k,j+1 − 2p̃k,j + p̃k,j−1

dy2

)e2πikxi (8.17)

so at each internal point i, j we have an equation of the form

∑k

−p̃k,j

((2sin(πkdx)

dx

)2

+1

rm2

)e2πikxi +

∑k

(p̃k,j+1 − 2p̃k,j + p̃k,j−1

dy2

)e2πikxi

=∑

k

R̃k,je2πikxi . (8.18)

But for this to be true for at all the points x = xi, it must be true for each Fourier componente2πikx separately, i.e. for all k and j, we must have

−p̃k,j

((2sin(πkdx)

dx

)2

+1

rm2

)+

(p̃k,j+1 − 2p̃k,j + p̃k,j−1)dy2

= R̃k,j . (8.19)

For each value of the M values of k, we can thus write the set of (N − 2) equations (8.19) forthe range of internal j values as a single tridiagonal matrix equation of size (N − 2)× (N − 2)

22

Page 23: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

relating the unknown vector p̃k,j and the known vector R̃k,j :

· ·· · ·· · ·· · ·

a bk aa bk a

a bk a

· · ·· · ·· · ·· ·

p̃k,j = R̃k,j (8.20)

where dots denote non-zero coefficients, and the a and b coefficients are known:

a =1

dy2, (8.21)

bk = −

((2sin(πkdx)

dx

)2

+1

rm2

)− 2a (8.22)

Note that to maintain strictly tridiagonal form, only two entries appear on the top and bottomrows of the matrix. This is equivalent to asserting that p̃ vanishes on the zonal boundaries j = 1and j = N for all k, and thus p = 0 also.

Such a tridiagonal system can be efficiently solved for the unknown vector without a fullmatrix inversion; see any good numerical linear algebra textbook, such as Press et al. (1992).For the modified Helmholtz operator, it is clear from (8.21) and (8.22) that |bk| ≥ 2|a| > 0 forall k, so the matrix is “diagonally dominant”, and no problems of zero pivots can occur. Thetridiagonal method is accurate to about machine precision, without any need for further iterativeimprovement. This method is built into the subroutines hscyat, hsbxoc and hscyoc. Havingsolved the system for p̃k,j at all M wavenumbers k, we can then use (8.15) at each latitude to getthe pressure pij at all gridpoints. Thus we have solved the inhomogeneous Helmholtz equation(8.14) in a zonally periodic channel, subject to the condition p = 0 on the zonal boundaries.

In the case of a finite length (box) ocean, where we require p to be constant around theentire boundary, we use Fourier sine transforms instead of the periodic Fourier transforms, toensure that p = 0 on the meridional boundaries too.

Note that the various Fourier transform routines use a significant fraction of the total CPUtime (16%–18% for the standard box ocean case, depending on the computer system used). Itis therefore important that the parameters determining the transform lengths (nxta, ndxr andnxaooc, all set in parameter.src) should be chosen to have numerous small prime factors, soas to maximise the efficiency of the transform routines.

We can also use this scheme to solve the homogeneous Helmholtz equation for baroclinicmodes. The homogeneous equation is:(

∇2H − 1

rm2

)p = 0. (8.23)

Write p = L + srm

2 , where L is a known solution of Laplace’s equation ∇2HL = 0 which is

non-zero on the boundaries; then s satisfies(∇2

H − 1rm

2

)s = L, (8.24)

23

Page 24: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

which is of the same form as (8.14). s satisfies the usual condition s = 0 on the solid boundariesof the domain, so p = L on these boundaries. We can add any multiple of these homogeneoussolutions to the inhomogeneous solution to obtain any required value of p on the solid boundaries.

8.5 Integration routines

Several of the radiative flux coefficients introduced in section 4.2 involve vertical integrals over theappropriate layers. A subroutine trapin is provided which computes the extended trapezoidalrule approximation to the integral of a tabulated function (Press et al., 1992). Two routines,xintt and xintp, are provided for computing area integrals. xintt computes the area integralof a quantity tabulated at T points, as a simple sum. xintp computes the area integral of aquantity tabulated at p points.

8.6 Diffusive timescales

Several of the equations contain diffusive terms of second or fourth order (recall that the ∇6H

term in (7.14) was originally introduced as fourth order terms in (2.7a,b), and is effectivelyfourth order since q ∼ ∇2

Hp). To understand the damping effect of the diffusion coefficients, itis useful to derive their associated timescales.

Consider some field p(x, y), and introduce second and fourth order diffusive terms into itsevolution equation, with coefficients A2 and A4 respectively, so that

∂p

∂t= . . . + A2∇2

Hp−A4∇4Hp. (8.25)

We will require A2, A4 > 0 to ensure decay. Expand p as a two-dimensional Fourier transform:

p(x, y) =∑

k

∑l

p̃kle2πi(kx+ly) (8.26)

then, differentiating the Fourier expansion, we find that each term will cause exponential decayof the coefficient p̃kl, with timescales τ2, τ4 given in the finite difference case (using (8.6)) by

1τ2

= A2

((2sin(πkδ)

δ

)2

+(

2sin(πlδ)δ

)2)

(8.27)

1τ4

= A4

((2sin(πkδ)

δ

)2

+(

2sin(πlδ)δ

)2)2

, (8.28)

where δ is the (equal) gridlength in either direction. Subroutine diffts evaluates these times-cales for two special cases:

1. A circular eddy whose radius is the baroclinic Rossby radius rm, so k = l = 12rm

,

1τ2

= 2A2

(2sin(πδ/2rm)

δ

)2

(8.29)

1τ4

= 4A4

(2sin(πδ/2rm)

δ

)4

(8.30)

2. A one-dimensional wave at the highest wavenumber representable on the grid (two grid-point noise), k = 1

2δ , l = 01τ2

= A2

(2δ

)2

(8.31)

1τ4

= A4

(2δ

)4

(8.32)

24

Page 25: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

9 Users’ guide

Having briefly described the numerical formulation of the model, we now discuss the practicalitiesof using the code. The code is available in gzipped tar format, which expands to a single directory.

9.1 Components of the code

The code for Q-GCM consists of a number of Fortran77 source files (*.f/*.F), various commonblock files (*.cmn), a file called parameter.src and a generic Makefile. The code uses threepublic domain software packages:

FFTPACK This is a free, portable library of Fortran routines for computing 1-D fast Fouriertransforms, originally written by Paul N. Swarztrauber of NCAR, Boulder. There is anFFTPACK webpage at NCAR:http://www.scd.ucar.edu/softlib/FFTPACK.htmlbut the package is also distributed as part of the Netlib software repository:http://www.netlib.org/in Tennessee, USA, and its various mirror sites, which include:http://www.mirror.ac.uk/sites/netlib.bell-labs.com/netlib/ (UK)http://netlib.uow.edu.au/ (Australia).

We use the double precision version of the library, which can usually be found in thesubdirectory bihar. Alternatively we also distribute our own versions of the necessaryroutines, modified to remove some programming constructs such as “arithmetic IFs” whichare deprecated in Fortran90, and which cause compiler warnings (directory newbihar).The FFTPACK routines are included via the file fftpack.f which you will have to editto point to the location of these files on your system.

LAPACK This is a free, public domain linear algebra package. It is included in the scientificsoftware libraries provided with most commercial Fortran compilers, and we recommendyou access it in this way. Otherwise the source code can be downloaded from Netlib andincluded in the same manner as FFTPACK. The file lasubs.f lists the LAPACK andunderlying BLAS routines which are required.

netCDF available fromhttp://www.unidata.ucar.edu/packages/netcdf/NetCDF (network Common Data Format) is a machine-independent, self-documentingformat for representing scientific data, and a library of routines for reading and writing datain this format. You will need to have installed the netCDF libraries on your system, andto edit the Makefile to indicate where they are. A version of the include file netcdf.inc(edited to eliminate some compiler warnings) is included in the Q-GCM distribution. Ourdevelopment and testing has used version 3.5.0 of netCDF.

There are several easy ways to access the data in netCDF format. One way to view thedata is with the browser package ncview:http://www.gfdl.gov/~jps/GFDL_VG_2DPackages.html.We also use the netCDF toolbox for Matlab :http://woodshole.er.usgs.gov/staffpages/cdenham/public_html.

It is our policy to use public domain packages where possible, so that anyone may use Q-GCMwithout having to pay for package licences.

9.2 Compiling the code

The Makefile will take care of the compiling and linking, but it contains preprocessor optionsand a few flags specific to your system which must be set before it will work:

25

Page 26: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

atmos only, ocean only Flags which, if set, restrict the model to run in atmosphere/oceanonly mode. At most one of these flags should be set.

get areav Flag to determine whether area averages should be computed. The relevant routinesare in areasubs.F; the areas are defined in areas.limits.

get covar Flag to determine whether the covariance matrices should be computed. If set, thisoption turns on routines which accumulate the corrected sums of squares and products,which enable the covariance matrix and hence time-independent EOFS and principal com-ponents to be found in post-processing. This option significantly increases the memoryrequirement of the program.

use netcdf Flag to make use of the netCDF output facility (see below). Turn this flag off torun the model without netCDF output.

small local Flag to activate Fortran SAVE statements in those subroutines with significantinternal storage. Needed on systems which have a small kernel limit on the amount oftemporary (stack) storage which can be allocated.

Ideally this flag should not need to be set: try using it if your system (linux only?) givesa Segmentation Fault error message which is not fixed by setting environment stacksize limits as described in section 9.3.8. This flag also turns on diagnostics (in subroutinememreq) indicating the approximate amount of stack storage allocated by those subroutineswith significant local arrays.

cyclic ocean Flag to switch between the box ocean and channel ocean configurations.

nb hflux, sb hflux Flags to switch on northern or southern boundary heat fluxes. Whenturned on, the ocean mixed layer temperature boundary condition on the relevant bound-ary becomes constant temperature (the default is no flux), the boundary temperaturebeing the radiative equilibrium temperature at that latitude. This flag is designed to al-low advection and diffusion of tropical water into the domain, and therefore the southernboundary flag may only be used when the model is on northern hemisphere mode (f0 > 0,F ′

s > 0). Likewise the northern boundary flag may only be used when the model is insouthern hemisphere mode (f0 < 0, F ′

s < 0).

The above items control the treatment of *.F files by the Fortran preprocessor.

FC The command which invokes your Fortran compiler (e.g. f90, ifort, pgf90, xlf, . . . )

FFLAGS List of flags for your Fortran compiler (to control optimisation/debugging/profilingetc.). See your Fortran compiler’s man pages for details.

LAPACK Linker option to pick up the LAPACK library

NCDIR The top directory of your netCDF installation

NCLIB The flag showing where to find the library of your netCDF installation

IDIR Directory containing the netCDF include file netcdf.inc. This will be the currentdirectory if you are using the version of this file included in the distribution.

NCLINK Linker option to pick up netCDF library.

Compilation has been tested on several systems, and the Makefile contains some exampleoptions (commented out) from each of these systems, along with information on the operatingsystem and compiler used. Simply type make q-gcm to compile, once you have edited theMakefile to suit your system.

26

Page 27: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

The model has been run using both f77 and f90/f95 compilers. The model can run inparallel; instructions using the standard OpenMP API are included in the code. You will needto set a compiler flag to enable these directives. We do not recommend the use of an auto-paralleliser in addition to the OpenMP parallelisation in the code; this degrades the parallelperformance on some systems.

9.3 Structure of the code

The Q-GCM model consists of a main program and 66 subprograms, 8 of which remain with themain program in the file q-gcm.F, the remainder having been separated out into other *.f/*.Ffiles. Below is a list showing where to find subroutines in the *.f/*.F files:

Filename subroutines contained within number ofsubroutines

q-gcm.F inpget, zeroin*, rbalin*, prsamp*, cfltry*, resave, (8)memreq, diffts

amlsubs.F aml*, amladf* (2)areasubs.F areavg, areint* (2)atisubs.F atinvq*, hscyat* (2)conhoms.F constr*, homsol* (2)covsubs.F covini*, covatm, covocn, covout, tsampl* , psampl* , (7)

dssp*diasubs.F diagno*, del4bx*, del4ch*, genint* (4)intsubs.f xintt*, xintp* (2)nc_subs.F handle_err, ocnc_init, atnc_init, ocnc_out*, atnc_out* , (9)

monnc_init, monnc_out, resave_nc, restart_ncocisubs.F ocinvq*, hsbxoc*, hscyoc* (3)omlsubs.F oml*, omladf* (2)qgasubs.F qgastep*, atadif* (2)qgosubs.F qgostep*, ocadif* (2)radsubs.f radiat*, trapin* (2)tavsubs.F tavini*, tavatm*, tavocn*, tavout (4)topsubs.F topset, topout_nc (2)vorsubs.F qcomp*, merqcy*, ocqbdy*, atqzbd* (4)xfosubs.F xforc*, function fsprim, bilint* (3)valsubs.F valids*, scan2D, scan3D (3)eigmod.f is a single routine (1)

In addition there are linear algebra library routines from LAPACK and Fourier transformlibrary routines from FFTPACK (see fftpack.f) not counted above. Two additional codefragments in_param.f and out_param.f are also added to the main program by INCLUDE state-ments. All real variables are explicitly of Fortran type “double precision” (64 bit), giving aprecision of 15 significant figures. Routines marked here with a * are those which have beenexplicitly parallelised using OpenMP.

9.3.1 Input files

Variables governing the model run are contained in three input files. These are the files to editto change the model configuration from the standard cases.

parameter.src This file contains dimensioning information for the model arrays. It definesthe location of the oceanic domain within the atmospheric, and the relative resolutions ofthe two grids. It also contains the rotation parameters which define the latitude of the

27

Page 28: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

domains, and an explanation of all the parameters defined therein. This file is picked upby most of the *.f/*.F files via INCLUDE statements. Changes to this file therefore requirerecompilation.

input.params A file defining the values of all other model parameters, both physical paramet-ers, and control parameters for length of run, diagnostic intervals, etc. The file includesbrief comments explaining the meaning of each parameter, including its units. Changesto this file do not require recompilation. The values contained in this file are read viaformatted READ statements in the included file in_param.f.

outdata.dat A separate text file with a single line containing the name of the directory towhich output files are written. This file is read from the main program file q-gcm.F usinga formatted read statement (and so changes do not require recompilation).

areas.limits A file defining the boundaries over which area averages of temperature timeseriesare recorded. Data is stored in areas.nc.

All these parameters (and many derived quantities) are written to standard output by the mainprogram at the start of a run.

9.3.2 Program structure

A general idea of the structure of the code can be seen in the flow chart in figure 3. This showsthe flow of control through the most important subroutines, and which equations they solve.Note that each *.f or *.F file may contain more than one subroutine (see the earlier list), butthey are grouped logically, and well commented to describe their function.

9.3.3 Output files

Output files are stored in the directory specified in the variable outdir read from outdata.dat.The filenames are hardwired into the code, and therefore can only be changed by altering thebody of the code itself. Many of the files are in netCDF (*.nc) format, so that a description ofvariable names and units is included in the data file. The files are listed as follows:

input parameters.m A file which includes all the parameters as a Matlab script. Simply runthis script in Matlab, and variable names and values will be initialised.

restart.nc A netCDF file written periodically which includes the model state variables. Thiscan be useful for restarting the run if the model crashes part-way through.

lastday.nc A netCDF file written at the end of the model run which includes the model statevariables and can be used for continuing the run.

monit.nc A netCDF format file which includes timeseries of some important quantities.

atast.nc, atpa.nc Two netCDF data files which describe the atmospheric state. The variableswritten to the files are controlled by the outflag array in input.params.

ocsst.nc, ocpo.nc Two netCDF data files which describe the oceanic state. The variableswritten to the files are controlled by the outflag array in input.params.

avges.nc A netCDF data file which includes data averaged over the entire run.

areas.nc A netCDF data file which includes timeseries data from selected regions.

covar.nc A netCDF data file which includes the data needed to calculate the covariance matrixfor particular fields.

topog.nc A netCDF data file which includes the topography used for the run.

28

Page 29: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

Enter Q-GCM

Read input frominput.params

Find derived params, solve for eigenmodes and initialise everything

On ocean step ?

Call xforc (contained in xfosubs.F)Calculates forcing terms from (7.1)-(7.10)

Call oml (omlsubs.F)Integrates (7.11)Calculates (7.12) and (7.13)

Call qgostep (qgosubs.F)Integrates (7.14)

Call ocinvq (ocisubs.F)

Call ocqbdy (vorsubs.F)Finds boundary vorticityfrom pressure (7.15) subject to pressure BCs

Call aml (amlsubs.F)Integrates (7.16) and (7.17)Calculates (7.18) and (7.19) Call qgastep (qgasubs.F)

Integrates (7.14)

Call atinvq (atisubs.F)Solves (7.15) for p, subject to constraints

Bookkeeping tasks

Write output files

Exit Q-GCM

Timestepping loop:

At end of loop ?

YES

NO

NO

YES

Solves (7.15) for p, subject to constraints

Call atqzbd (vorsubs.F)Finds boundary vorticityfrom pressure (7.15) subject to pressure BCs

Figure 3: Flow chart showing the major subroutines of the code.

29

Page 30: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

9.3.4 Location of variables

Where possible variables are held in common blocks, rather than being passed as arguments tosubroutines. Each common block is defined in a separate *.cmn file, which contains commentsdescribing the meaning of each variable, and its units. Each of the 18 common blocks containsa set of related variables thus:atconst.cmn Time independent atmospheric parametersathomog.cmn Homogeneous atmospheric solutions and their coefficientsatmfft.cmn Atmospheric Fourier transform coefficientsatnc.cmn Identifiers for netCDF dumps of atmospheric variablesatstate.cmn Time varying atmospheric state

(pressure, vorticity, entrainment and Ekman velocity)covarat.cmn Atmospheric variables needed for the covariance routines in covsubs.Fcovaroc.cmn Oceanic variables needed for the covariance routines in covsubs.Fintrfac.cmn All mixed layer parameters and variables, for

both atmosphere and ocean, including dynamic stressesmonitor.cmn Diagnostic quantities for monitoring modelmonnc.cmn Identifiers for netCDF dumps of diagnostic variablesocconst.cmn Time independent oceanic parametersochomog.cmn Homogeneous oceanic solutions and their coefficientsocnc.cmn Identifiers for netCDF dumps of oceanic variablesocnfft.cmn Oceanic Fourier transform coefficientsocstate.cmn Time varying oceanic state

(pressure, vorticity, entrainment and Ekman velocity)radiate.cmn Input radiative parameters, and the derived coefficients needed for the

radiation schemetimavat.cmn Used for averaging atmospheric fields over the course of a runtimavoc.cmn Used for averaging oceanic fields over the course of a run

These files are included at the start of those subroutines where they are required. They are allincluded in the main program, to ensure that the values of their contents remain defined at alltimes. Variables declared within subroutines are purely local, so “stack” storage can be used tosave memory.

9.3.5 Diagnostics

Where possible, instantaneous diagnostic quantities are computed by subroutine diagno, whosecalling frequency is determined by the variable dgnday, set in input.params. One exception tothis is that some quantities which would require inconvenient duplication of code are computedby the timestepping routines. Another exception is that convection-related quantities need to becomputed in the timestepping subroutines, before convective adjustment is finally applied. Thesediagnostic quantities are all stored in the common block monitor.cmn, and output in netCDFformat by subroutine monnc_out. Time averaged quantities are accumulated by subroutinestavatm and tavocn in the common blocks timavat.cmn and timavoc.cmn respectively, andfinally computed and output by subroutine tavout.

9.3.6 Test programs

The code distribution includes three test programs. They were originally written to independ-ently test particular routines, but can also be used to test the effects of changing certain inputparameters, without needing to run the full Q-GCM model.

eigtest.f Tests subroutine eigmod, and thus the dependence of phase speeds, Rossby radii,

30

Page 31: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

damping timescales etc. on layer thicknesses, reduced gravities, diffusivities etc., as spe-cified via input.params.

radtest.f Tests radsubs.f, and thus the dependence of the mean state radiative balance and thelinearised radiation coefficients on the optical properties and radiative forcing, as specifiedvia input.params.

toptest.F Tests topsubs.F, and thus enables the user to experiment with defining suitable to-pographies for the ocean and atmosphere. Creates a topog.nc file in the current directory.

These programs are compiled using the Makefile in the usual way, except that they don’t usethe optimisation and possible parallelisation options used for the full model.

9.3.7 Standard cases

The input files are supplied set to run some standard spin-up cases.

• A finite box ocean of 384 × 480 gridcells and resolution 10 km, and an atmosphere of128× 64 gridcells and resolution 120 km. This case requires 110 MB of static memory, or340 MB if the covariance is computed. This is the case used in Hogg et al. (2006). It is thedefault case provided in input.params, parameter.src and areas.limits (with backupcopies provided in input.params.box, parameter.src.box and areas.limits.box).

• A channel ocean with 1536 × 200 gridcells and resolution 15 km, and an atmosphere of192 × 60 gridcells and resolution 120 km. This case requires 185 MB of static memory,or 425 MB if the covariance is computed. The parameters for this case are provided ininput.params.cyclic, parameter.src.cyclic, and areas.limits.cyclic. An appro-priate topography file this case is provided in topog.cyclic.nc

Both cases use 3 QG layers in both atmosphere and ocean. Sample output files from 30 dayruns (q-gcm.out.*) are included in the distribution, and provide a useful cross check that thecode has compiled and run successfully.

9.3.8 Possible problems

• The program uses significant ”stack” memory which may exceed the default limit on yoursystem causing a Segmentation fault error. You will need to reset the limit by doinge.g.

limit stacksize 96m, or even

limit stacksize unlimited (C shell)

ulimit -s 98304 (bash or ksh; units are kbytes)

• When running the program in parallel, you may need to increase the limit on stack al-location by each separate thread. The name of the environment variable depends onthe compiler being used; the syntax for setting it depends on the shell in the usual way.Examples are:

setenv MP_STACK_SIZE 40000000 (Csh, Compaq)

setenv XLSMPOPTS "stack=40000000" (Csh, IBM)

setenv MP_SLAVE_STACKSIZE 40000000 (Csh, SGI)

setenv STACKSIZE 40000000 (Csh, Sun)

setenv MPSTKZ 40000000 (linux/Csh, Portland Group Compiler)

setenv KMP_STACKSIZE 40000000 (linux/Csh, Intel compiler)

31

Page 32: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

Remember to set the number of threads required; syntax for this depends only on theshell:

setenv OMP_NUM_THREADS 4 (Csh)

export OMP_NUM_THREADS=4 (bash)

• Some systems (linux only?) seem to have an additional limit (typically a few Mbytes, andperhaps set by the kernel) on the allocation of stack storage, which we don’t yet know howto reset. As a workaround, we have provided the small_local preprocessor option whichcauses the main temporary arrays in subroutines to be allocated as static rather than stackstorage, by using the Fortran SAVE statement. If the environment settings described abovedo not fix any segmentation problems you encounter, try using small_local as describedin section 9.2.

• When running in parallel on systems using Itanium 2 processors, some “reduction” opera-tions, summing variables to compute integrals, incorrectly return a value of zero. This hasbeen observed using both v8.1 and v9.0 of the Intel Fortran compiler, and the problem iscurrently under investigation. This problem mainly affects diagnostic variables. The onlyknown impact on model evolution, caused by a failure to correctly apply the entrainmentconstraint (B.17), has been dealt with by a temporary fix to the code (clearly commentedas such) in subroutine oml in the file omlsubs.F, pending a complete understanding of theproblem.

9.3.9 Feedback

The model conforms strictly to Fortran standards, and so should be highly portable. It has beenchecked using the public domain Fortran77 analyser “ftnchek”, which we highly recommend. Thehome website is:http://dsm.dsm.fordham.edu/~ftnchek/.This software is also available from the Netlib software repository and its many mirror sites.

Please report any compilation or runtime problems, with details of the operating system andcompiler used, and whether running in parallel or not.

9.4 Changes Log

9.4.1 Changes from v1.3 to v1.3.1

• More thorough application of #ifndef atmos_only, #ifndef ocean_only preprocessorflags to remove unnecessary code and common blocks. Consequent changes include split-ting common blocks for covariance and time averages into atmosphere and ocean compon-ents, and that atmospheric *.f files have been changed to *.F files.

• Simplified preprocessor structure in code.

• Addition of wekpo and its boundary integrals to time averaged fields.

• Additional ocean zonal transport diagnostics.

• Modified Makefile to more cleanly remove netCDF where required.

• Extra preprocessor flag get_areav to turn area averaging on.

• Modified format statements to allow up to 9 layers.

• More checking of input netCDF topography.

• Better output from validity checking routine.

32

Page 33: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

• Additional memory diagnostics in q-gcm.F.

9.4.2 Changes from v1.2 to v1.3

• Option of channel ocean, which entails new array dimensioning (nxta/nxpa), redimen-sioning some atmospheric arrays, changes to bilint in xfosubs.F and additional codechanges as indicated by #ifdef cyclic_ocean.

• Redefinition of f0 relative to the central latitude of the domain.

• New method of computing owek, by interpolation of awek (rather than from the curl ofoτ ).

• New method of reading physical parameters (avoids recompilation).

• All routines deriving vorticity from pressure are collected in vorsubs.F.

• Computation of diffusive timescales moved into new subroutine diffts.

• More use of #ifdefs to remove unnecessary computations in particular configurations.

• Added #ifdef flags nb_hflux and sb_hflux to allow easy switching between temperatureboundary conditions and hemispheres.

9.4.3 Changes from v1.1 to v1.2

• Addition of ∇2H viscosity in the ocean.

• Addition of ∇4H diffusion in SST and AST.

• Non-dimensionalising the mixed boundary condition coefficient.

• Generalisation of atmosphere from 2 layers to N layers.

• Simplification of atmospheric radiation scheme.

• Addition of a minimum mixed layer thickness to the atmospheric mixed layer scheme.

• Added vorticity and Ekman pumping to time-average diagnostics. Added mean outgoinglongwave radiation, mean pressure and potential vorticity to monitoring diagnostics.

• Addition of topography to both atmosphere and ocean components of the model.

• More explicit parallelisation for improved performance.

• More use of #ifdefs to reduce wasted data output in uncoupled simulations.

• Alterations to the structure which move more subroutines into separate *.f/*.F files, andshorten the main q-gcm.F file.

• Addition of #ifdef small_local flag to fix problems which arise on machines with asmall predefined stacklimit.

Acknowledgements

Neil Stringfellow of Manchester Computing assisted with optimisation and parallelisation of thecode. Peter Challenor assisted us to implement the statistics packages which are built into thecode.

33

Page 34: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

A Writing radiation as a perturbation to mean state

A.1 Functional form of radiation parameters

We follow a simplified, linearised model of vertical radiative heat transfer in the atmosphere(see Peixoto and Oort, 1992, for details on the basics of radiative balance). At any point inthe atmosphere transfer is due to two sources: (i) blackbody radiative emission from radiativelyactive elements within the current layer, which is of the form

Flux =∫

B(z)τz(z, Z) dz

and (ii) radiation from other layers which is partially absorbed within the current layer

Flux = Finτ(Zk−1, Zk).

Here we have used a new notation Zk for the unperturbed interface height coordinate (as themodel is framed in terms of layer thicknesses) and introduced the transmissivity τ which iswritten as

τ(z, Z) = e−Z−z

z0 , (A.1)

where τ(z, Z) is the fraction of radiation from z reaching Z, and z0 is the (constant) optical depthof the layer (or τ(Z, z) is the fraction reaching Z from z for downgoing radiation). Derivativesof the transmissivities are then

τz(z, Z) =τ(z, Z)

z0. (A.2)

In a comprehensive model, the optical depth z0 will vary with height. We assume for our modelthat we know the optical depth in each QG layer (zk). Note also that we use an optical depthof zero at the bottom of the mixed layer, and zm near the top of the mixed layer.

We have also used the blackbody radiation emitted from each layer which is written accordingto the Stefan-Boltzmann law

Bm(z) =σ

2(aTm + aTm

′ − γz)4, (A.3)

for the mixed layer, andBk(z) =

σ

2(aTk − γz)4, (A.4)

for other layers. The terms in the temperature function represent constant potential temperat-ure, the variation of in situ temperature with height being determined by the adiabatic lapserate γ.

A.2 Rules for linearising

We want to linearise the radiation equations about a mean state. To do this we expand abouta mean and retain the first order terms in aTm

′, aηm and aηk. Note that the topography aDis included as a first order perturbation to the radiation, as it is to the dynamics. It thereforedoes not enter the mean state calculation. For the mixed layer radiation function

σ

2(aTm − γz + aTm

′)4 ≈ σ

2(aTm − γz)4 + 2σ(aTm − γz)3 aTm

′. (A.5)

Transmissivities are expanded by writing, for example,

τ(ahm + aD, ah1) = e−

aZ1+aη1−aHm−aD−aηm

z1

= e−

aZ1−aHm

z1 e−

aη1z1 e

aηm+aDz1

≈ τ1

(1−

aη1

z1

)(1 +

aηm + aD

z1

)≈ τ1

(1−

aη1

z1+

aηm + aD

z1

)(A.6)

34

Page 35: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

where τ1 ≡ e−

aZ1−aHm

z1 is the unperturbed value. For other layers, τk ≡ e−

aHkzk .

Any integrals are also linearised as, for example,∫ aZ1+aη1

ahm+aDf(z)dz ≈

∫ aZ1

aHm

f(z)dz − f(aHm)(aηm + aD) + f(aZ1)aη1. (A.7)

When calculating the radiation at any point, we write the full radiation balance, first expandthe integration and then expand remaining terms, eliminating quadratic and higher order terms.This is explicitly done for each layer in the following section.

A.3 Calculations

Oceanic Mixed Layer absorbs all downgoing longwave radiation (as well as incoming short-wave radiation) which passes through the atmospheric mixed layer. Emits radiation ac-cording to its blackbody temperature,

F ↑0 = B0(0) = σ

(oTm + oTm

′)4 . (A.8)

We linearise this by writingF ↑

0 ≈ F ↑0 + D↑

0oTm

′ (A.9)

whereF ↑

0 = σoTm4, (A.10)

D↑0 = 4σoTm

3. (A.11)

Atmospheric Mixed Layer To calculate upward radiation leaving the atmospheric mixedlayer, we note that optical depth at the base of the mixed layer is assumed to be zero:thus outgoing radiation here must be internally generated:

F ↑m =

∫ ahm+aD

aDBm(z)τz(z, ahm + aD) dz. (A.12)

We first linearise the integral, giving

F ↑m ≈

∫ aHm

0Bm(z)τz(z, ahm) dz + Bm(aHm)τz(aHm, ahm + aD)(aηm + aD)−

Bm(0)τz(0, ahm + aD)aD, (A.13)

and then evaluate each of the terms (noting that the last term disappears because themixed layer is opaque at the bottom),

F ↑m ≈

∫ aHm

0

2(aTm − γz)4 + 2σ

(aTm − γz

)3 aTm′) e−

aHm−zzm

zm

(1−

aηm + aD

zm

)dz

2(aTm − γaHm

)4 aηm + aD

zm. (A.14)

By omitting the remaining quadratic terms we obtain an expression for upwards radiation,

F ↑m ≈ σI↑

m

2zm+(

zm

∫ aHm

0

(aTm − γz

)3e−

aHm−zzm dz

)aTm

+

2zm(aTm − γaHm)4 − σI↑

m

2zm2

)(aηm + aD). (A.15)

35

Page 36: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

Here we have defined

I↑m =

∫ aHm

0

(aTm − γz

)4e−

aHm−zzm dz,

and we use similar integrals when calculating radiation in other layers. The completeradiation formula is written in terms of the coefficients

F ↑m =

σI↑m

2zm, (A.16)

B↑m =

2(aTm − γaHm)4 − F ↑

m

) 1zm

, (A.17)

C↑m = B↑

m, (A.18)

D↑m =

zm

∫ aHm

0

(aTm − γz

)3e−

aHm−zzm dz, (A.19)

givingF ↑

m ≈ F ↑m + B↑

maηm + C↑

maD + D↑

maTm

′. (A.20)

These constant coefficients are evaluated at the initialisation of the model, and stored forlater use.

Downgoing radiation can be calculated simply using the assumption that optical depthat the bottom of the mixed layer is z0 = 0, so that radiation only depends upon localtemperature,

F ↓m ≈ −σ

2aTm

4 − 2σaTm3aTm

= F ↓m + D↓

maTm

′,(A.21)

whereF ↓

m = −σ

2aTm

4, (A.22)

D↓m = −2σaTm

3. (A.23)

Atmospheric QG layers The QG layers include both partial absorption and emission terms,

F ↑k = F ↑

k−1τ(aZk−1 + aηk−1,aZk + aηk) +

∫ aZk+aηk

aZk−1+aηk−1

Bk(z)τz(z, aZk + aηk) dz. (A.24)

Note that when k = 1, we use aZk−1 = aHm and aηk−1 = aηm + aD. The full equation isthus

F ↑k =

(F ↑

k−1 + F ↑k−1

′)τk

(1 +

aηk−1

zk−

aηk

zk

)

+∫ aZk

aZk−1

σ

2(aTk − γz)4

e−

aZk−z

zk

zk

(1−

aηk

zk

)dz

− σ

2(aTk − γaZk−1)4

τk

zk

aηk−1 +σ

2(aTk − γaZk)4

aηk

zk. (A.25)

Again we organise this equation into mean and perturbation quantities,

F ↑k ≈ F ↑

k−1τk +σI↑

k

2zk+ F ↑

k−1

′τk +

(F ↑

k−1 −σ

2(aTk − γaZk−1)4

) τk

zk

aηk−1

+

(−F ↑

k−1τk −σI↑

k

2zk+

σ

2(aTk − γaZk)4

)aηk

zk, (A.26)

36

Page 37: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

where

I↑k =

∫ aZk

aZk−1

(aTk − γz

)4e−

aZk−z

zk dz.

Note that this equation requires contributions from layers below so that the individualterms need to be evaluated from the bottom upwards. The general form of the equation is

F ↑k ≈ F ↑

k +min(k,N−1)∑

i=1

A↑k,i

aηi + B↑kaηm + C↑

kaD + D↑

kaTm

′ for k = 1, N, (A.27)

where

F ↑k = F ↑

k−1τk +σI↑

k

2zk, (A.28)

D↑1 = D↑

mτ1, (A.29)

D↑k = D↑

k−1τk for k = 2, N. (A.30)

Calculation of the other three terms is more complicated:

B↑1 =

(B↑

m +F ↑

m

z1− σ

2z1(aT1 − γaHm)4

)τ1, (A.31)

B↑k = B↑

k−1τk for k = 2, N. (A.32)

C↑1 =

(C↑

m +F ↑

m

z1− σ

2z1(aT1 − γaHm)4

)τ1, (A.33)

C↑k = C↑

k−1τk for k = 2, N. (A.34)

A↑1,1 =

(−F ↑

mτ1 −σI↑

1

2z1+

σ

2(aT1 − γaZ1)4

)1z1

, (A.35)

A↑k,k =

(−F ↑

k−1τk −σI↑

k

2zk+

σ

2(aTk − γaZk)4

)1zk

for k = 2, N − 1, (A.36)

A↑k,k−1 =

F ↑k−1

zk+ A↑

k−1,k−1 −σ

2zk(aTk − γaZk−1)4

τk for k = 2, N. (A.37)

A↑k,i = A↑

k−1,iτk for i = 1, k − 2 and k = 3, N. (A.38)

For downgoing radiation the full equation is

F ↓k = F ↓

k+1τ(aZk−1+aηk−1,aZk +aηk)+

∫ aZk+aηk

aZk−1+aηk−1

Bk(z)τz(aZk−1+aηk−1, z) dz (A.39)

which reduces to

F ↓k ≈

(F ↓

k+1 + F ↓k+1

′)τk

(1 +

aηk−1

zk−

aηk

zk

)

−∫ aZk

aZk−1

σ

2(aTk − γz)4

e−

z−aZk−1zk

zk

(1 +

aηk−1

zk

)dz

2(aTk − γaZk−1)4

aηk−1

zk− σ

2(aTk − γaZk)4

τk

zk

aηk, (A.40)

37

Page 38: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

giving

F ↓k ≈ F ↓

k+1τk −σI↓

k

2zk+ F ↓

k+1

′τk +

(F ↓

k+1τk −σI↓

k

2zk+

σ

2(aTk − γaZk−1)4

)aηk−1

zk

+(−F ↓

k+1 −σ

2(aTk − γaZk)4

) τk

zk

aηk, (A.41)

where

I↓k =

∫ aZk

aZk−1

(aTk − γz

)4e−

z−aZk−1zk dz.

This equation requires contributions from layers above, so that the individual terms needto be evaluated from the top downwards. This can be written in the general form

F ↓k ≈ F ↓

k +N−1∑

i=max(k−1,1)

A↓k,i

aηi + B↓kaηm + C↓

kaD for k = 1, N, (A.42)

where we know

F ↓k = F ↓

k+1τk −σI↓

k

2zk, (A.43)

B↓1 =

(F ↓

2 τ1 −σI↓

1

2z1+

σ

2(aT1 − γaHm)4

)1z1

, (A.44)

B↓k = 0 for k = 2, N, (A.45)

C↓1 = B↓

1 (A.46)

C↓k = 0 for k = 2, N, (A.47)

A↓N,N−1 =

(−

σI↓N

2zN+

σ

2(aTN − γaZN−1)4

)1

zN, (A.48)

A↓k,k−1 =

(F ↓

k+1τk −σI↓

k

2zk+

σ

2(aTk − γaZk−1)4

)1zk

for k = 2, N − 1, (A.49)

A↓k,k =

A↓k+1,k −

F ↓k+1

zk− σ

2zk(aTk − γaZk)4

τk, for k = 1, N − 1, (A.50)

A↓k,i = A↓

k+1,iτk for k = 1, N − 1 and i = k + 1, N − 1, (A.51)

B Constraints on mass and momentum

B.1 Atmospheric momentum constraints

Following McWilliams (1977) we need to find constraints on momentum for flow in the channelatmosphere. We start with an example of using constraints in the continuous case and thenprogress to the discrete case.

38

Page 39: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

B.1.1 The continuous case

To determine these constraints in the continuous case, we integrate as an example the atmo-spheric layer 1 vorticity from (7.14) over the entire basin area A,∫∫

∇2H

ap1t dA− f20

aH1

∫∫aη1t dA =

∫∫J(aq1,

ap1) dA+

f20

aH1

∫∫(ae1 − awek) dA− aA4

∫∫∇6

Hap1 dA. (B.1)

We apply a mass constraint ∫∫aη1t dA = −

∫∫ae1 dA, (B.2)

and require that there is no net advection over the basin, giving∫∫∇2

Hap1t dA = − f2

0aH1

∫∫awek dA− aA4

∫∫∇6

Hap1 dA. (B.3)

This equation can be simplified by writing∫∫∇H .(∇H

ap1t) dA = − f0

aH1

∫∫∇H × τ dA− aA4

∫∫∇H .∇H(∇4

Hap1) dA (B.4)

so that application of Gauss’ and Stokes’ theorems in a periodic channel gives∫ [ap1yt

]Ly

0dx =

f0

aH1

∫[aτx]Ly

0 dx− aA4

∫ [∇4

Hap1y

]Ly

0dx, (B.5)

where the square brackets refers to the difference between the values of the variables within atthe north and south of the domain. The equivalent equations can be found in other layers inthe same way.

B.1.2 The discrete case

The same equations can be written for the discrete case, however we only know about vorticityevolution at internal points in the domain (and not the boundary points). Therefore we integrateonly over the internal points (area AI)∫∫

∇2H

ap1t dAI −f20

aH1

∫∫aη1t dAI =

∫∫J(aq1,

ap1) dAI+

f20

aH1

∫∫(ae1 − awek) dAI − aA4

∫∫∇6

Hap1 dAI (B.6)

and note that there remain finite contributions from the advection terms and the mass balance.The displacement and entrainment terms are simplified using∫∫

(aη1t + ae1) dA =∫∫

(aη1t + ae1) dAI

+∆y

2

∫ [(aη1t + ae1)

(1) + (aη1t + ae1)(n)]

dx = 0, (B.7)

giving ∫∫(aη1t + ae1) dAI = −∆y

2

∫ [(aη1t + ae1)

(1) + (aη1t + ae1)(n)]

dx. (B.8)

Here the bracketed superscripts refer to the value of the quantity at that gridpoint.

39

Page 40: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

Since the Jacobian describes conservative advection of q1, its integral vanishes over theinterior of the domain, leaving contributions only from some near-boundary components. So wecan write ∫∫

J(aq1,ap1) dAI =

∫ (J

(1)1 + J

(n)1

)dx. (B.9)

where Jk is the evaluation of the non-cancelling Jacobian terms near the boundary of layer k.Following McWilliams (1977) we choose to satisfy constraints along each of the north and

south boundaries independently. We gather all the terms in (B.6), once again applying Stokes’and Gauss’ theorems to simplify the pressure derivatives and Ekman pumping term, and writetwo equations for the constraints on the atmospheric layer 1 flow,

−∫

ap1(1.5)yt dx +

f20 ∆y

2aH1

∫aη1

(1)t dx

=∫

J(1)1 dx− f2

0 ∆y

2aH1

∫ae1

(1) dx− f0

aH1

∫aτx(1.5) dx + aA4

∫ap1

(1.5)5y dx, (B.10)

∫ap1

(n−0.5)yt dx +

f20 ∆y

2aH1

∫aη1

(n)t dx =

∫J

(n)1 dx− f2

0 ∆y

2aH1

∫ae1

(n) dx

+f0

aH1

∫aτx(n−0.5) dx− aA4

∫ap1

(n−0.5)5y dx. (B.11)

Note that the integral over internal pressure points gives terms which must be evaluated half agridpoint in from the boundary (the first and last two terms in the above equations), and thatin the upper layer we can simplify the Ekman pumping term using Stokes’ theorem (althoughthis distinction is lost in the vector equations below).

These equations can be generalised to the vector form (with the exception of the linearintegral of stress in the previous equations), so that the constraints on all layers can be written

−∫

p(1.5)yt dx +

f20 ∆y

2A

∫p(1)

t dx

=∫

J(1) dx +f0∆y

2aB

∫ae(1) dx + aA4

∫p(1.5)

5y dx, (B.12)

∫p(n−0.5)

yt dx +f20 ∆y

2A

∫p(n)

t dx

=∫

J(n) dx +f0∆y

2aB

∫ae(n) dx− aA4

∫p(n−0.5)

5y dx. (B.13)

The right hand sides of (B.12) and (B.13) are accumulated in the program during timestepping.Therefore we define

LS = −∫

p(1.5)y dx +

f20 ∆y

2A

∫p(1) dx

LN =∫

p(n−0.5)y dx +

f20 ∆y

2A

∫p(n) dx

RS =∫

J(1) dx +f0∆y

2aB

∫ae(1) dx + aA4

∫p(1.5)

5y dx,

RN =∫

J(n) dx +f0∆y

2aB

∫ae(n) dx− aA4

∫p(n−0.5)

5y dx.

It follows from (B.12) and (B.13) that, after timestepping, the new values of L can be written

Lnew = Lold + 2δtR

40

Page 41: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

for both the northern and southern boundaries.With knowledge of the evolution of L at both the north and south boundaries we proceed

to solve for pressure using the Helmholtz solver, which returns a modal pressure p̃ which is zeroon both north and south boundaries. We are looking for p̂, the full modal pressure includingboundary contributions, which can be written as a linear superposition of p̃ and two precomputedsolutions to the homogeneous Helmholtz equation:

p̂(x, y) = p̃(x, y) + C1P1(y) + C2P2(y).

Note that the precomputed solutions P1 and P2 are found from (8.23) and (8.24) using thelinear functions

L1(y) =aY − y

aY,

andL2(y) =

yaY

.

We need to solve for coefficient vectors C1 and C2. To do this we take advantage of theconversion between modal and layer pressures to write

LS = −∫

Cm2lp̂(1.5)y dx +

f20 ∆y

2A

∫Cm2lp̂(1) dx,

which gives

LS = −Cm2l

∫ (p̃(1.5)

y + C1P(1.5)1y + C2P

(1.5)2y

)dx+

f20 ∆y

2ACm2l

∫ (p̃(1) + C1P

(1)1 + C2P

(1)2

)dx.

Premultiply by Cl2m,

Cl2mLS = −∫ (

p̃(1.5)y + C1P

(1.5)1y + C2P

(1.5)2y

)dx+

f20 ∆y

∫ (p̃(1) + C1P

(1)1 + C2P

(1)2

)dx,

where have used the identities Cl2mCm2l = 1 and Cl2mACm2l = λ. Thus, using the fact that p̃(1)

vanishes on the boundary, we can write

Cl2mLS +∫

p̃(1.5)y dx = C1

[−∫

P(1.5)1y dx +

f20 ∆y

∫P(1)

1 dx

]+ C2

[−∫

P(1.5)2y dx +

f20 ∆y

∫P(1)

2 dx

]. (B.14)

Likewise, for the northern boundary we can write

Cl2mLN −∫

p̃(n−0.5)y dx = C1

[∫P(n−0.5)

1y dx +f20 ∆y

∫P(n)

1 dx

]+ C2

[∫P(n−0.5)

2y dx +f20 ∆y

∫P(n)

2 dx

]. (B.15)

Thus we have a pair of simultaneous linear equations for the homogeneous solution coefficientsC1 and C2. The terms in the square brackets can be precomputed at model initialisation (insubroutine homsol); the left hand sides are determined at each timestep, and C1 and C2 are

41

Page 42: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

then found. These are used to form the baroclinic modes, and the modes are transformed intolayer pressures using the matrix Cm2l.

The barotropic mode is a special case of the above, because the eigenvalue λb is zero. Inaddition, according to McWilliams (1977) we need only one constraint on the barotropic mode;we choose to apply this on the southern boundary. In addition we only have one homogeneousbarotropic mode (as the barotropic mode satisfies pyy = 0). The equations then reduce to(

Cl2mLS +∫

p̃(1.5)y dx

)b

= −Cb

∫Pb

(1.5)y dx,

where we have chosen Pb = 1− yaY , and thus can explicitly write

Cb =aYaX

(Cl2mLS +

∫p̃(1.5)

y dx

)b

.

We perform a consistency check on the conservation of mass in the baroclinic solutions. Thechange in mean interface height between timesteps can be explicitly calculated from the integralof entrainment. This is compared with the change computed by applying the constaints derivedabove, and the absolute and fractional errors are stored in the monitoring variables ermasa andemfrat.

B.2 Ocean constraints

B.2.1 Box ocean case

At each interface k we have a mass constraint∫∫oηkt dA = −

∫∫oek dA, k = 1, N − 1. (B.16)

The pressures obtained by solving the inhomogeneous Helmholtz equations will not necessar-ily satisfy these constraints; this is achieved by adding suitable multiples of the homogeneoussolutions.

Although we have posed the constraints quite generally, we in practice make a very restrictivechoice of allowed entrainment. We choose entrainment in the ocean to act only on the uppermostinterface, so that oek ≡ 0 for k = 2, N − 1 (see 4.27). At interface 1, entrainment is nonzero.However (B.16), as well as ensuring conservation of mass, also determines the amount of heatentering the deep ocean. As Q-GCM has no overturning circulation or vertical diffusion, thereis no mechanism for heat to be transferred from the deep ocean back to the surface layer.Therefore, we adjust (in subroutine oml) the entrainment oe1 to satisfy∫∫

oe1 dA = 0. (B.17)

The following procedure ensures that the layer pressures opk are consistent with (B.16) inits general form. Define integrated pressure differences

∆pk =∫∫

(opk+1 − opk) dA, k = 1, N − 1. (B.18)

Combining this with (2.23) and (B.16) gives

∆pkt = −g′k

∫∫oek dA, k = 1, N − 1. (B.19)

With our usual leapfrog timestepping, we have

∆pk = ∆pkold − 2δtg′k

∫∫oek dA = Ek, k = 1, N − 1. (B.20)

42

Page 43: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

The RHS Ek can be computed for each timestep; we must adjust the updated pressure fieldsopk to satisfy this condition. We suppose that the corresponding modal pressures p̂m can bewritten as a combination of the (known) inhomogeneous solutions p̃m and an as yet undeterminedmultiple of the homogeneous solutions:

p̂m(x, y) = p̃m(x, y) + αmhm(x, y). (B.21)

The homogeneous solutions are computed at the start of the run. Area integrating this equation,and using the mode to layer conversion coefficients Cm2l, we have∫∫

opk dA =∑m

Cm2l(k, m)[∫∫

p̃m dA + αm

∫∫hm dA

]. (B.22)

Subtracting to obtain ∆pk and using (B.20), we have

Ek =∑m

[Cm2l(k + 1,m)− Cm2l(k, m)][∫∫

p̃m dA + αm

∫∫hm dA

]. (B.23)

Separating out the unknown quantities αm, we have∑m

M(k, m)αm = Ek −∑m

[Cm2l(k + 1,m)− Cm2l(k, m)]∫∫

p̃m dA, (B.24)

where the matrix elements M(k, m) are given by

M(k, m) = [Cm2l(k + 1,m)− Cm2l(k, m)]∫∫

hm dA.

So we have a vector equation for the unknown coefficient vector αm with a known, constantmatrix M on the LHS, and a RHS which is recomputed each timestep because Ek and p̃m changewith time. There is one inconsistency: k on the RHS ranges from 1 to N − 1, whereas m on theLHS ranges from 1 to N .

Recall from §8.3 that Cm2l(k,m) = Rm(k). For the barotropic mode (m = 1), R1(k) = 1 ∀ k,which implies that this mode makes no contribution to any oηk. Thus for m = 1 the coefficientsinvolving Cm2l vanish on both sides of (B.24).

On the LHS this means that α1 is undetermined, and we are left with an (N − 1)× (N − 1)matrix equation for the baroclinic mode coefficients. The matrix and its LU decomposition arecomputed at the start of the run, in subroutine homsol. Since the homogeneous barotropic modesatisfies ∇2h1 = 0, and has a constant value around the boundary, the solution is h1(x, y) =constant. The barotropic mode is thus just a constant offset to the pressures opk, with nodynamical significance. Therefore without loss of generality we can choose α1 ≡ 0 and h1 ≡ 0.

On the RHS this means that no contribution should come from the barotropic mode p̃1. TheRHS coefficient array is computed for all m (in subroutine homsol) to confirm that, to numericalprecision, the m = 1 coefficients vanish.

B.2.2 Channel ocean case

This involves the same derivation as in Appendix B.1, with several subtle differences. We againintegrate over the internal points (area AI)∫∫

∇2H

op1t dAI +f20

oH1

∫∫oη1t dAI =

∫∫J(oq1,

op1) dAI−

f20

oH1

∫∫(oe1 − owek) dAI + oA2

∫∫∇4

Hop1 dAI − oA4

∫∫∇6

Hop1 dAI . (B.25)

43

Page 44: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

The displacement and entrainment terms are simplified using an equation similar to (B.7). Inthe box ocean we explicitly set the area-averages of entrainment to be zero and interface positionto be constant (B.17). We apply the same constraint in the channel ocean, giving∫∫

oη1t dAI = −∆y

2

∫ [oη1

(1)t + oη1

(n)t

]dx. (B.26)

and ∫∫oe1 dAI = −∆y

2

∫ [oe1

(1) + oe1(n)]

dx. (B.27)

The Jacobian term is equivalent to (B.9). We also assert that the Ekman velocity can be writtenin a similar form ∫∫

owek dAI =∫ (

w(1) + w(n))

dx (B.28)

where w(1) and w(n) are near-boundary integrals whose exact form depends on whether owek isdetermined directly from wind stress, or by interpolation of awek. In either case, we can writethe full constraints as

−∫

op1(1.5)yt dx− f2

0 ∆y

2oH1

∫oη1

(1)t dx =

∫J

(1)1 dx +

f20 ∆y

2oH1

∫oe1

(1) dx

+f20

oH1

∫w(1) dx + oA2

∫op1

(1.5)3y dx + oA4

∫op1

(1.5)5y dx, (B.29)

∫op1

(n−0.5)yt dx− f2

0 ∆y

2oH1

∫oη1

(n)t dx =

∫J

(n)1 dx +

f20 ∆y

2oH1

∫oe1

(n) dx

− f20

oH1

∫w(n) dx + oA2

∫op1

(n−0.5)3y dx− oA4

∫op1

(n−0.5)5y dx. (B.30)

With the exceptions of the owek term and the additional Laplacian diffusion term, this gener-alises to the same vector form as (B.12) and (B.13) (note that an additional bottom drag termalso appears in the lowest layer). The solution is found in the same way, with errors in massconservation stored as monitoring variables ermaso and emfroc.

C Application of pressure derivative boundary conditions

The pressure boundary conditions in the model are given by (2.27) and (2.28). To apply theseconditions at (say) the southern boundary of the domain, we use the second order accuratecentred-difference approximations to pressure derivatives on the boundary:

p(1)y =

p(2) − p(0)

2∆(C.1)

p(1)yy =

p(2) − 2p(1) + p(0)

∆2(C.2)

where p(0) is defined at a ghost point one gridlength outside the boundary, and ∆ is the gridspacing. Using (2.27), and noting that the outward normal derivative pn = −py,

p(2) − 2p(1) + p(0)

∆2=

αbc

∆p(2) − p(0)

2∆(C.3)

which can be solved for p(0):

p(0) =( αbc

2 − 1)p(2) + 2p(1)

αbc2 + 1

. (C.4)

44

Page 45: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

Eliminating p(0), the boundary derivatives can thus be restated as

p(1)y =

p(2) − p(1)

∆( αbc2 + 1)

(C.5)

p(1)yy =

αbc(p(2) − p(1))∆2( αbc

2 + 1). (C.6)

Likewise at the northern boundary we can write

p(n)y =

p(n) − p(n−1)

∆( αbc2 + 1)

(C.7)

p(n)yy =

αbc(p(n−1) − p(n))∆2( αbc

2 + 1). (C.8)

At the western boundary in the finite box ocean, the condition is identical to the southerncondition (with y derivatives replaced by x), and the eastern boundary is equivalent to northernboundary.

D Starting at radiative equilibrium

We can start at radiative equilibrium by writing

aF Tm = 0 (D.1)

oF Tm = 0 (D.2)

ae1 = 0 (D.3)

These can be used to find starting conditions for aTm′, oTm

′ and aη1, if we assume oη1 = 0 andaηm = 0, and neglect atmospheric topography. We therefore set

0 = −N−1∑i=1

A↓1,i

aηi −D↑m

aTm′ − F ′

s, (D.4)

0 = (λ−D↓m)aTm

′ + (−λ−D↑0)

oTm′ − F ′

s, (D.5)

0 =N−1∑i=1

(A↓

1,i −A↑N,i

)aηi + (D↑

m −D↑2)

aTm′. (D.6)

Here we have insufficient equations to constrain aηi for all i, and so we further assume aηi = 0for i > 1. Using (D.4) and (D.6) we get

aTm′ =

(A↓1,1 −A↑

N,1)F′s

A↑N,1D

↑m −A↓

1,1D↑2

, (D.7)

and feed this back into (D.6):

aη1 =(−D↑

m + D↑2)F

′s

A↑N,1D

↑m −A↓

1,1D↑2

(D.8)

We then find ocean mixed layer temperature from (D.5):

oTm′ =

((λ−D↓

m)(A↓1,1 −A↑

N,1)

A↑N,1D

↑m −A↓

1,1D↑2

− 1

)F ′

s

λ + D↑0

(D.9)

45

Page 46: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

E Energy

The definitions of potential and kinetic energy in a QG model are specified by Holland (1978).We write the total kinetic energy in layer k as

KEk ≡ 0.5ρHk

∫∫(uk

2 + vk2) dA,

while potential energy is defined in terms of interfaces rather than layers, and is simply

PEk ≡ 0.5ρg′k

∫∫(ηk)

2 dA.

In addition we define the (positive definite) dissipations in layer k due to the Laplacian andbiharmonic friction respectively as

ε2k ≡ −A2ρHk

∫∫(uk∇2

H uk + vk∇2H vk) dA.

ε4k ≡ A4ρHk

∫∫(uk∇4

H uk + vk∇4H vk) dA.

We start by considering the kinetic energy in atmosphere layer 1. Starting with (2.24) wemultiply the atmospheric layer 1 component by ap1 and integrate over the entire domain,∫∫

ap1

(∇2

Hap1t −

f20

aH1

aη1t

)dA =

f20

aH1

∫∫ap1(ae1−awek) dA−aA4

∫∫ap1∇6

Hap1 dA. (E.1)

To write a kinetic energy equation we need to replace ap (which contains an arbitrary additiveconstant) with its derivatives (which are unambiguous). Therefore, we integrate by parts wherepossible,∫ (

[ap1ap1xt]

Lx0 −

∫ap1x

ap1xt dx

)dy +

∫ ([ap1

ap1yt]Ly

0 −∫

ap1yap1yt dy

)dx

− f20

aH1

∫∫ap1

aη1t dA =f20

aH1

∫∫ap1

ae1 dA− f0

aH1

∫ ([ap1

aτy]Lx0 −

∫ap1x

aτy dx

)dy

+f0

aH1

∫ ([ap1

aτx]Ly

0 −∫

ap1yaτx dy

)dx− aA4

∫ ([ap1∇4

Hap1x]Lx

0 −∫

ap1x∇4H

ap1x dx

)dy

− aA4

∫ ([ap1∇4

Hap1y]

Ly

0 −∫

ap1y∇4H

ap1y dy

)dx, (E.2)

where we have expanded Ekman pumping terms into separate components of stress. We thenwrite pressure gradients as geostrophic velocities and multiply by

aρaH1

f20

to give

− aρaH1

∫∫(av1

av1t + au1au1t) dA− aρ

∫∫ap1

aη1t dA = aρ

∫∫ap1

ae1 dA

+ aρ

∫∫(av1

aτy + au1aτx) dA + aA4

aρaH1

∫∫ (av1∇4

Hav1 + au1∇4

Hau1

)dA

−aρaH1

f0

∫ [ap1

(av1t +

aτy

aH1+ aA4∇4

Hav1

)]Lx

0

dy

+aρaH1

f0

∫ [ap1

(au1t +

aτx

aH1+ aA4∇4

Hau1

)]Ly

0

dx. (E.3)

The last two terms in this equation respectively represent jumps in quantities across the atmo-spheric domain in x and y. In the first case we note that jumps across a periodic domain must

46

Page 47: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

be zero. The second integral can be cancelled using the momentum constraint (B.5). The resultis the simplified equation

aKE1t + aρ

∫∫ap1

aη1t dA = −aρ

∫∫ap1

ae1 dA− aρ

∫∫(av1

aτy + au1aτx) dA− aε41. (E.4)

Here the first term on the right represents the forcing due to up- or downwelling; the second termrepresents the drag on the bottom of the atmosphere and the third is the dissipation of kineticenergy by the biharmonic viscosity. The analogous equation for other layers in the atmospherecan be written

aKEkt + aρ

∫∫apk (aηkt − aηk−1t) dA = aρ

∫∫apk(aek−1 − aek) dA− aε4k. (E.5)

It follows that by summing the equations for all layers we can write a total energy equation forthe system,

aKE1t + aKE2t + . . . + aKEN t + aPE1t + . . . + aPEN−1t = −aρ

∫∫(av1

aτy + au1aτx) dA

− aρ

∫∫ (ag′1

aη1ae1 + . . . + ag′N−1

aηN−1aeN−1

)dA− aε41 − aε42 − . . .− aε4N . (E.6)

where we have assumed that aeN (entrainment at the top of the atmosphere) is always zero.We repeat this exercise for the ocean, beginning with layer 1 where each equation differs

only in the forcing terms. The derivation is therefore identical, except that in the finite boxcase, the jumps across the domain are cancelled by finding an integral of the vorticity equationrather than using pre-existing constraint equations. The resulting layer equations are then

oKE1t− oρ

∫∫op1

oη1t dA = oρ

∫∫op1

oe1 dA+ oρ

∫∫(ov1

oτy + ou1oτx) dA− oε21− oε41, (E.7)

oKEkt + oρ

∫∫opk (oηk−1t −

oηkt) dA =

∫∫opk (oek − oek−1) dA− oε2k − oε4k, k = 2, N − 1, (E.8)

oKEN t + oρ

∫∫opN

oηN−1t dA =

− oρ

∫∫opN

oeN−1 dA−oρδek|f0|

2

∫∫ (ouN

2 + ovN2)

dA− oε2N − oε4N , (E.9)

where we have an additional term in the layer N equation representing linear bottom drag. Thetotal energy equation is then

oKE1t + oKE2t + . . . + oKEN t + oPE1t + . . . + oPEN−1t =

− oρ

∫∫ (og′1

oη1oe1 + . . . + og′N−1

oηN−1oeN−1

)dA + oρ

∫∫(ov1

oτy + ou1oτx) dA

−oρδek|f0|

2

∫∫ (ouN

2 + ovN2)

dA− oε21 − oε41 − oε22 − oε42 − . . .− oε2N − oε4N . (E.10)

This equation shows buoyancy forcing, wind stress forcing, bottom drag and dissipation respect-ively on the right hand side. Each of these terms is independently recorded as a function oftime in the monitoring section of the code. (Strictly speaking this formulation for the windstressforcing is exact only when the Ekman pumping is computed as the curl of the windstress, andis only approximate now that we get the Ekman pumping by interpolation.)

47

Page 48: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Hogg, Blundell, Dewar & Killworth

F Partially coupled experiments

This model includes the facility to do numerical simulations in which the atmosphere and oceandomains are decoupled. The simplest way to do this is to run uncoupled experiments, withforcing from the temporal mean of a coupled run. However, it is more informative to partiallycouple the two domains using the parameters XC and YC defined below (both of which areconstrained to the range [0, 1]).

For example, we partially couple the atmosphere by writing the second element of the atmo-spheric forcing vector as

ae1 =XCF ↑ + (1−XC)F ↑

aρaCp∆a1T

(F.1)

where the instantaneous diabatic heating term is labelled F ↑, while the mean diabatic heatingterm F ↑ is calculated from the time average of a coupled simulation. Thus, when XC = 1the two domains are fully coupled, but with XC = 0 the atmosphere is forced by the meanforcing F ↑, rather than the time varying forcing. Under this scenario, the ocean is still forcedby the atmosphere in the usual way (driven by Ekman pumping, and exchanging heat with theatmospheric boundary layer) but the atmospheric boundary layer does not force the atmosphericcirculation. As such, any modes of variability which are completely coupled, or are driven bythe ocean will be damped; any variability driven entirely from the the atmospheric circulationwill remain.

Likewise the parameter YC controls the link between ocean advection and sea surface tem-perature (SST). This is achieved by rewriting the ocean mixed layer advection terms in (7.11)as

(oum, ovm) =YC

f0(−op1y,

op1x) +1

f0oHm

(oτy,−oτx). (F.2)

When YC = 1, equation (F.2) describes the evolution of a temperature field which is advectedby the oceanic circulation. But when YC = 0 this effect is eliminated – in such cases the SSTvariability is driven only by the wind-driven ageostrophic component of (F.2), Ekman pumpingand ocean-atmosphere heat flux. This parameter setting does allow limited coupled interactions,in the same way as a swamp ocean, but does not allow ocean dynamics to play any role in suchinteractions.

References

Arakawa, A. and Lamb, V. R. (1977). Computational design of the basic dynamical processesof the UCLA general circulation model. Meth. Comp. Phys., 17:173–365.

Arakawa, A. and Lamb, V. R. (1981). A potential enstrophy and energy conserving scheme forthe shallow water equations. Mon. Wea. Rev., 109:18–36.

Golub, G. H. and van Loan, C. F. (1983). Matrix Computations. John Hopkins University Press,Baltimore.

Haidvogel, D. B., McWilliams, J. C., and Gent, P. R. (1992). Boundary current separation in aquasigeostrophic, eddy-resolving ocean circulation model. J. Phys. Oceanogr., 22:882–902.

Hogg, A. M., Blundell, J. R., Dewar, W. K., and Killworth, P. D. (2003a). Formulation and users’guide for Q-GCM (version 1.0). Southampton Oceanography Centre. Internal Document No.88. Most recent version available from http://www.noc.soton.ac.uk/JRD/PROC/Q-GCM/.

Hogg, A. M., Dewar, W. K., Killworth, P. D., and Blundell, J. R. (2003b). A quasi-geostrophiccoupled model: Q-GCM. Mon. Wea. Rev., 131(10):2261–2278.

48

Page 49: Formulation and users’ guide for Q-GCM. Version 1.3q-gcm.org/downloads/q-gcmv1.3.1.pdfFormulation and users’ guide for Q-GCM. Version 1.3.1 A. McC. Hogg, J. R. Blundell, W. K

Q-GCM (version 1.3.1)

Hogg, A. M., Dewar, W. K., Killworth, P. D., and Blundell, J. R. (2006). Decadal variability ofthe midlatitude climate system driven by the ocean circulation. J. Climate. In Press.

Hogg, A. M., Killworth, P. D., Blundell, J. R., and Dewar, W. K. (2005). Mechanisms of decadalvariability of the wind-driven ocean circulation. J. Phys. Oceanogr., 35:512–531.

Holland, W. (1978). The role of mesoscale eddies in the general circulation of the ocean: numer-ical experiments using a wind-driven quasi-geostrophic model. J. Phys. Oceanogr., 8:363–392.

Kravtsov, S. and Robertson, A. W. (2002). Midlatitude ocean-atmosphere interaction in anidealized coupled model. Climate Dyn., 19:693–711.

McDougall, T. and Dewar, W. (1998). Vertical mixing and cabbeling in layered models. J. PhysOceanogr., 28:1458–1480.

McWilliams, J. C. (1977). A note on a consistent quasigeostrophic model in a multiply connecteddomain. Dyn. Atmos. Oceans, 1:427–441.

Opsteegh, J. D., Haarsma, R. J., Selten, F. M., and Kattenberg, A. (1998). ECBilt: a dynamicalternative to mixed boundary conditions in ocean models. Tellus, 50A:348–367.

Pedlosky, J. (1987). Geophysical Fluid Dynamics. Springer-Verlag.

Peixoto, J. P. and Oort, A. H. (1992). Physics of Climate. Springer-Verlag.

Press, W. H., Teukolsky, S. A., Vetterling, W. T., and Flannery, B. P. (1992). Numerical Recipesin Fortran 77: The Art of Scientific Computing (2nd ed.). Cambridge University Press.

49