openfoam: Add *-mpi wrappers for all bins that use libPstream.so

* Ensure correct mpirun is used and right number of processes
This commit is contained in:
Tyson Whitehead
2016-10-27 10:57:04 -04:00
parent 7a6534cb21
commit a90c9e5ee3

View File

@@ -34,7 +34,8 @@ stdenv.mkDerivation rec {
'';
# stick etc, bin, and platforms under lib/OpenFOAM-${version}
# fill bin proper up with wrappers to everything in platform/$WM_OPTIONS/bin that source etc/bashrc
# fill bin proper up with wrappers that source etc/bashrc for everything in platform/$WM_OPTIONS/bin
# add -mpi suffixed versions that calls proper mpirun for those with libPstream.so depencies too
installPhase = ''
echo "copying etc, bin, and platforms directories to $out/lib/OpenFOAM-${version}"
mkdir -p "$out/lib/OpenFOAM-${version}"
@@ -43,6 +44,12 @@ stdenv.mkDerivation rec {
for program in "$out/lib/OpenFOAM-${version}/platforms/$WM_OPTIONS/bin/"*; do
makeWrapper "$program" "$out/bin/''${program##*/}" \
--run "source \"$out/lib/OpenFOAM-${version}/etc/bashrc\""
if readelf -d "$program" | fgrep -q libPstream.so; then
makeWrapper "${openmpi}/bin/mpirun" "$out/bin/''${program##*/}-mpi" \
--run "[ -r processor0 ] || { echo \"Case is not currently decomposed, see decomposePar documentation\"; exit 1; }" \
--run "extraFlagsArray+=(-n \"\$(ls -d processor* | wc -l)\" \"$out/bin/''${program##*/}\" -parallel)" \
--run "source \"$out/lib/OpenFOAM-${version}/etc/bashrc\""
fi
done
'';