#!/usr/bin/perl
#
# Run "flam_mag" over several stars and several filters
#   in order to determine synthetic magnitudes
#
# MWR 3/14/2008
#
# Modified to deal with the "8B" filterset.
#
# MWR 3/17/2008

$debug = 1;

@filter_list = ("2", "6", "8");
@star_list = ("o5v", "b0v", "a0v", "f0v", "a0v", "g0v", "k0v", "m0v", "m5v");

foreach $star (@star_list) {
  if ($debug > 0) {
    printf "next is star %s\n", $star;
  }
  $star_file = sprintf "uk%s_dat", $star;
  if ($debug > 0) {
    printf "next is star_file %s\n", $star_file;
  }

  foreach $filter (@filter_list) {
    if ($debug > 0) {
      printf "next is filter %s\n", $filter;
    }
    $filter_file = sprintf "../b8_filters/b8_%s.filter", $filter;
    if ($debug > 0) {
      printf "next is filter_file %s\n", $filter_file;
    }

    $cmd = sprintf "./flam_mag $star_file $filter_file 0 0 strict ";
    $cmd .= sprintf " > conv_%s_b8_%s.dat", $star, $filter;
    exec_cmd($cmd);

  }
  

}


exit 0;



##############################################################################
# PROCEDURE: exec_cmd
#
# DESCRIPTION: Execute the given shell command line.  If the $debug flag
#              is set, we print to stdout the command line, and
#              also print out the result string.
#
# RETURNS:
#              the result of the command
#
#
sub exec_cmd {

  my($cmd, $ret);

  $cmd = $_[0];

  if ($debug > 0) {
    printf "cmd is ..$cmd.. \n";
  }
  $ret = `$cmd`;
  if ($debug > 0) {
    printf "ret is ..$ret.. \n";
  }

  return($ret);
}


