How to run OpenMC with MPI? Tutorial of OpenMC in Parallel

Finally find a solution!

The problem is with the package parallel HDF5 (hdf5-openmpi package).

The solution is simply compile the OpenMC with serial HDF5 (hdf5 package).

Source: Depletion simulation on supercomputer gets stuck between depletion steps.
And: Allow depletion with MPI and serial HDF5 by paulromano · Pull Request #1566 · openmc-dev/openmc · GitHub

My new package build is:

pkgname=openmc-ompi-nopy
pkgver=v0.15.0
pkgrel=1
pkgdesc="OpenMC build with OpenMPI but without hdf5-openmpi, and without python env."
arch=('x86_64')
url="https://github.com/openmc-dev/openmc"
license=('MIT')

source=("${pkgname}::git+${url}.git")

pkgver() {
    cd "$pkgname"
    git checkout master > /dev/null  # Change to brench master (last version stable)
    git describe --tags | sed 's/-.*//'
}

md5sums=('SKIP')

depends=( 
    hdf5
    openssh
    fmt
)

makedepends=(
    hdf5
    base-devel
    cmake
    git
    fmt
)

conflicts=(
    openmc-git
    hdf5-openmpi
)

provides=("${pkgname%-pkgver}")

build() {
    cd $srcdir/${pkgname}
    rm -rf build
    mkdir build && cd build
    cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENMC_USE_MPI=ON -DCMAKE_INSTALL_PREFIX=/opt/openmc

    _ccores=$(nproc)
    # check if _ccores is a positive integer, if not, serial build
    if [[ "${_ccores}" =~ ^[1-9][0-9]*$ ]]; then
        make -j ${_ccores}
    else
        make
    fi
}

package() {
    cd $srcdir/${pkgname}/build
    make DESTDIR="$pkgdir/" install
    rm -rf $srcdir/${pkgname}/build
    mkdir $pkgdir/opt/openmc/openmc-src
    cp -r $srcdir/${pkgname}/* $pkgdir/opt/openmc/openmc-src
    rm -rf $srcdir
    mkdir -p $pkgdir/usr/bin
    ln -s /opt/openmc/bin/openmc $pkgdir/usr/bin
}

Save this as a file called PKGBUILD. To compile and install on ArchLinux family (Manjaro, etc) run this command in the same folder of PKGBUILD file:

makepkg -si #or use just -s to just compile

To create a python envrolvment in your user:

cd ~
python -m venv openmc-env
source openmc-env/bin/activate
cp -r /opt/openmc/openmc-src/ ~/
cd openmc-src/
python -m pip install .
rm -rf ~/openmc-src/

In the cluster you need the python envrolvment just in the father computer.

You need run the comand below every time you open the terminal in the father computer before run openmc python:

source openmc-env/bin/activate

Or you can put this command in the ~/.bashrc file.

1 Like