Background #
Installing the Acoustic Toolbox (AT) software is nontrivial for basic and even intermediate computer users. The source files are written in Fortran and require a Fortran compiler to build the binary executables. macOS does not necessarily ship with the required compilers or libraries. One approach is to install and use the GNU Compiler Collection (GCC), but I had frequent problems with missing libraries and compatibility issues. Updating the OS often broke the installation of AT when compiled with GCC’s GFortran compiler. After many efforts at troubleshooting, I settled on using Intel’s Fortran compiler. The following steps will guide you through most of the steps required to install AT using ifort.
Initial Conditions: #
- 2019 MacBook Pro (Intel) running macOS Monterey v12.1.
- As of December 2022, executables run on same computer running macOS Monterey v12.6.1.
- The program
make
is installed. Check installation by typingmake -v
in your Terminal. Ifmake
is not installed, you can download it from GNU or Homebrew. - Apple’s Command Line Tools are installed - these can be installed via Xcode.
Preparation #
Download Required Tools and References #
- Download the standalone Intel Fortran Compiler Classic. Note: ensure you download from the section titled Compilers, not other options such as Runtime Versions.
- Download the documentation for the HPC Toolkit.
- Download the Acoustics Toolbox (AT) and unzip it to the desired installation directory.
Install Required Tools #
- Install the Intel Fortran Compiler Classic (ifort) using the installer. Use default setup options.
- Before using the ifort compiler, you need to tell your computer where to find the compiler components. There are two ways to do this.
(a) If you only need to use ifort to compile AT, you can set the necessary environment variables for just this terminal session by typing:source /<install-dir>/setvars.sh intel64
If you installed the compiler correctly, the<install-dir>
should be located at:/opt/intel/oneapi/
(b) If you do not wish to perform step 2.B.2(a) every time you enter a new terminal session, you can add the following to your.bashrc
or.zshrc
:source /<install-dir>/setvars.sh intel64
Get CPU Model Name #
In later steps you will need to know what CPU chipset model you have.
- Run the following code in your terminal:
sysctl -a | grep brand
- You should see a variable
machdep.cpu.brand_string
printed that looks something like:Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
.
The9980HK
is the model of your CPU. - Do an internet search for
Intel <model number> model name
. For example, the 9980HK is based on Intel’s “Coffee Lake” chipset model. - Open the documentation you downloaded in step 2.A.2. Navigate to:
Home -> Compiler Reference -> Compiler Options -> Alphabetical List of Compiler Options
- Click on the link for
ax, Qax
. - Find your CPU model name and note the syntax (e.g., Coffee Lake is all caps
COFFEELAKE
). This value will be used to configure your Makefiles in the following steps.
Add Library to Path #
Ensure MacOS command line tools (see 1.4) are on your computer’s LIBRARY_PATH
.
- If not already present, add the following to your
.bashrc
or.zshrc
:
export LIBRARY_PATH=$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
Prepare AT Makefiles #
Configure /AT/Makefile
#
- Navigate to the directory containing AT. Open
Makefile
in a text editor. - Read the instructions at the top of the file, and then scroll down to the
***ifort
section. - Comment out all lines beginning with
export FFLAGS
. - Paste the following beneath the
export FC=ifort
line:
export FFLAGS= -O3 -parallel -ax<YOUR CPU MODEL> -nologo -inline-level=2 -assume byterecl -threads -heap-arrays
For information on the various options, consult the documentation you downloaded in step 2.A.2.
5. Under the *** GNU Compiler Collection GFORTRAN
section, comment out all export
statements.
6. Scroll down to the bottom section, just below the *** Portland Group FORTRAN
section.
7. Change export CC=gcc
to export CC=ifort
.
8. Comment out export CFLAGS=-g
.
9. Save and close the Makefile.
Configure /AT/misc/Makefile
#
- Navigate to
/AT/misc
. - Open
Makefile
in this directory in a text editor. - Comment out the line
AR = ar
. - Uncomment the line
AR = xiar
. - Save and close the Makefile.
Configure /AT/tslib/Makefile #
- Navigate to
/AT/tslib
. - Open
Makefile
in this directory in a text editor. - Comment out the line
AR = ar
. - Uncomment the line
AR = xiar
. - Save and close the Makefile.
Compile AT #
- Navigate to
/AT
in Terminal. - Run the command:
make clean
. - Run the command:
make
.
Note: Intel Fortran will take a few minutes to compile all the files. - Once complete, you can run tests per the AT documentation. For example, in Terminal navigate to
/AT/tests/Munk
and run:kraken.exe MunkK
Set Symbolic Links #
Acoustic Toolbox programs can now be run from your Terminal (or from Python/MATLAB), but to do so, you must specify the path of the program in each call, or be in the same directory as the executable. For example, to run the command in 4.4 from a separate working directory, you would need to run:
<path to AT>/kraken/kraken.exe MunkK
For those of us who run these programs often enough, that can be a bit of a hassle. To be able to call AT programs from the command line without specifying the path to AT
, follow these steps.
- Download the shell script
mk_sym_links.sh
available here. - Open
mk_sym_links.sh
in a text editor. - Set the
AT_PATH
environment variable to your installation of AT. - Save and close the file.
- In Terminal, navigate to the same directory you saved
mk_sym_links.sh
. - Run the command:
sh mk_sym_links.sh
. You should now be able to run AT programs from any directory without specifying the path to AT.
Remove Symbolic Links #
- If you need to reinstall or remove AT and wish to remove the symbolic links, download
rm_sym_links.sh
available here. - In Terminal, naviage to the same directory you saved
rm_sym_links.sh
. - Run the command:
sh rm_sym_links.sh
.