Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules)

option("NOPLOT" "Disable matplotlib C++ code at compiling time." OFF)


if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
string(CONCAT CMAKE_Fortran_FLAGS
"-g -O3"
Expand Down Expand Up @@ -55,6 +58,10 @@ else()
add_compile_definitions(ENABLE_PLT)
endif()

if(NOPLOT)
add_compile_definitions(NOPLOT)
endif()

###

# Add the new C++ source file
Expand Down Expand Up @@ -128,11 +135,9 @@ add_compile_definitions(VERSION="${PROJECT_VERSION}")
add_compile_definitions(ESTER_DATADIR="${CMAKE_INSTALL_PREFIX}/share")
add_compile_definitions(PACKAGE_VERSION="${PROJECT_VERSION}")

#add_library(ester SHARED # was previous
#add_library(ester STATIC
add_library(ester SHARED

set(ESTER_CPP_FILES
src/global/global.cpp
src/graphics/matplotlib.cpp
src/solver/RKF_solver.cpp
src/main/read_config.cpp
src/solver/SDIRK_solver.cpp
Expand Down Expand Up @@ -190,16 +195,31 @@ add_library(ester SHARED
src/physics/opa_opmesa.cpp
src/physics/mesa_opacity_modules.F90
src/physics/cubic_interpolator.f90
src/physics/read_hdf5_data.cpp)
#src/physics/opa_mesa_wrapper.cpp) # blocked for fixing other issues

src/physics/read_hdf5_data.cpp
#src/physics/opa_mesa_wrapper.cpp # blocked for fixing other issues
)

if(NOT NOPLOT)
list(PREPEND ESTER_CPP_FILES src/graphics/matplotlib.cpp)
# NOTE: only used for matplotlib
list(APPEND OPTIONAL_LIBS ${PYTHON_LIBRARIES})
endif()

#add_library(ester SHARED # was previous
#add_library(ester STATIC
add_library(ester SHARED
${ESTER_CPP_FILES}
)

# Link libmesac libraries using --whole-archive to include all symbols
#set(LIBMESAC_LIBS "-Wl,--whole-archive $ENV{LIBMESAC_ROOT}/lib/libkapcmesa.a $ENV{LIBMESAC_ROOT}/lib/libchemcmesa.a $ENV{LIBMESAC_ROOT}/lib/libutilscmesa.a -#Wl,--no-whole-archive ${SDK_LIBS}") # test lines 2 --> needed?


message(LIBMESAC_LIBS="${LIBMESAC_LIBS}")
target_link_libraries(ester cesam freeeos opint
${OPTIONAL_LIBS} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${CBLAS_LIBRARIES} ${PYTHON_LIBRARIES} ${HDF5_LIBRARIES} ${LIBMESAC_LIBS})
${OPTIONAL_LIBS} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${CBLAS_LIBRARIES} ${HDF5_LIBRARIES} ${LIBMESAC_LIBS})



# Set properties for ester
#set_target_properties(ester PROPERTIES
Expand Down
3 changes: 3 additions & 0 deletions src/graphics/matplotlib.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#ifndef WITH_CMAKE
#include "ester-config.h"
#endif
#ifndef NOPLOT
#include "matplotlib.h"
#endif


#if ENABLE_PLT

Expand Down
3 changes: 3 additions & 0 deletions src/main/polytrope1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#include "ester-config.h"
#endif
#include "utils.h"
#ifndef NOPLOT
#include "matplotlib.h"
#endif

#include "star.h"
#include "read_config.h"

Expand Down
13 changes: 12 additions & 1 deletion src/main/read_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
#include "utils.h"
#include "parser.h"
#include "read_config.h"
#ifndef NOPLOT
#include "matplotlib.h"
#endif



configuration::configuration(int argc,char *argv[]) {

Expand Down Expand Up @@ -54,8 +58,11 @@ configuration::configuration(int argc,char *argv[]) {
}
cmd.close();


#ifndef NOPLOT
if (noplot == false)
plt::init();
plt::init();
#endif
}

int configuration::check_arg(const char *arg,const char *val) {
Expand Down Expand Up @@ -100,8 +107,12 @@ int configuration::check_arg(const char *arg,const char *val) {
}
else if(!strcmp(arg,"noplot")) {
strcpy(plot_device,"/NULL");
#ifndef NOPLOT
noplot = true;
plt::init(true);
#else
ester_warn("matplotlib has been disabled at building time.");
#endif
}
else if(!strcmp(arg,"maxit")) {
if(val==NULL) return 2;
Expand Down
8 changes: 8 additions & 0 deletions src/main/star1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#include "ester-config.h"
#endif
#include "utils.h"
#ifndef NOPLOT
#include "matplotlib.h"
#endif

#include "star.h"
#include "read_config.h"

Expand Down Expand Up @@ -92,12 +95,15 @@ int main(int argc,char *argv[]) {

int last_plot_it = -100;


#ifndef NOPLOT
if (config.noplot == false) {
plt::init();
plt::figure(1, 10, 4);
A.plot(error_map.block(0, nit-1, 0 ,0));
plt::show();
}
#endif

while(!last_it) {

Expand Down Expand Up @@ -156,7 +162,9 @@ int main(int argc,char *argv[]) {
if(config.verbose)
printf("%2.2f seconds\n",t.value());

#ifndef NOPLOT
plt::show(true);
#endif

return 0;
}
13 changes: 11 additions & 2 deletions src/main/star2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
#include "utils.h"
#include "star.h"
#include "read_config.h"
#ifndef NOPLOT
#include "matplotlib.h"
#endif


#include <stdlib.h>
#include <stdio.h>
Expand All @@ -29,7 +32,9 @@ int main(int argc,char *argv[]) {

signal(SIGINT,sig_handler);

plt::figure(1, 10, 4);
#ifndef NOPLOT
plt::figure(1, 10, 4);
#endif

t.start();

Expand Down Expand Up @@ -118,11 +123,13 @@ int main(int argc,char *argv[]) {
t_plot=tt(nit-1);
#else
static bool plotOpen = false;
#ifndef NOPLOT
if (plotOpen == false) {
plt::show();
plotOpen = true;
}
A.plot(error_map.block(0, nit-1, 0, 0));
#endif // NOPLOT
#endif
}

Expand Down Expand Up @@ -166,7 +173,9 @@ int main(int argc,char *argv[]) {
if(config.verbose)
printf("%2.2f seconds\n",t.value());

plt::show(true);
#ifndef NOPLOT
plt::show(true);
#endif

return 0;
}
Expand Down
7 changes: 7 additions & 0 deletions src/star/star1d_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
#endif
#include "utils.h"
#include "star.h"
#ifndef NOPLOT
#include "matplotlib.h"
#endif


#include <string.h>
#include <stdlib.h>
Expand Down Expand Up @@ -303,6 +306,7 @@ matrix star1d::spectrum(const matrix& var) {

void star1d::plot(const matrix_map& error) {

#ifndef NOPLOT
plt::clf();

plt::subplot(231);
Expand Down Expand Up @@ -369,4 +373,7 @@ void star1d::plot(const matrix_map& error) {

plt::draw();
plt::pause();
#else
ester_warn("matplotlib has been disabled at building time.");
#endif
}
3 changes: 3 additions & 0 deletions src/star/star1d_solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
#include <string.h>
#include "symbolic.h"

#ifndef NOPLOT
#include "matplotlib.h"
#endif

//---------------------------------------------------------------------
void star1d::fill() {
Y0=1.-X0-Z0;
Expand Down
8 changes: 8 additions & 0 deletions src/star/star2d_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
#include <string.h>
#include <cstdlib>
#include <H5Cpp.h>
#ifndef NOPLOT
#include "matplotlib.h"
#endif

#include "physics.h"

#include <iostream>
Expand Down Expand Up @@ -983,6 +986,7 @@ void star2d::dump_info() {
}

void star2d::plot(const matrix_map& error) {
#ifndef NOPLOT

matrix theta = vector(0, 2*M_PI, 64);
matrix r = map.leg.eval_00(this->r, theta);
Expand Down Expand Up @@ -1045,4 +1049,8 @@ void star2d::plot(const matrix_map& error) {

plt::draw();
plt::pause();

#else
ester_warn("matplotlib has been disabled at building time.");
#endif
}
9 changes: 9 additions & 0 deletions src/star/star_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#include "ester-config.h"
#endif
#include "star.h"
#ifndef NOPLOT
#include "matplotlib.h"
#endif


extern "C" {
#include <stdlib.h>
Expand Down Expand Up @@ -215,15 +218,21 @@ matrix star2d::find_boundaries(const matrix &logTi) const {
zj+=dzj;
nit++;
if(nit>100) {
#ifndef NOPLOT
plt::clf();
plt::plot(r, log(T), "$T$");
#endif
for (int i=0; i<logTi.nrows(); i++) {
#ifndef NOPLOT
plt::axvline(zj(i));
plt::axhline(logTi(i));
#endif
LOGE("ri%d zj=%e, dzj=%e\n", i, zj(i), dzj(i));
}
LOGE("No convergence in find_boundaries");
#ifndef NOPLOT
plt::show(true);
#endif
ester_err("No convergence in find_boundaries\n");
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/star/star_phys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#include "ester-config.h"
#endif
#include "star.h"
#ifndef NOPLOT
#include "matplotlib.h"
#endif


extern "C" {
#include <string.h>
Expand Down
Loading