#!/bin/sh 
#!perl
eval 'exec perl -x -S -w $0 "$@";'
    if 0;


%dir_val = (
  'Linux' => {
    'alpha' => "/ufs/gm/ruth/mpich_alpha/mpich/examples/basic",
    'i386'  => "/ufs/gm/ruth/mpich/examples/basic",
    'i486'  => "/ufs/gm/ruth/mpich/examples/basic",
    'i586'  => "/ufs/gm/ruth/mpich/examples/basic",
    'i686'  => "/ufs/gm/ruth/mpich/examples/basic",
    'i786'  => "/ufs/gm/ruth/mpich/examples/basic",
  },
  'other' => {
    'alpha' => "/ufs/gm/ruth/mpich_alpha/mpich/examples/basic",
    'i386'  => "/ufs/gm/ruth/mpich/examples/basic",
    'i486'  => "/ufs/gm/ruth/mpich/examples/basic",
    'i586'  => "/ufs/gm/ruth/mpich/examples/basic",
    'i686'  => "/ufs/gm/ruth/mpich/examples/basic",
    'i786'  => "/ufs/gm/ruth/mpich/examples/basic",
  },
);


$mach_type = `uname -m`;
chomp $mach_type;

#print "$mach_type\n";

$op_type = `uname -s`;
chomp $op_type;

#print "$op_type\n";

$mget= '';
$mrel = '';

$cmd = "./cpi";

$verbose = 1;

$display=$ENV{'DISPLAY'};
print "DISPLAY = $display\n" if $verbose;
$gmpi_conf=$ENV{'GMPI_CONF'};
print "GMPI_CONF = $gmpi_conf\n" if $verbose;
$gmpi_opts=$ENV{'GMPI_OPTS'};
print "GMPI_OPTS = $gmpi_opts\n" if $verbose;

$varenv .= " DISPLAY=$display" if $display;
$varenv .= " GMPI_CONF=$gmpi_conf";
$varenv .= " GMPI_OPTS=$gmpi_opts";

$the_args = '';
if (@ARGV > 0) {
    @the_args = (@ARGV[0..$#ARGV]);
}
$the_args = [@the_args];
$cmd_arg = "@{$the_args}";

#print "cmd args are: $cmd_arg\n";


#if ($mach_type eq 'alpha' ) {
#  $dir = "/ufs/gm/ruth/mpich_alpha/mpich/examples/basic";
#  print "set alpha dir\n"
#} elsif ($mach_type =~ /i\d86/ ) {
#  $dir = "/ufs/gm/ruth/mpich/examples/basic";
#  print "set i686 dir\n"
#}

$dir = $dir_val{$op_type}{$mach_type};

$cmdline = "cd $dir;$mget env $varenv $cmd $cmd_arg $mrel";    

#print "starting $cmdline\n";

system($cmdline);


