tempOutputFile << "cd " << workDir << endl ;
// generate nodes file
- tempOutputFile << "LIBBATCH_NODEFILE=`mktemp nodefile-XXXXXXXXXX` || exit 1" << endl;
+ tempOutputFile << "LIBBATCH_NODEFILE=$(mktemp nodefile-XXXXXXXXXX) || exit 1" << endl;
tempOutputFile << "bool=0" << endl;
tempOutputFile << "for i in $LSB_MCPU_HOSTS; do" << endl;
tempOutputFile << " if test $bool = 0; then" << endl;
} else {
#endif
- tempOutputFile << "#!/bin/sh" << endl;
+ tempOutputFile << "#!/bin/sh -f" << endl;
tempOutputFile << "cd " << workDir << endl;
// Optional parameters (system limits on the job process)
tempOutputFile << "export " << iter->first << "=" << iter->second << endl;
}
- // 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;
tempOutputFile << "export LIBBATCH_NODEFILE" << endl;
// Launch the executable
tempOutputFile << " 1>" << stdoutFile << " 2>" << stderrFile << endl;
// Remove the node file
- tempOutputFile << "rm $LIBBATCH_NODEFILE" << endl;
+ tempOutputFile << "rm \"$LIBBATCH_NODEFILE\"" << endl;
#ifdef WIN32
}
ofstream tempOutputFile;
string tmpFileName = Utils::createAndOpenTemporaryFile("slurm-script", tempOutputFile);
- tempOutputFile << "#!/bin/bash" << endl;
+ tempOutputFile << "#!/bin/sh -f" << endl;
tempOutputFile << "#SBATCH --output=" << workDir << "/logs/output.log." << rootNameToExecute << endl;
tempOutputFile << "#SBATCH --error=" << workDir << "/logs/error.log." << rootNameToExecute << endl;
}
// generate nodes file
- tempOutputFile << "LIBBATCH_NODEFILE=`mktemp nodefile-XXXXXXXXXX`" << endl;
- tempOutputFile << "srun hostname > $LIBBATCH_NODEFILE" << endl;
+ tempOutputFile << "LIBBATCH_NODEFILE=$(mktemp nodefile-XXXXXXXXXX)" << endl;
+ tempOutputFile << "srun hostname > \"$LIBBATCH_NODEFILE\"" << endl;
tempOutputFile << "export LIBBATCH_NODEFILE" << endl;
// Launch the executable
tempOutputFile << endl;
// Remove the node file
- tempOutputFile << "rm $LIBBATCH_NODEFILE" << endl;
+ tempOutputFile << "rm \"$LIBBATCH_NODEFILE\"" << endl;
tempOutputFile.flush();
tempOutputFile.close();