From 47f0b97a5b116ff045200cbd5d172a4069a7a878 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Wed, 17 Jan 2024 13:12:46 -0500 Subject: [PATCH 01/44] Replace M_PI with PI constant for compiling on Windows with Intel. --- src/external/quartic_solver.cpp | 11 +++++++---- src/mesh.cpp | 4 ++-- src/plot.cpp | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/external/quartic_solver.cpp b/src/external/quartic_solver.cpp index 0b280e83c29..c42f4e1e679 100644 --- a/src/external/quartic_solver.cpp +++ b/src/external/quartic_solver.cpp @@ -4,6 +4,9 @@ #include #include +// TODO: replace with when we go for C++20 +constexpr double PI {3.141592653589793238462643383279502884L}; + namespace oqs { // pow(DBL_MAX,1.0/3.0)/1.618034; @@ -35,10 +38,10 @@ double solve_cubic_analytic_depressed_handle_inf(double b, double c) if (KK < 0.0) { double sqrtQ = std::sqrt(Q); double theta = std::acos((R / std::abs(Q)) / sqrtQ); - if (2.0 * theta < M_PI) + if (2.0 * theta < PI) return -2.0 * sqrtQ * std::cos(theta / 3.0); else - return -2.0 * sqrtQ * std::cos((theta + 2.0 * M_PI) / 3.0); + return -2.0 * sqrtQ * std::cos((theta + 2.0 * PI) / 3.0); } else { double A; if (std::abs(Q) < std::abs(R)) @@ -67,10 +70,10 @@ double solve_cubic_analytic_depressed(double b, double c) if (R2 < Q3) { double theta = std::acos(R / std::sqrt(Q3)); double sqrtQ = -2.0 * std::sqrt(Q); - if (2.0 * theta < M_PI) + if (2.0 * theta < PI) return sqrtQ * std::cos(theta / 3.0); else - return sqrtQ * std::cos((theta + 2.0 * M_PI) / 3.0); + return sqrtQ * std::cos((theta + 2.0 * PI) / 3.0); } else { double A = -std::copysign(1.0, R) * std::pow(std::abs(R) + std::sqrt(R2 - Q3), 1.0 / 3.0); diff --git a/src/mesh.cpp b/src/mesh.cpp index 34510b614e4..b4fc78dd6a2 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -1079,7 +1079,7 @@ StructuredMesh::MeshIndex CylindricalMesh::get_indices( } else { mapped_r[1] = std::atan2(r.y, r.x); if (mapped_r[1] < 0) - mapped_r[1] += 2 * M_PI; + mapped_r[1] += 2 * PI; } MeshIndex idx = StructuredMesh::get_indices(mapped_r, in_mesh); @@ -1363,7 +1363,7 @@ StructuredMesh::MeshIndex SphericalMesh::get_indices( mapped_r[1] = std::acos(r.z / mapped_r.x); mapped_r[2] = std::atan2(r.y, r.x); if (mapped_r[2] < 0) - mapped_r[2] += 2 * M_PI; + mapped_r[2] += 2 * PI; } MeshIndex idx = StructuredMesh::get_indices(mapped_r, in_mesh); diff --git a/src/plot.cpp b/src/plot.cpp index bf733cff48f..6040229c3fc 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -1192,7 +1192,7 @@ void ProjectionPlot::create_output() const // Now we convert to the polar coordinate system with the polar angle // measuring the angle from the vector up_. Phi is the rotation about up_. For // now, up_ is hard-coded to be +z. - constexpr double DEGREE_TO_RADIAN = M_PI / 180.0; + constexpr double DEGREE_TO_RADIAN = PI / 180.0; double horiz_fov_radians = horizontal_field_of_view_ * DEGREE_TO_RADIAN; double p0 = static_cast(pixels_[0]); double p1 = static_cast(pixels_[1]); @@ -1261,7 +1261,7 @@ void ProjectionPlot::create_output() const double this_phi = -horiz_fov_radians / 2.0 + dphi * horiz + 0.5 * dphi; double this_mu = - -vert_fov_radians / 2.0 + dmu * vert + M_PI / 2.0 + 0.5 * dmu; + -vert_fov_radians / 2.0 + dmu * vert + PI / 2.0 + 0.5 * dmu; Direction camera_local_vec; camera_local_vec.x = std::cos(this_phi) * std::sin(this_mu); camera_local_vec.y = std::sin(this_phi) * std::sin(this_mu); From 6f6ebae66b2981009c22e0c753e3414909ee13a6 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Wed, 17 Jan 2024 14:30:02 -0500 Subject: [PATCH 02/44] Fix reading in file paths on Windows for xs data. --- src/cross_sections.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/cross_sections.cpp b/src/cross_sections.cpp index a7bd86095b3..e936b34bcb1 100644 --- a/src/cross_sections.cpp +++ b/src/cross_sections.cpp @@ -37,6 +37,19 @@ std::map library_map; vector libraries; } // namespace data + +//============================================================================== +// Separator strings for Windows and Unix-like systems +//============================================================================== + +namespace details { +#if defined(_WIN32) || defined(_WIN64) + const char sep_char[] = "\\"; // Windows separator string +#else + const char sep_char[] = "/"; // Unix-like separator string +#endif +} + //============================================================================== // Library methods //============================================================================== @@ -72,12 +85,12 @@ Library::Library(pugi::xml_node node, const std::string& directory) } std::string path = get_node_value(node, "path"); - if (starts_with(path, "/")) { + if (starts_with(path, details::sep_char)) { path_ = path; - } else if (ends_with(directory, "/")) { + } else if (ends_with(directory, details::sep_char)) { path_ = directory + path; } else if (!directory.empty()) { - path_ = directory + "/" + path; + path_ = directory + details::sep_char + path; } else { path_ = path; } @@ -144,10 +157,10 @@ void read_cross_sections_xml(pugi::xml_node root) settings::path_cross_sections = get_node_value(root, "cross_sections"); // If no '/' found, the file is probably in the input directory - auto pos = settings::path_cross_sections.rfind("/"); + auto pos = settings::path_cross_sections.rfind(details::sep_char); if (pos == std::string::npos && !settings::path_input.empty()) { settings::path_cross_sections = - settings::path_input + "/" + settings::path_cross_sections; + settings::path_input + details::sep_char + settings::path_cross_sections; } } @@ -307,7 +320,7 @@ void read_ce_cross_sections_xml() // directory in which the cross_sections.xml file resides // TODO: Use std::filesystem functionality when C++17 is adopted - auto pos = filename.rfind("/"); + auto pos = filename.rfind(details::sep_char); if (pos == std::string::npos) { // No '\\' found, so the file must be in the same directory as // materials.xml From 9eff74667bb8bcb30893f4a551e5c88c7fc20a48 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Wed, 17 Jan 2024 14:31:21 -0500 Subject: [PATCH 03/44] Makes cmake compatible with Windows/Intel build. --- CMakeLists.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf3555d8433..aea8ad4aad7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,9 +189,6 @@ endif() # Set compile/link flags based on which compiler is being used #=============================================================================== -# Skip for Visual Studio which has its own configurations through GUI -if(NOT MSVC) - if(OPENMC_USE_OPENMP) find_package(OpenMP) if(OPENMP_FOUND) @@ -201,23 +198,24 @@ if(OPENMC_USE_OPENMP) endif() endif() -set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# Skip for Visual Studio which has its own configurations through GUI +if(NOT MSVC) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) -if(OPENMC_ENABLE_PROFILE) - list(APPEND cxxflags -g -fno-omit-frame-pointer) -endif() + if(OPENMC_ENABLE_PROFILE) + list(APPEND cxxflags -g -fno-omit-frame-pointer) + endif() -if(OPENMC_ENABLE_COVERAGE) - list(APPEND cxxflags --coverage) - list(APPEND ldflags --coverage) + if(OPENMC_ENABLE_COVERAGE) + list(APPEND cxxflags --coverage) + list(APPEND ldflags --coverage) + endif() endif() # Show flags being used message(STATUS "OpenMC C++ flags: ${cxxflags}") message(STATUS "OpenMC Linker flags: ${ldflags}") -endif() - #=============================================================================== # Update git submodules as needed #=============================================================================== @@ -449,7 +447,9 @@ if(MSVC) # To use the shared HDF5 libraries on Windows, the H5_BUILT_AS_DYNAMIC_LIB # compile definition must be specified. - target_compile_definitions(libopenmc PRIVATE -DH5_BUILT_AS_DYNAMIC_LIB) + if (NOT HDF5_USE_STATIC_LIBRARIES) + target_compile_definitions(libopenmc PRIVATE -DH5_BUILT_AS_DYNAMIC_LIB) + endif() else() add_library(libopenmc SHARED ${libopenmc_SOURCES}) endif() From d711dde244ba8c621225f9113238223845a96a23 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Wed, 17 Jan 2024 15:34:25 -0500 Subject: [PATCH 04/44] Updates for MSVC/Visual Studio compiler. --- CMakeLists.txt | 5 +++++ include/openmc/event.h | 2 ++ include/openmc/geometry.h | 2 +- include/openmc/mesh.h | 4 ++-- include/openmc/shared_array.h | 10 ++++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aea8ad4aad7..390572177a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,6 +195,11 @@ if(OPENMC_USE_OPENMP) # In CMake 3.9+, can use the OpenMP::OpenMP_CXX imported target list(APPEND cxxflags ${OpenMP_CXX_FLAGS}) list(APPEND ldflags ${OpenMP_CXX_FLAGS}) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Special flag to get OpenMP to work on Windows + list(APPEND cxxflags /openmp:llvm) + endif() endif() endif() diff --git a/include/openmc/event.h b/include/openmc/event.h index 2d215a10e46..6004d0ffbcd 100644 --- a/include/openmc/event.h +++ b/include/openmc/event.h @@ -7,6 +7,8 @@ #include "openmc/particle.h" #include "openmc/shared_array.h" +#include + namespace openmc { //============================================================================== diff --git a/include/openmc/geometry.h b/include/openmc/geometry.h index 107cc7d1f3e..2e31f7c49e1 100644 --- a/include/openmc/geometry.h +++ b/include/openmc/geometry.h @@ -10,7 +10,7 @@ namespace openmc { -class BoundaryInfo; +struct BoundaryInfo; class GeometryState; //============================================================================== diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index de556321f22..74504f7b955 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -472,7 +472,7 @@ class CylindricalMesh : public PeriodicStructuredMesh { inline int sanitize_angular_index(int idx, bool full, int N) const { - if ((idx > 0) and (idx <= N)) { + if ((idx > 0) && (idx <= N)) { return idx; } else if (full) { return (idx + N - 1) % N + 1; @@ -534,7 +534,7 @@ class SphericalMesh : public PeriodicStructuredMesh { inline int sanitize_angular_index(int idx, bool full, int N) const { - if ((idx > 0) and (idx <= N)) { + if ((idx > 0) && (idx <= N)) { return idx; } else if (full) { return (idx + N - 1) % N + 1; diff --git a/include/openmc/shared_array.h b/include/openmc/shared_array.h index 7e9ef28c580..e18da53507b 100644 --- a/include/openmc/shared_array.h +++ b/include/openmc/shared_array.h @@ -72,13 +72,23 @@ class SharedArray { { // Atomically capture the index we want to write to int64_t idx; +#if defined(_WIN32) || defined(_WIN64) +#pragma omp atomic capture + idx = size_++; +#else #pragma omp atomic capture seq_cst idx = size_++; +#endif // Check that we haven't written off the end of the array if (idx >= capacity_) { +#if defined(_WIN32) || defined(_WIN64) +#pragma omp atomic write + size_ = capacity_; +#else #pragma omp atomic write seq_cst size_ = capacity_; +#endif return -1; } From c2fc162132d330a677bd21b1581776675a38c98f Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Thu, 18 Jan 2024 20:59:51 -0500 Subject: [PATCH 05/44] Make sure atomic has seq_cst with Intel compiler on Windows --- include/openmc/shared_array.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/openmc/shared_array.h b/include/openmc/shared_array.h index e18da53507b..031a42e9eb7 100644 --- a/include/openmc/shared_array.h +++ b/include/openmc/shared_array.h @@ -72,7 +72,7 @@ class SharedArray { { // Atomically capture the index we want to write to int64_t idx; -#if defined(_WIN32) || defined(_WIN64) +#if _MSC_VER && !__INTEL_COMPILER #pragma omp atomic capture idx = size_++; #else @@ -82,7 +82,7 @@ class SharedArray { // Check that we haven't written off the end of the array if (idx >= capacity_) { -#if defined(_WIN32) || defined(_WIN64) +#if _MSC_VER && !__INTEL_COMPILER #pragma omp atomic write size_ = capacity_; #else From 722c6e6dad91996f06db559adb04978e439400d4 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Thu, 18 Jan 2024 21:02:22 -0500 Subject: [PATCH 06/44] Adds macros to export global variable symbols on Windows --- include/openmc/capi.h | 11 ++++++++++- include/openmc/constants.h | 13 +++++++++++++ include/openmc/message_passing.h | 3 ++- include/openmc/settings.h | 2 +- include/openmc/tallies/filter.h | 2 +- src/error.cpp | 2 +- src/message_passing.cpp | 2 +- src/settings.cpp | 2 +- src/tallies/filter.cpp | 2 +- 9 files changed, 31 insertions(+), 8 deletions(-) diff --git a/include/openmc/capi.h b/include/openmc/capi.h index a444814f585..ee120de68b0 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -273,7 +273,16 @@ extern int OPENMC_E_PHYSICS; extern int OPENMC_E_WARNING; // Global variables -extern char openmc_err_msg[256]; + +#if _MSC_VER && OPENMC_WIN_COMPILE +#define DllExport __declspec( dllexport ) +#elif _MSC_VER +#define DllExport __declspec( dllimport ) +#else +#define DllExport +#endif + +extern char DllExport openmc_err_msg[256]; #ifdef __cplusplus } diff --git a/include/openmc/constants.h b/include/openmc/constants.h index ba558b04089..e7d84c4f450 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -345,6 +345,19 @@ enum class RunMode { enum class GeometryType { CSG, DAG }; +//============================================================================== +// Shared Libraries on Windows need the functions/classes/variables to be +// exposed to be declared with this special keyword "__declspec( dllexport )". +// We use a macro for this, so that it is only exported on Windows. + +#if _MSC_VER && OPENMC_WIN_COMPILE +#define DllExport __declspec( dllexport ) +#elif _MSC_VER +#define DllExport __declspec( dllimport ) +#else +#define DllExport +#endif + } // namespace openmc #endif // OPENMC_CONSTANTS_H diff --git a/include/openmc/message_passing.h b/include/openmc/message_passing.h index a1641a9069e..14b9a7a9315 100644 --- a/include/openmc/message_passing.h +++ b/include/openmc/message_passing.h @@ -7,6 +7,7 @@ #include #endif +#include "openmc/constants.h" #include "openmc/vector.h" namespace openmc { @@ -14,7 +15,7 @@ namespace mpi { extern int rank; extern int n_procs; -extern bool master; +extern bool DllExport master; #ifdef OPENMC_MPI extern MPI_Datatype source_site; diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 69a8d7d13be..39ab5a90e32 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -113,7 +113,7 @@ extern double res_scat_energy_min; //!< Min energy in [eV] for res. upscattering extern double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering extern vector res_scat_nuclides; //!< Nuclides using res. upscattering treatment -extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.) +extern RunMode DllExport run_mode; //!< Run mode (eigenvalue, fixed src, etc.) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written extern std::unordered_set diff --git a/include/openmc/tallies/filter.h b/include/openmc/tallies/filter.h index dc5872ce670..eaaab3c5930 100644 --- a/include/openmc/tallies/filter.h +++ b/include/openmc/tallies/filter.h @@ -147,7 +147,7 @@ class Filter { namespace model { extern "C" int32_t n_filters; -extern std::unordered_map filter_map; +extern std::unordered_map DllExport filter_map; extern vector> tally_filters; } // namespace model diff --git a/src/error.cpp b/src/error.cpp index 566950a973c..3110081752a 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -30,7 +30,7 @@ int OPENMC_E_PHYSICS {-10}; int OPENMC_E_WARNING {1}; // Error message -char openmc_err_msg[256]; +char DllExport openmc_err_msg[256]; //============================================================================== // Functions diff --git a/src/message_passing.cpp b/src/message_passing.cpp index 374c1aa7257..9da88631009 100644 --- a/src/message_passing.cpp +++ b/src/message_passing.cpp @@ -5,7 +5,7 @@ namespace mpi { int rank {0}; int n_procs {1}; -bool master {true}; +bool DllExport master {true}; #ifdef OPENMC_MPI MPI_Comm intracomm {MPI_COMM_NULL}; diff --git a/src/settings.cpp b/src/settings.cpp index a5256c9c26d..730db684408 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -111,7 +111,7 @@ ResScatMethod res_scat_method {ResScatMethod::rvs}; double res_scat_energy_min {0.01}; double res_scat_energy_max {1000.0}; vector res_scat_nuclides; -RunMode run_mode {RunMode::UNSET}; +RunMode DllExport run_mode {RunMode::UNSET}; std::unordered_set sourcepoint_batch; std::unordered_set statepoint_batch; std::unordered_set source_write_surf_id; diff --git a/src/tallies/filter.cpp b/src/tallies/filter.cpp index 5fae4cf600b..eb4b158327f 100644 --- a/src/tallies/filter.cpp +++ b/src/tallies/filter.cpp @@ -45,7 +45,7 @@ namespace openmc { //============================================================================== namespace model { -std::unordered_map filter_map; +std::unordered_map DllExport filter_map; vector> tally_filters; } // namespace model From ae0b297051f745f5ceb9ecb204fb0845fcbe9c2a Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Thu, 18 Jan 2024 21:03:46 -0500 Subject: [PATCH 07/44] Updates Python API to find the dynamic libopenmc.dll on Windows --- openmc/lib/__init__.py | 4 +++- setup.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/openmc/lib/__init__.py b/openmc/lib/__init__.py index 0e5ad92feb9..c5a8fb9bda4 100644 --- a/openmc/lib/__init__.py +++ b/openmc/lib/__init__.py @@ -20,7 +20,9 @@ # Determine shared-library suffix -if sys.platform == 'darwin': +if sys.platform == 'win32': + _suffix = 'dll' +elif sys.platform == 'darwin': _suffix = 'dylib' else: _suffix = 'so' diff --git a/setup.py b/setup.py index 29c129d7b28..643818f5149 100755 --- a/setup.py +++ b/setup.py @@ -9,7 +9,9 @@ # Determine shared library suffix -if sys.platform == 'darwin': +if sys.platform == 'win32': + suffix = 'dll' +elif sys.platform == 'darwin': suffix = 'dylib' else: suffix = 'so' @@ -73,10 +75,12 @@ 'sphinxcontrib-svg2pdfconverter', 'sphinx-rtd-theme'], 'test': ['pytest', 'pytest-cov', 'colorama'], 'vtk': ['vtk'], - }, - # Cython is used to add resonance reconstruction and fast float_endf - 'ext_modules': cythonize('openmc/data/*.pyx'), - 'include_dirs': [np.get_include()] + } } +if sys.platform != 'win32': + # Cython is used to add resonance reconstruction and fast float_endf + kwargs['ext_modules'] = cythonize('openmc/data/*.pyx') + kwargs['include_dirs'] = [np.get_include()] + setup(**kwargs) From 7c832e25fdc50e48fb04ea4467540c4f21301925 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Thu, 18 Jan 2024 21:09:11 -0500 Subject: [PATCH 08/44] Adds logic to generat dll on Windows and moves to more recent xtensor version --- CMakeLists.txt | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 390572177a8..50b9a5cc67d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -277,9 +277,30 @@ endif() find_package_write_status(xtensor) if (NOT xtensor_FOUND) - add_subdirectory(vendor/xtl) - set(xtl_DIR ${CMAKE_CURRENT_BINARY_DIR}/vendor/xtl) - add_subdirectory(vendor/xtensor) + # The version of xtensor which is in the submodules appears to have a memory + # bug on Windows machines. For now, I am just going to comment out using the + # submodules, and will get a recent version of xtensor with fetch content. + #add_subdirectory(vendor/xtl) + #set(xtl_DIR ${CMAKE_CURRENT_BINARY_DIR}/vendor/xtl) + #add_subdirectory(vendor/xtensor) + + include(FetchContent) + + # Get XTL + message(STATUS "Downloading xtl v0.7.7") + FetchContent_Declare(xtl + GIT_REPOSITORY https://github.com/xtensor-stack/xtl.git + GIT_TAG 0.7.7 + ) + FetchContent_MakeAvailable(xtl) + + # Get XTENSOR + message(STATUS "Downloading xtensor v0.24.7") + FetchContent_Declare(xtensor + GIT_REPOSITORY https://github.com/xtensor-stack/xtensor.git + GIT_TAG 0.24.7 + ) + FetchContent_MakeAvailable(xtensor) endif() #=============================================================================== @@ -445,22 +466,31 @@ list(APPEND libopenmc_SOURCES src/external/quartic_solver.cpp src/external/Faddeeva.cc) -# For Visual Studio compilers +#=============================================================================== +# openmc library +#=============================================================================== +add_library(libopenmc SHARED ${libopenmc_SOURCES}) +add_library(OpenMC::libopenmc ALIAS libopenmc) + +# For compilers on Windows if(MSVC) - # Use static library (otherwise explicit symbol portings are needed) - add_library(libopenmc STATIC ${libopenmc_SOURCES}) + # This ensures that all function/class method symbols are exported, without + # needing to add the export macros in the source. + set_target_properties(libopenmc PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + + # This compile definition is needed to make sure that the correct macros + # are used for exporting symbols in the dll. While the + # WINDOWS_EXPORT_ALL_SYMBOLS exports all function/class symbols, it + # unfortunately does not work on global variables, which still need the macro. + target_compile_definitions(libopenmc PRIVATE -DOPENMC_WIN_COMPILE) # To use the shared HDF5 libraries on Windows, the H5_BUILT_AS_DYNAMIC_LIB # compile definition must be specified. if (NOT HDF5_USE_STATIC_LIBRARIES) target_compile_definitions(libopenmc PRIVATE -DH5_BUILT_AS_DYNAMIC_LIB) endif() -else() - add_library(libopenmc SHARED ${libopenmc_SOURCES}) endif() -add_library(OpenMC::libopenmc ALIAS libopenmc) - # Avoid vs error lnk1149 :output filename matches input filename if(NOT MSVC) set_target_properties(libopenmc PROPERTIES OUTPUT_NAME openmc) From 45e7e198948c97e6415222f385453197d96b0294 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Thu, 18 Jan 2024 21:54:32 -0500 Subject: [PATCH 09/44] Fix python parallel bug on Windows in depletion. --- openmc/deplete/pool.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openmc/deplete/pool.py b/openmc/deplete/pool.py index 27ecaa4dd8b..8627d8f5028 100644 --- a/openmc/deplete/pool.py +++ b/openmc/deplete/pool.py @@ -10,10 +10,17 @@ from openmc.mpi import comm +import sys + # Configurable switch that enables / disables the use of # multiprocessing routines during depletion USE_MULTIPROCESSING = True +# Not sure why, but using multiprocessing on Windows leads to many transport +# simualtions being run over eachother and leads to catastrophe. +if sys.platform == 'win32': + USE_MULTIPROCESSING = False + # Allow user to override the number of worker processes to use for depletion # calculations NUM_PROCESSES = None From a6eee380d579bac3979cdf5307de3e830d9ec619 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Fri, 19 Jan 2024 12:12:13 -0500 Subject: [PATCH 10/44] Update file_utils tests for Windows --- tests/cpp_unit_tests/test_file_utils.cpp | 28 +++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/cpp_unit_tests/test_file_utils.cpp b/tests/cpp_unit_tests/test_file_utils.cpp index 3b7a74346bd..3aac7a8d07b 100644 --- a/tests/cpp_unit_tests/test_file_utils.cpp +++ b/tests/cpp_unit_tests/test_file_utils.cpp @@ -5,6 +5,18 @@ using namespace openmc; TEST_CASE("Test get_file_extension") { +#if defined(_WIN32) || defined(_WIN64) + REQUIRE(get_file_extension("rememberthealamo.png") == "png"); + REQUIRE(get_file_extension("statepoint.20.h5") == "h5"); + REQUIRE(get_file_extension("wEiRDNaa_ame.h4") == "h4"); + REQUIRE(get_file_extension("has_directory\\asdf.20.h5") == "h5"); + REQUIRE(get_file_extension("wasssssup_lol") == ""); + REQUIRE(get_file_extension("has_directory\\secret_file") == ""); + REQUIRE(get_file_extension("lovely.dir\\extensionless_file") == ""); + REQUIRE(get_file_extension("lovely.dir\\statepoint.20.h5") == "h5"); + REQUIRE(get_file_extension("lovely.dir\\asdf123.cpp") == "cpp"); + +#else REQUIRE(get_file_extension("rememberthealamo.png") == "png"); REQUIRE(get_file_extension("statepoint.20.h5") == "h5"); REQUIRE(get_file_extension("wEiRDNaa_ame.h4") == "h4"); @@ -14,19 +26,33 @@ TEST_CASE("Test get_file_extension") REQUIRE(get_file_extension("lovely.dir/extensionless_file") == ""); REQUIRE(get_file_extension("lovely.dir/statepoint.20.h5") == "h5"); REQUIRE(get_file_extension("lovely.dir/asdf123.cpp") == "cpp"); +#endif } TEST_CASE("Test dir_exists") -{ +{ +#if defined(_WIN32) || defined(_WIN64) + // If this doesn't exist on a Windows system, I have no clue what is happening + REQUIRE(dir_exists("C:\\")); + + // if this exists on your system... you deserve for this test to fail + REQUIRE(!dir_exists("C:\\asdfa\\asdfasdf\\asdgasodgosuihasjkgh")); +#else // not sure how to test this when running on windows? REQUIRE(dir_exists("/")); // if this exists on your system... you deserve for this test to fail REQUIRE(!dir_exists("/asdfa/asdfasdf/asdgasodgosuihasjkgh/")); +#endif } TEST_CASE("Test file_exists") { +#if defined(_WIN32) || defined(_WIN64) + // Note: not clear how to portably test where a file should exist. + REQUIRE(!file_exists("C:\\should_not_exist\\really_do_not_make_this_please")); +#else // Note: not clear how to portably test where a file should exist. REQUIRE(!file_exists("./should_not_exist/really_do_not_make_this_please")); +#endif } From a1bcd55c96cff64952834c49d02f56a7cdf14f9c Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Fri, 19 Jan 2024 16:14:55 -0500 Subject: [PATCH 11/44] Export some more global variables in the DLL --- include/openmc/dagmc.h | 4 +++- include/openmc/mcpl_interface.h | 3 ++- include/openmc/mesh.h | 3 ++- include/openmc/ncrystal_interface.h | 3 ++- src/dagmc.cpp | 4 ++-- src/mcpl_interface.cpp | 4 ++-- src/mesh.cpp | 4 ++-- src/ncrystal_interface.cpp | 4 ++-- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/openmc/dagmc.h b/include/openmc/dagmc.h index 0b23e567abc..8f43e6ad2c3 100644 --- a/include/openmc/dagmc.h +++ b/include/openmc/dagmc.h @@ -1,8 +1,10 @@ #ifndef OPENMC_DAGMC_H #define OPENMC_DAGMC_H +#include "openmc/constants.h" // Needed for DllExport + namespace openmc { -extern "C" const bool DAGMC_ENABLED; +extern "C" const bool DllExport DAGMC_ENABLED; } // always include the XML interface header diff --git a/include/openmc/mcpl_interface.h b/include/openmc/mcpl_interface.h index 1f0c94d6dec..c97243c2e3f 100644 --- a/include/openmc/mcpl_interface.h +++ b/include/openmc/mcpl_interface.h @@ -1,6 +1,7 @@ #ifndef OPENMC_MCPL_INTERFACE_H #define OPENMC_MCPL_INTERFACE_H +#include "openmc/constants.h" #include "openmc/particle_data.h" #include "openmc/vector.h" @@ -14,7 +15,7 @@ namespace openmc { // Constants //============================================================================== -extern "C" const bool MCPL_ENABLED; +extern "C" const bool DllExport MCPL_ENABLED; //============================================================================== // Functions diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 74504f7b955..ebcb4bbf93c 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -10,6 +10,7 @@ #include "pugixml.hpp" #include "xtensor/xtensor.hpp" +#include "openmc/constants.h" // for DllExport #include "openmc/error.h" #include "openmc/memory.h" // for unique_ptr #include "openmc/particle.h" @@ -48,7 +49,7 @@ enum class ElementType { UNSUPPORTED = -1, LINEAR_TET, LINEAR_HEX }; // Global variables //============================================================================== -extern "C" const bool LIBMESH_ENABLED; +extern "C" const bool DllExport LIBMESH_ENABLED; class Mesh; diff --git a/include/openmc/ncrystal_interface.h b/include/openmc/ncrystal_interface.h index 5a3882df9c3..4620952b1f0 100644 --- a/include/openmc/ncrystal_interface.h +++ b/include/openmc/ncrystal_interface.h @@ -6,6 +6,7 @@ #include "NCrystal/NCrystal.hh" #endif +#include "openmc/constants.h" // Needed for DllExport #include "openmc/particle.h" #include // for uint64_t @@ -18,7 +19,7 @@ namespace openmc { // Constants //============================================================================== -extern "C" const bool NCRYSTAL_ENABLED; +extern "C" const bool DllExport NCRYSTAL_ENABLED; //! Energy in [eV] to switch between NCrystal and ENDF constexpr double NCRYSTAL_MAX_ENERGY {5.0}; diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 56722fde664..035767049dc 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -24,9 +24,9 @@ namespace openmc { #ifdef DAGMC -const bool DAGMC_ENABLED = true; +const bool DllExport DAGMC_ENABLED = true; #else -const bool DAGMC_ENABLED = false; +const bool DllExport DAGMC_ENABLED = false; #endif } // namespace openmc diff --git a/src/mcpl_interface.cpp b/src/mcpl_interface.cpp index 5c3df026ce5..5297ec569ff 100644 --- a/src/mcpl_interface.cpp +++ b/src/mcpl_interface.cpp @@ -22,9 +22,9 @@ namespace openmc { //============================================================================== #ifdef OPENMC_MCPL -const bool MCPL_ENABLED = true; +const bool DllExport MCPL_ENABLED = true; #else -const bool MCPL_ENABLED = false; +const bool DllExport MCPL_ENABLED = false; #endif //============================================================================== diff --git a/src/mesh.cpp b/src/mesh.cpp index b4fc78dd6a2..806be36b23e 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -46,9 +46,9 @@ namespace openmc { //============================================================================== #ifdef LIBMESH -const bool LIBMESH_ENABLED = true; +const bool DllExport LIBMESH_ENABLED = true; #else -const bool LIBMESH_ENABLED = false; +const bool DllExport LIBMESH_ENABLED = false; #endif namespace model { diff --git a/src/ncrystal_interface.cpp b/src/ncrystal_interface.cpp index b39f62d9020..9cb26d4d240 100644 --- a/src/ncrystal_interface.cpp +++ b/src/ncrystal_interface.cpp @@ -11,9 +11,9 @@ namespace openmc { //============================================================================== #ifdef NCRYSTAL -const bool NCRYSTAL_ENABLED = true; +const bool DllExport NCRYSTAL_ENABLED = true; #else -const bool NCRYSTAL_ENABLED = false; +const bool DllExport NCRYSTAL_ENABLED = false; #endif //============================================================================== From 5f5bec81e3d9e518fc56b3f55564a8bea0d500b3 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 25 Mar 2024 20:13:49 -0400 Subject: [PATCH 12/44] Fixes formating --- include/openmc/capi.h | 4 ++-- include/openmc/constants.h | 4 ++-- include/openmc/mcpl_interface.h | 2 +- include/openmc/ncrystal_interface.h | 15 +++------------ include/openmc/settings.h | 2 +- src/cross_sections.cpp | 11 +++++------ tests/cpp_unit_tests/test_file_utils.cpp | 2 +- 7 files changed, 15 insertions(+), 25 deletions(-) diff --git a/include/openmc/capi.h b/include/openmc/capi.h index b2996bfcecf..6e4511cdf3b 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -281,9 +281,9 @@ extern int OPENMC_E_WARNING; // Global variables #if _MSC_VER && OPENMC_WIN_COMPILE -#define DllExport __declspec( dllexport ) +#define DllExport __declspec(dllexport) #elif _MSC_VER -#define DllExport __declspec( dllimport ) +#define DllExport __declspec(dllimport) #else #define DllExport #endif diff --git a/include/openmc/constants.h b/include/openmc/constants.h index e7d84c4f450..dbe52d33126 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -351,9 +351,9 @@ enum class GeometryType { CSG, DAG }; // We use a macro for this, so that it is only exported on Windows. #if _MSC_VER && OPENMC_WIN_COMPILE -#define DllExport __declspec( dllexport ) +#define DllExport __declspec(dllexport) #elif _MSC_VER -#define DllExport __declspec( dllimport ) +#define DllExport __declspec(dllimport) #else #define DllExport #endif diff --git a/include/openmc/mcpl_interface.h b/include/openmc/mcpl_interface.h index c97243c2e3f..a5d99efa03b 100644 --- a/include/openmc/mcpl_interface.h +++ b/include/openmc/mcpl_interface.h @@ -37,7 +37,7 @@ vector mcpl_source_sites(std::string path); //! calculate_parallel_index_vector on //! source_bank.size(). void write_mcpl_source_point(const char* filename, - gsl::span source_bank, vector const& bank_index); + gsl::span source_bank, const vector& bank_index); } // namespace openmc #endif // OPENMC_MCPL_INTERFACE_H diff --git a/include/openmc/ncrystal_interface.h b/include/openmc/ncrystal_interface.h index 4620952b1f0..eba90c589c1 100644 --- a/include/openmc/ncrystal_interface.h +++ b/include/openmc/ncrystal_interface.h @@ -59,19 +59,10 @@ class NCrystalMat { //---------------------------------------------------------------------------- // Trivial methods when compiling without NCRYSTAL - std::string cfg() const - { - return ""; - } - double xs(const Particle& p) const - { - return -1.0; - } + std::string cfg() const { return ""; } + double xs(const Particle& p) const { return -1.0; } void scatter(Particle& p) const {} - operator bool() const - { - return false; - } + operator bool() const { return false; } #endif private: diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 39ab5a90e32..df3977af321 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -112,7 +112,7 @@ extern ResScatMethod res_scat_method; //!< resonance upscattering method extern double res_scat_energy_min; //!< Min energy in [eV] for res. upscattering extern double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering extern vector - res_scat_nuclides; //!< Nuclides using res. upscattering treatment + res_scat_nuclides; //!< Nuclides using res. upscattering treatment extern RunMode DllExport run_mode; //!< Run mode (eigenvalue, fixed src, etc.) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written diff --git a/src/cross_sections.cpp b/src/cross_sections.cpp index e936b34bcb1..95dce4971d6 100644 --- a/src/cross_sections.cpp +++ b/src/cross_sections.cpp @@ -37,18 +37,17 @@ std::map library_map; vector libraries; } // namespace data - //============================================================================== // Separator strings for Windows and Unix-like systems //============================================================================== namespace details { #if defined(_WIN32) || defined(_WIN64) - const char sep_char[] = "\\"; // Windows separator string +const char sep_char[] = "\\"; // Windows separator string #else - const char sep_char[] = "/"; // Unix-like separator string +const char sep_char[] = "/"; // Unix-like separator string #endif -} +} // namespace details //============================================================================== // Library methods @@ -159,8 +158,8 @@ void read_cross_sections_xml(pugi::xml_node root) // If no '/' found, the file is probably in the input directory auto pos = settings::path_cross_sections.rfind(details::sep_char); if (pos == std::string::npos && !settings::path_input.empty()) { - settings::path_cross_sections = - settings::path_input + details::sep_char + settings::path_cross_sections; + settings::path_cross_sections = settings::path_input + details::sep_char + + settings::path_cross_sections; } } diff --git a/tests/cpp_unit_tests/test_file_utils.cpp b/tests/cpp_unit_tests/test_file_utils.cpp index 3aac7a8d07b..8505277f038 100644 --- a/tests/cpp_unit_tests/test_file_utils.cpp +++ b/tests/cpp_unit_tests/test_file_utils.cpp @@ -30,7 +30,7 @@ TEST_CASE("Test get_file_extension") } TEST_CASE("Test dir_exists") -{ +{ #if defined(_WIN32) || defined(_WIN64) // If this doesn't exist on a Windows system, I have no clue what is happening REQUIRE(dir_exists("C:\\")); From 2c82b3a9f4b8d24c54e738196689ffd9b26e2e77 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Sat, 30 Mar 2024 13:35:00 -0400 Subject: [PATCH 13/44] Add directory to openmc dll on Windows systems with python >= 3.8.0 --- openmc/lib/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openmc/lib/__init__.py b/openmc/lib/__init__.py index c5a8fb9bda4..658c042df97 100644 --- a/openmc/lib/__init__.py +++ b/openmc/lib/__init__.py @@ -28,6 +28,13 @@ _suffix = 'so' if os.environ.get('READTHEDOCS', None) != 'True': + # To load the DLL on Windows without error, we need to add the path of + # the DLL. We get the directory from the path of this file. This should + # only be necessary with Python >= 3.8.0. + if sys.platform == 'win32' and sys.version_info.minor > 7: + dll_path = os.path.dirname(os.path.abspath(__file__)) + os.add_dll_directory(dll_path) + # Open shared library _filename = pkg_resources.resource_filename( __name__, 'libopenmc.{}'.format(_suffix)) From ee58f87c26f6c128d94fe7be108d29da858735cc Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Sat, 30 Mar 2024 15:45:02 -0400 Subject: [PATCH 14/44] Update openmc/deplete/pool.py Co-authored-by: Gavin Ridley --- openmc/deplete/pool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/deplete/pool.py b/openmc/deplete/pool.py index 8627d8f5028..705980ec67b 100644 --- a/openmc/deplete/pool.py +++ b/openmc/deplete/pool.py @@ -17,7 +17,7 @@ USE_MULTIPROCESSING = True # Not sure why, but using multiprocessing on Windows leads to many transport -# simualtions being run over eachother and leads to catastrophe. +# simulations being run over eachother and leads to catastrophe. if sys.platform == 'win32': USE_MULTIPROCESSING = False From 8b5826470b382ee5cb69b008e7671d2f3e232486 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Wed, 5 Jun 2024 11:54:04 -0400 Subject: [PATCH 15/44] Use submodules for xtensor again now that they have been updated. --- CMakeLists.txt | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 100bf043773..68b771f0365 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,30 +282,9 @@ endif() find_package_write_status(xtensor) if (NOT xtensor_FOUND) - # The version of xtensor which is in the submodules appears to have a memory - # bug on Windows machines. For now, I am just going to comment out using the - # submodules, and will get a recent version of xtensor with fetch content. - #add_subdirectory(vendor/xtl) - #set(xtl_DIR ${CMAKE_CURRENT_BINARY_DIR}/vendor/xtl) - #add_subdirectory(vendor/xtensor) - - include(FetchContent) - - # Get XTL - message(STATUS "Downloading xtl v0.7.7") - FetchContent_Declare(xtl - GIT_REPOSITORY https://github.com/xtensor-stack/xtl.git - GIT_TAG 0.7.7 - ) - FetchContent_MakeAvailable(xtl) - - # Get XTENSOR - message(STATUS "Downloading xtensor v0.24.7") - FetchContent_Declare(xtensor - GIT_REPOSITORY https://github.com/xtensor-stack/xtensor.git - GIT_TAG 0.24.7 - ) - FetchContent_MakeAvailable(xtensor) + add_subdirectory(vendor/xtl) + set(xtl_DIR ${CMAKE_CURRENT_BINARY_DIR}/vendor/xtl) + add_subdirectory(vendor/xtensor) endif() #=============================================================================== From 578faba9f5181e36b3e117daaf12a0e194f79d91 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Wed, 5 Jun 2024 12:01:19 -0400 Subject: [PATCH 16/44] Fixes clang-format test --- include/openmc/dagmc.h | 2 +- include/openmc/settings.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/openmc/dagmc.h b/include/openmc/dagmc.h index 53120f878e9..c2cde83efcf 100644 --- a/include/openmc/dagmc.h +++ b/include/openmc/dagmc.h @@ -6,7 +6,7 @@ namespace openmc { extern "C" const bool DllExport DAGMC_ENABLED; extern "C" const bool DllExport UWUW_ENABLED; -} +} // namespace openmc // always include the XML interface header #include "openmc/xml_interface.h" diff --git a/include/openmc/settings.h b/include/openmc/settings.h index a22fe41637b..e6e54639aff 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -114,7 +114,8 @@ extern double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering extern vector res_scat_nuclides; //!< Nuclides using res. upscattering treatment extern RunMode DllExport run_mode; //!< Run mode (eigenvalue, fixed src, etc.) -extern SolverType DllExport solver_type; //!< Solver Type (Monte Carlo or Random Ray) +extern SolverType DllExport + solver_type; //!< Solver Type (Monte Carlo or Random Ray) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written extern std::unordered_set From ccdb7eea34a0376c5da46929cf24d1c7cf310153 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 16 Aug 2024 07:54:34 -0500 Subject: [PATCH 17/44] Rename OPENMC_WIN_COMPILE to OPENMC_DLL_EXPORTS --- CMakeLists.txt | 6 +++--- include/openmc/capi.h | 6 +++--- include/openmc/constants.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abfe2ca407e..a03c9e96111 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,8 +82,8 @@ endif() if(OPENMC_USE_OPENMP) find_package(OpenMP REQUIRED) - - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # Special flag to get OpenMP to work on Windows with MSVC list(APPEND cxxflags /openmp:llvm) endif() @@ -462,7 +462,7 @@ if(MSVC) # are used for exporting symbols in the dll. While the # WINDOWS_EXPORT_ALL_SYMBOLS exports all function/class symbols, it # unfortunately does not work on global variables, which still need the macro. - target_compile_definitions(libopenmc PRIVATE -DOPENMC_WIN_COMPILE) + target_compile_definitions(libopenmc PRIVATE -DOPENMC_DLL_EXPORTS) # To use the shared HDF5 libraries on Windows, the H5_BUILT_AS_DYNAMIC_LIB # compile definition must be specified. diff --git a/include/openmc/capi.h b/include/openmc/capi.h index 62fad07f7bb..34957db04a1 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -279,9 +279,8 @@ extern int OPENMC_E_DATA; extern int OPENMC_E_PHYSICS; extern int OPENMC_E_WARNING; -// Global variables - -#if _MSC_VER && OPENMC_WIN_COMPILE +// Macro to ensure global variables are exported in Windows DLLs +#if _MSC_VER && OPENMC_DLL_EXPORTS #define DllExport __declspec(dllexport) #elif _MSC_VER #define DllExport __declspec(dllimport) @@ -289,6 +288,7 @@ extern int OPENMC_E_WARNING; #define DllExport #endif +// Global variables extern char DllExport openmc_err_msg[256]; #ifdef __cplusplus diff --git a/include/openmc/constants.h b/include/openmc/constants.h index 1a8e2d9f497..be4915f1aca 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -351,10 +351,10 @@ enum class GeometryType { CSG, DAG }; //============================================================================== // Shared Libraries on Windows need the functions/classes/variables to be -// exposed to be declared with this special keyword "__declspec( dllexport )". +// exposed to be declared with this special keyword "__declspec(dllexport)". // We use a macro for this, so that it is only exported on Windows. -#if _MSC_VER && OPENMC_WIN_COMPILE +#if _MSC_VER && OPENMC_DLL_EXPORTS #define DllExport __declspec(dllexport) #elif _MSC_VER #define DllExport __declspec(dllimport) From 3db902892cfbe078c31d782e33e88bf49e453aee Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 16 Aug 2024 07:56:53 -0500 Subject: [PATCH 18/44] Remove mention of Python 3.8+ --- openmc/lib/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openmc/lib/__init__.py b/openmc/lib/__init__.py index 9cf02973c66..fefae219aa4 100644 --- a/openmc/lib/__init__.py +++ b/openmc/lib/__init__.py @@ -28,9 +28,8 @@ if os.environ.get('READTHEDOCS', None) != 'True': # To load the DLL on Windows without error, we need to add the path of - # the DLL. We get the directory from the path of this file. This should - # only be necessary with Python >= 3.8.0. - if sys.platform == 'win32' and sys.version_info.minor > 7: + # the DLL. We get the directory from the path of this file. + if sys.platform == 'win32': dll_path = os.path.dirname(os.path.abspath(__file__)) os.add_dll_directory(dll_path) From d6c7e0a53457c3f3cf32e7836d1b9b21f8375955 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 16 Aug 2024 08:16:36 -0500 Subject: [PATCH 19/44] Use std::filesystem to get rid of sep_char --- src/cross_sections.cpp | 50 ++++++++++++------------------------------ 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/src/cross_sections.cpp b/src/cross_sections.cpp index 235a6063ed9..574b0835e5c 100644 --- a/src/cross_sections.cpp +++ b/src/cross_sections.cpp @@ -23,6 +23,7 @@ #include "pugixml.hpp" #include // for getenv +#include #include namespace openmc { @@ -37,18 +38,6 @@ std::map library_map; vector libraries; } // namespace data -//============================================================================== -// Separator strings for Windows and Unix-like systems -//============================================================================== - -namespace details { -#if defined(_WIN32) || defined(_WIN64) -const char sep_char[] = "\\"; // Windows separator string -#else -const char sep_char[] = "/"; // Unix-like separator string -#endif -} // namespace details - //============================================================================== // Library methods //============================================================================== @@ -82,16 +71,14 @@ Library::Library(pugi::xml_node node, const std::string& directory) if (!check_for_node(node, "path")) { fatal_error("Missing library path"); } - std::string path = get_node_value(node, "path"); - - if (starts_with(path, details::sep_char)) { - path_ = path; - } else if (ends_with(directory, details::sep_char)) { - path_ = directory + path; - } else if (!directory.empty()) { - path_ = directory + details::sep_char + path; + std::filesystem::path path(get_node_value(node, "path")); + std::filesystem::path dir(directory); + if (path.is_absolute()) { + path_ = path.string(); + } else if (std::filesystem::is_directory(dir)) { + path_ = (dir / path).string(); } else { - path_ = path; + path_ = path.string(); } if (!file_exists(path_)) { @@ -155,11 +142,11 @@ void read_cross_sections_xml(pugi::xml_node root) } else { settings::path_cross_sections = get_node_value(root, "cross_sections"); - // If no '/' found, the file is probably in the input directory - auto pos = settings::path_cross_sections.rfind(details::sep_char); - if (pos == std::string::npos && !settings::path_input.empty()) { - settings::path_cross_sections = settings::path_input + details::sep_char + - settings::path_cross_sections; + // If the path is relative, it is probably in the input directory + std::filesystem::path p(settings::path_cross_sections); + if (p.is_relative() && !settings::path_input.empty()) { + std::filesystem::path dir(settings::path_input); + settings::path_cross_sections = (dir / p).string(); } } @@ -321,16 +308,7 @@ void read_ce_cross_sections_xml() } else { // If no directory is listed in cross_sections.xml, by default select the // directory in which the cross_sections.xml file resides - - // TODO: Use std::filesystem functionality when C++17 is adopted - auto pos = filename.rfind(details::sep_char); - if (pos == std::string::npos) { - // No '\\' found, so the file must be in the same directory as - // materials.xml - directory = settings::path_input; - } else { - directory = filename.substr(0, pos); - } + directory = std::filesystem::path(filename).parent_path().string(); } for (const auto& node_library : root.children("library")) { From c609f24c77f72f25c8dc95f01c97e69db6296691 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 16 Aug 2024 08:47:29 -0500 Subject: [PATCH 20/44] Use _WIN32, not _MSC_VER --- include/openmc/capi.h | 4 ++-- include/openmc/constants.h | 4 ++-- include/openmc/shared_array.h | 4 ++-- src/external/quartic_solver.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/openmc/capi.h b/include/openmc/capi.h index 34957db04a1..516f338ff29 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -280,9 +280,9 @@ extern int OPENMC_E_PHYSICS; extern int OPENMC_E_WARNING; // Macro to ensure global variables are exported in Windows DLLs -#if _MSC_VER && OPENMC_DLL_EXPORTS +#if defined(_WIN32) && defined(OPENMC_DLL_EXPORTS) #define DllExport __declspec(dllexport) -#elif _MSC_VER +#elif defined(_WIN32) #define DllExport __declspec(dllimport) #else #define DllExport diff --git a/include/openmc/constants.h b/include/openmc/constants.h index be4915f1aca..9ff207812bf 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -354,9 +354,9 @@ enum class GeometryType { CSG, DAG }; // exposed to be declared with this special keyword "__declspec(dllexport)". // We use a macro for this, so that it is only exported on Windows. -#if _MSC_VER && OPENMC_DLL_EXPORTS +#if defined(_WIN32) && defined(OPENMC_DLL_EXPORTS) #define DllExport __declspec(dllexport) -#elif _MSC_VER +#elif defined(_WIN32) #define DllExport __declspec(dllimport) #else #define DllExport diff --git a/include/openmc/shared_array.h b/include/openmc/shared_array.h index 031a42e9eb7..fc9a975c781 100644 --- a/include/openmc/shared_array.h +++ b/include/openmc/shared_array.h @@ -72,7 +72,7 @@ class SharedArray { { // Atomically capture the index we want to write to int64_t idx; -#if _MSC_VER && !__INTEL_COMPILER +#if _WIN32 && !__INTEL_COMPILER #pragma omp atomic capture idx = size_++; #else @@ -82,7 +82,7 @@ class SharedArray { // Check that we haven't written off the end of the array if (idx >= capacity_) { -#if _MSC_VER && !__INTEL_COMPILER +#if _WIN32 && !__INTEL_COMPILER #pragma omp atomic write size_ = capacity_; #else diff --git a/src/external/quartic_solver.cpp b/src/external/quartic_solver.cpp index c42f4e1e679..ddcce17fbec 100644 --- a/src/external/quartic_solver.cpp +++ b/src/external/quartic_solver.cpp @@ -4,11 +4,11 @@ #include #include +namespace oqs { + // TODO: replace with when we go for C++20 constexpr double PI {3.141592653589793238462643383279502884L}; -namespace oqs { - // pow(DBL_MAX,1.0/3.0)/1.618034; constexpr double CUBIC_RESCAL_FACT = 3.488062113727083e+102; // pow(DBL_MAX,1.0/4.0)/1.618034; From 28c42ef317b02ed4766c75e94932cd6232f211e7 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 16 Aug 2024 08:53:50 -0500 Subject: [PATCH 21/44] Rename DllExport to OPENMC_API --- include/openmc/capi.h | 8 ++++---- include/openmc/constants.h | 6 +++--- include/openmc/dagmc.h | 6 +++--- include/openmc/mcpl_interface.h | 2 +- include/openmc/mesh.h | 4 ++-- include/openmc/message_passing.h | 2 +- include/openmc/ncrystal_interface.h | 4 ++-- include/openmc/settings.h | 4 ++-- include/openmc/tallies/filter.h | 2 +- src/dagmc.cpp | 4 ++-- src/error.cpp | 2 +- src/mcpl_interface.cpp | 4 ++-- src/mesh.cpp | 4 ++-- src/message_passing.cpp | 2 +- src/ncrystal_interface.cpp | 4 ++-- src/settings.cpp | 4 ++-- src/tallies/filter.cpp | 2 +- 17 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/openmc/capi.h b/include/openmc/capi.h index 516f338ff29..566d804cf44 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -281,15 +281,15 @@ extern int OPENMC_E_WARNING; // Macro to ensure global variables are exported in Windows DLLs #if defined(_WIN32) && defined(OPENMC_DLL_EXPORTS) -#define DllExport __declspec(dllexport) +#define OPENMC_API __declspec(dllexport) #elif defined(_WIN32) -#define DllExport __declspec(dllimport) +#define OPENMC_API __declspec(dllimport) #else -#define DllExport +#define OPENMC_API #endif // Global variables -extern char DllExport openmc_err_msg[256]; +extern char OPENMC_API openmc_err_msg[256]; #ifdef __cplusplus } diff --git a/include/openmc/constants.h b/include/openmc/constants.h index 9ff207812bf..74b050c858b 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -355,11 +355,11 @@ enum class GeometryType { CSG, DAG }; // We use a macro for this, so that it is only exported on Windows. #if defined(_WIN32) && defined(OPENMC_DLL_EXPORTS) -#define DllExport __declspec(dllexport) +#define OPENMC_API __declspec(dllexport) #elif defined(_WIN32) -#define DllExport __declspec(dllimport) +#define OPENMC_API __declspec(dllimport) #else -#define DllExport +#define OPENMC_API #endif } // namespace openmc diff --git a/include/openmc/dagmc.h b/include/openmc/dagmc.h index c2cde83efcf..ee9fb9b6da4 100644 --- a/include/openmc/dagmc.h +++ b/include/openmc/dagmc.h @@ -1,11 +1,11 @@ #ifndef OPENMC_DAGMC_H #define OPENMC_DAGMC_H -#include "openmc/constants.h" // Needed for DllExport +#include "openmc/constants.h" // Needed for OPENMC_API namespace openmc { -extern "C" const bool DllExport DAGMC_ENABLED; -extern "C" const bool DllExport UWUW_ENABLED; +extern "C" const bool OPENMC_API DAGMC_ENABLED; +extern "C" const bool OPENMC_API UWUW_ENABLED; } // namespace openmc // always include the XML interface header diff --git a/include/openmc/mcpl_interface.h b/include/openmc/mcpl_interface.h index a5d99efa03b..d38eb554f1d 100644 --- a/include/openmc/mcpl_interface.h +++ b/include/openmc/mcpl_interface.h @@ -15,7 +15,7 @@ namespace openmc { // Constants //============================================================================== -extern "C" const bool DllExport MCPL_ENABLED; +extern "C" const bool OPENMC_API MCPL_ENABLED; //============================================================================== // Functions diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 44b18c8dd72..06ad162d62f 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -11,7 +11,7 @@ #include "xtensor/xtensor.hpp" #include -#include "openmc/constants.h" // for DllExport +#include "openmc/constants.h" // for OPENMC_API #include "openmc/error.h" #include "openmc/memory.h" // for unique_ptr #include "openmc/particle.h" @@ -50,7 +50,7 @@ enum class ElementType { UNSUPPORTED = -1, LINEAR_TET, LINEAR_HEX }; // Global variables //============================================================================== -extern "C" const bool DllExport LIBMESH_ENABLED; +extern "C" const bool OPENMC_API LIBMESH_ENABLED; class Mesh; diff --git a/include/openmc/message_passing.h b/include/openmc/message_passing.h index 14b9a7a9315..23b79b4f676 100644 --- a/include/openmc/message_passing.h +++ b/include/openmc/message_passing.h @@ -15,7 +15,7 @@ namespace mpi { extern int rank; extern int n_procs; -extern bool DllExport master; +extern bool OPENMC_API master; #ifdef OPENMC_MPI extern MPI_Datatype source_site; diff --git a/include/openmc/ncrystal_interface.h b/include/openmc/ncrystal_interface.h index eba90c589c1..aee896cb106 100644 --- a/include/openmc/ncrystal_interface.h +++ b/include/openmc/ncrystal_interface.h @@ -6,7 +6,7 @@ #include "NCrystal/NCrystal.hh" #endif -#include "openmc/constants.h" // Needed for DllExport +#include "openmc/constants.h" // Needed for OPENMC_API #include "openmc/particle.h" #include // for uint64_t @@ -19,7 +19,7 @@ namespace openmc { // Constants //============================================================================== -extern "C" const bool DllExport NCRYSTAL_ENABLED; +extern "C" const bool OPENMC_API NCRYSTAL_ENABLED; //! Energy in [eV] to switch between NCrystal and ENDF constexpr double NCRYSTAL_MAX_ENERGY {5.0}; diff --git a/include/openmc/settings.h b/include/openmc/settings.h index a7bde1b7d11..e81c9826186 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -121,8 +121,8 @@ extern double res_scat_energy_min; //!< Min energy in [eV] for res. upscattering extern double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering extern vector res_scat_nuclides; //!< Nuclides using res. upscattering treatment -extern RunMode DllExport run_mode; //!< Run mode (eigenvalue, fixed src, etc.) -extern SolverType DllExport +extern RunMode OPENMC_API run_mode; //!< Run mode (eigenvalue, fixed src, etc.) +extern SolverType OPENMC_API solver_type; //!< Solver Type (Monte Carlo or Random Ray) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written diff --git a/include/openmc/tallies/filter.h b/include/openmc/tallies/filter.h index f275fd525c3..758f2acaad2 100644 --- a/include/openmc/tallies/filter.h +++ b/include/openmc/tallies/filter.h @@ -148,7 +148,7 @@ class Filter { namespace model { extern "C" int32_t n_filters; -extern std::unordered_map DllExport filter_map; +extern std::unordered_map OPENMC_API filter_map; extern vector> tally_filters; } // namespace model diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 69cd2e6cccc..c94026d084e 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -24,9 +24,9 @@ namespace openmc { #ifdef DAGMC -const bool DllExport DAGMC_ENABLED = true; +const bool OPENMC_API DAGMC_ENABLED = true; #else -const bool DllExport DAGMC_ENABLED = false; +const bool OPENMC_API DAGMC_ENABLED = false; #endif #ifdef UWUW diff --git a/src/error.cpp b/src/error.cpp index 3110081752a..467bc67c184 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -30,7 +30,7 @@ int OPENMC_E_PHYSICS {-10}; int OPENMC_E_WARNING {1}; // Error message -char DllExport openmc_err_msg[256]; +char OPENMC_API openmc_err_msg[256]; //============================================================================== // Functions diff --git a/src/mcpl_interface.cpp b/src/mcpl_interface.cpp index 5297ec569ff..e2e001c36d5 100644 --- a/src/mcpl_interface.cpp +++ b/src/mcpl_interface.cpp @@ -22,9 +22,9 @@ namespace openmc { //============================================================================== #ifdef OPENMC_MCPL -const bool DllExport MCPL_ENABLED = true; +const bool OPENMC_API MCPL_ENABLED = true; #else -const bool DllExport MCPL_ENABLED = false; +const bool OPENMC_API MCPL_ENABLED = false; #endif //============================================================================== diff --git a/src/mesh.cpp b/src/mesh.cpp index f7e905472a2..228e39b01ef 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -55,9 +55,9 @@ namespace openmc { //============================================================================== #ifdef LIBMESH -const bool DllExport LIBMESH_ENABLED = true; +const bool OPENMC_API LIBMESH_ENABLED = true; #else -const bool DllExport LIBMESH_ENABLED = false; +const bool OPENMC_API LIBMESH_ENABLED = false; #endif namespace model { diff --git a/src/message_passing.cpp b/src/message_passing.cpp index 9da88631009..fa246a5d7d2 100644 --- a/src/message_passing.cpp +++ b/src/message_passing.cpp @@ -5,7 +5,7 @@ namespace mpi { int rank {0}; int n_procs {1}; -bool DllExport master {true}; +bool OPENMC_API master {true}; #ifdef OPENMC_MPI MPI_Comm intracomm {MPI_COMM_NULL}; diff --git a/src/ncrystal_interface.cpp b/src/ncrystal_interface.cpp index 9cb26d4d240..6f45d434205 100644 --- a/src/ncrystal_interface.cpp +++ b/src/ncrystal_interface.cpp @@ -11,9 +11,9 @@ namespace openmc { //============================================================================== #ifdef NCRYSTAL -const bool DllExport NCRYSTAL_ENABLED = true; +const bool OPENMC_API NCRYSTAL_ENABLED = true; #else -const bool DllExport NCRYSTAL_ENABLED = false; +const bool OPENMC_API NCRYSTAL_ENABLED = false; #endif //============================================================================== diff --git a/src/settings.cpp b/src/settings.cpp index 2205b30738e..f9cf877dad0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -113,8 +113,8 @@ ResScatMethod res_scat_method {ResScatMethod::rvs}; double res_scat_energy_min {0.01}; double res_scat_energy_max {1000.0}; vector res_scat_nuclides; -RunMode DllExport run_mode {RunMode::UNSET}; -SolverType DllExport solver_type {SolverType::MONTE_CARLO}; +RunMode OPENMC_API run_mode {RunMode::UNSET}; +SolverType OPENMC_API solver_type {SolverType::MONTE_CARLO}; std::unordered_set sourcepoint_batch; std::unordered_set statepoint_batch; std::unordered_set source_write_surf_id; diff --git a/src/tallies/filter.cpp b/src/tallies/filter.cpp index 73b141b6e2d..fe2d2d0ac64 100644 --- a/src/tallies/filter.cpp +++ b/src/tallies/filter.cpp @@ -46,7 +46,7 @@ namespace openmc { //============================================================================== namespace model { -std::unordered_map DllExport filter_map; +std::unordered_map OPENMC_API filter_map; vector> tally_filters; } // namespace model From 071c946dc848e4caf873daa08b05474e973f6065 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Fri, 16 Aug 2024 11:03:19 -0400 Subject: [PATCH 22/44] Change and to && for MSVC compilation --- src/source.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source.cpp b/src/source.cpp index 15fe8433ba5..07318ef505a 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -378,7 +378,7 @@ SourceSite IndependentSource::sample(uint64_t* seed) const site.E = energy_->sample(seed); // Resample if energy falls above maximum particle energy - if (site.E < data::energy_max[p] and + if (site.E < data::energy_max[p] && (satisfies_energy_constraints(site.E))) break; From fde82e2ec4dd0e9c6113c8a9ad5e3e9faf2739fb Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Fri, 16 Aug 2024 11:04:46 -0400 Subject: [PATCH 23/44] Fixes to OMP reductions for compilation with MSVC --- src/random_ray/flat_source_domain.cpp | 6 ++++-- src/random_ray/random_ray_simulation.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/random_ray/flat_source_domain.cpp b/src/random_ray/flat_source_domain.cpp index 584b3a7edb4..c31e94ee3a0 100644 --- a/src/random_ray/flat_source_domain.cpp +++ b/src/random_ray/flat_source_domain.cpp @@ -968,7 +968,8 @@ void FlatSourceDomain::apply_external_source_to_cell_and_children( void FlatSourceDomain::count_external_source_regions() { -#pragma omp parallel for reduction(+ : n_external_source_regions_) + int64_t temp_n_external_source_regions {0}; +#pragma omp parallel for reduction(+ : temp_n_external_source_regions) for (int sr = 0; sr < n_source_regions_; sr++) { float total = 0.f; for (int e = 0; e < negroups_; e++) { @@ -976,9 +977,10 @@ void FlatSourceDomain::count_external_source_regions() total += external_source_[se]; } if (total != 0.f) { - n_external_source_regions_++; + temp_n_external_source_regions++; } } + n_external_source_regions_ = temp_n_external_source_regions; } void FlatSourceDomain::convert_external_sources() diff --git a/src/random_ray/random_ray_simulation.cpp b/src/random_ray/random_ray_simulation.cpp index 4bc77645bcd..6035b8f2bf8 100644 --- a/src/random_ray/random_ray_simulation.cpp +++ b/src/random_ray/random_ray_simulation.cpp @@ -285,13 +285,15 @@ void RandomRaySimulation::simulate() simulation::time_transport.start(); // Transport sweep over all random rays for the iteration + uint64_t temp_total_geometric_intersections {0}; #pragma omp parallel for schedule(dynamic) \ - reduction(+ : total_geometric_intersections_) + reduction(+ : temp_total_geometric_intersections) for (int i = 0; i < simulation::work_per_rank; i++) { RandomRay ray(i, domain_.get()); - total_geometric_intersections_ += + temp_total_geometric_intersections += ray.transport_history_based_single_ray(); } + total_geometric_intersections_ = temp_total_geometric_intersections; simulation::time_transport.stop(); From f6e1a0405669560a93172338c4e3ed17f379f378 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 16 Aug 2024 11:48:40 -0500 Subject: [PATCH 24/44] Fix C++ style --- src/random_ray/random_ray_simulation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/random_ray/random_ray_simulation.cpp b/src/random_ray/random_ray_simulation.cpp index 6035b8f2bf8..7dc8f92e605 100644 --- a/src/random_ray/random_ray_simulation.cpp +++ b/src/random_ray/random_ray_simulation.cpp @@ -284,7 +284,7 @@ void RandomRaySimulation::simulate() // Start timer for transport simulation::time_transport.start(); -// Transport sweep over all random rays for the iteration + // Transport sweep over all random rays for the iteration uint64_t temp_total_geometric_intersections {0}; #pragma omp parallel for schedule(dynamic) \ reduction(+ : temp_total_geometric_intersections) From 38e11f2f9974f17ae1eea8d310cb1168666aebd8 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Sun, 18 Aug 2024 17:11:17 -0400 Subject: [PATCH 25/44] First attempt at adding Windows to CI --- .github/workflows/ci.yml | 58 +++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 6 ++++ tools/ci/download-xs.ps1 | 13 +++++++++ tools/ci/gha-install.ps1 | 10 +++++++ tools/ci/gha-install.py | 15 ++++++++-- tools/ci/gha_script.ps1 | 10 +++++++ tools/ci/hdf5_install.ps1 | 9 ++++++ 7 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 tools/ci/download-xs.ps1 create mode 100644 tools/ci/gha-install.ps1 create mode 100644 tools/ci/gha_script.ps1 create mode 100644 tools/ci/hdf5_install.ps1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9293e319b42..33531a16658 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,6 +155,64 @@ jobs: cpp-coveralls -i src -i include -e src/external --exclude-pattern "/usr/*" --dump cpp_cov.json coveralls --merge=cpp_cov.json --service=github + win: + runs-on: windows-latest + strategy: + matrix: + python-version: ["3.10"] + omp: [n, y] + + include: + - python-version: "3.10" + omp: n + - python-version: "3.10" + omp: y + name: "Windows Python ${{ matrix.python-version }} (omp=${{ matrix.omp }}" + + env: + OMP: ${{ matrix.omp }} + EVENT: ${{ matrix.event }} + NPY_DISABLE_CPU_FEATURES: "AVX512F AVX512_SKX" + OPENBLAS_NUM_THREADS: 1 + # libfabric complains about fork() as a result of using Python multiprocessing. + # We can work around it with RDMAV_FORK_SAFE=1 in libfabric < 1.13 and with + # FI_EFA_FORK_SAFE=1 in more recent versions. + RDMAV_FORK_SAFE: 1 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Environment Variables + shell: pwsh + run: | + $Env:OPENMC_CROSS_SECTIONS = "$Env:USERPROFILE\nndc_hdf5\cross_sections.xml" + $Env:OPENMC_ENDF_DATA = "$Env:USERPROFILE\endf-b-vii.1" + + - name: HDF5 Dependency + shell: pwsh + run: | + ${{github.workspace}}\tools\ci\hdf5_install.ps1 + + - name: Install + shell: pwsh + run: | + ${{github.workspace}}\tools\ci\gha-install.ps1 + + - name: Before + shell: pwsh + run: ${{github.workspace}}\tools\ci\download-xs.ps1 + + - name: Test + shell: pwsh + run: | + ctest --output-on-failure -C Debug ${{ github.workspace }}\build\ + ${{github.workspace}}\tools\ci\gha-script.ps1 + finish: needs: main runs-on: ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index a03c9e96111..219cbd94526 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,6 +168,12 @@ if(NOT DEFINED HDF5_PREFER_PARALLEL) endif() endif() +if (MSVC) + # To avoid problems with loading DLLs on Windows in the Python API, + # we should try to link libhdf5 statically. + set(HDF5_USE_STATIC_LIBRARIES TRUE) +endif() + find_package(HDF5 REQUIRED COMPONENTS C HL) # Remove HDF5 transitive dependencies that are system libraries diff --git a/tools/ci/download-xs.ps1 b/tools/ci/download-xs.ps1 new file mode 100644 index 00000000000..b9f212e5f34 --- /dev/null +++ b/tools/ci/download-xs.ps1 @@ -0,0 +1,13 @@ + +# Download HDF5 data +if (Test-Path "$Env:USERPROFILE\nndc_hdf5" = False) { + wget https://anl.box.com/shared/static/teaup95cqv8s9nn56hfn7ku8mmelr95p.xz -OutFile hdf5.xz + tar -xvzf hdf5.xz +} + +# Download ENDF/B-VII.1 distribution +$Env:ENDF = "$Env:USERPROFILE\endf-b-vii.1" +if (Test-Path $Env:ENDF) { + wget https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -OutFile endf.xs + tar -xvzf endf.xz +} diff --git a/tools/ci/gha-install.ps1 b/tools/ci/gha-install.ps1 new file mode 100644 index 00000000000..cdd4a62c659 --- /dev/null +++ b/tools/ci/gha-install.ps1 @@ -0,0 +1,10 @@ +# Upgrade pip, pytest, numpy before doing anything else. +pip install --upgrade pip +pip install --upgrade pytest +pip install --upgrade numpy + +# Build and install OpenMC executable +python tools/ci/gha-install.py + +# Install Python API in editable mode +pip install -e .[test,vtk,ci] \ No newline at end of file diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index f046e863470..7e2112bfd7e 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -1,4 +1,5 @@ import os +import sys import shutil import subprocess @@ -10,7 +11,11 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys os.chdir('build') # Build in debug mode by default with support for MCPL - cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DOPENMC_USE_MCPL=on'] + if sys.platform == 'win32': + vcpkg_dir = os.environ.get('VCPKG_ROOT') + cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+vcpkg_dir+'\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static'] + else: + cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DOPENMC_USE_MCPL=on'] # Turn off OpenMP if specified if not omp: @@ -50,8 +55,12 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys cmake_cmd.append('..') print(' '.join(cmake_cmd)) subprocess.check_call(cmake_cmd) - subprocess.check_call(['make', '-j4']) - subprocess.check_call(['sudo', 'make', 'install']) + + if sys.platform == 'win32': + subprocess.check_call(['cmake', '--install', '.', '--config=Debug']) + else: + subprocess.check_call(['make', '-j4']) + subprocess.check_call(['sudo', 'make', 'install']) def main(): # Convert Travis matrix environment variables into arguments for install() diff --git a/tools/ci/gha_script.ps1 b/tools/ci/gha_script.ps1 new file mode 100644 index 00000000000..04a5c7817cf --- /dev/null +++ b/tools/ci/gha_script.ps1 @@ -0,0 +1,10 @@ +# Argument list +$Env:args = "" + +# Check for event-based +if ($Env:EVENT) { + $Env:args = $Env:args + " --event " +} + +# Run regression and unit tests +python --cov=openmc -v $Env:args tests \ No newline at end of file diff --git a/tools/ci/hdf5_install.ps1 b/tools/ci/hdf5_install.ps1 new file mode 100644 index 00000000000..78b56b0dcae --- /dev/null +++ b/tools/ci/hdf5_install.ps1 @@ -0,0 +1,9 @@ +git clone https://github.com/microsoft/vcpkg.git "$Env:USERPROFILE\vcpkg" + +cd "$Env:USERPROFILE\vcpkg" +.\bootstrap-vcpkg.bat + +$Env:VCPKG_ROOT = "$Env:USERPROFILE\vcpkg" +$Env:Path += ";$Env:VCPKG_ROOT" + +vcpkg install hdf5:x64-windows-static \ No newline at end of file From 3e1bce25e1bf529d2862e90b96df64e3b74fa6c9 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Sun, 18 Aug 2024 17:39:33 -0400 Subject: [PATCH 26/44] Fix xs download script on Windows --- tools/ci/download-xs.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/ci/download-xs.ps1 b/tools/ci/download-xs.ps1 index b9f212e5f34..d10aa464f8b 100644 --- a/tools/ci/download-xs.ps1 +++ b/tools/ci/download-xs.ps1 @@ -1,13 +1,13 @@ # Download HDF5 data -if (Test-Path "$Env:USERPROFILE\nndc_hdf5" = False) { +if (-not (Test-Path "$Env:USERPROFILE\nndc_hdf5")) { wget https://anl.box.com/shared/static/teaup95cqv8s9nn56hfn7ku8mmelr95p.xz -OutFile hdf5.xz tar -xvzf hdf5.xz } # Download ENDF/B-VII.1 distribution $Env:ENDF = "$Env:USERPROFILE\endf-b-vii.1" -if (Test-Path $Env:ENDF) { +if (-not (Test-Path $Env:ENDF)) { wget https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -OutFile endf.xs tar -xvzf endf.xz } From 61b716483d0037afc07db82562f6de554b769a70 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Sun, 18 Aug 2024 18:31:16 -0400 Subject: [PATCH 27/44] More annoying Windows fixes --- .github/workflows/ci.yml | 6 +++--- tools/ci/download-xs.ps1 | 4 ++-- tools/ci/hdf5_install.ps1 | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33531a16658..76c2849ef56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,7 +167,7 @@ jobs: omp: n - python-version: "3.10" omp: y - name: "Windows Python ${{ matrix.python-version }} (omp=${{ matrix.omp }}" + name: "Windows Python ${{ matrix.python-version }} (omp=${{ matrix.omp }})" env: OMP: ${{ matrix.omp }} @@ -190,8 +190,8 @@ jobs: - name: Environment Variables shell: pwsh run: | - $Env:OPENMC_CROSS_SECTIONS = "$Env:USERPROFILE\nndc_hdf5\cross_sections.xml" - $Env:OPENMC_ENDF_DATA = "$Env:USERPROFILE\endf-b-vii.1" + [Environment]::SetEnvironmentVariable("OPENMC_CROSS_SECTIONS", "$Env:USERPROFILE\nndc_hdf5\cross_sections.xml", [System.EnvironmentVariableTarget]::User) + [Environment]::SetEnvironmentVariable("OPENMC_ENDF_DATA", "$Env:USERPROFILE\endf-b-vii.1", [System.EnvironmentVariableTarget]::User) - name: HDF5 Dependency shell: pwsh diff --git a/tools/ci/download-xs.ps1 b/tools/ci/download-xs.ps1 index d10aa464f8b..7b71d2f735b 100644 --- a/tools/ci/download-xs.ps1 +++ b/tools/ci/download-xs.ps1 @@ -1,13 +1,13 @@ # Download HDF5 data if (-not (Test-Path "$Env:USERPROFILE\nndc_hdf5")) { - wget https://anl.box.com/shared/static/teaup95cqv8s9nn56hfn7ku8mmelr95p.xz -OutFile hdf5.xz + Invoke-WebRequest https://anl.box.com/shared/static/teaup95cqv8s9nn56hfn7ku8mmelr95p.xz -OutFile hdf5.xz tar -xvzf hdf5.xz } # Download ENDF/B-VII.1 distribution $Env:ENDF = "$Env:USERPROFILE\endf-b-vii.1" if (-not (Test-Path $Env:ENDF)) { - wget https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -OutFile endf.xs + Invoke-WebRequest https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -OutFile endf.xs tar -xvzf endf.xz } diff --git a/tools/ci/hdf5_install.ps1 b/tools/ci/hdf5_install.ps1 index 78b56b0dcae..ebc566ca529 100644 --- a/tools/ci/hdf5_install.ps1 +++ b/tools/ci/hdf5_install.ps1 @@ -3,7 +3,7 @@ git clone https://github.com/microsoft/vcpkg.git "$Env:USERPROFILE\vcpkg" cd "$Env:USERPROFILE\vcpkg" .\bootstrap-vcpkg.bat -$Env:VCPKG_ROOT = "$Env:USERPROFILE\vcpkg" +[Environment]::SetEnvironmentVariable("VCPKG_ROOT", "$Env:USERPROFILE\vcpkg", [System.EnvironmentVariableTarget]::User) $Env:Path += ";$Env:VCPKG_ROOT" vcpkg install hdf5:x64-windows-static \ No newline at end of file From 666e8afc46d28b7b6467bae2e4937a9d30bd175d Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Sun, 18 Aug 2024 19:02:56 -0400 Subject: [PATCH 28/44] Changes USERPROFILE to GITHUB_WORKSPACE to try and make Windows CI work --- .github/workflows/ci.yml | 4 ++-- tools/ci/download-xs.ps1 | 4 ++-- tools/ci/gha-install.py | 4 ++-- tools/ci/hdf5_install.ps1 | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76c2849ef56..6427e3b9535 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,8 +190,8 @@ jobs: - name: Environment Variables shell: pwsh run: | - [Environment]::SetEnvironmentVariable("OPENMC_CROSS_SECTIONS", "$Env:USERPROFILE\nndc_hdf5\cross_sections.xml", [System.EnvironmentVariableTarget]::User) - [Environment]::SetEnvironmentVariable("OPENMC_ENDF_DATA", "$Env:USERPROFILE\endf-b-vii.1", [System.EnvironmentVariableTarget]::User) + [Environment]::SetEnvironmentVariable("OPENMC_CROSS_SECTIONS", "$Env:GITHUB_WORKSPACE\nndc_hdf5\cross_sections.xml", 'Machine') + [Environment]::SetEnvironmentVariable("OPENMC_ENDF_DATA", "$Env:GITHUB_WORKSPACE\endf-b-vii.1", 'Machine') - name: HDF5 Dependency shell: pwsh diff --git a/tools/ci/download-xs.ps1 b/tools/ci/download-xs.ps1 index 7b71d2f735b..d8d97d516bb 100644 --- a/tools/ci/download-xs.ps1 +++ b/tools/ci/download-xs.ps1 @@ -1,12 +1,12 @@ # Download HDF5 data -if (-not (Test-Path "$Env:USERPROFILE\nndc_hdf5")) { +if (-not (Test-Path "$Env:GITHUB_WORKSPACE\nndc_hdf5")) { Invoke-WebRequest https://anl.box.com/shared/static/teaup95cqv8s9nn56hfn7ku8mmelr95p.xz -OutFile hdf5.xz tar -xvzf hdf5.xz } # Download ENDF/B-VII.1 distribution -$Env:ENDF = "$Env:USERPROFILE\endf-b-vii.1" +$Env:ENDF = "$Env:GITHUB_WORKSPACE\endf-b-vii.1" if (-not (Test-Path $Env:ENDF)) { Invoke-WebRequest https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -OutFile endf.xs tar -xvzf endf.xz diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index 7e2112bfd7e..27ee98f2fd3 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -12,8 +12,8 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys # Build in debug mode by default with support for MCPL if sys.platform == 'win32': - vcpkg_dir = os.environ.get('VCPKG_ROOT') - cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+vcpkg_dir+'\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static'] + work_dir = os.environ.get('GITHUB_WORKSPACE') + cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static'] else: cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DOPENMC_USE_MCPL=on'] diff --git a/tools/ci/hdf5_install.ps1 b/tools/ci/hdf5_install.ps1 index ebc566ca529..9798d648d35 100644 --- a/tools/ci/hdf5_install.ps1 +++ b/tools/ci/hdf5_install.ps1 @@ -1,9 +1,10 @@ -git clone https://github.com/microsoft/vcpkg.git "$Env:USERPROFILE\vcpkg" +git clone https://github.com/microsoft/vcpkg.git "$Env:GITHUB_WORKSPACE\vcpkg" -cd "$Env:USERPROFILE\vcpkg" +cd "$Env:GITHUB_WORKSPACE\vcpkg" .\bootstrap-vcpkg.bat -[Environment]::SetEnvironmentVariable("VCPKG_ROOT", "$Env:USERPROFILE\vcpkg", [System.EnvironmentVariableTarget]::User) +[Environment]::SetEnvironmentVariable("VCPKG_ROOT", "$Env:GITHUB_WORKSPACE\vcpkg", [System.EnvironmentVariableTarget]::User) +$Env:VCPKG_ROOT = "$Env:GITHUB_WORKSPACE\vcpkg" $Env:Path += ";$Env:VCPKG_ROOT" vcpkg install hdf5:x64-windows-static \ No newline at end of file From ac97924bb6a8f373ccf341c1c681cbf6135049ba Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Sun, 18 Aug 2024 19:07:38 -0400 Subject: [PATCH 29/44] Add caching of xs for windows CI --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6427e3b9535..16d82ca8891 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -198,6 +198,14 @@ jobs: run: | ${{github.workspace}}\tools\ci\hdf5_install.ps1 + - name: Cache XS + uses: actions/cache@v4 + with: + path: | + ${{github.workspace}}\nndc_hdf5 + ${{github.workspace}}\endf-b-vii.1 + key: ${{ runner.os }}-build-xs-cache + - name: Install shell: pwsh run: | From b1480eecb49118bfb7433cbe6fc170ca8b2b5400 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Tue, 20 Aug 2024 18:59:24 -0400 Subject: [PATCH 30/44] Tries to fix some Windows CI problems --- tools/ci/download-xs.ps1 | 5 +++-- tools/ci/gha-install.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/ci/download-xs.ps1 b/tools/ci/download-xs.ps1 index d8d97d516bb..74a45943212 100644 --- a/tools/ci/download-xs.ps1 +++ b/tools/ci/download-xs.ps1 @@ -1,13 +1,14 @@ +$ProgressPreference = 'SilentlyContinue' # Download HDF5 data if (-not (Test-Path "$Env:GITHUB_WORKSPACE\nndc_hdf5")) { - Invoke-WebRequest https://anl.box.com/shared/static/teaup95cqv8s9nn56hfn7ku8mmelr95p.xz -OutFile hdf5.xz + Invoke-WebRequest https://anl.box.com/shared/static/teaup95cqv8s9nn56hfn7ku8mmelr95p.xz -OutFile hdf5.xz -UseBasicParsing tar -xvzf hdf5.xz } # Download ENDF/B-VII.1 distribution $Env:ENDF = "$Env:GITHUB_WORKSPACE\endf-b-vii.1" if (-not (Test-Path $Env:ENDF)) { - Invoke-WebRequest https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -OutFile endf.xs + Invoke-WebRequest https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -OutFile endf.xs -UseBasicParsing tar -xvzf endf.xz } diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index 27ee98f2fd3..715ee950f52 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -13,7 +13,7 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys # Build in debug mode by default with support for MCPL if sys.platform == 'win32': work_dir = os.environ.get('GITHUB_WORKSPACE') - cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static'] + cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static', '-DVCPKG_DEFAULT_TRIPLET=x64-windows-static'] else: cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DOPENMC_USE_MCPL=on'] @@ -49,7 +49,8 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys cmake_cmd.append(f'-DCMAKE_PREFIX_PATH={ncrystal_cmake_path}') # Build in coverage mode for coverage testing - cmake_cmd.append('-DOPENMC_ENABLE_COVERAGE=on') + if sys.platform != 'win32': + cmake_cmd.append('-DOPENMC_ENABLE_COVERAGE=on') # Build and install cmake_cmd.append('..') From 7a99acebe221d51036b9d820e8850d73db47c260 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Tue, 20 Aug 2024 19:10:21 -0400 Subject: [PATCH 31/44] Maybe cmake will find HDF5 this time... --- tools/ci/gha-install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index 715ee950f52..9209265581c 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -13,7 +13,7 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys # Build in debug mode by default with support for MCPL if sys.platform == 'win32': work_dir = os.environ.get('GITHUB_WORKSPACE') - cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static', '-DVCPKG_DEFAULT_TRIPLET=x64-windows-static'] + cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static-rel'] else: cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DOPENMC_USE_MCPL=on'] From 37cf13e9aa2debe47db5dde55274c65427cabd2f Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Thu, 22 Aug 2024 19:04:31 -0400 Subject: [PATCH 32/44] Debug action to explor windows runner --- .github/workflows/ci.yml | 6 ++++++ tools/ci/gha-install.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16d82ca8891..8c3ad11582f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -211,6 +211,12 @@ jobs: run: | ${{github.workspace}}\tools\ci\gha-install.ps1 + - name: Breakpoint For Debugging + uses: namespacelabs/breakpoint-action@v0 + with: + duration: 30m + authorized-users: HunterBelanger + - name: Before shell: pwsh run: ${{github.workspace}}\tools\ci\download-xs.ps1 diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index 9209265581c..581f9a48bf4 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -13,7 +13,7 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False, ncrys # Build in debug mode by default with support for MCPL if sys.platform == 'win32': work_dir = os.environ.get('GITHUB_WORKSPACE') - cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static-rel'] + cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static'] else: cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DOPENMC_USE_MCPL=on'] From 2535052487576e8bce12de0b677b3967b447c501 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 15:16:57 -0400 Subject: [PATCH 33/44] Update Windows CICD to Python 3.11 --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35a5063c2ad..956acfd040f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -181,13 +181,13 @@ jobs: runs-on: windows-latest strategy: matrix: - python-version: ["3.10"] + python-version: ["3.11"] omp: [n, y] include: - - python-version: "3.10" + - python-version: "3.11" omp: n - - python-version: "3.10" + - python-version: "3.11" omp: y name: "Windows Python ${{ matrix.python-version }} (omp=${{ matrix.omp }})" From 3f78e6c28e14e8730f35d04ac0034f52e7d8aa7f Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 16:41:17 -0400 Subject: [PATCH 34/44] Some updates to Windows CICD scripts --- tools/ci/gha-install.py | 5 +++-- tools/ci/{gha_script.ps1 => gha-script.ps1} | 0 2 files changed, 3 insertions(+), 2 deletions(-) rename tools/ci/{gha_script.ps1 => gha-script.ps1} (100%) diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index ee63e968a7f..59f9adba381 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -13,7 +13,7 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False): # Build in debug mode by default with support for MCPL if sys.platform == 'win32': work_dir = os.environ.get('GITHUB_WORKSPACE') - cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static'] + cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static'] else: cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DOPENMC_USE_MCPL=on'] @@ -55,7 +55,8 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False): subprocess.check_call(cmake_cmd) if sys.platform == 'win32': - subprocess.check_call(['cmake', '--install', '.', '--config=Debug']) + subprocess.check_call(['cmake', '--build', '.', '--config=Release']) + subprocess.check_call(['cmake', '--install', '.', '--config=Release']) else: subprocess.check_call(['make', '-j4']) subprocess.check_call(['sudo', 'make', 'install']) diff --git a/tools/ci/gha_script.ps1 b/tools/ci/gha-script.ps1 similarity index 100% rename from tools/ci/gha_script.ps1 rename to tools/ci/gha-script.ps1 From 76d8c2150fc08f3767a59323fd62a9b8b49c5646 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 16:48:47 -0400 Subject: [PATCH 35/44] Fix some clang-format problems --- include/openmc/mesh.h | 2 +- src/random_ray/random_ray_simulation.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 7c0e403b96e..65e32b33eeb 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -10,8 +10,8 @@ #include "pugixml.hpp" #include "xtensor/xtensor.hpp" -#include "openmc/constants.h" // for OPENMC_API #include "openmc/bounding_box.h" +#include "openmc/constants.h" // for OPENMC_API #include "openmc/error.h" #include "openmc/memory.h" // for unique_ptr #include "openmc/particle.h" diff --git a/src/random_ray/random_ray_simulation.cpp b/src/random_ray/random_ray_simulation.cpp index 82cf0fc4da8..58787909f67 100644 --- a/src/random_ray/random_ray_simulation.cpp +++ b/src/random_ray/random_ray_simulation.cpp @@ -465,9 +465,9 @@ void RandomRaySimulation::simulate() // Start timer for transport simulation::time_transport.start(); - // Transport sweep over all random rays for the iteration - // Must use temporary accumulator variable for OpenMP on Windows - uint64_t tmp_total_geometric_intersections {0}; + // Transport sweep over all random rays for the iteration + // Must use temporary accumulator variable for OpenMP on Windows + uint64_t tmp_total_geometric_intersections {0}; #pragma omp parallel for schedule(dynamic) \ reduction(+ : tmp_total_geometric_intersections) for (int i = 0; i < settings::n_particles; i++) { From 0398a7decdb03f4d11d8b3bce63809a296304f7d Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 16:49:24 -0400 Subject: [PATCH 36/44] Temporarily disable normal linux tests to simplify debugging of windows CICD --- .github/workflows/ci.yml | 310 +++++++++++++++++++-------------------- 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 956acfd040f..42508b97ff8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,161 +21,161 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - main: - runs-on: ubuntu-22.04 - strategy: - matrix: - python-version: ["3.11"] - mpi: [n, y] - omp: [n, y] - dagmc: [n] - libmesh: [n] - event: [n] - vectfit: [n] - - include: - - python-version: "3.12" - omp: n - mpi: n - - python-version: "3.13" - omp: n - mpi: n - - dagmc: y - python-version: "3.11" - mpi: y - omp: y - - libmesh: y - python-version: "3.11" - mpi: y - omp: y - - libmesh: y - python-version: "3.11" - mpi: n - omp: y - - event: y - python-version: "3.11" - omp: y - mpi: n - - vectfit: y - python-version: "3.11" - omp: n - mpi: y - name: "Python ${{ matrix.python-version }} (omp=${{ matrix.omp }}, - mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }}, - libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }} - vectfit=${{ matrix.vectfit }})" - - env: - MPI: ${{ matrix.mpi }} - PHDF5: ${{ matrix.mpi }} - OMP: ${{ matrix.omp }} - DAGMC: ${{ matrix.dagmc }} - EVENT: ${{ matrix.event }} - VECTFIT: ${{ matrix.vectfit }} - LIBMESH: ${{ matrix.libmesh }} - NPY_DISABLE_CPU_FEATURES: "AVX512F AVX512_SKX" - OPENBLAS_NUM_THREADS: 1 - # libfabric complains about fork() as a result of using Python multiprocessing. - # We can work around it with RDMAV_FORK_SAFE=1 in libfabric < 1.13 and with - # FI_EFA_FORK_SAFE=1 in more recent versions. - RDMAV_FORK_SAFE: 1 - - steps: - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: '3.31' - - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Environment Variables - run: | - echo "OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml" >> $GITHUB_ENV - echo "OPENMC_ENDF_DATA=$HOME/endf-b-vii.1" >> $GITHUB_ENV - # get the sha of the last branch commit - # for push and workflow_dispatch events, use the current reference head - BRANCH_SHA=HEAD - # for a pull_request event, use the last reference of the parents of the merge commit - if [ "${{ github.event_name }}" == "pull_request" ]; then - BRANCH_SHA=$(git rev-list --parents -n 1 HEAD | rev | cut -d" " -f 1 | rev) - fi - COMMIT_MESSAGE=$(git log $BRANCH_SHA -1 --pretty=%B | tr '\n' ' ') - echo ${COMMIT_MESSAGE} - echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV - - - name: Apt dependencies - shell: bash - run: | - sudo apt -y update - sudo apt install -y libpng-dev \ - libnetcdf-dev \ - libpnetcdf-dev \ - libhdf5-serial-dev \ - libeigen3-dev - - - name: Optional apt dependencies for MPI - shell: bash - if: ${{ matrix.mpi == 'y' }} - run: | - sudo apt install -y libhdf5-mpich-dev \ - libmpich-dev - sudo update-alternatives --set mpi /usr/bin/mpicc.mpich - sudo update-alternatives --set mpirun /usr/bin/mpirun.mpich - sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich - - - name: Optional apt dependencies for vectfit - shell: bash - if: ${{ matrix.vectfit == 'y' }} - run: sudo apt install -y libblas-dev liblapack-dev - - - name: install - shell: bash - run: | - echo "$HOME/NJOY2016/build" >> $GITHUB_PATH - $GITHUB_WORKSPACE/tools/ci/gha-install.sh - - - name: display-config - shell: bash - run: | - openmc -v - - - name: cache-xs - uses: actions/cache@v4 - with: - path: | - ~/nndc_hdf5 - ~/endf-b-vii.1 - key: ${{ runner.os }}-build-xs-cache - - - name: before - shell: bash - run: $GITHUB_WORKSPACE/tools/ci/gha-before-script.sh - - - name: test - shell: bash - run: | - CTEST_OUTPUT_ON_FAILURE=1 make test -C $GITHUB_WORKSPACE/build/ - $GITHUB_WORKSPACE/tools/ci/gha-script.sh - - - name: Setup tmate debug session - continue-on-error: true - if: ${{ contains(env.COMMIT_MESSAGE, '[gha-debug]') }} - uses: mxschmitt/action-tmate@v3 - timeout-minutes: 10 - - - name: after_success - shell: bash - run: | - cpp-coveralls -i src -i include -e src/external --exclude-pattern "/usr/*" --dump cpp_cov.json - coveralls --merge=cpp_cov.json --service=github + #main: + # runs-on: ubuntu-22.04 + # strategy: + # matrix: + # python-version: ["3.11"] + # mpi: [n, y] + # omp: [n, y] + # dagmc: [n] + # libmesh: [n] + # event: [n] + # vectfit: [n] + + # include: + # - python-version: "3.12" + # omp: n + # mpi: n + # - python-version: "3.13" + # omp: n + # mpi: n + # - dagmc: y + # python-version: "3.11" + # mpi: y + # omp: y + # - libmesh: y + # python-version: "3.11" + # mpi: y + # omp: y + # - libmesh: y + # python-version: "3.11" + # mpi: n + # omp: y + # - event: y + # python-version: "3.11" + # omp: y + # mpi: n + # - vectfit: y + # python-version: "3.11" + # omp: n + # mpi: y + # name: "Python ${{ matrix.python-version }} (omp=${{ matrix.omp }}, + # mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }}, + # libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }} + # vectfit=${{ matrix.vectfit }})" + + # env: + # MPI: ${{ matrix.mpi }} + # PHDF5: ${{ matrix.mpi }} + # OMP: ${{ matrix.omp }} + # DAGMC: ${{ matrix.dagmc }} + # EVENT: ${{ matrix.event }} + # VECTFIT: ${{ matrix.vectfit }} + # LIBMESH: ${{ matrix.libmesh }} + # NPY_DISABLE_CPU_FEATURES: "AVX512F AVX512_SKX" + # OPENBLAS_NUM_THREADS: 1 + # # libfabric complains about fork() as a result of using Python multiprocessing. + # # We can work around it with RDMAV_FORK_SAFE=1 in libfabric < 1.13 and with + # # FI_EFA_FORK_SAFE=1 in more recent versions. + # RDMAV_FORK_SAFE: 1 + + # steps: + # - name: Setup cmake + # uses: jwlawson/actions-setup-cmake@v2 + # with: + # cmake-version: '3.31' + + # - name: Checkout repository + # uses: actions/checkout@v4 + # with: + # fetch-depth: 0 + + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v5 + # with: + # python-version: ${{ matrix.python-version }} + + # - name: Environment Variables + # run: | + # echo "OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml" >> $GITHUB_ENV + # echo "OPENMC_ENDF_DATA=$HOME/endf-b-vii.1" >> $GITHUB_ENV + # # get the sha of the last branch commit + # # for push and workflow_dispatch events, use the current reference head + # BRANCH_SHA=HEAD + # # for a pull_request event, use the last reference of the parents of the merge commit + # if [ "${{ github.event_name }}" == "pull_request" ]; then + # BRANCH_SHA=$(git rev-list --parents -n 1 HEAD | rev | cut -d" " -f 1 | rev) + # fi + # COMMIT_MESSAGE=$(git log $BRANCH_SHA -1 --pretty=%B | tr '\n' ' ') + # echo ${COMMIT_MESSAGE} + # echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV + + # - name: Apt dependencies + # shell: bash + # run: | + # sudo apt -y update + # sudo apt install -y libpng-dev \ + # libnetcdf-dev \ + # libpnetcdf-dev \ + # libhdf5-serial-dev \ + # libeigen3-dev + + # - name: Optional apt dependencies for MPI + # shell: bash + # if: ${{ matrix.mpi == 'y' }} + # run: | + # sudo apt install -y libhdf5-mpich-dev \ + # libmpich-dev + # sudo update-alternatives --set mpi /usr/bin/mpicc.mpich + # sudo update-alternatives --set mpirun /usr/bin/mpirun.mpich + # sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich + + # - name: Optional apt dependencies for vectfit + # shell: bash + # if: ${{ matrix.vectfit == 'y' }} + # run: sudo apt install -y libblas-dev liblapack-dev + + # - name: install + # shell: bash + # run: | + # echo "$HOME/NJOY2016/build" >> $GITHUB_PATH + # $GITHUB_WORKSPACE/tools/ci/gha-install.sh + + # - name: display-config + # shell: bash + # run: | + # openmc -v + + # - name: cache-xs + # uses: actions/cache@v4 + # with: + # path: | + # ~/nndc_hdf5 + # ~/endf-b-vii.1 + # key: ${{ runner.os }}-build-xs-cache + + # - name: before + # shell: bash + # run: $GITHUB_WORKSPACE/tools/ci/gha-before-script.sh + + # - name: test + # shell: bash + # run: | + # CTEST_OUTPUT_ON_FAILURE=1 make test -C $GITHUB_WORKSPACE/build/ + # $GITHUB_WORKSPACE/tools/ci/gha-script.sh + + # - name: Setup tmate debug session + # continue-on-error: true + # if: ${{ contains(env.COMMIT_MESSAGE, '[gha-debug]') }} + # uses: mxschmitt/action-tmate@v3 + # timeout-minutes: 10 + + # - name: after_success + # shell: bash + # run: | + # cpp-coveralls -i src -i include -e src/external --exclude-pattern "/usr/*" --dump cpp_cov.json + # coveralls --merge=cpp_cov.json --service=github win: runs-on: windows-latest From 6611d85809c0b8edab37f4e04e3d8197ef3c989b Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 16:53:36 -0400 Subject: [PATCH 37/44] Undo trying to disable Ubuntu CICD. Didn't work right. --- .github/workflows/ci.yml | 310 +++++++++++++++++++-------------------- 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42508b97ff8..956acfd040f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,161 +21,161 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - #main: - # runs-on: ubuntu-22.04 - # strategy: - # matrix: - # python-version: ["3.11"] - # mpi: [n, y] - # omp: [n, y] - # dagmc: [n] - # libmesh: [n] - # event: [n] - # vectfit: [n] - - # include: - # - python-version: "3.12" - # omp: n - # mpi: n - # - python-version: "3.13" - # omp: n - # mpi: n - # - dagmc: y - # python-version: "3.11" - # mpi: y - # omp: y - # - libmesh: y - # python-version: "3.11" - # mpi: y - # omp: y - # - libmesh: y - # python-version: "3.11" - # mpi: n - # omp: y - # - event: y - # python-version: "3.11" - # omp: y - # mpi: n - # - vectfit: y - # python-version: "3.11" - # omp: n - # mpi: y - # name: "Python ${{ matrix.python-version }} (omp=${{ matrix.omp }}, - # mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }}, - # libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }} - # vectfit=${{ matrix.vectfit }})" - - # env: - # MPI: ${{ matrix.mpi }} - # PHDF5: ${{ matrix.mpi }} - # OMP: ${{ matrix.omp }} - # DAGMC: ${{ matrix.dagmc }} - # EVENT: ${{ matrix.event }} - # VECTFIT: ${{ matrix.vectfit }} - # LIBMESH: ${{ matrix.libmesh }} - # NPY_DISABLE_CPU_FEATURES: "AVX512F AVX512_SKX" - # OPENBLAS_NUM_THREADS: 1 - # # libfabric complains about fork() as a result of using Python multiprocessing. - # # We can work around it with RDMAV_FORK_SAFE=1 in libfabric < 1.13 and with - # # FI_EFA_FORK_SAFE=1 in more recent versions. - # RDMAV_FORK_SAFE: 1 - - # steps: - # - name: Setup cmake - # uses: jwlawson/actions-setup-cmake@v2 - # with: - # cmake-version: '3.31' - - # - name: Checkout repository - # uses: actions/checkout@v4 - # with: - # fetch-depth: 0 - - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v5 - # with: - # python-version: ${{ matrix.python-version }} - - # - name: Environment Variables - # run: | - # echo "OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml" >> $GITHUB_ENV - # echo "OPENMC_ENDF_DATA=$HOME/endf-b-vii.1" >> $GITHUB_ENV - # # get the sha of the last branch commit - # # for push and workflow_dispatch events, use the current reference head - # BRANCH_SHA=HEAD - # # for a pull_request event, use the last reference of the parents of the merge commit - # if [ "${{ github.event_name }}" == "pull_request" ]; then - # BRANCH_SHA=$(git rev-list --parents -n 1 HEAD | rev | cut -d" " -f 1 | rev) - # fi - # COMMIT_MESSAGE=$(git log $BRANCH_SHA -1 --pretty=%B | tr '\n' ' ') - # echo ${COMMIT_MESSAGE} - # echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV - - # - name: Apt dependencies - # shell: bash - # run: | - # sudo apt -y update - # sudo apt install -y libpng-dev \ - # libnetcdf-dev \ - # libpnetcdf-dev \ - # libhdf5-serial-dev \ - # libeigen3-dev - - # - name: Optional apt dependencies for MPI - # shell: bash - # if: ${{ matrix.mpi == 'y' }} - # run: | - # sudo apt install -y libhdf5-mpich-dev \ - # libmpich-dev - # sudo update-alternatives --set mpi /usr/bin/mpicc.mpich - # sudo update-alternatives --set mpirun /usr/bin/mpirun.mpich - # sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich - - # - name: Optional apt dependencies for vectfit - # shell: bash - # if: ${{ matrix.vectfit == 'y' }} - # run: sudo apt install -y libblas-dev liblapack-dev - - # - name: install - # shell: bash - # run: | - # echo "$HOME/NJOY2016/build" >> $GITHUB_PATH - # $GITHUB_WORKSPACE/tools/ci/gha-install.sh - - # - name: display-config - # shell: bash - # run: | - # openmc -v - - # - name: cache-xs - # uses: actions/cache@v4 - # with: - # path: | - # ~/nndc_hdf5 - # ~/endf-b-vii.1 - # key: ${{ runner.os }}-build-xs-cache - - # - name: before - # shell: bash - # run: $GITHUB_WORKSPACE/tools/ci/gha-before-script.sh - - # - name: test - # shell: bash - # run: | - # CTEST_OUTPUT_ON_FAILURE=1 make test -C $GITHUB_WORKSPACE/build/ - # $GITHUB_WORKSPACE/tools/ci/gha-script.sh - - # - name: Setup tmate debug session - # continue-on-error: true - # if: ${{ contains(env.COMMIT_MESSAGE, '[gha-debug]') }} - # uses: mxschmitt/action-tmate@v3 - # timeout-minutes: 10 - - # - name: after_success - # shell: bash - # run: | - # cpp-coveralls -i src -i include -e src/external --exclude-pattern "/usr/*" --dump cpp_cov.json - # coveralls --merge=cpp_cov.json --service=github + main: + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: ["3.11"] + mpi: [n, y] + omp: [n, y] + dagmc: [n] + libmesh: [n] + event: [n] + vectfit: [n] + + include: + - python-version: "3.12" + omp: n + mpi: n + - python-version: "3.13" + omp: n + mpi: n + - dagmc: y + python-version: "3.11" + mpi: y + omp: y + - libmesh: y + python-version: "3.11" + mpi: y + omp: y + - libmesh: y + python-version: "3.11" + mpi: n + omp: y + - event: y + python-version: "3.11" + omp: y + mpi: n + - vectfit: y + python-version: "3.11" + omp: n + mpi: y + name: "Python ${{ matrix.python-version }} (omp=${{ matrix.omp }}, + mpi=${{ matrix.mpi }}, dagmc=${{ matrix.dagmc }}, + libmesh=${{ matrix.libmesh }}, event=${{ matrix.event }} + vectfit=${{ matrix.vectfit }})" + + env: + MPI: ${{ matrix.mpi }} + PHDF5: ${{ matrix.mpi }} + OMP: ${{ matrix.omp }} + DAGMC: ${{ matrix.dagmc }} + EVENT: ${{ matrix.event }} + VECTFIT: ${{ matrix.vectfit }} + LIBMESH: ${{ matrix.libmesh }} + NPY_DISABLE_CPU_FEATURES: "AVX512F AVX512_SKX" + OPENBLAS_NUM_THREADS: 1 + # libfabric complains about fork() as a result of using Python multiprocessing. + # We can work around it with RDMAV_FORK_SAFE=1 in libfabric < 1.13 and with + # FI_EFA_FORK_SAFE=1 in more recent versions. + RDMAV_FORK_SAFE: 1 + + steps: + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.31' + + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Environment Variables + run: | + echo "OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml" >> $GITHUB_ENV + echo "OPENMC_ENDF_DATA=$HOME/endf-b-vii.1" >> $GITHUB_ENV + # get the sha of the last branch commit + # for push and workflow_dispatch events, use the current reference head + BRANCH_SHA=HEAD + # for a pull_request event, use the last reference of the parents of the merge commit + if [ "${{ github.event_name }}" == "pull_request" ]; then + BRANCH_SHA=$(git rev-list --parents -n 1 HEAD | rev | cut -d" " -f 1 | rev) + fi + COMMIT_MESSAGE=$(git log $BRANCH_SHA -1 --pretty=%B | tr '\n' ' ') + echo ${COMMIT_MESSAGE} + echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV + + - name: Apt dependencies + shell: bash + run: | + sudo apt -y update + sudo apt install -y libpng-dev \ + libnetcdf-dev \ + libpnetcdf-dev \ + libhdf5-serial-dev \ + libeigen3-dev + + - name: Optional apt dependencies for MPI + shell: bash + if: ${{ matrix.mpi == 'y' }} + run: | + sudo apt install -y libhdf5-mpich-dev \ + libmpich-dev + sudo update-alternatives --set mpi /usr/bin/mpicc.mpich + sudo update-alternatives --set mpirun /usr/bin/mpirun.mpich + sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich + + - name: Optional apt dependencies for vectfit + shell: bash + if: ${{ matrix.vectfit == 'y' }} + run: sudo apt install -y libblas-dev liblapack-dev + + - name: install + shell: bash + run: | + echo "$HOME/NJOY2016/build" >> $GITHUB_PATH + $GITHUB_WORKSPACE/tools/ci/gha-install.sh + + - name: display-config + shell: bash + run: | + openmc -v + + - name: cache-xs + uses: actions/cache@v4 + with: + path: | + ~/nndc_hdf5 + ~/endf-b-vii.1 + key: ${{ runner.os }}-build-xs-cache + + - name: before + shell: bash + run: $GITHUB_WORKSPACE/tools/ci/gha-before-script.sh + + - name: test + shell: bash + run: | + CTEST_OUTPUT_ON_FAILURE=1 make test -C $GITHUB_WORKSPACE/build/ + $GITHUB_WORKSPACE/tools/ci/gha-script.sh + + - name: Setup tmate debug session + continue-on-error: true + if: ${{ contains(env.COMMIT_MESSAGE, '[gha-debug]') }} + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 10 + + - name: after_success + shell: bash + run: | + cpp-coveralls -i src -i include -e src/external --exclude-pattern "/usr/*" --dump cpp_cov.json + coveralls --merge=cpp_cov.json --service=github win: runs-on: windows-latest From 53e1b8211adb65181b2ce36bbc435d96271110c3 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 17:06:28 -0400 Subject: [PATCH 38/44] Require Windows tests and run them first (for now). --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 956acfd040f..e658b0b01d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -250,7 +250,7 @@ jobs: ${{github.workspace}}\tools\ci\gha-script.ps1 finish: - needs: main + needs: [win, main] runs-on: ubuntu-latest steps: - name: Coveralls Finished From c511b7970b030fe8a87c14b94f90c2f78c680741 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 22:25:41 -0400 Subject: [PATCH 39/44] Updates to Windows CI scripts and actions. --- .github/workflows/ci.yml | 19 +++++++------------ tools/ci/download-xs.ps1 | 2 +- tools/ci/gha-install.ps1 | 16 ++++++++++++++++ tools/ci/gha-install.py | 2 +- tools/ci/gha-script.ps1 | 2 +- tools/ci/hdf5_install.ps1 | 10 ---------- 6 files changed, 26 insertions(+), 25 deletions(-) delete mode 100644 tools/ci/hdf5_install.ps1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e658b0b01d9..0cbb31def30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -215,11 +215,6 @@ jobs: [Environment]::SetEnvironmentVariable("OPENMC_CROSS_SECTIONS", "$Env:GITHUB_WORKSPACE\nndc_hdf5\cross_sections.xml", 'Machine') [Environment]::SetEnvironmentVariable("OPENMC_ENDF_DATA", "$Env:GITHUB_WORKSPACE\endf-b-vii.1", 'Machine') - - name: HDF5 Dependency - shell: pwsh - run: | - ${{github.workspace}}\tools\ci\hdf5_install.ps1 - - name: Cache XS uses: actions/cache@v4 with: @@ -233,12 +228,6 @@ jobs: run: | ${{github.workspace}}\tools\ci\gha-install.ps1 - - name: Breakpoint For Debugging - uses: namespacelabs/breakpoint-action@v0 - with: - duration: 30m - authorized-users: HunterBelanger - - name: Before shell: pwsh run: ${{github.workspace}}\tools\ci\download-xs.ps1 @@ -246,9 +235,15 @@ jobs: - name: Test shell: pwsh run: | - ctest --output-on-failure -C Debug ${{ github.workspace }}\build\ + ctest --output-on-failure -C Release ${{ github.workspace }}\build\ ${{github.workspace}}\tools\ci\gha-script.ps1 + - name: Setup tmate debug session + continue-on-error: true + if: ${{ contains(env.COMMIT_MESSAGE, '[gha-debug]') }} + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 10 + finish: needs: [win, main] runs-on: ubuntu-latest diff --git a/tools/ci/download-xs.ps1 b/tools/ci/download-xs.ps1 index 74a45943212..c94cc0f2dd4 100644 --- a/tools/ci/download-xs.ps1 +++ b/tools/ci/download-xs.ps1 @@ -9,6 +9,6 @@ if (-not (Test-Path "$Env:GITHUB_WORKSPACE\nndc_hdf5")) { # Download ENDF/B-VII.1 distribution $Env:ENDF = "$Env:GITHUB_WORKSPACE\endf-b-vii.1" if (-not (Test-Path $Env:ENDF)) { - Invoke-WebRequest https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -OutFile endf.xs -UseBasicParsing + Invoke-WebRequest https://anl.box.com/shared/static/4kd2gxnf4gtk4w1c8eua5fsua22kvgjb.xz -OutFile endf.xz -UseBasicParsing tar -xvzf endf.xz } diff --git a/tools/ci/gha-install.ps1 b/tools/ci/gha-install.ps1 index cdd4a62c659..600d8310ecc 100644 --- a/tools/ci/gha-install.ps1 +++ b/tools/ci/gha-install.ps1 @@ -1,3 +1,19 @@ +# Install VCPKG +git clone https://github.com/microsoft/vcpkg.git "$Env:GITHUB_WORKSPACE\..\vcpkg" + +cd "$Env:GITHUB_WORKSPACE\..\vcpkg" +.\bootstrap-vcpkg.bat + +[Environment]::SetEnvironmentVariable("VCPKG_ROOT", "$Env:GITHUB_WORKSPACE\..\vcpkg", [System.EnvironmentVariableTarget]::User) +$Env:VCPKG_ROOT = "$Env:GITHUB_WORKSPACE\..\vcpkg" +$Env:Path += ";$Env:VCPKG_ROOT" + +# Install HDF5 +vcpkg install hdf5:x64-windows-static + +# Go back to main directory for install +cd "$Env:GITHUB_WORKSPACE" + # Upgrade pip, pytest, numpy before doing anything else. pip install --upgrade pip pip install --upgrade pytest diff --git a/tools/ci/gha-install.py b/tools/ci/gha-install.py index 59f9adba381..88f5b1d4441 100644 --- a/tools/ci/gha-install.py +++ b/tools/ci/gha-install.py @@ -13,7 +13,7 @@ def install(omp=False, mpi=False, phdf5=False, dagmc=False, libmesh=False): # Build in debug mode by default with support for MCPL if sys.platform == 'win32': work_dir = os.environ.get('GITHUB_WORKSPACE') - cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static'] + cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_TOOLCHAIN_FILE='+work_dir+'\\..\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake', '-DVCPKG_TARGET_TRIPLET=x64-windows-static'] else: cmake_cmd = ['cmake', '-DCMAKE_BUILD_TYPE=Debug', '-DOPENMC_USE_MCPL=on'] diff --git a/tools/ci/gha-script.ps1 b/tools/ci/gha-script.ps1 index 04a5c7817cf..bd3f89b856b 100644 --- a/tools/ci/gha-script.ps1 +++ b/tools/ci/gha-script.ps1 @@ -7,4 +7,4 @@ if ($Env:EVENT) { } # Run regression and unit tests -python --cov=openmc -v $Env:args tests \ No newline at end of file +pytest --cov=openmc -v $Env:args tests \ No newline at end of file diff --git a/tools/ci/hdf5_install.ps1 b/tools/ci/hdf5_install.ps1 deleted file mode 100644 index 9798d648d35..00000000000 --- a/tools/ci/hdf5_install.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -git clone https://github.com/microsoft/vcpkg.git "$Env:GITHUB_WORKSPACE\vcpkg" - -cd "$Env:GITHUB_WORKSPACE\vcpkg" -.\bootstrap-vcpkg.bat - -[Environment]::SetEnvironmentVariable("VCPKG_ROOT", "$Env:GITHUB_WORKSPACE\vcpkg", [System.EnvironmentVariableTarget]::User) -$Env:VCPKG_ROOT = "$Env:GITHUB_WORKSPACE\vcpkg" -$Env:Path += ";$Env:VCPKG_ROOT" - -vcpkg install hdf5:x64-windows-static \ No newline at end of file From 06df927063ff2bcd70f7007a3eb59f4e23f06d26 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 22:28:23 -0400 Subject: [PATCH 40/44] Skip compiled source tests on Windows. --- tests/regression_tests/cpp_driver/test.py | 4 ++++ tests/regression_tests/source_dlopen/test.py | 4 ++++ tests/regression_tests/source_parameterized_dlopen/test.py | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/tests/regression_tests/cpp_driver/test.py b/tests/regression_tests/cpp_driver/test.py index b80e82ee0e1..286f0a7377f 100644 --- a/tests/regression_tests/cpp_driver/test.py +++ b/tests/regression_tests/cpp_driver/test.py @@ -1,5 +1,6 @@ from pathlib import Path import os +import sys import shutil import subprocess import textwrap @@ -11,6 +12,9 @@ from tests.regression_tests import config from tests.testing_harness import PyAPITestHarness +pytestmark = pytest.mark.skipif( + sys.platform == 'win32', + reason="Cannot use compiled tests on Windows.") @pytest.fixture def cpp_driver(request): diff --git a/tests/regression_tests/source_dlopen/test.py b/tests/regression_tests/source_dlopen/test.py index 0581d6deec4..c3308a0b8fc 100644 --- a/tests/regression_tests/source_dlopen/test.py +++ b/tests/regression_tests/source_dlopen/test.py @@ -1,5 +1,6 @@ from pathlib import Path import os +import sys import shutil import subprocess import textwrap @@ -9,6 +10,9 @@ from tests.testing_harness import PyAPITestHarness +pytestmark = pytest.mark.skipif( + sys.platform == 'win32', + reason="Cannot use compiled tests on Windows.") @pytest.fixture def compile_source(request): diff --git a/tests/regression_tests/source_parameterized_dlopen/test.py b/tests/regression_tests/source_parameterized_dlopen/test.py index 151fb37356e..441a125e85f 100644 --- a/tests/regression_tests/source_parameterized_dlopen/test.py +++ b/tests/regression_tests/source_parameterized_dlopen/test.py @@ -1,5 +1,6 @@ from pathlib import Path import os +import sys import shutil import subprocess import textwrap @@ -9,6 +10,9 @@ from tests.testing_harness import PyAPITestHarness +pytestmark = pytest.mark.skipif( + sys.platform == 'win32', + reason="Cannot use compiled tests on Windows.") @pytest.fixture def compile_source(request): From 84753ef67007bb792862f2b66774b5ddf8884346 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 22:29:33 -0400 Subject: [PATCH 41/44] Update comparison of file paths for cross platform compatability. --- tests/unit_tests/test_config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit_tests/test_config.py b/tests/unit_tests/test_config.py index 9d3f53a7403..a1037bf074a 100644 --- a/tests/unit_tests/test_config.py +++ b/tests/unit_tests/test_config.py @@ -3,6 +3,7 @@ import openmc import pytest +from pathlib import Path @pytest.fixture(autouse=True, scope='module') @@ -38,8 +39,8 @@ def test_config_basics(): def test_config_patch(): openmc.config['cross_sections'] = '/path/to/cross_sections.xml' with openmc.config.patch('cross_sections', '/path/to/other.xml'): - assert str(openmc.config['cross_sections']) == '/path/to/other.xml' - assert str(openmc.config['cross_sections']) == '/path/to/cross_sections.xml' + assert str(openmc.config['cross_sections']) == str(Path('/path/to/other.xml')) + assert str(openmc.config['cross_sections']) == str(Path('/path/to/cross_sections.xml')) def test_config_set_envvar(): From 0c12586005f3c0d9570ea3220a5b8d1864041916 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 22:30:10 -0400 Subject: [PATCH 42/44] Fixes for tests that were failing due to Windows line endings. --- tests/regression_tests/deplete_decay_only/test.py | 2 +- tests/regression_tests/deplete_no_transport/test.py | 2 +- tests/regression_tests/diff_tally/test.py | 2 +- tests/regression_tests/microxs/test.py | 4 ++-- tests/regression_tests/surface_tally/test.py | 2 +- tests/unit_tests/test_deplete_independent_operator.py | 4 ++-- tests/unit_tests/test_deplete_microxs.py | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/regression_tests/deplete_decay_only/test.py b/tests/regression_tests/deplete_decay_only/test.py index 4345b86b898..7b9f9af9714 100644 --- a/tests/regression_tests/deplete_decay_only/test.py +++ b/tests/regression_tests/deplete_decay_only/test.py @@ -50,7 +50,7 @@ def model(): @pytest.fixture(scope="module") def micro_xs(): micro_xs_file = Path(__file__).parents[2] / 'micro_xs_simple.csv' - return MicroXS.from_csv(micro_xs_file) + return MicroXS.from_csv(micro_xs_file, lineterminator='\n') @pytest.fixture(scope="module") diff --git a/tests/regression_tests/deplete_no_transport/test.py b/tests/regression_tests/deplete_no_transport/test.py index 63ae584e116..b76c4fa01d8 100644 --- a/tests/regression_tests/deplete_no_transport/test.py +++ b/tests/regression_tests/deplete_no_transport/test.py @@ -28,7 +28,7 @@ def fuel(): @pytest.fixture(scope="module") def micro_xs(): micro_xs_file = Path(__file__).parents[2] / 'micro_xs_simple.csv' - return MicroXS.from_csv(micro_xs_file) + return MicroXS.from_csv(micro_xs_file, lineterminator='\n') @pytest.fixture(scope="module") diff --git a/tests/regression_tests/diff_tally/test.py b/tests/regression_tests/diff_tally/test.py index 89460df9152..5ab1f52f621 100644 --- a/tests/regression_tests/diff_tally/test.py +++ b/tests/regression_tests/diff_tally/test.py @@ -109,7 +109,7 @@ def _get_results(self): # Extract the relevant data as a CSV string. cols = ('d_material', 'd_nuclide', 'd_variable', 'score', 'mean', 'std. dev.') - return df.to_csv(None, columns=cols, index=False, float_format='%.7e') + return df.to_csv(None, columns=cols, index=False, float_format='%.7e', lineterminator='\n') def test_diff_tally(): diff --git a/tests/regression_tests/microxs/test.py b/tests/regression_tests/microxs/test.py index a35150a1b80..bf36c37099f 100644 --- a/tests/regression_tests/microxs/test.py +++ b/tests/regression_tests/microxs/test.py @@ -60,8 +60,8 @@ def test_from_model(model, domain_type): 'Xe136', 'Cs135', 'Gd157', 'Gd156'] _, test_xs = get_microxs_and_flux(model, domains, nuclides, chain_file=CHAIN_FILE) if config['update']: - test_xs[0].to_csv(f'test_reference_{domain_type}.csv') + test_xs[0].to_csv(f'test_reference_{domain_type}.csv', lineterminator='\n') - ref_xs = MicroXS.from_csv(f'test_reference_{domain_type}.csv') + ref_xs = MicroXS.from_csv(f'test_reference_{domain_type}.csv', lineterminator='\n') np.testing.assert_allclose(test_xs[0].data, ref_xs.data, rtol=1e-11) diff --git a/tests/regression_tests/surface_tally/test.py b/tests/regression_tests/surface_tally/test.py index e496ac0f65c..0f2507db480 100644 --- a/tests/regression_tests/surface_tally/test.py +++ b/tests/regression_tests/surface_tally/test.py @@ -168,7 +168,7 @@ def _get_results(self): # Extract the relevant data as a CSV string. cols = ('mean', 'std. dev.') - return df.to_csv(None, columns=cols, index=False, float_format='%.7e') + return df.to_csv(None, columns=cols, index=False, float_format='%.7e', lineterminator='\n') return outstr diff --git a/tests/unit_tests/test_deplete_independent_operator.py b/tests/unit_tests/test_deplete_independent_operator.py index c765d065009..88d3f8e8546 100644 --- a/tests/unit_tests/test_deplete_independent_operator.py +++ b/tests/unit_tests/test_deplete_independent_operator.py @@ -24,7 +24,7 @@ def test_operator_init(): 'O16': 4.639065406771322e+22, 'O17': 1.7588724018066158e+19} flux = 1.0 - micro_xs = MicroXS.from_csv(ONE_GROUP_XS) + micro_xs = MicroXS.from_csv(ONE_GROUP_XS, lineterminator='\n') IndependentOperator.from_nuclides( volume, nuclides, flux, micro_xs, CHAIN_PATH, nuc_units='atom/cm3') @@ -41,7 +41,7 @@ def test_operator_init(): def test_error_handling(): - micro_xs = MicroXS.from_csv(ONE_GROUP_XS) + micro_xs = MicroXS.from_csv(ONE_GROUP_XS, lineterminator='\n') fuel = Material(name="oxygen") fuel.add_element("O", 2) fuel.set_density("g/cc", 1) diff --git a/tests/unit_tests/test_deplete_microxs.py b/tests/unit_tests/test_deplete_microxs.py index 073b3f162d1..aebc7c6ff8e 100644 --- a/tests/unit_tests/test_deplete_microxs.py +++ b/tests/unit_tests/test_deplete_microxs.py @@ -51,9 +51,9 @@ def test_from_array(): def test_csv(): - ref_xs = MicroXS.from_csv(ONE_GROUP_XS) - ref_xs.to_csv('temp_xs.csv') - temp_xs = MicroXS.from_csv('temp_xs.csv') + ref_xs = MicroXS.from_csv(ONE_GROUP_XS, lineterminator='\n') + ref_xs.to_csv('temp_xs.csv', lineterminator='\n') + temp_xs = MicroXS.from_csv('temp_xs.csv', lineterminator='\n') assert np.all(ref_xs.data == temp_xs.data) remove('temp_xs.csv') From be79895aea50f4b756d1ef183cc3bc29fd47f647 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Mon, 5 May 2025 22:30:38 -0400 Subject: [PATCH 43/44] Fix failing plot test on Windows. --- openmc/model/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/model/model.py b/openmc/model/model.py index 9ff574ec63c..f9196044c75 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -982,7 +982,7 @@ def plot( if outline: # Combine R, G, B values into a single int - rgb = (img * 256).astype(int) + rgb = img.astype(int) * 256 image_value = (rgb[..., 0] << 16) + \ (rgb[..., 1] << 8) + (rgb[..., 2]) From 3fb37a75bbdfb01d81335f353feb8cfd3510e71f Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Fri, 9 May 2025 16:45:39 -0400 Subject: [PATCH 44/44] Fixes some iterator / uninitialized bugs causing windows debug builds to abort. --- src/cell.cpp | 6 ++++-- src/secondary_correlated.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cell.cpp b/src/cell.cpp index 4b26992299e..3640a4a501c 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -482,7 +482,9 @@ Region::Region(std::string region_spec, int32_t cell_id) auto it = std::find(expression_.begin(), expression_.end(), OP_COMPLEMENT); while (it != expression_.end()) { // Erase complement - expression_.erase(it); + it = expression_.erase(it); + if (it == expression_.end()) + break; // Shouldn't happen, but to be safe // Define stop given left parenthesis or not auto stop = it; @@ -536,7 +538,7 @@ Region::Region(std::string region_spec, int32_t cell_id) if (simple_) { for (auto it = expression_.begin(); it != expression_.end(); it++) { if (*it == OP_INTERSECTION || *it > OP_COMPLEMENT) { - expression_.erase(it); + it = expression_.erase(it); it--; } } diff --git a/src/secondary_correlated.cpp b/src/secondary_correlated.cpp index 0e4891dd3e7..0674c89fa74 100644 --- a/src/secondary_correlated.cpp +++ b/src/secondary_correlated.cpp @@ -208,7 +208,7 @@ void CorrelatedAngleEnergy::sample( } // Continuous portion - double c_k1; + double c_k1 = 0.; for (int j = n_discrete; j < end; ++j) { k = j; c_k1 = distribution_[l].c[k + 1];