mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Tiny updates from experience building on Mac (#2894)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
5111aa2621
commit
b53b601edc
15 changed files with 95 additions and 55 deletions
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
project(openmc C CXX)
|
||||
project(openmc CXX)
|
||||
|
||||
# Set version numbers
|
||||
set(OPENMC_VERSION_MAJOR 0)
|
||||
|
|
@ -80,6 +80,14 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build" FORCE)
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
# OpenMP for shared-memory parallelism (and GPU support some day!)
|
||||
#===============================================================================
|
||||
|
||||
if(OPENMC_USE_OPENMP)
|
||||
find_package(OpenMP REQUIRED)
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
# MPI for distributed-memory parallelism
|
||||
#===============================================================================
|
||||
|
|
@ -192,13 +200,6 @@ endif()
|
|||
# Skip for Visual Studio which has its own configurations through GUI
|
||||
if(NOT MSVC)
|
||||
|
||||
if(OPENMC_USE_OPENMP)
|
||||
find_package(OpenMP REQUIRED)
|
||||
# In CMake 3.9+, can use the OpenMP::OpenMP_CXX imported target
|
||||
list(APPEND cxxflags ${OpenMP_CXX_FLAGS})
|
||||
list(APPEND ldflags ${OpenMP_CXX_FLAGS})
|
||||
endif()
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(OPENMC_ENABLE_PROFILE)
|
||||
|
|
@ -522,6 +523,10 @@ if (PNG_FOUND)
|
|||
target_link_libraries(libopenmc PNG::PNG)
|
||||
endif()
|
||||
|
||||
if (OPENMC_USE_OPENMP)
|
||||
target_link_libraries(libopenmc OpenMP::OpenMP_CXX)
|
||||
endif()
|
||||
|
||||
if (OPENMC_USE_MPI)
|
||||
target_link_libraries(libopenmc MPI::MPI_CXX)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ if(@OPENMC_USE_MPI@)
|
|||
find_package(MPI REQUIRED)
|
||||
endif()
|
||||
|
||||
if(@OPENMC_USE_OPENMP@)
|
||||
find_package(OpenMP REQUIRED)
|
||||
endif()
|
||||
|
||||
if(@OPENMC_USE_MCPL@)
|
||||
find_package(MCPL REQUIRED)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -107,31 +107,54 @@ can be used to access the installed packages.
|
|||
.. _Spack: https://spack.readthedocs.io/en/latest/
|
||||
.. _setup guide: https://spack.readthedocs.io/en/latest/getting_started.html
|
||||
|
||||
--------------------------------
|
||||
Installing from Source on Ubuntu
|
||||
--------------------------------
|
||||
-------------------------------
|
||||
Manually Installing from Source
|
||||
-------------------------------
|
||||
|
||||
To build OpenMC from source, several :ref:`prerequisites <prerequisites>` are
|
||||
needed. If you are using Ubuntu or higher, all prerequisites can be installed
|
||||
directly from the package manager:
|
||||
Obtaining prerequisites on Ubuntu
|
||||
---------------------------------
|
||||
|
||||
When building OpenMC from source, all :ref:`prerequisites <prerequisites>` can
|
||||
be installed using the package manager:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
sudo apt install g++ cmake libhdf5-dev libpng-dev
|
||||
|
||||
After the packages have been installed, follow the instructions below for
|
||||
building and installing OpenMC from source.
|
||||
After the packages have been installed, follow the instructions to build from
|
||||
source below.
|
||||
|
||||
-------------------------------------------
|
||||
Installing from Source on Linux or Mac OS X
|
||||
-------------------------------------------
|
||||
Obtaining prerequisites on macOS
|
||||
--------------------------------
|
||||
|
||||
For an OpenMC build with multithreading enabled, a package manager like
|
||||
`Homebrew <https://brew.sh>`_ should first be installed. Then, the following
|
||||
packages should be installed, for example in Homebrew via:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
brew install llvm cmake xtensor hdf5 python libomp libpng
|
||||
|
||||
The compiler provided by the above LLVM package should be used in place of the
|
||||
one provisioned by XCode, which does not support the multithreading library used
|
||||
by OpenMC. Consequently, the C++ compiler should explicitly be set before
|
||||
proceeding:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
export CXX=/opt/homebrew/opt/llvm/bin/clang++
|
||||
|
||||
After the packages have been installed, follow the instructions to build from
|
||||
source below.
|
||||
|
||||
Building Source on Linux or macOS
|
||||
---------------------------------
|
||||
|
||||
All OpenMC source code is hosted on `GitHub
|
||||
<https://github.com/openmc-dev/openmc>`_. If you have `git
|
||||
<https://git-scm.com>`_, the `gcc <https://gcc.gnu.org/>`_ compiler suite,
|
||||
`CMake <https://cmake.org>`_, and `HDF5
|
||||
<https://www.hdfgroup.org/solutions/hdf5/>`_ installed, you can download and
|
||||
install OpenMC be entering the following commands in a terminal:
|
||||
<https://git-scm.com>`_, a modern C++ compiler, `CMake <https://cmake.org>`_,
|
||||
and `HDF5 <https://www.hdfgroup.org/solutions/hdf5/>`_ installed, you can
|
||||
download and install OpenMC by entering the following commands in a terminal:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
|
|
@ -151,14 +174,14 @@ should specify an installation directory where you have write access, e.g.
|
|||
cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local ..
|
||||
|
||||
The :mod:`openmc` Python package must be installed separately. The easiest way
|
||||
to install it is using `pip <https://pip.pypa.io/en/stable/>`_, which is
|
||||
included by default in Python 3.4+. From the root directory of the OpenMC
|
||||
distribution/repository, run:
|
||||
to install it is using `pip <https://pip.pypa.io/en/stable/>`_.
|
||||
From the root directory of the OpenMC repository, run:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
python -m pip install .
|
||||
|
||||
If you want to build a parallel version of OpenMC (using OpenMP or MPI),
|
||||
directions can be found in the :ref:`detailed installation instructions
|
||||
By default, OpenMC will be built with multithreading support. To build
|
||||
distributed-memory parallel versions of OpenMC using MPI or to configure other
|
||||
options, directions can be found in the :ref:`detailed installation instructions
|
||||
<usersguide_build>`.
|
||||
|
|
|
|||
|
|
@ -464,11 +464,11 @@ can typically be set for a single command, i.e.
|
|||
|
||||
.. _compile_linux:
|
||||
|
||||
Compiling on Linux and Mac OS X
|
||||
-------------------------------
|
||||
Compiling on Linux and macOS
|
||||
----------------------------
|
||||
|
||||
To compile OpenMC on Linux or Max OS X, run the following commands from within
|
||||
the root directory of the source code:
|
||||
To compile OpenMC on Linux or macOS, run the following commands from within the
|
||||
root directory of the source code:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
project(openmc_sources CXX)
|
||||
add_library(source SHARED source_ring.cpp)
|
||||
find_package(OpenMC REQUIRED)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
project(openmc_sources CXX)
|
||||
add_library(parameterized_source SHARED parameterized_source_ring.cpp)
|
||||
find_package(OpenMC REQUIRED)
|
||||
|
|
|
|||
|
|
@ -1169,10 +1169,11 @@ class WindowedMultipole(EqualityMixin):
|
|||
sqrtE = sqrt(E)
|
||||
invE = 1.0 / E
|
||||
|
||||
# Locate us. The i_window calc omits a + 1 present in F90 because of
|
||||
# the 1-based vs. 0-based indexing. Similarly startw needs to be
|
||||
# decreased by 1. endw does not need to be decreased because
|
||||
# range(startw, endw) does not include endw.
|
||||
# Locate us. The i_window calc omits a + 1 present from the legacy
|
||||
# Fortran version of OpenMC because of the 1-based vs. 0-based
|
||||
# indexing. Similarly startw needs to be decreased by 1. endw does
|
||||
# not need to be decreased because range(startw, endw) does not include
|
||||
# endw.
|
||||
i_window = min(self.n_windows - 1,
|
||||
int(np.floor((sqrtE - sqrt(self.E_min)) / self.spacing)))
|
||||
startw = self.windows[i_window, 0] - 1
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ MDGXS_TYPES = (
|
|||
'delayed-nu-fission matrix'
|
||||
)
|
||||
|
||||
# Maximum number of delayed groups, from src/constants.F90
|
||||
# Maximum number of delayed groups, from include/openmc/constants.h
|
||||
MAX_DELAYED_GROUPS = 8
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -634,16 +634,23 @@ void Nuclide::calculate_xs(
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure these values are set
|
||||
// Note, the only time either is used is in one of 4 places:
|
||||
// 1. physics.cpp - scatter - For inelastic scatter.
|
||||
// 2. physics.cpp - sample_fission - For partial fissions.
|
||||
// 3. tally.F90 - score_general - For tallying on MTxxx reactions.
|
||||
// 4. nuclide.cpp - calculate_urr_xs - For unresolved purposes.
|
||||
// It is worth noting that none of these occur in the resolved
|
||||
// resonance range, so the value here does not matter. index_temp is
|
||||
// set to -1 to force a segfault in case a developer messes up and tries
|
||||
// to use it with multipole.
|
||||
/*
|
||||
* index_temp, index_grid, and interp_factor are used only in the
|
||||
* following places:
|
||||
* 1. physics.cpp - scatter - For inelastic scatter.
|
||||
* 2. physics.cpp - sample_fission - For partial fissions.
|
||||
* 3. tallies/tally_scoring.cpp - score_general -
|
||||
* For tallying on MTxxx reactions.
|
||||
* 4. nuclide.cpp - calculate_urr_xs - For unresolved purposes.
|
||||
* It is worth noting that none of these occur in the resolved resonance
|
||||
* range, so the value here does not matter. index_temp is set to -1 to
|
||||
* force a segfault in case a developer messes up and tries to use it with
|
||||
* multipole.
|
||||
*
|
||||
* However, a segfault is not necessarily guaranteed with an out-of-bounds
|
||||
* access, so this technique should be replaced by something more robust
|
||||
* in the future.
|
||||
*/
|
||||
micro.index_temp = -1;
|
||||
micro.index_grid = -1;
|
||||
micro.interp_factor = 0.0;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <fmt/core.h>
|
||||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/constants.h" // For F90_NONE
|
||||
#include "openmc/constants.h" // For C_NONE
|
||||
#include "openmc/mgxs_interface.h"
|
||||
#include "openmc/search.h"
|
||||
#include "openmc/settings.h"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ def cpp_driver(request):
|
|||
openmc_dir = Path(str(request.config.rootdir)) / 'build'
|
||||
with open('CMakeLists.txt', 'w') as f:
|
||||
f.write(textwrap.dedent("""
|
||||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
project(openmc_cpp_driver CXX)
|
||||
add_executable(cpp_driver driver.cpp)
|
||||
find_package(OpenMC REQUIRED HINTS {})
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ def cpp_driver(request):
|
|||
openmc_dir = Path(str(request.config.rootdir)) / 'build'
|
||||
with open('CMakeLists.txt', 'w') as f:
|
||||
f.write(textwrap.dedent("""
|
||||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
project(openmc_cpp_driver CXX)
|
||||
add_executable(main main.cpp)
|
||||
find_package(OpenMC REQUIRED HINTS {})
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ def cpp_driver(request):
|
|||
openmc_dir = Path(str(request.config.rootdir)) / 'build'
|
||||
with open('CMakeLists.txt', 'w') as f:
|
||||
f.write(textwrap.dedent("""
|
||||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
project(openmc_cpp_driver CXX)
|
||||
add_executable(main main.cpp)
|
||||
find_package(OpenMC REQUIRED HINTS {})
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ def compile_source(request):
|
|||
openmc_dir = Path(str(request.config.rootdir)) / 'build'
|
||||
with open('CMakeLists.txt', 'w') as f:
|
||||
f.write(textwrap.dedent("""
|
||||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
project(openmc_sources CXX)
|
||||
add_library(source SHARED source_sampling.cpp)
|
||||
find_package(OpenMC REQUIRED HINTS {})
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ def compile_source(request):
|
|||
openmc_dir = Path(str(request.config.rootdir)) / 'build'
|
||||
with open('CMakeLists.txt', 'w') as f:
|
||||
f.write(textwrap.dedent("""
|
||||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
project(openmc_sources CXX)
|
||||
add_library(source SHARED parameterized_source_sampling.cpp)
|
||||
find_package(OpenMC REQUIRED HINTS {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue