#!/bin/sh
#
# script to generate MPIhosts file for MPI
#
# B. Massingill, 01/24/2002
#
# generate list of machines for which (1) name contains "pattern"
#   and (2) ruptime reports an "up" status
# result replaces file MPIhost in the current directory (old
#   MPIhosts file is copied to MPIhosts.bak first)
#
# usage:
#   make-MPIhosts [pattern]
#
# "pattern" is optional; if omitted, the default is to list all JanusXX,
#   XenaXX, AtlasXX, and DwarfX machines, and SnowWhite
# usage example -- to list only the AtlasXX machines that are up:
#   make-MPIhosts Atlas
#

if [ ".$1" = "." ]
then
	pattern="Atlas|Janus|Xena|Dwarf|SnowWhite"
else
	pattern=$1
fi

if [ -r MPIhosts ]
then
	/bin/mv MPIhosts MPIhosts.bak
fi

ruptime | egrep -i "$pattern" \
	| grep -v down | cut -f1 -d' ' | sed 's/$/.cs.trinity.edu/' \
	> MPIhosts