This repository accompanies the "Generating meshes for MPAS-Atmosphere" mini-tutorial, presented at the 2026 MPAS/WRF Users Workshop.
Before generating meshes with the workflow provided by this repository, you'll first need to install JIGSAW. The JIGSAW README.md file provides installation guidance, though the following should generally be sufficient:
git clone https://github.com/dengwirda/jigsaw.git
cd jigsaw && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<WHERE_TO_INSTALL_JIGSAW>
make -j 4 install
(Be sure to set the installation directory by replacing WHERE_TO_INSTALL_JIGSAW in the cmake command above.)
Additionally, you'll also need a Python environment with at least the numpy and netCDF4 packages. If you don't already have a suitable environemnt, setting up a Python virtual environment may be an easiest:
python -m venv mpas_mesh
source mpas_mesh/bin/activate
pip install --upgrade pip
pip install numpy netCDF4
Finally, in order to compile the mkgrid program, which derives MPAS's required mesh geometry and connectivity information from generating points and their triangulation, you will need an MPI implementation (OpenMPI and MPICH are common options) plus the PnetCDF library. After ensuring that the mpicc command is in your PATH, and the PNETCDF environment variable points to the installation path of the PnetCDF library, you can simply run
make
to build the mkgrid program from mkgrid.c.
Generating a variable-resolution mesh with a 12-km circular refinement region centered at 38 N, 95 W, relaxing to 60-km grid spacing over a distance of 1600 km is accomplished with the following steps.
- Run the
create_hfun.pyscript to generate anHFUN.mshfile - Run
jigsaw, specifyingMESH.jigas its command-line argument, to produce aMESH.mshfile - Run
convert_jigsaw.pyto produceSaveVerticesandSaveTrianglesfiles from theMESH.mshfile - Run
create_density.pyto produce aSaveDensityfile - Copy the
hfun.pyfile toSaveCode - Run
mkgrid, specifying12000.0as its command-line argument, to producegrid.ncandgraph.infofiles