-
Notifications
You must be signed in to change notification settings - Fork 25
Add simplified build system with meta-modules and wrapper scripts #4512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/v2
Are you sure you want to change the base?
Changes from all commits
b89f1e7
9e38de1
3afbfb8
9e2c6e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| # MAPL Build System | ||
|
|
||
| This directory contains simplified build and test scripts for MAPL development. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### Building MAPL | ||
|
|
||
| ```bash | ||
| ./build.sh [compiler] [build_type] | ||
| ``` | ||
|
|
||
| **Examples:** | ||
| ```bash | ||
| # Build with NAG compiler (Debug mode, default) | ||
| ./build.sh nag | ||
|
|
||
| # Build with GFortran compiler (Debug mode) | ||
| ./build.sh gfortran | ||
|
|
||
| # Build with NAG compiler (Release mode) | ||
| ./build.sh nag Release | ||
| ``` | ||
|
|
||
| ### Running Tests | ||
|
|
||
| ```bash | ||
| ./test.sh [compiler] [test_pattern] | ||
| ``` | ||
|
|
||
| **Examples:** | ||
| ```bash | ||
| # Run all tests with NAG compiler | ||
| ./test.sh nag | ||
|
|
||
| # Run all tests with GFortran compiler | ||
| ./test.sh gfortran | ||
|
|
||
| # Run specific test(s) matching pattern | ||
| ./test.sh nag ConservationAspect | ||
| ``` | ||
|
|
||
| ## How It Works | ||
|
|
||
| The build system uses **meta-modules** (compiler stacks) and **wrapper scripts** to simplify the workflow: | ||
|
|
||
| ### Meta-Modules | ||
|
|
||
| - `nag-stack` - Loads NAG compiler + OpenMPI + baselibs | ||
| - `gfortran-stack` - Loads GFortran compiler + OpenMPI + baselibs | ||
| - `ifort-stack` - Loads Intel Fortran compiler + OpenMPI + baselibs | ||
|
|
||
| These meta-modules automatically handle: | ||
| - `module purge` and `module load` sequences | ||
| - Compiler dependencies (e.g., NAG requires clang) | ||
| - MPI configuration | ||
| - Baselibs setup | ||
|
|
||
| ### Wrapper Scripts | ||
|
|
||
| **`build.sh`**: | ||
| - Loads the appropriate compiler stack module | ||
| - Creates build directory (`build-<compiler>`) | ||
| - Configures CMake with appropriate settings | ||
| - Builds the project | ||
|
|
||
| **`test.sh`**: | ||
| - Loads the appropriate compiler stack module | ||
| - Uses `ctest` to run tests (automatically handles DYLD_LIBRARY_PATH on macOS) | ||
| - Supports test filtering with regex patterns | ||
|
|
||
| ## Build Directories | ||
|
|
||
| By convention, builds are organized by compiler: | ||
| - `build-nag/` - NAG compiler builds | ||
| - `build-gfortran/` - GFortran compiler builds | ||
| - `build-ifort/` - Intel compiler builds | ||
|
|
||
| ## Manual Module Loading | ||
|
|
||
| If you need more control, you can still use modules manually: | ||
|
|
||
| ```bash | ||
| module purge | ||
| module load nag-stack | ||
| cmake -B build-nag -DCMAKE_BUILD_TYPE=Debug | ||
| cmake --build build-nag -j8 | ||
| ``` | ||
|
|
||
| ## Supported Compilers | ||
|
|
||
| - **nag** - NAG Fortran compiler (default: 7.2.41) | ||
| - **gfortran** - GNU Fortran compiler (default: 15.2.0) | ||
| - **ifort** - Intel Fortran compiler | ||
|
|
||
| ## System Requirements | ||
|
|
||
| - Lmod module system | ||
| - CMake 3.24+ | ||
| - Appropriate compiler stack modules installed | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| **"Module not found" errors:** | ||
| - Ensure you have the meta-modules installed in `~/modulefiles/core/` | ||
| - Check `module avail` to see available modules | ||
|
|
||
| **Build failures:** | ||
| - Check that all dependencies are loaded: `module list` | ||
| - Verify the build directory is clean or rebuild from scratch | ||
|
|
||
| **Test failures on macOS:** | ||
| - The `test.sh` script uses `ctest` which automatically handles DYLD_LIBRARY_PATH | ||
| - If running tests manually, ensure proper library paths are set | ||
|
|
||
| ## For AI Agents | ||
|
|
||
| The simplified workflow is designed to reduce cognitive load: | ||
|
|
||
| 1. **To build**: `./build.sh <compiler>` | ||
| 2. **To test**: `./test.sh <compiler>` | ||
|
|
||
| No need to remember: | ||
| - Module loading sequences | ||
| - DYLD_LIBRARY_PATH settings | ||
| - CMake configuration options | ||
| - Build directory naming conventions | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| #!/bin/bash | ||
| # MAPL build wrapper script | ||
| # Simplifies building with different compilers by handling module loading | ||
|
|
||
| set -e | ||
|
|
||
| # Default values | ||
| COMPILER="${1:-nag}" | ||
| BUILD_TYPE="${2:-Debug}" | ||
| INSTALL_PREFIX="${3:-}" | ||
|
|
||
| # Use full paths for safety | ||
| SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| BUILD_DIR="${SOURCE_DIR}/build-${COMPILER}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use something like
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, at the moment we ignore: /build*
/install*so if it's a directory called that, we ignore it. Plus our CMake adds a |
||
| if [[ -z "$INSTALL_PREFIX" ]]; then | ||
| INSTALL_DIR="${SOURCE_DIR}/install-${COMPILER}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to |
||
| else | ||
| INSTALL_DIR="$INSTALL_PREFIX" | ||
| fi | ||
|
|
||
| # Supported compilers | ||
| SUPPORTED_COMPILERS="nag gfortran ifort" | ||
|
|
||
| # Check if compiler is supported | ||
| if [[ ! " $SUPPORTED_COMPILERS " =~ " $COMPILER " ]]; then | ||
| echo "Error: Unsupported compiler '$COMPILER'" | ||
| echo "Supported compilers: $SUPPORTED_COMPILERS" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "=========================================" | ||
| echo "MAPL Build Configuration" | ||
| echo "=========================================" | ||
| echo "Compiler: $COMPILER" | ||
| echo "Build Type: $BUILD_TYPE" | ||
| echo "Build Dir: $BUILD_DIR" | ||
| echo "Install Dir: $INSTALL_DIR" | ||
| echo "=========================================" | ||
|
|
||
| # Load the appropriate compiler stack | ||
| echo "Loading ${COMPILER}-stack module..." | ||
| module purge | ||
| module load ${COMPILER}-stack | ||
|
|
||
| echo "" | ||
| echo "Loaded modules:" | ||
| module list | ||
|
|
||
| # Configure with CMake (modern syntax) | ||
| echo "" | ||
| echo "Configuring with CMake..." | ||
| cmake -B "${BUILD_DIR}" \ | ||
| -S "${SOURCE_DIR}" \ | ||
| --install-prefix="${INSTALL_DIR}" \ | ||
| -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" | ||
|
|
||
| # Build | ||
| echo "" | ||
| echo "Building..." | ||
| cmake --build "${BUILD_DIR}" --parallel 8 | ||
|
|
||
| echo "" | ||
| echo "=========================================" | ||
| echo "Build completed successfully!" | ||
| echo "=========================================" | ||
| echo "Build directory: $BUILD_DIR" | ||
| echo "Install directory: $INSTALL_DIR" | ||
| echo "To run tests: ./test.sh $COMPILER" | ||
| echo "To install: cmake --build ${BUILD_DIR} --target install" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/bin/bash | ||
| # MAPL test wrapper script | ||
| # Simplifies running tests with different compilers | ||
|
|
||
| set -e | ||
|
|
||
| # Default values | ||
| COMPILER="${1:-nag}" | ||
| TEST_PATTERN="${2:-}" | ||
|
|
||
| # Use full paths for safety | ||
| SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| BUILD_DIR="${SOURCE_DIR}/build-${COMPILER}" | ||
|
|
||
| # Supported compilers | ||
| SUPPORTED_COMPILERS="nag gfortran ifort" | ||
|
|
||
| # Check if compiler is supported | ||
| if [[ ! " $SUPPORTED_COMPILERS " =~ " $COMPILER " ]]; then | ||
| echo "Error: Unsupported compiler '$COMPILER'" | ||
| echo "Supported compilers: $SUPPORTED_COMPILERS" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check if build directory exists | ||
| if [[ ! -d "$BUILD_DIR" ]]; then | ||
| echo "Error: Build directory '$BUILD_DIR' does not exist" | ||
| echo "Please run './build.sh $COMPILER' first" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "=========================================" | ||
| echo "MAPL Test Configuration" | ||
| echo "=========================================" | ||
| echo "Compiler: $COMPILER" | ||
| echo "Build Dir: $BUILD_DIR" | ||
| if [[ -n "$TEST_PATTERN" ]]; then | ||
| echo "Test Pattern: $TEST_PATTERN" | ||
| fi | ||
| echo "=========================================" | ||
|
|
||
| # Load the appropriate compiler stack | ||
| echo "Loading ${COMPILER}-stack module..." | ||
| module purge | ||
| module load ${COMPILER}-stack | ||
|
|
||
| echo "" | ||
| echo "Loaded modules:" | ||
| module list | ||
|
|
||
| # Run tests using ctest (modern syntax with --test-dir) | ||
| echo "" | ||
| echo "Running tests..." | ||
| if [[ -n "$TEST_PATTERN" ]]; then | ||
| ctest --test-dir "${BUILD_DIR}" --output-on-failure -R "$TEST_PATTERN" | ||
| else | ||
| ctest --test-dir "${BUILD_DIR}" --output-on-failure | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "=========================================" | ||
| echo "Tests completed!" | ||
| echo "=========================================" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We’ll need build type, unless we assume that we are testing only the Debug build for that compiler