This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Configure (out-of-source build)
cmake -B build -S .
# Build
cmake --build build -j$(nproc)
# Run all tests
cd build && ctest --output-on-failure
# Run a single test
cd build && ctest -R test_Dataset --output-on-failure
# Build and run a single test executable directly
cmake --build build --target test_Dataset
./build/tests/test_Dataset
# Parallel IO (requires MPI)
cmake -B build-mpi -S . -DUSE_MPI=ON -DENABLE_PARALLEL_IO=ON
cmake --build build-mpi -j$(nproc)
# Parallel computing only (MPI topology/halo, no parallel IO)
cmake -B build-mpi -S . -DUSE_MPI=ON
cmake --build build-mpi -j$(nproc)
- Fortran compiler (gfortran), C compiler
- CMake >= 3.18
- NetCDF-Fortran (found via pkg-config:
netcdf-fortran) - HDF5 with Fortran bindings
- C backend uses uthash (header
uthash.hinsrc/c_backend/) - Parallel IO (optional): MPI, parallel HDF5
- Kokkos (mandatory): GPU/CPU backend, requires Kokkos CMake package (see
src/kokkos/CLAUDE.md)
- Use Spack environment
unistate— mixing system and Spack HDF5/NetCDF causes ABI crashes - CMake detects Spack env via
$SPACK_ENVto avoid adding/usr/include - Module files (
.mod) go to${CMAKE_BINARY_DIR}/include
Modern Fortran (2003+) library for managing simulation state, inspired by xarray. Uses OOP with type extension, polymorphic dispatch, and iso_c_binding.
- Precision → C Backend → Core Types (
src/core/) → Variable → Registry (src/registry/) → Parallel (src/parallel/) → Component → IO (src/io/) - Kokkos (
src/kokkos/) — C++ core (buffer management, kernel dispatch) + Fortran interface (iso_c_binding). Always enabled. - Each
src/*/CLAUDE.mdhas gotchas and conventions specific to that layer
include/unistate_layout.hdefines Kokkos-compatible layout macros- Module naming convention: type
Foolives in moduleFoo_Mod - Fortran source list order in CMakeLists.txt reflects dependency chain — modules must compile before dependents
Data_Bufferis polymorphic — useselect typefor dispatch, never assume concrete type- Parallel layer (
src/parallel/) provides topology, halo exchange, and MPI communication — most files compile unconditionally; onlyComm_Backend_ModrequiresUSE_MPI=ON USE_MPIenables parallel computing (topology/halo);ENABLE_PARALLEL_IOenables parallel HDF5/NetCDF I/O (impliesUSE_MPI)- Kokkos is always enabled — C++ templates handle view wrappers (ranks 1–8, managed/unmanaged); Fortran code uses Kokkos for buffer management and kernel dispatch
Tests are standalone Fortran programs (not frameworks). Each test:
uses the module under test- Creates objects, exercises functionality, checks values with
ifassertions - Prints pass/fail messages
- Calls
destroymethods for cleanup
examples/ contains usage examples, built automatically via CMake:
ex1_su2_style.f90— SU2-style static field registration and I/Oex2_dynamic.f90— Dynamic field allocation pattern