'pmat' in optic.F90 has incorrect rank?  [SOLVED]

Documentation, Web site and code modifications

Moderators: baguetl, routerov

Locked
raul_l
Posts: 74
Joined: Sun Jan 08, 2012 7:45 pm

'pmat' in optic.F90 has incorrect rank?

Post by raul_l » Fri May 15, 2015 11:34 pm

The array for holding the momentum matrix elements, 'pmat', is declared in optic.F90 as

Code: Select all

complex(dpc),allocatable :: pmat(:,:,:,:,:,:)

Next, it is allocated with

Code: Select all

ABI_ALLOCATE(pmat,(2,mband,mband,nkpt,3,nsppol))

and then passed to pmat2cart where the dummy variable is

Code: Select all

complex(dpc),intent(out) :: pmat(mband,mband,nkpt,3,nsppol)

which has a different rank. My suspicion is that the first index used to refer to the components of a complex variable when 'pmat' was declared real. The type has since been changed to complex but the first index has been incorrectly retained. Currently it seems that no actual results are influenced by this. If I correct the rank,

Code: Select all

--- optic.F90.bak   2015-05-16 00:19:28.576163138 +0300
+++ optic.F90   2015-05-16 00:19:48.436324755 +0300
@@ -136,7 +136,7 @@
  real(dp),allocatable :: eig0tmp(:),eigen0(:),eigen11(:)
  real(dp),allocatable :: eigen12(:),eigtmp(:)
  real(dp),allocatable :: eigen13(:),occ(:),wtk(:)
- complex(dpc),allocatable :: pmat(:,:,:,:,:,:)
+ complex(dpc),allocatable :: pmat(:,:,:,:,:)
  character(len=fnlen) :: filnam,filnam0,filnam1,filnam2,filnam3,filnam_out
 !  for the moment this is imposed by the format in linopt.f and nlinopt.f
  character(len=256) :: fn_radix,tmp_radix
@@ -374,7 +374,7 @@
  gprimd_trans = transpose(gprimd)
  call sym2cart(gprimd_trans,nsym,rprimd,symrel,symcart)
 
- ABI_ALLOCATE(pmat,(2,mband,mband,nkpt,3,nsppol))
+ ABI_ALLOCATE(pmat,(mband,mband,nkpt,3,nsppol))
  write(std_out,*) ' optic : Call pmat2cart'
  call pmat2cart(eigen11,eigen12,eigen13,mband,nkpt,nsppol,pmat,rprimd)

and run the code with input files from the lesson on Optic, I get the same results as before.
Raul Laasner
Netherlands Institute for Space Research

User avatar
torrent
Posts: 127
Joined: Fri Aug 14, 2009 7:40 pm

Re: 'pmat' in optic.F90 has incorrect rank?  [SOLVED]

Post by torrent » Mon May 18, 2015 3:47 pm

Dear Raul,

Thanks for the bug report.
Yes, this was not correct and you suspicion seems right.

I have made the corresponding changes in the dev version of ABINIT.
Marc Torrent
CEA - Bruyères-le-Chatel
France

Locked