1 0 GfsRiver GfsBox GfsGEdge {} {
    PhysicalParams { L = 8. }
    RefineSolid 9

    # Set a solid boundary close to the top boundary to limit the
    # domain width to one cell (i.e. a 1D domain)
    Solid (y - 3.9999)

    # Set the topography Zb and the initial water surface elevation P
    Init {} {
	Zb = x*x/8.+cos(M_PI*x)/2.
	P = {
	    double p = x > 0. ? 0.35 : x < -2. ? 1.9 : -1.;
	    return MAX (0., p - Zb);
	}
    }
    PhysicalParams { g = 1. }

    # Use a first-order scheme rather than the default second-order
    # minmod limiter. This is just to add some numerical damping.
    AdvectionParams {
       # gradient = gfs_center_minmod_gradient
	gradient = none
    }

    Time { end = 40 }
    OutputProgress { istep = 10 } stderr
    OutputScalarSum { istep = 10 } ke { v = (P > 0. ? U*U/P : 0.) }
    OutputScalarSum { istep = 10 } vol { v = P }
    OutputScalarNorm { istep = 10 } u { v = (P > 0. ? U/P : 0.) }

    # Save a text-formatted simulation
    OutputSimulation { step = 0.5 } sim-%g.txt { format = text }

    # Use gnuplot to create gif images
    EventScript { step = 0.5 } {
	time=`echo $GfsTime | awk '{printf("%4.1f\n", $1);}'`
	cat <<EOF | gnuplot
load 'dam.plot'
set title "t = $time"
set term postscript eps color 14
set output "sim.eps"
plot [-4.:4.]'sim-$GfsTime.txt' u 1:7:8 w filledcu lc 3, 'sim-0.txt' u 1:7 w l lw 4 lc 1 lt 1
EOF
	time=`echo $GfsTime | awk '{printf("%04.1f\n", $1);}'`
	convert -density 300 sim.eps -trim +repage -bordercolor white -border 10 -resize 640x282! sim-$time.gif
	rm -f sim.eps
    }

    # Combine all the gif images into a gif animation using gifsicle
    EventScript { start = end } {
	gifsicle --colors 256 --optimize --delay 25 --loopcount=0 sim-*.gif > dam.gif
	rm -f sim-*.gif sim-*.txt
    }
}
GfsBox {
    left = Boundary
    right = Boundary
}