Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
98c9f26
Changed to current CXX23 standard
JanNiklasB Mar 31, 2026
891589d
binary_function not needed anymore
JanNiklasB Mar 31, 2026
f94a0ab
fixed deprecated enum-enum-conversion
JanNiklasB Mar 31, 2026
3a3d9df
removed lower cmake standard in testing_OSX.yml
JanNiklasB Mar 31, 2026
c373f3e
replaced deprecated ::first_argument_type
JanNiklasB Mar 31, 2026
9771e84
added missing return in Variant.cpp
JanNiklasB Mar 31, 2026
fbd0eee
Fixed deprecation fortran warnings in sophia
JanNiklasB Mar 31, 2026
483ad6d
repaired doxygen comments
JanNiklasB Mar 31, 2026
ff0433a
changed sprintf to snprintf (safer and not deprecated)
JanNiklasB Mar 31, 2026
e276924
added newer include path to possible search paths
JanNiklasB Mar 31, 2026
1cbffcb
changed to the more general <memory>
JanNiklasB Mar 31, 2026
9501169
added brackets to avoid warning and comment to clarify
JanNiklasB Mar 31, 2026
afce3c3
constScaleBendover not initialized at that time
JanNiklasB Mar 31, 2026
6f60299
setExtends did nothing
JanNiklasB Mar 31, 2026
afb9dca
expression was never used...
JanNiklasB Mar 31, 2026
36f351d
fixed very crucial typo (type -> to_type)
JanNiklasB Mar 31, 2026
ca42395
fixed wrong formatting
JanNiklasB Mar 31, 2026
92b94ac
corrected buffersize with subsequent calls
JanNiklasB Mar 31, 2026
033af5e
fixed issue with "%ull" when formatting uint64_t between clang and gcc
JanNiklasB Mar 31, 2026
ad93a46
added ninja to workflows
JanNiklasB Mar 31, 2026
9ba0a15
removed ninja from worklows
JanNiklasB Apr 1, 2026
ac82689
set CMAKE_CXX_STANDARD back to 11 for now
JanNiklasB Apr 1, 2026
763e934
reversed cmake --build . back to make, kept ctest --output-on-failure
JanNiklasB Apr 1, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/create_coverage_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: run test
run: |
cd build
make test
ctest --output-on-failure
continue-on-error: true
- name: coverage report
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: run test
run: |
cd build
make test
ctest --output-on-failure
continue-on-error: true
- name: coverage report
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_new_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: run test
run: |
cd build
make test
ctest --output-on-failure
continue-on-error: true
- name: coverage report
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing_OSX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
CRPROPA_DATA_PATH: "/Users/runner/work/CRPropa3/CRPropa3/build/data"
run: |
cd build
make test
ctest --output-on-failure
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing_ubuntu22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Run tests
run: |
cd build
make test
ctest --output-on-failure
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/testing_ubuntu24.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Run tests
run: |
cd build
make test
ctest --output-on-failure
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Run tests
run: |
cd build
make test
ctest --output-on-failure
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindGooglePerfTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# STACKTRACE_LIBRARIES, where to find the stacktrace library.
# PROFILER_LIBRARIES, where to find the profiler library.

FIND_PATH(GOOGLE_PERFTOOLS_INCLUDE_DIR google/heap-profiler.h)
FIND_PATH(GOOGLE_PERFTOOLS_INCLUDE_DIR NAMES google/heap-profiler.h gperftools/heap-profiler.h)

SET(TCMALLOC_NAMES ${TCMALLOC_NAMES} tcmalloc)
FIND_LIBRARY(TCMALLOC_LIBRARY NAMES ${TCMALLOC_NAMES})
Expand Down
21 changes: 10 additions & 11 deletions include/crpropa/AssocVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ namespace Loki

