From 5b540bea6abe2af0af691e1d8b30d6c4a08de13e Mon Sep 17 00:00:00 2001 From: Daniel Rosen Date: Fri, 25 Sep 2026 08:40:27 -0600 Subject: [PATCH] Add CDEPS Dev Container to repo --- .devcontainer/ubuntu-24.04_gcc-13/Dockerfile | 161 ++++++++++++++++++ .devcontainer/ubuntu-24.04_gcc-13/README.md | 77 +++++++++ .../ubuntu-24.04_gcc-13/devcontainer.json | 24 +++ .devcontainer/ubuntu-24.04_gcc-13/envsetup.sh | 36 ++++ 4 files changed, 298 insertions(+) create mode 100644 .devcontainer/ubuntu-24.04_gcc-13/Dockerfile create mode 100644 .devcontainer/ubuntu-24.04_gcc-13/README.md create mode 100644 .devcontainer/ubuntu-24.04_gcc-13/devcontainer.json create mode 100644 .devcontainer/ubuntu-24.04_gcc-13/envsetup.sh diff --git a/.devcontainer/ubuntu-24.04_gcc-13/Dockerfile b/.devcontainer/ubuntu-24.04_gcc-13/Dockerfile new file mode 100644 index 00000000..90d159b3 --- /dev/null +++ b/.devcontainer/ubuntu-24.04_gcc-13/Dockerfile @@ -0,0 +1,161 @@ +FROM ubuntu:24.04 + +# Define arguments for image +ARG CTNR_NAME="cdepsdev_ubuntu-24.04_gcc-13" \ + CTNR_DESCRIPTION="CDEPS development container" \ + CTNR_VERSION="1.0.0" \ + CTNR_USER="cdepsdev" \ + SPACK_VERSION="v1.2.1" \ + SPACK_REPO_VERSION="v2026.06.0" + +# Set system environment variables +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=en_US.UTF-8 \ + LANGUAGE=en_US:en \ + LC_ALL=en_US.UTF-8 + +# Install system packages via apt +RUN <> /etc/sudoers +SETUP_USER +USER ${CTNR_USER} +WORKDIR ${HOME} + +# Install spack via git clone +ENV SPACK_ROOT=${HOME}/spack +RUN < "$tmp" + [ -f ${HOME}/.bashrc ] && cat ${HOME}/.bashrc >> "$tmp" + mv "$tmp" ${HOME}/.bashrc +SETUPENV + +# Copy README file +COPY --chown=$CTNR_USER:$CTNR_USER --chmod=0644 README.md ${HOME}/README.md + +# Default command +CMD ["/bin/bash", "-l"] + +# Set environment variable for devcontainer title +ENV DEVCONTAINER_NAME=${CTNR_NAME} + +# Add OCI labels for image metadata +# https://specs.opencontainers.org/image-spec/annotations/ +LABEL org.opencontainers.image.version="${CTNR_VERSION}" \ + org.opencontainers.image.title="${CTNR_NAME}" \ + org.opencontainers.image.description="${CTNR_DESCRIPTION}" diff --git a/.devcontainer/ubuntu-24.04_gcc-13/README.md b/.devcontainer/ubuntu-24.04_gcc-13/README.md new file mode 100644 index 00000000..0a5736f7 --- /dev/null +++ b/.devcontainer/ubuntu-24.04_gcc-13/README.md @@ -0,0 +1,77 @@ + # CDEPS Ubuntu 24.04 Development Container + +This Dev Container provides a reproducible CDEPS development environment based +on Ubuntu 24.04, GCC / GFortran 13, an MPI library, and other packages needed +to build CDEPS. + +## Prerequisites + +- Docker or another Docker-compatible container runtime +- Visual Studio Code +- The **Dev Containers** extension for Visual Studio Code + +Open the CDEPS repository in Visual Studio Code and run **Dev Containers: +Reopen in Container**. The image is built from `Dockerfile` in this directory, +and the repository is mounted at `/home/cdepsdev/CDEPS`. + +## Installed Toolchain + +The image includes the following build tools and packages: + +| Software | Version | +| --- | --- | +| GCC / G++ / GNU Fortran | 13 | +| Spack | 1.2.1 | +| OpenMPI | 4.1.6 | +| ESMF | 8.9.0 | +| HDF5 | 1.14.6 | +| NetCDF-C | 4.10.0 | +| NetCDF-Fortran | 4.6.2 | +| ParallelIO | 2.6.6 | +| Parallel-netCDF | 1.14.1 | + +Spack is installed at `/home/cdepsdev/spack`. + +## Environment + +The bash login shell sources `.envsetup.sh` automatically. This initializes +Spack and loads the software stack, then sets environment variables needed +for the CDEPS build: + +- CC +- FC +- CXX +- CPPFLAGS +- LDFLAGS +- FFLAGS +- ESMF_VERSION +- ParallelIO_VERSION +- PIO +- CDEPS_CMAKE_FLAGS + +To reinitialize the environment in an existing shell, run: + +```bash +source ~/.envsetup.sh +``` + +## Build CDEPS + +Use an out-of-source build directory. From the repository root inside the +container: + +Replace CDEPS_BUILD_DIRECTORY and CDEPS_SOURCE_DIRECTORY with their +respective locations. + +```bash +mkdir -p CDEPS_BUILD_DIRECTORY +cd CDEPS_BUILD_DIRECTORY +cmake CDEPS_SOURCE_DIRECTORY ${CDEPS_CMAKE_FLAGS} +make -j4 VERBOSE=1 +``` + +To disable the bundled FoX XML library, configure with: + +```bash +cmake /home/cdepsdev/CDEPS ${CDEPS_CMAKE_FLAGS} -DDISABLE_FoX=ON +``` \ No newline at end of file diff --git a/.devcontainer/ubuntu-24.04_gcc-13/devcontainer.json b/.devcontainer/ubuntu-24.04_gcc-13/devcontainer.json new file mode 100644 index 00000000..fc9cbc3e --- /dev/null +++ b/.devcontainer/ubuntu-24.04_gcc-13/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "cdepsdev_ubuntu-24.04_gcc-13", + "build": { "dockerfile": "Dockerfile" }, + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "bash", + "terminal.integrated.profiles.linux": { + "bash": { + "path": "bash", + "args": ["-l"] + } + } + }, + "extensions": [ + "ms-vscode.cmake-tools", + "ms-vscode.cpptools", + "fortran-lang.modern-fortran" + ] + } + }, + "workspaceMount": "source=${localWorkspaceFolder},target=/home/cdepsdev/CDEPS,type=bind,consistency=cached", + "workspaceFolder": "/home/cdepsdev/CDEPS" +} diff --git a/.devcontainer/ubuntu-24.04_gcc-13/envsetup.sh b/.devcontainer/ubuntu-24.04_gcc-13/envsetup.sh new file mode 100644 index 00000000..300be10f --- /dev/null +++ b/.devcontainer/ubuntu-24.04_gcc-13/envsetup.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Spack setup +. ${SPACK_ROOT}/share/spack/setup-env.sh +spack load openmpi +spack load esmf +spack load hdf5 +spack load netcdf-c +spack load netcdf-fortran +spack load parallelio +spack load parallel-netcdf + +# CDEPS environment variables +export CC=mpicc +export FC=mpifort +export CXX=mpicxx +export CPPFLAGS="-I/usr/include -I/usr/local/include" +export LDFLAGS="-L/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)" +export FFLAGS="-DCPRGNU -g -Wall -ffree-form -ffree-line-length-none -fallow-argument-mismatch" +export ESMF_VERSION=v$(spack find --format "{version}" esmf) +export ParallelIO_VERSION=pio$(spack find --format "{version}" parallelio) +export PIO=$PIO_ROOT +export CDEPS_CMAKE_FLAGS="-Wno-dev -DCMAKE_BUILD_TYPE=DEBUG -DWERROR=ON" + +# Print Welcome Message +echo "Welcome to the CDEPS Development Container!" +echo "*** ${DEVCONTAINER_NAME} ***" +echo "" +echo "The following packages have been pre-loaded:" +spack find --loaded --format "{name}@{version}" +echo "" +echo "Build CDEPS using the following steps:" +echo "1. Create directory: mkdir -p && cd " +echo "2. Generate build files: cmake \${CDEPS_CMAKE_FLAGS}" +echo "3. Build CDEPS: make -j 4 VERBOSE=1" +echo ""