#windconv.cgi by Tim Brice NWS El Paso
if ($wc{units} eq knots) {
$windb = $wc{wind};
}
elsif ($wc{units} eq MPH) {
$windb = $wc{wind} * 0.868391;
}
elsif ($wc{units} eq KperH) {
$windb = $wc{wind} * 0.539593;
}
else {
$windb = $wc{wind} * 1.94254;
}
if ($windb < 1) {
$beaufort = 'Calm';
$force = 0;
} elsif ($windb < 4) {
$beaufort = 'Light air';
$force = 1;
} elsif ($windb < 7) {
$beaufort = 'Light breeze';
$force = 2;
} elsif ($windb < 11) {
$beaufort = 'Gentle breeze';
$force = 3;
} elsif ($windb < 17) {
$beaufort = 'Moderate breeze';
$force = 4;
} elsif ($windb < 22) {
$beaufort = 'Fresh breeze';
$force = 5;
} elsif ($windb < 28) {
$beaufort = 'Strong breeze';
$force = 6;
} elsif ($windb < 34) {
$beaufort = 'Strong breeze';
$force = 7;
} elsif ($windb < 41) {
$beaufort = 'Gale';
$force = 8;
} elsif ($windb < 48) {
$beaufort = 'Gale';
$force = 9;
} elsif ($windb < 56) {
$beaufort = 'Whole Gale';
$force = 10;
} elsif ($windb <= 62) {
$beaufort = 'Whole Gale';
$force = 11;
} elsif ($windb > 62) {
$beaufort = 'Hurricane';
$force = 12;
} else {
$beaufort = 'unknown';
$force = 'unknown';
}
if ($wc{units} eq knots) {
if ($wc{wind} =~ /(\d+)\.?(\d+)|^\d+$/) {
$MPH = $wc{wind} * 1.15155;
$MperS = $wc{wind} * 0.514791;
$KMH = $wc{wind} * 1.85325;
$~ = "WC1";
write;
format WC1 =
A wind speed of @##.# knots equals:
$wc{wind}
@##.# Miles per Hour
$MPH
@##.# Meters per Second
$MperS
@##.# Kilometers per Hour
$KMH
Beaufort Scale: Force @##, @<<<<<<<<<<<<<<<
$force $beaufort
.
} else {
print "An illegal character was entered.\n";
die
}
}
elsif ($wc{units} eq MPH) {
if ($wc{wind} =~ /(\d+)\.?(\d+)|^\d+$/) {
$knots = $wc{wind} * 0.868391;
$MperS = $wc{wind} * 0.44704;
$KMH = $wc{wind} * 1.609344;
$~ = "WC2";
write;
format WC2 =
A wind speed of @##.# Miles per Hour equals:
$wc{wind}
@##.# Knots
$knots
@##.# Meters per Second
$MperS
@##.# Kilometers per Hour
$KMH
Beaufort Scale: Force @##, @<<<<<<<<<<<<<<<
$force $beaufort
.
} else {
print "An illegal character was entered.\n";
die
}
}
elsif ($wc{units} eq KperH) {
if ($wc{wind} =~ /(\d+)\.?(\d+)|^\d+$/) {
$knots = $wc{wind} * 0.539593;
$MperS = $wc{wind} * 0.277778;
$MPH = $wc{wind} * 0.621371;
$~ = "WC3";
write;
format WC3 =
A wind speed of @##.# Kilometers per Hour equals:
$wc{wind}
@##.# Knots
$knots
@##.# Meters per Second
$MperS
@##.# Miles per Hour
$MPH
Beaufort Scale: Force @##, @<<<<<<<<<<<<<<<
$force $beaufort
.
} else {
print "An illegal character was entered.\n";
die
}
} else {
if ($wc{wind} =~ /(\d+)\.?(\d+)|^\d+$/) {
$knots = $wc{wind} * 1.94254;
$MPH = $wc{wind} * 2.23694;
$KMH = $wc{wind} * 3.6;
$~ = "WC4";
write;
format WC4 =
A wind speed of @##.# Meters per Second equals:
$wc{wind}
@##.# Knots
$knots
@##.# Miles per Hour
$MPH
@##.# Kilometers per Hour
$KMH
Beaufort Scale: Force @##, @<<<<<<<<<<<<<<<
$force $beaufort
.
}
}