Skip to content

Commit

Permalink
Merge pull request #6 from CosmoStat/devel_MK
Browse files Browse the repository at this point in the history
Devel mk
  • Loading branch information
martinkilbinger committed Apr 25, 2018
2 parents f7850e5 + 9221237 commit 25bbf3d
Show file tree
Hide file tree
Showing 36 changed files with 3,009 additions and 1,171 deletions.
179 changes: 104 additions & 75 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,81 +1,110 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 2.6)
include(FindPkgConfig)

# Adding customized cmake module
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")


project(nicaea)

#
# Loading dependencies
#
find_package(FFTW REQUIRED)
find_package(GSL 1.8 REQUIRED)

include_directories(${GSL_INCLUDE_DIRS} ${FFTW_INCLUDES})
link_directories(${GSL_LIBRARY_DIRS} ${FFTW_LIBRARY_DIRS})

#
# Compilation flags
#
set(CMAKE_C_FLAGS "-Wuninitialized -O3 -fPIC -std=gnu9x")

#
# Building nicaea library
#
#
include_directories(Cosmo/include Coyote/include halomodel/include tools/include)
FILE(GLOB src_cosmo "${PROJECT_SOURCE_DIR}/Cosmo/src/*.c")
FILE(GLOB src_halo "${PROJECT_SOURCE_DIR}/halomodel/src/*.c")
FILE(GLOB src_coyote "${PROJECT_SOURCE_DIR}/Coyote/src/*.c")
FILE(GLOB src_tools "${PROJECT_SOURCE_DIR}/tools/src/*.c")
add_library(nicaea STATIC ${src_cosmo} ${src_halo} ${src_coyote} ${src_tools})
target_link_libraries(nicaea ${GSL_LIBRARIES} ${FFTW_LIBRARIES} m)

#
# Compiling executables
#
#
add_executable(lensingdemo Demo/lensingdemo.c)
target_link_libraries(lensingdemo nicaea)

add_executable(cmb_bao_demo Demo/cmb_bao_demo.c)
target_link_libraries(cmb_bao_demo nicaea)

add_executable(cosebi_demo Demo/cosebi_demo.c)
target_link_libraries(cosebi_demo nicaea)

add_executable(decomp_eb_demo Demo/decomp_eb_demo.c)
target_link_libraries(decomp_eb_demo nicaea)

add_executable(halomodeldemo Demo/halomodeldemo.c)
target_link_libraries(halomodeldemo nicaea)

add_executable(sn1ademo Demo/sn1ademo.c)
target_link_libraries(sn1ademo nicaea)

add_executable(third_order_demo Demo/third_order_demo.c)
target_link_libraries(third_order_demo nicaea)


#
# Install (by default in the project directory)
#
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})

# Install nicaea library
INSTALL(TARGETS nicaea DESTINATION lib)

# Install nicaea headers
FILE(GLOB inc "${PROJECT_SOURCE_DIR}/tools/include/*.h" "${PROJECT_SOURCE_DIR}/Cosmo/include/*.h" "${PROJECT_SOURCE_DIR}/halomodel/include/*.h" "${PROJECT_SOURCE_DIR}/Coyote/include/*.h")
INSTALL(FILES ${inc} DESTINATION include/nicaea)

# install nicaea executables
INSTALL(TARGETS lensingdemo cmb_bao_demo decomp_eb_demo halomodeldemo sn1ademo cosebi_demo third_order_demo DESTINATION bin)

#
# Tests
#
enable_testing()
message("-- Creating test module lensingdemo")
add_test(NAME lensingdemo COMMAND ${CMAKE_INSTALL_PREFIX}/bin/lensingdemo WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/par_files)
add_test(NAME cmb_bao_demo COMMAND ${CMAKE_INSTALL_PREFIX}/bin/cmb_bao_demo WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/par_files)
cmake_policy(SET CMP0042 NEW)

#
# Loading dependencies
#
pkg_check_modules(PKGS REQUIRED fftw3 gsl)
include_directories(${PKGS_INCLUDE_DIRS})
link_directories(${PKGS_LIBRARY_DIRS})


#
# Compilation flags
#
set(CMAKE_C_FLAGS "-Wall -Wuninitialized -pedantic -O3 -fPIC -std=gnu9x")


