...
Rebuild the program with:
- The default GNU GCC compiler.
- The default Classic Intel compiler.
- The default LLVM-based Intel compiler.
- The default AMD AOCC.
Use the following command to test and show what versions of the libraries are being used at any point:
No Format make clean ldd test
Expand title Solution You can perform this test with the following one-liner, exploiting the
prgenv
module:No Format for pe in gnu intel intel-llvm amd; do ml prgenv/$pe; make clean ldd test; echo "******************"; done
Pay attention to the following aspects:
- The Lmod module command informs you that it has reloaded the corresponding modules when changing the
prgenv
. This ensures the libraries used in your program are built with the same compiler for maximum compatibility. - The compiler command changes automatically, since we are using the environment variable $
CC
in the Makefile. - The include and library flags in the compilation lines are adapted automatically based on the libraries loaded.
- The final binary is linked with the corresponding libraries for the version of the compiler as shown by
ldd
output.
Real-world example: CDO
To put into practice what we have learned so far, let's try to build and install CDO. You would typically not need to build this particular application, since it is already available as part of the standard software stack via modules or easily installable with conda. However, it is a good illustration of how to build a real-world software with dependencies to other software packages and libraries.
The goal of this exercise is for you to be able to build CDO and install it under one of your storage spaces (HOME or PERM), and then successfully run:
No Format |
---|
<PREFIX>/bin/cdo -V |
You will need to:
- Familiarise yourself with the installation instructions of this package in the official documentation.
- Decide your installation path and your build path.
- Download the source code from the CDO website.
- Set up your build environment (i.e. modules, environment variables) for a successful build
- Build and install the software
- Test that works with the command above.
Make sure that CDO is built at least with support to:
- NetCDF
- HDF5
- SZLIB (hint: use AEC)
- ecCodes
- PROJ
- CMOR
- UDUNITS
Tip | |||||||||
---|---|---|---|---|---|---|---|---|---|
| |||||||||
It is strongly recommended you bundle all your build process in a job script that you can submit in batch requesting additional cpus so that you can exploit build parallelism with make -j If you would like a starting point for such a job, you can start from the following example, adding and amending the necessary bits as needed:
|
Expand | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||
This is the complete job script to
You can submit it to the batch system with
While it builds, you may want to keep an eye on the progress with:
Make sure the job completes successfully and that the output of the CDO executable you built is what you would expect. |