Bugs with pointers in structures

Problems running VASP: crashes, internal errors, "wrong" results.

Moderators: Global Moderator, Moderator

Post Reply
Message
Author
tfrankcombe
Newbie
Newbie
Posts: 18
Joined: Tue Apr 12, 2016 8:19 am
License Nr.: 5-2211

Bugs with pointers in structures

#1 Post by tfrankcombe » Mon May 02, 2016 4:09 am

I have found at least two bugs in the code cause by incorrect use of pointers.

According to the Fortran 95 standard, the association status of a pointer is initially undefined. Nullify or an initialisation to NULL() can be used to set it.

The array VKPT_SHIFT in nonl_struct is nullified in NONL_ALLOC, allowing the associated test in SPHER to work fine generally. But there is no nullify in NONL_ALLOC_SPHPRO, so when SPHER is called in response to e.g. setting RWIGS, the association status may be undefined.

Similarly, PSPNL_SPLINE in the potcar type can be of undefined association inside the P argument to SPHER, giving the wrong result to the associated test.

It seems that ifort takes the time to nullify pointers on creation, so this bug is hidden. However, gfortran does not (or not any more, as some previous versions apparently used to). So my gfortran-compiled binary crashes whenever I set RWIGS in INCAR.

The fixes are either appropriate nullify statements or initialisation to NULL(). [I have done one of each to fix the problem: NULLIFY(NONL_S%VKPT_SHIFT) in NONL_ALLOC_SPHPRO in nonl.F and REAL(q),POINTER :: PSPNL_SPLINE(:,:,:) => NULL() in TYPE potcar in pseudo.F.]

admin
Administrator
Administrator
Posts: 2922
Joined: Tue Aug 03, 2004 8:18 am
License Nr.: 458

Re: Bugs with pointers in structures

#2 Post by admin » Mon May 02, 2016 1:10 pm

Thank you very much.

Post Reply