- // generate nodes file
- tempOutputFile << "LIBBATCH_NODEFILE=`mktemp nodefile-XXXXXXXXXX`" << endl;
- for (int i=0 ; i<nbproc ; i++)
- tempOutputFile << "echo `hostname` >> $LIBBATCH_NODEFILE" << endl;
+ // generate nodes file (one line per required proc)
+ tempOutputFile << "LIBBATCH_NODEFILE=$(mktemp nodefile-XXXXXXXXXX)" << endl;
+ tempOutputFile << "i=" << nbproc << endl;
+ tempOutputFile << "hn=$(hostname)" << endl;
+ tempOutputFile << "{" << endl;
+ tempOutputFile << "while [ $i -gt 0 ]" << endl;
+ tempOutputFile << "do" << endl;
+ tempOutputFile << " echo \"$hn\"" << endl;
+ tempOutputFile << " i=$((i-1))" << endl;
+ tempOutputFile << "done" << endl;
+ tempOutputFile << "} > \"$LIBBATCH_NODEFILE\"" << endl;