Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mvu25s #993

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jupyter-images/mvu25s/.condarc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
envs_dirs:
- /home/jovyan/additional-envs
43 changes: 43 additions & 0 deletions jupyter-images/mvu25s/Acknowledgements.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "c86cd54f-b73c-4781-b6eb-89c79d3d3b22",
"metadata": {},
"source": [
"## Acknowledgements\n",
"\n",
"Launching this JupyterHub server is the result of a collaboration between several research and academic institutions and their staff. For Jetstream2 and JupyterHub expertise, we thank Andrea Zonca (San Diego Supercomputing Center), Jeremy Fischer, Mike Lowe (Indiana University), the NSF Jetstream2 (`doi:10.1145/3437359.3465565`) team.\n",
"\n",
"This work employs the NSF Jetstream2 Cloud at Indiana University through allocation EES220002 from the Advanced Cyberinfrastructure Coordination Ecosystem: Services & Support (ACCESS) program, which is supported by National Science Foundation grants #2138259, #2138286, #2138307, #2137603, and #2138296.\n",
"\n",
"Unidata is one of the University Corporation for Atmospheric Research (UCAR)'s Community Programs (UCP), and is funded primarily by the National Science Foundation (AGS-2403649).\n",
"\n",
"## To Acknowledge This JupyterHub and the Unidata Science Gateway\n",
"\n",
"If you have benefited from the Unidata Science Gateway, please cite `doi:10.5065/688s-2w73`. Additional citation information can be found in this [Citation File Format file](https://raw.githubusercontent.com/Unidata/science-gateway/master/CITATION.cff).\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
195 changes: 195 additions & 0 deletions jupyter-images/mvu25s/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
# Multistage Docker build to include the WRF single column model in a
# JupyterLab environment

FROM ubuntu as build-wrf

####################################################
# Begin WRF ideal single column model compilation #
####################################################

# Mostly following the steps outlined here:
# https://forum.mmm.ucar.edu/threads/full-wrf-and-wps-installation-example.12385/

# Dependencies missing from base image
RUN apt-get update && apt-get install --yes --no-install-recommends \
gcc cpp gfortran g++ openmpi-bin libopenmpi-dev git csh perl file \
make m4 curl vim ca-certificates && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Run tests recommended by MMM to confirm the fortran and c compilers are
# functioning as expected
# https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php#STEP1
RUN set -x && cd / && mkdir TESTS && cd TESTS && \
curl https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_tests.tar -O && \
tar -xf Fortran_C_tests.tar && \
gfortran TEST_1_fortran_only_fixed.f && ./a.out && \
gfortran TEST_2_fortran_only_free.f90 && ./a.out && \
gcc TEST_3_c_only.c && ./a.out && \
gcc -c -m64 TEST_4_fortran+c_c.c && gfortran -c -m64 TEST_4_fortran+c_f.f90 && \
gfortran -m64 TEST_4_fortran+c_f.o TEST_4_fortran+c_c.o && ./a.out && \
./TEST_csh.csh && \
./TEST_perl.pl && \
./TEST_sh.sh && \
cd / && rm -rf TESTS

# Test for other utilities
RUN which ar awk cat cp cut expr file grep gzip \
head hostname ln ls make mkdir mv nm printf rm \
sed sleep sort tar touch tr uname wc which m4

###########################################################
# Library and software versions
###########################################################

ENV NETCDF_VERSION=4.9.0 \
NETCDF_F_VERSION=4.5.3 \
WRF_VERSION=4.4.2

###########################################################
# Library and software PATHS
###########################################################

ENV DIR=/Build_WRF/LIBRARIES
ENV NETCDF=$DIR/netcdf
ENV PATH=$NETCDF/bin:$PATH \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF/lib:/$ZLIB_DIR/lib

RUN mkdir -p $DIR

###########################################################
# Compiler options
###########################################################

ENV CC=gcc \
CXX=g++ \
FC=gfortran \
FCFLAGS=-m64 \
F77=gfortran \
FFLAGS=-m64 \
LDFLAGS="-L$NETCDF/lib" \
CPPFLAGS="-I$NETCDF/include"

###########################################################
# Build libraries
###########################################################

# netcdf-c
# BUILT WITH "--disable-netcdf4" SO WE COMPILE WRF WITH "NETCDF_classic"
RUN set -x && \
cd / && mkdir -p Build_WRF/LIBRARIES && cd Build_WRF/LIBRARIES && \
curl https://downloads.unidata.ucar.edu/netcdf-c/$NETCDF_VERSION/netcdf-c-$NETCDF_VERSION.tar.gz -O && \
tar xzvf netcdf-c-$NETCDF_VERSION.tar.gz && \
cd netcdf-c-$NETCDF_VERSION && \
./configure --enable-shared --disable-netcdf4 --disable-filter-testing --disable-dap --prefix=$DIR/netcdf && \
make && make install && \
cd .. && rm -rf netcdf-c-$NETCDF_VERSION*

# netcdf-f
RUN set -x && \
export CPPFLAGS="-I$NETCDF/include -L$NETCDF/lib" && \
cd /Build_WRF/LIBRARIES && \
curl https://downloads.unidata.ucar.edu/netcdf-fortran/$NETCDF_F_VERSION/netcdf-fortran-$NETCDF_F_VERSION.tar.gz -O && \
tar xzvf netcdf-fortran-$NETCDF_F_VERSION.tar.gz && \
cd netcdf-fortran-$NETCDF_F_VERSION && \
./configure --prefix=$DIR/netcdf --disable-shared && \
make && make install && \
cd .. && rm -rf netcdf-fortran-$NETCDF_F_VERSION

###########################################################
# Verify libraries will play nice with the compilers used to build WRF
###########################################################

# https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php#STEP3

RUN set -x && \
cd / && mkdir TESTS && cd TESTS && \
curl https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compile_tutorial/tar_files/Fortran_C_NETCDF_MPI_tests.tar -O && \
tar -xf Fortran_C_NETCDF_MPI_tests.tar && \
cp ${NETCDF}/include/netcdf.inc . && \
gfortran -c 01_fortran+c+netcdf_f.f && \
gcc -c 01_fortran+c+netcdf_c.c && \
gfortran 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o -L${NETCDF}/lib -lnetcdff -lnetcdf && \
./a.out && \
mpif90 -c 02_fortran+c+netcdf+mpi_f.f && \
mpicc -c 02_fortran+c+netcdf+mpi_c.c && \
mpif90 02_fortran+c+netcdf+mpi_f.o 02_fortran+c+netcdf+mpi_c.o -L${NETCDF}/lib -lnetcdff -lnetcdf && \
mpirun --allow-run-as-root ./a.out && \
cd / && rm -rf TESTS

###########################################################
# Actually build WRF
###########################################################

# At the moment, the configure script on the repo has an open issue regarding
# string comparison:
# https://github.com/wrf-model/WRF/issues/1817
COPY ./configure /tmp/configure
COPY ./Registry.EM_COMMON_edit /tmp/Registry.EM_COMMON_edit

# ./configure won't run with the options (33 and 0) if this variable is not set
ENV NETCDF_classic=1

# Piping the output of "echo '33\r0\r'" tells the script to configure WRF to
# compile for parallel using smpar and the GNU compilers we have been using (33)
# and to compile for no nesting (0)
RUN set -x && \
cd /Build_WRF && \
git clone --recurse-submodule https://github.com/wrf-model/WRF.git && \
cd WRF && \
git checkout release-v${WRF_VERSION} && \
mv /tmp/Registry.EM_COMMON_edit ./Registry/Registry.EM_COMMON && \
mv /tmp/configure ./configure && chmod u+x ./configure && \
git diff && \
echo '33\r0\r' | ./configure && \
./compile em_scm_xy > log.compile 2>&1

###########################################################
# Begin JupyterLab Stage
###########################################################

# Heavily borrowed from docker-stacks/minimal-notebook/
# https://github.com/jupyter/docker-stacks/blob/main/minimal-notebook/Dockerfile

FROM quay.io/jupyter/minimal-notebook

ENV DEFAULT_ENV_NAME=mvu25s EDITOR=nano VISUAL=nano

LABEL maintainer="Unidata <support-gateway@unidata.ucar.edu>"

USER root

RUN apt-get update && \
apt-get install -y --no-install-recommends vim nano curl wget zip unzip \
gcc cpp gfortran g++ openmpi-bin libopenmpi-dev git csh perl file \
make m4 ca-certificates libgl1 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

USER $NB_UID

ADD environment.yml /tmp

RUN mamba install --quiet --yes \
'conda-forge::nb_conda_kernels' \
'conda-forge::jupyterlab-git' \
'conda-forge::ipywidgets' && \
mamba env create --name $DEFAULT_ENV_NAME -f /tmp/environment.yml && \
pip install --no-cache-dir nbgitpuller && \
mamba clean --all -f -y && \
jupyter lab clean -y && \
#npm cache clean --force && \
rm -rf /home/$NB_USER/.cache/yarn && \
rm -rf /home/$NB_USER/.node-gyp && \
fix-permissions $CONDA_DIR && \
fix-permissions /home/$NB_USER

COPY additional_kernels.ipynb update_material.ipynb Acknowledgements.ipynb \
default_kernel.py .condarc /

COPY --from=build-wrf /Build_WRF /Build_WRF

USER root
RUN chown -R ${NB_UID}:${NB_GID} /Build_WRF/WRF && \
ldconfig /Build_WRF/LIBRARIES/netcdf/lib

USER $NB_UID
Loading