GfsOcean

Examples

• Lunar tides in Cook Strait, New Zealand
• ```1 0 GfsOcean GfsBox GfsGEdge {} {
# Set the timestep to sthg small compared to the tidal period
Time { dtmax = 100. }

# Set the box size to 500 km
PhysicalParams { L = 500e3 }

# Use cartographic projection module
GModule map

# Use a Lambert conformal conic projection centered on 174 degrees
# longitude and -40.8 degrees latitude. Rotate the domain 40
# degrees counter-clockwise.
MapProjection { lon = 174 lat = -40.8 angle = 40 }

# Refine to six levels
Refine 6

# We want more accuracy in the projection than the default 1e-3
ApproxProjectionParams { tolerance = 1e-6 nitermax = 10 }

# Initialise tidal amplitudes
Init {} {
A_amp = AM2.gts
B_amp = BM2.gts
}

# Bathymetry
Solid bath.gts

# Refine the coastline to 10 levels
RefineSurface 10 bath.gts { twod = 1 }

# Acceleration of gravity
PhysicalParams { g = 9.81 }

SourceCoriolis -1e-4

# Bottom friction parameterisation:
# Quadratic drag with friction coefficient of 4e-4.
Init { istep = 1 } {
U = U/(1. + dt*Velocity*4e-4/H)
V = V/(1. + dt*Velocity*4e-4/H)
}

# Weak exponential filtering of the velocity field
#    EventFilter { istep = 1 } U 40000
#    EventFilter { istep = 1 } V 40000

# After t=100000, starts on-the-fly harmonic decomposition of the pressure field...
EventHarmonic { start = 100000 istep = 10 } P A B Z EP M2F
# ... and of the velocity field
EventHarmonic { start = 100000 istep = 10 } U AU BU ZU EU M2F
EventHarmonic { start = 100000 istep = 10 } V AV BV ZV EV M2F

# After t=100000, stops the simulation if the variations of the A0
# harmonic component are less than 0.025 in 100 timesteps.
EventStop { start = 100000 istep = 100 } A0 0.025

OutputTime { istep = 1 } stderr
OutputProjectionStats { istep = 1 } stderr

# Output solution on standard output every 20 timesteps
# for on-the-fly visualisation with GfsView.
# Do not include the GTS file for the embedded surface to save bandwidth.
OutputSimulation { istep = 20 } stdout { solid = 0 }

# Output solution in file 'end.gfs' at the end of the simulation
OutputSimulation { start = end } end.gfs

# Output curves using gnuplot
EventScript { start = end } {
cat <<EOF | gnuplot
set term postscript eps lw 3 solid 20 colour
set output 'pv.eps'
set xlabel 'Time (days)'
set ylabel 'Elevation (metres) or Velocity (metres/s)'
plot 'p' u (\\$3/86400.):(\\$9/9.81) w l t "Elevation", \
'u' u (\\$3/86400.):9 w l t "Velocity"
set output 'a0.eps'
set ylabel 'Maximum harmonic elevation (metres)'
plot [1:]'a0' u (\\$3/86400.):(\\$9/9.81) w l t ""
EOF
}

OutputScalarNorm { istep = 1 } p { v = P }
OutputScalarNorm { istep = 1 } u { v = Velocity }
OutputScalarNorm { istep = 10 } a0 { v = sqrt(A0*A0 + B0*B0) }
}
```

