One of my first college assignments was to fix the long-term C application that was ported from FORTRAN. The arrays were much larger than yours, and it took about 27 hours per turn. After he fixed it, they ran about 2.5 hours ... pretty sweet!
(OK, it really wasnโt assigned, but I was curious, and I found a big problem with their code. Some of the old timers did not like me, despite this fix.)
It would seem that the same problem is found here.
real B(100, 200) real A(100,200) ... initialize B array code. do I = 1, 100 do J = 1, 200 A(I,J) = B(I,J) end do end do
Your loop (to be a good FORTRAN) would be as follows:
real B(100, 200) real A(100,200) ... initialize B array code. do J = 1, 200 do I = 1, 100 A(I,J) = B(I,J) end do end do
Otherwise, you are navigating through arrays in a row, which can be very inefficient.
At least I believe that it would be in FORTRAN - it has been a long time.
I saw that you updated the code ...
Now you want to change the loop control variables so that you iterate through the rows and then inside, iterate through the columns if you convert to C.