# Using 3D finite volume for the pressure-gradient force in atmospheric models

## Abstract

The horizontal pressure-gradient force is traditionally discretized in partial-differential equation (PDE) form in atmospheric models, but may alternatively be discretized as the net normal surface force divided by the mass, which is referred to as the Green–Gauss method in computational fluid dynamics (CFD). The latter approach is ubiquitous in engineering because of the utility of unstructured grids; in the meteorological context Lin derived in 1997 a two-dimensional (2D), plane-parallel, Green–Gauss algorithm and showed that it eliminated inaccuracies related to using terrain-following (sigma) coordinates in steep terrain. Although a hierarchy of three-dimensional (3D) algorithms have been developed by the CFD community, with varying cost-to-benefit trade-offs, work remains to be done to take full advantage of the 3D approach in atmospheric models. Here, we move in this direction by extending Lin's 2D algorithm to 3D. As is true of all Green–Gauss implementations, our algorithm is the same regardless of choice of vertical coordinate or number of fluid constituents. We show that the modifications to the 2D algorithm may be written in the form of additive terms composed of differences of the squares of the top and bottom tilts of the finite-volume faces; the cases for which the 2D and 3D algorithms are identical are then straightforward to discern. For plane-parallel geometry, we include explicit finite-volume formulae for the longitude–latitude and general convex quadrilateral planforms, which includes the cubed-sphere grid, with arbitrary geopotentials on the eight corners. Compared with the 2D version, the 3D algorithm yields approximately a 10% reduction in truncation error and, in the context of a general circulation model, it requires only about a 1% increase in run time. Copyright © 2012 Royal Meteorological Society

## 1. Introduction

When the horizontal pressure-gradient force (PGF) is expressed in partial differential equation (PDE) form, and the vertical coordinate is a terrain-following (sigma) coordinate, the PGF splits into two terms that cannot be combined under a single gradient operator. In this case, the truncation errors of these terms do not cancel and lead to significant errors in steep terrain. Discussions of this problem in the meteorological and oceanographic literature are referenced below. In the planetary atmospheres context, we have encountered this problem when applying a hybrid isentropic-sigma coordinate model to Venus (Herrnstein and Dowling, 2007), and have noted that a similar split also arises when modelling ortho- and parahydrogen for gas-giant atmospheres (Dowling et al., 1998).

Lin (1997) reviews the steep-terrain problem and prescribes an elegant solution: a two-dimensional (2D), plane-parallel, Green–Gauss pressure-gradient algorithm. This algorithn was further elucidated by Chu and Fan (2003) and is now offered as a finite-volume option in several models. Further advances along these lines have been made; e.g. Adcroft et al. (2008) derive a 2D Green–Gauss algorithm that takes into account the compressibility of seawater. Lin (2004) reviews the field and covers all aspects of the finite-volume approach, but still employs his 2D algorithm for the horizontal PGF (his Eq. (28)).

As elegant as they are, the above studies have not yet investigated the ramifications of applying 2D algorithms to three-dimensional (3D) atmospheres and oceans. Engineering computational fluid dynamics (CFD) models tend not to apply 2D algorithms to 3D problems, and hence provide little or no guidance on the efficacy of the approach.

Much CFD development has been done with 3D pressure-gradient algorithms for arbitrary grids, using both finite-volume and finite-element approaches, including the Green–Gauss and least-squares techniques, e.g. Mavriplis (2003), Christon (2009), and the references cited by Lin (2004). For the most part, these CFD algorithms have not yet been tested in the meteorological setting, which Lin (2004) points out has strong stratification unlike most gas-dynamics applications, and will have different cost-to-benefit criteria in general. One notable exception is the Operational Multiscale Environment Model with Grid Adaptivity (OMEGA; Bacon et al., 2000), an unstructured-grid atmospheric model with a dynamical core designed around CFD techniques, which uses a 3D Green–Gauss PGF algorithm. However, a description of that algorithm is not available in the literature.

As far as we are aware, at the time of writing there are no 3D Green–Gauss pressure-gradient algorithms described in the meteorological literature. The 118-page review on finite-volume methods in meteorology by Machenhaur et al. (2009) is a tour de force on the continuity equation, but presents the PGF in PDE form (their Eqs (3.102)–(3.105) and (3.147)), or cites Lin's 2D algorithm (p. 101). Adcroft et al. (2004) describe a finite-volume option for the Massachusetts Institute of Technology general circulation model (MITgcm), but implement the PGF in PDE form times a differential volume (their Eqs (8a, b)). Sawyer and Mirin (2007) describe a horizontal-area average of the PDE-form pressure-gradient terms (their Eqs (14)–(16), (22), (23)). We feel it is important to start the conversation in meteorology about the 3D Green–Gauss approach to the horizontal PGF.

