BeClaude

parflow-skill

New
1GitHubDocumentationby earth-space-ai

Deep skill / knowledge package for ParFlow (parallel watershed flow model). SKILL.md routing hub plus reference/ deep-dive docs covering architecture, physics and numerics, simulation workflow, CLM coupling, output formats, GPU performance, debugging, and contributing.

Community PluginView Source

Overview

ParFlow Complete Guide

ParFlow = PARallel watershed FLOW model

Source: https://github.com/parflow/parflow

Docs: https://parflow.readthedocs.io/

Wiki: https://github.com/parflow/parflow/wiki

Mailing list: https://groups.google.com/g/parflow

Reference paper: Maxwell, Advances in Water Resources 53:109-117, 2013

What ParFlow does: Solves three-dimensional, variably-saturated subsurface flow with Richards equation, fully coupled to two-dimensional kinematic-wave overland flow, optionally coupled to the Common Land Model (CLM) for land surface energy, biogeochemistry, and snow. Designed for parallel execution on laptops to leadership-class supercomputers using MPI, with optional CUDA, HIP, Kokkos, or OpenMP acceleration.

Who this skill is for: Agents, students, hydrologists, and developers who need to build, configure, run, post-process, debug, or contribute to ParFlow on Linux, macOS, HPC, or in Docker.


Quick Decision Tree

code
"What do I need?"
|
+- First time. What is ParFlow and how do I install it?
|  -> reference/getting-started.md
|     (CMake build, Hypre/Silo/HDF5/PDI deps, MPI, OpenMP, CUDA, Docker)
|
+- I want to set up and run a simulation
|  -> reference/running-simulations.md
|     (TCL vs Python pftools, pfset keys, Solver Impes vs Richards,
|      examples/ walk-through, distributing input files, running parallel)
|
+- I want to understand what is in the source tree
|  -> reference/architecture.md
|     (pfsimulator, pftools, pf-keys, pfnuopc, examples, performance_tests,
|      AMPS, KINSOL, CLM module, modules-as-objects pattern in C)
|
+- I need to know what equations ParFlow solves
|  -> reference/physics-and-numerics.md
|     (Richards equation, OverlandKinematic vs OverlandFlow vs OverlandDiffusive,
|      hydraulic conductivity tensor, Newton-Krylov + Hypre PFMG/SMG/MGSemi)
|
+- I want to run ParFlow-CLM (integrated land surface)
|  -> reference/coupling-with-clm.md
|     (PARFLOW_HAVE_CLM=ON, Solver.LSM CLM, drv_clmin.dat, drv_vegm.dat,
|      drv_vegp.dat, NLDAS forcing, RZWaterStress option)
|
+- I have output files. How do I read or visualize them?
|  -> reference/output-formats.md
|     (pfb binary, Silo, NetCDF via PDI, VisIt/ParaView, Python pftools,
|      HydroFrame ecosystem)
|
+- I need GPU performance or scaling guidance
|  -> reference/gpu-and-performance.md
|     (PARFLOW_ACCELERATOR_BACKEND=cuda|kokkos|omp, RMM/Umpire allocator,
|      MGSemi preconditioner, GPUDirect, OMP_NUM_THREADS, MPI mapping)
|
+- The build fails / the run crashes / the mass balance is off
|  -> reference/debugging.md
|     (CMake config, Hypre version mismatch, CFL/timestep failures,
|      KINSOL convergence, mass balance check, conf.yml for PDI)
|
+- I want to submit a fix or feature upstream
   -> reference/contributing-pr.md
      (fork, branch, pfformat / Uncrustify / Black, make check, Doxygen,
      LGPL header, GitHub Actions CI)

What Is Inside the ParFlow Repository