#
# Building nicaea library
#
#
include_directories(Cosmo/include Coyote/include halomodel/include tools/include)
FILE(GLOB src_cosmo "${PROJECT_SOURCE_DIR}/Cosmo/src/*.c")
FILE(GLOB src_halo "${PROJECT_SOURCE_DIR}/halomodel/src/*.c")
FILE(GLOB src_coyote "${PROJECT_SOURCE_DIR}/Coyote/src/*.c")
FILE(GLOB src_tools "${PROJECT_SOURCE_DIR}/tools/src/*.c")
add_library(nicaea STATIC ${src_cosmo} ${src_halo} ${src_coyote} ${src_tools})
target_link_libraries(nicaea ${PKGS_LIBRARIES})

#
# Build python module
#
#
find_package(PythonLibsNew)
if (NOT PYTHON_LIBRARIES)
message("-- Python library not found, cannot install pynicaea")
endif()
find_package(Boost 1.45.0 COMPONENTS python)
if (NOT Boost_LIBRARIES)
message("-- Boost not found, cannot install pynicaea, continuing...")
endif()
if (PYTHON_LIBRARIES AND Boost_LIBRARIES)
message("-- Adding pynicaea to targets")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})

add_library(pynicaea SHARED python/bindings.cpp python/cosmo.cpp)
target_link_libraries(pynicaea nicaea ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
set_target_properties(pynicaea PROPERTIES PREFIX "")
set_target_properties(pynicaea PROPERTIES OUTPUT_NAME "nicaea")
endif()


#
# Compiling executables
#
#
add_executable(lensingdemo Demo/lensingdemo.c)
target_link_libraries(lensingdemo nicaea)

add_executable(cmb_bao_demo Demo/cmb_bao_demo.c)
target_link_libraries(cmb_bao_demo nicaea)

add_executable(cosebi_demo Demo/cosebi_demo.c)
target_link_libraries(cosebi_demo nicaea)

add_executable(decomp_eb_demo Demo/decomp_eb_demo.c)
target_link_libraries(decomp_eb_demo nicaea)

add_executable(halomodeldemo Demo/halomodeldemo.c)
target_link_libraries(halomodeldemo nicaea)

add_executable(sn1ademo Demo/sn1ademo.c)
target_link_libraries(sn1ademo nicaea)

add_executable(third_order_demo Demo/third_order_demo.c)
target_link_libraries(third_order_demo nicaea)


#
# Install (by default in the project directory)
#
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})

# Install nicaea library
INSTALL(TARGETS nicaea DESTINATION lib)

# Install nicaea headers
FILE(GLOB inc "${PROJECT_SOURCE_DIR}/tools/include/*.h" "${PROJECT_SOURCE_DIR}/Cosmo/include/*.h" "${PROJECT_SOURCE_DIR}/halomodel/include/*.h" "${PROJECT_SOURCE_DIR}/Coyote/include/*.h")
INSTALL(FILES ${inc} DESTINATION include/nicaea)

# install nicaea executables
INSTALL(TARGETS lensingdemo cmb_bao_demo decomp_eb_demo halomodeldemo sn1ademo cosebi_demo third_order_demo DESTINATION bin)

#
# Tests
#
enable_testing()
message("-- Creating test module lensingdemo")
add_test(NAME lensingdemo COMMAND ${CMAKE_INSTALL_PREFIX}/bin/lensingdemo WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/par_files)
add_test(NAME cmb_bao_demo COMMAND ${CMAKE_INSTALL_PREFIX}/bin/cmb_bao_demo WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/par_files)


10 changes: 0 additions & 10 deletions Cosmo/include/cmb_bao.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#ifndef __CMB_BAO_H
#define __CMB_BAO_H