• ```1 0 GfsOcean GfsBox GfsGEdge {} {
Time { iend = 1580 dtmax = 1000 }
Refine 6
Global {
#define L0 1000e3
#define H0 1000
#define G 0.01
#define R0 100e3
#define ETA0 599.5
#define F0 1.0285e-4
}
PhysicalParams { L = L0 g = G }
Solid (z + H0)
Init {} {
# e-folding radius = 100 km
# umax = 0.5 m/s = sqrt(200)*exp(-1/2)
P = ETA0*exp (-(x*x + y*y)/(R0*R0))*G
U = 2.*G*ETA0*y/(F0*R0*R0)*exp (-(x*x + y*y)/(R0*R0))
V = - 2.*G*ETA0*x/(F0*R0*R0)*exp (-(x*x + y*y)/(R0*R0))
}
SourceCoriolis F0

AdvectionParams { scheme = none }
ApproxProjectionParams { tolerance = 1e-6 }

OutputErrorNorm { istep = 1 } {
awk '{print \$3/86400. " " \$9; fflush (stdout); }' > e
} { v = P/G } {
s = ETA0*exp (-(x*x + y*y)/(R0*R0))
unbiased = 1
v = E
}
GModule gfsview
OutputView {  istart = 100 iend = 500 istep = 100 } error-%ld.eps { format = EPS } geo.gfv
OutputView {  istart = 1500 } error-%ld.eps { format = EPS } geo.gfv
EventScript { start = end } {
cat <<EOF | gnuplot
set term postscript eps lw 3 color solid 20
set output 'geo_error.eps'
set xlabel 'Time (days)'
set ylabel 'Maximum error on surface height (m)'
plot 'e.ref' t 'ref' w l, 'e' t '' w l
EOF
}
}
```

• Geostrophic adjustment on a beta-plane
• ```1 0 GfsOcean GfsBox GfsGEdge {} {
# dt = 1000 s
Time { iend = 1580 dtmax = 0.10285 }
Refine 6
# Lx = Ly = 1000 km
# H0 = 1000 m
# g = 0.01 m/s^2
PhysicalParams { g = 9.4534734306584e-4 }
ApproxProjectionParams { tolerance = 1e-6 }
Solid (z + 1.)
Init {} {
# e-folding radius = 100 km
# umax = 0.5 m/s = sqrt(200)*exp(-1/2)
U = (5.667583815e-4*200.*y*exp (-100.*(x*x + y*y)))
V = (- 5.667583815e-4*200.*x*exp (-100.*(x*x + y*y)))
P = (5.667583815e-4*exp (-100.*(x*x + y*y)))
}
# f0 = 1.0285e-4 s-1
# beta = 1.607e-11 m-1s-1
SourceCoriolis (1. + 0.156246961595*(y + 0.5))

OutputScalarSum { istep = 150 } {
awk '{print \$3/1.0285e-4/3600./24. " " \$5/9.683940e-11}' > energy
} { v = (Velocity2 + P*P/9.4534734306584e-4) }
}
```

