[Pw_forum] unallocated variable

David Strubbe dstrubbe at berkeley.edu
Tue Nov 22 05:00:43 CET 2011


Dear developers,

I compiled with Intel and debugging flags, and encountered a runtime error
due to use of an unallocated variable. The value will not ultimately be
used, but it seems like it could cause segmentation faults or memory
corruption, and at any rate makes it harder to use these flags to find
other bugs.

I ran example09, on 4 nodes, ch4.nm.in
intel/11.1.072, mkl/11.1.072, fftw/3.2.2-intel,openmpi/1.4.2-intel
FFLAGS         = -g -O0 -check all -traceback

In the output, I get:

Representation #  3 mode #   3

...

End of self-consistent calculation

     Convergence has been achieved

     Number of q in the star =    1
     List of q in the star:
          1   0.000000000   0.000000000   0.000000000
forrtl: severe (408): fort: (8): Attempt to fetch from allocatable variable
RAMTNS when it is not allocated

Image              PC                Routine            Line        Source

ph.x               0000000001A7F16D  Unknown               Unknown  Unknown
ph.x               0000000001A7DC75  Unknown               Unknown  Unknown
ph.x               0000000001A201A0  Unknown               Unknown  Unknown
ph.x               00000000019B853F  Unknown               Unknown  Unknown
ph.x               00000000019B8942  Unknown               Unknown  Unknown
ph.x               000000000046EFAC  dynmatrix_                150
 dynmatrix.f90
ph.x               0000000000443CAA  MAIN__                    118
 phonon.f90
ph.x               0000000000443A9C  Unknown               Unknown  Unknown
libc.so.6          00002B76493A8994  Unknown               Unknown  Unknown
ph.x               00000000004439A9  Unknown               Unknown  Unknown

The offending lines in PH/dynmatrix.f90 are:

     IF (lgamma.AND.done_epsil.AND.done_zeu) THEN
        CALL write_dyn_mat_header( fildyn, ntyp, nat, ibrav, nspin_mag, &
             celldm, at, bg, omega, symm_type, atm, pmass, tau, ityp,
m_loc, &
             nqq, epsilon, zstareu, lraman, ramtns*omega/fpi*convfact)

I added

          if(.not. allocated(ramtns)) allocate ( ramtns (3, 3, 3, nat) )

before the call, which allowed the calculation to complete, but what really
ought to be done is to avoid passing this thing at all when lraman ==
.false. since ramtns is an optional parameter to write_dyn_mat_header.

David Strubbe
UC Berkeley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quantum-espresso.org/pipermail/users/attachments/20111121/cb486a03/attachment.html>


More information about the users mailing list