Hello everyone.
I am working on a computation fluid dynamics code which needs to solve some subdomains parallel defined in function ASPINS1Sub.
To do this, I wrote the code given below which consists of many if statements.
g1 = @spawnat 2 ASPINS1Sub(COMP, u, Fparam, N, Tln, UTln, MIln, SOLll,
Tll, UTll, Sis, Sin, 1, G, INs1)
if nsubs > 1
g2 = @spawnat 3 ASPINS1Sub(COMP, u, Fparam, N, Tln, UTln, MIln, SOLll,
Tll, UTll, Sis, Sin, 2, G, INs1) end
if nsubs > 2
g3 = @spawnat 4 ASPINS1Sub(COMP, u, Fparam, N, Tln, UTln, MIln, SOLll,
Tll, UTll, Sis, Sin, 3, G, INs1) end
if nsubs > 3
g4 = @spawnat 5 ASPINS1Sub(COMP, u, Fparam, N, Tln, UTln, MIln, SOLll,
Tll, UTll, Sis, Sin, 4, G, INs1) end
.
.
.
nsubs is number of subdomains. So I write many if2 like this.
At the end I collect data and sum them as:
G = fetch(g1)
if nsubs > 1 G += fetch(g2) end
if nsubs > 2 G += fetch(g3) end
if nsubs > 3 G += fetch(g4) end
if nsubs > 4 G += fetch(g5) end
.
.
.
I also have 2 functions like in this patterns, many if statements.
However I have an issue with having too much if statemets.
It makes it take many time to enter to 2 upper function, 30-60 sec.
There should be an easier/alternative way to do this.
I need advises to make it better.