Is it possible to re-code the following in a more efficient way? The code performs a so-called red-black SOR to solve a Poisson equation, dividing an iterative step into two half-steps with the second using updated neighbored values of the first.
I'm know that best would be to switch to a state-of-the-art solver, but i need to stay with this one for maintenance reasons. I'm concerned about the IF block again, since this is called within a 3d loop which is performed a several 1000 times during each run of my program. The solver consumes about 2/3 of the code's CPU time.
Code:
DO ijswap = 0,1
DO k = 2,n-2
DO j = 2,m-2
DO i = 2,l-2
IF (MOD((i+j+k),2) .EQ. ijswap) THEN !
compute some stuff depending on i,j,k
END IF
END DO
END DO
END DO
END DO ! ijswap
I'm know that best would be to switch to a state-of-the-art solver, but i need to stay with this one for maintenance reasons. I'm concerned about the IF block again, since this is called within a 3d loop which is performed a several 1000 times during each run of my program. The solver consumes about 2/3 of the code's CPU time.