Skip to content

Commit 896bc28

Browse files
committed
fix icart indexing in heuristics
1 parent 7adbc5a commit 896bc28

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/heuristics.f90

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ subroutine movebad(n,x,fx,movebadprint)
1818

1919
! Internal variables
2020
integer :: n, i, j, icart, itype, iatom, imol, ilubar, ilugan, &
21-
ilubar2, ilugan2, nbad, igood, ibad, nmove, nmove_total, itype_tmp
21+
ilubar2, ilugan2, nbad, igood, ibad, nmove, nmove_total,&
22+
itype_tmp, iitype_tmp
2223
double precision :: x(n), fx, rnd, frac
2324
double precision :: fdist_mol, frest_mol
2425
logical :: movebadprint, hasbad
@@ -60,12 +61,15 @@ subroutine movebad(n,x,fx,movebadprint)
6061
end if
6162
nmove_total = 0
6263
hasbad = .false.
63-
icart = 0
6464
move_itype : do itype_tmp = 1, ntype
6565
itype = rand_type(itype_tmp)
6666
if(.not.comptype(itype)) then
67-
icart = icart + nmols(itype)*natoms(itype)
67+
cycle move_itype
6868
else
69+
icart = 0
70+
do iitype_tmp = 1, itype - 1
71+
icart = icart + nmols(iitype_tmp)*natoms(iitype_tmp)
72+
end do
6973

7074
! Checking the function value for each molecule
7175

0 commit comments

Comments
 (0)