Added a check to avoid division by zero.

git-svn-id: http://qeforge.qe-forge.org/svn/q-e/trunk/espresso@1894 c92efa57-630b-4861-b058-cf58834340f0
This commit is contained in:
dalcorso 2005-05-24 08:29:59 +00:00
parent 8ccf1f9774
commit 5e8b31a464
1 changed files with 2 additions and 0 deletions

View File

@ -58,6 +58,8 @@ IF (i_cons.LT.3) THEN
! the penalty functional in this case is
! lambda*(m_loc(z)/|m_loc| - cos(theta) )^2
ma = dsqrt(m_loc(1,na)**2+m_loc(2,na)**2+m_loc(3,na)**2)
if (ma.lt.1.d-30) call errore('add_bfield', &
'local magnetization is zero',1)
xx=(m_loc(3,na)/ma - mcons(3,nt))
m1(1) = - xx*m_loc(1,na)*m_loc(3,na) / (ma*ma*ma)
m1(2) = - xx*m_loc(2,na)*m_loc(3,na) / (ma*ma*ma)