|
2 | 2 |
|
3 | 3 | **Complete walkthrough**: Get SCHISM-ESMF building and running in under 30 minutes. |
4 | 4 |
|
5 | | -> **Quick Reference**: See [Readme.md](./Readme.md) for build summary. This guide provides **detailed explanations** and **platform-specific tips**. |
| 5 | +> **Quick Reference**: See [ReadMe.md](./ReadMe.md) for build summary. This guide provides **detailed explanations** and **platform-specific tips**. |
6 | 6 |
|
7 | 7 | --- |
8 | 8 |
|
|
32 | 32 | ### Using Conda/Mamba (Recommended) |
33 | 33 |
|
34 | 34 | ```bash |
35 | | -# Create environment |
36 | | -mamba create -n esmf-env |
| 35 | +# Create and activate environment |
| 36 | +mamba create -n esmf "esmf=8.9.1=mpi_mpich*" |
| 37 | +mamba activate esmf |
37 | 38 |
|
38 | | -# Activate environment |
39 | | -conda activate esmf-env |
| 39 | +# Verify MPI support (should NOT show "mpiuni") |
| 40 | +grep ESMF_COMM $CONDA_PREFIX/lib/esmf.mk |
| 41 | +``` |
40 | 42 |
|
41 | | -# Install ESMF with MPI (choose one) |
42 | | -mamba install -c conda-forge "esmf=8.9.0=mpi_mpich*" |
43 | | -# OR |
44 | | -mamba install -c conda-forge "esmf=8.9.0=mpi_openmpi*" |
| 43 | +You may also use the `mpi_openmpi*` variant if preferred. |
| 44 | + |
| 45 | +### Using Homebrew |
| 46 | + |
| 47 | +```bash |
| 48 | +brew install gcc open-mpi esmf |
| 49 | + |
| 50 | +# Point to the installed esmf.mk |
| 51 | +export ESMFMKFILE=$(brew --prefix esmf)/lib/esmf.mk |
45 | 52 |
|
46 | 53 | # Verify MPI support (should NOT show "mpiuni") |
47 | | -grep ESMF_COMM $CONDA_PREFIX/lib/esmf.mk |
| 54 | +grep ESMF_COMM $ESMFMKFILE |
48 | 55 | ``` |
49 | 56 |
|
| 57 | +If you prefer MPICH, swap `open-mpi` for `mpich` in the install step. |
| 58 | + |
50 | 59 | ### Using Spack |
51 | 60 |
|
52 | 61 | ```bash |
53 | 62 | spack install esmf+mpi |
54 | 63 | spack load esmf |
55 | 64 | ``` |
56 | 65 |
|
| 66 | + |
57 | 67 | ### From Source |
58 | 68 |
|
| 69 | +You need to manually install in your operating system the dependencies of ESMF, typically `netcdf`, `xerces` and `mpi`; how these are installed, depends heavily on your package manager. |
| 70 | + |
59 | 71 | ```bash |
60 | | -export ESMF_DIR=/path/to/esmf |
61 | | -export ESMF_COMM=mpich # or openmpi |
| 72 | +export ESMF_DIR=/devel/esmf/esmf # or any other |
| 73 | +export ESMF_COMM=mpich # or openmpi |
62 | 74 | cd $ESMF_DIR |
63 | 75 | make |
64 | 76 | make install |
65 | 77 | ``` |
66 | 78 |
|
| 79 | +Then set an environment variable to point to the `esmf.mk` file: |
| 80 | + |
| 81 | +```bash |
| 82 | +export ESMFMKFILE=$ESMF_DIR/lib/esmf.mk |
| 83 | +``` |
| 84 | + |
67 | 85 | ## Step 2: Build SCHISM |
68 | 86 |
|
69 | | -SCHISM must be built with CMake (not the legacy Makefile). |
| 87 | +From the installation before, set the environment variables for the C and Fortran compiler, for a `mamba` system they would be: |
70 | 88 |
|
71 | 89 | ```bash |
72 | | -# Clone SCHISM |
73 | | -git clone https://github.com/schism-dev/schism.git |
74 | | -cd schism |
| 90 | +export FC=$CONDA_PREFIX/bin/gfortran CC=$CONDA_PREFIX/bin/clang |
| 91 | +``` |
| 92 | + |
| 93 | +Choose a directory where your sources reside and reference them with environment variables; you may choose different ones than those suggested here. |
| 94 | + |
| 95 | +```bash |
| 96 | +export SCHISM_BASE=$HOME/devel/schism/schism |
| 97 | +export SCHISM_BUILD_DIR=$SCHISM_BASE/build |
| 98 | +export SCHISM_ESMF_BASE=$SCHISM_BASE/../schism-esmf |
| 99 | +export SCHISM_ESMF_BUILD_DIR=$SCHISM_ESMF_BASE/build |
| 100 | +```` |
| 101 | + |
| 102 | +Then, clone and build SCHISM with CMake (not the legacy Makefile). |
| 103 | + |
| 104 | +```bash |
| 105 | +mkdir -p $SCHISM_BASE/.. # make sure the parent directory exists |
| 106 | +git clone --recurse-submodules --depth=1 https://github.com/schism-dev/schism.git $SCHISM_BASE |
| 107 | +
|
| 108 | +mkdir -p $SCHISM_BUILD_DIR # make sure the build directory exists |
| 109 | +cd $SCHISM_BUILD_DIR |
75 | 110 |
|
76 | 111 | # Configure with CMake |
77 | | -mkdir -p build && cd build |
78 | | -cmake ../src \ |
79 | | - -DCMAKE_Fortran_COMPILER=$(which gfortran) \ |
80 | | - -DUSE_PARMETIS=ON \ |
| 112 | +cmake -S $SCHISM_BASE/src -B $SCHISM_BUILD_DIR \ |
| 113 | + -DCMAKE_Fortran_COMPILER=$FC \ |
| 114 | + -DCMAKE_C_COMPILER=$CC \ |
| 115 | + -DUSE_PARMETIS=ON -DBLD_STANDALONE=ON \ |
81 | 116 | -DUSE_WWM=OFF |
82 | 117 |
|
83 | 118 | # Build (adjust -j for your CPU count) |
84 | | -make -j8 |
85 | | - |
86 | | -# Note the build directory path |
87 | | -export SCHISM_BUILD_DIR=$(pwd) |
88 | | -echo "SCHISM built in: $SCHISM_BUILD_DIR" |
| 119 | +cmake --build $SCHISM_BUILD_DIR --parallel 8 --target pschism |
89 | 120 | ``` |
90 | 121 |
|
91 | 122 | **Verify SCHISM libraries**: |
92 | 123 | ```bash |
93 | 124 | ls -lh $SCHISM_BUILD_DIR/lib/ |
94 | | -# Should see: libcore.a, libhydro.a, libturbulence.a, libyaml.a, libparmetis.a, libmetis.a |
| 125 | +# Should see: libcore.a, libhydro.a, libparmetis.a, libmetis.a |
95 | 126 | ``` |
96 | 127 |
|
97 | 128 | ## Step 3: Build SCHISM-ESMF |
98 | 129 |
|
99 | 130 | ```bash |
100 | 131 | # Clone this repository |
101 | | -git clone https://github.com/schism-dev/schism-esmf.git |
102 | | -cd schism-esmf |
103 | | - |
104 | | -# Set environment variables |
105 | | -export ESMFMKFILE=/path/to/esmf.mk # e.g., $CONDA_PREFIX/lib/esmf.mk |
106 | | -export SCHISM_BUILD_DIR=/path/to/schism/build |
107 | | - |
108 | | -# Configure |
109 | | -mkdir -p build && cd build |
110 | | -cmake .. -DCMAKE_Fortran_COMPILER=$(which gfortran) |
111 | | - |
112 | | -# Build |
113 | | -cmake --build . -- -j8 |
114 | | -``` |
| 132 | +git clone --depth=1 --recurse-submodules https://github.com/schism-dev/schism-esmf.git $SCHISM_ESMF_BASE |
| 133 | +cd $SCHISM_ESMF_BASE |
115 | 134 |
|
116 | | -**macOS specific**: |
117 | | -```bash |
118 | | -cmake .. \ |
119 | | - -DCMAKE_Fortran_COMPILER=$(which gfortran) \ |
120 | | - -DCMAKE_C_COMPILER=$(which gcc) |
121 | | -cmake --build . -- -j$(sysctl -n hw.ncpu) |
| 135 | +# Build the cap |
| 136 | +mkdir -p $SCHISM_ESMF_BUILD_DIR |
| 137 | +cmake -S $SCHISM_ESMF_BASE -B $SCHISM_ESMF_BUILD_DIR -DCMAKE_Fortran_COMPILER=mpifort -DSCHISM_REQUIRE_turbulence=OFF |
| 138 | +cmake --build $SCHISM_ESMF_BUILD_DIR -- -j8 |
122 | 139 | ``` |
123 | 140 |
|
124 | 141 | **Expected output**: |
@@ -269,6 +286,6 @@ gfortran --version # Should be 11+ |
269 | 286 |
|
270 | 287 | --- |
271 | 288 |
|
272 | | -**Build time**: ~10 minutes (after dependencies installed) |
273 | | -**Skill level**: Intermediate (Fortran/MPI experience helpful) |
| 289 | +**Build time**: ~10 minutes (after dependencies installed) |
| 290 | +**Skill level**: Intermediate (Fortran/MPI experience helpful) |
274 | 291 | **Last updated**: November 2025 |
0 commit comments