In section 2, we give a description of our extension of Lin's 2D Green–Gauss pressure-gradient algorithm to plane-parallel 3D geometry, starting with the traditional longitude–latitude grid and then proceeding to the general convex quadrilateral planform, which may be applied to the cubed-sphere grid. In section 3, we provide a simple cost-to-benefit analysis by comparing the 3D versus 2D truncation errors and runtime costs arising from a hydrostatic atmosphere in the vicinity of a Gaussian mountain. We show that the trade-off when switching from 2D to 3D is about a 10% reduction in PGF truncation error for a 1% increase in complete-model run time. In section 4, we summarize our results and discuss possibilities for future improvement.

## 2. 3D Algorithm

We follow Lin (1997) and design a Green–Gauss algorithm for the horizontal PGF assuming pressure, p, locally varies linearly with respect to geopotential, Φ, across a 3D finite volume instead of a 2D one. (As was done by Lin, the final algorithm is presented more generally by assuming a monotonic function of pressure, π(p), varies linearly with respect to Φ, as described below.) To manage the algebra, we restrict our scope to the plane-parallel case, starting with the horizontal cross-section for a longitude–latitude (λϕ) grid, which in a local-Cartesian sense forms an isosceles trapezoid with parallel poleward and equatorward faces, followed by the general convex quadrilateral planform that is appropriate for more modern grids like the cubed sphere (e.g. Ronchi et al., 1996). The eight corners are at arbitrary altitudes, consequently the top and bottom faces are not planes, but can and will be treated as bilinear surfaces. Because the eight corner heights are arbitrary, the algorithm handles any vertical coordinate without modification.

### 2.1. 3D Notation

Eight corner geopotentials and pressures are supplied as inputs. In terms of corner notation, the ‘top northeast’ geopotential is labelled Φtne, and so on. Originally, we developed the 3D algorithm in terms of this corner notation, but subsequently discovered it is easier to compare with Lin's 2D algorithm by recasting without loss of generality in terms of midpoint values and tilts, as follows. The corners are input as above, and then the algorithm internally calculates for the zonal component the corresponding midpoint values, Φtebetwbw, and tilts, δtebetwbw, as illustrated in Figures 1 and 2. For example, the corner inputs Φtne and Φtse combine to yield the ‘top east’ midpoint value Φte ≡ (Φtne + Φtse)/2 and tilt δte ≡ (Φtne − Φtse)/2. Analogously for the meridional component, the algorithm internally calculates the midpoint values Φtnbntsbs, and tilts δtnbntsbs, as illustrated in Figure 2(b). The finite volume is treated in a local-Cartesian sense to compute the force components (Adcroft et al., 2004, 2846–2847). In general for what follows, Lin's 2D algorithm may be recovered from the 3D version by setting these tilts to zero.

### 2.2. Mass

Either the zonal or meridional midpoint-tilt notation (Figure 2(a, b)) can be used to express the mass, and we have occasion to use both below. In terms of the zonal notation, which is appropriate for terms affecting the zonal-wind tendency, ∂u/∂t, we integrate to get an expression for the volume, and express the mass, Δm, as this times the finite volume's bulk density, ρ (which is not a required input in the final form):

(1)

Here , Δr ≡ (rsrn), g is a constant reference value for gravity (which divides out of the final form), and Δλ and Δϕ are the spans in longitude and latitude (in radians) of the finite volume, respectively. (Note that some authors reverse the symbols for longitude and latitude.) The volume and surface integrals in this project have been carried out with the aid of symbolic-manipulation software (Wolfram, 2010).

In a hydrostatic model, one may conveniently recast (1) in terms of pressure to eliminate ρ,

(2)

where we determine from the eight corner input pressure values the midpoint pressures, and the pressure tilts, τ, in the arithmetic sense, e.g. τte ≡ (ptneptse)/2. Interestingly, in the meridional notation, which is appropriate for the meridional-wind tendency, ∂v/∂t, the tilts drop out and the expression for the mass in terms of pressure is

(3)

