Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
190 lines (117 sloc) 5.86 KB

Installation

Obtaining PyCLES

The simplest way to obtain the PyCLES source code is to clone it from GitHub:

$ git clone https://github.com/pressel/pycles.git

Alternatively, we recommend forking the code directly from GitHub if you anticipate contributing to PyCLES. To fork the repository, first create a GitHub account. Then visit the PyCLES Github Page and click the Fork button that appears on the upper right side of the page. Once you have forked PyCLES, clone your fork.

Building PyCLES

PyCLES depends on several Python packages:

  1. numpy (tested with 1.9.1)
  2. scipy (tested with 0.16.0)
  3. matplotlib (tested with 1.4.3)
  4. Cython (tested with 0.23.1)
  5. mpi4py (tested with 1.3.1)
  6. netCDF4 (tested with 1.1.9)

Instructions for installation of these packages on Mac and Linux systems are given below.

Building on a Mac

PyCLES is developed on Macs, so installation on Mac systems is very straight forward.

Perhaps the simplest way to install PyCLES on a Mac is to use MacPorts_. Alternatively one could use Homebrew_, see below for further details. .. _MacPorts: https://www.macports.org/ .. _Homebrew: http://brew.sh/

MacPorts_ makes the installation straight forward. We recommend using a version of Python installed using MacPorts. PyCLES has been written to support both Python 2.7 and Python 3.x. In this documentation we will specifically describe installation using Python 2.7, but installation using Python 3.x follows a similar progression. To install Python 2.7 using Macports run:

$ [sudo] port install python27

Install NumPy:

$ [sudo] port install py27-numpy

Install SciPy:

$ [sudo] port install py27-scipy

Install mpi4py:

$ [sudo] port install py27-mpi4py

Install Cython:

$ [sudo] port install py27-cython

Install netCDF4:

$[sudo] port install py27-netcdf4

The above sequence of steps installs python to /opt/local/bin as python2.7, to make this version of python runnable as python install python_select:

$[sudo] port install python_select

and then select python2.7 using:

$[sudo] port select --set python python27

Once all dependencies have been installed, move to the directory created when you cloned the PyCLES Github repository. This probably requires something like:

$cd pycles

Once in the pycles directory run:

$ python generate_parameters.py

to generate parameters.pxi and ./Csrc/paramters.h. The source code can then be compiled by running setup.py

$ CC=mpicc python setup.py build_ext --inplace

Note

In the above command, mpicc should be replaced by the name of your MPI C compiler.

Building on Mac with Homebrew

Install the necessary Homebrew libraries:

$ brew install netcdf open-mpi

Create a new virtualenv that will contain all the necessary python libraries, without interfering with any that you may have previously installed. I like to put this inside the pycles source folder, but you can put it whereever you wish.

If virtualenv is not yet installed:

$ [sudo] pip install virtualenv

Then create and activate the environment:

$ cd pycles
$ virtualenv pyclesenv
$ source pyclesenv/bin/activate

Now we can install all the Python libraries:

(pyclesenv) $ pip install cython numpy scipy mpi4py

And proceed to build the extensions as above:

(pyclesenv) $ python generate_parameters.py
(pyclesenv) $ CC=mpicc python setup.py build_ext --inplace

Building on Linux

Building PyCLES on Linux systems involves installing the requires Python modules and their individual dependencies. The python packages required by PyCLES are fairly standard and are likely pre-installed on most HPC systems. If the required packages are not install we recommend consulting your system administrator to have them installed for you.

To install them on a non-HPC system we recommend using the package manager of your choice.

Note

At ETH we have found it very useful on HPC systems to use a Python Virtual Environment to locally manage a Python environment without having administrator privileges.

Once all dependencies have been installed, move to the directory created when you cloned the PyCLES Github repository. This probably requires something like:

$cd pycles

Once in the pycles directory run:

$ python generate_parameters.py

to generate parameters.pxi and ./Csrc/paramters.h. The source code can then be compiled by running setup.py

Compile PyCLES:

$ CC=mpicc python setup.py build_ext --inplace

Note

In the above command, mpicc should be replaced by the name of your MPI C compiler.

Note

If compilation fails with a KeyError, check the flags used in the setup.py to make sure they match the flags in your machine.

Site Specific Builds

Euler @ ETH Zurich

PyCLES has been extensively tested and run on Euler using a Python Virtual Environment that has all of PyCLES's dependencies pre-installed. To use the Python virtual environment add the following lines to your .bashrc file:

module load new
module load open_mpi
module load python/2.7.6
module load netcdf
module load hdf5/1.8.12

export PATH=/cluster/home/presselk/local2/bin:$PATH

From inside the PyCLES directory, parameters.pxi and ./Csrc/parameters.h can be generated by running:

$ python generate_parameters.py

Finally, PyCLES can be compiled by running:

$CC=mpicc python setup.py build_ext --inplace
You can’t perform that action at this time.