#!/usr/local/bin/perl
#
$prog	   = "/f/mwhite/work/lyasim/tau2flux";
$power     = "/f/mwhite/work/lyasim/fluxpk";
$delpk     = "/f/mwhite/work/lyasim/delpk";
$base      = "/cdm3/www/mwhite/htdocs/Lya";
$nout      = 10;
$species   = "H";
@modellist = ( "OS30A", "OS30B", "OS30C");
@filterlist= ( "nj", "ej", "lj" );

@zz     = (8.50, 6.00, 5.50, 5.00, 4.00, 3.89, 3.10, 3.00, 2.75, 2.41);
for ($iout=0; $iout<$nout; $iout++) {
  @taueff[$iout] = 0.0028*exp(3.46*log(1+@zz[$iout]));
}
@taueff = (6.76, 2.54, 2.54, 2.12, 0.73, 0.63, 0.37, 0.36, 0.30, 0.20);

  foreach $model (@modellist) {

    print "Changing to directory $base/$model\n";
    chdir("$base/$model");

    foreach $filter (@filterlist) {

      for ($iout=0; $iout < $nout; $iout++) {
#        $cmd = sprintf "%s tau_%s_%d.dat %f %f > flux_%d.dat",
#          $prog,$species,$iout,@zz[$iout],@taueff[$iout],$iout;
#        print "$cmd\n";  $output=`$cmd`;
#        if ($output) {print "$output";}
#
#        $cmd = sprintf "gzip -f flux_%d.dat",$iout;
#        print "$cmd\n";  $output=`$cmd`;
#        if ($output) {print "$output";}
#
        $cmd = sprintf "%s tau_%s_%s_%d.dat %f %f > power_%s_%d.dat",
          $power,$species,$filter,$iout,@zz[$iout],@taueff[$iout],
          $filter,$iout;
        print "$cmd\n";  $output=`$cmd`;
        if ($output) {print "$output";}
#
        $cmd = sprintf "%s del_%s_%d.dat > delpk_%s_%d.dat",
          $delpk,$filter,$iout,$filter,$iout;
        print "$cmd\n";  $output=`$cmd`;
        if ($output) {print "$output";}
      }
    }
    `chmod og+r \*`;
  }