One may verify that (2) and (3) are equivalent by using corner-location identities such as pbwτbw = pbsτbs, pbw+τbw = pbnτbn, etc., and closed-loop identities such as pbw + τbw + 2τbn − 2τbe − 2τbs + τbw = pbw.

The PGF in the zonal direction* may be obtained by integrating the pressure with respect to latitude and altitude across the apparent areas, looking east, of the west, east, top and bottom faces (Figure 2(a)), adding these together, and dividing by the mass. This is the Green–Gauss approach.

The design and accuracy of a Green–Gauss PGF algorithm depends on how one chooses to treat the pressure as a function of position in these surface integrations. In the CFD literature, a distinction is made between cell-based and node-based algorithms. Here, we have followed the latter approach, requiring the values at the eight corners, since this is natural for our in-house purpose of retrofitting this algorithm into an otherwise finite-difference model. We see no impediment to trying other approaches.

A general way to proceed would be to first construct a model for pressure on each face that varies both vertically and horizontally, and then integrate it over each face. However, we have elected to keep this first attempt at a 3D Green–Gauss algorithm simple, and so have followed Lin (1997) by assuming pressure varies only as a linear function of geopotential on each face, without incorporating horizontal variation, except that each face is treated locally. In this manner we are able to isolate how much additional algebraic complexity results from expanding from 2D to 3D geometry for the finite volume, including the effect of varying map factors, and to provide a cost-to-benefit benchmark that should prove useful to future, more general, 3D developments.

