Hello I solve an eigenvalue problem with this code:

```
subroutine jdiag(lda,n,A,W)
! A: input matrix, and eigenvectors will be stored here
! W: vector for eigenvalues
! n: matrix size (4*NCC, 4*az atomok szama)
! lda: leading dimension
implicit none
integer :: lda, n
real*8 :: A(lda,n), W(n)
!call jdiagLAPACK(lda,n,A,W) ! CPU serial version (LAPACK)
call jdiagMAGMA(lda,n,A,W) ! GPU version (MAGMA)
return
end
```

Lapack function is very simple and works well:

```
subroutine jdiagLAPACK(lda,n,A,W)
implicit none
integer :: info, lda, n
real*8 :: A(lda,n), W(n), WORK(lwork)
call dsyev ('v','L', n, A, lda, W, WORK, lwork, info)
return
end
```

But it runs only 1 CPU. A want it to move to GPU. My only idea is MAGMA:

```
subroutine jdiagMAGMA(lda,n,A,W)
implicit none
integer :: info, lda, n
real*8 :: A(lda,n), W(n)
real*8, allocatable :: WORK(:)
integer*4 :: lwork = -1
integer :: ngpu = 1
integer, allocatable :: IWORK(:)
integer :: liwork = -1
integer ::status
call magmaf_init()
allocate (work(10000), IWORK(10000) ) !, stat=status)
call magmaf_dsyevd_m (ngpu, 'V', 'L', n, A, lda, W, WORK, lwork, IWORK, liwork, info)
deallocate (work, iwork) !, stat=status)
lwork = int(work(1))
liwork = int(iwork(1))
allocate (work(lwork), IWORK(liwork)) !, stat=status)
call magmaf_dsyevd_m (ngpu, 'V', 'L', n, A, lda, W, WORK, lwork, IWORK, liwork, info)
call magmaf_finalize()
return
end
```

In the 2nd dsyev call it gives Segmentation fault and I am unable to find its reason. Can anyone help me?