code
parflow/
|-- CMakeLists.txt                  <- top-level build, version 3.14.1+
|-- README.md                       <- quick start
|-- README-GPU.md                   <- CUDA / Kokkos build instructions
|-- README-OPENMP.md                <- OpenMP build instructions
|-- README-PDI.md                   <- PDI (parallel data interface) build
|-- README-SAMRAI.md                <- legacy SAMRAI variant
|-- README-Spack.md                 <- Spack-based build
|-- RELEASE-NOTES.md                <- version-by-version changelog
|-- CONTRIBUTING.md                 <- code style, license, PR process
|-- LICENSE.txt                     <- LGPL v2.1
|-- VERSION
|-- bin/                            <- build helpers, pfformat, docker-build.sh
|-- cmake/                          <- recipes (ubuntu-18.10-CUDA, etc.), modules
|-- docker/                         <- Dockerfiles for ParFlow image
|-- Dockerfile, Dockerfile_CUDA     <- build a runnable ParFlow image
|-- docs/
|   |-- user_manual/                <- Sphinx source for parflow.readthedocs.io
|   |   |-- intro.rst, start.rst, pfsystem.rst, models.rst,
|   |   |-- files.rst, keys.rst, pftools.rst, python/, refs.bib
|   |-- design_documents/
|   |-- doxygen/                    <- code documentation
|   |-- manuals/
|   |-- software_plan.md
|-- examples/                       <- annotated TCL + Python example scripts
|   |-- example_single.tcl, example_single.py, example_richards.tcl,
|   |-- forsyth2.tcl, forsyth5.tcl, llnl.tcl, well_*.tcl, *.pfsol
|-- pf-keys/                        <- key definitions + Python/Sphinx generators
|   |-- definitions/                <- YAML files, source of truth for keys
|   |-- generators/
|-- pfnuopc/                        <- NUOPC cap (couples ParFlow to ESMF apps)
|-- pfsimulator/                    <- the simulator
|   |-- amps/                       <- "Another Message Passing System"
|   |-- clm/                        <- embedded CLM (Fortran 90)
|   |-- kinsol/                     <- embedded KINSOL nonlinear solver
|   |-- parflow_exe/                <- main() for the parflow executable
|   |-- parflow_lib/                <- the simulator library (most C/C++ code)
|   |-- third_party/                <- pdi/, etc.
|-- pftools/                        <- pre/post-processing tools
|   |-- python/                     <- Python pftools (modern interface)
|   |-- *.c, *.h, *.tcl             <- TCL pftools and helpers
|   |-- pfmask-to-pfsol.cpp, pfsol-to-vtk.c, compute_domain.c, water_balance.c,
|   |-- toposlopes.c, top.c, water_table.c, well.c
|-- performance_tests/              <- inactive_active_time, etc.
|-- test/                           <- regression tests run by `make check`
|-- misc/

For most users: write a .tcl or .py input deck using pftools (which sets key/value pairs in a <runname>.pfidb database), then call pfrun. The script pipes the database to the parflow executable, which spawns MPI tasks across the process topology.


Critical Rules

  1. CMake out-of-source build. Never run cmake inside the source tree.

Always mkdir build; cd build; cmake ... Restarting a failed build is then rm -rf build; mkdir build; cd build; cmake ...

  1. Set `PARFLOW_DIR` before configuring. The simulator and pftools both

honor it at runtime to find tables, scripts, and libraries. Match it to CMAKE_INSTALL_PREFIX.

  1. Match Hypre, Silo, HDF5, NetCDF compilers. Mixing GCC-built Hypre with

an Intel-built ParFlow produces subtle linker errors and silently wrong numerical results. Build dependencies with the same compiler suite, or use Spack to pin one toolchain.

  1. Distribute input PFB files before running. pftools provides

pfdist <file> (TCL) or run.dist(file) (Python) which splits a global PFB into per-process chunks named <file>.dist.<rank>. Forgetting this step produces "cannot open file" errors on rank N>0.

  1. Process topology must divide grid size cleanly. With

Process.Topology.P=2, Q=2, R=1, the grid NX, NY, NZ should be evenly divisible by P, Q, R. The Python run.dist() was historically fragile when this rule was violated (fixed in 3.14.1).

  1. **OverlandKinematic and OverlandDiffusive need TerrainFollowingGrid.SlopeUpwindFormulation

set to Upwind or UpwindSine.** Mixing the legacy OverlandFlow boundary with a non-Original slope formulation causes silent mass imbalance. See physics-and-numerics.md.

  1. The default linear solver preconditioner is `PFMG` from Hypre. For GPU

builds, switch to MGSemi (the only preconditioner with a GPU-supported Jacobian path; Release 3.14.1 added full overland-flow GPU support with MGSemi).

  1. Two subsequent GPU runs of the same script are not bit-identical.

Atomic operations on GPU change the order of floating-point reductions. Set tolerances accordingly when comparing.

  1. **CLM needs PARFLOW_HAVE_CLM=ON at CMake time AND Solver.LSM CLM in

the input deck.** Setting only one of the two is a common mistake. CLM also needs drv_clmin.dat, drv_vegm.dat, and drv_vegp.dat in the working directory.

  1. `make check` must pass before submitting a PR. GitHub Actions CI

runs serial and parallel tests on Ubuntu, plus Black and Uncrustify style checks. PRs failing any of these will be rejected.