An apparent drawback of this approach is that, for each pair of faces that share an edge, the pressure from each face does not in general match at the edge (Lin's chords in 2D are not to be confused with our edges in 3D; his run down the middle of our faces and are not associated with discontinuities in pressure). However, this has not proved to be a problem in practice, because only the surface integrals of pressure are important (and the volume integral to get the mass), not the edges.

#### 2.3.1. East and west faces

Turning now to the surface integrals of pressure for the zonal component, consider first the west face, which is the trapezoid with corner heights Φbw + δbw, Φbwδbw, Φtwδtw, Φtw + δtw, as outlined in bold in Figure 2(a). Applying the linear model everywhere on this face, where the slope factor

(4)

can be interpreted as a local density, the double integral of pressure over the apparent area as viewed in the zonal direction yields

(5)

One recovers Lin's 2D formulation in the special case , which occurs when the absolute values of the top and bottom tilts on a face are equivalent, including when both tilts are zero, but not otherwise. (This symmetry will disappear, and the expression involving the tilts will become more complicated, when horizontal variation of pressure on the face is incorporated.) Note that the 3D algorithm makes explicit use of , whereas the 2D algorithm does not. The east face is analogous to (5), except that it is subtracted rather than added when calculating the net force, below, and there are no contributions from the north or south faces for the zonal component. There are contributions from the top and bottom faces, and these require the following additional consideration.

#### 2.3.2. Top and bottom faces

A key design specification of our Green–Gauss algorithm is to yield exactly zero horizontal PGF when subjected to any pressure field that is locally linear with respect to geopotential, p = aΦ + b, where a and b are arbitrary constants (or a more general monotonic function π(p) = aΦ + b, as discussed below). We obtain the cancellations that achieve this goal when we design the algorithm using a linear-with-geopotential pressure model on all the faces, including the top and bottom. The problem is that, in this particular 3D formulation, we need to supply , but this slope term is not defined for the perfectly reasonable, flat orientation Φte = Φtw. We have dubbed this the ‘bowtie’ case because of its physical presentation when the tilt terms are not zero. Lin's 2D formulation is immune to this problem because terms do not appear in the 2D case. A simple solution would be to have the user input these slope terms, and we see no obvious drawbacks to this approach. However, for our implementation we have decided to construct them from the existing inputs as follows.

We tried three different ideas, eventually settling on the third; each is briefly described here for completeness. The first scheme was to calculate as above when it is defined, but set the term in which it appears to zero when it is not. This approach has the drawback that it is not continuous when the top or bottom face orientation is continuously varied through the bowtie (Φte = Φtw) case. This is a mild issue in practice because, when a top or bottom face is in the bowtie configuration, it usually does not make a large contribution, but is a problem we nevertheless wish to avoid. Our second idea was to assume pressure varies linearly with longitude instead of altitude on the top and bottom faces, which avoids the divide-by-zero problem altogether. However, it suffers the drawback that it does not generate an algorithm whose terms cancel to yield precisely zero when subjected to p = aΦ + b. Our third idea, which we ultimately adopted, was to set

(6)

and similarly for , where the arrows indicate the east-face and west-face slope factors from the finite volumes that are below and above the horizontal face in question. This yields an algorithm that is robust and continuous with respect to top- and bottom-face orientation, has the desired cancellations in the p = aΦ + b case, albeit with less locality, and provides precise equal-and-opposite forces for each horizontal face shared by stacked finite volumes. To handle the very top and very bottom faces of each column, we use and , respectively.

#### 2.3.3. Zonal algorithm

We are now in a position to add together the surface integrals of pressure, and divide by the mass,

(7)

where the signs for the top and bottom faces may be confirmed by examining Figure 2(a) and taking into account that the integration over z is from the apparent west edge to the apparent east edge.

At this point we follow Lin (1997, p. 1753) and generalize the terms involving pressure into a monotonic function of pressure, pπ(p). This allows for increased accuracy by matching a model's pressure-gradient algorithm to the employed form of its hydrostatic balance equation. For example, the choice π = pκ (π = lnp) is most appropriate when potential temperature, θ (temperature, T) is a prognostic variable, respectively. For the final algorithm formulae in this paper, we therefore write π in place of p, while continuing to use τ to denote the corresponding tilts, such that τte ≡ (πtneπtse)/2. For the west face, the slope factor, , which is no longer the local density, generalizes to

(8)

with the linear relation assumed to apply everywhere on the face, and so forth for the other faces.

Our resulting zonal 3D Green–Gauss algorithm is

(9)

with the following new additive terms compared to the 2D case appearing, respectively, in the numerator and denominator:

(10)

and

(11)

Setting Nu and Du to zero recovers Lin's 2D algorithm.

To test this expression against the arbitrary linear pressure model, π = aΦ + b, note that all the terms become constant, , such that Nu = 0 for arbitrary geopotential tilts, δ, and the rest cancel as in Lin (1997), such that PGFu = 0. We would argue that this 3D version of the zonal component retains much of the simplicity of the 2D version, and is straightforward to implement. We now turn to the meridional component, for which the map factors are more intertwined in the solution.

All six faces contribute to the north–south component of the PGF, as seen in Figure 2(b). The north and south faces are trapezoids analogous to the east and west faces for the zonal component, whereas the top and bottom faces are slightly more complicated, and there are now ‘northeast’ and ‘northwest’ faces (or ‘southeast’ and ‘southwest’ in the Southern Hemisphere) to account for.

#### 2.4.1. Top and bottom faces

In terms of calculation strategy for the top and bottom faces, the only change to the procedure above is that we split the top and bottom area integrations into three sections, partitioned by the vertical dotted lines shown in Figure 2(b), such that each sub-integral has straight lines for its lower and upper limits of integration. Starting on the left side of Figure 2(b), the west section runs from xsw = 0 to xnw = (rsrnλ/2, which is also the base of the west-face integration, the middle section runs from xnw to xne = (rs + rnλ/2, and the east section runs from xne to xse = rsΔλ, which is also the base for the east-face integration.

The pressure force on the top face integrates to be

(12)

with an analogous result for the bottom face; these resemble their zonal counterparts when . Following the discussion above, the slope factor is set to

(13)

and likewise for .

#### 2.4.2. East and west faces

In the Northern Hemisphere, one can interpret the east and west faces as being the ‘northeast’ and ‘northwest’ faces, such that they enter with the same sign as the north face:

(14)

They are most simply expressed with the zonal notation (Figure 2(a)); for example the pressure force on the west face integrates to be

(14)

but one may convert to the meridional notation (Figure 2(b)) by adding and subtracting corner identities to get the mid-values and tilt values, respectively. For example,

Having tried both ways, we prefer to work with these two faces as expressed in (15). In the Southern Hemisphere, Δrrsrn changes sign and the roles and signs of these two faces switch to ‘southeast’ and ‘southwest’ automatically.

#### 2.4.3. Meridional algorithm

Unlike in the zonal case, the map factors prevent significant cancellation of terms in the general meridional expression, but nevertheless it is straightforward to implement. Our algorithm in terms of reduced factors (for which a common factor of Δλ/(6g) has been removed), with pπ(p), is

(16)

where

(17)
(18)
(19)
(20)
(21)
(22)

and

(23)

To see some of the properties of this scheme, first note that in the special case rs = rn, both and are zero, and the remaining map factors cancel out such that (16) becomes analogous to the zonal result (9), and hence has the same properties. Second, when pressure is constant, the factors are all zero, and the numerator of (16) can be shown to be zero after making use of averaging identities like Φtw + Φte = Φtn + Φts, which follows from setting one-half of the sum of the four corner values equal to itself and using the associative property of addition.

An intermediate result of this article is that for the arbitrary-linear case π = aΦ + b, our 3D Green–Gauss meridional pressure gradient algorithm yields exactly zero for arbitrary input map factors, R, rs, and rn, and eight arbitrary input corner geopotential values. To prove this, one may proceed by replacing the east–west notation in (19) and (20) with north–south notation as outlined above. We next generalize these results for application to the cubed-sphere grid.

While channel models based on the longitude–latitude grid continue to be useful for gas-giant research–Jupiter has 120 times the surface area of Earth and is extremely zonal–global models of Earth have predominantely turned to grids with quasi-uniform horizontal resolution. The cubed sphere in particular has emerged as a leader, buoyed by a number of technical advantages (Ronchi et al., 1996). With this application in mind, we now adapt the 3D algorithm above to the general convex quadrilateral planform, Figure 3. Note that, in what follows, the x and y directions are assumed to correspond to true east and true north of the finite-volume centre, respectively, but can be any similarly orthogonal horizontal directions of interest, so long as the corner notation is applied in a consistent manner.

#### 2.5.1. Generic side face

We use the same pressure-model and plane-parallel assumptions as above, such that a reduced-factor expression for the force on a generic side face is

(24)

where L is the apparent horizontal width between the parallel vertical sides (length in metres; unlike above there is no common factor Δλ cancelled from the reduced-factor terms). For example, with reference to Figure 3, one sees that for the meridional-component south face, L = xsexsw ≡ Δxs is always positive, whereas for the zonal-component south face, L = yseysw ≡ Δys changes sign depending on the orientation of the finite volume. Once each Fside has been correctly included in the net force algorithm using the sign corresponding to L > 0, maintaining L as a signed factor ensures the proper contribution.

#### 2.5.2. Top and bottom faces

The top and bottom faces are similar to the meridional case (21), except instead of R, rs and rn, here the horizontal positions of the finite-volume edges are input (Figure 3). A reduced-factor expression for the meridional-component top face is

(25)

where Δxnxnexnw and Δxsxsexsw take the place of rnΔλ and rsΔλ. Notice the appearance of a new 3D term that is proportional to the difference , where and , such that it is responsive to the orientation of the planform (in the sense of a compass). The meridional bottom face is analogous to (25), as are the top and bottom faces for the zonal component (below).

#### 2.5.3. Mass

To calculate the mass of a 3D finite volume with an arbitary convex quadrilateral planform, we assume bilinear top and bottom surfaces as above. One can visualize such a surface as being like the trace of a baton on a short flight (a baton that can change its length like a telescope and for which each end traces out a straight-line path). Using vector notation, x ≡ (x,y,z), a point on the top surface satisfies

and similarly for the bottom surface, where ξ ∈ [0,1] and η ∈ [0,1] are non-dimensional position variables. To determine the differential area at a point, dA = F(ξ,η)dξdη, which is itself a convex quadrilateral, we use the fact that dA is equal to one-half of the two-dimensional cross-product of the diagonal corner-to-corner horizontal vectors for the differential element. Assuming hydrostatic balance and a bulk density as above, the mass in terms of pressure integrates to be

(26)

where and . The mass expressions (2) and (3) are special cases of (26). The three factors in curly braces involving x and y are each invariant to horizontal translations and rotations; they depend on position for a cubed-sphere grid and should be precomputed before running a model.

#### 2.5.4. Cubed-sphere algorithm

Collecting the above results together, our algorithm for the zonal component of the PGF for a plane-parallel, 3D finite volume with a general convex quadrilateral planform is

(27)

where the reduced-factor, pπ(p) terms are

(28)
(29)
(30)
(31)
(32)
(33)

and

(34)

In the above equations, Δyw ≡ (ynwysw), Δye ≡ (yneyse), Δynyneynw, Δysyseysw, and τ and are defined in terms of π rather than p as described above. For the meridional component, the same mass equation (34) can be employed, and we have

(35)

where

(36)
(37)
(38)
(39)
(40)

and

(41)

In the above equations, Δxexnexse and Δxwxnwxsw. The main result of this article is that, for a finite volume with arbitrary geopotential heights on the eight corners and an arbitrary convex quadrilateral planform, which includes the cubed-sphere and longitude–latitude grids, our 3D Green–Gauss algorithm yields exactly zero zonal and meridional PGF for the case π(p) = aΦ+b. We next provide a simple cost-to-benefit analysis of the 3D scheme compared to its 2D predecessor.

## 3. Accuracy and performance

The 2D Green–Gauss algorithms referenced in the introduction capture the lion's share of the reduction of truncation error over traditional, PDE formulations of the horizontal PGF. Here, we examine the additional reduction provided by the 3D formulation, and its computational cost, by testing it in the EPIC atmospheric model (Dowling et al., 2006), which uses a longitude–latitude grid.

### 3.1. Gaussian mountain tests

Following Lin (1997), we test with an idealized, constant-lapse-rate atmosphere, Γ = 20/3Kkm−1, with a sea-level temperature of 288K, and a Gaussian mountain given by

(42)

where is the radial distance from a point on the mountain to the mountain's central axis, d is the half-width of the mountain, and x and y are the local-Cartesian analogues of longitude and latitude, respectively. The vertical domain ranges in pressure from 1013 to 250 hPa. For Lin's mountain, Hmax = 4 km and d = 312.5 km, whereas we have elected to use a mountain with a smaller half-width, d = 80 km, and have examined the effects of mountain height from 0 to 8 km. Much of this parameter range is steep enough such that, given a reasonable number of vertical layers, the local finite difference of the geopotential on a constant-sigma surface exceeds its vertical difference between layers, which signals violation of hydrostatic consistency for some PDE algorithms (Mesinger, 1982).

The EPIC model has a hybrid isentropic-sigma vertical coordinate, for which we set the transition to sigma coordinates at p = 250 hPa, the top of Lin's model, such that we have a sigma-coordinate model (the isentropic-coordinate portion of the model extends from 250 up to 100 hPa, but all references made here to the number of layers count only those between 1013 and 250 hPa). The model treats potential temperature as a prognostic variable, hence we set π(p) = pκ, as did Lin. Since the analytical horizontal PGF is exactly zero for a perfectly hydrostatic atmosphere, the actual value returned by the various algorithms is the reported error.

#### 3.1.1. Domain-mean error

Rather than swapping to a 2D averaging scheme when testing the 2D algorithm applied to the 3D mountain, all domain-mean results reported in this article use 3D volume averaging. Specifically, the domain-mean absolute error in the zonal component of the PGF is defined as the sum of the absolute values from each finite volume, weighted by their volume (m3) increments, and divided by the sum of the volume increments across the 3D domain.

We find the same behaviour of truncation error versus vertical resolution as reported by Lin (1997). The dependence of truncation error on mountain height and grid resolution is illustrated in Figure 4. The steepest mountain we consider has Hmax = 8 km and d = 80 km, which yields a maximum slope of 0.086 and is in the same class of mountain steepness as Maxwell Montes on Venus and steep terrain on Earth. In all cases, the 3D error is modestly but systematically less than the 2D error. Linear regression reveals the improvement is 12 ± 1% for the cases we have examined, with a slight dependence on vertical resolution.

This uniform reduction is likely to be related to the fact that the same pressure model has been used to design both the 2D and 3D algorithms. In addition to placing the mountain at the Equator, we looked at cases where the mountain's centre is located at 15°,30°,45° and 65° latitude. No significant change in domain-mean error results for either the 2D or 3D algorithms, including the meridional-component error in the 3D case. We interpret these results as suggesting there is a ∼10% reduction in domain-mean error per timestep that may be realized from geometrical effects alone by generalizing the Green–Gauss algorithm from 2D to 3D, which is encouraging.

#### 3.1.2. Slope orientation

It is interesting to complement the domain-mean error calculations above with a search for patterns that associate with local conditions. In particular, identifying errors associated with the orientation of the mountain slope should ultimately lead to improvements in the prediction of wind as a vector quantity in the vicinity of variable terrain. Here, we focus on the signal for the PGF just above the mountain, at the steepest slope of the Hmax = 8 km, d = 80 km Gaussian-mountain case, which occurs on a ring of radius km and surface altitude 4.85 km. We accept data points from the horizontal grid of the model associated with surface altitudes that fall within a tolerance of 4.85 ± 0.35 km (7%) in height, and plot the errors versus angle around the mountain. As seen in Figure 5, both the 2D and 3D algorithms exhibit a directional bias when the terrain slope is orientated between the zonal and meridional directions. Again, it is promising that the 3D algorithm has systematically lower errors than the 2D algorithm. We also examined the meridional component errors and found they are essentially indistinguishable from Figure 5 after rotating by 90°.

### 3.2. Computational cost

To assess the performance cost of our 3D Green–Gauss algorithm versus Lin's 2D algorithm, we did runtime profiling and timing of the code as implemented in the EPIC atmospheric model. We analyzed a 40-layer (total) model, with 104 grid points in each horizontal direction, using the profiling tool callgrind (part of valgrind, version 3.3.1). Measuring cost in terms of Instruction Read (Ir) events for the respective PGF subroutines (inclusive of all direct and indirect calls), the 3D algorithm is 3.2 times more expensive than the 2D algorithm, for the longitude–latitude grid.

In terms of the overall percentage of a complete model timestep (exclusive of data input or output and startup bookkeeping), the 2D and 3D versions cost 0.5% and 1.5%, respectively, in the EPIC model. The net result is that the difference in wallclock time is negligible when switching from the 2D to the 3D algorithm, and we expect this to hold true for other atmospheric models.

## 4. Conclusions

We have extended the 2D Green–Gauss horizontal PGF algorithm of Lin (1997) to three dimensions, and shown how to calculate the zonal and meridional force components for the longitude–latitude and cubed-sphere grids. We find the trade-off is approximately a 10% reduction in truncation error from the PGF terms for a 1% increase in computational cost of a full atmospheric model.

The algorithm presented here is robust in practice–variations of it have been used extensively in the EPIC model (Dowling et al., 2006) over the past three years, and it is now the model's default. In addition to gaining significantly on accuracy, we prefer the Green–Gauss formulation because we do not have to modify the algorithm when switching from terrestrial planets to gas-giant planets (for which the ortho-/parahydrogen mix splits the pressure gradient in PDE form), or from the terrain-following to the isentropic-coordinate regions in our hybrid-coordinate model. This satisfies a top design goal of the EPIC atmospheric model, to find robust algorithms that work well in all cases without conditional modifications.

We advocate making this 3D Green–Gauss algorithm available as an option alongside Lin's 2D algorithm, such that each group may optimize for their particular application. A geophysical fluid dynamics model that is completely implemented in finite-volume form has many advantages, and those in particular that pertain to advection and continuity (mass conservation) have been well enumerated in the literature. However, one does not need to convert an entire model to finite volume to gain the advantages outlined in this article and its predecessors–examples include the Geophysical Fluid Dynamics Laboratory (GFDL) AM2 B-grid model (Anderson et al., 2004) and our EPIC C-grid model. If only one component is to be so modified to finite volume, for many geophysical fluid dynamics applications we feel a case has been made that it should be the horizontal PGF.

The next steps in the evolution of 3D Green–Gauss pressure-gradient algorithms applied to meteorological problems include: (i) improving the pressure model on the faces by including horizontal as well as vertical variation, (ii) investigating sub-grid distributions that are higher order than linear, and (iii) considering the non-plane-parallel case. Our sense is that significant improvements in accuracy are still available, and are likely to be worth the cost.

## Acknowledgements

We thank Aaron Herrnstein for useful discussions and two anonymous referees for insightful comments which improved the paper. This research was supported by NASA's Planetary Atmospheres Program, grant NNX08AE64G.

• *

A common misconception is that the two horizontal directions are locally orthogonal to the vertical coordinate. In fact, they are always exactly horizontal, meaning orthogonal to the local direction of gravity–the gradient of the geopotential–even when using pressure, potential temperature, or any other non-geopotential variable for the vertical coordinate. In this sense, meteorologists use non-orthogonal coordinate systems.

• A proof is included in the Mathematica notebooks generated in this work, which are available in the Explicit Planetary Isentropic-Coordinate (EPIC) model distribution under epic/tools/mathematica. http://pds-atmospheres.nmsu.edu/data_and_services/software/epic/epic.htm

• The EPIC atmospheric model source code is freely available from the NASA Planetary Data System (PDS) Atmospheres Node, http://atmos.pds.nasa.gov/