howto:compile_on_macos
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| howto:compile_on_macos [2025/08/22 10:48] – Update macOS version krack | howto:compile_on_macos [2026/10/16 09:47] (current) – oschuett | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Compile CP2K on macOS ====== | + | This page has been moved to: https:// |
| - | This page describes how CP2K can be installed under [[https:// | ||
| - | [[https:// | ||
| - | |||
| - | ==== 1. Install Homebrew ==== | ||
| - | |||
| - | Open a Terminal and run the command | ||
| - | < | ||
| - | /bin/bash -c " | ||
| - | </ | ||
| - | which will install the latest Homebrew version. This howto was tested with Homebrew 3.6.11 as well as with newer versions up to 4.4.19. | ||
| - | |||
| - | === a) The easy way === | ||
| - | |||
| - | If you are only interested in testing CP2K under macOS, then you can install a pre-compiled CP2K binary providing all basic features via | ||
| - | < | ||
| - | brew install cp2k | ||
| - | </ | ||
| - | using this [[https:// | ||
| - | |||
| - | === b) Compile CP2K under macOS from scratch === | ||
| - | |||
| - | For best performance or code development, | ||
| - | e.g. with | ||
| - | < | ||
| - | brew uninstall cp2k | ||
| - | brew unlink open-mpi scalapack | ||
| - | </ | ||
| - | before you continue to avoid any interference with these Homebrew packages during the installation of the CP2K toolchain. | ||
| - | |||
| - | Create the following links | ||
| - | < | ||
| - | ln -s / | ||
| - | ln -s / | ||
| - | ln -s / | ||
| - | </ | ||
| - | to make Homebrew' | ||
| - | < | ||
| - | gcc -v | ||
| - | </ | ||
| - | if that is the case. | ||
| - | |||
| - | ==== 2. Obtain CP2K ==== | ||
| - | |||
| - | Checkout the latest CP2K (master) version available from the [[https:// | ||
| - | < | ||
| - | git clone --recursive https:// | ||
| - | </ | ||
| - | or the latest CP2K release version | ||
| - | < | ||
| - | git clone --recursive -b support/ | ||
| - | </ | ||
| - | |||
| - | ==== 3. Build the CP2K toolchain ==== | ||
| - | |||
| - | Change to the new folder '' | ||
| - | < | ||
| - | cd cp2k | ||
| - | </ | ||
| - | and run the command | ||
| - | < | ||
| - | source arch/ | ||
| - | </ | ||
| - | to build the toolchain for a serial CP2K binary. | ||
| - | Alternatively, | ||
| - | < | ||
| - | source arch/ | ||
| - | </ | ||
| - | |||
| - | ==== 4. Compile CP2K ==== | ||
| - | |||
| - | Check the output from the toolchain build in the previous step and if there is no error, run | ||
| - | < | ||
| - | make -j ARCH=Darwin-gnu-arm64 VERSION=ssmp | ||
| - | </ | ||
| - | or | ||
| - | < | ||
| - | make -j ARCH=Darwin-gnu-arm64 VERSION=psmp | ||
| - | </ | ||
| - | as suggested depending on the selected toolchain build. | ||
| - | |||
| - | ==== 5. Test the CP2K binary ==== | ||
| - | |||
| - | As a final check, you can run a CP2K regression test with | ||
| - | < | ||
| - | make -j ARCH=Darwin-arm64 VERSION=psmp test | ||
| - | </ | ||
| - | to validate the generated CP2K binary. This will run more than 4000 test cases. At the end of that test, a summary is printed which should indicate that there are no '' | ||
| - | < | ||
| - | make -j ARCH=Darwin-arm64 VERSION=psmp TESTOPTS=" | ||
| - | </ | ||
| - | which will only run the test cases in the folder '' | ||
| - | < | ||
| - | tests/ | ||
| - | </ | ||
| - | All data generated by '' | ||
| - | < | ||
| - | make ARCH=Darwin-arm64 VERSION=psmp testclean | ||
| - | </ | ||
| - | whereas | ||
| - | < | ||
| - | make ARCH=Darwin-arm64 VERSION=psmp realclean | ||
| - | </ | ||
| - | and | ||
| - | < | ||
| - | make distclean | ||
| - | </ | ||
| - | will remove all data from '' | ||
| - | |||
| - | ==== Last but not least ==== | ||
| - | |||
| - | Before using CP2K, do not forget to '' | ||
| - | < | ||
| - | source tools/ | ||
| - | </ | ||
| - | |||
| - | It is also suggested to increase the '' | ||
| - | < | ||
| - | export OMP_STACKSIZE=16M | ||
| - | ulimit -s 65000 | ||
| - | </ | ||
| - | and the '' | ||
| - | |||
| - | Adding the '' | ||
| - | < | ||
| - | export PATH=$PATH: | ||
| - | </ | ||
| - | will allow for running CP2K just with | ||
| - | < | ||
| - | cp2k.ssmp | ||
| - | </ | ||
| - | and likewise with '' | ||
| - | |||
| - | CP2K MPI/OpenMP parallel runs are launched with '' | ||
| - | < | ||
| - | mpiexec -n 4 -genv OMP_NUM_THREADS=2 cp2k.psmp H2O-32.inp | ||
| - | </ | ||
| - | will use 4 MPI ranks with 2 OpenMP threads each (i.e. it will consume 8 CPU cores) to run the input file '' | ||
| - | |||
| - | The '' | ||
| - | < | ||
| - | mpiexec -n 4 -genv OMP_NUM_THREADS=1 cp2k.psmp H2O-32.inp | ||
| - | mpiexec -n 4 | ||
| - | </ | ||
| - | are basically equivalent. | ||
| - | |||
| - | **Enjoy CP2K under macOS!** | ||
howto/compile_on_macos.txt · Last modified: by oschuett
