diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index b1ece9d95fef419350b007627708745a5c8183b6..1821f16e89dc4c7d787165708d46143ef063f3a2 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -1443,6 +1443,7 @@ class Population: # TODO: Check whether all the probability and phasevol values are correct. # TODO: import only the necessary packages/functions # TODO: Put all the masses, eccentricities and periods in there already + # TODO: Put the certain blocks that are repeated in some subfunctions Results in a generated file that contains a system_generator function. """ @@ -1723,6 +1724,11 @@ class Population: # whether this is the last loop. if loopnr == len(self.grid_options["_grid_variables"]) - 1: + code_string = self._write_gridcode_system_call(code_string, indent, depth, grid_variable, dry_run) + +def _write_gridcode_system_call(self, code_string, indent, depth, grid_variable, dry_run): + + ################################################################################# # Here are the calls to the queuing or other solution. this part is for every system # Add comment @@ -1802,9 +1808,11 @@ class Population: depth -= 1 code_string += "\n" + # Write parts to write below the part that yield the results. # this has to go in a reverse order: # Here comes the stuff that is put after the deepest nested part that calls returns stuff. + # Here we will have a for loopnr, grid_variable_el in enumerate( sorted( self.grid_options["_grid_variables"].items(), diff --git a/src/binary_c_python.c b/src/binary_c_python.c index 71b549488c2104bdc513a4de5c8e7fd69060ee4e..a3d045e5beaca72e5ba10930ff58f3bb2c0ba6e1 100644 --- a/src/binary_c_python.c +++ b/src/binary_c_python.c @@ -669,6 +669,23 @@ int run_system(char * argstring, // store can be NULL, but could be a valid pointer to a store // persistent_data can be NULL, but could be a valid pointer to a persistent_data + /* Determine whether to free the store memory adress*/ + Boolean free_store = FALSE; + if (store==NULL) + { + debug_printf("Decided to free the store memaddr\n"); + free_store = TRUE; + } + + /* Determine whether to free the persistent data memory adress*/ + Boolean free_persistent_data = FALSE; + if (persistent_data == NULL) + { + debug_printf("Decided to free the persistent_data memaddr\n"); + free_persistent_data = TRUE; + } + + /* Set up new system */ binary_c_new_system(&stardata, // stardata NULL, // previous_stardatas @@ -715,22 +732,6 @@ int run_system(char * argstring, /* get error buffer pointer */ binary_c_error_buffer(stardata, error_buffer); - /* Determine whether to free the store memory adress*/ - Boolean free_store = FALSE; - if (store == NULL) - { - debug_printf("Decided to free the store memaddr\n"); - free_store = TRUE; - } - - /* Determine whether to free the persistent data memory adress*/ - Boolean free_persistent_data = FALSE; - if (persistent_data == NULL) - { - debug_printf("Decided to free the persistent_data memaddr\n"); - free_persistent_data = TRUE; - } - /* free stardata (except the buffer) */ binary_c_free_memory(&stardata, // Stardata TRUE, // free_preferences @@ -989,7 +990,7 @@ int return_minimum_orbit_for_RLOF(char * argstring, binary_c_error_buffer(stardata, error_buffer); /* Determine whether to free the store memory adress*/ - Boolean free_store = FALSE; + Boolean free_store = FALSE; // TODO: fix this. Its using capsules now if (store_memaddr == -1) { debug_printf("Decided to free the store memaddr\n");