namespace Private
{
template <class Value, class C>
template <class Value, class C, class K>
class AssocVectorCompare : public C
{
typedef std::pair<typename C::first_argument_type, Value>
typedef K first_argument_type;
typedef std::pair<first_argument_type, Value>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first_argument is removed in CXX23 so we need an additional template argument, the rest of the code is adjusted, user code is not affected as far as I see

Data;
typedef typename C::first_argument_type first_argument_type;

public:
AssocVectorCompare()
Expand Down Expand Up @@ -98,10 +98,10 @@ namespace Loki
>
class AssocVector
: private std::vector< std::pair<K, V>, A >
, private Private::AssocVectorCompare<V, C>
, private Private::AssocVectorCompare<V, C, K>
{
typedef std::vector<std::pair<K, V>, A> Base;
typedef Private::AssocVectorCompare<V, C> MyCompare;
typedef Private::AssocVectorCompare<V, C, K> MyCompare;

public:
typedef K key_type;
Expand All @@ -110,20 +110,19 @@ namespace Loki

typedef C key_compare;
typedef A allocator_type;
typedef typename A::reference reference;
typedef typename A::const_reference const_reference;
typedef typename A::value_type& reference;
typedef const typename A::value_type* const_reference;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reference and const_reference are removed in CXX23, value_type is equivalent

typedef typename Base::iterator iterator;
typedef typename Base::const_iterator const_iterator;
typedef typename Base::size_type size_type;
typedef typename Base::difference_type difference_type;
typedef typename A::pointer pointer;
typedef typename A::const_pointer const_pointer;
typedef typename A::value_type* pointer;
typedef const typename A::value_type* const_pointer;
typedef typename Base::reverse_iterator reverse_iterator;
typedef typename Base::const_reverse_iterator const_reverse_iterator;

class value_compare
: public std::binary_function<value_type, value_type, bool>
, private key_compare
: private key_compare
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binary_function is not needed in newer CXX versions, its functionality is now done automatically and therefore it was removed

{
friend class AssocVector;

Expand Down
2 changes: 1 addition & 1 deletion include/crpropa/Random.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace crpropa {
Mersenne Twister random number generator -- a C++ class Random
Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
Richard J. Wagner v1.0 15 May 2003 rjwagner@writeme.com
Richard J. Wagner v1.0 15 May 2003 rjwagner\@writeme.com
*/
class Random {
public:
Expand Down
2 changes: 1 addition & 1 deletion include/crpropa/Vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class Vector3 {

const std::string getDescription() {
char buffer[256];
sprintf(buffer, "Vector(%.6G, %.6G, %.6G)", data[0], data[1], data[2]);
snprintf(buffer, 256, "Vector(%.6G, %.6G, %.6G)", data[0], data[1], data[2]);
return buffer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SimpleTurbulenceSpectrum : public TurbulenceSpectrum {
*/
SimpleTurbulenceSpectrum(double Brms, double lMin, double lMax,
double sIndex = 5. / 3)
: TurbulenceSpectrum(Brms, lMin, lMax, constScaleBendover * lMax, sIndex, 0) {}
: TurbulenceSpectrum(Brms, lMin, lMax, 1000 * lMax, sIndex, 0) {}
~SimpleTurbulenceSpectrum() {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class TurbulenceSpectrum : public Referenced {

/**
Computes the magnetic field coherence length
Obtained from the definition of \f$l_c = 1/B_{\rm rms}^2 \int_0^\infty dr\langleB(0)B^*(r)\rangle \f$
Obtained from the definition of \\f$l_c = 1/B_{\\rm rms}^2 \\int_0^\\infty dr\\langleB(0)B^*(r)\\rangle \\f$
Approximates the true value correctly as long as lBendover <= lMax/8 (~5%
error) (for the true value the above integral should go from lMin to lMax)
*/
Expand Down
14 changes: 7 additions & 7 deletions include/crpropa/module/Acceleration.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ class DirectedFlowOfScatterCenters : public StepLengthModifier {
/// @class QuasiLinearTheory
/// @brief Scales the steplength according to quasi linear theory.
/// @details Following quasi-linear theory [Schlickeiser1989], the mean free
/// path \f$\lambda\f$ of a
/// particle with energy \f$E\f$ and charge \f$Z\f$ in a field with turbulence
/// spectrum \f$\frac{k}{k_{\min}}^{-q}\f$ is
/// \f$ \lambda = {\left(\frac{B}{\delta B}\right)}^2 {\left(R_G\;
/// k_{\min}\right)}^{1-q} R_G \equiv \lambda_0 {\left( \frac{E}{1
/// EeV}\frac{1}{Z} \right)}^{2-q} \f$
/// where \f$R_G = \frac{E}{B Z}\f$ is the gyro-radius of the
/// path \\f$\\lambda\\f$ of a
/// particle with energy \\f$E\\f$ and charge \\f$Z\\f$ in a field with turbulence
/// spectrum \\f$\\frac{k}{k_{\\min}}^{-q}\\f$ is
/// \\f$ \\lambda = {\\left(\\frac{B}{\\delta B}\\right)}^2 {\\left(R_G\\;
/// k_{\\min}\\right)}^{1-q} R_G \\equiv \\lambda_0 {\\left( \\frac{E}{1
/// EeV}\\frac{1}{Z} \\right)}^{2-q} \\f$
/// where \\f$R_G = \\frac{E}{B Z}\\f$ is the gyro-radius of the
/// particles.
/// This class implements the rigidity dependent scaling factor used to modify
/// the base step length.
Expand Down
96 changes: 55 additions & 41 deletions libs/sophia/sophia_interface.f
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENDDO is the more modern approach, the old one also works but throws warnings

Original file line number Diff line number Diff line change
Expand Up @@ -2568,45 +2568,55 @@ SUBROUTINE DECPAR(LA,P0,ND,LL,P)

C...generation of the masses, compute weight, if rejected try again
240 RORD(1) = 1.D0
DO 260 IL1=2,ND-1
RSAV = RNDM(0)
DO 250 IL2=IL1-1,1,-1
IF(RSAV.LE.RORD(IL2)) GOTO 260
250 RORD(IL2+1)=RORD(IL2)
DO IL1=2,ND-1
RSAV = RNDM(0)
DO IL2=IL1-1,1,-1
IF(RSAV.LE.RORD(IL2)) GOTO 260
RORD(IL2+1)=RORD(IL2)
ENDDO
260 RORD(IL2+1)=RSAV
ENDDO
RORD(ND) = 0.D0
WT = 1.D0
DO 270 IL=ND-1,1,-1
PV(IL,5)=PV(IL+1,5)+P(IL,5)+(RORD(IL)-RORD(IL+1))*(PV(1,5)-PS)
270 WT=WT*PAWT(PV(IL,5),PV(IL+1,5),P(IL,5))
DO IL=ND-1,1,-1
PV(IL,5)=PV(IL+1,5)+P(IL,5)+(RORD(IL)-RORD(IL+1))*(PV(1,5)-PS)
WT=WT*PAWT(PV(IL,5),PV(IL+1,5),P(IL,5))
ENDDO
IF (WT.LT.RNDM(0)*WWTMAX) GOTO 240

C...Perform two particle decays in respective cm frame
280 DO 300 IL=1,ND-1
PA=PAWT(PV(IL,5),PV(IL+1,5),P(IL,5))
UE(3)=2.D0*RNDM(0)-1.D0
PHI=2.D0*PI*RNDM(0)
UT = SQRT(1.D0-UE(3)**2)
UE(1) = UT*COS(PHI)
UE(2) = UT*SIN(PHI)
DO 290 J=1,3
P(IL,J)=PA*UE(J)
290 PV(IL+1,J)=-PA*UE(J)
P(IL,4)=SQRT(PA**2+P(IL,5)**2)
300 PV(IL+1,4)=SQRT(PA**2+PV(IL+1,5)**2)
280 DO IL=1,ND-1
PA=PAWT(PV(IL,5),PV(IL+1,5),P(IL,5))
UE(3)=2.D0*RNDM(0)-1.D0
PHI=2.D0*PI*RNDM(0)
UT = SQRT(1.D0-UE(3)**2)
UE(1) = UT*COS(PHI)
UE(2) = UT*SIN(PHI)
DO J=1,3
P(IL,J)=PA*UE(J)
PV(IL+1,J)=-PA*UE(J)
ENDDO
P(IL,4)=SQRT(PA**2+P(IL,5)**2)
PV(IL+1,4)=SQRT(PA**2+PV(IL+1,5)**2)
ENDDO

C...Lorentz transform decay products to lab frame
DO 310 J=1,4
310 P(ND,J)=PV(ND,J)
DO 340 IL=ND-1,1,-1
DO 320 J=1,3
320 BE(J)=PV(IL,J)/PV(IL,4)
GA=PV(IL,4)/PV(IL,5)
DO 340 I=IL,ND
BEP = BE(1)*P(I,1)+BE(2)*P(I,2)+BE(3)*P(I,3)
DO 330 J=1,3
330 P(I,J)=P(I,J)+GA*(GA*BEP/(1.+GA)+P(I,4))*BE(J)
340 P(I,4)=GA*(P(I,4)+BEP)
DO J=1,4
P(ND,J)=PV(ND,J)
ENDDO
DO IL=ND-1,1,-1
DO J=1,3
BE(J)=PV(IL,J)/PV(IL,4)
ENDDO
GA=PV(IL,4)/PV(IL,5)
DO I=IL,ND
BEP = BE(1)*P(I,1)+BE(2)*P(I,2)+BE(3)*P(I,3)
DO J=1,3
P(I,J)=P(I,J)+GA*(GA*BEP/(1.+GA)+P(I,4))*BE(J)
ENDDO
P(I,4)=GA*(P(I,4)+BEP)
ENDDO
ENDDO

C...Weak decays
IF (MAT .EQ. 1) THEN
Expand All @@ -2621,14 +2631,17 @@ SUBROUTINE DECPAR(LA,P0,ND,LL,P)

C...Boost back for rapidly moving particle
IF (MBST .EQ. 1) THEN
DO 440 J=1,3
440 BE(J)=P0(J)/P0(4)
GA= P0(4)/P0(5)
DO 460 I=1,ND
BEP=BE(1)*P(I,1)+BE(2)*P(I,2)+BE(3)*P(I,3)
DO 450 J=1,3
450 P(I,J)=P(I,J)+GA*(GA*BEP/(1.+GA)+P(I,4))*BE(J)
460 P(I,4)=GA*(P(I,4)+BEP)
DO J=1,3
BE(J)=P0(J)/P0(4)
ENDDO
GA= P0(4)/P0(5)
DO I=1,ND
BEP=BE(1)*P(I,1)+BE(2)*P(I,2)+BE(3)*P(I,3)
DO J=1,3
P(I,J)=P(I,J)+GA*(GA*BEP/(1.+GA)+P(I,4))*BE(J)
ENDDO
P(I,4)=GA*(P(I,4)+BEP)
ENDDO
ENDIF

C...labels for antiparticle decay
Expand Down Expand Up @@ -2804,8 +2817,9 @@ DOUBLE PRECISION FUNCTION PO_RNDGAM(ALAM,ETA)
IF(RNDM(0).GT.Y**(F-1.D0)) GOTO 10
40 IF(N.EQ.0) GOTO 70
50 Z = 1.D0
DO 60 I = 1,N
60 Z = Z*RNDM(0)
DO I = 1,N
Z = Z*RNDM(0)
ENDDO
Y = Y-LOG(Z+1.D-7)
70 PO_RNDGAM = Y/ALAM

Expand Down
4 changes: 2 additions & 2 deletions src/ProgressBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void ProgressBar::setPosition(unsigned long position) {
std::string s = " - Finished at ";
s.append(ctime(&currentTime));
char fs[255];
std::sprintf(fs, "%c[%d;%dm Finished %c[%dm", 27, 1, 32, 27, 0);
std::snprintf(fs, 255, "%c[%d;%dm Finished %c[%dm", 27, 1, 32, 27, 0);
std::printf(stringTmpl.c_str(), fs, 100, "Needed",
int(tElapsed / 3600), (int(tElapsed) % 3600) / 60,
int(tElapsed) % 60, s.c_str());
Expand All @@ -68,7 +68,7 @@ void ProgressBar::setError() {
std::string s = " - Finished at ";
s.append(ctime(&currentTime));
char fs[255];
std::sprintf(fs, "%c[%d;%dm ERROR %c[%dm", 27, 1, 31, 27, 0);
std::snprintf(fs, 255, "%c[%d;%dm ERROR %c[%dm", 27, 1, 31, 27, 0);
std::printf(stringTmpl.c_str(), fs, _currentCount, "Needed",
int(tElapsed / 3600), (int(tElapsed) % 3600) / 60,
int(tElapsed) % 60, s.c_str());
Expand Down
9 changes: 5 additions & 4 deletions src/Random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ uint64_t Random::randInt64()
{
int64_t a = randInt();
int64_t b = randInt();
return (b + a << 32);
// a is shifted to the left to create a proper 64 bit integer
return (b + (a << 32));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the old one, but does not throw a warning

}


Expand Down Expand Up @@ -390,11 +391,11 @@ void Random::initialize(const uint32_t seed) {
void Random::reload() {
uint32_t *p = state;
int i;
for (i = N - M; i--; ++p)
for (i = +N - M; i--; ++p)
*p = twist(p[M], p[0], p[1]);
for (i = M; --i; ++p)
*p = twist(p[M - N], p[0], p[1]);
*p = twist(p[M - N], p[0], state[0]);
*p = twist(p[+M - N], p[0], p[1]);
*p = twist(p[+M - N], p[0], state[0]);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum-enum-conversion was removed, the + fixes that


left = N, pNext = state;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ Variant Variant::fromString(const std::string& s, Type t) {
std::string s;
v.push_back(s);
}
return Variant(v);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was missing for some reason

} else {
std::string msg;
msg += "fromString not implemented for type ";
Expand Down Expand Up @@ -1010,7 +1011,7 @@ Variant::operator const std::vector<Variant>&() const {

#define INT_FUNCTION(to_type, fun, to) \
to Variant::fun() const { \
switch (type) { \
switch (to_type) { \
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fatal typo

case Variant::TYPE_BOOL: \
return data._t_bool ? 1 : 0; \
break; \
Expand Down
2 changes: 1 addition & 1 deletion src/magneticField/CMZField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Vector3d CMZField::getMCField(const Vector3d& pos) const {//Field in molecular c
Bphi = - B1*exp(-z*z/Hc/Hc)*R/r;
}
else{
- B1*exp(-z*z/Hc/Hc)*R/r1*(3*r/r1- 2*r*r/r1*r1);
Bphi = - B1*exp(-z*z/Hc/Hc)*R/r1*(3*r/r1- 2*r*r/r1*r1);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was forgotten

}

b.x -= Bphi*sin(phi);
Expand Down
2 changes: 1 addition & 1 deletion src/magneticField/MagneticField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Vector3d &PeriodicMagneticField::getExtends() {
return extends;
}

void PeriodicMagneticField::setExtends(const Vector3d &origin) {
void PeriodicMagneticField::setExtends(const Vector3d &extends) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

propably a typo

this->extends = extends;
}

Expand Down
2 changes: 1 addition & 1 deletion src/magneticField/turbulentField/PlaneWaveTurbulence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

#ifdef ENABLE_FAST_WAVES
#include <immintrin.h>
#include <memory.h>
#include <memory>
Copy link
Copy Markdown
Contributor Author

@JanNiklasB JanNiklasB Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<memory> is more general, we had vocally reported issues in the past and <memory> seemed to fix them

#endif

namespace crpropa {
Expand Down
Loading
Loading