• Coastally-trapped waves
• ```1 0 GfsOcean GfsBox GfsGEdge {} {
Time { end = 37.80501984 dtmax = 0.1 }
PhysicalParams { g = 5.87060327757e-3 }
Global {
#include <gsl/gsl_sf_bessel.h>

#define Ik(k,r,D) (gsl_sf_bessel_Inu ((k) - 1., (r)/(D))/(D)\
- (k)/(r)*gsl_sf_bessel_Inu ((k), (r)/(D)))

static double D = 8.83906519983e-2;
static double k = 3.;
static double sigma = 0.4986;
static double a = 1./2555510.;

static double pwave (double x, double y, double angle) {
double theta = atan2 (y, x) + angle*M_PI/180.;
double r = sqrt (x*x + y*y);
return a*cos (k*theta)*gsl_sf_bessel_Inu (k, r/D);
}

static double ur (double theta, double r) {
return -a*D*D/5.87060327757e-3*sin (k*theta)*(sigma*Ik (k, r, D) -
k/r*gsl_sf_bessel_Inu (k, r/D));
}

static double vt (double theta, double r) {
return a*D*D/5.87060327757e-3*cos (k*theta)*(Ik (k, r, D) -
k*sigma/r*gsl_sf_bessel_Inu (k, r/D));
}

static double uwave (double x, double y) {
double theta = atan2 (y, x);
double r = sqrt (x*x + y*y);
return ur (theta, r)*cos (theta) - vt (theta, r)*sin (theta);
}

static double vwave (double x, double y) {
double theta = atan2 (y, x);
double r = sqrt (x*x + y*y);
return ur (theta, r)*sin (theta) + vt (theta, r)*cos (theta);
}
}
Init {} {
P = pwave(cx, cy, 0)
U = uwave(x, y)
V = vwave(x, y)
# Remove the line below when using gerris3D
H = 1
}
Refine LEVEL
Solid (union (- ellipse (0, 0, 0.49975, 0.49975), z + 1.))
AdvectionParams { scheme = none }
ApproxProjectionParams { tolerance = 1e-9 weighted = 0 }
SourceCoriolis {} 1.
EventFilter { istep = 1 } U 4
EventFilter { istep = 1 } V 4
EventScript { start = end } { echo -n "-30 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -30)
unbiased = 1
}
EventScript { start = end } { echo -n "-29 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -29)
unbiased = 1
}
EventScript { start = end } { echo -n "-28 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -28)
unbiased = 1
}
EventScript { start = end } { echo -n "-27 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -27)
unbiased = 1
}
EventScript { start = end } { echo -n "-26 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -26)
unbiased = 1
}
EventScript { start = end } { echo -n "-25 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -25)
unbiased = 1
}
EventScript { start = end } { echo -n "-24 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -24)
unbiased = 1
}
EventScript { start = end } { echo -n "-23 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -23)
unbiased = 1
}
EventScript { start = end } { echo -n "-22 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -22)
unbiased = 1
}
EventScript { start = end } { echo -n "-21 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -21)
unbiased = 1
}
EventScript { start = end } { echo -n "-20 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -20)
unbiased = 1
}
EventScript { start = end } { echo -n "-19 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -19)
unbiased = 1
}
EventScript { start = end } { echo -n "-18 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -18)
unbiased = 1
}
EventScript { start = end } { echo -n "-17 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -17)
unbiased = 1
}
EventScript { start = end } { echo -n "-16 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -16)
unbiased = 1
}
EventScript { start = end } { echo -n "-15 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -15)
unbiased = 1
}
EventScript { start = end } { echo -n "-14 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -14)
unbiased = 1
}
EventScript { start = end } { echo -n "-13 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -13)
unbiased = 1
}
EventScript { start = end } { echo -n "-12 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -12)
unbiased = 1
}
EventScript { start = end } { echo -n "-11 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -11)
unbiased = 1
}
EventScript { start = end } { echo -n "-10 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -10)
unbiased = 1
}
EventScript { start = end } { echo -n "-9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -9)
unbiased = 1
}
EventScript { start = end } { echo -n "-8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -8)
unbiased = 1
}
EventScript { start = end } { echo -n "-7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -7)
unbiased = 1
}
EventScript { start = end } { echo -n "-6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -6)
unbiased = 1
}
EventScript { start = end } { echo -n "-5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -5)
unbiased = 1
}
EventScript { start = end } { echo -n "-4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -4)
unbiased = 1
}
EventScript { start = end } { echo -n "-3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -3)
unbiased = 1
}
EventScript { start = end } { echo -n "-2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -2)
unbiased = 1
}
EventScript { start = end } { echo -n "-1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -1)
unbiased = 1
}
EventScript { start = end } { echo -n "0 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0)
unbiased = 1
}
EventScript { start = end } { echo -n "0.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.1)
unbiased = 1
}
EventScript { start = end } { echo -n "0.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.2)
unbiased = 1
}
EventScript { start = end } { echo -n "0.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.3)
unbiased = 1
}
EventScript { start = end } { echo -n "0.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.4)
unbiased = 1
}
EventScript { start = end } { echo -n "0.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.5)
unbiased = 1
}
EventScript { start = end } { echo -n "0.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.6)
unbiased = 1
}
EventScript { start = end } { echo -n "0.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.7)
unbiased = 1
}
EventScript { start = end } { echo -n "0.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.8)
unbiased = 1
}
EventScript { start = end } { echo -n "0.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.9)
unbiased = 1
}
EventScript { start = end } { echo -n "1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1)
unbiased = 1
}
EventScript { start = end } { echo -n "1.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.1)
unbiased = 1
}
EventScript { start = end } { echo -n "1.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.2)
unbiased = 1
}
EventScript { start = end } { echo -n "1.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.3)
unbiased = 1
}
EventScript { start = end } { echo -n "1.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.4)
unbiased = 1
}
EventScript { start = end } { echo -n "1.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.5)
unbiased = 1
}
EventScript { start = end } { echo -n "1.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.6)
unbiased = 1
}
EventScript { start = end } { echo -n "1.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.7)
unbiased = 1
}
EventScript { start = end } { echo -n "1.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.8)
unbiased = 1
}
EventScript { start = end } { echo -n "1.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.9)
unbiased = 1
}
EventScript { start = end } { echo -n "2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2)
unbiased = 1
}
EventScript { start = end } { echo -n "2.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.1)
unbiased = 1
}
EventScript { start = end } { echo -n "2.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.2)
unbiased = 1
}
EventScript { start = end } { echo -n "2.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.3)
unbiased = 1
}
EventScript { start = end } { echo -n "2.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.4)
unbiased = 1
}
EventScript { start = end } { echo -n "2.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.5)
unbiased = 1
}
EventScript { start = end } { echo -n "2.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.6)
unbiased = 1
}
EventScript { start = end } { echo -n "2.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.7)
unbiased = 1
}
EventScript { start = end } { echo -n "2.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.8)
unbiased = 1
}
EventScript { start = end } { echo -n "2.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.9)
unbiased = 1
}
EventScript { start = end } { echo -n "3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3)
unbiased = 1
}
EventScript { start = end } { echo -n "3.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.1)
unbiased = 1
}
EventScript { start = end } { echo -n "3.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.2)
unbiased = 1
}
EventScript { start = end } { echo -n "3.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.3)
unbiased = 1
}
EventScript { start = end } { echo -n "3.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.4)
unbiased = 1
}
EventScript { start = end } { echo -n "3.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.5)
unbiased = 1
}
EventScript { start = end } { echo -n "3.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.6)
unbiased = 1
}
EventScript { start = end } { echo -n "3.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.7)
unbiased = 1
}
EventScript { start = end } { echo -n "3.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.8)
unbiased = 1
}
EventScript { start = end } { echo -n "3.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.9)
unbiased = 1
}
EventScript { start = end } { echo -n "4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4)
unbiased = 1
}
EventScript { start = end } { echo -n "4.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.1)
unbiased = 1
}
EventScript { start = end } { echo -n "4.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.2)
unbiased = 1
}
EventScript { start = end } { echo -n "4.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.3)
unbiased = 1
}
EventScript { start = end } { echo -n "4.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.4)
unbiased = 1
}
EventScript { start = end } { echo -n "4.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.5)
unbiased = 1
}
EventScript { start = end } { echo -n "4.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.6)
unbiased = 1
}
EventScript { start = end } { echo -n "4.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.7)
unbiased = 1
}
EventScript { start = end } { echo -n "4.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.8)
unbiased = 1
}
EventScript { start = end } { echo -n "4.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.9)
unbiased = 1
}
EventScript { start = end } { echo -n "5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 5)
unbiased = 1
}
EventScript { start = end } { echo -n "6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 6)
unbiased = 1
}
EventScript { start = end } { echo -n "7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 7)
unbiased = 1
}
EventScript { start = end } { echo -n "8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 8)
unbiased = 1
}
EventScript { start = end } { echo -n "9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 9)
unbiased = 1
}
EventScript { start = end } { echo -n "10 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 10)
unbiased = 1
}
EventScript { start = end } { echo -n "11 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 11)
unbiased = 1
}
EventScript { start = end } { echo -n "12 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 12)
unbiased = 1
}
EventScript { start = end } { echo -n "13 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 13)
unbiased = 1
}
EventScript { start = end } { echo -n "14 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 14)
unbiased = 1
}
EventScript { start = end } { echo -n "15 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 15)
unbiased = 1
}
EventScript { start = end } { echo -n "16 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 16)
unbiased = 1
}
EventScript { start = end } { echo -n "17 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 17)
unbiased = 1
}
EventScript { start = end } { echo -n "18 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 18)
unbiased = 1
}
EventScript { start = end } { echo -n "19 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 19)
unbiased = 1
}
EventScript { start = end } { echo -n "20 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 20)
unbiased = 1
}
EventScript { start = end } { echo -n "21 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 21)
unbiased = 1
}
EventScript { start = end } { echo -n "22 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 22)
unbiased = 1
}
EventScript { start = end } { echo -n "23 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 23)
unbiased = 1
}
EventScript { start = end } { echo -n "24 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 24)
unbiased = 1
}
EventScript { start = end } { echo -n "25 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 25)
unbiased = 1
}
EventScript { start = end } { echo -n "26 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 26)
unbiased = 1
}
EventScript { start = end } { echo -n "27 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 27)
unbiased = 1
}
EventScript { start = end } { echo -n "28 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 28)
unbiased = 1
}
EventScript { start = end } { echo -n "29 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 29)
unbiased = 1
}
EventScript { start = end } { echo -n "30 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 30)
unbiased = 1
}
OutputSimulation { start = end } sim-LEVEL
#  OutputSimulation { istep = 1 } stdout
}
```

