Index
# Illustrate depth-dependence of ocean sound speed.
system perl >tmp <<"EOF"
sub sound_speed ($$$;) { # T, S, p 
    $T = $_[0];
    $S = $_[1];
    $p = $_[2];
    return (1449 
	    + 4.6 * $T 
	    - 0.055 * $T * $T + 0.0003 * $T * $T * $T
	    + (1.39 - 0.012 * $T) * ($S - 25)
	    + 0.017 * $p);
}
sub T_of_z ($;) { # canonical ocean temperature profile
    $z = $_[0];
    return (3 + 20 * exp(-$z / 300));
}
for ($p = 0; $p < 4000; $p += 10) {
    print $p, ' ', sound_speed(T_of_z($p), 35, $p), "\n";
}
EOF
set x size 5
set y name "Depth, m"
set x name "Sound Speed, m/s"
set x axis 1490 1550 20 10
set y axis 4000 0 -1000 -100

draw axes none			# would be whited out by next!
set color hsb {rpn 244 360 /} 0.13 0.98
draw box filled ..xleft.. ..ybottom.. ..xright.. ..ytop..
set color white
set line width rapidograph 0
draw lines vertically 1490 1550 10
draw lines horizontally 0 4000 500
set color black
draw axes frame
draw x axis at top
draw y axis at left

open tmp
read columns y x
draw curve
set color blue
set line width rapidograph 2
draw curve
set font size 18
set color black
# The min is at:
# 830 1495.10950099642
.s_min. = 1495
.s_lab. = {rpn .s_min. 20 +}
.z_min. = 830
set line width rapidograph 1
draw arrow from .s_lab. .z_min. to .s_min. .z_min.
draw label "Minimum" at \
    {rpn .s_lab. xusertocm "M" width 2 / +} \
    {rpn .z_min. yusertocm "M" ascent 2 / -} \
    cm
system rm -f tmp