Skip to content

Commit

Permalink
Merge pull request #331 from LSSTDESC/move_examples
Browse files Browse the repository at this point in the history
Move example code/scripts to a separate directory
  • Loading branch information
philbull committed Feb 16, 2018
2 parents c58d0ad + 6d936be commit c45faad
Show file tree
Hide file tree
Showing 27 changed files with 2,956 additions and 629 deletions.
10 changes: 5 additions & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ else
SUBDIRS = include
endif

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
EXTRA_DIST = doc sandbox README.md tests/benchmark tests/ctest.h tests/readme.md include/ccl_params.ini tests/ccl_test_neutrinos.c examples/ccl_sample_baryons.c examples/ccl_sample_neutrinos.c examples/ccl_sample_photoz.c examples/ccl_sample_pkemu.c examples/ccl_sample_power.c examples/ccl_sample_run.c

ccldir = $(datadir)/ccl
ccl_DATA = include/ccl_params.ini
Expand Down Expand Up @@ -37,7 +37,7 @@ dist-hook:
rm -f $(distdir)/clean_code.sh

check-cpp:
echo '#include "ccl_sample_run.c"' > tests/ccl_sample_run.cpp
$(CXX) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -std=c++11 $(AM_CFLAGS) $(CFLAGS) -I$(includedir) $(LDFLAGS) tests/ccl_sample_run.cpp -o tests/ccl_sample_run -L$(libdir) -lccl $(LIBS)
echo '#include "ccl_sample_pkemu.c"' > tests/ccl_sample_pkemu.cpp
$(CXX) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -std=c++11 $(AM_CFLAGS) $(CFLAGS) -I$(includedir) $(LDFLAGS) tests/ccl_sample_pkemu.cpp -o tests/ccl_sample_pkemu -L$(libdir) -lccl $(LIBS)
echo '#include "ccl_sample_run.c"' > examples/ccl_sample_run.cpp
$(CXX) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -std=c++11 $(AM_CFLAGS) $(CFLAGS) -I$(includedir) $(LDFLAGS) examples/ccl_sample_run.cpp -o examples/ccl_sample_run -L$(libdir) -lccl $(LIBS)
echo '#include "ccl_sample_pkemu.c"' > examples/ccl_sample_pkemu.cpp
$(CXX) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -std=c++11 $(AM_CFLAGS) $(CFLAGS) -I$(includedir) $(LDFLAGS) examples/ccl_sample_pkemu.cpp -o examples/ccl_sample_pkemu -L$(libdir) -lccl $(LIBS)
23 changes: 12 additions & 11 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# Copyright (C) 1994-2014 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
Expand Down Expand Up @@ -431,6 +431,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
Expand All @@ -441,7 +442,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@LOCALCLASS_FALSE@SUBDIRS = include
@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
EXTRA_DIST = doc sandbox README.md tests/benchmark tests/ctest.h tests/readme.md include/ccl_params.ini tests/ccl_test_neutrinos.c examples/ccl_sample_baryons.c examples/ccl_sample_neutrinos.c examples/ccl_sample_photoz.c examples/ccl_sample_pkemu.c examples/ccl_sample_power.c examples/ccl_sample_run.c
ccldir = $(datadir)/ccl
ccl_DATA = include/ccl_params.ini
lib_LTLIBRARIES = libccl.la
Expand Down Expand Up @@ -1338,7 +1339,7 @@ distdir: $(DISTFILES)
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir)

dist-bzip2: distdir
Expand All @@ -1364,7 +1365,7 @@ dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)

dist-zip: distdir
Expand All @@ -1382,7 +1383,7 @@ dist dist-all:
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
Expand All @@ -1392,7 +1393,7 @@ distcheck: dist
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
Expand Down Expand Up @@ -1607,10 +1608,10 @@ dist-hook:
rm -f $(distdir)/clean_code.sh

