Skip to content

Commit

Permalink
Merge pull request #23 from martinkilbinger/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
martinkilbinger committed Apr 6, 2020
2 parents 9743328 + 2576d54 commit 3aee1d6
Show file tree
Hide file tree
Showing 13 changed files with 480 additions and 385 deletions.
108 changes: 73 additions & 35 deletions CMakeLists.txt
@@ -1,82 +1,120 @@
project(nicaea)

### Set-up
cmake_minimum_required(VERSION 2.6)

# General

cmake_minimum_required(VERSION 2.6)
project(nicaea)

cmake_policy(SET CMP0042 NEW)

#
# Loading dependencies
#

# Use conda path
IF(DEFINED $ENV{CONDA_PREFIX})
message("-- Using CONDA_PREFIX=${CONDA_PREFIX} for libraries")
include_directories(${CMAKE_INSTALL_PREFIX}/include)
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
else()
message("-- Looking for external libraries...")

include(FindPkgConfig)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
pkg_check_modules(PKGS REQUIRED fftw3 gsl)
include_directories(${PKGS_INCLUDE_DIRS})
link_directories(${PKGS_LIBRARY_DIRS})
endif()

include_directories(${CMAKE_INSTALL_PREFIX}/include)
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
set(LIBS ${LIBS} gsl gslcblas)
set(LIBS ${LIBS} fftw3 m)
set(LIBS ${LIBS} fftw3 m)


#
# Compilation flags

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


### Compilation

# Building the nicaea library

#
# 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})
#add_library(nicaea STATIC ${src_cosmo} ${src_halo} ${src_coyote} ${src_tools})
add_library(nicaea ${src_cosmo} ${src_halo} ${src_coyote} ${src_tools})
#target_link_libraries(nicaea ${PKGS_LIBRARIES})
target_link_libraries(nicaea ${LIBS})


#
# Build python module (optional)
#
#
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)
#target_link_libraries(lensingdemo nicaea ${PKGS_LIBRARIES})
target_link_libraries(lensingdemo nicaea ${LIBS})

add_executable(cmb_bao_demo Demo/cmb_bao_demo.c)
target_link_libraries(cmb_bao_demo nicaea)
target_link_libraries(cmb_bao_demo nicaea ${LIBS})

add_executable(cosebi_demo Demo/cosebi_demo.c)
target_link_libraries(cosebi_demo nicaea)
target_link_libraries(cosebi_demo nicaea ${LIBS})

add_executable(decomp_eb_demo Demo/decomp_eb_demo.c)
target_link_libraries(decomp_eb_demo nicaea)
target_link_libraries(decomp_eb_demo nicaea ${LIBS})

add_executable(halomodeldemo Demo/halomodeldemo.c)
target_link_libraries(halomodeldemo nicaea)
target_link_libraries(halomodeldemo nicaea ${LIBS})

add_executable(sn1ademo Demo/sn1ademo.c)
target_link_libraries(sn1ademo nicaea)
target_link_libraries(sn1ademo nicaea ${LIBS})

add_executable(third_order_demo Demo/third_order_demo.c)
target_link_libraries(third_order_demo nicaea)
target_link_libraries(third_order_demo nicaea ${LIBS})

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

### Installation (by default in the project directory)

# MKDEBUG: Testing on travis
set(CMAKE_INSTALL_PREFIX ".")
target_link_libraries(getHODModel nicaea ${LIBS})

# Install the nicaea library
# 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 nicaea executables
INSTALL(TARGETS lensingdemo cmb_bao_demo decomp_eb_demo halomodeldemo sn1ademo cosebi_demo third_order_demo DESTINATION bin)

### Testing

#
# 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)
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)


118 changes: 0 additions & 118 deletions CMakeLists.txt-nonconda

This file was deleted.

10 changes: 7 additions & 3 deletions Cosmo/include/cosmo.h
Expand Up @@ -264,6 +264,7 @@ double f_de(cosmo*, double a, error **err);
double Esqr(cosmo*, double a, int wOmegar, error **err);
double Omega_m_a(cosmo*,double a, double Esqrpre, error **err);
double Omega_de_a(cosmo*,double a, double Esqrpre, error **err);
double Omega_nu_a(cosmo*,double a, double Esqrpre, error **err);
void Omega_a(cosmo*,double a, double *omega_m, double *omega_v);
double w_nu_mass(cosmo *self, double a);

Expand Down Expand Up @@ -295,9 +296,11 @@ double k_silk(const cosmo *model);
double ratio_b_gamma(cosmo *self, double a);
double z_drag(cosmo *self);
double G_EH98(double y);
double Bpf(double fff);
double growthk0(cosmo* self, double a);
double T_tilde(const cosmo *self, double k, double alpha_c, double beta_c);
double Tsqr_one(cosmo*,double k,double Gamma_eff,error **err);
double Tsqr(cosmo*,double k,error **err);
double Tsqr_one(cosmo *self, double k, double a, double Gamma_eff, error **err);
double Tsqr(cosmo* self, double a, double k, error **err);

/* Linear power spectrum */
double W_tophat(double x);
Expand All @@ -323,7 +326,8 @@ void wint2(cosmo*,double r,double *sig,double *d1,double *d2, double a, int only
error **err, double precision);
double slope_NL(double rn, double rncur, double om_m, double om_v);
void halofit(double rk, double rn, double rncur, double rknl, double plin,
double om_m, double om_v, double *pnl, nonlinear_t nonlinear, double aa, cosmo *self, error **err);
double om_m, double om_v, double om_nu, double *pnl, nonlinear_t nonlinear,
double aa, cosmo *self, error **err);
double dlog(double x);
double P_NL(cosmo *self, double a, double k, error **err);
double P_NL_fitting(cosmo*, double a, double k, error **err);
Expand Down
1 change: 0 additions & 1 deletion Cosmo/include/lensing.h
Expand Up @@ -326,7 +326,6 @@ 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

0 comments on commit 3aee1d6

Please sign in to comment.