diff --git a/CMakeLists.txt b/CMakeLists.txt index 696338534..53c13006f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ if(GOMC_ASAN) set(CMAKE_CLANG_COMP_FLAGS ${CMAKE_CLANG_COMP_FLAGS} -fsanitize=address -fno-omit-frame-pointer) set(CMAKE_CLANG_CUDA_COMP_FLAGS ${CMAKE_CLANG_CUDA_COMP_FLAGS} "SHELL:-Xcompiler -fsanitize=address" "SHELL:-Xcompiler -fno-omit-frame-pointer") set(CMAKE_CLANG_LINK_FLAGS ${CMAKE_CLANG_LINK_FLAGS} -fsanitize=address -fno-omit-frame-pointer) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /fsanitize=address") endif() # find OpenMP and set it up @@ -94,12 +95,12 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_GPU_COMP_FLAGS "${CMAKE_CLANG_CUDA_COMP_FLAGS}") set(CMAKE_LINK_FLAGS "${CMAKE_CLANG_LINK_FLAGS}") elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_MSVC_OPENMP_FLAGS} /D DEBUG /MTd /Zi /Ob0 /Od /RTC1") - set(CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /D DEBUG /MTd /Zi /Ob0 /Od /RTC1") - set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /MT /O1 /Ob1 /D NDEBUG") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /MT /O2 /Ob2 /D NDEBUG") - set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /MT /O2 /Ob2 /D NDEBUG") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /MT /Zi /O2 /Ob1 /D NDEBUG") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_MSVC_OPENMP_FLAGS} /D DEBUG /MTd /Zi /Ob0 /Od /RTC1 /D_USE_MATH_DEFINES") + set(CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /D DEBUG /MTd /Zi /Ob0 /Od /RTC1 /D_USE_MATH_DEFINES") + set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /MT /O1 /Ob1 /D NDEBUG /D_USE_MATH_DEFINES") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /MT /O2 /D NDEBUG /D_USE_MATH_DEFINES") + set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /MT /O2 /D NDEBUG /D_USE_MATH_DEFINES") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT} ${CMAKE_MSVC_OPENMP_FLAGS} /MT /Zi /O2 /Ob1 /D NDEBUG /D_USE_MATH_DEFINES") endif() # Set Source and Header files diff --git a/lib/BasicTypes.h b/lib/BasicTypes.h index 18e7e87c7..b34ce54f8 100644 --- a/lib/BasicTypes.h +++ b/lib/BasicTypes.h @@ -8,7 +8,13 @@ along with this program, also can be found at #ifndef BASIC_TYPES_H #define BASIC_TYPES_H +// Standard way to get pi constant on most platforms +// Needs to be defined _before_ including cmath +// so that the PI constants come from cmath +#ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES +#endif + #include #include #include diff --git a/lib/GeomLib.h b/lib/GeomLib.h index d5b53e87d..f8642f5b4 100644 --- a/lib/GeomLib.h +++ b/lib/GeomLib.h @@ -8,12 +8,6 @@ along with this program, also can be found at #ifndef GEOM_LIB_H #define GEOM_LIB_H -// Standard way to get pi constant on most platforms -// Needs to be defined _before_ including cmath -// so that the PI constants come from cmath -//#define _USE_MATH_DEFINES -//#include //For sqrt, fabs, M_PI - #include "BasicTypes.h" //For uint, XYZ #include "XYZArray.h" #include //for double limits @@ -43,9 +37,6 @@ along with this program, also can be found at #define M_PI_4 \ 0.785398163397448309615660845819875721049292349843776455243736148076954101572 #endif -#ifndef M_2_SQRTPI -#define M_2_SQRTPI 2.0 / std::sqrt(M_PI) -#endif #define DEG_TO_RAD (M_PI / 180.0) #define RAD_TO_DEG (180.0 * M_1_PI) // Same as 180/PI diff --git a/src/FFAngles.h b/src/FFAngles.h index 4498202ec..81e7d4468 100644 --- a/src/FFAngles.h +++ b/src/FFAngles.h @@ -8,8 +8,6 @@ along with this program, also can be found at #ifndef FF_ANGLES_H #define FF_ANGLES_H -#include - #include "BasicTypes.h" //For "uint" #include "FFSetup.h" //For initialization data #include "NumLib.h" //For "Sq" function diff --git a/src/FFDihedrals.h b/src/FFDihedrals.h index c04eea04b..7a01ce676 100644 --- a/src/FFDihedrals.h +++ b/src/FFDihedrals.h @@ -8,8 +8,6 @@ along with this program, also can be found at #ifndef FF_DIHEDRALS_H #define FF_DIHEDRALS_H -#include //cos, pow - #include "BasicTypes.h" //For "uint" #include "FFConst.h" //GetRot #include "NumLib.h" //Sq diff --git a/src/Forcefield.cpp b/src/Forcefield.cpp index c07919130..38c98f41e 100644 --- a/src/Forcefield.cpp +++ b/src/Forcefield.cpp @@ -12,8 +12,6 @@ along with this program, also can be found at #include "FFSwitch.h" #include "FFSwitchMartini.h" #include "Setup.h" -#define _USE_MATH_DEFINES -#include Forcefield::Forcefield() { particles = NULL; diff --git a/src/MersenneTwister.h b/src/MersenneTwister.h index f6b53e9c7..66a31425d 100644 --- a/src/MersenneTwister.h +++ b/src/MersenneTwister.h @@ -58,6 +58,10 @@ #ifndef MERSENNETWISTER_H #define MERSENNETWISTER_H +#ifndef _USE_MATH_DEFINES +#define _USE_MATH_DEFINES +#endif + // Not thread safe (unless auto-initialization is avoided and each thread has // its own MTRand object) diff --git a/src/MoveSettings.cpp b/src/MoveSettings.cpp index 79dfd4736..ab4e8c9f3 100644 --- a/src/MoveSettings.cpp +++ b/src/MoveSettings.cpp @@ -6,9 +6,6 @@ along with this program, also can be found at . ********************************************************************************/ #include "MoveSettings.h" //header spec - -#include - #include "BoxDimensions.h" //For axis sizes #include "BoxDimensionsNonOrth.h" #include "GeomLib.h" //For M_PI diff --git a/src/PRNG.h b/src/PRNG.h index 1b5a549b7..c3172af28 100644 --- a/src/PRNG.h +++ b/src/PRNG.h @@ -11,8 +11,6 @@ along with this program, also can be found at #include #include #include -#define _USE_MATH_DEFINES -#include #include #include #include diff --git a/src/XYZArray.h b/src/XYZArray.h index 6479495db..055573d2f 100644 --- a/src/XYZArray.h +++ b/src/XYZArray.h @@ -12,7 +12,6 @@ along with this program, also can be found at #include //for memset, memcpy, etc. #include //for swap pre-c++11 compilers -#include #include //for swap (most modern compilers) #include "BasicTypes.h" diff --git a/src/cbmc/DCFreeCycle.cpp b/src/cbmc/DCFreeCycle.cpp index 5dc4eb307..92aa258b9 100644 --- a/src/cbmc/DCFreeCycle.cpp +++ b/src/cbmc/DCFreeCycle.cpp @@ -5,11 +5,7 @@ A copy of the MIT License can be found in License.txt along with this program, also can be found at . ********************************************************************************/ -#define _USE_MATH_DEFINES #include "DCFreeCycle.h" - -#include - #include "DCData.h" #include "Forcefield.h" #include "MolSetup.h" diff --git a/src/cbmc/DCFreeCycleSeed.cpp b/src/cbmc/DCFreeCycleSeed.cpp index f57a2aced..5eebde94e 100644 --- a/src/cbmc/DCFreeCycleSeed.cpp +++ b/src/cbmc/DCFreeCycleSeed.cpp @@ -5,11 +5,7 @@ A copy of the MIT License can be found in License.txt along with this program, also can be found at . ********************************************************************************/ -#define _USE_MATH_DEFINES #include "DCFreeCycleSeed.h" - -#include - #include "DCData.h" #include "Forcefield.h" #include "MolSetup.h" diff --git a/src/cbmc/DCFreeHedron.cpp b/src/cbmc/DCFreeHedron.cpp index 89aa59efc..c0a6432da 100644 --- a/src/cbmc/DCFreeHedron.cpp +++ b/src/cbmc/DCFreeHedron.cpp @@ -5,11 +5,7 @@ A copy of the MIT License can be found in License.txt along with this program, also can be found at . ********************************************************************************/ -#define _USE_MATH_DEFINES #include "DCFreeHedron.h" - -#include - #include "DCData.h" #include "Forcefield.h" #include "MolSetup.h" diff --git a/src/cbmc/DCFreeHedronSeed.cpp b/src/cbmc/DCFreeHedronSeed.cpp index b6d527069..ad2733ecb 100644 --- a/src/cbmc/DCFreeHedronSeed.cpp +++ b/src/cbmc/DCFreeHedronSeed.cpp @@ -5,11 +5,7 @@ A copy of the MIT License can be found in License.txt along with this program, also can be found at . ********************************************************************************/ -#define _USE_MATH_DEFINES #include "DCFreeHedronSeed.h" - -#include - #include "DCData.h" #include "Forcefield.h" #include "MolSetup.h" diff --git a/src/cbmc/DCHedron.cpp b/src/cbmc/DCHedron.cpp index da341ff55..9004f7841 100644 --- a/src/cbmc/DCHedron.cpp +++ b/src/cbmc/DCHedron.cpp @@ -5,11 +5,9 @@ A copy of the MIT License can be found in License.txt along with this program, also can be found at . ********************************************************************************/ -#define _USE_MATH_DEFINES #include "DCHedron.h" #include -#include #include #include "DCData.h" @@ -91,7 +89,7 @@ void DCHedron::SetBondOld(double const *bondLen, double const &anchBond) { anchorBondOld = anchBond; } -double DCHedron::GetWeight() { +double DCHedron::GetWeight() const { double result = 1; for (uint i = 0; i < nBonds; ++i) { result *= thetaWeight[i]; diff --git a/src/cbmc/DCHedron.h b/src/cbmc/DCHedron.h index 425174062..b454d5fd9 100644 --- a/src/cbmc/DCHedron.h +++ b/src/cbmc/DCHedron.h @@ -29,12 +29,12 @@ class DCHedron { uint Bonded(uint i) const { return bonded[i]; } double Theta(uint i) const { return theta[i]; } double Phi(uint i) const { return phi[i]; } - double GetWeight(); - double GetEnergy() { return bendEnergy; } - double GetNonBondedEn() { return oneThree; } - uint NumBond() { return nBonds; } - uint Focus() { return focus; } - uint Prev() { return prev; } + double GetWeight() const; + double GetEnergy() const { return bendEnergy; } + double GetNonBondedEn() const { return oneThree; } + uint NumBond() const { return nBonds; } + uint Focus() const { return focus; } + uint Prev() const { return prev; } // need to go to private uint bonded[MAX_BONDS]; diff --git a/src/cbmc/DCHedronCycle.cpp b/src/cbmc/DCHedronCycle.cpp index 92771a9e9..8925fdb55 100644 --- a/src/cbmc/DCHedronCycle.cpp +++ b/src/cbmc/DCHedronCycle.cpp @@ -5,11 +5,9 @@ A copy of the MIT License can be found in License.txt along with this program, also can be found at . ********************************************************************************/ -#define _USE_MATH_DEFINES #include "DCHedronCycle.h" #include -#include #include #include "DCData.h" diff --git a/src/cbmc/DCLinkedCycle.cpp b/src/cbmc/DCLinkedCycle.cpp index 11e89218a..2e9015f54 100644 --- a/src/cbmc/DCLinkedCycle.cpp +++ b/src/cbmc/DCLinkedCycle.cpp @@ -5,11 +5,9 @@ A copy of the MIT License can be found in License.txt along with this program, also can be found at . ********************************************************************************/ -#define _USE_MATH_DEFINES #include "DCLinkedCycle.h" #include -#include #include #include "DCData.h" diff --git a/src/cbmc/DCLinkedHedron.cpp b/src/cbmc/DCLinkedHedron.cpp index 038141293..9d60b8ad5 100644 --- a/src/cbmc/DCLinkedHedron.cpp +++ b/src/cbmc/DCLinkedHedron.cpp @@ -5,11 +5,9 @@ A copy of the MIT License can be found in License.txt along with this program, also can be found at . ********************************************************************************/ -#define _USE_MATH_DEFINES #include "DCLinkedHedron.h" #include -#include #include #include "DCData.h" diff --git a/src/cbmc/DCRotateCOM.cpp b/src/cbmc/DCRotateCOM.cpp index 19471438f..fc5cc0d4c 100644 --- a/src/cbmc/DCRotateCOM.cpp +++ b/src/cbmc/DCRotateCOM.cpp @@ -5,11 +5,7 @@ A copy of the MIT License can be found in License.txt along with this program, also can be found at . ********************************************************************************/ -#define _USE_MATH_DEFINES #include "DCRotateCOM.h" - -#include - #include "DCData.h" #include "Forcefield.h" #include "MolSetup.h" diff --git a/src/cbmc/TrialMol.cpp b/src/cbmc/TrialMol.cpp index 04393a87e..df256eb1e 100644 --- a/src/cbmc/TrialMol.cpp +++ b/src/cbmc/TrialMol.cpp @@ -8,15 +8,10 @@ along with this program, also can be found at #include "TrialMol.h" #include -#include //for sin, cos, atan2 #include //swap -#include "BasicTypes.h" #include "BoxDimensions.h" -#include "EnergyTypes.h" #include "GeomLib.h" //for Theta -#include "MoleculeKind.h" -#include "XYZArray.h" #ifndef NDEBUG #include #endif diff --git a/src/moves/IntraMoleculeExchange1.h b/src/moves/IntraMoleculeExchange1.h index f9a9cdf1a..154f910d8 100644 --- a/src/moves/IntraMoleculeExchange1.h +++ b/src/moves/IntraMoleculeExchange1.h @@ -8,8 +8,6 @@ along with this program, also can be found at #ifndef INTRAMOLECULEEXCHANGE1_H #define INTRAMOLECULEEXCHANGE1_H -#include - #include "GeomLib.h" #include "MoveBase.h" #include "TrialMol.h" diff --git a/src/moves/IntraMoleculeExchange2.h b/src/moves/IntraMoleculeExchange2.h index 542c393f5..74bd8a4a3 100644 --- a/src/moves/IntraMoleculeExchange2.h +++ b/src/moves/IntraMoleculeExchange2.h @@ -8,8 +8,6 @@ along with this program, also can be found at #ifndef INTRAMOLECULEEXCHANGE2_H #define INTRAMOLECULEEXCHANGE2_H -#include - #include "GeomLib.h" #include "IntraMoleculeExchange1.h" #include "TrialMol.h" diff --git a/src/moves/IntraMoleculeExchange3.h b/src/moves/IntraMoleculeExchange3.h index 49d0355fc..1bc0e8ab7 100644 --- a/src/moves/IntraMoleculeExchange3.h +++ b/src/moves/IntraMoleculeExchange3.h @@ -8,8 +8,6 @@ along with this program, also can be found at #ifndef INTRAMOLECULEEXCHANGE3_H #define INTRAMOLECULEEXCHANGE3_H -#include - #include "GeomLib.h" #include "IntraMoleculeExchange1.h" #include "TrialMol.h" diff --git a/src/moves/IntraTargetedSwap.h b/src/moves/IntraTargetedSwap.h index cc88b1f44..0715d36e3 100644 --- a/src/moves/IntraTargetedSwap.h +++ b/src/moves/IntraTargetedSwap.h @@ -8,9 +8,6 @@ along with this program, also can be found at #ifndef INTRATARGETEDSWAP_H #define INTRATARGETEDSWAP_H -#include -#include - #include "ConfigSetup.h" #include "FloydWarshallCycle.h" #include "GeomLib.h" @@ -19,6 +16,8 @@ along with this program, also can be found at #include "TargetedSwap.h" // for enum PBC Struct TSwapParam defined in there #include "TrialMol.h" +#include + struct BondList; class IntraTargetedSwap : public MoveBase { diff --git a/src/moves/MoleculeExchange1.h b/src/moves/MoleculeExchange1.h index 2eca32323..24018c593 100644 --- a/src/moves/MoleculeExchange1.h +++ b/src/moves/MoleculeExchange1.h @@ -9,9 +9,6 @@ along with this program, also can be found at #define MOLECULEEXCHANGE1_H #if ENSEMBLE == GCMC || ENSEMBLE == GEMC - -#include - #include "GeomLib.h" #include "MoveBase.h" #include "TrialMol.h" diff --git a/src/moves/MoleculeExchange2.h b/src/moves/MoleculeExchange2.h index 959165052..35dcb7761 100644 --- a/src/moves/MoleculeExchange2.h +++ b/src/moves/MoleculeExchange2.h @@ -9,9 +9,6 @@ along with this program, also can be found at #define MOLECULEEXCHANGE2_H #if ENSEMBLE == GCMC || ENSEMBLE == GEMC - -#include - #include "GeomLib.h" #include "MoleculeExchange1.h" #include "TrialMol.h" diff --git a/src/moves/MoleculeExchange3.h b/src/moves/MoleculeExchange3.h index c40c64b1c..6cbcaa2c5 100644 --- a/src/moves/MoleculeExchange3.h +++ b/src/moves/MoleculeExchange3.h @@ -9,9 +9,6 @@ along with this program, also can be found at #define MOLECULEEXCHANGE3_H #if ENSEMBLE == GCMC || ENSEMBLE == GEMC - -#include - #include "GeomLib.h" #include "MoleculeExchange1.h" #include "TrialMol.h" diff --git a/src/moves/MultiParticle.h b/src/moves/MultiParticle.h index f92400c5c..d74deae75 100644 --- a/src/moves/MultiParticle.h +++ b/src/moves/MultiParticle.h @@ -8,9 +8,6 @@ along with this program, also can be found at #ifndef MULTIPARTICLE_H #define MULTIPARTICLE_H -#include -#include - #include "MoveBase.h" #include "Random123Wrapper.h" #include "StaticVals.h" @@ -19,6 +16,7 @@ along with this program, also can be found at #include "TransformParticlesCUDAKernel.cuh" #include "VariablesCUDA.cuh" #endif +#include #define MIN_FORCE 1E-12 #define MAX_FORCE 30 diff --git a/src/moves/MultiParticleBrownianMotion.h b/src/moves/MultiParticleBrownianMotion.h index 68c095cbb..d55552a6a 100644 --- a/src/moves/MultiParticleBrownianMotion.h +++ b/src/moves/MultiParticleBrownianMotion.h @@ -8,8 +8,6 @@ along with this program, also can be found at #ifndef MULTIPARTICLEBROWNIANMOTION_H #define MULTIPARTICLEBROWNIANMOTION_H -#include - #include "MoveBase.h" #include "Random123Wrapper.h" #include "StaticVals.h" diff --git a/src/moves/TargetedSwap.h b/src/moves/TargetedSwap.h index a4d2df58b..827641ced 100644 --- a/src/moves/TargetedSwap.h +++ b/src/moves/TargetedSwap.h @@ -40,7 +40,6 @@ struct TSwapParam { #if ENSEMBLE == GCMC || ENSEMBLE == GEMC -#include #include #include "ConfigSetup.h"