Skip to content

Commit d713eb2

Browse files
committed
Add MPAS devcontainer setup
* add top-level devcontainer documentation * add devcontainer definition for ubuntu@25.10-gcc@14.3-mpich@4.3 * add Dockerfile and setup files for ubuntu@25.10-gcc@14.3-mpich@4.3
1 parent 33dedf6 commit d713eb2

File tree

6 files changed

+240
-0
lines changed

6 files changed

+240
-0
lines changed

.devcontainer/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# MPAS Dev Containers
2+
3+
This directory contains the MPAS development container definitions used for local Docker workflows and VS Code Dev Containers.
4+
5+
## Purpose
6+
7+
Dev containers provide a reproducible environment with the compilers, MPI libraries, and scientific libraries required to build MPAS. Each container variant lives in its own directory and includes:
8+
9+
- `devcontainer.json` for VS Code Dev Containers
10+
- `docker/` for the Dockerfile and supporting scripts
11+
- a README with variant-specific usage notes
12+
13+
## Available Dev Containers
14+
15+
Container directories are named as `<os>-<compiler>-<mpi>` so additional variants can be added without changing the layout of this directory.
16+
17+
| Variant | Summary |
18+
|---------|---------|
19+
| [ubuntu@25.10-gcc@14.3-mpich@4.3](ubuntu@25.10-gcc@14.3-mpich@4.3/) | GCC 14 and MPICH 4.3 development environment with Spack-managed MPAS dependencies |
20+
21+
## VS Code Usage
22+
23+
Install the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension for Visual Studio Code.
24+
25+
Open the repository in VS Code, choose `Reopen in Container`, and select the desired container. The workspace is typically mounted at `/home/mpas-dev/MPAS-Model`, and the integrated terminal starts as a login shell.
26+
27+
## Notes
28+
29+
For background on Docker itself, see the [Docker documentation](https://docs.docker.com/).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker/README.md
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "MPAS Dev Container",
3+
"build": {
4+
"dockerfile": "docker/Dockerfile"
5+
},
6+
"customizations": {
7+
"vscode": {
8+
"settings": {
9+
"terminal.integrated.defaultProfile.linux": "bash",
10+
"terminal.integrated.profiles.linux": {
11+
"bash": {
12+
"path": "bash",
13+
"args": ["-l"]
14+
}
15+
}
16+
}
17+
}
18+
},
19+
"workspaceMount": "source=${localWorkspaceFolder},target=/home/mpas-dev/MPAS-Model,type=bind,consistency=cached",
20+
"workspaceFolder": "/home/mpas-dev/MPAS-Model",
21+
"runArgs": []
22+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
FROM ubuntu:rolling
2+
3+
# Set environment variables
4+
ENV SPACK_ROOT=/opt/spack \
5+
DEBIAN_FRONTEND=noninteractive
6+
7+
# Install system dependencies required by spack
8+
RUN <<INSTALL_PACKAGES
9+
apt-get update
10+
apt-get install -yqq \
11+
build-essential \
12+
ca-certificates \
13+
curl \
14+
file \
15+
g++-14 \
16+
gcc-14 \
17+
gfortran-14 \
18+
git \
19+
gpg \
20+
gzip \
21+
libc6-dev \
22+
libcurl4-openssl-dev \
23+
libssl-dev \
24+
m4 \
25+
make \
26+
openssh-client \
27+
pkg-config \
28+
python3 \
29+
python3-dev \
30+
tar \
31+
unzip \
32+
wget \
33+
zlib1g-dev
34+
apt-get clean
35+
INSTALL_PACKAGES
36+
37+
# Clone spack repository
38+
RUN <<INSTALL_SPACK
39+
mkdir -p ${SPACK_ROOT}
40+
git clone --depth=2 --branch=releases/v1.1 https://github.com/spack/spack.git ${SPACK_ROOT}
41+
INSTALL_SPACK
42+
43+
# Set up spack environment
44+
ENV PATH="${SPACK_ROOT}/bin:${PATH}"
45+
46+
# Install MPAS dependencies with gcc 12
47+
RUN <<SETUP_SPACK
48+
. ${SPACK_ROOT}/share/spack/setup-env.sh
49+
spack compiler find
50+
spack external find
51+
spack install \
52+
mpich@4.3%gcc \
53+
netcdf-c@4.9%gcc \
54+
netcdf-fortran@4.6%gcc \
55+
parallel-netcdf@1.14%gcc \
56+
parallelio@2.6%gcc \
57+
esmf@8.9%gcc
58+
spack clean --all
59+
SETUP_SPACK
60+
61+
# Create environment
62+
RUN <<SETUP_ENV
63+
mkdir -p /etc/profile.d
64+
mkdir -p /home/mpas-dev
65+
SETUP_ENV
66+
67+
# Copy spack setup script
68+
COPY --chmod=0755 mpas_spack.sh /etc/profile.d/mpas_spack.sh
69+
70+
# Copy README file
71+
COPY --chmod=0644 README.md /home/mpas-dev/README.md
72+
73+
# Set bash as default shell
74+
SHELL ["/bin/bash", "-c"]
75+
76+
# Set working directory
77+
WORKDIR /home/mpas-dev
78+
79+
# Default command
80+
CMD ["/bin/bash", "-l"]
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# MPAS Dev Container: ubuntu@25.10-gcc@14.3-mpich@4.3
2+
3+
This image provides a ready-to-build MPAS development environment with GCC 14.3, MPICH 4.3, and scientific libraries installed through Spack.
4+
5+
For general MPAS project information, see the [MPAS Documentation](https://www.mmm.ucar.edu/models/mpas).
6+
7+
## Installed Toolchain
8+
9+
The Dockerfile currently builds from `ubuntu:rolling` and installs:
10+
11+
- GCC, G++, and GFortran @14.3
12+
- Spack @1.1
13+
- MPICH @4.3
14+
- NetCDF-C @4.9
15+
- NetCDF-Fortran @4.6
16+
- Parallel-NetCDF @1.14
17+
- ParallelIO @2.6
18+
- ESMF @8.9
19+
20+
## Environment
21+
22+
Start the container with `bash -l` to load the Spack-managed environment automatically.
23+
24+
| Environment Variable | Description |
25+
|----------------------|-------------|
26+
| `SPACK_ROOT` | Path to the Spack installation |
27+
| `MPICH_ROOT` | Path to the MPICH installation |
28+
| `NETCDF_C_ROOT` | Path to the NetCDF C installation |
29+
| `NETCDF_FORTRAN_ROOT` | Path to the NetCDF Fortran installation |
30+
| `PARALLEL_NETCDF_ROOT` | Path to the Parallel-NetCDF installation |
31+
| `PARALLELIO_ROOT` | Path to the ParallelIO installation |
32+
| `ESMF_ROOT` | Path to the ESMF installation |
33+
| `LD_LIBRARY_PATH` | Library search path including installed dependencies |
34+
| `PNETCDF` | Path to the Parallel-NetCDF installation |
35+
36+
## Docker Usage
37+
38+
### Build the image
39+
40+
From `.devcontainer/ubuntu@25.10-gcc@14.3-mpich@4.3/docker/`:
41+
42+
```bash
43+
docker build -t mpasdev-ubuntu-25.10-gcc-14.3-mpich-4.3 .
44+
```
45+
46+
### Run an interactive shell
47+
48+
```bash
49+
docker run --rm -it mpasdev-ubuntu-25.10-gcc-14.3-mpich-4.3 bash -l
50+
```
51+
52+
### Run an interactive shell with mounted local MPAS-Model folder
53+
54+
From the repository root:
55+
56+
```bash
57+
docker run --rm -it \
58+
-v "$PWD:/home/mpas-dev/MPAS-Model" \
59+
-w /home/mpas-dev/MPAS-Model \
60+
mpasdev-ubuntu-25.10-gcc-14.3-mpich-4.3 \
61+
bash -l
62+
```
63+
64+
## Build MPAS
65+
66+
With the repository mounted at `/home/mpas-dev/MPAS-Model`, a typical atmosphere build is:
67+
68+
```bash
69+
make -j4 gnu CORE="atmosphere"
70+
```
71+
72+
For other cores, replace `CORE` value with `init_atmosphere`, `ocean`, `landice`, or `seaice`.
73+
74+
## Troubleshooting
75+
76+
**Environment variables are missing**
77+
78+
Start a login shell with `bash -l` so `/etc/profile.d/mpas_spack.sh` is sourced.
79+
80+
**The container exits immediately**
81+
82+
Run an interactive shell, `-it`.
83+
84+
**Docker is using too much disk space**
85+
86+
Inspect usage with `docker system df` and remove unused images or containers with `docker system prune`.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
. ${SPACK_ROOT}/share/spack/setup-env.sh
3+
spack load cmake
4+
spack load mpich
5+
spack load netcdf-c
6+
spack load netcdf-fortran
7+
spack load parallel-netcdf
8+
spack load parallelio
9+
spack load esmf
10+
export MPICH_ROOT=$(spack location -i mpich)
11+
export NETCDF_C_ROOT=$(spack location -i netcdf-c)
12+
export NETCDF_FORTRAN_ROOT=$(spack location -i netcdf-fortran)
13+
export PARALLEL_NETCDF_ROOT=$(spack location -i parallel-netcdf)
14+
export PARALLELIO_ROOT=$(spack location -i parallelio)
15+
export ESMF_ROOT=$(spack location -i esmf)
16+
export LD_LIBRARY_PATH=${MPICH_ROOT}/lib:${LD_LIBRARY_PATH}
17+
export LD_LIBRARY_PATH=${NETCDF_C_ROOT}/lib:${LD_LIBRARY_PATH}
18+
export LD_LIBRARY_PATH=${NETCDF_FORTRAN_ROOT}/lib:${LD_LIBRARY_PATH}
19+
export LD_LIBRARY_PATH=${PARALLEL_NETCDF_ROOT}/lib:${LD_LIBRARY_PATH}
20+
export LD_LIBRARY_PATH=${PARALLELIO_ROOT}/lib:${LD_LIBRARY_PATH}
21+
export LD_LIBRARY_PATH=${ESMF_ROOT}/lib:${LD_LIBRARY_PATH}
22+
export PNETCDF=${PARALLEL_NETCDF_ROOT}

0 commit comments

Comments
 (0)