I tried to develop a code and use LAPACK subroutines to calculate Eigen value and Eigenvector in the code and was succesful. The code runs without any errors.
Since my main goal was to solve a large matrix and there are memory limitations in Windows, I tried to allocate and deallocate the arrays in the code. Before stopping the code, a pop-window shows and reports that the ***.exe has stopped working.
I have attached part of the code where allocation and deallocation was done for perusal.
IMPLICIT REAL*8(A-H, O-Z)
real*8, allocatable :: A(:,:),U(:,:),VT(:,:),SH(:,:)
real*8, allocatable :: UH(:,:),AN(:,:),AN1(:,:),AN2(:,:),EV(:,:)
real*8, allocatable :: UHM(:,:),UH1(:,:),B(:,:),V(:,:)
real*8, allocatable :: S(:),WORK(:),EVL(:)
allocate (A(M,N),U(M,M),V(N,N),VT(N,N),SH(N,N),STAT = iERROR)
allocate (UH(M,M),AN(M,N),AN1(M,N),AN2(M,N),STAT = iERROR)
allocate (S(N),WORK(LWMAX),EVL(M),UHM(M,N),STAT = iERROR)
allocate (UH1(M,M),B(M,N),EV(N,N),STAT = iERROR)
deallocate(A,U,V,VT,SH,UH,AN,AN1,AN2,UHM,UH1,B,EV, STAT = iERROR)
deallocate(S,WORK,EVL,STAT = IERR7)
Problem arises in deallocation. Can someone help me how to debug this error?
Thanks in advance.
Have you checked whether all the allocations were successful? That is, did you examine the value of IERROR after the attempted allocations? If any failed, and a variable that was not allocated was not used in the program, when you try to deallocate that variable an error will occur.
If that suggestion does not help to find the problem, please go ahead and post example code that exhibits the problem.
PRADEEP KUMAR P. wrote:
Thanks Mr. mecej4. I made a mistake. I have allocated some arrays and have never used it in the code and that caused the error while deallocating.
You can always use the allocated function....
IF ( allocated( array) ) deallocate(array, stat = istatus)