#!/usr/bin/perl
# SlopeArea.pl
# Computes Discharge by Slope Area Method 
# Use HMTL POST method


use warnings;
use strict;
use CGI qw( :standard );

my $manning_n = param( "manning_n");
my $area = param( "area" );
my $perimeter = param( "perimeter" );
my $slope = param( "slope" );

my $radius = $area/$perimeter;
my $discharge = (1.49/$manning_n)*($area)*($radius**(2/3))*($slope**(1/2));
my $velocity = $discharge/$area;
print header(), start_html( 'Slope-Area Method (US Customary)' );
print "Discharge by Slope-Area Method <br/><br/> ";
print "Run Date: ",scalar(localtime ())," <br/><br/>" ;
print "------ INPUT AND INTERMEDIATE VALUES ------ <br/> ";
print p('        Manning n = ', b( $manning_n ) );
print p('        Flow area = ', b( $area ), ' square feet ') ;
print p(' Wetted Perimeter = ', b( $perimeter), ' feet ') ;
print p('      Hyd. Radius = ', b( $radius ), ' feet ' ) ;
print p('            Slope = ', b( $slope ) );
print "------ COMPUTED DISCHARGE AND VELOCITY ----- <br/> ";
print p('Discharge = ', b( $discharge ), ' cfs ' );
print p('Mean Section Velocity = ', b( $velocity), ' ft/sec ' );
end_html();

# end of script