#ifdef __cplusplus
extern "C" {
#endif


#include <stdio.h>
#include <stdlib.h>
Expand All @@ -22,9 +18,6 @@ extern "C" {
#include "maths.h"
#include "mvdens.h"

#ifdef __cplusplus
namespace nicaea {
#endif

double z_star(cosmo *self);
double acoustic_scale(cosmo *self, error **err);
Expand All @@ -38,8 +31,5 @@ double chi2_bao_A(cosmo *model, mvdens *g, const double *z_BAO, error **err);
double chi2_bao_d_z(cosmo *model, mvdens *g, const double *z_BAO, error **err);
double chi2_bao_D_V_ratio(cosmo *model, mvdens *g, const double *z_BAO, error **err);

#ifdef __cplusplus
}}
#endif

#endif
12 changes: 0 additions & 12 deletions Cosmo/include/decomp_eb.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#ifndef __DECOMP_EB_H
#define __DECOMP_EB_H

#ifdef __cplusplus
extern "C" {
#endif


#include <stdio.h>
#include <math.h>
Expand Down Expand Up @@ -39,11 +35,6 @@ extern "C" {
#define NMAX_COSEBI 20


#ifdef __cplusplus
namespace nicaea {
#endif


typedef enum {cheby, cheby2, legen, cosebi} poly_t;
#define spoly_t(i) ( \
i==cheby ? "cheby" : \
Expand Down Expand Up @@ -114,8 +105,5 @@ double sum_combinations(int j, int n, const double *r, error **err);
void xipmEB(double theta, double THETA_MIN, double THETA_MAX, const double *c,
const double *E, const double *B, int N, double xi_pm_EB[4], error **err);

#ifdef __cplusplus
}}
#endif

#endif
15 changes: 4 additions & 11 deletions Cosmo/include/lensing.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#ifndef __LENSING_H
#define __LENSING_H

#ifdef __cplusplus
extern "C" {
#endif

#include <math.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -40,10 +36,6 @@ extern "C" {
#include "reduced_fit.h"


#ifdef __cplusplus
namespace nicaea {
#endif

/* Dimensions of interpolation tables */
/* N_s was increased from 200 to 400, for linear tabulation of P_kappa */
#define N_s 400
Expand Down Expand Up @@ -332,6 +324,9 @@ cosmo_lens* set_cosmological_parameters_to_default_lens(error **err);
void free_parameters_lens(cosmo_lens** self);
void dump_param_lens(cosmo_lens* self, FILE *F, int wnofz, error **err);

void update_cosmo_lens_par_one(cosmo_lens **self, char spar[], double val, error **err);


/* ============================================================ *
* Lensing functions. *
* ============================================================ */
Expand Down Expand Up @@ -429,8 +424,6 @@ CHANGE(gamma2);
CHANGE(map2);
#undef CHANGE

#ifdef __cplusplus
}}
#endif

#endif /* __LENSING_H */

13 changes: 2 additions & 11 deletions Cosmo/include/lensing_3rd.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#ifndef __LENSING_3RD_H
#define __LENSING_3RD_H

#ifdef __cplusplus
extern "C" {
#endif

#include <math.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -51,10 +47,6 @@ extern "C" {
#define lensing_3rd_rootbracket -4 + lensing_3rd_base
#define lensing_3rd_slc -5 + lensing_3rd_base

#ifdef __cplusplus
namespace nicaea {
#endif

typedef enum {fgauss=0, fpoly=1, ftophat=2, fdelta=3, fxip=4, fxim=5, fall=6} filter_t;

typedef enum {PT=0, SCOCOU=1, GM12} bispmode_t;
Expand Down Expand Up @@ -229,8 +221,7 @@ void fill_dmm_map3gauss(cosmo_3rd *self, double *data_minus_model, int start, co
int Ntheta, double *theta, error **err);
double chi2_lensing_3rd(cosmo_3rd *self, datcov *dc, const cosebi_info_t *cosebi_info, error **err);

#ifdef __cplusplus
}}
#endif


#endif

12 changes: 0 additions & 12 deletions Cosmo/include/nofz.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#ifndef __NOFZ_H
#define __NOFZ_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
Expand Down Expand Up @@ -39,10 +35,6 @@ extern "C" {
* distribution formally goes to infinity. */
#define ZMAX 7

#ifdef __cplusplus
namespace nicaea {
#endif

/* Distribution types and functions */
typedef enum {ludo, jonben, ymmk, ymmk0const, cfhtlens, hist, single} nofz_t;
#define snofz_t(i) ( \
Expand Down Expand Up @@ -146,9 +138,5 @@ CHANGE(redshift);

int change_zmean(redshift_t *, redshift_t *, error **err);

#ifdef __cplusplus
}}
#endif


#endif
9 changes: 0 additions & 9 deletions Cosmo/include/reduced_fit.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef __REDUCED_FIT_H
#define __REDUCED_FIT_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
Expand All @@ -24,9 +21,6 @@ extern "C" {
#define N_B 4
#define N_C 4

#ifdef __cplusplus
namespace nicaea {
#endif

extern const double B_fit[M_PAR][N_PL][N_B];
extern const double C_fit[M_PAR][N_POLY][N_C];
Expand All @@ -52,8 +46,5 @@ double sum_a_for_Pg1(double logell, double a_min, int Na, double da, const doubl
const double dpar[M_PAR]);
int check_limits(const double dpar[M_PAR]);

#ifdef __cplusplus
}}
#endif

#endif

0 comments on commit 25bbf3d

Please sign in to comment.