X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f0446c8f827c76c8f59790b1ab87e66f3eb8c319..93930744c818285a426e426c674c84275269a7f8:/examples/smpi/replay_multiple/generate_multiple_deployment.sh diff --git a/examples/smpi/replay_multiple/generate_multiple_deployment.sh b/examples/smpi/replay_multiple/generate_multiple_deployment.sh index 5b1ceed93f..1288fcbb12 100755 --- a/examples/smpi/replay_multiple/generate_multiple_deployment.sh +++ b/examples/smpi/replay_multiple/generate_multiple_deployment.sh @@ -1,7 +1,6 @@ #! /bin/sh -# Copyright (c) 2007-2014. The SimGrid Team. -# All rights reserved. +# Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. @@ -20,8 +19,6 @@ then exit fi -EXTOPT="" -WRAPPER="" HOSTFILE="" while true; do @@ -29,7 +26,7 @@ while true; do "-platform") PLATFORM="$2" if [ ! -f "${PLATFORM}" ]; then - echo "[`basename $0`] ** error: the file '${PLATFORM}' does not exist. Aborting." + echo "[$(basename $0)] ** error: the file '${PLATFORM}' does not exist. Aborting." exit 1 fi shift 2 @@ -37,7 +34,7 @@ while true; do "-hostfile") HOSTFILE="$2" if [ ! -f "${HOSTFILE}" ]; then - echo "[`basename $0`] ** error: the file '${HOSTFILE}' does not exist. Aborting." + echo "[$(basename $0)] ** error: the file '${HOSTFILE}' does not exist. Aborting." exit 1 fi shift 2 @@ -45,7 +42,7 @@ while true; do "-machinefile") HOSTFILE="$2" if [ ! -f "${HOSTFILE}" ]; then - echo "[`basename $0`] ** error: the file '${HOSTFILE}' does not exist. Aborting." + echo "[$(basename $0)] ** error: the file '${HOSTFILE}' does not exist. Aborting." exit 1 fi shift 2 @@ -88,7 +85,7 @@ fi UNROLLEDHOSTFILETMP=0 #parse if our lines are terminated by :num_process -multiple_processes=`grep -c ":" $HOSTFILE` +multiple_processes=$(grep -c ":" $HOSTFILE) if [ "${multiple_processes}" -gt 0 ] ; then UNROLLEDHOSTFILETMP=1 UNROLLEDHOSTFILE="$(mktemp tmphostXXXXXX)" @@ -101,9 +98,9 @@ if [ "${multiple_processes}" -gt 0 ] ; then fi # Don't use wc -l to compute it to avoid issues with trailing \n at EOF -hostfile_procs=`grep -c "[a-zA-Z0-9]" $HOSTFILE` +hostfile_procs=$(grep -c "[a-zA-Z0-9]" $HOSTFILE) if [ ${hostfile_procs} = 0 ] ; then - echo "[`basename $0`] ** error: the hostfile '${HOSTFILE}' is empty. Aborting." >&2 + echo "[$(basename $0)] ** error: the hostfile '${HOSTFILE}' is empty. Aborting." >&2 exit 1 fi @@ -114,20 +111,18 @@ APPLICATIONTMP=$(echo ${PROC_ARGS}|cut -d' ' -f2 -s) cat > ${APPLICATIONTMP} < - + APPLICATIONHEAD ##---- cache hostnames of hostfile--------------- if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then - hostnames=$(cat ${HOSTFILE} | tr '\n\r' ' ') - NUMHOSTS=$(cat ${HOSTFILE} | wc -l) + hostnames=$(tr '\n\r' ' ' < ${HOSTFILE}) + NUMHOSTS=$(wc -l < ${HOSTFILE}) fi DESCRIPTIONFILE=$(echo $PROC_ARGS|cut -d' ' -f1) if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then - NUMINSTANCES=$(cat ${DESCRIPTIONFILE} | wc -l) - replayinstances=$(cat ${DESCRIPTIONFILE}) IFS_OLD=$IFS IFS=$'\n' set -f @@ -138,23 +133,23 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then IFS_OLD= # generate three lists, one with instance id, ont with instance size, one with files instance=$(echo "$line"|cut -d' ' -f1) - hosttrace=$(cat $(echo "$line"|cut -d' ' -f2)| tr '\n\r' ' ' ) - NUMPROCSMINE=$(cat $(echo "$line"|cut -d' ' -f2) | wc -l) + hosttrace=$(tr '\n\r' ' ' < $(echo "$line"|cut -d' ' -f2)) + NUMPROCSMINE=$(wc -l < $(echo "$line"|cut -d' ' -f2)) if [ $NUMPROCSMINE != $(echo "$line"|cut -d' ' -f3) ]; then - echo "declared num of processes for instance $instance : ${array[2]} is not the same as the one in the replay files : $NUMPROCSMINE. Please check consistency of these information" + echo "declared num of processes for instance $instance : $(echo "$line"|cut -d' ' -f3) is not the same as the one in the replay files : $NUMPROCSMINE. Please check consistency of these information" exit 1 fi sleeptime=$(echo "$line"|cut -d' ' -f4) - HAVE_SEQ="`which seq 2>/dev/null`" + HAVE_SEQ=$(which seq 2>/dev/null) if [ -n "${HAVE_SEQ}" ]; then - SEQ1=`${HAVE_SEQ} 0 $((${NUMPROCSMINE}-1))` + SEQ1=$( ${HAVE_SEQ} 0 $(( $NUMPROCSMINE - 1 )) ) else cnt=0 - while (( $cnt < ${NUMPROCSMINE} )) ; do + while (( $cnt < $NUMPROCSMINE )) ; do SEQ1="$SEQ1 $cnt" cnt=$((cnt + 1)); done @@ -168,10 +163,10 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then ## hostfile has less than i lines. ##---------------------------------------------------------- -##---- generate tags------------------------------ +##---- generate tags------------------------------ do if [ -n "${HOSTFILE}" ]; then - j=$(( ${NUMPROCS} % ${NUMHOSTS} +1)) + j=$(( $NUMPROCS % $NUMHOSTS +1)) fi hostname=$(echo $hostnames|cut -d' ' -f$j) if [ -z "${hostname}" ]; then @@ -180,14 +175,14 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then host="${hostname}" fi - echo " " >> ${APPLICATIONTMP} + echo " " >> ${APPLICATIONTMP} echo " " >> ${APPLICATIONTMP} echo " " >> ${APPLICATIONTMP} echo " " >> ${APPLICATIONTMP} echo " " >> ${APPLICATIONTMP} - echo " " >> ${APPLICATIONTMP} - NUMPROCS=$(( ${NUMPROCS} +1)) + echo " " >> ${APPLICATIONTMP} + NUMPROCS=$(( $NUMPROCS +1)) done # return IFS back to newline for "for" loop IFS_OLD=$IFS @@ -198,7 +193,7 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then IFS=$IFS_OLD IFS_OLD= else - printf "File not found: %s\n", "${APP_TRACES[0]:-\${APP_TRACES[0]\}}" >&2 + printf "File not found: %s\n", ${DESCRIPTIONFILE} >&2 exit 1 fi