BUG in Abinit 8.0.8 in abi_xheev.f90 routine

Moderators: jbeuken, jzwanzig, gonze, mcote

Post Reply
Posts: 18
Joined: Mon Jan 21, 2013 4:34 pm

BUG in Abinit 8.0.8 in abi_xheev.f90 routine

Post by Dominic » Fri Feb 03, 2017 9:09 am

I have encountered a bug where it expected a complex number but received a double, it is found in abi_xheev.f90


Code: Select all

real(dp),target, intent(inout) :: a(lda,*)
 call magmaf_zheevd(jobz,uplo,n,a,...)

as I checked zheevd should receive a complex number in its fourth parameter from the left, but Abinit submits a double data type resulting to an error with the following message:

Error Message

Code: Select all

Problem in abi_xheev, info -8
Parameter incorrect?

When could we see this corrected?

Posts: 282
Joined: Tue May 07, 2013 9:47 am

Re: BUG in Abinit 8.0.8 in abi_xheev.f90 routine

Post by Jordan » Mon Feb 06, 2017 9:10 am

Abinit does not use complex for the most part of the code.
We usually have arrays of the shape (2,*) with (1,*) the real part and (2,*) the imaginary part.
Fortran does not check the type of the argument for pure subroutine. Therefore abinit arrays can be seen as 1D-complex array or 2D-real arrays in memory.
The error -8 means that argument 8 is wrong but as far as I can see it correspond to LWORK which is the dimension of WORK. Probably this temporary array is to small.

Could you provide the test case ?

Posts: 18
Joined: Mon Jan 21, 2013 4:34 pm

Re: BUG in Abinit 8.0.8 in abi_xheev.f90 routine Fix

Post by Dominic » Fri Feb 17, 2017 5:53 pm

Hi, I found the Culprit and I was able to solve the LWORK parameter problem.

What I found out is that abi_xheev.f90 was initiating the wrong LWORK, though the old code did work for some cases, but the way at which it is being set will not always be valid due to some unknown variation. The proper way of setting LWORK was, according to documentation (MAMGA source code)
1. let MAGMA survey the amount of WORK to be done by setting LWORK = -1, LWORK = -1 will not proceed with calculations in the routine.
2. this will spit out the correct value of LWORK from the first element of WORK.
3. then get the value of WORK(1) as the correct LWORK

That was the proper way of setting LWORK, but in abi_xheevd, it was different

This is how LWORK was being set from the original Abinit code

Code: Select all

lwork=n**2  33*n

Bug fix:

Code: Select all

!Initiate dummy array here (should not be similar to the arrays and variables used by the original 
!magmaf_zheevd so as magma will not overwrite the original variables)

!LWORK=n**2  33*n

!plan for lwork

!set lwork, this time it should be ircwork since magma overwrites LWORK
rcwork = REAL(cwork_(1)) !complex? to real
IRCWORK = rcwork_ !real to integer

!here goes the original abinit magmaf_zheevd code
magmaf_zheevd(***(1:2*IRCWORK),IRCWORK,***) ! LWORK is now IRCWORK, WORK is also being overwritten by the magma survey so its name should be different here.

Fix should also be done on other ABI code implementing the wrong LWORK, after this, things will be running fine and expected for double precision calculations.

Post Reply