Step by Step Guide for Mac OS X

This is a step-by-step guide for a new Installation of ProDiMo on a fresh installation of Mac OS X Catalina. We will use MacPorts, the new command line zsh of Mac OS X Catalina and the gfortran compiler.

Update 26.11.2023: This guide also works for Mac OS X Sonoma, Ventura and Monterey. We recommend using the gcc12 port, but gcc13 should also work.

Xcode Command Line Tools

After an OS update to a new version, one needs to also install the Xcode command line tools.

 xcode-select --install

to have make available. Please note that it is not required to install the full Xcode package from the App Store.

Compiler and Libraries

Mac OS X does not come with a Fortran compiler, so we need to install one. The easiest way to do this is to use a packaging system such as MacPorts or homebrew.

Here, we use MacPorts (see Installation), but other Mac OS X package managers should work as well.

If you already have a gfortran compiler (version >=11), you can skip this step.

Gfortran compiler

We use here the gfortran compiler (included in the Gnu compiler collection: https://gcc.gnu.org) because it is easy to get and free. You can install it with Macports in a terminal.

sudo port install gcc12

This installs Version 12 of gfortran (also newer version should work fine). The executable for the compiler is then located in /opt/local/bin/gfortran-mp-12. You can make an alias or a symbolic link to gfortran to make things easier (/opt/local/bin/ should already be added to the PATH by MacPorts).

Note that ifort for Mac OS X is not supported any-more by Intel. Therefore compiling ProDiMo on a Mac machine with ifort is not recommended.

With homebrew the installation process works very similar, e.g.

brew install gcc

Additional libraries

ProDiMo requires the cfitsio library. This can also be installed via Macports (we install it for gcc12). For cfitiso the latest release should be fine.

sudo port install cfitsio +gcc12

If it cannot be found or you would like to get the most recent version, Homebrew provides also the cfitsio binary

brew install cfitsio

Another library is xraylib. This one is optional and only required if you want to use X-ray radiative transfer (you can skip it if you are unsure). It can also be installed via homebrew, e.g.

brew install xraylib

But check out the link to xraylib for more detailed installation instructions.

Git

To get access to the source code of ProDiMo, the version control software git is required. This should be included in your MAC OS X installation; just type

git 

in your command line to check if it's there. If not one can install it view macports or homebrew.

Getting the source code

So, finally, we can download the code. This is done via git. You should already have a user and a password for the repository (otherwise, you should not see those pages). First, change into a directory where you want to install ProDiMo. Then clone the git repository:

git clone https://YOURUSERNAME@gitlab.astro.rug.nl/prodimo/prodimo.git

This will download the source code into the directory WORKINGDIR/prodimo, which we call pdir further on. This can take a bit as the source code repository is quite big (about a GB). If you want to install ProDiMo in a different directory, see Checkout_the_Code.

Compiling the Code

Now we can compile the code. The source code files are located in the directory pdir/src_develop. Within this directory, you find a file makefile.gfortran. This is a template for a makefile which you should copy before you edit it:

cp makefile.gfortran makefile

Look at the makefile and adapt the paths for the libraries and possibly the path to your gfortran compiler (F90 and FLINK), if required (these are the first three blocks in the file). If you used macports (homebrew) to install cfitsio the path to the library is likely /opt/local/lib (usr/local/lib). To know the path to gfortran, simply type in the terminal

which gfortran

To be sure of the path to your libraries when using Homebrew, use the command

$(brew --prefix)/lib

The path should be like

-bash: /usr/local/lib: is a directory

One can check the corresponding path in the Makefile

#----------------------------------------------------------
# location of cfitsio-library
# Adapt the path if necessary
FITS = -L/usr/local/lib -lcfitsio

Now you can compile ProDiMo. Within the pdir/src_develop directory, simply type.

make

If this is successful, there should be an executable file called prodimo in the pdir/src_develop directory. The makefile will compile the code with OpenMP support, so that you can run ProDiMo in parallel on multi-core machines. If you do not want this, you can remove the -fopenmp entries in the makefile.

To test the compilation, you can simply type ./prodimo. This should show you some output and an error message saying no input files are found. This means the compilation looks fine.

Running a ProDiMo model

Environment settings

Before you can run a proper ProDiMo model some entries in your shell profile are required. Here we edit the file ~/.zprofile (in the case of the bash shell, it is ~/.bash_profile). We add the lines:

######################################################################
# for ProDiMo

export PRODIMO_PATH=$HOME/pdir

# Add ProDiMo to the path so that it can be called from everywhere.
export PATH="$PATH:path_to_ProDiMo/src_develop/"

# set some parameters for the stacksize, so that ProDiMo will not crash
# the numbers are different to linux, but that worked for me
export GOMP_STACKSIZE=65000
ulimit -s 65000

if you run the code in parallel (OpenMP), you can control the number of threads used via the environment variable

export OMP_NUM_THREADS=12

Where 12 is the number of threads that you can allocate to run models. The number of possible threads depends on your machine/cpu (i.e. if it is a multi-core machine and/or if it supports multi-threading).

After you have done this and started a new shell, you should be able to run ProDiMo from any directory.

Now you can continue with the Beginner's Guide to learn how to run your first ProDiMo model.