check-cpp:
echo '#include "ccl_sample_run.c"' > tests/ccl_sample_run.cpp
$(CXX) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -std=c++11 $(AM_CFLAGS) $(CFLAGS) -I$(includedir) $(LDFLAGS) tests/ccl_sample_run.cpp -o tests/ccl_sample_run -L$(libdir) -lccl $(LIBS)
echo '#include "ccl_sample_pkemu.c"' > tests/ccl_sample_pkemu.cpp
$(CXX) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -std=c++11 $(AM_CFLAGS) $(CFLAGS) -I$(includedir) $(LDFLAGS) tests/ccl_sample_pkemu.cpp -o tests/ccl_sample_pkemu -L$(libdir) -lccl $(LIBS)
echo '#include "ccl_sample_run.c"' > examples/ccl_sample_run.cpp
$(CXX) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -std=c++11 $(AM_CFLAGS) $(CFLAGS) -I$(includedir) $(LDFLAGS) examples/ccl_sample_run.cpp -o examples/ccl_sample_run -L$(libdir) -lccl $(LIBS)
echo '#include "ccl_sample_pkemu.c"' > examples/ccl_sample_pkemu.cpp
$(CXX) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -std=c++11 $(AM_CFLAGS) $(CFLAGS) -I$(includedir) $(LDFLAGS) examples/ccl_sample_pkemu.cpp -o examples/ccl_sample_pkemu -L$(libdir) -lccl $(LIBS)

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ make install
`CCL` library can be called from C++ code without any additional requirements or modifications. To make sure that there are no problems you can run
````sh
make check-cpp
./tests/ccl_sample_run
./examples/ccl_sample_run
````

## Python installation
Expand Down Expand Up @@ -176,7 +176,7 @@ This Dockerfile currently contains all installed C libraries and the Python wrap
`CCL` has basic [doxygen](http://www.stack.nl/~dimitri/doxygen/) documentation for its C routines. This can be found in the directory ***doc/html*** within the `CCL` repository by opening the ***index.html*** file in your browser. The python routines are documented in situ; you can view the documentation for a function by calling `help(function name)` from within `python`.
This document contains basic information about used structures and functions. At the end of document is provided code which implements these basic functions (also in ***tests/ccl_sample_run.c***). More information about `CCL` functions and implementation can be found in ***doc/0000-ccl_note/0000-ccl_note.pdf***.
This document contains basic information about used structures and functions. At the end of document is provided code which implements these basic functions (also in ***examples/ccl_sample_run.c***). More information about `CCL` functions and implementation can be found in ***doc/0000-ccl_note/0000-ccl_note.pdf***.
### Cosmological parameters
Start by defining cosmological parameters defined in structure **`ccl_parameters`**. This structure (exact definition in ***include/ccl_core.h***) contains densities of matter, parameters of dark energy (`w0`, `wa`), Hubble parameters, primordial power spectra, radiation parameters, derived parameters (`sigma_8`, `Omega_1`, `z_star`) and modified growth rate.
Expand Down Expand Up @@ -336,10 +336,10 @@ void ccl_specs_free_photoz_info(user_pz_info *my_photoz_info);
````

## Example code
This code can also be found in ***tests/ccl_sample_run.c*** You can run the following example code. For this you will need to compile with the following command:
This code can also be found in ***examples/ccl_sample_run.c*** You can run the following example code. For this you will need to compile with the following command:
````sh
gcc -Wall -Wpedantic -g -I/path/to/install/include -std=gnu99 -fPIC tests/ccl_sample_run.c \
-o tests/ccl_sample_run -L/path/to/install/lib -L/usr/local/lib -lgsl -lgslcblas -lm -lccl
gcc -Wall -Wpedantic -g -I/path/to/install/include -std=gnu99 -fPIC examples/ccl_sample_run.c \
-o examples/ccl_sample_run -L/path/to/install/lib -L/usr/local/lib -lgsl -lgslcblas -lm -lccl
````
where `/path/to/install/` is the path to the location where the library has been installed.

Expand Down

0 comments on commit c45faad

Please sign in to comment.