#!/usr/bin/perl
#

$debug = 0;

$phot_dist_exe = "/z1/snap/zero_point/progs/phot_dist";
$omega_matter = 0.3;
$omega_lambda = 0.7;

# compromise for all SNe
$peak_abs_mag = -18.5;

$dz = 0.01;
$z = 0.01;
while ($z <= 2.0) {

 
  $cmd = sprintf "%s %lf %lf %lf", $phot_dist_exe, 
             $omega_matter, $omega_lambda, $z;
  if ($debug > 0) {
    printf " cmd is ..%s.. \n", $cmd;
  }
  $ret = `$cmd`;
  if ($debug > 0) {
    printf " ret is ..%s.. \n", $ret;
  }
  @words = split(/\s+/, $ret);
  if ($debug > 0) {
    for ($i = 0; $i <= $#words; $i++) {
      printf " words %3d is ..%s.. \n", $i, $words[$i];
    }
  }
  $dist_mod = $words[1];

  $peak_mag = $dist_mod + $peak_abs_mag;

  printf " %6.2f %6.2f \n", $z, $peak_mag;
  
  if ($z >= 0.099) {
    $dz = 0.10;
  }
  if ($debug > 0) {
    printf "about to add %5.3f to %5.2f \n", $dz, $z;
  }
  $z += $dz;
  if ($debug > 0) {
    printf " now z is %6.3f \n", $z;
  }

}







exit 0;
