+# steel --cfg and --logs options
+while [ $# -gt 0 ]; do
+ case "$1" in
+ "--cfg="*|"--log="*)
+ for OPT in ${1#*=}
+ do
+ SIMOPTS="$SIMOPTS ${1%%=*}=$OPT"
+ done
+ shift 1
+ ;;
+ *)
+ PROC_ARGS="${PROC_ARGS:+$PROC_ARGS }$1"
+ shift
+ ;;
+ esac
+done
+
+if [ -z "${HOSTFILE}" ] && [ -z "${PLATFORM}" ] ; then
+ echo "No hostfile nor platform specified."
+ usage
+ exit 1
+fi
+
+if [ -z "${HOSTFILE}" ] ; then
+ HOSTFILETMP=1
+ HOSTFILE="$(mktemp smpitmp-hostfXXXXXX)"
+ perl -ne 'print "$1\n" if /.*<host.*?id="(.*?)".*?\/>.*/' ${PLATFORM} > ${HOSTFILE}
+ perl -ne 'if (/.*<cluster.*?prefix="(.*?)".*?radical="(.*?)".*?suffix="(.*?)".*/) {
+ my ($pre,$rad,$post)=($1,$2,$3);
+ for my $elm (split(",",$rad)) {
+ if ($elm=~/^([^-]*?)-([^-]*)$/) {
+ for (my $i=$1; $i<=$2;$i++) {
+ print "$pre$i$post\n";
+ }
+ } else {
+ print "$pre$elm$post\n";
+ }
+ }
+ } elsif (/<cluster/) {
+ die ("Unparsable cluster tag. Either provide an hostfile yourself or give the attributes prefix, radical and suffix in that order on the <cluster line");
+ }' ${PLATFORM} >> ${HOSTFILE}
+fi
+UNROLLEDHOSTFILETMP=0
+
+#parse if our lines are terminated by :num_process
+multiple_processes=`grep -c ":" $HOSTFILE`
+if [ "${multiple_processes}" -gt 0 ] ; then
+ UNROLLEDHOSTFILETMP=1
+ UNROLLEDHOSTFILE="$(mktemp smpitmp-hostfXXXXXX)"
+ perl -ne ' do{ for ( 1 .. $2 ) { print "$1\n" } } if /(.*?):(\d+).*/' ${HOSTFILE} > ${UNROLLEDHOSTFILE}
+ if [ ${HOSTFILETMP} = 1 ] ; then
+ rm ${HOSTFILE}
+ HOSTFILETMP=0
+ fi
+ HOSTFILE=$UNROLLEDHOSTFILE
+fi