|
| 1 | +# Third-party Libraries Required by EAMxx |
| 2 | + |
| 3 | +- First, we note that if you are running EAMxx on a supported machine, |
| 4 | +then you can expect that the third-party libraries (TPLs) are |
| 5 | +installed, properly configured, and recognized by the EAMxx build system. |
| 6 | +- However, if you choose to run and/or develop EAMxx on a local machine, |
| 7 | +workstation, or unsupported cluster, then you will likely need to build some |
| 8 | +number of the TPLs manually. |
| 9 | + - **Note:** The exception to this is if you are running on a machine with |
| 10 | + a module system that already provides them--e.g., research institutions |
| 11 | + that run E3SM regularly. |
| 12 | + |
| 13 | +## List of TPLs |
| 14 | + |
| 15 | +- **Note:** For this section, we will assume you plan to build EAMxx on a fresh |
| 16 | +Linux[^only-linux] system with the standard development tools available. |
| 17 | + - E.g., a package manager (`apt`, `yum`), `git`, `make`, `cmake`, etc. |
| 18 | + |
| 19 | +??? Abstract "TPLs You Will (almost certainly) Need to Install or Build Manually" |
| 20 | + |
| 21 | + - [OpenMPI](https://docs.open-mpi.org/en/v5.0.x/installing-open-mpi/quickstart.html) |
| 22 | + - Only required for builds employing multi-node parallelism. |
| 23 | + - Required for parallel configurations of the netCDF libraries. |
| 24 | + - Likely to be provided by your package manager or module system. |
| 25 | + - [HDF5](https://www.hdfgroup.org/download-hdf5/) |
| 26 | + - High-performance data-wrangling library. |
| 27 | + - The link above provides `.deb` and `.rpm` binary packages, though |
| 28 | + the page also provides a link to build from source. |
| 29 | + - [netCDF-C](https://github.com/Unidata/netcdf-c) |
| 30 | + - Used for I/O of simulation data in a format containing descriptive metadata. |
| 31 | + - [netCDF-fortran](https://github.com/Unidata/netcdf-fortran) |
| 32 | + - [PnetCDF](https://parallel-netcdf.github.io) |
| 33 | + - Only required for builds employing multi-node parallelism. |
| 34 | + |
| 35 | + **Build Tips** |
| 36 | + |
| 37 | + - As of 2024, the author found much less resistance configuring the build |
| 38 | + for the netCDF libraries using Autoconf, rather than CMake. |
| 39 | + |
| 40 | +??? List "Auxiliary TPLs Your System May Already Have Installed" |
| 41 | + |
| 42 | + The following list of TPLs may be pre-installed on some systems, and are |
| 43 | + helpful, if not required, for building the netCDF libraries. |
| 44 | + However, in the author's experience they did need to be built on a fresh |
| 45 | + installation of Red Hat Enterprise Linux 8. |
| 46 | + |
| 47 | + **Required** |
| 48 | + |
| 49 | + - [LAPACK](https://www.netlib.org/lapack/) or [BLAS](https://www.netlib.org/blas/) |
| 50 | + - Alternatively, [OpenBLAS](http://www.openmathlib.org/OpenBLAS/), |
| 51 | + which is unlikely to be pre-installed. |
| 52 | + |
| 53 | + **Likely Required** |
| 54 | + |
| 55 | + - [Autoconf](https://www.gnu.org/software/autoconf/) |
| 56 | + - [Libtool](https://www.gnu.org/software/libtool/) |
| 57 | + |
| 58 | + **Maybe Required**[^computers-amirite] |
| 59 | + |
| 60 | + - [help2man](https://www.gnu.org/software/help2man/) |
| 61 | + |
| 62 | +## Help & Hints |
| 63 | + |
| 64 | +Building third-party libraries can be a pain. |
| 65 | +To help here are some reasonable example scripts to start from that should |
| 66 | +help getting the ***TPLs You Will Need to Build*** compiled and working. |
| 67 | + |
| 68 | +??? Example "Basic Configuration Script Examples" |
| 69 | + |
| 70 | + !!! Warning "Disclaimer" |
| 71 | + |
| 72 | + We provide these scripts as demonstrative examples, only. |
| 73 | + They will almost certainly not build your libraries successfully if they |
| 74 | + are copy/paste-ed as they appear here. |
| 75 | + That being said, every hardware/software environment is different and |
| 76 | + will display different and sometimes strange behaviors. |
| 77 | + So, the best advice we can provide is to begin with something |
| 78 | + resembling what is below and respond to the compiler messages |
| 79 | + by modifying: environment variables, `PATH` or `[LD_]LIBRARY_PATH` |
| 80 | + entries, configuration arguments, and compiler arguments as required. |
| 81 | + As long as you do ***all of that*** perfectly, you should be just fine. |
| 82 | + :sunglasses: |
| 83 | + |
| 84 | + ### Assumptions |
| 85 | + |
| 86 | + - Source code is downloaded to a directory we assign to the variable `${TPL_ROOT}`. |
| 87 | + - We build the libraries in a separate ***build*** and ***install*** |
| 88 | + directory in the root directory of the source code. |
| 89 | + - E.g., `${TPL_ROOT}/<lib-name>/{build/,install/}` |
| 90 | + - The bash scripts below are placed in the `build/` directory. |
| 91 | + - Hence, note that when executing the configure script from the |
| 92 | + `build/` directory, the final `../configure [...]` command in the |
| 93 | + script (that calls autoconf) is running the `configure` command in |
| 94 | + the source directory for that TPL--e.g., `${TPL_ROOT}/<lib-name>/` |
| 95 | + - `libtool` is installed and on your `PATH`. |
| 96 | + - I.e., `which libtool` returns the location of the executable. |
| 97 | + |
| 98 | + ??? Abstract "`configure-hdf5.sh`" |
| 99 | + |
| 100 | + ```{.shell .copy} |
| 101 | + #!/bin/bash |
| 102 | + |
| 103 | + # add MPI C/C++ compilers to the proper environment variables |
| 104 | + mpi_path="${TPL_ROOT}/openmpi/install/bin/" |
| 105 | + export CC="${mpi_path}/mpicc" |
| 106 | + export CXX="${mpi_path}/mpicxx" |
| 107 | + |
| 108 | + # configure HDF5 build |
| 109 | + ../configure \ |
| 110 | + --prefix=${TPL_ROOT}/hdf5/install \ |
| 111 | + --enable-shared \ |
| 112 | + --enable-hl \ |
| 113 | + --enable-parallel \ |
| 114 | + --with-zlib=/usr/include,/usr/lib |
| 115 | + ``` |
| 116 | + |
| 117 | + ??? Abstract "`configure-netcdf-c.sh`" |
| 118 | + |
| 119 | + ```{.shell .copy} |
| 120 | + #!/bin/bash |
| 121 | + |
| 122 | + # add MPI C/C++ to the proper environment variables |
| 123 | + mpi_path="${TPL_ROOT}/openmpi/install/bin" |
| 124 | + export CC="${mpi_path}/mpicc" |
| 125 | + export CXX="${mpi_path}/mpicxx" |
| 126 | + |
| 127 | + # historically, netcdf can be a little picky to build, so it can help to |
| 128 | + # make ABSOLUTELY CERTAIN that the build system knows where HDF5 is |
| 129 | + # via the "sledgehammer" approach |
| 130 | + hdf5_path="${TPL_ROOT}/hdf5/install" |
| 131 | + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${hdf5_path}/lib" |
| 132 | + export LIBRARY_PATH=${LIBRARY_PATH}:${hdf5_path}/lib |
| 133 | + export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:${hdf5_path}/lib/pkgconfig |
| 134 | + export CPPFLAGS="-I${hdf5_path}/include" |
| 135 | + |
| 136 | + ../configure --prefix=${TPL_ROOT}/netcdf-c/install |
| 137 | + ``` |
| 138 | + |
| 139 | + ??? Abstract "`configure-netcdf-fortran.sh`" |
| 140 | + |
| 141 | + ```{.shell .copy} |
| 142 | + #! /bin/bash |
| 143 | + |
| 144 | + # add MPI Fortran compiler to the proper environment variables |
| 145 | + mpi_path="${TPL_ROOT}/openmpi/install/bin" |
| 146 | + export FC="${mpi_path}/mpif90" |
| 147 | + |
| 148 | + # local variables, to be used below |
| 149 | + export NetCDF_C_ROOT=${TPL_ROOT}/netcdf-c/install |
| 150 | + export NETCDF_C_LIBRARY=${NetCDF_C_ROOT}/lib |
| 151 | + export NETCDF_C_INCLUDE_DIR=${NetCDF_C_ROOT}/include |
| 152 | + |
| 153 | + # add netcdf-C bits and pieces to the proper paths |
| 154 | + export LD_LIBRARY_PATH="${NETCDF_C_LIBRARY}:${LD_LIBRARY_PATH}" |
| 155 | + export LIBRARY_PATH="${NETCDF_C_LIBRARY}:${LIBRARY_PATH}" |
| 156 | + export PATH=${NetCDF_C_ROOT}/bin:${PATH} |
| 157 | + |
| 158 | + # add netcdf-C include and library dir to the requisite compiler flags |
| 159 | + export CPPFLAGS="-I${NETCDF_C_INCLUDE_DIR}" |
| 160 | + export LDFLAGS="-L${NETCDF_C_LIBRARY}" |
| 161 | + |
| 162 | + # while we're at it, tell it where to find hdf5, too |
| 163 | + export HDF5_ROOT=${TPL_ROOT}/hdf5/install |
| 164 | + |
| 165 | + ../configure --prefix=${TPL_ROOT}/netcdf-fortran/install |
| 166 | + ``` |
| 167 | + |
| 168 | + ??? Abstract "`configure-pnetcdf.sh`" |
| 169 | + |
| 170 | + ```{.shell .copy} |
| 171 | + #!/bin/bash |
| 172 | + |
| 173 | + mpi_path="${TPL_ROOT}/openmpi/install/bin" |
| 174 | + export CC="${mpi_path}/mpicc" |
| 175 | + export CXX="${mpi_path}/mpicxx" |
| 176 | + export FC="${mpi_path}/mpif90" |
| 177 | + |
| 178 | + ../configure \ |
| 179 | + --prefix=${TPL_ROOT}/pnetcdf/install \ |
| 180 | + --enable-shared \ |
| 181 | + MPICC=mpicc \ |
| 182 | + MPICXX=mpicxx \ |
| 183 | + MPIF77=mpifort \ |
| 184 | + MPIF90=mpifort |
| 185 | + ``` |
| 186 | + |
| 187 | +<!-- ======================================================================= --> |
| 188 | + |
| 189 | +[^only-linux]: We only support build instructions for Linux, though some individuals have previously built EAMxx on MacOS with success. |
| 190 | +We would not recommend using EAMxx on Windows, other than via WSL. |
| 191 | +However, if you do end up building and running on MacOS or Windows, |
| 192 | +please let the developers know or submit a PR! |
| 193 | +<!-- markdownlint-disable-next-line MD053 --> |
| 194 | +[^computers-amirite]: Computers are weird. While it's by no means required from |
| 195 | +a functionality standpoint, a recently-configured RHEL8 system seemed to be |
| 196 | +convinced it needed help2man for some reason. |
0 commit comments