Question

With FORTRAN 77 is it possible to perform a swap on two arrays, in the same way swap works in c++?

I have two large arrays, e.g. v1 and v2, and would like to swap v1 and v2 at the end of each iteration such that v2 is always the last iteration and v1 is the working array. How does one do this in F77?

Was it helpful?

Solution

If I get it, you want to do the following kind of thing:

do while (i.LE.max_iter .AND. .NOT.converged)
  call sub_iter(v1, v2)
  call swap(v1,v2)
enddo

I would think this isn't really feasible, since a nice way to do this would be to use pointers to switch between arrays, which are not available in Fortran 77.

Can't you just do a double call to a the subroutine in each iteration?

do while (i.LE.max_iter .AND. .NOT.converged)
  call sub_iter(v1, v2)
  call sub_iter(v2, v1)
enddo
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top