seeming infinite loop in charge_mod.f90
Posted: Thu Jul 02, 2009 12:46 am
I may have compiler issues, but the code gets stuck in an infinite loop in SUBROUTINE dpbc_car in the file charge_mod.f90 . The loop is
DO
done=.TRUE.
DO d1=-1,1
v1=ions%lattice(1,:)*REAL(d1,q2)
DO d2=-1,1
v2=ions%lattice(2,:)*REAL(d2,q2)
DO d3=-1,1
v3=ions%lattice(3,:)*REAL(d3,q2)
drt_car=dr_car+v1+v2+v3
dsq=DOT_PRODUCT(drt_car,drt_car)
IF(dsq<dsqmin) THEN
dr_car=drt_car
dsqmin=dsq
done=.FALSE.
END IF
END DO
END DO
END DO
IF(done) EXIT
END DO
Apparently, the IF(done) EXIT line isn't executed, because the program is stuck in this loop and (I've checked) the value of done is true. I can remove this part of the loop to make the program run, so I have a simple question: what is the purpose of the outer loop? It should work without this loop, right?
DO
done=.TRUE.
DO d1=-1,1
v1=ions%lattice(1,:)*REAL(d1,q2)
DO d2=-1,1
v2=ions%lattice(2,:)*REAL(d2,q2)
DO d3=-1,1
v3=ions%lattice(3,:)*REAL(d3,q2)
drt_car=dr_car+v1+v2+v3
dsq=DOT_PRODUCT(drt_car,drt_car)
IF(dsq<dsqmin) THEN
dr_car=drt_car
dsqmin=dsq
done=.FALSE.
END IF
END DO
END DO
END DO
IF(done) EXIT
END DO
Apparently, the IF(done) EXIT line isn't executed, because the program is stuck in this loop and (I've checked) the value of done is true. I can remove this part of the loop to make the program run, so I have a simple question: what is the purpose of the outer loop? It should work without this loop, right?