• Coastally-trapped waves with adaptive refinement
• ```1 0 GfsOcean GfsBox GfsGEdge {} {
Time { end = 37.80501984 dtmax = 0.1 }
PhysicalParams { g = 5.87060327757e-3 }
Global {
#include <gsl/gsl_sf_bessel.h>

#define Ik(k,r,D) (gsl_sf_bessel_Inu ((k) - 1., (r)/(D))/(D)\
- (k)/(r)*gsl_sf_bessel_Inu ((k), (r)/(D)))

static double D = 8.83906519983e-2;
static double k = 3.;
static double sigma = 0.4986;
static double a = 1./2555510.;

static double pwave (double x, double y, double angle) {
double theta = atan2 (y, x) + angle*M_PI/180.;
double r = sqrt (x*x + y*y);
return a*cos (k*theta)*gsl_sf_bessel_Inu (k, r/D);
}

static double ur (double theta, double r) {
return -a*D*D/5.87060327757e-3*sin (k*theta)*(sigma*Ik (k, r, D) -
k/r*gsl_sf_bessel_Inu (k, r/D));
}

static double vt (double theta, double r) {
return a*D*D/5.87060327757e-3*cos (k*theta)*(Ik (k, r, D) -
k*sigma/r*gsl_sf_bessel_Inu (k, r/D));
}

static double uwave (double x, double y) {
double theta = atan2 (y, x);
double r = sqrt (x*x + y*y);
return ur (theta, r)*cos (theta) - vt (theta, r)*sin (theta);
}

static double vwave (double x, double y) {
double theta = atan2 (y, x);
double r = sqrt (x*x + y*y);
return ur (theta, r)*sin (theta) + vt (theta, r)*cos (theta);
}
}
Init {} {
P = pwave(cx, cy, 0)
U = uwave(x, y)
V = vwave(x, y)
# Remove the line below when using gerris3D
H = 1
}
Refine LEVEL
AdaptVorticity { istep = 1 } { cmax = 5e-2 maxlevel = LEVEL }
Solid (union (- ellipse (0, 0, 0.49975, 0.49975), z + 1.))
AdvectionParams { scheme = none }
ApproxProjectionParams { tolerance = 1e-9 weighted = 0 }
SourceCoriolis {} 1.
EventFilter { istep = 1 } U 4
EventFilter { istep = 1 } V 4
EventScript { start = end } { echo -n "-30 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -30)
unbiased = 1
}
EventScript { start = end } { echo -n "-29 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -29)
unbiased = 1
}
EventScript { start = end } { echo -n "-28 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -28)
unbiased = 1
}
EventScript { start = end } { echo -n "-27 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -27)
unbiased = 1
}
EventScript { start = end } { echo -n "-26 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -26)
unbiased = 1
}
EventScript { start = end } { echo -n "-25 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -25)
unbiased = 1
}
EventScript { start = end } { echo -n "-24 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -24)
unbiased = 1
}
EventScript { start = end } { echo -n "-23 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -23)
unbiased = 1
}
EventScript { start = end } { echo -n "-22 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -22)
unbiased = 1
}
EventScript { start = end } { echo -n "-21 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -21)
unbiased = 1
}
EventScript { start = end } { echo -n "-20 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -20)
unbiased = 1
}
EventScript { start = end } { echo -n "-19 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -19)
unbiased = 1
}
EventScript { start = end } { echo -n "-18 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -18)
unbiased = 1
}
EventScript { start = end } { echo -n "-17 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -17)
unbiased = 1
}
EventScript { start = end } { echo -n "-16 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -16)
unbiased = 1
}
EventScript { start = end } { echo -n "-15 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -15)
unbiased = 1
}
EventScript { start = end } { echo -n "-14 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -14)
unbiased = 1
}
EventScript { start = end } { echo -n "-13 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -13)
unbiased = 1
}
EventScript { start = end } { echo -n "-12 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -12)
unbiased = 1
}
EventScript { start = end } { echo -n "-11 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -11)
unbiased = 1
}
EventScript { start = end } { echo -n "-10 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -10)
unbiased = 1
}
EventScript { start = end } { echo -n "-9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -9)
unbiased = 1
}
EventScript { start = end } { echo -n "-8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -8)
unbiased = 1
}
EventScript { start = end } { echo -n "-7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -7)
unbiased = 1
}
EventScript { start = end } { echo -n "-6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -6)
unbiased = 1
}
EventScript { start = end } { echo -n "-5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -5)
unbiased = 1
}
EventScript { start = end } { echo -n "-4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -4)
unbiased = 1
}
EventScript { start = end } { echo -n "-3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -3)
unbiased = 1
}
EventScript { start = end } { echo -n "-2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -2)
unbiased = 1
}
EventScript { start = end } { echo -n "-1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, -1)
unbiased = 1
}
EventScript { start = end } { echo -n "0 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0)
unbiased = 1
}
EventScript { start = end } { echo -n "0.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.1)
unbiased = 1
}
EventScript { start = end } { echo -n "0.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.2)
unbiased = 1
}
EventScript { start = end } { echo -n "0.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.3)
unbiased = 1
}
EventScript { start = end } { echo -n "0.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.4)
unbiased = 1
}
EventScript { start = end } { echo -n "0.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.5)
unbiased = 1
}
EventScript { start = end } { echo -n "0.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.6)
unbiased = 1
}
EventScript { start = end } { echo -n "0.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.7)
unbiased = 1
}
EventScript { start = end } { echo -n "0.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.8)
unbiased = 1
}
EventScript { start = end } { echo -n "0.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 0.9)
unbiased = 1
}
EventScript { start = end } { echo -n "1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1)
unbiased = 1
}
EventScript { start = end } { echo -n "1.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.1)
unbiased = 1
}
EventScript { start = end } { echo -n "1.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.2)
unbiased = 1
}
EventScript { start = end } { echo -n "1.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.3)
unbiased = 1
}
EventScript { start = end } { echo -n "1.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.4)
unbiased = 1
}
EventScript { start = end } { echo -n "1.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.5)
unbiased = 1
}
EventScript { start = end } { echo -n "1.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.6)
unbiased = 1
}
EventScript { start = end } { echo -n "1.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.7)
unbiased = 1
}
EventScript { start = end } { echo -n "1.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.8)
unbiased = 1
}
EventScript { start = end } { echo -n "1.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 1.9)
unbiased = 1
}
EventScript { start = end } { echo -n "2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2)
unbiased = 1
}
EventScript { start = end } { echo -n "2.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.1)
unbiased = 1
}
EventScript { start = end } { echo -n "2.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.2)
unbiased = 1
}
EventScript { start = end } { echo -n "2.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.3)
unbiased = 1
}
EventScript { start = end } { echo -n "2.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.4)
unbiased = 1
}
EventScript { start = end } { echo -n "2.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.5)
unbiased = 1
}
EventScript { start = end } { echo -n "2.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.6)
unbiased = 1
}
EventScript { start = end } { echo -n "2.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.7)
unbiased = 1
}
EventScript { start = end } { echo -n "2.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.8)
unbiased = 1
}
EventScript { start = end } { echo -n "2.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 2.9)
unbiased = 1
}
EventScript { start = end } { echo -n "3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3)
unbiased = 1
}
EventScript { start = end } { echo -n "3.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.1)
unbiased = 1
}
EventScript { start = end } { echo -n "3.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.2)
unbiased = 1
}
EventScript { start = end } { echo -n "3.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.3)
unbiased = 1
}
EventScript { start = end } { echo -n "3.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.4)
unbiased = 1
}
EventScript { start = end } { echo -n "3.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.5)
unbiased = 1
}
EventScript { start = end } { echo -n "3.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.6)
unbiased = 1
}
EventScript { start = end } { echo -n "3.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.7)
unbiased = 1
}
EventScript { start = end } { echo -n "3.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.8)
unbiased = 1
}
EventScript { start = end } { echo -n "3.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 3.9)
unbiased = 1
}
EventScript { start = end } { echo -n "4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4)
unbiased = 1
}
EventScript { start = end } { echo -n "4.1 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.1)
unbiased = 1
}
EventScript { start = end } { echo -n "4.2 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.2)
unbiased = 1
}
EventScript { start = end } { echo -n "4.3 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.3)
unbiased = 1
}
EventScript { start = end } { echo -n "4.4 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.4)
unbiased = 1
}
EventScript { start = end } { echo -n "4.5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.5)
unbiased = 1
}
EventScript { start = end } { echo -n "4.6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.6)
unbiased = 1
}
EventScript { start = end } { echo -n "4.7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.7)
unbiased = 1
}
EventScript { start = end } { echo -n "4.8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.8)
unbiased = 1
}
EventScript { start = end } { echo -n "4.9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 4.9)
unbiased = 1
}
EventScript { start = end } { echo -n "5 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 5)
unbiased = 1
}
EventScript { start = end } { echo -n "6 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 6)
unbiased = 1
}
EventScript { start = end } { echo -n "7 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 7)
unbiased = 1
}
EventScript { start = end } { echo -n "8 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 8)
unbiased = 1
}
EventScript { start = end } { echo -n "9 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 9)
unbiased = 1
}
EventScript { start = end } { echo -n "10 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 10)
unbiased = 1
}
EventScript { start = end } { echo -n "11 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 11)
unbiased = 1
}
EventScript { start = end } { echo -n "12 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 12)
unbiased = 1
}
EventScript { start = end } { echo -n "13 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 13)
unbiased = 1
}
EventScript { start = end } { echo -n "14 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 14)
unbiased = 1
}
EventScript { start = end } { echo -n "15 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 15)
unbiased = 1
}
EventScript { start = end } { echo -n "16 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 16)
unbiased = 1
}
EventScript { start = end } { echo -n "17 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 17)
unbiased = 1
}
EventScript { start = end } { echo -n "18 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 18)
unbiased = 1
}
EventScript { start = end } { echo -n "19 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 19)
unbiased = 1
}
EventScript { start = end } { echo -n "20 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 20)
unbiased = 1
}
EventScript { start = end } { echo -n "21 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 21)
unbiased = 1
}
EventScript { start = end } { echo -n "22 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 22)
unbiased = 1
}
EventScript { start = end } { echo -n "23 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 23)
unbiased = 1
}
EventScript { start = end } { echo -n "24 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 24)
unbiased = 1
}
EventScript { start = end } { echo -n "25 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 25)
unbiased = 1
}
EventScript { start = end } { echo -n "26 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 26)
unbiased = 1
}
EventScript { start = end } { echo -n "27 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 27)
unbiased = 1
}
EventScript { start = end } { echo -n "28 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 28)
unbiased = 1
}
EventScript { start = end } { echo -n "29 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 29)
unbiased = 1
}
EventScript { start = end } { echo -n "30 " }
OutputCorrelation { start = end } stdout { v = P } {
s = pwave(cx, cy, 30)
unbiased = 1
}
OutputSimulation { start = end } sim-LEVEL
}
```

