@@ -24,7 +24,6 @@ subroutine cluster
2424      use inform
2525      use iounit
2626      use keys
27-       use limits
2827      use molcul
2928      implicit none 
3029      integer  i,j,k
@@ -154,37 +153,67 @@ subroutine cluster
154153c 
155154c      pack atoms of each group into a contiguous indexed list
156155c 
157-       do  i =  1 , n
158-          list(i) =  grplist(i)
159-       end do 
160-       call  sort3 (n,list,kgrp)
156+       if  (use_group) then 
157+          do  i =  1 , n
158+             list(i) =  grplist(i)
159+          end do 
160+          call  sort3 (n,list,kgrp)
161161c 
162162c      find the first and last atom in each of the groups
163163c 
164-       k =  list(1 )
165-       igrp(1 ,k) =  1 
166-       do  i =  1 , n
167-          j =  list(i)
168-          if  (j .ne.  k) then 
169-             igrp(2 ,k) =  i -  1 
170-             igrp(1 ,j) =  i
171-             k =  j
172-          end if 
173-          ngrp =  max (j,ngrp)
174-       end do 
175-       igrp(2 ,j) =  n
164+           k =  list(1 )
165+           igrp(1 ,k) =  1 
166+           do  i =  1 , n
167+              j =  list(i)
168+              if  (j .ne.  k) then 
169+                 igrp(2 ,k) =  i -  1 
170+                 igrp(1 ,j) =  i
171+                 k =  j
172+              end if 
173+              ngrp =  max (j,ngrp)
174+           end do 
175+           igrp(2 ,j) =  n
176176c 
177177c      sort the list of atoms in each group by atom number
178178c 
179-       do  i =  0 , ngrp
180-          size =  igrp(2 ,i) -  igrp(1 ,i) +  1 
181-          if  (igrp(1 ,i) .ne.  0 )  call  sort (size,kgrp(igrp(1 ,i)))
182-       end do 
179+          do  i =  0 , ngrp
180+             size =  igrp(2 ,i) -  igrp(1 ,i) +  1 
181+             if  (igrp(1 ,i) .ne.  0 )  call  sort (size,kgrp(igrp(1 ,i)))
182+          end do 
183+ c 
184+ c      if groups are not used, put full system in default group
185+ c 
186+       else 
187+          ngrp =  0 
188+          igrp(1 ,0 ) =  1 
189+          igrp(2 ,0 ) =  n
190+          do  i =  1 , n
191+             kgrp(i) =  i
192+             grplist(i) =  0 
193+          end do 
194+       end if 
183195c 
184196c      perform deallocation of some local arrays
185197c 
186198      deallocate (list)
187199c 
200+ c      compute the total mass of all atoms in each group
201+ c 
202+       do  i =  0 , ngrp
203+          grpmass(i) =  0.0d0 
204+          do  j =  igrp(1 ,i), igrp(2 ,i)
205+             grpmass(i) =  grpmass(i) +  mass(kgrp(j))
206+          end do 
207+       end do 
208+ c 
209+ c      turn off bounds and replicas for intragroup calculations
210+ c 
211+       if  (use_intra) then 
212+          use_bounds =  .false. 
213+          use_replica =  .false. 
214+          call  cutoffs
215+       end if 
216+ c 
188217c      use only intragroup or intergroup interactions if selected
189218c 
190219      if  (use_intra) then 
@@ -204,7 +233,7 @@ subroutine cluster
204233         end do 
205234      end if 
206235c 
207- c      disable consideration of interactions with any  empty groups
236+ c      disable consideration of interactions with empty groups
208237c 
209238      do  i =  0 , ngrp
210239         size =  igrp(2 ,i) -  igrp(1 ,i) +  1 
@@ -216,27 +245,10 @@ subroutine cluster
216245         end if 
217246      end do 
218247c 
219- c      turn off bounds and replicas for intragroup calculations
220- c 
221-       if  (use_intra) then 
222-          use_bounds =  .false. 
223-          use_replica =  .false. 
224-          call  cutoffs
225-       end if 
226- c 
227- c      compute the total mass of all atoms in each group
228- c 
229-       do  i =  0 , ngrp
230-          grpmass(i) =  0.0d0 
231-          do  j =  igrp(1 ,i), igrp(2 ,i)
232-             grpmass(i) =  grpmass(i) +  mass(kgrp(j))
233-          end do 
234-       end do 
235- c 
236248c      output the final list of atoms in each group
237249c 
238250      if  (use_group .and.  debug) then 
239-          do  i =  0 , ngrp
251+          do  i =  1 , ngrp
240252            size =  igrp(2 ,i) -  igrp(1 ,i) +  1 
241253            if  (size .ne.  0 ) then 
242254               write  (iout,50 )  i
0 commit comments