#!/usr/bin/perl5
#cardio.pl
#CGI (Common Gateway Interface)
#Roger Kessler, July 16, 1997
#using code developed by
#Bob O'Neill 5/31/96
$server_name = "storm.shodor.org";
$tmp = "/tmp";
&get_request;
&html_header ("CardioWeb");
#Get all variables from form input
#Variables from STELLA
$va=$rqpairs{'va'};
$vv=$rqpairs{'vv'};
$vra=$rqpairs{'vra'};
$ca=$rqpairs{'ca'};
$cv=$rqpairs{'cv'};
$cra=$rqpairs{'cra'};
$ra=$rqpairs{'ra'};
$rv=$rqpairs{'rv'};
$uva=$rqpairs{'uva'};
$uvv=$rqpairs{'uvv'};
$uvra=$rqpairs{'uvra'};
#Other variables
$t=$rqpairs{'t'};
$dt=$rqpairs{'dt'};
$tend=$rqpairs{'tend'};
$style=$rqpairs{'style'};
$prop=$rqpairs{'prop'};
$xmin=$rqpairs{'xmin'};
$xmax=$rqpairs{'xmax'};
$ymin=$rqpairs{'ymin'};
$ymax=$rqpairs{'ymax'};
$graph=$rqpairs{'graph'};
$title=$rqpairs{'title'};
#Run cardio perl code
open (CO, ">$tmp/co$$.dat") || die "Can't open co.dat: $!\n";
open (PA, ">$tmp/pa$$.dat") || die "Can't open pa.dat: $!\n";
open (PV, ">$tmp/pv$$.dat") || die "Can't open pv.dat: $!\n";
open (RAP, ">$tmp/rap$$.dat") || die "Can't open rap.dat: $!\n";
open (VA, ">$tmp/va$$.dat") || die "Can't open va.dat: $!\n";
open (VV, ">$tmp/vv$$.dat") || die "Can't open vv.dat: $!\n";
open (VRA, ">$tmp/vra$$.dat") || die "Can't open vra.dat: $!\n";
for($t=0;$t<=$tend;$t+=$dt) {
$pa=(1./$ca)*($va-$uva);
$pv=(1./$cv)*($vv-$uvv);
$pra=(1./$cra)*($vra-$uvra)-4.;
$fco=1250.*($pra+4.);
if ($pra>=6.) {
$fco=12500.;
}
$fp=($pa-$pv)/$ra;
$fvr=($pv-$pra)/$rv;
$va=$va+($fco-$fp)*$dt;
$vv=$vv+($fp-$fvr)*$dt;
$vra=$vra+($fvr-$fco)*$dt;
print CO "$t $fco\n";
print PA "$t $pa\n";
print PV "$t $pv\n";
print RAP "$t $rap\n";
print VA "$t $va\n";
print VV "$t $vv\n";
print VRA "$t $vra\n";
}
close (CO);
close (PA);
close (PV);
close (RAP);
close (VA);
close (VV);
close (VRA);
#End of model code