Skip to content

Commit

Permalink
Merge pull request #295 from LSSTDESC/class_installation_script
Browse files Browse the repository at this point in the history
Automatic class installation
  • Loading branch information
damonge committed Dec 22, 2017
2 parents 587d187 + 895e035 commit 97ea02f
Show file tree
Hide file tree
Showing 68 changed files with 553 additions and 53,181 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ python:

# Travis uses Ubuntu 12.04 and 14.04. None of them have GSL2x in apt-get
# We have to install it from source (this will make the tests slower)
# CLASS also needs to be downloaded and compiled, which there is no easy fix for.
before_install:
- sudo apt-get -qq update
- sudo apt-get install fftw3 fftw3-dev pkg-config
# - sudo apt-get install latexmk
- pip install numpy
- ./install-gsl.sh
- python class_install.py
#addons:
# apt:
# packages:
Expand Down
15 changes: 12 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

if LOCALCLASS
SUBDIRS = include class
SUBDIRS = include
else
SUBDIRS = include
endif
Expand All @@ -13,9 +13,18 @@ ccl_DATA = include/ccl_params.ini
lib_LTLIBRARIES = libccl.la
libccl_la_SOURCES = src/ccl_background.c src/ccl_core.c src/ccl_error.c src/ccl_lsst_specs.c src/ccl_placeholder.c src/ccl_power.c src/ccl_utils.c src/ccl_cls.c src/ccl_massfunc.c src/ccl_neutrinos.c src/ccl_correlation.c src/fftlog.c
if LOCALCLASS
libccl_la_LIBADD = class/libclass.la

libccl_la_LIBADD = class/libclass.a
libccl_la_CPPFLAGS = -I./include/ -I./class/include -D__CCL_DATA_DIR__=$(datadir)/ccl

else

libccl_la_CPPFLAGS = -I./include/ -I$(CLASSDIR)/include -D__CCL_DATA_DIR__=$(datadir)/ccl

endif
libccl_la_CPPFLAGS = -I./include/ -I$(CLASSDIR)/include -D__CCL_DATA_DIR__=$(datadir)/ccl




