-
Notifications
You must be signed in to change notification settings - Fork 2
Installation on macOS
Homebrew
is a packet manager for macOS similar to apt
for Ubuntu and frankly, every scientist using macOS should have Homebrew
installed. Install with (or see detailed install instructions here):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install the newest Fortran compiler with (per 2021-09-29 version 11.2.0 will be installed):
brew install gfortran
and check that the version is equal to or greater than 10.2.0 by (version x.y.z with x > 10 should also be fine):
gfortran --version
For installing the correct version of Python, it is highly recommended to install an environment management system like miniconda
as to not mess up any other Python dependencies your system has, and to easily download the exact version needed. Start by cd
ing to your downloads directory with
cd ~/Downloads
and download the latest release of miniconda
(alternative downloads here) by:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
Then, run the installer which you just downloaded with:
bash Miniconda3-latest-MacOSX-x86_64.sh
Follow the on-screen instructions and accept the terms of service. Choose all default settings except when the installer asks if it should initialize by running conda init. For that option select yes. After the installation is complete, close and re-open your terminal session for the conda installation to function properly. Check that conda has been installed by running the command conda
. If a helpful description of conda shows up in your terminal then the installation is complete. However, if you see
> conda
conda: command not found
then conda has not been installed properly. To fix this, cd
to <install_location>/anaconda3/bin
and initialize conda from there. Replace <install_location>
with the path to where miniconda is installed which should be your home directory ~/
. Then, initialise conda with:
./conda init bash
Replace bash
if you are using a different shell, for example zsh
or fish
to mention a few. Close your terminal and open a new session, then run the command conda
once more to see that the installation is proper. When the initialization is complete, create an environment named kshell
with Python 3.10
:
conda create --name kshell python=3.10
Activate the environment with:
conda activate kshell
Note that any additional Python packages may be installed normally with pip
. You do not have to type pip3
or python3
because conda maps pip
and python
to the requested version of Python. For example, to install numpy
, simply run:
pip install numpy
The kshell
environment is only active within your terminal session and does not interfere with any other Python dependencies on your system. You can see the currently active conda environment in the bottom right or left corner of your terminal. The default environment is called (base)
and if you have followed these instructions you will see that the active environment is (kshell)
. This is one of the main reasons why I recommend using an environment manager. You may mess around however much you like inside of any conda environment other than base
without having to worry about a thing. Should you at any time in the future need a different version of Python (newer or older), simply create a conda environment with the appropriate Python version.
You: I need Python 2.7 to run some old code. Lets open the good ole' terminal. Apple: Tough luck. 2.7 is not included in newer versions of macOS. You: But wait... I have conda!
conda create --name <name of environment here> python=2.7
conda activate <name of environment here>
python --version
> Python 2.7.18
You: Noice!
As an alternative to using the forementioned conda approach, you can download Python 3.10
with brew
. Use brew search python
to find the correct name of Python version 3.10 or newer and then use brew install <correct name>
to install it. Note that you may have to use python3.10 myfile.py
to actually use version 3.10.
We are now ready to actually compile (install) KSHELL
. Navigate to the directory where you want to install KSHELL
. This guide assumes that you use your home directory (cd ~/
) but you may use another path if you'd like. Note that you do not need to create a directory called kshell (or whatever), because such a directory will be created during the installation. In your home directory, clone this repo with the command:
git clone https://github.com/GaffaSnobb/kshell.git
which copies all the needed files to your home inside a directory called kshell
. cd
to the ~/kshell/src/
directory and run the command
make
to compile KSHELL
. The output should be something like this (mismatch warnings are normal):
Click to see normal terminal output
> make
gfortran -O3 -fopenmp -fallow-argument-mismatch -c constant.f90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c model_space.f90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c lib_matrix.F90
lib_matrix.F90:304:29:
304 | call dlarnv(1, iseed, 1, r )
| 1
......
312 | call dlarnv(1, iseed, n, r)
| 2
Warning: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
gfortran -O3 -fopenmp -fallow-argument-mismatch -c class_stopwatch.F90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c partition.F90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c wavefunction.F90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c rotation_group.f90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c harmonic_oscillator.f90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c operator_jscheme.f90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c operator_mscheme.f90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c bridge_partitions.F90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c sp_matrix_element.f90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c interaction.f90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c bp_io.F90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c lanczos.f90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c bp_expc_val.F90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c bp_block.F90
gfortran -O3 -fopenmp -fallow-argument-mismatch -c block_lanczos.F90
block_lanczos.F90:548:12:
548 | vr(i*nb+1,1), size(vr,1), &
| 1
......
577 | -1.d0, vin(i*nb+1, 1), size(vin,1), an, size(an,1), &
| 2
Warning: Element of assumed-shape or pointer array as actual argument at (1) cannot correspond to actual argument at (2)
block_lanczos.F90:250:20:
250 | 1.d0, vi, nc, &
| 1
......
577 | -1.d0, vin(i*nb+1, 1), size(vin,1), an, size(an,1), &
| 2
Warning: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-2)
gfortran -O3 -fopenmp -fallow-argument-mismatch -c kshell.F90
gfortran -O3 -fopenmp -fallow-argument-mismatch -o kshell.exe kshell.o model_space.o interaction.o harmonic_oscillator.o constant.o rotation_group.o sp_matrix_element.o operator_jscheme.o operator_mscheme.o lib_matrix.o lanczos.o partition.o wavefunction.o bridge_partitions.o bp_io.o bp_expc_val.o class_stopwatch.o bp_block.o block_lanczos.o -llapack -lblas -lm
gfortran -O3 -fopenmp -fallow-argument-mismatch -c transit.F90
gfortran -O3 -fopenmp -fallow-argument-mismatch -o transit.exe transit.o model_space.o interaction.o harmonic_oscillator.o constant.o rotation_group.o sp_matrix_element.o operator_jscheme.o operator_mscheme.o lib_matrix.o lanczos.o partition.o wavefunction.o bridge_partitions.o bp_io.o bp_expc_val.o class_stopwatch.o bp_block.o block_lanczos.o -llapack -lblas -lm
gfortran -O3 -fopenmp -fallow-argument-mismatch -o count_dim.exe count_dim.f90 model_space.o interaction.o harmonic_oscillator.o constant.o rotation_group.o sp_matrix_element.o operator_jscheme.o operator_mscheme.o lib_matrix.o lanczos.o partition.o wavefunction.o bridge_partitions.o bp_io.o bp_expc_val.o class_stopwatch.o bp_block.o block_lanczos.o -llapack -lblas -lm
cp kshell.exe transit.exe count_dim.exe ../bin/
If the output of your terminal is like the expected terminal output listed above then KSHELL
is compiled correctly and is ready to use. See a section further down in this readme for instructions on how to run KSHELL
. If your terminal reports that the command gfortran
cannot be found then you need to correctly edit your ~/kshell/src/Makefile
with FC = <correct gfortran command>
. It might be gfortran
, gfortran-10
, gfortran-11
or something similar. To check, type the command directly into your terminal, hit enter, and see if your terminal can find the command:
gfortran
> gfortran: command not found
means that gfortran
is not a valid command. However:
gfortran-12
> gfortran-12: fatal error: no input files
> compilation terminated.
allthough fatal, means that the command gfortran-12
is a valid command. Edit the ~/kshell/src/Makefile
with FC = gfortran-12
in this case.
Another possible problem is that your terminal reports this:
ld: library not found for -llapack
collect2: error: ld returned 1 exit status
make: *** [kshell.exe] Error 1
This means that lapack
is either not installed or not in your LIBRARY_PATH
. brew install lapack
should solve this problem. Same for openblas
. When you now try to compile KSHELL
again, make sure to clean first:
make clean
make