Hi, we recently notice serious memory corruption when using VASP 5.2.12 on a certain type of model. After a lot of debugging we found the offending portion of code is in "symmetry.F" subroutine RHOSYM() and consequent RHOSYG(). The following code snippet looks very problematic:
Code: Select all
?529???????N?=GRIDC%NGX_rd*GRIDC%NGY*GRIDC%NGZ_rd
?530???????NP=GRIDC%NGX*GRIDC%NGY*GRIDC%NGZ
...
?554??????????ALLOCATE(CWORK(N),CWORK2(N),WORK(NP))
...
?558??????????CALL?RHOSYG(CWORK2,CWORK,GRIDC%NGX,GRIDC%NGX,GRIDC%NGY,GRIDC%NGY,&
?559????????????????GRIDC%NGZ,GRIDC%NGZ,PTRANS,NIOND,MAGROT,ISP,WORK)
...
However according to the definition of subroutine RHOSYG():
Code: Select all
?639???????SUBROUTINE?RHOSYG(RHOG,RHOGIN,?&
?640??????&??????????????ID1,NR1,ID2,NR2,ID3,NR3,PTRANS,NIOND,MAGROT,ISP,DONE)
So ID[123] and NR[123] would be identical based on the arguments passed in. But now the problem comes:
Code: Select all
?645???????COMPLEX(q)?RHOG(ID1*ID2*ID3),RHOGIN(ID1*ID2*ID3)
So if "-DNGXhalf" or "-DNGZhalf" or both are defined during compilation time, this could cause serious memory violation because NG[XZ]_rd could be only NG[XZ]/2+1. I've tried to patch both functions but since this is the first time that I work with this code internal I don't think I fully understand all the logic behind it. I'm also suspecting some other mixed usage between ID[123] and NR[123] in RHOSYG() subroutine which caused my patch to be not working properly. So any suggestion on how to fix this problem?
Thanks!