diff --git a/definition-files/almalinux/Singularity.base b/definition-files/almalinux/Singularity.base new file mode 100644 index 0000000000000000000000000000000000000000..03700390c5dc004a51bef72ff1a98a04c97265da --- /dev/null +++ b/definition-files/almalinux/Singularity.base @@ -0,0 +1,23 @@ +Bootstrap: docker +From: almalinux:8 + +%labels + maintainer IT-IMGW <it.img-wien@univie.ac.at> + +%files + $PWD/definition-files/runscript /.singularity.d/runscript + $PWD/definition-files/run-help /.singularity.d/runscript.help + +%post + # command prompt name + CNAME=alma8.base + # does not work goes into /.singularity.d/env/91-environment.sh + echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh + # add some labels + echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS" + echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS" + +%environment + export LANG=C.UTF-8 + export LIBRARY=/usr/lib64:/lib64:/lib + export INCLUDE=/usr/include \ No newline at end of file diff --git a/definition-files/almalinux/Singularity.met b/definition-files/almalinux/Singularity.met new file mode 100644 index 0000000000000000000000000000000000000000..1c83097b9af05b25463a9469a1e6d0c14a4029a5 --- /dev/null +++ b/definition-files/almalinux/Singularity.met @@ -0,0 +1,55 @@ +Bootstrap: docker +From: almalinux:8 + +%labels + maintainer IT-IMGW <it.img-wien@univie.ac.at> + +%files + $PWD/definition-files/runscript /.singularity.d/runscript + $PWD/definition-files/run-help /.singularity.d/runscript.help + +%post + # Every line will be a layer in the container + # See https://fedoraproject.org/wiki/EPEL#Quickstart for powertools + yum update -y \ + && yum install -y dnf-plugins-core \ + && dnf config-manager --set-enabled powertools \ + && yum install -y epel-release \ + && yum update -y \ + && yum --enablerepo epel groupinstall -y "Development Tools" \ + && yum --enablerepo epel install -y \ + curl \ + findutils \ + gcc-c++ \ + gcc \ + gcc-gfortran \ + git \ + gnupg2 \ + hostname \ + iproute \ + make \ + patch \ + python38 \ + python38-pip \ + python38-setuptools \ + unzip \ + nco \ + hdf5-devel \ + netcdf-devel \ + netcdf-fortran-devel \ + python38-numpy-f2py \ + && rm -rf /var/cache/yum \ + && yum clean all + # This means no openmpi + # command prompt name + CNAME=alma8.met + # does not work goes into /.singularity.d/env/91-environment.sh + echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh + # add some labels + echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS" + echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS" + +%environment + export LIBRARY=/usr/lib64:/lib64:/lib + export INCLUDE=/usr/lib64/gfortran/modules:/usr/include + diff --git a/definition-files/almalinux/Singularity.met.ompi b/definition-files/almalinux/Singularity.met.ompi new file mode 100644 index 0000000000000000000000000000000000000000..d3a22aea2b87d4a704f64a8fb17001f0f97317a9 --- /dev/null +++ b/definition-files/almalinux/Singularity.met.ompi @@ -0,0 +1,55 @@ +Bootstrap: docker +From: almalinux:8 + +%labels + maintainer IT-IMGW <it.img-wien@univie.ac.at> + +%files + $PWD/definition-files/runscript /.singularity.d/runscript + $PWD/definition-files/run-help /.singularity.d/runscript.help + +%post + # Every line will be a layer in the container + # See https://fedoraproject.org/wiki/EPEL#Quickstart for powertools + yum update -y \ + && yum install -y dnf-plugins-core \ + && dnf config-manager --set-enabled powertools \ + && yum install -y epel-release \ + && yum update -y \ + && yum --enablerepo epel groupinstall -y "Development Tools" \ + && yum --enablerepo epel install -y \ + curl \ + findutils \ + gcc-c++ \ + gcc \ + gcc-gfortran \ + git \ + gnupg2 \ + hostname \ + iproute \ + make \ + patch \ + python38 \ + python38-pip \ + python38-setuptools \ + unzip \ + nco \ + hdf5-openmpi-devel \ + netcdf-openmpi-devel \ + netcdf-fortran-openmpi-devel \ + python38-numpy-f2py \ + && rm -rf /var/cache/yum \ + && yum clean all + # This means no openmpi + # command prompt name + CNAME=alma8.metompi + # does not work goes into /.singularity.d/env/91-environment.sh + echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh + # add some labels + echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS" + echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS" + +%environment + export LIBRARY=/usr/lib64:/lib64:/lib + export INCLUDE=/usr/lib64/gfortran/modules:/usr/include + diff --git a/definition-files/almalinux/Singularity-alma8-spack b/definition-files/almalinux/Singularity.spack similarity index 92% rename from definition-files/almalinux/Singularity-alma8-spack rename to definition-files/almalinux/Singularity.spack index c9065487af1c7040bb545c643311c21f1db982bc..bc2ff4421095789e7305629c855fda48a3fe15f0 100644 --- a/definition-files/almalinux/Singularity-alma8-spack +++ b/definition-files/almalinux/Singularity.spack @@ -1,6 +1,11 @@ Bootstrap: docker From: almalinux:8 +# +# This is a spack development image to use for downstream development +# to be combined with the base image for two stage builds +# + %labels MAINTAINER Spack Maintainers <maintainers@spack.io> @@ -68,6 +73,7 @@ From: almalinux:8 export DEBIAN_FRONTEND=noninteractive %runscript + # Need spack entry point to allow spack builds exec /bin/bash /opt/spack/share/spack/docker/entrypoint.bash interactive-shell "$@" %startscript diff --git a/definition-files/alpine/Singularity.met b/definition-files/alpine/Singularity.met new file mode 100644 index 0000000000000000000000000000000000000000..7da3717c642892f3637a96930f426aa51fa87128 --- /dev/null +++ b/definition-files/alpine/Singularity.met @@ -0,0 +1,34 @@ +Bootstrap: docker +From: alpine + +%labels + MAINTAINER Michael Blaschek <michael.blaschek@univie.ac.at> + +%files + $PWD/definition-files/runscript /.singularity.d/runscript + $PWD/definition-files/run-help /.singularity.d/runscript.help + +%post + apk add --no-cache build-base \ + curl \ + gcc \ + gcc-gfortran \ + make \ + cdo \ + nco \ + hdf5-dev \ + hdf5-fortran \ + netcdf-dev \ + netcdf-fortran + # command prompt name + CNAME=u18.04.base + # does not work goes into /.singularity.d/env/91-environment.sh + echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh + # add some labels + echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS" + echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS" + +%environment + export LANG=C.UTF-8 + export LIBRARY=/usr/lib64:/lib64:/lib + export INCLUDE=/usr/include \ No newline at end of file diff --git a/definition-files/micromamba/Singularity.conda-py39-dev-debian b/definition-files/micromamba/Singularity.conda-py39-dev-debian deleted file mode 100644 index ab0dab5c5bcbe9c6116ac382435ceb50bed47be7..0000000000000000000000000000000000000000 --- a/definition-files/micromamba/Singularity.conda-py39-dev-debian +++ /dev/null @@ -1,26 +0,0 @@ -Bootstrap: docker -From: mambaorg/micromamba:latest - -%help - Micromamba conda environment with - Python 3.9.13 and the latest eccodes (binary+py) - https://pypi.org/project/eccodes/ -%labels - maintainer M. Blaschek - mail michael.blaschek@univie.ac.at - date 7.10.2022 - python 3.9.13 - eccodes 2.27.0 - gcc 9.5.0 - gfortran 9.5.0 -%post - micromamba -q install -y -n base -c conda-forge eccodes=2.27.0 cdo nco netcdf4 hdf5 openmpi=4.0.5 gcc=9.5.0 gfortran=9.5.0 python=3.9.13 && - /opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge && - micromamba clean --all --yes -%environment - LIBRARY=/opt/conda/lib - INCLUDE=/opt/conda/include - BIN=/opt/conda/bin - SHARE=/opt/conda/share -%test - /opt/conda/bin/python3 -m eccodes selfcheck diff --git a/definition-files/micromamba/Singularity.conda-py39-eccodes-debian b/definition-files/micromamba/Singularity.conda-py39-eccodes-debian deleted file mode 100644 index 76c11c173b001938a10b32c1cb6b8ce111082b44..0000000000000000000000000000000000000000 --- a/definition-files/micromamba/Singularity.conda-py39-eccodes-debian +++ /dev/null @@ -1,19 +0,0 @@ -Bootstrap: docker -From: mambaorg/micromamba:latest - -%help - Micromamba conda environment with - Python 3.9.13 and the latest eccodes (binary+py) - https://pypi.org/project/eccodes/ -%labels - maintainer M. Blaschek - mail michael.blaschek@univie.ac.at - date 7.10.2022 - python 3.9.13 - eccodes 2.27.0 -%post - micromamba -q install -y -n base -c conda-forge eccodes=2.27.0 python=3.9.13 && - /opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge && - micromamba clean --all --yes -%test - python -m eccodes selfcheck diff --git a/definition-files/micromamba/Singularity.py39.dart b/definition-files/micromamba/Singularity.py39.dart new file mode 100644 index 0000000000000000000000000000000000000000..f107914c9ed5bd730995ba865eefd8f7d4ffac26 --- /dev/null +++ b/definition-files/micromamba/Singularity.py39.dart @@ -0,0 +1,53 @@ +Bootstrap: docker +From: mambaorg/micromamba:latest + +%labels + maintainer IT-IMGW <it.img-wien@univie.ac.at> + +%files + $PWD/definition-files/runscript /.singularity.d/runscript + $PWD/definition-files/run-help /.singularity.d/runscript.help + +%post + apt -y update && apt -y install \ + build-essential \ + git \ + tcsh \ + csh \ + ksh \ + m4 \ + libtool \ + automake \ + autoconf \ + && apt -y clean + micromamba -q install -y -n base -c conda-forge \ + eccodes=2.27.0 \ + cdo \ + nco \ + netcdf4 \ + hdf5 \ + openmpi=4.0.5 \ + gcc=9.5.0 \ + gfortran=9.5.0 \ + python=3.9.13 && + /opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge && + micromamba clean --all --yes + # command prompt name + CNAME=m.dart + # does not work goes into /.singularity.d/env/91-environment.sh + echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh + # add some labels + echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS" + echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS" + +%test + python -m eccodes selfcheck + gfortran --version + gcc --version + ncks --version + cdo --version + +%environment + export PATH=/opt/conda/bin:$PATH + export LIBRARY=/opt/conda/lib:/usr/lib64:/lib64:/lib + export INCLUDE=/opt/conda/include:/usr/include diff --git a/definition-files/micromamba/Singularity.py39.eccodes b/definition-files/micromamba/Singularity.py39.eccodes new file mode 100644 index 0000000000000000000000000000000000000000..ad82c2d50a34f432a55bbb4413d988233a9ccddf --- /dev/null +++ b/definition-files/micromamba/Singularity.py39.eccodes @@ -0,0 +1,31 @@ +Bootstrap: docker +From: mambaorg/micromamba:latest + +%labels + maintainer IT-IMGW <it.img-wien@univie.ac.at> + python 3.9.13 + eccodes 2.27.0 + +%files + $PWD/definition-files/runscript /.singularity.d/runscript + $PWD/definition-files/run-help /.singularity.d/runscript.help + +%post + micromamba -q install -y -n base -c conda-forge eccodes=2.27.0 python=3.9.13 && + /opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge && + micromamba clean --all --yes + # command prompt name + CNAME=m.eccodes + # does not work goes into /.singularity.d/env/91-environment.sh + echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh + # add some labels + echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS" + echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS" + +%test + python -m eccodes selfcheck + +%environment + export PATH=/opt/conda/bin:$PATH + export LIBRARY=/opt/conda/lib + export INCLUDE=/opt/conda/include \ No newline at end of file diff --git a/definition-files/micromamba/Singularity.py39.metdev b/definition-files/micromamba/Singularity.py39.metdev new file mode 100644 index 0000000000000000000000000000000000000000..a669d8beeb4824b07b5a78963ad3e4a7d357a379 --- /dev/null +++ b/definition-files/micromamba/Singularity.py39.metdev @@ -0,0 +1,78 @@ +Bootstrap: docker +From: mambaorg/micromamba:latest + +%labels + maintainer IT-IMGW <it.img-wien@univie.ac.at> + +%files + $PWD/definition-files/runscript /.singularity.d/runscript + $PWD/definition-files/run-help /.singularity.d/runscript.help + +%apprun install-ipykernel + # install current container as kernel + mkdir -p $HOME/.local/share/jupyter/kernels/metdev-py3 + cat <<EOF >$HOME/.local/share/jupyter/kernels/metdev-py3/kernel.json +{ + "language": "python", + "argv": ["singularity", + "exec", + "$SINGULARITY_CONTAINER", + "/opt/conda/bin/python3", + "-m", + "ipykernel", + "-f", + "{connection_file}" + ], + "display_name": "sPy 3 (metdev)" +} +EOF + echo "Kernel written: $HOME/.local/share/jupyter/kernels/metdev-py3" + +%post + micromamba -q install -y -n base -c conda-forge \ + python=3.9.13 \ + eccodes=2.27.0 \ + ipykernel \ + nco \ + cdo \ + pandas \ + xarray \ + dask \ + numba \ + scipy \ + netcdf4 \ + h5py \ + hdf5 \ + distributed \ + proj \ + h5netcdf \ + matplotlib \ + zarr \ + metpy \ + cartopy \ + && /opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge && + micromamba clean --all --yes + # command prompt name + CNAME=m.metdev + # does not work goes into /.singularity.d/env/91-environment.sh + echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh + # add some labels + echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS" + echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS" + # add App help information + echo -e "Apps: \n- install-ipykernel Install IPython Kernel to local user\n" >> /.singularity.d/runscript.help + +%test + # Check eccodes lib functionality + python -m eccodes selfcheck + # Check cartopy + + # Check netcdf + + # Check hdf5 + +%environment + export LANG=C.UTF-8 + export PATH=/opt/conda/bin:$PATH + export LIBRARY=/opt/conda/lib + export INCLUDE=/opt/conda/include \ No newline at end of file diff --git a/definition-files/run-help b/definition-files/run-help new file mode 100644 index 0000000000000000000000000000000000000000..23cc9595ca931f8085fe049ceac66c90120761ea --- /dev/null +++ b/definition-files/run-help @@ -0,0 +1,20 @@ +Singularity/Apptainer container +(c) Department of Meteorology and Geophysics + University of Vienna + +interactive shell +> singularity shell image.sif +> ./image.sif + +run a command inside the container +> ./image.sif [cmd] [args] + +bind special directories +> export SINGULARITY_BIND=/this/is/not/a/typical/linux/path +> ./image.sif ls /this/is/not/a/typical/linux/path + +development using includes and libraries from inside the container +> ./image.sif gfortran -I\$INCLUDE -L\$LIBRARY -o test.x test.f90 + +Ask for help: it.img-wien@univie.ac.at +Gitlab: https://gitlab.phaidra.org/imgw/singularity diff --git a/definition-files/runscript b/definition-files/runscript new file mode 100644 index 0000000000000000000000000000000000000000..e57112314385a86de5e5d816804518f4a2ff8430 --- /dev/null +++ b/definition-files/runscript @@ -0,0 +1,12 @@ +#!/bin/sh +# overwrite any existing runscript +# add IMGW customized PROMPT_COMMAND +if [ $# -gt 0 ]; then + # run cmd line options + exec "$@" +else + # interactive + echo "Welcome inside an IMGW container!" + echo "Get help: singularity run-help $SINGULARITY_NAME" + exec /.singularity.d/actions/shell "$@" +fi \ No newline at end of file diff --git a/definition-files/ubuntu/Singularity.ubuntu-18.04 b/definition-files/ubuntu/Singularity.18.04.base similarity index 79% rename from definition-files/ubuntu/Singularity.ubuntu-18.04 rename to definition-files/ubuntu/Singularity.18.04.base index f883a69d83da190c5a00172a38c2d46caac351b7..bba4590c9b1855cb80cda39faa6296641978d116 100644 --- a/definition-files/ubuntu/Singularity.ubuntu-18.04 +++ b/definition-files/ubuntu/Singularity.18.04.base @@ -3,20 +3,9 @@ MirrorURL: http://at.archive.ubuntu.com/ubuntu OSVersion: bionic %labels - - APPLICATION_NAME ubuntu - APPLICATION_VERSION 18.04 - APPLICATION_URL https://www.ubuntu.com - - AUTHOR_NAME Michael Blaschek - AUTHOR_EMAIL michael.blaschek@univie.ac.at - - LAST_UPDATED 20211118 - -%setup + maintainer IT-IMGW <it.img-wien@univie.ac.at> %environment - # Set operating system mirror URL export MIRRORURL='http://at.archive.ubuntu.com/ubuntu' @@ -24,7 +13,8 @@ OSVersion: bionic export OSVERSION='bionic' # Set system locale - export LC_ALL='C' + #export LC_ALL='C' + export LANG=C.UTF-8 # Set debian frontend interface export DEBIAN_FRONTEND='noninteractive' @@ -38,7 +28,8 @@ OSVersion: bionic export OSVERSION='bionic' # Set system locale - export LC_ALL=C + # export LC_ALL=C + export LANG=C.UTF-8 # Set debian frontend interface export DEBIAN_FRONTEND='noninteractive' @@ -91,9 +82,15 @@ OSVersion: bionic # Update database for mlocate updatedb + # command prompt name + CNAME=u18.04.base + # does not work goes into /.singularity.d/env/91-environment.sh + echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh + # add some labels + echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS" + echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS" -%files - -%runscript - -%test +%environment + export LANG=C.UTF-8 + export LIBRARY=/usr/lib64:/lib64:/lib + export INCLUDE=/usr/include \ No newline at end of file diff --git a/definition-files/ubuntu/Singularity.ubuntu-20.04 b/definition-files/ubuntu/Singularity.20.04.base similarity index 79% rename from definition-files/ubuntu/Singularity.ubuntu-20.04 rename to definition-files/ubuntu/Singularity.20.04.base index 26ff889f3d1a40afd985e5fd2883f4a2194349ad..8ab2e3701fad770933cbbde13c08480edb3e96d3 100644 --- a/definition-files/ubuntu/Singularity.ubuntu-20.04 +++ b/definition-files/ubuntu/Singularity.20.04.base @@ -2,18 +2,10 @@ Bootstrap: debootstrap MirrorURL: http://at.archive.ubuntu.com/ubuntu OSVersion: focal -%labels - - APPLICATION_NAME ubuntu - APPLICATION_VERSION 20.04 - APPLICATION_URL https://www.ubuntu.com - AUTHOR_NAME Michael Blaschek - AUTHOR_EMAIL michael.blaschek@univie.ac.at - - LAST_UPDATED 20211118 +%labels + maintainer IT-IMGW <it.img-wien@univie.ac.at> -%setup %environment @@ -24,7 +16,8 @@ OSVersion: focal export OSVERSION='focal' # Set system locale - export LC_ALL='C' + #export LC_ALL='C' + export LANG=C.UTF-8 # Set debian frontend interface export DEBIAN_FRONTEND='noninteractive' @@ -38,7 +31,8 @@ OSVersion: focal export OSVERSION='focal' # Set system locale - export LC_ALL=C + #export LC_ALL=C + export LANG=C.UTF-8 # Set debian frontend interface export DEBIAN_FRONTEND='noninteractive' @@ -91,9 +85,15 @@ OSVersion: focal # Update database for mlocate updatedb + # command prompt name + CNAME=u20.04.base + # does not work goes into /.singularity.d/env/91-environment.sh + echo "export PS1=\"[IMGW-$CNAME]\w\$ \"" >> /.singularity.d/env/99-zz-custom-env.sh + # add some labels + echo "libc $(ldd --version | head -n1 | cut -d' ' -f4)" >> "$SINGULARITY_LABELS" + echo "linux $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)" >> "$SINGULARITY_LABELS" -%files - -%runscript - -%test +%environment + export LANG=C.UTF-8 + export LIBRARY=/usr/lib64:/lib64:/lib + export INCLUDE=/usr/include \ No newline at end of file diff --git a/definition-files/ubuntu/Singularity.ompi b/definition-files/ubuntu/Singularity.ompi new file mode 100644 index 0000000000000000000000000000000000000000..e9f35423f1f6da24619a0f052cfc5884efe82cf8 --- /dev/null +++ b/definition-files/ubuntu/Singularity.ompi @@ -0,0 +1,66 @@ +Bootstrap: docker +From: ubuntu:18.04 + +%labels + maintainer IT-IMGW <it.img-wien@univie.ac.at> + +%environment + # Point to OMPI binaries, libraries, man pages + export OMPI_DIR=/opt/ompi + export PATH="$OMPI_DIR/bin:$PATH" + export LD_LIBRARY_PATH="$OMPI_DIR/lib:$LD_LIBRARY_PATH" + export MANPATH="$OMPI_DIR/share/man:$MANPATH" + export LANG=C.UTF-8 + +%post + echo "Installing required packages..." + apt-get update && apt-get install -y wget git bash gcc gfortran g++ make file + + echo "Installing Open MPI" + export OMPI_DIR=/opt/ompi + export OMPI_VERSION=4.0.5 + export OMPI_URL="https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-$OMPI_VERSION.tar.bz2" + mkdir -p /tmp/ompi + mkdir -p /opt + # Download + cd /tmp/ompi && wget -O openmpi-$OMPI_VERSION.tar.bz2 $OMPI_URL && tar -xjf openmpi-$OMPI_VERSION.tar.bz2 + # Compile and install + cd /tmp/ompi/openmpi-$OMPI_VERSION && ./configure --prefix=$OMPI_DIR && make -j8 install + + # Set env variables so we can compile our application + export PATH=$OMPI_DIR/bin:$PATH + export LD_LIBRARY_PATH=$OMPI_DIR/lib:$LD_LIBRARY_PATH + + echo "Compiling the MPI application..." + cat<<EOF>/opt/mpitest.c +/* + * Usage: + * mpicc mpitest.c -o mpitest + * mpirun -np 2 -H `hostname` ./mpitest + */ + +#include <stdio.h> +#include <mpi.h> + +int main(int argc, char *argv[]) +{ + int rank, size, h_len; + char hostname[MPI_MAX_PROCESSOR_NAME]; + MPI_Init(&argc, &argv); + + // get rank of this proces + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + // get total process number + MPI_Comm_size(MPI_COMM_WORLD, &size); + + MPI_Get_processor_name(hostname, &h_len); + printf("Start! rank:%d size: %d at %s\n", rank, size,hostname); + //do something + printf("Done! rank:%d size: %d at %s\n", rank, size,hostname); + + MPI_Finalize(); + return 0; +} +EOF + cd /opt && mpicc -o mpitest mpitest.c +