There are a large amount of global variables throughout the backend which are used across multiple files. This makes the package rely on the structure of including all .c files in GenerateIC.c, and makes it difficult to debug/develop the backend. We should separate these into a few cases:
If the computation required to get a value is negligible, we can re-compute as needed
For values which are re-used many times, or which need to be stored (e.g prefactors computed outside a loop) These should be sorted into structs.
These will ideally be declared and allocated in the ComputeX function and passed further down.
If this is not practical (e.g. the value needs to be stored across multiple calls of the backend functions) the structures can be delcared as static globals to avoid them being used in other files
This should be closely related to a re-think of how we pass in the parameter structures from the wrapper (#TBD), which are currently declared separately in several files e.g astro_params_ps and broadcast manually when needed. This can result in several issues if one is not careful in if/when they broadcast (and we should never expect a user to keep track of this).
There are a large amount of global variables throughout the backend which are used across multiple files. This makes the package rely on the structure of including all
.c
files inGenerateIC.c
, and makes it difficult to debug/develop the backend. We should separate these into a few cases:ComputeX
function and passed further down.static
globals to avoid them being used in other filesThis should be closely related to a re-think of how we pass in the parameter structures from the wrapper (#TBD), which are currently declared separately in several files e.g
astro_params_ps
and broadcast manually when needed. This can result in several issues if one is not careful in if/when they broadcast (and we should never expect a user to keep track of this).