[SOLVED] DEALLOCATE statement in Gfortran kills a program. Why?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
DEALLOCATE statement in Gfortran kills a program. Why?
I have this main in Gfortran. It works perfectly with one problem. If I include DEALLOCATE the program craches. In this particular configuration this problem is not lethal. By the time of the crash all execution is done and I usually simply comment this statement out, however, in real life it will be a serious problem. The main will eventually be converted into a subroutine with a loop and the memory will be allocated and deallocated many times. What is the problem? This is the code:
Code:
program main
use fft_vect_mod ! must also be in every procedure without exceptions.
implicit none
DOUBLE COMPLEX, DIMENSION (:), POINTER :: Input
DOUBLE COMPLEX, DIMENSION (:), POINTER :: Output
DOUBLE COMPLEX :: yy
integer :: N = 1024, jj = 1, sv
REAL*8 :: xx, blackmanHarrisWindow
ALLOCATE (Input(N),Output(N))
open (unit=1,file="cppFFTinp.dat",status="old")
open (unit=2,file="cppFFTout.dat",status="old")
open (unit=3,file="cppFFTcoef.dat",status="old")
do while (jj < N)
xx = blackmanHarrisWindow (jj,N)
yy = CMPLX (xx,0.0D0)
Input(jj) = yy
write (1,*) DBLE (Input(jj))
jj = jj + 1
enddo
call Forward (Input, Output, N)
jj = 1
do while (jj < N)
write (3,*) DBLE (Output(jj))
jj = jj + 1
enddo
call Inverse (Output, Input, N, .true.)
jj = 1
do while (jj < N)
write (2,*) DBLE (Input(jj))
jj = jj + 1
enddo
close (unit=1)
close (unit=2)
close (unit=3)
DEALLOCATE (Input,Output,STAT=sv)
end program main
Yes, I've tried. Something went wrong and it either did not compile or somehow it did not work, I now don't remember. Could be that it compiled but crashed on execution. The thing is this POINTER variant does work in everything except DEALLOCATE and it is very comforting.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.