- #1
cva
- 18
- 0
Hello,
I am am confused about how fortran code is being executed and how are the variables in the memory updated during the execution.
My code in simple terms looks like this:
give some values to a matrix psi(lx,ly) (initialization)
main loop do n=1,nend
nt=psi^3
make Fourier transform of psi and get kpsi
make Fourier transform of nt
calculate new kpsi from a simple old kpsi+ft(nt)
make inverse Fourier transform of kpsi and get the new psi in real space.
enddo
Most of the time is spent to make the 3 Fourier transforms. A smart algorithm would save the intermidiate value of kpsi and use a algorithm like this one:
give some values to a matrix psi(lx,ly) (initialization)
make Fourier transform of psi and get kpsi
main loop do n=1,nend
nt=psi^3
make Fourier transform of nt
calculate new kpsi from a simple old kpsi+FT(nt)
make inverse Fourier transform of kpsi and get the new psi in real space.
enddo
The problem is that it does not work. If I execute the second algorithm it will give rubbish. Between two iteration the cpu saves only the array psi. Second algorithm will work without problem in matlab. How can I force the cpu to save the intermediate value for later reuse. Doing another FT should take more than saving the array in the memory.
I am am confused about how fortran code is being executed and how are the variables in the memory updated during the execution.
My code in simple terms looks like this:
give some values to a matrix psi(lx,ly) (initialization)
main loop do n=1,nend
nt=psi^3
make Fourier transform of psi and get kpsi
make Fourier transform of nt
calculate new kpsi from a simple old kpsi+ft(nt)
make inverse Fourier transform of kpsi and get the new psi in real space.
enddo
Most of the time is spent to make the 3 Fourier transforms. A smart algorithm would save the intermidiate value of kpsi and use a algorithm like this one:
give some values to a matrix psi(lx,ly) (initialization)
make Fourier transform of psi and get kpsi
main loop do n=1,nend
nt=psi^3
make Fourier transform of nt
calculate new kpsi from a simple old kpsi+FT(nt)
make inverse Fourier transform of kpsi and get the new psi in real space.
enddo
The problem is that it does not work. If I execute the second algorithm it will give rubbish. Between two iteration the cpu saves only the array psi. Second algorithm will work without problem in matlab. How can I force the cpu to save the intermediate value for later reuse. Doing another FT should take more than saving the array in the memory.