• Gravity waves in a realistic ocean basin
• ```1 0 GfsOcean GfsBox GfsGEdge {} {
# Set the timestep to sthg small compared to the tidal period
Time { dtmax = 1e-2 end = 28.5 }
# Refine to six levels
Refine 6
# We want more accuracy in the projection than the default 1e-3
ApproxProjectionParams { tolerance = 1e-6 nitermax = 10 }
AdvectionParams { scheme = none }
Init {} { P = 1e-2*x }
# Bathymetry
Solid bath.gts
# Refine the coastline to 7 levels
RefineSurface 7 bath.gts { twod = 1 }
# Non-dimensional gravity
PhysicalParams { g = 19.62 }

OutputPPM { start = 2 } { convert ppm:- p.eps } { v = P min = -5e-3 max = 5e-3 }
OutputScalarSum { istep = 10 } k { v = Velocity2 }
EventScript { start = end } {
gnuplot <<EOF
set term postscript eps color lw 3 solid 20
set output 'k.eps'
set xlabel 'Time'
set ylabel 'Kinetic energy'
set grid
plot 'k' u 3:5 w l t ''
EOF
if awk '{if (\$5 > 6e-12) exit (1);}' < k ; then
return 0;
else
return \$GFS_STOP;
fi
}
}
```

