IAP GITLAB

Commit 621298d9 authored by Maximilian Reininghaus's avatar Maximilian Reininghaus 🖖

Merge branch 'master' into andre-master

parents 3f3225f1 6b19a7a9
Pipeline #2039 failed with stages
in 0 seconds
......@@ -6,3 +6,4 @@ build/
Framework/Particles/GeneratedParticleProperties.inc
flymd.html
flymd.md
Testing
This diff is collapsed.
[submodule "Data"]
path = Data
url = ../../AirShowerPhysics/corsika-data
branch = master
[submodule "ThirdParty/spdlog"]
path = ThirdParty/spdlog
url = https://github.com/gabime/spdlog.git
shallow = true
Maximilian Reininghaus, maximilian.reininghaus@kit.edu
Ralf Ulrich, ralf.ulrich@kit.edu
Felix Riehn, friehn@lip.pt
cmake_minimum_required (VERSION 3.9)
# we would need 3.16 to have CMP0097 for external subproject submodule (non) support
# prevent in-source builds and give warning message
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
......@@ -68,7 +69,7 @@ endif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
# FYI: optimizer flags: -O2 would not trade speed for size, neither O2/3 use fast-math
# debug: O0, relwithdebinfo: 02, release: O3, minsizerel: Os (all defaults)
set (CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Wno-ignored-qualifiers")
set (CMAKE_Fortran_FLAGS "-std=legacy")
set (CMAKE_Fortran_FLAGS "-std=legacy -Wfunction-elimination")
# setup coverage build type
set (CMAKE_CXX_FLAGS_COVERAGE "-g --coverage")
......@@ -78,6 +79,9 @@ set (CMAKE_SHARED_LINKER_FLAGS_COVERAGE "--coverage")
# clang produces a lot of unecessary warnings without this:
add_compile_options ("$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-nonportable-include-path>")
# set a flag to inform code that we are in debug mode
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
# COAST - interface, this requires CORSIKA7 to be installed first
# COAST will allow you to program code in CORSIKA8 and execute it inside CORSIKA7
if (WITH_COAST)
......@@ -114,8 +118,22 @@ if (CMAKE_BUILD_TYPE STREQUAL Coverage)
add_custom_target (coverage DEPENDS coverage-report)
endif ()
# add call to ./do-copyright.py to run as unit-test-case
add_test (NAME copyright_notices COMMAND ./do-copyright.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# include this test only if NOT run on gitlab-ci, since there we have a dedicated job for it:
if (NOT DEFINED ENV{CI})
# add call to ./do-copyright.py to run as unit-test-case
add_test (NAME copyright_notices COMMAND ./do-copyright.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif (NOT DEFINED ENV{CI})
if (DEFINED ENV{CORSIKA_DATA})
message ("Found corsika-data in $ENV{CORSIKA_DATA}")
set (CORSIKA_DATA $ENV{CORSIKA_DATA})
add_subdirectory ($ENV{CORSIKA_DATA} corsika_data)
else ()
message ("CORSIKA_DATA not defined: NEED to download AirShowerPhysics/corsika-data via git submodule")
message ("cmake will fail if you did not do this already.")
set (CORSIKA_DATA ${PROJECT_SOURCE_DIR}/Data)
add_subdirectory (Data)
endif ()
# include potential ThirdParty code provided with CORSIKA
add_subdirectory (ThirdParty)
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#ifndef _include_corsika_coast_coastprocess_h_
#define _include_corsika_coast_coastprocess_h_
#pragma once
#include <corsika/particles/ParticleProperties.h>
#include <corsika/process/ContinuousProcess.h>
......@@ -42,5 +39,3 @@ namespace corsika::coast {
};
} // namespace corsika::coast
#endif
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#ifndef _include_coaststack_h_
#define _include_coaststack_h_
#pragma once
#include <corsika/coast/ParticleConversion.h>
#include <corsika/particles/ParticleProperties.h>
......@@ -188,5 +185,3 @@ namespace corsika::coast {
typedef corsika::stack::Stack<COASTStackImpl, ParticleInterface> COASTStack;
} // namespace corsika::coast
#endif
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#ifndef _include_processes_sibyll_particles_h_
#define _include_processes_sibyll_particles_h_
#pragma once
#include <corsika/particles/ParticleProperties.h>
......@@ -210,5 +207,3 @@ namespace corsika::coast {
corsika::particles::Code ConvertFromCoast(CoastCode pCode);
} // namespace corsika::coast
#endif
......@@ -13,7 +13,7 @@ examples of other big scientific software projects.
The CORSIKA project consists of the contributions from the scientific
community and individuals in a best effort to deliver the best
possible computing performance and physics output.
possible performance and physics output.
The MCnet guidelines developed by [www.montecarlonet.org](www.montecarlonet.org)
are copied in [MCNET_GUIDELINES](MCNET_GUIDELINES) -- they provide a very good
additional scope that contributors should read and consider.
......@@ -27,78 +27,36 @@ The license adopted for the CORSIKA project is the explicit copyleft
license GPLv3, as copied in full in the file
[LICENSE](LICENSE). Each source file of the CORSIKA project contains a
short statement of the copyright and this license. Each binary or
source code release of CORSIKA must contain the file LICENSE. The
source code release of CORSIKA contains the file LICENSE. The
code, documentation and content in the folder [ThirdParty](ThirdParty)
is not integral part of the CORSIKA project and can be based on, or
include, other licenses, which must be compatible with GPLv3. Check the
content of this folder for details and additional license information. It depends on the configuration of
the build system to what extend this code is used to build CORSIKA.
## Who is the "copyright holder"
For legal reasons and the ability to maintain the CORSIKA project
effectively over a very long lifespan of several decades, all
contributors are required to transfer their copyright to the CORSIKA
Project. Of course you will be duly credited and your name will appear
on the contributors page and in the [AUTHORS](AUTHORS) file shipped
with every binary and source distribution. The copyright transfer is
necessary to be able to effectively defend the project in case of
litigation. The copyright holder may change, if decided by the CORSIKA
Project. The current copyright holder is the CORSIKA Project
corsika-project@lists.kit.edu, with the current chair person
Ralf Ulrich (KIT) ralf.ulrich@kit.edu.
## Definition of a "contributor"
Contributor is a person of whom at least one merge request was
accepted for the master branch of the CORSIKA project at
[https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika](https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika).
All contributors will be co-listed and credited as (software) authors
of the CORSIKA project, as well as listed indefinitely in the
[AUTHORS](AUTHORS) file. Contributors should add their name and
contact data to the [AUTHORS](AUTHORS) file, as part of one of their
merge requests. This file is always distributed together with all
source and binary releases. If you contribute to any non-master
branch, you can add your name to the [AUTHORS](AUTHORS) file of this
particular branch, but all official releases are normally performed
via the master branch.
## Contributing
If you want to contribute, you need to read
[the GUIDELINES](CONTRIBUTING.md) and comply with these rules, or help to
improve them.
improve them.
## The CORSIKA Project panel
The CORSIKA Project panel makes all decisions for the CORSIKA
Project. It can also change the
## The CORSIKA Projects Maintainers
The CORSIKA Project mainters make all decisions for the CORSIKA
Project. They can also change the
[COLLABORATION\_AGREEMENT](COLLABORATION\_AGREEMENT.md), the
[GUIDELINES](CONTRIBUTING.md) or any other structure or document relevant for the CORSIKA Project.
The CORSIKA Project *panel* consists (October 2018) of
* Hans Dembinski (MPG)
* Ralph Engel (KIT)
* Dieter Heck (KIT)
* Tanguy Pierog (KIT)
* Maximilian Reininghaus (KIT)
* Felix Riehn (LIP)
* Ralf Ulrich (KIT)
* Darko Veberic (KIT)
and can be contacted via corsika-project@lists.kit.edu. The chair
person of the CORSIKA Project is Ralf Ulrich (KIT). Members of the
CORSIKA Project *panel* can be *Maintainer* of the CORSIKA Project in
gitlab at
[https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika](https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika),
and have special responsibilities also for this reason.
The current CORSIKA Project maintainers are listed in the file [MAINTAINERS](MAINTAINERS.md).
### Changing to a different license, for parts, or the complete project
and can be contacted via corsika-project@lists.kit.edu. The chair
person of the CORSIKA Project is Ralf Ulrich (KIT). Maintainers have special
responsibilities for specific parts of the project.
The CORSIKA Project panel can change the license for parts or the entire project in general or for individual releases.
### Planning and performing releases
The CORSIKA Project panel decides on releases of the software, and about the content of it.
The CORSIKA maintainers decide on releases of the software, and about the content of it.
### Changes to the Collaboration Agreement
The CORSIKA Project panel decides on changes to the Collaboration
agreement.
......@@ -20,6 +20,7 @@ change/improve them.
- Proposed code to close one issue (located in a specific git
branch) is reviewed, discussed, and eventually merged
into the master branch to close the issue.
- all merge request will undergo a code review, and must be approved before merge, in order to ensure high code qualtiy: [Code Approval Procedure](https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika/-/wikis/Code-Approval-Procedure)
## Code formatting
......@@ -46,35 +47,54 @@ e.g. [link1](https://clangformat.com/) or
While `clang-format` does the structural formatting, we still need to agree on naming conventions:
- Classes and structs start with capital letters
- Class member variables start with "f"
- Any static variable has a "g" prefix. A static member variable starts with "fg"
- Class member functions start with capital letters
- Any class getter begins with "Get", and setter with "Set". Logical getters start with "Is" or "Has".
- enums should be "enum class" and start with a capital "E"
- Function parameter names start with "v"
- Classes and structs start with capital letters ```LikeThis```
- Class member variables start non-captial and have a trailing "_" ```likeThis_```
- Class member functions start with small letters ```LikeThis::doSomething(...)``` or ```LikeThis::do_something(...)```
- Any class setter begins with "set_" ```LikeThis::set_something(...)```
- Any class getter is named accoring to its property: ```LikeThis::something()```
- Logical getters may start with ```is_``` or ```has_```
- enums should be ```enum class```
- Named variables start with small letter ```likeThis```
- types in template definitions start with "T" ```TLikeThis```
- use names that explain and document the code, thus for example
```
TimeType TimeOfIntersection(Line const& line, Plane const& plane) {
auto const line_direction = line.GetDirection();
auto const plane_normal = plane.GetNormal();
return plane_normal.dot(plane.GetCenter()-line.GetPosition()) / plane_normal.dot(line_direction);
}
```
and not
```
TimeType TimeOfIntersection(Line const& l, Plane const& p) {
auto const d = p.GetCenter() - l.GetR0();
auto const v = l.GetV0();
auto const n = p.GetNormal();
auto const c = n.dot(v);
return n.dot(d) / c;
}
```
This actually is suffient to document the code, no further comments should be added in such cases. Only if further clarification is needed.
- We use namespaces to avoid clashes and to structure code
- *Everything* is part of the corsika namespace
- *Everything* is part of one of those namespaces:
- ```corsika::framework```, ```corsika::physics```, or ```corsika::process```
- All classes and objects are encapsulated into suited sub-namespaces,
thus corsika::geometry, corsika::processes, corsika::units, etc.
thus ```corsika::framework::geometry```, ```corsika::physics::process```, ```corsika::physics::units```, etc.
- Namespace names do not use capital letters.
- Every header file is copied during build and install into
"include/corsika/[namespace]" which also means, each header file
can only provide definitions for a _single_ namespace. It is one
main purpose of namespaces to structure the location of header
files.
- Each header file uses an include protection that includes at
least the namespace name, and header file name, thus, `#ifndef
__include_geometry_Point_h__` or `#ifndef __geometry_Point_h__`,
or similar are acceptable.
- Header files should always be included with `<..>`, thus,
`#include <corsika/geometry/Point.h>` since the build system
will always provide the correct include directives (and files
anyway cannot be found in file-system paths, which generally do
not follow the namespace naming conventions outlined
here).
- Every header file is located in the source tree in ```include/corsika/[namespace]```, which also means that in almost all cases each header file
can only provide definitions for a _single_ namespace. It is one
main purpose of namespaces to structure the location of header
files.
- Each header file uses an include protection ```#pragma once```
immediately below the copyright statement.
- Header files should always be included with `<..>`, thus,
`#include <corsika/geometry/Point.h>` since the build system
will always provide the correct include directives (and files
anyway cannot be found in file-system paths, which generally do
not follow the namespace naming conventions outlined
here).
- Header files are named after the main class (or object) they
define. This also means each header file name starts with a
capital letter.
......@@ -82,20 +102,24 @@ While `clang-format` does the structural formatting, we still need to agree on n
## Coding rules
- Code may not introduce any compiler errors, or warnings (latter: on current CI runners)
- All unit tests must succeed at all times. If tests fail, code is not merged.
- We use C++17 concepts wherever useful and helpful
- Warnings should be fixed, when they appear on the system(s) currently used by the CI, by altering the code unless the warning originates from third-party code and cannot be fixed. In that case, the warning should be locally silenced with appropriate pragmas or by locally turning off warnings for that translation unit.
- All unit tests must succeed on the specified systems/configurations on gitlab-ci. If tests fail, code is not merged.
- The unit test code coverage should not decrease due to a new merge request.
- We use C++17 features wherever useful and helpful.
- On any major error or malfunction we throw an exception. This is needed and required for complex physics and shower debugging.
- We never catch exceptions for error handling, there might be very few special exceptions from this. We need to discuss such cases.
- Everything that should not change should be `const`
- Everything that should not change should be ```const```
- Everything that does not need to be visible to the outside of a class/struct should be `private` or `protected`
- We prefer the use of references, wherever useful
- There cannot be any pointer in the interface of any class or object
exposed to outside users, there might be pointers for very special cases
- There cannot be any raw pointer in the interface of any class or object
exposed to outside users, there might be (technical) raw pointers for very special cases
inside of classes.
- (member)functions that do something (are not just getters/setters), model actions or transformations, and should therefore be verbs. Classes are nouns.
- When you contribute new code, or extend existing code, at the same time provide unit-tests for all functionality.
- When you contribute new physics algorithms, in addition you also need to provide a validation module
- Code must be documented with `doxygen` commands
- When you contribute new physics algorithms, in addition you also need to provide a validation module (this is still TBD what exactly this means)
- Code must be documented with `doxygen` commands extensively -> MAKE THIS INVESTMENT OF YOUR TIME EARLY, IT REALLY HELPS
- There should not be any useless comments in code, in particular absolutely avoid to commit commented-out debug remnants
- Add sufficient and meaningful comments to the code (only in English)
## CMAKE formatting
......@@ -120,6 +144,8 @@ Since cmake itself lacks structure almost entirely:
- add plenty of comments to all cmake code
- use expressive variables and functions
## Release versioning scheme
Releases of CORSIKA are thought to be the baseline for larger scale
......
Subproject commit 47e6e5abb78b8151c9748af44e09efcbee810fac
......@@ -8,12 +8,8 @@ target_link_libraries (particle_list_example CORSIKAparticles CORSIKAunits CORSI
CORSIKA_ADD_EXAMPLE (geometry_example)
target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits)
CORSIKA_ADD_EXAMPLE (logger_example)
target_link_libraries (logger_example CORSIKAunits CORSIKAlogging)
CORSIKA_ADD_EXAMPLE (stack_example)
target_link_libraries (stack_example SuperStupidStack CORSIKAunits
CORSIKAlogging)
target_link_libraries (stack_example SuperStupidStack CORSIKAunits)
# address sanitizer is making this example too slow, so we only do "undefined"
CORSIKA_ADD_EXAMPLE (boundary_example)
......@@ -93,12 +89,14 @@ if (Pythia8_FOUND)
ProcessUrQMD
ProcessSwitch
CORSIKAcascade
ProcessCONEXSourceCut
ProcessEnergyLoss
ProcessObservationPlane
ProcessInteractionCounter
ProcessTrackWriter
ProcessTrackingLine
ProcessParticleCut
ProcessOnShellCheck
ProcessStackInspector
ProcessLongitudinalProfile
CORSIKAprocesses
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
......@@ -75,8 +73,6 @@ struct MyBoundaryCrossingProcess
return EProcessReturn::eOk;
}
void Init() {}
private:
std::ofstream fFile;
};
......@@ -118,7 +114,7 @@ int main() {
// setup processes, decays and interactions
tracking_line::TrackingLine tracking;
random::RNGManager::GetInstance().RegisterRandomStream("s_rndm");
random::RNGManager::GetInstance().RegisterRandomStream("sibyll");
process::sibyll::Interaction sibyll;
process::sibyll::Decay decay;
......@@ -168,7 +164,7 @@ int main() {
// define air shower object, run simulation
cascade::Cascade EAS(env, tracking, sequence, stack);
EAS.Init();
EAS.Run();
cout << "Result: E0=" << E0 / 1_GeV << endl;
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
......@@ -135,7 +133,7 @@ int main() {
tracking_line::TrackingLine tracking;
stack_inspector::StackInspector<setup::Stack> stackInspect(1, true, E0);
random::RNGManager::GetInstance().RegisterRandomStream("s_rndm");
random::RNGManager::GetInstance().RegisterRandomStream("sibyll");
random::RNGManager::GetInstance().RegisterRandomStream("pythia");
process::sibyll::Interaction sibyll;
process::sibyll::NuclearInteraction sibyllNuc(sibyll, env);
......@@ -152,7 +150,7 @@ int main() {
// define air shower object, run simulation
cascade::Cascade EAS(env, tracking, sequence, stack);
EAS.Init();
EAS.Run();
eLoss.PrintProfile(); // print longitudinal profile
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
......@@ -118,7 +116,7 @@ int main() {
tracking_line::TrackingLine tracking;
stack_inspector::StackInspector<setup::Stack> stackInspect(1, true, E0);
random::RNGManager::GetInstance().RegisterRandomStream("s_rndm");
random::RNGManager::GetInstance().RegisterRandomStream("sibyll");
random::RNGManager::GetInstance().RegisterRandomStream("pythia");
// process::sibyll::Interaction sibyll(env);
process::pythia::Interaction pythia;
......@@ -142,7 +140,7 @@ int main() {
// define air shower object, run simulation
cascade::Cascade EAS(env, tracking, sequence, stack);
EAS.Init();
EAS.Run();
cout << "Result: E0=" << E0 / 1_GeV << endl;
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#include <corsika/logging/Logger.h>
#include <boost/format.hpp>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
using namespace corsika::logging;
int main() {
{
cout << "writing to \"another.log\"" << endl;
ofstream logfile("another.log");
sink::SinkStream unbuffered_sink(logfile);
sink::BufferedSinkStream sink(logfile, sink::StdBuffer(10000));
Logger<MessageOn, sink::BufferedSinkStream> info("\033[32m", "info", sink);
Logger<MessageOn, sink::BufferedSinkStream> err("\033[31m", "error", sink);