Commits

Britton Smith committed 24c84c7

Having scripts exit if there is an error in the chemistry initializer.

Comments (0)

Files changed (5)

src/clib/initialize_chemistry_data.C

   /* Initialize Cloudy cooling, even if not being used. */
   /* If not used, this will just initialize some data structues. */
   if (initialize_cloudy_data(my_chemistry, my_units, a_value) == FAIL) {
-    fprintf(stderr, "Error in initialize_cloudy_data.");
+    fprintf(stderr, "Error in initialize_cloudy_data.\n");
     return FAIL;
   }
 
   /* Initialize UV Background data. */
   if (initialize_UVbackground_data(my_chemistry) == FAIL) {
-    fprintf(stderr, "Error in initialize_UVbackground_data.");
+    fprintf(stderr, "Error in initialize_UVbackground_data.\n");
     return FAIL;
   }
 

src/python/examples/cooling_rate.py

 import copy
+import sys
 
 def check_convergence(fc1, fc2, fields=None, tol=0.10):
     if fields is None:
 
 a_value = 1.0
 
-my_chemistry.initialize(a_value)
+my_value = my_chemistry.initialize(a_value)
+if not my_value:
+    print "Error initializing chemistry."
+    sys.exit(0)
+
 my_chemistry.update_UVbackground(a_value)
 
 n_points = 200

src/python/examples/freefall.py

+import sys
+
 kboltz      = 1.3806504e-16
 mass_h      = 1.67262171e-24   
 mass_e      = 9.10938215e-28
 
 a_value = 1.0
 
-my_chemistry.initialize(a_value)
+my_value = my_chemistry.initialize(a_value)
+if not my_value:
+    print "Error initializing chemistry."
+    sys.exit(0)
 
 my_chemistry.update_UVbackground(a_value)
 

src/python/pygrackle/grackle_defs.pxd

     gr_int initialize_chemistry_data(c_chemistry_data &my_chemistry,
                                   c_code_units &my_units, gr_float a_value)
 
-    gr_int initialize_UVbackground_data(c_chemistry_data &my_chemistry)
-
     gr_int update_UVbackground_rates(c_chemistry_data &my_chemistry,
                                   c_code_units &my_units, gr_float a_value)
 

src/python/pygrackle/grackle_wrapper.pyx

         self.data = set_default_chemistry_parameters()
 
     def initialize(self, a_value):
-        initialize_chemistry_data(self.data, self.units, a_value)
-
-    def initialize_UVbackground(self):
-        initialize_UVbackground_data(self.data)
+        return initialize_chemistry_data(self.data, self.units, a_value)
 
     def update_UVbackground(self, a_value):
         update_UVbackground_rates(self.data, self.units, a_value)