macOS Big Sur for Computational Materials Science in 2021

April 15, 2021

Will this be my final update for Intel Macs? Given the initial performance reports of Apple Silicon, I hope so. This is a refresh of previous posts covering a clean install of macOS 11.2.1 (Big Sur) on an iMac Pro in April 2021.

Awaken UNIX

The first step is to give Terminal some power. Go to System Preferences; Security & Privacy; Privacy; Developer Tools and add Terminal to the apps that can run software locally.

A full Xcode install from the App Store is recommended. I used to open Terminal and type make, which triggers the system to install the command line tools module (basic UNIX commands including a gcc compiler), but you end up missing some essential components.

Note that zsh is the default shell. Set up your zprofile, ssh config, and vimrc files to make working faster and more comfortable. My .zprofile has some basic settings such as:

alias ls='ls -G -ltr'
export TERM=xterm-color
alias cpu='echo time $(uptime) && echo $(sysctl -n hw.ncpu) cores on $(hostname)'

Later you may need C libraries that are in a non-standard location, so I find it useful to create the following link:

sudo mkdir /usr/local/include
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/

Basics

My base applications include: (standard office) Box, Slack, MS Office (Imperial link), Mactex, Texmaker, Zotero; (scientific computing) latest gcc/gfortraniTerm, Textmate, XQuartz, Atom, Cyberduck, GitHub client(materials modelling) VESTA, Avogadro. For video and image editing, ffmpeg and imagemagick are essential.

Python

Python package and environment maintenance can cause headaches, so I now use conda (Python 3) as standard. This comes with all of the basic packages including jupyter-lab. Two commands are required to initialise conda properly after installation:

source /opt/anaconda3/bin/activate
conda init zsh

Fortran and C

It is possible to survive using gnu compilers and math libraries, but Intel C, Fortran and MKL tend to be faster and better tested (easier to compile). They now come free as part of the oneAPI suite, which avoids the clunky licensing protocols of times past.

There are two parts to install: the base toolkit includes MKL and the HPC Toolkit includes the compilers. The Mac version now comes with scalapack, which is a welcome bonus.

The install is easy and needs just one addition to your .zprofile:

source /opt/intel/oneapi/setvars.sh

Check the outcome with ifort --version.

Openmpi

To enable parallelism, I downloaded the latest source code of openmpi (4.1.1).

./configure -prefix=/usr/local/openmpi-4.1.1 CC=icc CXX=icpc FC=ifort F77=ifort FCFLAGS='-O1' CFLAGS='-O1' CXXFLAGS='-O1'
 make
 sudo make install

be patient… it can easily take 20 minutes.

With my version of oneAPI, the openmpi compilation was successful but later library errors emerged when compiling other code using mpif90. The fix (following this post) is to add  to add -Wl, to the wl variable (wl="-Wl,") in the libtool file after configure' and before make’. Finally add to your .zprofile:

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/openmpi-4.1.1/lib/
export PATH=./:/usr/local/openmpi-4.1.1/bin:$PATH
export OMP_NUM_THREADS=1

Check the outcome with mpif90 --version.

Phonopy

I use this open-source lattice-dynamics package a lot. The installation used to be multi-step, but if you just want to run the code (and not actively develop), then conda makes life simple:

sudo conda install -c conda-forge phonopy h5py

To run: phonopy

DFT: VASP

I use a range of density functional theory (DFT) packages, but VASP is a robust standard. Taking the shiny 6.2.0, enter the main folder and cp ./arch/makefile.include.linux_intel ./makefile.include. The file needs to be modified to point to the correct compilers (I used icc, icpc, and mpifort). MKL on Mac no longer has a “intel64” subfolder, you also need to adjust that link. The blacs library also changed name to -lmkl_blacs_mpich_lp64.

Although, mkl now includes scalapack, I found it produced a segmentation fault, so removed it by deleting DscaLAPACK from the pre-compiler options and setting SCALAPACK = . There is still one issue to fix: in ./src/lib/getshmem.c. Add #define SHM_NORESERVE 010000 to the end of the include statements. Then run make`.

Check the outcome with mpirun -np 4 vasp_std.

DFT: FHI-AIMS

The all-electron DFT package FHI-AIMS now uses cmake for compilation setup, which can be downloaded from here, and requires:
sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install.

In the program directory run

mkdir build
cd build
cp ../initial_cache.example.cmake ./initial_cache.cmake
cmake -C initial_cache.cmake ..'

I had to make the following edits to initial_cache.example.cmake:

set(LIB_PATHS "/opt/intel/oneapi/mkl/latest/libs" CACHE STRING "" FORCE)
set(LIBS "mkl_intel_lp64 mkl_sequential mkl_core mkl_blacs_mpich_lp64" CACHE STRING "" FORCE)

then simply compile using make -j 4 (to use 4 cores). Check the outcome with mpirun -np 4 aims.210226.mpi.x

ASE

The atomistic simulation environment is a useful set of Python tools and modules. It now installs, including the gui, with one command. Nothing more to say!

pip install --upgrade --user ase

The outcome can be checked with ase-gui.

ASE

I will update with more codes and tools as I find time, and always happy to receive suggestions.