seeming infinite loop in charge_mod.f90

Bader charge density analysis

Moderator: moderators

Post Reply
tholme
Posts: 3
Joined: Thu Jul 02, 2009 12:37 am

seeming infinite loop in charge_mod.f90

Post by tholme »

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?
Wenjie
Posts: 32
Joined: Sat Mar 10, 2007 7:11 pm

Re: seeming infinite loop in charge_mod.f90

Post by Wenjie »

The purpose of the outer loop is to make sure we get the shortest distance in the code. This doesn't cause problem before. Would you please send your charge density file (CHGCAR or cube file) to me? So I can look into the problem. Thanks.
tholme
Posts: 3
Joined: Thu Jul 02, 2009 12:37 am

Re: seeming infinite loop in charge_mod.f90

Post by tholme »

I get this error for any CHG file I input, it is a compiler issue rather than a strange input file.

Is there another way to write this loop?

I now agree the outer loop it is necessary because when the code runs, I sometimes get atoms that are neighbors due to the pbc with strange values for the atomic volume in the bader code. For example, atoms 3 and 40 are neighbors through a boundary, and the bader code with the outer loop commented out gives:


# X Y Z CHARGE MIN DIST ATOMIC VOL
--------------------------------------------------------------------------------
1 2.3560 -0.0133 17.2938 9.4585 0.9731 11.8015
2 5.1412 -1.8931 17.1418 9.4742 0.9519 11.5259
3 8.4108 -3.8727 17.1187 16.7336 0.9672 30.1052
...
40 18.6139 -0.1139 16.2595 0.0000 0.0000 0.0000
tholme
Posts: 3
Joined: Thu Jul 02, 2009 12:37 am

Re: seeming infinite loop in charge_mod.f90

Post by tholme »

The loop may have something to do with the optimization flag. See this:
https://www.pgroup.com/userforum/viewto ... 862aa9800f

The compiler may be moving the evaluation of the line outside the loop or something. In the makefile, the optimization code is

FFLAGS = -O3 -fast -tp px
Post Reply