• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmc-dev / openmc / 33201791925

28 Aug 2026 06:59PM UTC coverage: 81.328% (-0.005%) from 81.333%
33201791925

Pull #4080

github

web-flow
Merge 42e329cd4 into 15cd5eb34
Pull Request #4080: Replace exported settings globals with typed accessors

18617 of 27091 branches covered (68.72%)

Branch coverage included in aggregate %.

178 of 213 new or added lines in 11 files covered. (83.57%)

60443 of 70120 relevant lines covered (86.2%)

49926405.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.46
/src/openmc.cpp
1
#include "openmc/capi.h"
2

3
#ifdef OPENMC_MPI
4
#include <mpi.h>
5
#endif
6

7
#include "openmc/constants.h"
8
#include "openmc/error.h"
9
#include "openmc/message_passing.h"
10
#include "openmc/particle_restart.h"
11
#include "openmc/random_ray/random_ray_simulation.h"
12
#include "openmc/settings.h"
13

14
extern "C" int openmc_main(int argc, char* argv[])
3,870 ✔
15
{
16
  using namespace openmc;
3,870 ✔
17
  int err;
3,870 ✔
18

19
  // Initialize run -- when run with MPI, pass communicator
20
#ifdef OPENMC_MPI
21
  MPI_Comm world {MPI_COMM_WORLD};
22
  err = openmc_init(argc, argv, &world);
23
#else
24
  err = openmc_init(argc, argv, nullptr);
3,870 ✔
25
#endif
26
  if (err == -1) {
3,789 ✔
27
    // This happens for the -h and -v flags
28
    return 0;
29
  } else if (err) {
3,782 !
NEW
30
    fatal_error(get_errmsg());
×
31
  }
32

33
  // Start problem based on mode
34
  switch (settings::run_mode) {
3,782 !
35
  case RunMode::FIXED_SOURCE:
3,617 ✔
36
  case RunMode::EIGENVALUE:
3,617 ✔
37
    switch (settings::solver_type) {
3,617 !
38
    case SolverType::MONTE_CARLO:
3,239 ✔
39
      err = openmc_run();
3,239 ✔
40
      break;
3,239 ✔
41
    case SolverType::RANDOM_RAY:
378 ✔
42
      openmc_run_random_ray();
378 ✔
43
      err = 0;
378 ✔
44
      break;
378 ✔
45
    }
46
    break;
47
  case RunMode::PLOTTING:
70 ✔
48
    err = openmc_plot_geometry();
70 ✔
49
    break;
70 ✔
50
  case RunMode::PARTICLE:
28 ✔
51
    if (mpi::master)
28 ✔
52
      run_particle_restart();
28 ✔
53
    err = 0;
54
    break;
55
  case RunMode::VOLUME:
67 ✔
56
    err = openmc_calculate_volumes();
67 ✔
57
    break;
67 ✔
58
  default:
59
    break;
60
  }
61
  if (err)
3,744 ✔
62
    fatal_error(get_errmsg());
18 ✔
63

64
  // Finalize and free up memory
65
  err = openmc_finalize();
3,754 ✔
66
  if (err)
3,754 !
NEW
67
    fatal_error(get_errmsg());
×
68

69
    // If MPI is in use and enabled, terminate it
70
#ifdef OPENMC_MPI
71
  MPI_Finalize();
72
#endif
73

74
  return 0;
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc