I’m writing a chemistry simulation that has ~75 variables of which half of them are scalars while the other half of them are 2D or 1D arrays, and also half of them are constant while the other half of them are mutated by the code. All ~75 of the variables need to be passed into a function or into for loops (~4 nested for loops) for my main calculations. Computation speed is very important here.
What’s the best way of passing these ~75 variables into my for loops?
Should I place the entire code inside a module and define the ~75 variables as const globals? Except, of course, I can’t define the mutating scalars as const so I will have to do something different with them? I want the code to run fast, and I see all advice online says to have NO globals. So what do I do? Therefore I would have to write the code like this:
const scalar1 = 1;
const scalar2 = 1;
const scalar30 =1;
const array1=[1 2];
const array2=[1 2];
const array3=[1 2];
const array25=[1 2];
function foo_function(mutablescalar1, mutablescalar2, mutablescalar3, …etc…, mutablescalar20)
global scalar1, scalar2, scalar3, … etc… scalar30, array1, array2, array3, …etc… array25
for i in 1:100
for i in 1:50
for I in 1:75
foo_function(mutablescalar1, mutablescalar2, mutablescalar3, …etc…, mutablescalar20)
This seems clumsy, and I’m wondering if there’s a better way to do it. I’m kind of a beginner here.
Is there a better way to organize the overall code strategy?