IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 2b43d366 authored by ralfulrich's avatar ralfulrich Committed by Ralf Ulrich
Browse files

make CORSIKA_DATA optional. update docs

parent 2b8303d1
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,14 @@ include (corsikaUtilities) # extra cmake functions
#
include (corsikaDefines)
#+++++++++++++++++++++++++++++
# the location of the CORSIKA_DATA_DIR is of fundamental importance
# this should not be done in corsikaDefines.cmake since we may want
# to change behaviour at config/build/install time.
# And: Only the compile_definition of the CORSIKA8 target matters.
#
set (CORSIKA_DATA_DIR ${CMAKE_SOURCE_DIR}/modules/data)
#+++++++++++++++++++++++++++++
# check if compiler is C++17 compliant
#
......@@ -221,6 +229,12 @@ target_link_libraries (
CONAN_PKG::cli11
cnpy # for SaveBoostHistogram
)
target_compile_definitions (
CORSIKA8
INTERFACE
CORSIKA_DATA_DIR="${CORSIKA_DATA_DIR}"
)
# "src" is needed, since some headers (namely GeneratedParticleProperties.inc ec.) are produced by python script from e.g. ParticleData.xml
add_subdirectory (src)
......
......@@ -120,13 +120,6 @@ make install
## Runing Unit Tests
Note, before you run *any* executbale you must also define the
`CORSIKA_DATA` environment variable to point to the location where you
cloned corsika `modules/data`, thus typically
```shell
export CORSIKA_DATA=$PWD/../corsika/modules/data
```
To run the Unit Tests, just type `ctest` in your build area.
......@@ -144,7 +137,7 @@ e.g. `corsika-install/share/corsika/examples/` to your working place
Next, you need to define the environment variable `corsika_DIR` to point to, either,
your build, or your install area. Thus, e.g.
```shell
export corsika_DIR=<dir where you installed CORSIKA 8 to, or where you buld it">
export corsika_DIR=<dir where you installed CORSIKA 8 to, or where you build it>
```
Then compile your example/application with
......
......@@ -129,13 +129,6 @@ Follow these steps to download and install CORSIKA 8, master development version
Runing Unit Tests
-----------------
Note, before you run *any* executbale you must also define the
:code:`CORSIKA_DATA` environment variable to point to the location where you
cloned corsika :code:`modules/data`, thus typically
::
export CORSIKA_DATA=$PWD/../corsika/modules/data
To run the Unit Tests, just type :code:`ctest` in your build area.
......@@ -155,7 +148,7 @@ Next, you need to define the environment variable :code:`corsika_DIR` to point t
your build, or your install area. Thus, e.g.
::
export corsika_DIR=<dir where you installed CORSIKA 8 to, or where you buld it">
export corsika_DIR=<dir where you installed CORSIKA 8 to, or where you build it>
Then compile your example/application with
::
......
......@@ -62,6 +62,10 @@ check_required_components (corsika)
#+++++++++++++++++++++++++++++++
# add further definitions / options
#
target_compile_definitions (CORSIKA8::CORSIKA8
INTERFACE
CORSIKA_DATA_DIR=\"@CORSIKA_DATA_DIR@\"
)
if (WITH_HISTORY)
set_property (
TARGET CORSIKA8::CORSIKA8
......
......@@ -7,16 +7,25 @@
*/
#pragma once
#include <corsika/framework/core/Logging.hpp>
#include <boost/filesystem/path.hpp>
#include <cstdlib>
#include <stdexcept>
#include <string>
inline boost::filesystem::path corsika::corsika_data(boost::filesystem::path const& key) {
if (auto const* p = std::getenv("CORSIKA_DATA"); p != nullptr) {
return boost::filesystem::path(p) / key;
} else { // LCOV_EXCL_START, this cannot be easily tested system-independently
throw std::runtime_error("CORSIKA_DATA not set");
} // LCOV_EXCL_STOP
}
namespace corsika {
inline boost::filesystem::path corsika_data(boost::filesystem::path const& key) {
std::string const corsika_Data_Dir = std::string(CORSIKA_DATA_DIR); // from cmake
boost::filesystem::path fname = boost::filesystem::path(corsika_Data_Dir) / key;
// LCOV_EXCL_START, this cannot be easily tested system-independently
if (auto const* p = std::getenv("CORSIKA_DATA"); p != nullptr) {
fname = boost::filesystem::path(p) / key;
}
// LCOV_EXCL_STOP
CORSIKA_LOG_INFO("opening data file={}", fname);
return fname;
}
} // namespace corsika
......@@ -9,14 +9,16 @@
#pragma once
#include <corsika/modules/epos/Interaction.hpp>
#include <corsika/modules/epos/EposStack.hpp>
#include <corsika/media/Environment.hpp>
#include <corsika/media/NuclearComposition.hpp>
#include <corsika/framework/geometry/FourVector.hpp>
#include <corsika/modules/epos/EposStack.hpp>
#include <corsika/framework/utility/COMBoost.hpp>
#include <corsika/framework/utility/CorsikaData.hpp>
#include <corsika/setup/SetupStack.hpp>
#include <corsika/setup/SetupTrajectory.hpp>
#include <corsika/framework/utility/COMBoost.hpp>
#include <epos.hpp>
......@@ -33,13 +35,8 @@ namespace corsika::epos {
: data_path_(dataPath)
, epos_listing_(epos_printout_on) {
if (dataPath == "") {
if (std::getenv("CORSIKA_DATA")) {
data_path_ = std::string(std::getenv("CORSIKA_DATA")) + "/EPOS/";
CORSIKA_LOGGER_DEBUG(logger_, "Searching for EPOSLHC data tables in {}",
data_path_);
}
data_path_ = (std::string(corsika_data("EPOS").c_str()) + "/").c_str();
}
// initialize Eposlhc
static bool initialized = false;
if (!initialized) {
......
......@@ -46,25 +46,6 @@ auto sumMomentum(TStackView const& view, CoordinateSystemPtr const& vCS) {
return sum;
}
TEST_CASE("CORSIKA_DATA", "[processes]") {
logging::set_level(logging::level::info);
SECTION("check CORSIKA_DATA") {
const char* CORSIKA_DATA = std::getenv("CORSIKA_DATA");
// these CHECKS are needed:
CHECK(CORSIKA_DATA != 0);
CHECK(boost::filesystem::is_directory(boost::filesystem::path(CORSIKA_DATA) /
"QGSJetII"));
CORSIKA_LOG_INFO(
"data: {}"
" isDir: {}"
"/QGSJetII",
CORSIKA_DATA, boost::filesystem::is_directory(CORSIKA_DATA));
}
}
TEST_CASE("QgsjetII", "[processes]") {
logging::set_level(logging::level::info);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment