=============== LIBRARY RULES =============== From library maintainers: - Context7 URLs for specific documentation pages (i.e. pagename.md) may instead be https://erf.readthedocs.io/pagename.html or https://github.com/erf-model/ERF/tree/development/Docs/sphinx_doc/pagename.rst ### Usage Example for CMake Validation Setup Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Demonstrates how to use the setup script for CMake validation with different configurations and how to interact with the generated run script. ```bash cd Build ./setup_cmake_validation.sh default # or perlmutter, gnu_ekat cd ../build_default ./run.sh # List available scripts ./run.sh 1 # Run first script ``` -------------------------------- ### Out-of-Source Build Setup Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Sets up an out-of-source build directory. The optional 'make install' step copies executables to a central location. ```bash mkdir build && cd build ../Build/cmake.sh make install # optional - copies to install/bin/ (may be needed for builds that require kokkos) ``` -------------------------------- ### Log Installation Paths Source: https://github.com/erf-model/erf/blob/development/CMakeLists.txt Logs the installation prefix and library directory in verbose mode. Useful for verifying installation paths during configuration. ```cmake message(VERBOSE "Install prefix: ${CMAKE_INSTALL_PREFIX}") message(VERBOSE "Install libdir: ${CMAKE_INSTALL_LIBDIR}") ``` -------------------------------- ### Install and Run ERF from Install Directory Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/quickstart.md After an out-of-source build, install the ERF model and then run the executable from the designated install directory. ```bash make install cd ../../install/bin mpiexec -n 4 ./erf_exec ../../Exec/CanonicalTests/ABL/inputs_most ``` -------------------------------- ### Setup for SHOC or P3 Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Runs setup scripts for integrating SHOC or P3. Requires setting ERF_DIR and sourcing specific build scripts. ```bash export ERF_DIR=/path/to/ERF source /path/to/ERF/Build/GNU_Ekat/eamxx_clone.sh source /path/to/ERF/Build/GNU_Ekat/ekat_build_commands.sh ``` -------------------------------- ### Setup for SHOC or P3 Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Sets up environment variables for building ERF with SHOC or P3. ```bash export ERF_DIR=/path/to/ERF source /path/to/ERF/Build/GNU_Ekat/eamxx_clone.sh ``` -------------------------------- ### ERF Input File Example Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/aurora_build_run.md Example configuration for an ABL case in the ERF model's input file. ```text # Problem setup erf.prob_name = "ABL" max_step = 4000 # Domain: 1024^3 m on 64^3 grid geometry.prob_extent = 1024 1024 1024 amr.n_cell = 64 64 64 geometry.is_periodic = 1 1 0 # Boundary conditions zlo.type = "surface_layer" zhi.type = "SlipWall" # MOST surface layer erf.most.z0 = 0.1 erf.most.zref = 8.0 erf.most.surf_temp = 1.1 # Time stepping erf.fixed_dt = 1.0 # Refinement amr.max_level = 1 amr.ref_ratio_vect = 20 20 1 erf.coupling_type = "TwoWay" # Output erf.plot_file_1 = plt erf.plot_int_1 = 1 erf.check_file = chk erf.check_int = 100 # Physics erf.les_type = "Smagorinsky" erf.Cs = 0.1 ``` -------------------------------- ### Install ERF Targets and Headers Source: https://github.com/erf-model/erf/blob/development/CMakeLists.txt Installs the 'erf_api' and 'erf_srclib' targets to standard locations (bin, lib, include). Also installs public headers and creates an export set for package management. ```cmake install( TARGETS erf_api erf_srclib EXPORT ${PROJECT_NAME}Targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib INCLUDES DESTINATION include PUBLIC_HEADER DESTINATION include ) ``` -------------------------------- ### Install Parallel Libraries on Ubuntu/Debian Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingLibraryConfig.md Installs parallel NetCDF and HDF5 development libraries using apt on Ubuntu/Debian systems. ```bash sudo apt install libnetcdf-mpi-dev libhdf5-mpi-dev ``` -------------------------------- ### Install Parallel Libraries on Fedora/RHEL Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingLibraryConfig.md Installs parallel NetCDF and HDF5 development libraries using dnf on Fedora/RHEL systems. ```bash sudo dnf install netcdf-mpich-devel hdf5-mpich-devel ``` -------------------------------- ### CPM Input Parameters Example Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/InflowTurbulenceGeneration.md Example of the input tags required to configure a simulation using the Cell Perturbation Method (CPM). Ensure these parameters are set correctly for CPM to function. ```default erf.perturbation_type = "CPM" erf.perturbation_direction = 1 0 0 0 0 0 erf.perturbation_box_dims = 8 8 3 erf.perturbation_layers = 3 erf.perturbation_offset = 5 erf.perturbation_Ug = 10.0 ``` -------------------------------- ### WarpX Production Script Setup on Perlmutter Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/perlmutter_build_run.md A reference WarpX production script for Perlmutter, demonstrating environment setup, GPU binding, and threaded execution configuration. ```bash #!/bin/bash -l # Copyright 2021-2023 Axel Huebl, Kevin Gott # # This file is part of WarpX. # # License: BSD-3-Clause-LBNL #SBATCH -t 00:10:00 #SBATCH -N 2 #SBATCH -J WarpX # note: must end on _g #SBATCH -A #SBATCH -q regular # A100 40GB (most nodes) #SBATCH -C gpu # A100 80GB (256 nodes) #S BATCH -C gpu&hbm80g #SBATCH --exclusive #SBATCH --cpus-per-task=32 # ideally single:1, but NERSC cgroups issue #SBATCH --gpu-bind=none #SBATCH --ntasks-per-node=4 #SBATCH --gpus-per-node=4 #SBATCH -o WarpX.o%j #SBATCH -e WarpX.e%j # python interpreter & script here EXE=python3 INPUTS=run_script.py # or executable & inputs file #EXE=./warpx #INPUTS=inputs # environment setup if [[ -z "${MY_PROFILE}" ]]; then echo "WARNING: FORGOT TO" echo " source $HOME/perlmutter_gpu_warpx.profile" echo "before submission. Doing that now." source $HOME/perlmutter_gpu_warpx.profile fi # pin to closest NIC to GPU export MPICH_OFI_NIC_POLICY=GPU # threads for OpenMP and threaded compressors per MPI rank # note: 16 avoids hyperthreading (32 virtual cores, 16 physical) export OMP_NUM_THREADS=16 ``` -------------------------------- ### Grid and Boundary Condition Setup Source: https://github.com/erf-model/erf/blob/development/Exec/CanonicalTests/ABL/column_diffusion_test/README.md Configuration for grid and boundary conditions, including cell count, initial grid spacing, stretching ratio, and theta gradient at the upper boundary. ```plaintext amr.n_cell = 4 4 50 erf.initial_dz = 10.0 erf.grid_stretching_ratio = 1.025 zhi.theta_grad = 0.003 ``` -------------------------------- ### Shell Script for Script Execution Setup Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md This script prepares a clean subdirectory for running a specific build script, copies the script into it, and executes it. It includes checks for existing directories and prompts for recreation. ```bash # Create a clean subdirectory for this script if [ -d "$SUBDIR" ]; then echo "Warning: $SUBDIR already exists" read -p "Delete and recreate? (y/N) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then rm -rf "$SUBDIR" else echo "Aborting. Please remove $SUBDIR manually or choose a different script." exit 1 fi fi mkdir -p "$SUBDIR" echo "========================================" echo "Running: $SCRIPT" echo "Build directory: $SUBDIR" echo "Working directory: $SUBDIR" echo "========================================" echo "" # Copy the script into the subdirectory and run it there cp "$SCRIPT" "$SUBDIR/" cd "$SUBDIR" bash "./$SCRIPT" ``` -------------------------------- ### Manual CMake Configuration with a Profile Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Use the -C option to specify a CMake configuration file for manual setup, overriding automatic detection. ```bash cmake -C path/to/config.cmake .. ``` -------------------------------- ### Running ERF Executable (Installed) Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Executes the ERF program using mpiexec after it has been installed. ```bash cd install/bin mpiexec -n 4 ./erf_exec ../../Exec/CanonicalTests/ABL/inputs_most ``` -------------------------------- ### Build ERF Schemas and Indices Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/AgenticWorkFlow.md Build the ERF schemas and indices using the provided setup script. Use --force-rebuild to ensure a fresh build. ```bash bash demo/setup_demo_database.sh --code erf --force-rebuild ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/erf-model/erf/blob/development/CMakeLists.txt Sets the minimum required CMake version and defines the project name and supported languages. Conditional compilation is used to include Fortran support. ```cmake cmake_minimum_required (VERSION 3.14 FATAL_ERROR) # Set main ERF context list(APPEND CMAKE_MESSAGE_CONTEXT "ERF") # Include Cray compiler detection BEFORE project() to set compilers list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") include(CrayCompilerDetection) if(ERF_ENABLE_MORR_FORT OR ERF_ENABLE_WSM6_FORT OR ERF_ENABLE_NOAHMP) project(ERF CXX C Fortran) else() project(ERF CXX C) endif() message(STATUS "Configuring ERF") message(VERBOSE "Source directory: ${PROJECT_SOURCE_DIR}") message(VERBOSE "Build directory: ${PROJECT_BINARY_DIR}") ``` -------------------------------- ### Example Injection Configuration Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/theory/Microphysics.md Configures three injection sources: two uniform boxes with opposing velocities and one stationary bubble. Specifies spatial distribution, temporal control, injection rate, and particle attributes. ```bash super_droplets_moisture.num_injections = 3 # Moving box injection from left super_droplets_moisture.injection.0.distribution_type = "uniform" super_droplets_moisture.injection.0.particle_box_lo = 1000.0 0.0 5000.0 super_droplets_moisture.injection.0.particle_box_hi = 1400.0 400.0 5400.0 super_droplets_moisture.injection.0.domain_velocity = 18.0 0.0 0.0 super_droplets_moisture.injection.0.rate = 2.0e6 super_droplets_moisture.injection.0.particles_per_cell = 8 super_droplets_moisture.injection.0.aerosol_distribution_type_NaCl = "mass_exponential" super_droplets_moisture.injection.0.aerosol_mean_mass_NaCl = 1.0e-19 ``` -------------------------------- ### Shell Script for Running Validation Setup Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md This script sets up CMake validation by creating a build directory and providing instructions on how to run the setup script and the generated run script. ```bash chmod +x "$BUILD_DIR/run.sh" echo "" echo "Setup complete!" echo "Build directory: $BUILD_DIR" echo "" echo "To use:" echo " cd $BUILD_DIR" echo " ./run.sh # List available scripts" echo " ./run.sh # Run a specific script" echo "" echo "Copied $COPIED script(s)" ``` -------------------------------- ### Create Bug Report - System Information Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingTroubleshooting.md Example of system information to include when creating a bug report for build issues. ```text **System:** - OS: [e.g., Perlmutter/CrayOS, Ubuntu 22.04] - Compiler: [gcc --version or CC --version] - MPI: [mpirun --version] - Modules: [module list] ``` -------------------------------- ### Set Up RRTMGP Compilation on CPU Source: https://github.com/erf-model/erf/blob/development/Exec/RegTests/Radiation/README.md Set environment variables and source Ekat build commands for RRTMGP compilation on CPU. This setup is typically performed once after cloning the repository. ```bash export ERF_DIR=/path/to/ERF source /path/to/ERF/Build/GNU_Ekat/ekat_build_commands.sh ``` -------------------------------- ### Single-Column Model Domain Setup Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/BestPractices.md Configure a Single-Column Model (SCM) by setting the problem extent, number of cells, and periodicity for each dimension. ```python geometry.prob_extent = 400 400 400 amr.n_cell = 1 1 64 geometry.is_periodic = 1 1 0 ``` -------------------------------- ### Set Particle Initialization Start Time Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/Particles.md Control the time at which particles are initialized using 'tracer_particles.start_time'. ```inputs tracer_particles.start_time = 0.5 ``` -------------------------------- ### Bash Script for macOS Make.local Configuration Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingHPC.md Example `Make.local` file content for macOS to specify consistent compiler versions for C++, C, and Fortran using Homebrew installed GCC. This helps avoid conflicts between default Clang/Xcode and installed Fortran compilers. ```bash CXX = g++-13 CC = gcc-13 FC = gfortran-13 ``` -------------------------------- ### Clone, Build, and Run ERF (General) Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/GettingStarted.md Clone the ERF repository, set up the build environment, and run a sample simulation. Customize build directories using environment variables if needed. ```bash git clone --recursive https://github.com/erf-model/ERF.git cd ERF # Customize (optional): export ERF_BUILD_DIR=... ERF_SOURCE_DIR=... ERF_INSTALL_DIR=... or ERF_HOME=... ERF_HOME=$(pwd) ./Build/cmake_with_kokkos_many.sh # Run from install directory cd install/bin mpiexec -n 4 ./erf_exec ../../Exec/CanonicalTests/ABL/inputs_most ``` -------------------------------- ### Uninstall ERF Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Removes files that were installed using the 'make install' command. ```bash make uninstall ``` -------------------------------- ### Configure and Build on CPU Source: https://github.com/erf-model/erf/blob/development/Exec/RegTests/Radiation/README.md After setting up the environment, configure the GNUmakefile to use RRTMGP and NetCDF, then initiate the build process. ```makefile USE_RRTMGP = TRUE USE_NETCDF = TRUE ``` -------------------------------- ### Set Up Conda Environment Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/AgenticWorkFlow.md Create and activate the conda environment specified in the environment.yaml file. ```bash conda env create -f environment.yaml conda activate amrex-agent-dev ``` -------------------------------- ### Configure ERF to use external AMReX with CMake Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingLibraryConfig.md Build and install an external AMReX, then configure ERF using CMake to point to the external installation. This requires setting the installation prefix and the AMReX_ROOT path. ```bash # Build and install external AMReX git clone https://github.com/AMReX-Codes/amrex.git cd amrex && mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=/opt/amrex .. make install # Configure ERF to use external build cmake -DERF_USE_INTERNAL_AMREX=OFF \ -DAMReX_ROOT=/opt/amrex \ .. \ ``` -------------------------------- ### Entrainment Flux Calculation (Example 1) Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/theory/PBLschemes.md Formula for calculating the entrainment flux at the PBL top. This is one of two provided examples. ```mathematica $\overline{\left(w'c' \right)_h} = $ ``` -------------------------------- ### Configure Initial Aerosol Distribution (NaCl) Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/theory/Microphysics.md Set up the initial distribution parameters for a specific aerosol species (NaCl) using an exponential mass distribution. ```bash # NaCl aerosol with exponential mass distribution super_droplets_moisture.0.initial_aerosol_distribution_type_NaCl = "mass_exponential" super_droplets_moisture.0.initial_aerosol_mean_mass_NaCl = 1.0e-19 super_droplets_moisture.0.initial_aerosol_max_mass_NaCl = 1.0e-18 ``` -------------------------------- ### Configure External AMReX Installation Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Sets up the build to use an external AMReX installation by defining the AMREX_HOME environment variable. Supports both bash and tcsh shells. ```bash # Download external AMReX git clone https://github.com/amrex-codes/amrex.git # Set environment variable (bash) export AMREX_HOME=/path/to/external/amrex # Or for tcsh setenv AMREX_HOME /path/to/external/amrex ``` -------------------------------- ### Enable P3 and MPI with GNU Make Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingLibraryConfig.md Use GNU Make with specific variables to enable P3 and MPI. Ensure the build environment script is sourced. ```bash source Build/GNU_Ekat/ekat_build_commands.sh make USE_P3=TRUE USE_MPI=TRUE ``` -------------------------------- ### Install Package Configuration Files Source: https://github.com/erf-model/erf/blob/development/CMakeLists.txt Installs the CMake package configuration file (`Config.cmake`) to enable `find_package` for external projects. Requires `CMakePackageConfigHelpers` and `GNUInstallDirs` includes. ```cmake install( EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ) configure_package_config_file( CMake/${PROJECT_NAME}Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} ) ``` -------------------------------- ### Example Perlmutter Machine Profile Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingHPC.md An example of a machine profile file for the NERSC Perlmutter system. It loads necessary modules for compilation, including GCC, CMake, CUDA, and Cray-specific libraries. ```bash #!/bin/bash module load gcc-native/13.2 cmake cudatoolkit cray-hdf5-parallel cray-netcdf-hdf5parallel cray-libsci #module load gcc-native/13.2 #module load cray-mpich/8.1.30 #module load cray-hdf5-parallel/1.14.3.1 #module load cray-netcdf-hdf5parallel/4.9.0.13 #module load cmake/3.30.2 #module load cray-libsci/24.07.0 #module load cray-parallel-netcdf/1.12.3.13 # Automatically included with module load gpu # export MPICH_GPU_SUPPORT_ENABLED=1 ``` -------------------------------- ### Import yt and Check Version Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/Visualization.md Import the yt library and print its version. This is the initial step before loading any data. ```python import yt print(yt.__version__) ``` -------------------------------- ### Parse Build Arguments and Set Up Directories Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md This script parses command-line arguments to determine the build set, script pattern, and ERF directory. It validates the ERF directory and sets up the source and build directories accordingly. ```bash #!/bin/bash # Parse arguments if [ $# -lt 1 ] || [ $# -gt 3 ]; then echo "Usage: $0 [script_pattern] [erf_dir]" echo "" echo "Sets:" echo " default - Scripts from Build/" echo " perlmutter - Scripts from Build/Perlmutter/" echo " gnu_ekat - Scripts from Build/GNU_Ekat/" echo "" echo "If script_pattern is provided, creates build_/ ``` ```bash echo "Otherwise creates build_/" echo "" echo "If erf_dir is provided, uses that as ERF_DIR" echo "Otherwise auto-detects ERF repo root" exit 1 fi SET=$1 PATTERN=${2:-} ERF_DIR_ARG=${3:-} # Set ERF_DIR if [ -n "$ERF_DIR_ARG" ]; then ERF_DIR="$ERF_DIR_ARG" echo "Using provided ERF_DIR: $ERF_DIR" if ! verify_erf_dir "$ERF_DIR"; then echo "Error: Provided directory is not a valid ERF repository" echo "Must contain 'Energy Research and Forecasting' in README.rst, LICENSE.md, or CITATION.cff" exit 1 fi else if ! find_erf_dir; then echo "Error: Could not auto-detect ERF_DIR" echo "Please provide it as the third argument or run from ERF Build/ directory" echo "" echo "Verification checks for:" echo " - CMakeLists.txt and Source/ directory" echo " - 'Energy Research and Forecasting' in README.rst, LICENSE.md, or CITATION.cff" exit 1 fi fi echo "ERF_DIR set to: $ERF_DIR" # Define source directories relative to ERF_DIR DEFAULT_DIR="$ERF_DIR/Build" PERLMUTTER_DIR="$ERF_DIR/Build/Perlmutter" GNU_EKAT_DIR="$ERF_DIR/Build/GNU_Ekat" case $SET in default) SRC_DIR="$DEFAULT_DIR" ;; perlmutter) SRC_DIR="$PERLMUTTER_DIR" ;; gnu_ekat) SRC_DIR="$GNU_EKAT_DIR" ;; *) echo "Error: Invalid set '$SET'" echo "Choose: default, perlmutter, or gnu_ekat" exit 1 ;; esac if [ ! -d "$SRC_DIR" ]; then echo "Error: Source directory does not exist: $SRC_DIR" exit 1 fi # Determine build directory name if [ -n "$PATTERN" ]; then BUILD_DIR="$ERF_DIR/build_${PATTERN}" else BUILD_DIR="$ERF_DIR/build_${SET}" fi # Create build directory mkdir -p "$BUILD_DIR" echo "Created directory: $BUILD_DIR" # Find and copy ERF cmake build scripts echo "Scanning for ERF cmake scripts in $SRC_DIR:" COPIED=0 SKIPPED=0 # Temporarily disable exit on error for the loop set +e for script in "$SRC_DIR"/*.sh; do # Check if file exists (glob might not match anything) if [ ! -f "$script" ]; then continue fi basename_script=$(basename "$script") # Skip backup files if [[ "$basename_script" =~ ~$ ]]; then SKIPPED=$((SKIPPED + 1)) continue fi # Check if it's an ERF cmake script (contains DERF or cmake) has_derf=0 has_cmake=0 grep -q "DERF" "$script" 2>/dev/null && has_derf=1 grep -q "cmake" "$script" 2>/dev/null && has_cmake=1 if [ $has_derf -eq 1 ] || [ $has_cmake -eq 1 ]; then cp "$script" "$BUILD_DIR/" chmod +x "$BUILD_DIR/$basename_script" echo " DONE: $basename_script" COPIED=$((COPIED + 1)) else echo " ERROR: $basename_script (no DERF or cmake found)" SKIPPED=$((SKIPPED + 1)) fi done # Re-enable exit on error set -e echo "" echo "Summary: Copied $COPIED script(s), skipped $SKIPPED" if [ $COPIED -eq 0 ]; then echo "Warning: No ERF cmake scripts found" echo "Scripts should contain 'DERF' or 'cmake'" fi # Create a run script in the build directory cat > "$BUILD_DIR/run.sh" << 'EOF' #!/bin/bash set -e set -o pipefail # Resolve ERF_DIR (go up from build directory) SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export ERF_DIR="$(dirname "$SCRIPT_DIR")" echo "ERF_DIR set to: $ERF_DIR" # Find all .sh scripts (excluding run.sh and backups) SCRIPTS=() for script in *.sh; do if [ "$script" = "run.sh" ]; then continue fi if [[ "$script" =~ ~$ ]]; then continue fi if [ -f "$script" ]; then SCRIPTS+=("$script") fi done # Sort scripts alphabetically IFS=$'\n' SCRIPTS=($(sort <<<"${SCRIPTS[*]}")) unset IFS if [ ${#SCRIPTS[@]} -eq 0 ]; then echo "Error: No build scripts found in this directory" exit 1 fi if [ $# -ne 1 ]; then echo "Usage: $0 " echo "" echo "Available ERF cmake scripts:" for i in "${!SCRIPTS[@]}"; do script_base="${SCRIPTS[$i]%.sh}" printf "%3d: %s\n" $((i+1)) "${SCRIPTS[$i]}" printf " -> subdirectory: %s/script_%s/\n" "$ERF_DIR" "$script_base" done echo "" echo "Each script will run in its own clean subdirectory at ERF root." exit 1 fi NUM=$1 if [ $NUM -lt 1 ] || [ $NUM -gt ${#SCRIPTS[@]} ]; then echo "Error: Number must be between 1 and ${#SCRIPTS[@]}" exit 1 fi SCRIPT="${SCRIPTS[$((NUM-1))]}" SCRIPT_BASE="${SCRIPT%.sh}" SUBDIR="$ERF_DIR/script_${SCRIPT_BASE}" EOF ``` -------------------------------- ### Check NetCDF Installation on Aurora Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/aurora_build_run.md Verify the presence and accessibility of NetCDF-C, NetCDF-Fortran, and HDF5 libraries and headers on Aurora after sourcing the environment profile. These checks ensure that the necessary dependencies for ERF are correctly installed and configured. ```bash # C headers and library (required) ls $NETCDF_C_ROOT/include/netcdf.h ls $NETCDF_C_ROOT/lib64/libnetcdf* # Fortran module and library (required for Noah-MP) ls $NETCDF_FORTRAN_ROOT/include/netcdf.mod ls $NETCDF_FORTRAN_ROOT/lib64/libnetcdff* # HDF5 library ls $HDF5_ROOT/lib/libhdf5* ``` -------------------------------- ### Clone AMReX-Agent Repository Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/AgenticWorkFlow.md Clone the AMReX-Agent repository and checkout a specific commit for setup. ```bash git clone --recursive https://github.com/AMReX-Codes/amrex-agent.git cd amrex-agent git checkout 6e77ca3 ``` -------------------------------- ### Initialize GoogleTest Submodule Recursively Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/testing.md Alternative command to initialize GoogleTest and any nested submodules. Use this after cloning the repository if you need all submodules. ```bash git submodule update --init --recursive ``` -------------------------------- ### Manual CMake Configuration with Options Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Configures the build using CMake with specific options for build type, MPI, compilers, and other ERF-specific features. Followed by a make command. ```bash cmake -DCMAKE_BUILD_TYPE=Release \ -DERF_ENABLE_MPI=ON \ -DCMAKE_CXX_COMPILER=mpicxx \ -DCMAKE_C_COMPILER=mpicc \ -DCMAKE_Fortran_COMPILER=mpifort \ .. && make ``` -------------------------------- ### Cleanup for Rebuild (Out-of-Source) Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Removes build and install directories for a clean rebuild. Recreates the build directory and changes into it. ```bash rm -rf build/ install/ # complete cleanup mkdir build && cd build ``` -------------------------------- ### Get Interactive Nodes on Aurora Source: https://github.com/erf-model/erf/blob/development/Exec/CanonicalTests/ABL/README.md Obtain an interactive session on Aurora for scaling studies, utilizing the 'debug-scaling' queue. ```bash sh Scaling/Aurora/get_interactive_nodes.sh ``` -------------------------------- ### Quick Test Run Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingTroubleshooting.md Execute a short simulation using MPI to quickly verify that the ERF executable runs correctly after a successful build. ```bash # Run short simulation cd build/install/bin mpiexec -n 4 ./ERF3d.*.ex inputs max_step=10 ``` -------------------------------- ### Define erf_api Library Source: https://github.com/erf-model/erf/blob/development/CMakeLists.txt Defines a CMake library target 'erf_api'. Properties like POSITION_INDEPENDENT_CODE and CUDA compilation setup can be applied. ```cmake add_library(erf_api) if (BUILD_SHARED_LIBS) set_target_properties(erf_api PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() if (ERF_ENABLE_CUDA) setup_target_for_cuda_compilation(erf_api) endif () ``` -------------------------------- ### Quick Diagnostic Commands Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingTroubleshooting.md Run these commands to quickly check your build environment and identify potential issues with modules, GPU targets, and library paths. ```bash module list echo $CRAY_ACCEL_TARGET echo $NETCDF_DIR ``` -------------------------------- ### Customize CMake Build Directories Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/quickstart.md Override default build, source, and install directories for the CMake build process by setting environment variables. ```bash ERF_HOME=$(pwd) ./Build/cmake_with_kokkos_many.sh ERF_BUILD_DIR=$(pwd)/build_custom \ ERF_INSTALL_DIR=$(pwd)/install_custom \ ./Build/cmake_with_kokkos_many.sh ``` -------------------------------- ### Configure Initial Aerosol Distribution (NH4HSO4) Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/theory/Microphysics.md Set up the initial distribution parameters for a specific aerosol species (NH4HSO4) using a log-normal radius distribution. ```bash # NH4HSO4 aerosol with log-normal radius distribution super_droplets_moisture.0.initial_aerosol_distribution_type_NH4HSO4 = "radius_log_normal" super_droplets_moisture.0.initial_aerosol_mean_radius_NH4HSO4 = 30.0e-9 super_droplets_moisture.0.initial_aerosol_std_radius_NH4HSO4 = 0.247 ``` -------------------------------- ### Configure CMake with NetCDF and HDF5 Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingLibraryConfig.md Enables NetCDF and HDF5 support for the ERF model. Use -DNETCDF_DIR to specify a custom installation path. ```bash cmake -DERF_ENABLE_NETCDF=ON \ -DNETCDF_DIR=/opt/netcdf-parallel \ .. ``` ```bash export NETCDF_DIR=/opt/netcdf-parallel cmake -DERF_ENABLE_NETCDF=ON .. ``` -------------------------------- ### No-Slip Wall with Specified Tangential Velocities Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/BoundaryConditions.md Define no-slip wall boundaries with specified tangential velocities, as used in Couette flow examples. ```default geometry.is_periodic = 1 1 0 zlo.type = "NoSlipWall" zhi.type = "NoSlipWall" zlo.velocity = 0.0 0.0 0.0 zhi.velocity = 2.0 0.0 0.0 ``` -------------------------------- ### GNU Make Verify Build Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/buildingSystems.md Displays build configuration details for the ERF executable. ```bash ./ERF*ex --describe ``` -------------------------------- ### Initialize GoogleTest Submodule Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/testing.md Command to initialize the GoogleTest submodule, necessary for building unit tests. Run this command if you encounter issues with unit tests. ```bash git submodule update --init Submodules/googletest ``` -------------------------------- ### Build and Run ERF on Kestrel (NREL) Source: https://github.com/erf-model/erf/blob/development/Docs/sphinx_doc/GettingStarted.md Clone ERF, source the Kestrel machine profile, build with CUDA support, and submit a job using the provided sbatch script. ```bash git clone --recursive https://github.com/erf-model/ERF.git cd ERF source Build/machines/kestrel_erf.profile ERF_HOME=$(pwd) ./Build/cmake_with_kokkos_many_cuda.sh cd install/bin sbatch ../../Docs/sphinx_doc/scripts/quickstart/run_kestrel_erf.sbatch ``` -------------------------------- ### Get Interactive Nodes on Perlmutter Source: https://github.com/erf-model/erf/blob/development/Exec/CanonicalTests/ABL/README.md Request an interactive session on Perlmutter for small scaling studies, supporting up to 4 nodes (16 GPUs). ```bash cd Scaling/Perlmutter sh get_interactive_nodes.sh ```