noinst_PROGRAMS = tests/check_ccl
TESTS = tests/check_ccl tests/check_swig_timestamp.sh
Expand Down
11 changes: 6 additions & 5 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ am__uninstall_files_from_dir = { \
}
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(ccldir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
@LOCALCLASS_TRUE@libccl_la_DEPENDENCIES = class/libclass.la
@LOCALCLASS_TRUE@libccl_la_DEPENDENCIES = class/libclass.a
am__dirstamp = $(am__leading_dot)dirstamp
am_libccl_la_OBJECTS = src/libccl_la-ccl_background.lo \
src/libccl_la-ccl_core.lo src/libccl_la-ccl_error.lo \
Expand Down Expand Up @@ -270,7 +270,7 @@ am__tty_colors = { \
std=''; \
fi; \
}
DIST_SUBDIRS = include class
DIST_SUBDIRS = include
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in ar-lib \
compile config.guess config.sub depcomp install-sh ltmain.sh \
missing
Expand Down Expand Up @@ -436,14 +436,15 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@LOCALCLASS_FALSE@SUBDIRS = include
@LOCALCLASS_TRUE@SUBDIRS = include class
@LOCALCLASS_TRUE@SUBDIRS = include
EXTRA_DIST = doc sandbox README.md tests/benchmark tests/ccl_example_photoz.c tests/ccl_example_specs.c tests/ccl_sample_power.c tests/ctest.h tests/min_code.c tests/readme.md include/ccl_params.ini tests/ccl_test_neutrinos.c
ccldir = $(datadir)/ccl
ccl_DATA = include/ccl_params.ini
lib_LTLIBRARIES = libccl.la
libccl_la_SOURCES = src/ccl_background.c src/ccl_core.c src/ccl_error.c src/ccl_lsst_specs.c src/ccl_placeholder.c src/ccl_power.c src/ccl_utils.c src/ccl_cls.c src/ccl_massfunc.c src/ccl_neutrinos.c src/ccl_correlation.c src/fftlog.c
@LOCALCLASS_TRUE@libccl_la_LIBADD = class/libclass.la
libccl_la_CPPFLAGS = -I./include/ -I$(CLASSDIR)/include -D__CCL_DATA_DIR__=$(datadir)/ccl
@LOCALCLASS_TRUE@libccl_la_LIBADD = class/libclass.a
@LOCALCLASS_FALSE@libccl_la_CPPFLAGS = -I./include/ -I$(CLASSDIR)/include -D__CCL_DATA_DIR__=$(datadir)/ccl
@LOCALCLASS_TRUE@libccl_la_CPPFLAGS = -I./include/ -I./class/include -D__CCL_DATA_DIR__=$(datadir)/ccl
tests_check_ccl_SOURCES = tests/ccl_test.c tests/ccl_test_utils.c tests/ccl_test_params.c tests/ccl_test_cosmology.c tests/ccl_test_distances.c tests/ccl_test_growth.c tests/ccl_test_bbks.c tests/ccl_test_eh.c tests/ccl_test_cls.c tests/ccl_test_cmblens.c tests/ccl_test_sigmaM.c tests/ccl_test_massfunc.c tests/ccl_test_correlation.c tests/ccl_test_bcm.c
tests_check_ccl_CPPFLAGS = -I./tests/ -I./include/
tests_check_ccl_LDFLAGS = -L./ -lccl -lgsl -lgslcblas -lfftw3 $(CLASS_LIB)
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ In order to compile `CCL` you need a few libraries:
* The [SWIG](http://www.swig.org/) Python wrapper generator is not needed to run `CCL`, but must be installed if you intend to modify `CCL` in any way.
* [FFTW3](http://www.fftw.org/) is required for computation of correlation functions.
* FFTlog([here](http://casa.colorado.edu/~ajsh/FFTLog/) and [here](https://github.com/slosar/FFTLog))is provided within `CCL`, with minor modifications.
* The C library associated to the CLASS code. The installation of this library is described below.

## Installing CLASS
CCL uses CLASS as one of the possible ways of computing the matter power spectrum. In order to communicate with CLASS, CCL must be linked to its library. Before installing CCL proper you must therefore install this library first. Since this process is not necessarily straightforward, we provide a python script `class_install.py` that automatically downloads and install the latest tagged stable version of CLASS. You should run this script (`python class_install.py`) before carrying out the next steps. By default, the script assumes that your main C compiler is `gcc`. If that's not the case, pass the name of your C compiler to the script via the command-line argument `--c_comp` (i.e. `python class_install.py --c_comp=[name of compiler]`). Type `python class_install.py -h` for further details.

This procedure has one final caveat: if you already have a working installation of CCL, `class_install.py` may fail the first time you run it. This can be fixed by either simply running `class_install.py` a second time, or by starting from scratch (i.e. downloading or cloning CCL).

Note that, if you want to use your own version of CLASS, you should follow the steps described in the section "Compiling against an external version of CLASS" below.

## C-only installation
`CCL` can be easily installed using an *autotools*-generated configuration file. To install `CCL`, from the base directory (the one where this file is located) run:
Once the CLASS library is installed, `CCL` can be easily installed using an *autotools*-generated configuration file. To install `CCL`, from the base directory (the one where this file is located) run:
```sh
./configure
make
Expand Down Expand Up @@ -127,7 +135,7 @@ gcc -shared -o libclass.so -Wl,--whole-archive libclass.a \
-Wl,--no-whole-archive -lgomp
````
This should create a new shared library, ***libclass.so***, in the same directory. (N.B. The `-lgomp` flag has to appear at the end of the command; otherwise the linker can fail.) If you are running Mac OS X, use the following command instead:
````sh
````sh
gcc -fpic -shared -o libclass.dylib -Wl,-all\_load libclass.a -Wl,-noall\_load
````

Expand Down
2 changes: 1 addition & 1 deletion ar-lib
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
me=ar-lib
scriptversion=2012-03-01.08; # UTC

# Copyright (C) 2010-2013 Free Software Foundation, Inc.
# Copyright (C) 2010-2014 Free Software Foundation, Inc.
# Written by Peter Rosin <peda@lysator.liu.se>.
#
# This program is free software; you can redistribute it and/or modify
Expand Down
6 changes: 0 additions & 6 deletions class/Makefile.am

This file was deleted.

0 comments on commit 97ea02f

Please sign in to comment.