Quick Start (CMake build, single-point Richards)

bash
# 1. Install dependencies (Ubuntu example)
sudo apt-get install -y build-essential cmake gfortran tcl tcl-dev \
    libopenmpi-dev openmpi-bin libhdf5-openmpi-dev libsilo-dev \
    libhypre-dev python3 python3-pip

# 2. Decide install location
export PARFLOW_DIR=$HOME/parflow

# 3. Get the source
git clone https://github.com/parflow/parflow.git
cd parflow

# 4. Out-of-source CMake configure
mkdir build && cd build
cmake .. \
    -DCMAKE_INSTALL_PREFIX=${PARFLOW_DIR} \
    -DPARFLOW_AMPS_LAYER=mpi1 \
    -DPARFLOW_HAVE_CLM=ON \
    -DPARFLOW_ENABLE_HYPRE=TRUE \
    -DPARFLOW_ENABLE_SILO=TRUE \
    -DPARFLOW_ENABLE_HDF5=TRUE \
    -DPARFLOW_ENABLE_TIMING=TRUE \
    -DCMAKE_BUILD_TYPE=Release

# 5. Build and install
make -j 8
make install

# 6. Run the regression suite
make check

# 7. Run a sample problem (1x1x1 process topology)
cd ../test/tcl
tclsh default_single.tcl 1 1 1

For Python instead of TCL:

bash
pip install pftools
cd parflow/test/python
python default_single.py 1 1 1

Drill into reference/getting-started.md for HPC, GPU, Docker, and Spack flavors.


Reference Documents

DocumentWhat is inside
reference/getting-started.mdCMake configure flags, Hypre/Silo/HDF5/PDI dependencies, MPI/OpenMP/CUDA/HIP/Kokkos backends, Docker, Spack, NUOPC, smoke test
reference/architecture.mdpfsimulator/pftools/pf-keys/pfnuopc/examples/performance_tests layout, AMPS, KINSOL, CLM, the C "modules-as-objects" pattern, IDB key database
reference/running-simulations.mdTCL vs Python pftools, pfset and Run(), pfrun, pfdist/pfundist, Solver Impes vs Richards, examples/ walk-through, parallel topology
reference/physics-and-numerics.mdRichards equation, terrain-following grid, OverlandKinematic vs OverlandFlow vs OverlandDiffusive, hydraulic conductivity tensor, Newton-Krylov via KINSOL, Hypre PFMG/SMG/MGSemi
reference/coupling-with-clm.mdBuilding with PARFLOW_HAVE_CLM=ON, Solver.LSM CLM, drv_clmin.dat, drv_vegm.dat, drv_vegp.dat, NLDAS forcing, RZWaterStress option, ParFlow-CLM-only build
reference/output-formats.mdpfb binary layout, c.pfb, pfsb scattered binary, Silo, NetCDF via PDI, VisIt/ParaView, Python read_pfb / read_vegm, HydroFrame
reference/gpu-and-performance.mdPARFLOW_ACCELERATOR_BACKEND=cudakokkosomp, MGSemi preconditioner, RMM and Umpire allocators, GPUDirect, OMP_NUM_THREADS, MPI-to-GPU mapping
reference/debugging.mdCMake misconfigurations, Hypre version mismatches, KINSOL non-convergence, CFL and timestep failures, mass balance violations, PDI conf.yml issues
reference/contributing-pr.mdFork-branch-PR flow, pfformat (Uncrustify 0.79.0 + Black 25.12.0), Doxygen headers, LGPL boilerplate, regression tests, GitHub Actions CI

Install & Usage

1
Create the skills directory
mkdir -p .claude/skills
2
Download the skill file
mkdir -p .claude/skills && curl -o .claude/skills/parflow-skill.md https://raw.githubusercontent.com/earth-space-ai/parflow-skill/main/SKILL.md
3
Invoke in Claude Code
/parflow-skill
View source on GitHub

Frequently Asked Questions

What is parflow-skill?

Deep skill / knowledge package for ParFlow (parallel watershed flow model). SKILL.md routing hub plus reference/ deep-dive docs covering architecture, physics and numerics, simulation workflow, CLM coupling, output formats, GPU performance, debugging, and contributing.

How to install parflow-skill?

To install parflow-skill, create the .claude/skills directory in your project, then run the curl command to download the skill file. Once installed, invoke it in Claude Code with /parflow-skill.

What is parflow-skill best for?

parflow-skill is a community categorized under Documentation. Created by earth-space-ai.