diff --git a/.gitignore b/.gitignore index 1fcf15d0839098213ec23c52a0d3796c1f278a35..102af6293272d1a78a0de9312cf31038ab830f8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -*.sif \ No newline at end of file +*.sif +models/WRF/sandbox.wrf.dev +models/WRF/run diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..5436bc4c07836e598e9a00749d4c6cf5e485a302 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +# This is a makefile for building singularity containers +# from the definition files. + +CONTAINER_DIR := containers +null := + +output: + @mkdir -p $(CONTAINER_DIR) + +.PHONY: alma8.base # AlmaLinux 8 Base Image +alma8.base: output + @if [ ! -f '$(CONTAINER_DIR)/$@.sif' ]; then \ + echo Building AlmaLinux 8 Base image: $(CONTAINER_DIR)/$@.sif;\ + sudo singularity build $(CONTAINER_DIR)/$@.sif definition-files/almalinux/Singularity.base;\ + fi + @[ -f $(CONTAINER_DIR)/$@.sif ] && echo Exists: $(CONTAINER_DIR)/$@.sif || true + +.PHONY: alma8.met # AlmaLinux 8 Meteorology Image +alma8.met: output + @if [ ! -f $(CONTAINER_DIR)/$@.sif ]; then \ + echo Building AlmaLinux 8 Met image: $(CONTAINER_DIR)/alma8.met.sif;\ + sudo singularity build $(CONTAINER_DIR)/alma8.met.sif definition-files/almalinux/Singularity.met;\ + fi + @[ -f $(CONTAINER_DIR)/$@.sif ] && echo Exists: $(CONTAINER_DIR)/$@.sif || true + +.PHONY: alma8.met.ompi # AlmaLinux 8 Meteorology OMPI Image +alma8.met.ompi: output + @if [ ! -f $(CONTAINER_DIR)/$@.sif ]; then \ + echo Building AlmaLinux 8 Met OMPI image: $(CONTAINER_DIR)/alma8.met.ompi.sif;\ + sudo singularity build $(CONTAINER_DIR)/alma8.met.ompi.sif definition-files/almalinux/Singularity.met.ompi;\ + fi + @[ -f $(CONTAINER_DIR)/$@.sif ] && echo Exists: $(CONTAINER_DIR)/$@.sif || true + +.PHONY: help # Show make targets +help: # Show list of target + @echo Build Targets and helper functions: + @grep "^.PHONY: .* #" Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \t\2/' | expand -t20 + +.PHONY: clean # Remove all container images +clean: + rm -rf $(CONTAINER_DIR)/*.sif \ No newline at end of file diff --git a/definition-files/MPI/mpitest.c b/definition-files/MPI/mpitest.c index 3c38ef6b6945f0c00b0a4bf4930a1093d8a27787..e3ebda4245493a3ec3cfa35d61731f2e403c069d 100644 --- a/definition-files/MPI/mpitest.c +++ b/definition-files/MPI/mpitest.c @@ -25,7 +25,7 @@ int main (int argc, char **argv) { goto exit_with_error; } - fprintf (stdout, "Hello, I am rank %d/%d", myrank, size); + fprintf (stdout, "Hello, I am rank %d/%d\n", myrank, size); MPI_Finalize(); diff --git a/definition-files/almalinux/Singularity.met b/definition-files/almalinux/Singularity.met index 1c83097b9af05b25463a9469a1e6d0c14a4029a5..86dbcbe10fc43ee073e72220d439e07d5f2307e1 100644 --- a/definition-files/almalinux/Singularity.met +++ b/definition-files/almalinux/Singularity.met @@ -35,8 +35,11 @@ From: almalinux:8 unzip \ nco \ hdf5-devel \ + hdf5-static \ netcdf-devel \ + netcdf-static \ netcdf-fortran-devel \ + netcdf-fortran-static \ python38-numpy-f2py \ && rm -rf /var/cache/yum \ && yum clean all diff --git a/definition-files/almalinux/Singularity.met.ompi b/definition-files/almalinux/Singularity.met.ompi index d3a22aea2b87d4a704f64a8fb17001f0f97317a9..c5c1d6122926ea87db5082d8fbb436b4bfc2dcfc 100644 --- a/definition-files/almalinux/Singularity.met.ompi +++ b/definition-files/almalinux/Singularity.met.ompi @@ -16,7 +16,6 @@ From: almalinux:8 && 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 \ @@ -29,18 +28,17 @@ From: almalinux:8 iproute \ make \ patch \ - python38 \ - python38-pip \ - python38-setuptools \ - unzip \ - nco \ + openmpi-devel \ + openmpi \ hdf5-openmpi-devel \ + hdf5-openmpi-static \ netcdf-openmpi-devel \ + netcdf-openmpi-static \ netcdf-fortran-openmpi-devel \ - python38-numpy-f2py \ + netcdf-fortran-openmpi-static \ && rm -rf /var/cache/yum \ + && dnf clean all \ && yum clean all - # This means no openmpi # command prompt name CNAME=alma8.metompi # does not work goes into /.singularity.d/env/91-environment.sh @@ -50,6 +48,8 @@ From: almalinux:8 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 + # need to add openmpi to PATH + export PATH=/usr/lib64/openmpi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + export LIBRARY=/usr/lib64/openmpi/lib:/usr/lib64:/lib64:/lib + export INCLUDE=/usr/include/openmpi-x86_64/:/usr/lib64/gfortran/modules:/usr/include diff --git a/definition-files/centos/Singularity-centos8-IMPI b/definition-files/centos/Singularity.inteloneapi similarity index 97% rename from definition-files/centos/Singularity-centos8-IMPI rename to definition-files/centos/Singularity.inteloneapi index a17dbf5b6274339ac53488ffda23f0d6670e58d6..da0afdd842fd5d6b3307cb9f41aa24b57b88936f 100644 --- a/definition-files/centos/Singularity-centos8-IMPI +++ b/definition-files/centos/Singularity.inteloneapi @@ -1,6 +1,6 @@ BootStrap: yum OSVersion: 8 -MirrorURL: http://linux-ftp.jf.intel.com/pub/mirrors/centos/8/BaseOS/$basearch/os/ +MirrorURL: http://linux-ftp.jf.intel.com/pub/mirrors/centos/8/BaseOS/x86_64/os/ Include: yum %environment diff --git a/definition-files/micromamba/Singularity.py39.dart b/definition-files/micromamba/Singularity.py39.dart index f107914c9ed5bd730995ba865eefd8f7d4ffac26..a42fb4b8ce8e97f002073a578f528dc734b1a5ac 100644 --- a/definition-files/micromamba/Singularity.py39.dart +++ b/definition-files/micromamba/Singularity.py39.dart @@ -20,15 +20,15 @@ From: mambaorg/micromamba:latest automake \ autoconf \ && apt -y clean + # needed to update to openmpi versions 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 \ + netcdf4=1.6.1=mpi_openmpi_py39ha5e07e6_0 \ + hdf5=1.12.2=mpi_openmpi_h41b9b70_0 \ + gcc \ + gfortran \ python=3.9.13 && /opt/conda/bin/pip install eccodes && /opt/conda/bin/pip cache purge && micromamba clean --all --yes @@ -49,5 +49,6 @@ From: mambaorg/micromamba:latest %environment export PATH=/opt/conda/bin:$PATH + export LD_LIBRARY_PATH=/opt/conda/lib:/usr/lib64:/lib64:/lib export LIBRARY=/opt/conda/lib:/usr/lib64:/lib64:/lib export INCLUDE=/opt/conda/include:/usr/include diff --git a/definition-files/micromamba/Singularity.py39.metdev b/definition-files/micromamba/Singularity.py39.metdev index a669d8beeb4824b07b5a78963ad3e4a7d357a379..8f1ab7f597ed93c66f693c1151601238ae6016af 100644 --- a/definition-files/micromamba/Singularity.py39.metdev +++ b/definition-files/micromamba/Singularity.py39.metdev @@ -28,6 +28,10 @@ From: mambaorg/micromamba:latest EOF echo "Kernel written: $HOME/.local/share/jupyter/kernels/metdev-py3" +%apprun notebook + echo "Launching Notebook Server ..." + exec "/opt/conda/bin/jupyter-notebook $@" + %post micromamba -q install -y -n base -c conda-forge \ python=3.9.13 \ diff --git a/models/ICON/Singularity.gcc6 b/models/ICON/Singularity.gcc6 new file mode 100644 index 0000000000000000000000000000000000000000..40e9dec08db99ee05dc3c18d0f8195ec30687491 --- /dev/null +++ b/models/ICON/Singularity.gcc6 @@ -0,0 +1,43 @@ +Bootstrap: docker +From: ubuntu:18.04 + +%labels + maintainer IT-IMGW <it.img-wien@univie.ac.at> + +%post +# Install building tools and ICON dependencies: +apt install -y \ + build-essential \ + python3 \ + gcc-6 \ + gfortran-6 \ + libmpich-dev \ + libhdf5-dev \ + libnetcdf-dev \ + libnetcdff-dev \ + libeccodes-dev \ + libblas-dev \ + liblapack-dev \ + libxml2-dev + +# Select the compiler: +update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 50 \ + --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-6 + +# The command above can be reverted as follows: +# sudo update-alternatives --remove gcc /usr/bin/gcc-6 + +# Select MPI libraries and compiler wrappers +update-alternatives --set mpi /usr/include/mpich +update-alternatives --set mpirun /usr/bin/mpirun.mpich + +# If the two non-interactive commands above do not work, +# try the interactive analogues: +# sudo update-alternatives --config mpirun +# sudo update-alternatives --config mpi + +# Install optional tools: +apt install -y ksh cdo + +%environment +#What do we need to build ICON? \ No newline at end of file diff --git a/models/WRF/Makefile b/models/WRF/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..4c55d4ec5d5e8c62a3399868453fb02b91b2cc6d --- /dev/null +++ b/models/WRF/Makefile @@ -0,0 +1,39 @@ +# Makefile to build different WRF containers + +WRF_VERSION := 4.4.1 + +.PHONY: sandbox # WRF development sandbox for two stage builds +sandbox: + @if [ ! -d ./sandbox.wrf.dev ]; then\ + echo Building the WRF sandbox;\ + make -C ../.. alma8.base;\ + sudo singularity build --sandbox sandbox.wrf.dev Singularity.sandbox.dev;\ + fi + @[ -d ./sandbox.wrf.dev ] && echo Exists: WRF Sandbox || true + +.PHONY: em_real # WRF Real container +em_real: sandbox + @if [ ! -f WRF-$(WRF_VERSION)-$@.sif ]; then\ + echo Building em_real with WRF sandbox;\ + sed 's,WRF_BUILD_TARGET=em_real,WRF_BUILD_TARGET=em_real,g' Singularity.wrf > Singularity.tmp;\ + sudo singularity build WRF-$(WRF_VERSION)-$@.sif Singularity.tmp;\ + rm Singularity.tmp;\ + fi + @[ -f WRF-$(WRF_VERSION)-$@.sif ] && echo Exists: WRF-$(WRF_VERSION)-$@.sif || true + +.PHONY: em_les # WRF LES container +em_les: + @echo Building em_real with WRF sandbox + # replace compile target in twostage build setup + sed 's,WRF_BUILD_TARGET=em_real,WRF_BUILD_TARGET=em_les,g' Singularity.wrf > Singularity.tmp + sudo singularity build WRF-$(WRF_VERSION)-$@.sif Singularity.tmp + rm Singularity.tmp + +.PHONY: help # Show make targets +help: # Show list of target + @echo Build Targets and helper functions: + @grep "^.PHONY: .* #" Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \t\2/' | expand -t20 + +.PHONY: clean # Remove all container images +clean: + rm -rf $(CONTAINER_DIR)/*.sif \ No newline at end of file diff --git a/models/WRF/Singularity.sandbox.dev b/models/WRF/Singularity.sandbox.dev new file mode 100644 index 0000000000000000000000000000000000000000..71e138f90066d0c397c2b1ef9cce5afbd11c518f --- /dev/null +++ b/models/WRF/Singularity.sandbox.dev @@ -0,0 +1,79 @@ +Bootstrap: localimage +From: ../../containers/alma8.base.sif + +%labels +maintainer IT-IMGW <it.img-wien@univie.ac.at> +baseimage AlmaLinux8 +wrfversion 4.4.1 + +%post +WRF_VERSION=4.4.1 +WPS_VERSION=4.4 +# +# WRF install packages / requirements from repo +# +# Every line will be a layer in the container +# See https://fedoraproject.org/wiki/EPEL#Quickstart for powertools +# yum --enablerepo epel groupinstall -y "Development Tools" \ +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 install -y \ + curl \ + file \ + findutils \ + gcc-c++ \ + gcc \ + gcc-gfortran \ + glibc.i686 libgcc.i686 \ + libpng-devel jasper-libs jasper-devel \ + m4 make perl \ + tar tcsh time which zlib zlib-devel \ + git \ + gnupg2 \ + hostname \ + iproute \ + patch \ + openmpi-devel \ + openmpi \ + hdf5-openmpi-devel \ + hdf5-openmpi-static \ + netcdf-openmpi-devel \ + netcdf-openmpi-static \ + netcdf-fortran-openmpi-devel \ + netcdf-fortran-openmpi-static \ +&& rm -rf /var/cache/yum \ +&& yum clean all \ +&& dnf clean all \ +&& rm -rf /usr/share/doc \ +&& rm -rf /usr/share/man \ +&& ln -s /usr/include/openmpi-x86_64/ /usr/lib64/openmpi/include + +# WRF root directory +mkdir -p /wrf/WRF /wrf/WPS +# Download the WRF version from Github +curl -SL https://github.com/wrf-model/WRF/releases/download/v${WRF_VERSION}/v${WRF_VERSION}.tar.gz | tar --no-same-owner --strip-components=1 -zxC /wrf/WRF \ +&& curl -SL https://github.com/wrf-model/WPS/archive/refs/tags/v${WPS_VERSION}.tar.gz | tar --no-same-owner --strip-components=1 -zxC /wrf/WPS + +# command prompt name +CNAME=wrf.sandbox +# 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 to default environment +echo "export WRF_VERSION=$WRF_VERSION" >> $SINGULARITY_ENVIRONMENT +echo "export WPS_VERSION=$WPS_VERSION" >> $SINGULARITY_ENVIRONMENT +# not sure why that does not happen as default +echo "export PKG_CONFIG_PATH=/usr/lib64/openmpi/lib/pkgconfig/" >> $SINGULARITY_ENVIRONMENT + + +%environment +export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib:/usr/lib64:/lib64:/lib +export PATH=/usr/lib64/openmpi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +export LIBRARY=/usr/lib64/openmpi/lib:/usr/lib64:/lib64:/lib +export INCLUDE=/usr/include/openmpi-x86_64/:/usr/lib64/gfortran/modules:/usr/include +export NETCDF=/usr/lib64/openmpi +export NETCDF_ROOT=/usr/lib64/openmpi +export JASPERINC=/usr/include/jasper/ +export JASPERLIB=/usr/lib64/ diff --git a/models/WRF/Singularity.tmp b/models/WRF/Singularity.tmp new file mode 100644 index 0000000000000000000000000000000000000000..03a4a5a94a9b33cddc79b87cff1cf546366fef7b --- /dev/null +++ b/models/WRF/Singularity.tmp @@ -0,0 +1,80 @@ +Bootstrap: localimage +From: sandbox.wrf.dev +Stage: build + +# Two Stage Build of WRF +# use the sandbox development image +# 1. Compile the target +# 2. Copy relevant exe to target WRF container +# Make sure the ldd / linking and inputs are ok + +%labels +maintainer IT-IMGW <it.img-wien@univie.ac.at> + +%post +# Build a WRF release from the sandbox +WRF_BUILD_TARGET=em_real +LDFLAGS="-lm" +JASPERINC=/usr/include/jasper/ +JASPERLIB=/usr/lib64/ +NETCDF=/usr/lib64/openmpi/ + +# Build WRF with Option 34 and 1 +cd /wrf/WRF \ + && ./configure <<< $'34\r1\r' \ + && sed -i -e '/^DM_CC/ s/$/ -DMPI2_SUPPORT/' ./configure.wrf \ + && sed -i '/BUILD_RRTMG_FAST/d' ./configure.wrf \ + && /bin/csh ./compile $WRF_BUILD_TARGET 2>&1 | tee compile_wrf_arw_opt34.1.log + +# Build WPS with WRF +cd /wrf/WPS \ + && ./configure <<< $'1\r' \ + && sed -i -e 's/-L$(NETCDF)\/lib/-L$(NETCDF)\/lib -lnetcdff /' ./configure.wps \ + && /bin/csh ./compile 2>&1 | tee compile_wps.log + +# Copy everything to a save directory +# This needs to be compied to the final Stage +mkdir -p /wrf/run /wrf/bin \ + && cp -fL /wrf/WRF/run/* /wrf/run \ + && rm /wrf/run/*.exe \ + && find /wrf -iname '*.exe' -exec cp -vfL {} /wrf/bin/ \; \ + && cp /wrf/WPS/namelist* /wrf/run + +Bootstrap: localimage +From: sandbox.wrf.dev +Stage: final + +%files from build + # Copy only executables from WRF to directory + /wrf/bin /wrf/bin + /wrf/run /wrf/run + /wrf/WPS/link_grib.csh /wrf/bin + /wrf/WPS/ungrib/Variable_Tables /wrf/run + /wrf/WRF/compile_wrf_arw_opt34.1.log /wrf + /wrf/WPS/compile_wps.log /wrf + +%files + runscript /.singularity.d/runscript + run-help /.singularity.d/runscript.help + +%post + # compress + gzip -f /wrf/*.log + # remove src tree (is insidie sandbox) + rm -rf /wrf/WRF /wrf/WPS + # Strip the binaries to reduce the size of the image + find -L /wrf/* -type f -exec readlink -f '{}' \; | \ + xargs file -i | \ + grep 'charset=binary' | \ + grep 'x-executable\|x-archive\|x-sharedlib' | \ + awk -F: '{print $1}' | xargs strip -s + + # command prompt name + WRF_BUILD_TARGET=em_real + CNAME=alma8.wrf.$WRF_BUILD_TARGET + # 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 + +%environment + export PATH=/wrf/bin:$PATH + export WRF_BUILD_TARGET=em_real diff --git a/models/WRF/Singularity.wrf b/models/WRF/Singularity.wrf new file mode 100644 index 0000000000000000000000000000000000000000..ef6277ba09a7872292fa82bdfd79f67e86a7fb40 --- /dev/null +++ b/models/WRF/Singularity.wrf @@ -0,0 +1,80 @@ +Bootstrap: localimage +From: sandbox.wrf.dev +Stage: build + +# Two Stage Build of WRF +# use the sandbox development image +# 1. Compile the target +# 2. Copy relevant exe to target WRF container +# Make sure the ldd / linking and inputs are ok + +%labels +maintainer IT-IMGW <it.img-wien@univie.ac.at> + +%post +# Build a WRF release from the sandbox +WRF_BUILD_TARGET=em_real +LDFLAGS="-lm" +JASPERINC=/usr/include/jasper/ +JASPERLIB=/usr/lib64/ +NETCDF=/usr/lib64/openmpi/ + +# Build WRF with Option 34 and 1 +cd /wrf/WRF \ + && ./configure <<< $'34\r1\r' \ + && sed -i -e '/^DM_CC/ s/$/ -DMPI2_SUPPORT/' ./configure.wrf \ + && sed -i '/BUILD_RRTMG_FAST/d' ./configure.wrf \ + && /bin/csh ./compile $WRF_BUILD_TARGET 2>&1 | tee compile_wrf_arw_opt34.1.log + +# Build WPS with WRF +cd /wrf/WPS \ + && ./configure <<< $'1\r' \ + && sed -i -e 's/-L$(NETCDF)\/lib/-L$(NETCDF)\/lib -lnetcdff /' ./configure.wps \ + && /bin/csh ./compile 2>&1 | tee compile_wps.log + +# Copy everything to a save directory +# This needs to be compied to the final Stage +mkdir -p /wrf/run /wrf/bin \ + && cp -fL /wrf/WRF/run/* /wrf/run \ + && rm /wrf/run/*.exe \ + && find /wrf -iname '*.exe' -exec cp -vfL {} /wrf/bin/ \; \ + && cp /wrf/WPS/namelist* /wrf/run + +Bootstrap: localimage +From: sandbox.wrf.dev +Stage: final + +%files from build + # Copy only executables from WRF to directory + /wrf/bin /wrf/bin + /wrf/run /wrf/run + /wrf/WPS/link_grib.csh /wrf/bin + /wrf/WPS/ungrib/Variable_Tables /wrf/run + /wrf/WRF/compile_wrf_arw_opt34.1.log /wrf + /wrf/WPS/compile_wps.log /wrf + +%files + ./scripts/runscript /.singularity.d/runscript + ./scripts/run-help /.singularity.d/runscript.help + +%post + # compress + gzip -f /wrf/*.log + # remove src tree (is insidie sandbox) + rm -rf /wrf/WRF /wrf/WPS + # Strip the binaries to reduce the size of the image + find -L /wrf/* -type f -exec readlink -f '{}' \; | \ + xargs file -i | \ + grep 'charset=binary' | \ + grep 'x-executable\|x-archive\|x-sharedlib' | \ + awk -F: '{print $1}' | xargs strip -s + + # command prompt name + WRF_BUILD_TARGET=em_real + CNAME=alma8.wrf.$WRF_BUILD_TARGET + # 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 + +%environment + export PATH=/wrf/bin:$PATH + export WRF_BUILD_TARGET=em_real diff --git a/models/WRF/dtcenter/Dockerfile.base b/models/WRF/dtcenter/Dockerfile.base new file mode 100644 index 0000000000000000000000000000000000000000..6ebfe128fded43d79a15d654690ae07f05801e6f --- /dev/null +++ b/models/WRF/dtcenter/Dockerfile.base @@ -0,0 +1,258 @@ +# +FROM centos:7 +MAINTAINER Michael Kavulich <kavulich@ucar.edu> + +# Set up base OS environment + +RUN yum -y update \ + && yum -y install scl file gcc gcc-gfortran gcc-c++ glibc.i686 libgcc.i686 libpng-devel jasper \ + jasper-devel hostname m4 make perl tar bash ksh tcsh time wget which zlib zlib-devel \ + openssh-clients openssh-server net-tools fontconfig libgfortran libXext libXrender \ + libxml2 libxml2-devel perl-XML-LibXML ImageMagick sudo epel-release git \ +# Libraries for NetCDF + && yum -y install libcurl-devel zlib-devel \ + && yum -y install python3 python3-pip python3-devel \ +# Libraries for HDF4 + && yum -y install flex flex-devel bison bison-devel \ +# Download GNU version 8 compilers via devtoolset + && yum -y install centos-release-scl \ + && yum -y install devtoolset-8 \ + && yum -y install devtoolset-8-gcc devtoolset-8-gcc-gfortran devtoolset-8-gcc-c++ \ + && scl enable devtoolset-8 bash \ + && scl enable devtoolset-8 tcsh + + +#Source code locations +ENV HDF4_URL http://www.hdfgroup.org/ftp/HDF/releases/HDF4.2r3/src/HDF4.2r3.tar.gz +ENV HDFEOS_URL https://dtcenter.org/sites/default/files/community-code/met/docker_data/HDF-EOS2.16v1.00.tar.Z +ENV BUFRLIB_URL https://dtcenter.org/sites/default/files/community-code/met/docker_data/BUFRLIB_v10-2-3.tar + +#Compiler environment variables +ENV CC /opt/rh/devtoolset-8/root/usr/bin/gcc +ENV FC /opt/rh/devtoolset-8/root/usr/bin/gfortran + +# Build libraries with a parallel Make +ENV J 4 + +# Other necessary environment variables +ENV LD_LIBRARY_PATH /usr/local/lib +ENV NETCDF /comsoftware/libs/netcdf + +RUN groupadd comusers -g 9999 +RUN useradd -u 9999 -g comusers -G wheel -M -d /home comuser +RUN mkdir /comsoftware \ + && chown -R comuser:comusers /comsoftware \ + && chmod 6755 /comsoftware + +# Build OpenMPI +RUN mkdir -p /comsoftware/libs/openmpi/BUILD_DIR +RUN source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/openmpi/BUILD_DIR \ + && curl -L -O https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.0.tar.gz \ + && tar -xf openmpi-4.0.0.tar.gz \ + && cd openmpi-4.0.0 \ + && ./configure --prefix=/usr/local &> /comsoftware/libs/build_log_openmpi_config \ + && echo dummy printout to keep travis happy openmpi config \ + && make all install \ + && echo "make all install | awk 'NR % 1000 == 0'" \ + && echo "make all install &> /comsoftware/libs/build_log_openmpi_make" \ + && echo dummy printout to keep travis happy openmpi make \ + && cd / \ + && rm -rf /comsoftware/libs/openmpi/BUILD_DIR + +# Build SZIP libraries +RUN mkdir -p /comsoftware/libs/szip/BUILD_DIR +RUN source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/szip/BUILD_DIR \ + && curl -L -O https://support.hdfgroup.org/ftp/lib-external/szip/2.1.1/src/szip-2.1.1.tar.gz \ + && tar -xf szip-2.1.1.tar.gz \ + && cd szip-2.1.1 \ + && ./configure --prefix=/usr/local/ &> /comsoftware/libs/build_log_szip_config \ + && echo dummy printout to keep travis happy szip config \ + && make install &> /comsoftware/libs/build_log_szip_make \ + && echo dummy printout to keep travis happy szip make \ + && rm -rf /comsoftware/libs/szip/BUILD_DIR + +# Build HDF5 libraries +RUN mkdir -p /comsoftware/libs/hdf5/BUILD_DIR +RUN source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/hdf5/BUILD_DIR \ + && git clone https://bitbucket.hdfgroup.org/scm/hdffv/hdf5.git \ + && cd hdf5 \ + && git checkout hdf5-1_10_4 \ + && ./configure --enable-fortran --enable-cxx --enable-shared --with-zlib=/usr/local --with-szlib=/usr/local --prefix=/usr/local/ &> /comsoftware/libs/build_log_hdf5_config \ + && echo dummy printout to keep travis happy hdf5 config \ + && make install &> /comsoftware/libs/build_log_hdf5_make \ + && echo dummy printout to keep travis happy hdf5 make \ + && rm -rf /comsoftware/libs/hdf5/BUILD_DIR + +# Build netCDF C libraries +# Libraries for netCDF-C +RUN mkdir -p ${NETCDF}/BUILD_DIR +RUN source /opt/rh/devtoolset-8/enable \ + && cd ${NETCDF}/BUILD_DIR \ + && curl -L -O https://github.com/Unidata/netcdf-c/archive/v4.6.2.tar.gz \ + && curl -L -O https://github.com/Unidata/netcdf4-python/archive/v1.5.1rel.tar.gz \ + && tar -xf v4.6.2.tar.gz \ + && cd netcdf-c-4.6.2 \ + && ./configure --enable-shared --prefix=${NETCDF} &> /comsoftware/libs/build_log_ncc_config \ + && echo dummy printout to keep travis happy ncc config \ + && make install &> /comsoftware/libs/build_log_ncc_make \ + && echo dummy printout to keep travis happy ncc make + +# Build netCDF C++ libraries +RUN source /opt/rh/devtoolset-8/enable \ + && cd ${NETCDF}/BUILD_DIR \ + && curl -L -O https://github.com/Unidata/netcdf-cxx4/archive/v4.3.0.tar.gz \ + && tar -xzf v4.3.0.tar.gz \ + && cd netcdf-cxx4-4.3.0 \ + && ./configure --enable-shared CPPFLAGS="-I /comsoftware/libs/netcdf/include -L/comsoftware/libs/netcdf/lib" --prefix=${NETCDF} &> /comsoftware/libs/build_log_ncc_config \ + && export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/comsoftware/libs/netcdf/lib \ + && make install &> /comsoftware/libs/build_log_nccxx_make + +# Build netCDF Fortran libraries +RUN source /opt/rh/devtoolset-8/enable \ + && env \ + && cd ${NETCDF}/BUILD_DIR \ + && curl -L -O https://github.com/Unidata/netcdf-fortran/archive/v4.4.5.tar.gz \ + && tar -xf v4.4.5.tar.gz \ + && cd netcdf-fortran-4.4.5/ \ + && export LD_LIBRARY_PATH=${NETCDF}/lib:${LD_LIBRARY_PATH} \ + && CPPFLAGS=-I${NETCDF}/include LDFLAGS=-L${NETCDF}/lib ./configure --enable-shared --prefix=${NETCDF} &> /comsoftware/libs/build_log_ncf_config \ + && echo dummy printout to keep travis happy ncf config \ + && make install &> /comsoftware/libs/build_log_ncf_make \ + && echo dummy printout to keep travis happy ncf make + +RUN pip3 install --user --upgrade pip \ + && pip3 install numpy f90nml matplotlib scipy configobj pandas shapely wheel \ + && echo pip3 istalled numpy, f90nml, matplotlib, scipy, configobj, and pandas +RUN pip3 install --upgrade setuptools \ + && echo pip3 istalled setuptools +RUN ldconfig -v + +# Build netCDF4-python libraries +RUN source /opt/rh/devtoolset-8/enable \ + && cd ${NETCDF}/BUILD_DIR \ + && tar -xf v1.5.1rel.tar.gz \ + && cd netcdf4-python-1.5.1rel/ \ + && export LD_LIBRARY_PATH=${NETCDF}/lib:${LD_LIBRARY_PATH} \ + && export NETCDF4_DIR=${NETCDF} \ + && export HDF5_DIR=/usr/local \ + && python3 setup.py build \ + && CPPFLAGS="-I${NETCDF}/include -I/usr/local/include" LDFLAGS="-L${NETCDF}/lib -L/usr/local/lib" python3 setup.py install \ + && echo dummy printout to keep travis happy ncf4-python install +#&& python3 setup.py build &> /comsoftware/libs/build_log_ncf4-python_build + +# Download and compile HDF4 and HDFEOS +# +# Libraries for HDF4 +ENV HDF4_URL http://www.hdfgroup.org/ftp/HDF/releases/HDF4.2r3/src/HDF4.2r3.tar.gz +ENV HDFEOS_URL https://dtcenter.org/sites/default/files/community-code/met/docker_data/HDF-EOS2.16v1.00.tar.Z +RUN source /opt/rh/devtoolset-8/enable \ + && echo "Downloading HDF4.2r3 from ${HDF4_URL}" \ + && curl -SL ${HDF4_URL} | tar zxC /comsoftware/libs/ \ + && cd /comsoftware/libs/HDF4.2r3 \ + && LOG_FILE=/comsoftware/libs/HDF4.2r3/configure.log \ + && echo "Configuring HDF4.2r3 and writing log file ${LOG_FILE}" \ + && ./configure F77=gfortran --prefix=/comsoftware/libs/HDF4.2r3 --disable-netcdf > ${LOG_FILE} \ + && cat mfhdf/hdiff/Makefile | sed 's/LIBS = -ljpeg -lz/LIBS = -ljpeg -lz -lm/g' > Makefile_NEW \ + && mv -f Makefile_NEW mfhdf/hdiff/Makefile \ + && LOG_FILE=/comsoftware/libs/HDF4.2r3/make_install.log \ + && echo "Compiling HDF4.2r3 and writing log file ${LOG_FILE}" \ + && make install > ${LOG_FILE} \ + && echo "Downloading hdfeos from ${HDFEOS_URL}" \ + && curl -SL ${HDFEOS_URL} | tar zxC /comsoftware/libs \ + && cd /comsoftware/libs/hdfeos \ + && LOG_FILE=/comsoftware/libs/hdfeos/configure.log \ + && echo "Configuring hdfeos and writing log file ${LOG_FILE}" \ + && ./configure --prefix=/comsoftware/libs/hdfeos --with-hdf4=/comsoftware/libs/HDF4.2r3 CC=/comsoftware/libs/HDF4.2r3/bin/h4cc > ${LOG_FILE} \ + && LOG_FILE=/comsoftware/libs/hdfeos/make_install.log \ + && echo "Compiling hdfeos and writing log file ${LOG_FILE}" \ + && make install > ${LOG_FILE} + +# Build Cmake v3 (centos default is v2.8, which is too old for GSI) +RUN mkdir -p /comsoftware/libs/cmake/BUILD_DIR \ + && source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/cmake/BUILD_DIR \ + && curl -O -L https://github.com/Kitware/CMake/releases/download/v3.16.5/cmake-3.16.5.tar.gz \ + && tar -xf cmake-3.16.5.tar.gz \ + && cd cmake-3.16.5 \ + && ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF \ + && make \ + && make install \ + && cd / \ + && rm -rf /comsoftware/libs/cmake/BUILD_DIR + +# Build OpenBLAS with LAPACK +RUN mkdir -p /comsoftware/libs/openblas/BUILD_DIR +RUN source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/openblas/BUILD_DIR \ + && curl -L -O https://github.com/xianyi/OpenBLAS/archive/v0.3.5.tar.gz \ + && tar -xf v0.3.5.tar.gz \ + && cd OpenBLAS-0.3.5/ \ + && make \ + && make PREFIX=/usr/ install + +# +# Build BUFRLIB +# +RUN mkdir -p /comsoftware/libs/BUFRLIB \ + && cd /comsoftware/libs/BUFRLIB \ + && echo "Downloading BUFRLIB from ${BUFRLIB_URL}" \ + && curl -SL ${BUFRLIB_URL} | tar xC /comsoftware/libs/BUFRLIB \ + && cat preproc.sh | sed 's/cpp /cpp -traditional-cpp /g' > preproc_patch.sh \ + && chmod +x preproc_patch.sh \ + && LOG_FILE=/comsoftware/libs/BUFRLIB/build.log \ + && echo "Compiling BUFRLIB and writing log file ${LOG_FILE}" \ + && ./preproc_patch.sh *.F > ${LOG_FILE} \ + && ${CC} -c -DUNDERSCORE *.c >> ${LOG_FILE} \ + && ${FC} -c -fno-second-underscore *.f >> ${LOG_FILE} \ + && ar crv libbufr.a *.o >> ${LOG_FILE} \ + && rm -f /usr/lib/libbufr.a \ + && cp *.a /usr/lib + + +# Set environment for interactive container shells +RUN echo export LDFLAGS="-lm" >> /etc/bashrc \ + && echo export NETCDF=${NETCDF} >> /etc/bashrc \ + && echo export JASPERINC=/usr/include/jasper/ >> /etc/bashrc \ + && echo export JASPERLIB=/usr/lib64/ >> /etc/bashrc \ + && echo export LD_LIBRARY_PATH="/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8:/usr/lib64/openmpi/lib:${NETCDF}/lib:${LD_LIBRARY_PATH}" >> /etc/bashrc \ + && echo export PATH=".:/opt/rh/devtoolset-8/root/usr/bin:/usr/lib64/openmpi/bin:${NETCDF}/bin:$PATH" >> /etc/bashrc + +RUN echo setenv LDFLAGS "-lm" >> /etc/csh.cshrc \ + && echo setenv NETCDF "${NETCDF}" >> /etc/csh.cshrc \ + && echo setenv JASPERINC "/usr/include/jasper/" >> /etc/csh.cshrc \ + && echo setenv JASPERLIB "/usr/lib64/" >> /etc/csh.cshrc \ + && echo setenv LD_LIBRARY_PATH "/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8:/usr/lib64/openmpi/lib:${NETCDF}/lib:${LD_LIBRARY_PATH}" >> /etc/csh.cshrc \ + && echo setenv PATH ".:/opt/rh/devtoolset-8/root/usr/bin:/usr/lib64/openmpi/bin:${NETCDF}/bin:$PATH" >> /etc/csh.cshrc + +# Set up ssh +RUN mkdir /home/.ssh ; echo "StrictHostKeyChecking no" > /home/.ssh/config +RUN mkdir -p /var/run/sshd \ + && ssh-keygen -A \ + && sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config \ + && sed -i 's/#RSAAuthentication yes/RSAAuthentication yes/g' /etc/ssh/sshd_config \ + && sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config + +# Set up user home space correctly and make sure user has permissions on all stuff in /comsoftware +RUN chown -R comuser:comusers /home \ + && chmod 6755 /home +RUN chown -R comuser:comusers /comsoftware \ + && chmod -R 6755 /comsoftware + + +# all root steps completed above, now below as regular userID comuser +USER comuser +WORKDIR /home + +ENV JASPERINC /usr/include/jasper +ENV JASPERLIB /usr/lib64 +ENV LD_LIBRARY_PATH /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8:/usr/lib64/openmpi/lib:${NETCDF}/lib:${LD_LIBRARY_PATH} +ENV PATH .:/opt/rh/devtoolset-8/root/usr/bin:/usr/lib64/openmpi/bin:${NETCDF}/bin:$PATH + +RUN ssh-keygen -f /home/.ssh/id_rsa -t rsa -N '' \ + && chmod 600 /home/.ssh/config \ + && chmod 700 /home/.ssh \ + && cp /home/.ssh/id_rsa.pub /home/.ssh/authorized_keys +# diff --git a/models/WRF/dtcenter/Dockerfile.wrf b/models/WRF/dtcenter/Dockerfile.wrf new file mode 100644 index 0000000000000000000000000000000000000000..be9459358f16b723385543e86be6a5c9f6b3edee --- /dev/null +++ b/models/WRF/dtcenter/Dockerfile.wrf @@ -0,0 +1,63 @@ +ARG BASE_IMAGE=dtcenter/base_image:latest +FROM $BASE_IMAGE +MAINTAINER Michael Kavulich <kavulich@ucar.edu> or Jamie Wolff <jwolff@ucar.edu> or Michelle Harrold <harrold@ucar.edu> +# +# This Dockerfile compiles WRF from source during "docker build" step +USER comuser +RUN umask 0002 \ + && mkdir /comsoftware/wrf +WORKDIR /comsoftware/wrf +ENV WRF_VERSION 4.3 +ENV WPS_VERSION 4.3 +# +# Download original sources +# +RUN umask 0002 \ + && curl -SL https://github.com/wrf-model/WRF/archive/v${WRF_VERSION}.tar.gz | tar zxC /comsoftware/wrf \ + && curl -SL https://github.com/wrf-model/WPS/archive/v${WPS_VERSION}.tar.gz | tar zxC /comsoftware/wrf +# +# Set environment for interactive container shells +# +RUN echo export LDFLAGS="-lm" >> /home/.bashrc \ + && echo export LD_LIBRARY_PATH="/usr/lib64/openmpi/lib:/comsoftware/libs/netcdf/lib" >> /home/.bashrc \ + && echo export PATH="/usr/lib64/openmpi/bin:$PATH" >> /home/.bashrc \ + && echo setenv LDFLAGS "-lm" >> /home/.cshrc \ + && echo setenv LD_LIBRARY_PATH "/usr/lib64/openmpi/lib:/comsoftware/libs/netcdf/lib" >> /home/.cshrc \ + && echo setenv PATH "/usr/lib64/openmpi/bin:$PATH" >> /home/.cshrc +# +# Build WRF first +# input 34 and 1 to configure script alternative line = && echo -e "34\r1\r" | ./configure +# +RUN umask 0002 \ + && export NETCDF=/comsoftware/libs/netcdf/ \ + && export JASPERINC=/usr/include/jasper/ \ + && export JASPERLIB=/usr/lib64/ \ + && export J='-j 4' \ + && cd ./WRF-${WRF_VERSION} \ + && ./configure <<< $'34\r1\r' \ + && sed -i -e '/^DM_CC/ s/$/ -DMPI2_SUPPORT/' ./configure.wrf \ + && sed -i '/BUILD_RRTMG_FAST/d' ./configure.wrf \ + && /bin/csh ./compile em_real > compile_wrf_arw_opt34.1.log 2>&1 +# Check build success +RUN ls /comsoftware/wrf/WRF-${WRF_VERSION}/main/real.exe /comsoftware/wrf/WRF-${WRF_VERSION}/main/wrf.exe +# +# Build WPS second +# +# input 1 to configure script (gfortran serial build) +RUN umask 0002 \ + && ln -sf WRF-${WRF_VERSION} WRF \ + && cd ./WPS-${WPS_VERSION} \ + && echo export NETCDF=/comsoftware/libs/netcdf/ \ + && export JASPERINC=/usr/include/jasper/ \ + && export JASPERLIB=/usr/lib64/ \ + && ./configure <<< $'1\r' \ + && sed -i -e 's/-L$(NETCDF)\/lib/-L$(NETCDF)\/lib -lnetcdff /' ./configure.wps \ + && /bin/csh ./compile > compile_wps.log 2>&1 +# Check build success +RUN ls /comsoftware/wrf/WPS-${WPS_VERSION}/metgrid.exe /comsoftware/wrf/WPS-${WPS_VERSION}/ungrib.exe /comsoftware/wrf/WPS-${WPS_VERSION}/geogrid.exe +# +ENV LD_LIBRARY_PATH /usr/lib64/openmpi/lib:/comsoftware/libs/netcdf/lib +ENV PATH /usr/lib64/openmpi/bin:$PATH +# +# +USER root diff --git a/models/WRF/dtcenter/Singularity.dtcenter.base b/models/WRF/dtcenter/Singularity.dtcenter.base new file mode 100644 index 0000000000000000000000000000000000000000..8fc4b80925975516c6a530e28934c972d4f12739 --- /dev/null +++ b/models/WRF/dtcenter/Singularity.dtcenter.base @@ -0,0 +1,225 @@ +Bootstrap: docker +From: centos:7 + +%labels + MAINTAINER Michael Kavulich <kavulich@ucar.edu> +%post +# Set up base OS environment +yum -y update \ + && yum -y install scl file gcc gcc-gfortran gcc-c++ glibc.i686 libgcc.i686 libpng-devel jasper \ + jasper-devel hostname m4 make perl tar bash ksh tcsh time wget which zlib zlib-devel \ + openssh-clients openssh-server net-tools fontconfig libgfortran libXext libXrender \ + libxml2 libxml2-devel perl-XML-LibXML ImageMagick sudo epel-release git \ + # Libraries for NetCDF + && yum -y install libcurl-devel zlib-devel \ + && yum -y install python3 python3-pip python3-devel \ + # Libraries for HDF4 + && yum -y install flex flex-devel bison bison-devel \ + # Download GNU version 8 compilers via devtoolset + && yum -y install centos-release-scl \ + && yum -y install devtoolset-8 \ + && yum -y install devtoolset-8-gcc devtoolset-8-gcc-gfortran devtoolset-8-gcc-c++ \ + && scl enable devtoolset-8 bash \ + && scl enable devtoolset-8 tcsh + +#Source code locations +HDF4_URL=http://www.hdfgroup.org/ftp/HDF/releases/HDF4.2r3/src/HDF4.2r3.tar.gz +HDFEOS_URL=https://dtcenter.org/sites/default/files/community-code/met/docker_data/HDF-EOS2.16v1.00.tar.Z +BUFRLIB_URL=https://dtcenter.org/sites/default/files/community-code/met/docker_data/BUFRLIB_v10-2-3.tar + +#Compiler environment variables +CC=/opt/rh/devtoolset-8/root/usr/bin/gcc +FC=/opt/rh/devtoolset-8/root/usr/bin/gfortran + +# Build libraries with a parallel Make +J=4 + +# Other necessary environment variables +LD_LIBRARY_PATH=/usr/local/lib +NETCDF=/comsoftware/libs/netcdf +mkdir /comsoftware + +# Build OpenMPI +mkdir -p /comsoftware/libs/openmpi/BUILD_DIR +source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/openmpi/BUILD_DIR \ + && curl -L -O https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.0.tar.gz \ + && tar -xf openmpi-4.0.0.tar.gz \ + && cd openmpi-4.0.0 \ + && ./configure --prefix=/usr/local &> /comsoftware/libs/build_log_openmpi_config \ + && echo dummy printout to keep travis happy openmpi config \ + && make all install \ + && echo "make all install | awk 'NR % 1000 == 0'" \ + && echo "make all install &> /comsoftware/libs/build_log_openmpi_make" \ + && echo dummy printout to keep travis happy openmpi make \ + && cd / \ + && rm -rf /comsoftware/libs/openmpi/BUILD_DIR + +# Build SZIP libraries +mkdir -p /comsoftware/libs/szip/BUILD_DIR +source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/szip/BUILD_DIR \ + && curl -L -O https://support.hdfgroup.org/ftp/lib-external/szip/2.1.1/src/szip-2.1.1.tar.gz \ + && tar -xf szip-2.1.1.tar.gz \ + && cd szip-2.1.1 \ + && ./configure --prefix=/usr/local/ &> /comsoftware/libs/build_log_szip_config \ + && echo dummy printout to keep travis happy szip config \ + && make install &> /comsoftware/libs/build_log_szip_make \ + && echo dummy printout to keep travis happy szip make \ + && rm -rf /comsoftware/libs/szip/BUILD_DIR + +# Build HDF5 libraries +mkdir -p /comsoftware/libs/hdf5/BUILD_DIR +source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/hdf5/BUILD_DIR \ + && git clone https://bitbucket.hdfgroup.org/scm/hdffv/hdf5.git \ + && cd hdf5 \ + && git checkout hdf5-1_10_4 \ + && ./configure --enable-fortran --enable-cxx --enable-shared --with-zlib=/usr/local --with-szlib=/usr/local --prefix=/usr/local/ &> /comsoftware/libs/build_log_hdf5_config \ + && echo dummy printout to keep travis happy hdf5 config \ + && make install &> /comsoftware/libs/build_log_hdf5_make \ + && echo dummy printout to keep travis happy hdf5 make \ + && rm -rf /comsoftware/libs/hdf5/BUILD_DIR + +# Build netCDF C libraries +# Libraries for netCDF-C +mkdir -p ${NETCDF}/BUILD_DIR +source /opt/rh/devtoolset-8/enable \ + && cd ${NETCDF}/BUILD_DIR \ + && curl -L -O https://github.com/Unidata/netcdf-c/archive/v4.6.2.tar.gz \ + && curl -L -O https://github.com/Unidata/netcdf4-python/archive/v1.5.1rel.tar.gz \ + && tar -xf v4.6.2.tar.gz \ + && cd netcdf-c-4.6.2 \ + && ./configure --enable-shared --prefix=${NETCDF} &> /comsoftware/libs/build_log_ncc_config \ + && echo dummy printout to keep travis happy ncc config \ + && make install &> /comsoftware/libs/build_log_ncc_make \ + && echo dummy printout to keep travis happy ncc make + +# Build netCDF C++ libraries +source /opt/rh/devtoolset-8/enable \ + && cd ${NETCDF}/BUILD_DIR \ + && curl -L -O https://github.com/Unidata/netcdf-cxx4/archive/v4.3.0.tar.gz \ + && tar -xzf v4.3.0.tar.gz \ + && cd netcdf-cxx4-4.3.0 \ + && ./configure --enable-shared CPPFLAGS="-I /comsoftware/libs/netcdf/include -L/comsoftware/libs/netcdf/lib" --prefix=${NETCDF} &> /comsoftware/libs/build_log_ncc_config \ + && export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/comsoftware/libs/netcdf/lib \ + && make install &> /comsoftware/libs/build_log_nccxx_make + +# Build netCDF Fortran libraries +source /opt/rh/devtoolset-8/enable \ + && env \ + && cd ${NETCDF}/BUILD_DIR \ + && curl -L -O https://github.com/Unidata/netcdf-fortran/archive/v4.4.5.tar.gz \ + && tar -xf v4.4.5.tar.gz \ + && cd netcdf-fortran-4.4.5/ \ + && export LD_LIBRARY_PATH=${NETCDF}/lib:${LD_LIBRARY_PATH} \ + && CPPFLAGS=-I${NETCDF}/include LDFLAGS=-L${NETCDF}/lib ./configure --enable-shared --prefix=${NETCDF} &> /comsoftware/libs/build_log_ncf_config \ + && echo dummy printout to keep travis happy ncf config \ + && make install &> /comsoftware/libs/build_log_ncf_make \ + && echo dummy printout to keep travis happy ncf make + +pip3 install --user --upgrade pip \ + && pip3 install numpy f90nml matplotlib scipy configobj pandas shapely wheel \ + && echo pip3 istalled numpy, f90nml, matplotlib, scipy, configobj, and pandas +pip3 install --upgrade setuptools \ + && echo pip3 istalled setuptools +ldconfig -v + +# Build netCDF4-python libraries +source /opt/rh/devtoolset-8/enable \ + && cd ${NETCDF}/BUILD_DIR \ + && tar -xf v1.5.1rel.tar.gz \ + && cd netcdf4-python-1.5.1rel/ \ + && export LD_LIBRARY_PATH=${NETCDF}/lib:${LD_LIBRARY_PATH} \ + && export NETCDF4_DIR=${NETCDF} \ + && export HDF5_DIR=/usr/local \ + && python3 setup.py build \ + && CPPFLAGS="-I${NETCDF}/include -I/usr/local/include" LDFLAGS="-L${NETCDF}/lib -L/usr/local/lib" python3 setup.py install \ + && echo dummy printout to keep travis happy ncf4-python install +#&& python3 setup.py build &> /comsoftware/libs/build_log_ncf4-python_build + +# Download and compile HDF4 and HDFEOS +# +# Libraries for HDF4 +HDF4_URL=http://www.hdfgroup.org/ftp/HDF/releases/HDF4.2r3/src/HDF4.2r3.tar.gz +HDFEOS_URL=https://dtcenter.org/sites/default/files/community-code/met/docker_data/HDF-EOS2.16v1.00.tar.Z +source /opt/rh/devtoolset-8/enable \ + && echo "Downloading HDF4.2r3 from ${HDF4_URL}" \ + && curl -SL ${HDF4_URL} | tar zxC /comsoftware/libs/ \ + && cd /comsoftware/libs/HDF4.2r3 \ + && LOG_FILE=/comsoftware/libs/HDF4.2r3/configure.log \ + && echo "Configuring HDF4.2r3 and writing log file ${LOG_FILE}" \ + && ./configure F77=gfortran --prefix=/comsoftware/libs/HDF4.2r3 --disable-netcdf > ${LOG_FILE} \ + && cat mfhdf/hdiff/Makefile | sed 's/LIBS = -ljpeg -lz/LIBS = -ljpeg -lz -lm/g' > Makefile_NEW \ + && mv -f Makefile_NEW mfhdf/hdiff/Makefile \ + && LOG_FILE=/comsoftware/libs/HDF4.2r3/make_install.log \ + && echo "Compiling HDF4.2r3 and writing log file ${LOG_FILE}" \ + && make install > ${LOG_FILE} \ + && echo "Downloading hdfeos from ${HDFEOS_URL}" \ + && curl -SL ${HDFEOS_URL} | tar zxC /comsoftware/libs \ + && cd /comsoftware/libs/hdfeos \ + && LOG_FILE=/comsoftware/libs/hdfeos/configure.log \ + && echo "Configuring hdfeos and writing log file ${LOG_FILE}" \ + && ./configure --prefix=/comsoftware/libs/hdfeos --with-hdf4=/comsoftware/libs/HDF4.2r3 CC=/comsoftware/libs/HDF4.2r3/bin/h4cc > ${LOG_FILE} \ + && LOG_FILE=/comsoftware/libs/hdfeos/make_install.log \ + && echo "Compiling hdfeos and writing log file ${LOG_FILE}" \ + && make install > ${LOG_FILE} + +# Build Cmake v3 (centos default is v2.8, which is too old for GSI) +mkdir -p /comsoftware/libs/cmake/BUILD_DIR \ + && source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/cmake/BUILD_DIR \ + && curl -O -L https://github.com/Kitware/CMake/releases/download/v3.16.5/cmake-3.16.5.tar.gz \ + && tar -xf cmake-3.16.5.tar.gz \ + && cd cmake-3.16.5 \ + && ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF \ + && make \ + && make install \ + && cd / \ + && rm -rf /comsoftware/libs/cmake/BUILD_DIR + +# Build OpenBLAS with LAPACK +mkdir -p /comsoftware/libs/openblas/BUILD_DIR +source /opt/rh/devtoolset-8/enable \ + && cd /comsoftware/libs/openblas/BUILD_DIR \ + && curl -L -O https://github.com/xianyi/OpenBLAS/archive/v0.3.5.tar.gz \ + && tar -xf v0.3.5.tar.gz \ + && cd OpenBLAS-0.3.5/ \ + && make \ + && make PREFIX=/usr/ install + +# +# Build BUFRLIB +# +mkdir -p /comsoftware/libs/BUFRLIB \ + && cd /comsoftware/libs/BUFRLIB \ + && echo "Downloading BUFRLIB from ${BUFRLIB_URL}" \ + && curl -SL ${BUFRLIB_URL} | tar xC /comsoftware/libs/BUFRLIB \ + && cat preproc.sh | sed 's/cpp /cpp -traditional-cpp /g' > preproc_patch.sh \ + && chmod +x preproc_patch.sh \ + && LOG_FILE=/comsoftware/libs/BUFRLIB/build.log \ + && echo "Compiling BUFRLIB and writing log file ${LOG_FILE}" \ + && ./preproc_patch.sh *.F > ${LOG_FILE} \ + && ${CC} -c -DUNDERSCORE *.c >> ${LOG_FILE} \ + && ${FC} -c -fno-second-underscore *.f >> ${LOG_FILE} \ + && ar crv libbufr.a *.o >> ${LOG_FILE} \ + && rm -f /usr/lib/libbufr.a \ + && cp *.a /usr/lib + +%environment +export LDFLAGS="-lm" +export CC=/opt/rh/devtoolset-8/root/usr/bin/gcc +export FC=/opt/rh/devtoolset-8/root/usr/bin/gfortran +export J=4 +export LD_LIBRARY_PATH=/usr/local/lib +export NETCDF=/comsoftware/libs/netcdf +export JASPERINC=/usr/include/jasper +export JASPERLIB=/usr/lib64 +export LD_LIBRARY_PATH=/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8:/usr/lib64/openmpi/lib:${NETCDF}/lib:${LD_LIBRARY_PATH} +export PATH=.:/opt/rh/devtoolset-8/root/usr/bin:/usr/lib64/openmpi/bin:${NETCDF}/bin:$PATH + +%runscript +exec /bin/bash "$@" + +%startscript +exec /bin/bash "$@" diff --git a/models/WRF/dtcenter/Singularity.dtcenter.wrf b/models/WRF/dtcenter/Singularity.dtcenter.wrf new file mode 100644 index 0000000000000000000000000000000000000000..eae48d60fd2f727d3937ad7618de1ced52ff15ad --- /dev/null +++ b/models/WRF/dtcenter/Singularity.dtcenter.wrf @@ -0,0 +1,76 @@ +Bootstrap: docker +From: dtcenter/base_image:latest +Stage: spython-base + +%labels +MAINTAINER Michael Kavulich <kavulich@ucar.edu> or Jamie Wolff <jwolff@ucar.edu> or Michelle Harrold <harrold@ucar.edu> +%post +BASE_IMAGE=dtcenter/base_image:latest +# +# This Dockerfile compiles WRF from source during "docker build" step +su - comuser # USER comuser +umask 0002 \ +&& mkdir /comsoftware/wrf +cd /comsoftware/wrf +WRF_VERSION=4.3 +WPS_VERSION=4.3 +# +# Download original sources +# +umask 0002 \ +&& curl -SL https://github.com/wrf-model/WRF/archive/v${WRF_VERSION}.tar.gz | tar zxC /comsoftware/wrf \ +&& curl -SL https://github.com/wrf-model/WPS/archive/v${WPS_VERSION}.tar.gz | tar zxC /comsoftware/wrf +# +# Set environment for interactive container shells +# +echo export LDFLAGS="-lm" >> /home/.bashrc \ +&& echo export LD_LIBRARY_PATH="/usr/lib64/openmpi/lib:/comsoftware/libs/netcdf/lib" >> /home/.bashrc \ +&& echo export PATH="/usr/lib64/openmpi/bin:$PATH" >> /home/.bashrc \ +&& echo setenv LDFLAGS "-lm" >> /home/.cshrc \ +&& echo setenv LD_LIBRARY_PATH "/usr/lib64/openmpi/lib:/comsoftware/libs/netcdf/lib" >> /home/.cshrc \ +&& echo setenv PATH "/usr/lib64/openmpi/bin:$PATH" >> /home/.cshrc +# +# Build WRF first +# input 34 and 1 to configure script alternative line = && echo -e "34\r1\r" | ./configure +# +umask 0002 \ +&& export NETCDF=/comsoftware/libs/netcdf/ \ +&& export JASPERINC=/usr/include/jasper/ \ +&& export JASPERLIB=/usr/lib64/ \ +&& export J='-j 4' \ +&& cd ./WRF-${WRF_VERSION} \ +&& ./configure <<< $'34\r1\r' \ +&& sed -i -e '/^DM_CC/ s/$/ -DMPI2_SUPPORT/' ./configure.wrf \ +&& sed -i '/BUILD_RRTMG_FAST/d' ./configure.wrf \ +&& /bin/csh ./compile em_real > compile_wrf_arw_opt34.1.log 2>&1 +# Check build success +ls /comsoftware/wrf/WRF-${WRF_VERSION}/main/real.exe /comsoftware/wrf/WRF-${WRF_VERSION}/main/wrf.exe +# +# Build WPS second +# +# input 1 to configure script (gfortran serial build) +umask 0002 \ +&& ln -sf WRF-${WRF_VERSION} WRF \ +&& cd ./WPS-${WPS_VERSION} \ +&& echo export NETCDF=/comsoftware/libs/netcdf/ \ +&& export JASPERINC=/usr/include/jasper/ \ +&& export JASPERLIB=/usr/lib64/ \ +&& ./configure <<< $'1\r' \ +&& sed -i -e 's/-L$(NETCDF)\/lib/-L$(NETCDF)\/lib -lnetcdff /' ./configure.wps \ +&& /bin/csh ./compile > compile_wps.log 2>&1 +# Check build success +ls /comsoftware/wrf/WPS-${WPS_VERSION}/metgrid.exe /comsoftware/wrf/WPS-${WPS_VERSION}/ungrib.exe /comsoftware/wrf/WPS-${WPS_VERSION}/geogrid.exe + +%environment +export WRF_VERSION=4.3 +export WPS_VERSION=4.3 +export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib:/comsoftware/libs/netcdf/lib +export PATH=/usr/lib64/openmpi/bin:$PATH + +%runscript +cd /comsoftware/wrf +exec /bin/bash "$@" + +%startscript +cd /comsoftware/wrf +exec /bin/bash "$@" diff --git a/models/WRF/hurricane-sany-example.sh b/models/WRF/hurricane-sany-example.sh new file mode 100755 index 0000000000000000000000000000000000000000..f5b73716a2780d23c42e26e45b521dc65c41012c --- /dev/null +++ b/models/WRF/hurricane-sany-example.sh @@ -0,0 +1,99 @@ +#!/bin/bash +# By MB +# Based on the Example from DTCenter, Boulder NCAR. +# https://dtcenter.org/nwp-containers-online-tutorial +# https://dtcenter.org/nwp-containers-online-tutorial/hurricane-sandy-case-27-oct-2012 + +CPATH=$(dirname $0) +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' + +pause() { + if $DEBUG; then + read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n' + fi +} + +warning() { + printf "%-68s[$YELLOW%10s$NC]\n" "$@" "SKIPPED" + return 0 +} + +report() { + if [ $? -eq 0 ]; then + printf "%-68s[$GREEN%10s$NC]\n" "$@" "OK" + return 0 + else + printf "%-68s[$RED%10s$NC]\n" "$@" "FAILED" + return 1 + fi +} + +question(){ + read -p "$@ (y/n)" yn + case $yn in + [Yy]*) return 0;; + * ) warning "skipping"; return 1;; + esac +} + +INAME="SANDY" +# Check if we have the container? + +test -f Makefile +report "[$INAME] Makefile found" +if [ $? -eq 0 ]; then + echo "[$INAME] Building WRF ..." + make em_real +fi + +test -f WRF-4.4.1-em_real.sif +report "[$INAME] WRF em_real container available" || exit 1 + +PROJ_PATH= +read -p "[$INAME] Where do you want to place all files? [$PWD] :" PROJ_PATH +if [ -z "$PROJ_PATH" ]; then + PROJ_PATH=. +fi + +mkdir -vp $PROJ_PATH/sandy/data/ +report "[$INAME] using $PROJ_PATH" +cd $PROJ_PATH/sandy/data/ +# curl -SL https://dtcenter.ucar.edu/dfiles/container_nwp_tutorial/tar_files/container-dtc-nwp-derechodata_20120629.tar.gz | tar zxC . +# curl -SL https://dtcenter.ucar.edu/dfiles/container_nwp_tutorial/tar_files/container-dtc-nwp-snowdata_20160123.tar.gz | tar zxC . + +test -d model_data +report "[$INAME] Sandy input data" +if [ $? -ne 0 ]; then + curl -SL https://dtcenter.ucar.edu/dfiles/container_nwp_tutorial/tar_files/container-dtc-nwp-sandydata_20121027.tar.gz | tar zxC . + report "[$INAME] using Sandy input data" || exit 1 +fi +test -d obs_data +report "[$INAME] Sandy obs data" +if [ $? -ne 0 ]; then + curl -SL https://dtcenter.ucar.edu/dfiles/container_nwp_tutorial/tar_files/CRTM_v2.3.0.tar.gz | tar zxC . + report "[$INAME] using Sandy obs data" || exit 1 +fi +test -d WPS_GEOG +report "[$INAME] Sandy geogrid data" +if [ $? -ne 0 ]; then + curl -SL https://dtcenter.ucar.edu/dfiles/container_nwp_tutorial/tar_files/wps_geog.tar.gz | tar zxC . + report "[$INAME] using Sandy geogrid data" || exit 1 +fi +test -d shapefiles +report "[$INAME] Sandy trajectory data" +if [ $? -ne 0 ]; then + curl -SL https://dtcenter.ucar.edu/dfiles/container_nwp_tutorial/tar_files/shapefiles.tar.gz | tar zxC . + report "[$INAME] using Sandy trajectory data" || exit 1 +fi + +exit 0 +/home/scripts/common/run_python_domain.ksh + +WPS_GEOG +/home/scripts/common/run_wps.ksh + + +/home/scripts/common/run_real.ksh \ No newline at end of file diff --git a/models/WRF/scripts/run-help b/models/WRF/scripts/run-help new file mode 100644 index 0000000000000000000000000000000000000000..a0351f7527dc606864b7290552d474ce61eba37b --- /dev/null +++ b/models/WRF/scripts/run-help @@ -0,0 +1,37 @@ +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 + + +WRF Simulations - Example +default run files are located in /wrf/run +executables are located in /wrf/bin + +Default simulation of the container (still requires input) +1. copies /wrf/run files to the local directory +2. No local files will be overwritten (e.g. namelists ) +3. Execute real.exe +> ./image.sif real.exe + +Manually copy run files to current directory +> ./image.sif init + +Compilation log files are located in /wrf +> ./image.sif zcat /wrf/compile_wrf_arw_opt34.1.log.gz | less + +Ask for help: it.img-wien@univie.ac.at +Gitlab: https://gitlab.phaidra.org/imgw/singularity diff --git a/models/WRF/scripts/runscript b/models/WRF/scripts/runscript new file mode 100644 index 0000000000000000000000000000000000000000..f02abe0c386132a59ab2f7b9f8a1a54197da5b8b --- /dev/null +++ b/models/WRF/scripts/runscript @@ -0,0 +1,29 @@ +#!/bin/sh +# overwrite any existing runscript +# add IMGW customized PROMPT_COMMAND +if [ $# -gt 0 ]; then + if [ "$1" == "init" ]; then + echo "[WRF] Copying default run files here" + cp -rvu /wrf/run/* . + exit 0 + elif [ ! -f namelist.input ]; then + # copy necessary files to current directory + echo "[WRF] Updating default/missing run files here" + cp -rvu /wrf/run/* . + else + echo "[WRF] no automatic copying" + fi + # run cmd line options + echo "Executing" + exec "$@" + echo "Finished inside the container." +else + # interactive + echo "Welcome inside an IMGW container!" + echo "Get help: singularity run-help $SINGULARITY_NAME" + echo "WRF ($WRF_VERSION, $WRF_BUILD_TARGET)" + echo "WRF $WRF_BUILD_TARGET -> /wrf/run" + echo "WRF exe -> /wrf/bin" + cd /wrf/run + exec /.singularity.d/actions/shell "$@" +fi \ No newline at end of file