diff --git a/containers/README.md b/containers/README.md new file mode 100644 index 0000000000..f4234c268c --- /dev/null +++ b/containers/README.md @@ -0,0 +1,32 @@ +# MPAS Containers + +This directory contains containerized environments for MPAS. + +## Purpose + +Containers provide reproducible, isolated environments with pre-installed compilers, libraries, and software. This eliminates the need to install compilers, MPI libraries, and NetCDF libraries on your local system. + +## Available Containers + +| Container | Location | Purpose | +|-----------|----------|---------| +| [Docker Development Container](#docker-development-container) | [docker/dev/](docker/dev) | Pre-built development environment | + +--- + +### Docker Development Container + +The Docker Development Container includes: +- **ubuntu:rolling**: base image +- **gcc,g++,gfortran**: compilers +- **spack**: package manager +- **mpich**: MPI implementation +- **netcdf-c**: NetCDF C library +- **netcdf-fortran**: NetCDF Fortran library +- **parallel-netcdf**: PnetCDF library +- **parallelio**: PIO library +- **esmf**: Earth System Modeling Framework +- preconfigured environment variables + +See [README](docker/dev/README.md) for more details. +For more information about Docker, see the [Docker Documentation](https://docs.docker.com/). diff --git a/containers/docker/dev/Dockerfile b/containers/docker/dev/Dockerfile new file mode 100644 index 0000000000..1c183d2f26 --- /dev/null +++ b/containers/docker/dev/Dockerfile @@ -0,0 +1,79 @@ +FROM ubuntu:rolling + +# Set environment variables +ENV SPACK_ROOT=/opt/spack \ + DEBIAN_FRONTEND=noninteractive + +# Install system dependencies required by spack +RUN <:/home/mpas-dev/` | Mount a local directory inside the container | +| `--rm` | Automatically remove the container when it exits | +| `--name ` | Assign a name to the container | +| `-e VAR=value` | Set runtime environment variable | + +### Checkout MPAS + +Clone the MPAS repository: + +```bash +git clone https://github.com/MPAS-Dev/MPAS-Model.git +cd MPAS-Model +``` + +### Build MPAS + +For the atmosphere core: + +```bash +make -j4 gnu CORE="atmosphere" +``` + +For other cores, replace "atmosphere" with "init_atmosphere", "ocean", "landice", or "seaice". + +## Troubleshooting + +**Container exits immediately:** +- Ensure you're using `-it` flags for interactive mode +- Use `-l` with bash to force login shell and load environment + +**Out of disk space:** +- Spack can use significant disk space. Check with `docker system df` +- Remove unused images/containers: `docker system prune` + +**Can't find compiler/libraries:** +- Make sure you're in a bash login shell: `docker run -it mpas-dev bash -l` +- Manually source the spack setup: `source /etc/profile.d/spack.sh` diff --git a/containers/docker/dev/mpas_spack.sh b/containers/docker/dev/mpas_spack.sh new file mode 100644 index 0000000000..d339950b36 --- /dev/null +++ b/containers/docker/dev/mpas_spack.sh @@ -0,0 +1,21 @@ +#!/bin/bash +. ${SPACK_ROOT}/share/spack/setup-env.sh +spack load mpich +spack load netcdf-c +spack load netcdf-fortran +spack load parallel-netcdf +spack load parallelio +spack load esmf +export MPICH_ROOT=$(spack location -i mpich) +export NETCDF_C_ROOT=$(spack location -i netcdf-c) +export NETCDF_FORTRAN_ROOT=$(spack location -i netcdf-fortran) +export PARALLEL_NETCDF_ROOT=$(spack location -i parallel-netcdf) +export PARALLELIO_ROOT=$(spack location -i parallelio) +export ESMF_ROOT=$(spack location -i esmf) +export LD_LIBRARY_PATH=${MPICH_ROOT}/lib:${LD_LIBRARY_PATH} +export LD_LIBRARY_PATH=${NETCDF_C_ROOT}/lib:${LD_LIBRARY_PATH} +export LD_LIBRARY_PATH=${NETCDF_FORTRAN_ROOT}/lib:${LD_LIBRARY_PATH} +export LD_LIBRARY_PATH=${PARALLEL_NETCDF_ROOT}/lib:${LD_LIBRARY_PATH} +export LD_LIBRARY_PATH=${PARALLELIO_ROOT}/lib:${LD_LIBRARY_PATH} +export LD_LIBRARY_PATH=${ESMF_ROOT}/lib:${LD_LIBRARY_PATH} +export PNETCDF=${PARALLEL_NETCDF_ROOT}