• Rossby--Haurwitz wave with a free surface
• ```6 12 GfsOcean GfsBox GfsGEdge {} {
Global {
#define AR 6.37122e6
#define N 4.
#define Umax 50.
#define M (Umax/(N*AR))
#define K M

#define Omega 7.292e-5
#define G 9.806116
#define DTR (M_PI/180.)

// Williamson 1992, eq. (137)
static double u0 (double lambda, double phi) {
double cosphi = cos (phi), sinphi = sin (phi);
return AR*M*cosphi + AR*K*pow (cosphi, N - 1)*
cos (N*lambda)*(N*sinphi*sinphi - cosphi*cosphi);
}

// Williamson 1992, eq. (138)
static double v0 (double lambda, double phi) {
double cosphi = cos (phi), sinphi = sin (phi);
return - AR*K*N*pow (cosphi, N - 1)*sinphi*sin (N*lambda);
}

// Williamson 1992, eq. (139)
static double vorticity0 (double lambda, double phi) {
return 2.*M*sin(phi) - K*sin(phi)*pow (cos (phi), N)*(N*N + 3.*N + 2.)*cos (N*lambda);
}

// Williamson 1992, eqs. (140-143)
static double p0 (double lambda, double phi, double t) {
double nu = (N*(3. + N)*M - 2.*Omega)/((1. + N)*(2. + N));
lambda -= nu*t;
double cosphi = cos (phi);
double Aphi = M/2.*(2.*Omega + M)*cosphi*cosphi + K*K/4.*pow (cosphi, 2.*N)*
((N + 1.)*cosphi*cosphi + 2.*N*N - N - 2. - 2.*N*N*pow(cosphi, -2.));
double Bphi = 2.*(Omega + M)*K/((N + 1.)*(N + 2.))*pow(cosphi, N)*
(N*N + 2.*N + 2. - (N + 1.)*(N + 1.)*cosphi*cosphi);
double Cphi = K*K/4.*pow(cosphi,2.*N)*((N + 1.)*cosphi*cosphi - (N + 2.));
return AR*AR*(Aphi + Bphi*cos (N*lambda) + Cphi*cos (2.*N*lambda));
}
}
PhysicalParams {
L = 2.*M_PI*AR/4.
# g*H0
g = G*8e3
}
MetricCubed M LEVEL
SourceCoriolis 2.*Omega*sin(y*DTR)

Init {} {
(U,V) = (u0(x*DTR,y*DTR), v0(x*DTR,y*DTR))
P = p0(x*DTR,y*DTR,0)
# fixme: it would be more logical to set H = H0 and g = 9.806116
H = 1
}

ApproxProjectionParams { tolerance = 1e-9 }

Refine LEVEL

# ~24 days
Time { end = 2073534 dtmax = 1e3 }
#    OutputTime { istep = 1 } stderr
#    OutputProjectionStats { istep = 1 } stderr

OutputScalarNorm { istep = 10 } v-LEVEL { v = V }
OutputScalarSum { istep = 10 } ec-LEVEL { v = Velocity2 }
OutputScalarSum { istep = 10 } zeta-LEVEL { v = Vorticity }
OutputScalarSum { istep = 10 } p-LEVEL { v = P }
OutputErrorNorm { istart = 1 istep = 10 } eh-LEVEL { v = P/G } {
s = p0(x*DTR,y*DTR,t)/G
v = EH unbiased = 1 relative = 1
}
OutputSimulation { start = end } end-LEVEL.gfs
#    OutputSimulation { istep = 10 } stdout

GModule gfsview
OutputView { start = end } ehp-LEVEL.gnu { format = Gnuplot } ehp.gfv
OutputView { start = end } ehm-LEVEL.gnu { format = Gnuplot } ehm.gfv
OutputView { start = end } h-LEVEL.gnu { format = Gnuplot } h.gfv
OutputView { start = end } href-LEVEL.gnu { format = Gnuplot } href.gfv
}
```