From d0fa6dbb09cbb5da882f91b65594ad42672c0644 Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Wed, 28 Jul 2021 00:37:14 +0100
Subject: [PATCH] added option to do dry run

---
 binarycpython/utils/grid.py                  | 12 ++++++++----
 binarycpython/utils/grid_options_defaults.py |  2 ++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 1f8f781c2..3d3e71fda 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -1642,8 +1642,9 @@ class Population:
             # Load the grid code
             self._load_grid_function()
 
-            # Do a dry run
-            self._dry_run()
+            if self.grid_options['do_dry_run']:
+                # Do a dry run
+                self._dry_run()
 
             print(
                 "Total starcount for this run will be: {}".format(
@@ -1679,8 +1680,9 @@ class Population:
             # TODO: fix this function
             # self._load_source_file_function()
 
-            # Do a dry run
-            self._dry_run_source_file()
+            if self.grid_options['do_dry_run']:
+                # Do a dry run
+                self._dry_run_source_file()
 
             print(
                 "Total starcount for this run will be: {}".format(
@@ -2197,6 +2199,8 @@ class Population:
 
         with open(gridcode_filename, "w") as file:
             file.write(code_string)
+
+
     def _write_gridcode_system_call(
         self, code_string, indent, depth, grid_variable, dry_run, branchpoint
     ):
diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py
index 35e6eefc5..4fb5fe1b7 100644
--- a/binarycpython/utils/grid_options_defaults.py
+++ b/binarycpython/utils/grid_options_defaults.py
@@ -40,6 +40,7 @@ grid_options_defaults_dict = {
     "run_zero_probability_system": True, # Whether to run the zero probability systems
     "_zero_prob_stars_skipped": 0,
     "ensemble_factor_in_probability_weighted_mass": False, # Whether to multiply the ensemble results by 1/probability_weighted_mass
+    "do_dry_run": True, # Whether to do a dry run to calculate the total probability for this run
     ##########################
     # Execution log:
     ##########################
@@ -491,6 +492,7 @@ grid_options_descriptions = {
     "multiplicity_fraction_function": "Which multiplicity fraction function to use. 0: None, 1: Arenou 2010, 2: Rhagavan 2010, 3: M&S 2017",
     "m&s_options": "Internal variable that holds the M&S options. Don't write to this your self",
     "_loaded_ms_data": "Internal variable storing whether the M&S data has been loaded into memory",
+    "do_dry_run": "Whether to do a dry run to calculate the total probability for this run",
 }
 
 ###
-- 
GitLab