Spectral Core
Spectral Core
You are strongly encouraged to read the companion files on the non-divergent
barotropic vorticity equation and the shallow water equation before proceeding
to the documentation for the full spectral dynamical core. We do not repeat
the discussion that can be found there concerning spherical coordinates and
the spherical harmonic spectral transform method. The numerics of the shal-
low water model, in particular, are closely analogous to those for the full
model.
Thermodynamics
The dry component of the atmosphere is assumed to have uniform composi-
tion and to be an ideal gas:
pd = ρd Rd T.
The only variable constituent of the atmosphere that has a significant effect
on its density is water vapor. Strictly speaking, there are a number of effects
of water vapor, and condensate, on the thermodynamics and dynamics, but
because water vapor mixing ratios are at most 2% in the atmosphere, and are
generally much smaller, we ignore all of these in the dynamical core except for
the effect of vapor on the density, often referred to as the virtual temperature
effect.
Setting the ratio of the mass of a water molecule to the average mass of
a molecule of dry air equal to ξ = mw /md = Rd /Rw ≈ 0.622, and using the
ideal gas law for the water vapor as well, pw = ρw Rw T , we have ρ = ρd + ρw
and p = pd + pw = (ρRd + ρw (Rw − Rd ))T = ρRd Tv , with
1−ξ
Tv ≡ T (1 + µq); µ = ≈ 0.608 (1)
ξ
q is the specific humidity, the ratio of the density of vapor to the total density,
ρw /(ρd + ρw ). In the following, we drop the subscript on Rd .
Within this model, one can advect several tracers if desired: only one of
these, specific humidity, affects the rest of the dynamical core of the model,
and only through this virtual temperature effect. Other effects of water, such
as on the heat capacity per unit mass, and the various effects of condensed
1
water, are neglected. There is also no provision for changes in the mass of the
atmosphere due to precipitation: in particular, there is no mass flux through
the lower boundary of the model. In its present form, the model should
not be utilized for extremely warm climates in which water vapor becomes a
substantial part of the atmospheric mass.
In terms of the material derivative, D/Dt, conservation of mass takes the
form
Dρ
= −ρ∇ · v (2)
Dt
or, in flux form,
∂ρ
= −∇ · (ρv) (3)
∂t
The conservation law for any tracer, including specific humidity, can be writ-
ten in either flux or advective form as well:
Dξ
=S (4)
Dt
∂ρξ
= −∇ · (ρvξ) + ρS (5)
∂t
where S represents the sources/sinks.
We can write the first law of thermodynamics in terms of the internal
energy cv T
DT D(1/ρ) p Dρ
cv = −p +Q= 2 +Q (6)
Dt Dt ρ Dt
where Q is the diabatic heating and cv is the heat capacity at fixed volume.
One can also write the first law in terms of the enthalpy cp T , where cp is the
heat capacity at constant pressure,
DT 1 Dp
cp = +Q (7)
Dt ρ Dt
or, using the equation of state
DT κTv ω Q
= + (8)
Dt p cp
where κ = R/cp and ω is the traditional notation for Dp/Dt. Q includes the
heating due to frictional dissipation. For our ideal gas, cp = cv + R.
2
Equation of motion
In a spherical coordinate system rotating with angular velocity of magni-
tude Ω, we have for the rate of change of the zonal, meridional, and radial
components of the flow (u, v, w):
Du uv tan(θ) uw 1 ∂p
= 2Ω sin(θ)v − 2Ω cos(θ)w + − − (9)
Dt r r ρr cos(θ) ∂λ
Dv u2 tan(θ) vw 1 ∂p
= −2Ω sin(θ)u − − − (10)
Dt r r ρr ∂θ
Dw u2 + v 2 1 ∂p
= −2Ω cos(θ)u + − −g (11)
Dt r ρ ∂r
where
D u ∂ v ∂ ∂
= + +w (12)
Dt r cos(θ) ∂λ r ∂θ ∂r
Here gz (z ≡ r − a, with a a constant) is the geopotential (the gravitational
plus the centrifugal) potential. We ignore the equatorial bulge of the Earth,
and simply set g to be a constant as well. The lower boundary of the model
is at z = h(λ, θ), where h defined the orography of the surface.
The hydrostatic approximation is made throughout, justified by the small
aspect ratio, the ratio of vertical to horizontal scale, of the flow. Generally
speaking, the resulting primitive equations will be well-posed only if one’s
subgrid closure does not allow aspect ratios of order unity from developing,
(i.e., scales comparable to the vertical scale height, say 10 km). One avoids
this issue by never pushing the horizontal resolution to this point. The
hydrostatic relation is obtained by ignoring all but the final two terms in
(11) (we also replace r by z):
∂p
= −ρg (13)
∂z
or, in terms of the geopotential Φ ≡ gz,
∂Φ
= −RTv (14)
∂ ln p
Because we have omitted the vertical component of the Coriolis force
and the metric term in the w-equation, as well as the vertical acceleration,
3
one must also ignore the components of the horizontal Coriolis force due to
vertical motion and the metric terms involving w so as to conserve energy.
In order to conserve angular momentum, one must also replace r with a
constant radius a as follows:
Du uv tan(θ) 1 ∂p
= 2Ω sin(θ)v + − (15)
Dt a ρa cos(θ) ∂λ
Dv u2 tan(θ) 1 ∂p
= −2Ω sin(θ)v − − (16)
Dt a ρa ∂θ
where
D u ∂ v ∂ ∂
= + +w (17)
Dt a cos(θ) ∂λ a ∂θ ∂z
These are referred to as the primitive equations in the traditional approxi-
mation.
Our equation set now includes 4 prognostic equations, for (u, v, ρ, T ),
with the ideal gas law then determining p. Consistency with the hydrostatic
equation must then determine the vertical motion. This is an awkward im-
plicit system. The problem is simplified if one moves to pressure as a vertical
coordinate. The only change to the equations of motion for v ≡ (u, v) is that
1
∇·p⇒∇·Φ (18)
ρ
where the derivatives on the right are taken at constant pressure. (All vectors
from here on are assumed to lie along the surface of the sphere). In addition,
D u ∂ v ∂ ∂
= + +ω (19)
Dt a cos(θ) ∂λ a ∂θ ∂p
Conservation of mass in pressure coordinates takes the simple form
∂ω
0= +∇·v (20)
∂p
We also have, either by integrating (20) over the atmosphere, or directly
from conservation of mass and the hydrostatic equation, that
Z ps
∂ps
= −∇ · vdp (21)
∂t 0
4
These form a less implicit set of equations, but the lower boundary is
no longer a coordinate surface. In a spectral model, in particular, there
is no alternative to using a terrain following coordinate. The simplest and
traditional choice is Phillips’ sigma-coordinate, σ ≡ p/ps . But rather than
write down these equations and then finite-difference them in the vertical,
it is actually more informative to finite difference the pressure coordinate
equations first by dividing the flow into layers with interfaces defined in a
more general way, as described below.
Vertical differencing
The spectral core uses the vertical differencing described by
pN +1/2 is the surface pressure, ps , while p1/2 is the pressure at the top of the
model, which can be zero, but need not be. However, if it is not zero, we
assume that ∇p1/2 = 0, i.e., that the top of the model is at constant pressure.
We then assume the relationship
Here pref is a constant, chosen to be close to the global mean surface pressure
for convenience. It is included here so as to make A dimensionless, and so
that the values of A lie between 0 and 1. If Ak = 0 for all k, then this reduces
to sigma coordinates, with the choice of Bk0 s determining the level spacing.
One requires that AN +1/2 = 0 so that we have a σ-coordinate at the ground.
5
If Bk = 0 for all k < kp , then we have pressure coordinates above this level.
One should always have B1/2 = 0 .
A natural way of defining a hybrid coordinate (one with A 6= 0 ) is by
first defining a σ-coordinate [Aσk = 0, Bkσ ], then defining the corresponding
p-coordinate, [Apk = Bkσ , Bkp = 0], and finally making a smooth transition
from one to the other
[Ak , Bk ] = γk [Aσk , Bkσ ] + (1 − γk )[Apk , Bkp ] = Bkσ [(1 − γk ), γk ] (24)
where γk is unity near the surface and vanishes near the top of the model.
Much of the following can be generalized to other choices for the defini-
tions of the interfaces between model layers (for example one can transition
to potential temperature rather than pressure coordinates) but none of these
generalizations are currently implemented.
6
If the interface were a material surface, the change in the pressure on it
would be given by the divergence of mass above the interface (the first term
in the equation above). The difference between this pressure tendency and
the actual pressure tendency on the interface gives the mass moving through
the interface. Consistent with the finite-differencing of the surface pressure
equation, MN +1/2 will be identically zero.
In the σ-coordinate special case, M = ps σ̇
Vertical advection
The vertical advection in the spectral model is in advective rather than flux
form, but start with the flux form for a tracer ξ,
∂(ξk ∆k p)
= −∇ · (vk ξk ∆k p) − (Mk+1/2 ξk+1/2 − Mk−1/2 ξk−1/2 ) (29)
∂t
This requires a specification of ξ at the interfaces. Using conservation of
mass for this layer, in the finite-differenced form (27), we can also write this
as
∂ξk 1
= −vk · ∇ξk − (Mk+1/2 (ξk+1/2 − ξk ) + Mk−1/2 (ξk − ξk−1/2 )) (30)
∂t ∆k p
This is the advective form that we use.
Different vertical advection options are defined by different choices for
the interface values of the tracer. A vertical advection module is shared
by our B-grid point and spectral dynamical cores, which provides several
choices: 2nd order centered differencing, 4’th order centered, piecewise linear
finite-volume, and piecewise parabolic finite volume.
The finite volume schemes can be thought of as remappings, in the follow-
ing sense: postulate a sub-grid scale distribution of ξ within each layer, con-
strained by the requirement that the mean of this distribution is the model’s
value of ξ in that layer. Then determine that part of the upstream grid box
that would flow through the interface in question over the given timestep,
assuming uniform flow with the velocity (M ) defined at the interface. Av-
erage ξ over this part of the upstream grid box to define the interfacial ξ.
If the assumed subgrid distribution is simply a constant, this results in the
simplest upstream scheme (which is far to diffusive to be useful). Linear and
parabolic distributions result in usable schemes, the art being to determine
7
the slope in the linear scheme, or the parameters defining the parabola in
the parabolic scheme, to provide features such as monotonicity (producing
no values of the tracer that are outside of the range of values present initially)
with minimal dissipation. See the documentation of the vertical advection
module for details.
which can be summed up from the ground, given the surface geopotential
ΦN +1/2 ≡ Φs . However, the equation of motion require the full-level values
of the geopotential. To obtain these, one must define the full-level pressures,
pk , and then compute
8
or ∂Φ
∇(∆k p Φk ) − Φk (∇pk+1/2 − ∇pk−1/2 ) + ∆k p (36)∇p
∂p k
Temperature equation
One also requires an expression for the term κT ω/p in the temperature equa-
tion. We set
D ln p 1 ∂p 1
(ω/p)k = ( )k = ( )k + (v · ∇p)k + Vk (40)
Dt p ∂t p
where
1 h i
Vk ≡ Mk+1/2 (lnpk+1/2 − lnpk ) + Mk−1/2 (lnpk − lnpk−1/2 ) (41)
∆pk
using the same formulation of the vertical advection of lnp as in (30). The
term involving the horizontal gradient is computed as
1
vk · ( ∇p)k (42)
p
9
where (∇p/p)k is treated just as in the momentum equations. We also have
an expression for ∂p/∂t at the half-levels, from (28).
k
∂pk+1/2 X
=− Dr − Mk+1/2 (43)
∂t r=1
To conserve energy, one must weight these in the same way as in the com-
putation of the pressure gradient
" #
1 ∂p 1 ∂pk+1/2 ∂pk−1/2
( )k = [lnpk+1/2 − lnpk ] + [lnpk − lnpk−1/2 ] (44)
p ∂t ∆pk ∂t ∂t
or
k
" #
1 ∂p 1 X
( )k = − [lnpk+1/2 − lnpk−1/2 ] Dr + [lnpk − lnpk−1/2 ]Dk
p ∂t ∆pk r=1
− Vk (45)
The term Vk involving the vertical mass flux cancels out nicely and we have
k
" #
1 X
(ω/p)k = − [lnpk+1/2 − lnpk−1/2 ] Dr + [lnpk − lnpk−1/2 ]Dk
∆pk r=1
1
+ vk · ( ∇p)k (46)
p
where the last term is computed as in (39). The required term in the tem-
perature equation is then written as κTk (ω/p)k .
Full-level pressures
In the σ-coordinate limit (A = 0), the expression (39) for ∇lnp reduces to
C∇lnps where
1 h i
C≡ (lnpk − lnpk−1/2 )Bk−1/2 + (lnpk+1/2 − lnpk )Bk+1/2
Bk+1/2 − Bk−1/2
(47)
Since ∇lnp ≡ ∇lnps in σ-coordinates, it would be nice if C ≡ 1. This will
be true in the σ-coordinate special case if, more generally,
1 h i
1= (lnpk − lnpk−1/2 )pk−1/2 + (lnpk+1/2 − lnpk )pk+1/2 (48)
∆pk
10
or
pk+1/2 lnpk+1/2 − pk−1/2 lnpk−1/2
lnpk = −1 (49)
∆pk
This can also be written as
where
pk−1/2
αk ≡ 1 − (lnpk+1/2 − lnpk−1/2 ) (51)
∆pk
which is the notation used by Simmons and Burridge. One can think of (49)
as a finite-differencing of the expression
∂(p lnp)
lnp = −1 (52)
∂p
If one takes (48), multiplies by ∆pk and then computes the horizontal gradi-
ent or time derivative, one can rederive the expressions (39) and (44) for the
gradient and time derivative of lnp on the full-level surfaces.
A slight complication occurs if the top of the model is at zero pressure, as
would be true in the σ-coordinate special case, since lnp1/2 is then undefined.
But limp→ 0 plnp = 0, so the natural extension of (49) to this case is
p3/2 lnp3/2
lnp1 = − 1 = lnp3/2 − 1 (53)
p3/2
or
p1 = p3/2 /e. (54)
When p1/2 6= 0 , (49) is used to define p1 .
For an atmosphere in which the temperature is a function of pressure only,
the pressure gradient force in the horizontal equations of motion vanishes
identically, and the two terms into which this force is decomposed in this
coordinate should cancel exactly. An important consequence of the choice
(49) for full-level pressures is that it results in exact cancellation for the
special case of σ-coordinates as long as the temperature is a linear function
of lnp (see Simmons and Burridge).
11
Vorticity/divergence form of equations of motion
Define the vertical advection operator
1
Wk (ξ) ≡ − (Mk+1/2 (ξk+1 − ξk ) + Mk−1/2 (ξk − ξk−1 )) (55)
2∆pk
with the full-level values ξk determined by one’s choice of advection scheme.
The zonal and meridional equations of motion can then be manipulated into
the form
∂uk 1 ∂Ek ∂lnpk
= (f + ζk )vk − ( + RTkv ) + Wk (u) (56)
∂t acos(θ) ∂λ ∂λ
1 ∂v 1 ∂u cos(θ)
ζ≡ − (58)
a cos(θ) ∂λ a cos(θ) ∂θ
and
1
Ek ≡ Φk + (u2k + vk2 ) (59)
2
Rewrite this as
∂uk 1 ∂Ek
= Ak − (60)
∂t acos(θ) ∂λ
∂vk 1 ∂Ek
= Bk − (61)
∂t a ∂θ
where
RTkv ∂lnpk
Ak ≡ (f + ζk )vk − + Wk (u) (62)
acos(θ) ∂λ
RTkv ∂lnpk
Bk ≡ −(f + ζk )uk − + Wk (v) (63)
a ∂θ
We can now easily write these equations in vorticity/divergence form.
With
1 ∂u 1 ∂v cos(θ)
D≡ + (64)
a cos(θ) ∂λ a cos(θ) ∂θ
12
and defining the vectors T ≡ (A, B) and T⊥ ≡ (B, −A), we have
∂ζk
= ∇ · T⊥k (65)
∂t
∂Dk
= ∇ · Tk − ∇2 Ek (66)
∂t
Our system of equations now consists of prognostic equations for ζ, D, T, ln ps
and whatever tracers are included, particularly, specific humidity. The geopo-
tential is computed by integrating up from the surface, with its surface value
set to gz where z is the prescribed orography. The vertical mass fluxes M are
computed by integrating down from the top of the model, where M = 0. The
vorticity, divergence, and temperature are diffused horizontally with a ∇2n
operator, in which one typically chooses n = 2 or 4. If tracers are advected
spectrally, they are also subject to this diffusion. Tracers advected hori-
zontally by the finite-volume scheme (see below) are not subject to explicit
diffusion.
Following the procedure used in nearly all global spectral models, ln ps is
utilized as a prognostic variable
N
∂ ln ps 1 X
=− ∇ · (vk ∆k p) (67)
∂t ps k=1
13
1D decomposition in latitude only, for efficiency hole filling is performed by
looking at nearest neighbors in the latitude-height plane only, and reduces
these values in a uniform ratio to fill in negative values at the central point.
Finally, an optional energy conservation correction is also provided which
corrects the temperature field by adding a globally uniform constant every
time step so as to conserve the sum of cp T and the kinetic energy of the
horizontal flow. (In a hydrostatic model, the vertical integral of cp T is equal
to the vertical integral of the sum of the internal energy cv T and potential
energy gz.) The dynamical core should conserve energy except for the action
of the horizontal n-th harmonic diffusion and the time filter associated with
the leapfrog time step.
Semi-implicit time-stepping
The code uses a standard semi-implicit leapfrog scheme, followed by a Robert-
Asselin time filter.
The semi-implicit aspect of the algorithm allows one to take time steps
that are determined by the strength of the advection, rather that the gravity
wave speeds. This technique is invariably employed in spectral models and
is, in fact, in large part responsible for the predominant use of the spectral
transform algorithm in global atmospheric modeling. Let V represent the
state of the system, and divide the operator N describing the evolution of
this system into two parts, N = NE + NI :
∂V
= NE (V ) + NI (V ) (68)
∂t
Use a centered leapfrog scheme for NE and an implicit scheme for NI :
V i+1 − V i−1
= NE (V i ) + NI (αV i+1 + (1 − α)V i−1 ) (69)
2∆t
We assume that NI is a linear operator in V , otherwise an expensive iteration
would be required to solve this implicit system. The choice of α = 0.5,
centered implicit, is the one typically used, but one can also consider a fully
backward scheme (α = 1.0), for example, if one prefers to damp as well as
slow down the gravity waves.
Using the notation
ξ ≡ 2α∆t, (70)
14
and
V i+1 − V i−1
δV ≡ (71)
2∆t
we find
δV = NE V i + NI V i−1 ) + ξNI (δV ) (72)
or
δV = (1 − ξNI )−1 G (73)
where
G = NE V i + NI (V i−1 ) = N (V i ) + NI (V i−1 − V i ) (74)
We need first of all to define the parts of the equations that are to be part
of the implicit operator NI . This is determined by linearizing the equations
for a non-rotating atmosphere about a state of rest, in which orography is
ignored, surface pressure is uniform, and temperatures are a function of the
vertical coordinate only.
With this simple reference state, the linear matrix to be inverted is di-
agonal in the spectral domain, just as for the shallow water equations. The
different vertical levels are coupled to each other, however.
Our equations for each complex spectral harmonic take the form:
δT = GT + ξLδD (75)
δD = GD + ξ(RδT + U δ ln ps )
δ ln ps = Gln p + ξW δD
15
We compute S −1 at initialization for each harmonic (S depends only on the
total horizontal wavenumber `). On each time step, we first compute all
tendencies with all terms explicit and centered in time. (This procedure has
the advantage that it is easy to return to an explicit model for specialized
purposes and code checkout). We then compute G, being careful to include
the term in (74) that moves the terms treated implicitly from i to i − 1. δD
is then computed by matrix multiplication for each harmonic, and then δT
and δ ln ps are generated by substituting back into 76).
Algorithm
Transforms mod provides several high-level routines for moving from vortic-
ity and divergence to (u, v) and back, as well as for computing the advection
operator −v · ∇ξ. subroutine uv grid from vor div takes as input vorticity
and divergence in the spectral domain and returns (u, v) on the grid. It first
computes (cos(θ)u, cos(θ)v in the spectral domain, then transforms these to
the grid and divides by cos(θ). subroutine vor div from uv grid reverses this
procedure. subroutine horizontal advection computes −v · ∇ξ in the grid do-
main, given ξ in the spectral domain and (u, v) on the grid. It does this by
first computing cos(θ)∇ξ in the spectral domain, transforms the components
to grid space, and then divides by cos(θ) and multiplies by the components of
the velocity field in the grid domain. If one also has available the divergence,
D, on the grid, one can then compute −∇ · (vξ) = −v · ∇ξ − ξD. One could
also compute this quantity using vor div from uv grid. The answer would be
identical.
2: Compute the information that will be needed at the end of the time
step for any global corrections to mass, energy, or water vapor.
16
3: Compute the full and half level values of pressure and log(pressure)
from the surface pressure, as well as the virtual temperature and the
geopotential
5: Using these gradients and the grid divergence, compute the vertical
mass fluxes, the log(surface pressure) tendency (δ ln ps ). and the RT ∇ ln ps
term in (δu, δv), the u and v tendencies
7: Compute (f + ζ)v and −(f + ζ)u on the grid at time t, and add to δu
and δv respectively.
8: compute the divergence and curl of (δu, δv) to obtain δζ and δD in the
spectral domain, using subroutine vor div from uv grid.
11: correct (δT , δD, δ ln ps ) tendencies to take into account the semi-
implicit algorithm, as described above
12: add the (nth-)harmonic damping to δζ, δD, δT in the spectral domain,
treating the damping implicitly, as in the barotropic and shallow water
models
17
16: Update spectral tracers by first computing horizontal advection, adding
on vertical advection, performing hole filling where needed, transferring
the tendency back to the spectral domain, performing leapfrog and time
filter and transforming t + ∆t values back to the grid to prepare for
next step.
Note that we do not bother to compute the new grid values of those fields
modified by the Robert filter.
The finite volume advection scheme follows closely that described in
For backwards compatibility, there is also the option of finally passing the
new grid temperatures and humidities to a second physics routine , for an
adjustment step, after which these adjusted temperatures and humidities are
returned to the spectral domain. In this case, the way in which the time filter
is imposed is modified, as one cannot compute the finalized time t fields from
t − ∆t and t + ∆t until the latter has been finalized. The standard leapfrog
and time filter take the form
• ξ(t + ∆t) = ξ(t − ∆t) + 2∆t dξ/dt
18
• ξ(t + ∆t) = ξ(t − ∆t) + 2∆t dξ/dt
Held-Suarez forcing
When extracted from the FMS repository as an isolated dynamical core,
rather than as a component of a comprehensive model, the spectral model is
packaged to run with the simple forcing defined in
Held, I. M., and M. J. Suarez, 1994: A proposal for the intercomparison of the dy-
namical cores of atmospheric general circulation models. Bulletin of the American Mete-
orological Society, 75(10), 1825-1830.
19