nano part 3
[unres.git] / source / cluster / unres / src / srtclust.f
1       SUBROUTINE SRTCLUST(ICUT,NCON)
2       include 'DIMENSIONS'
3       include 'sizesclu.dat'
4       include 'COMMON.CLUSTER'
5       include 'COMMON.IOUNITS'
6 C
7 C  SORT CONFORMATIONS IN GROUPS ACC. TO ENERGY
8 C
9       DO 16 IGR=1,NGR
10       LIGR=LICZ(IGR)
11       DO 17 ICO=1,LIGR-1
12       IND1=NCONF(IGR,ICO)
13       ENE=totfree(IND1)
14       DO 18 JCO=ICO+1,LIGR
15       IND2=NCONF(IGR,JCO)
16       EN1=totfree(IND2)
17       IF (EN1.LT.ENE) THEN
18         NCONF(IGR,ICO)=IND2
19         NCONF(IGR,JCO)=IND1
20         IND1=IND2
21         ENE=EN1
22       ENDIF
23    18 CONTINUE
24    17 CONTINUE
25    16 CONTINUE
26 C
27 C  SORT GROUPS
28 C
29       DO 71 IGR=1,NGR
30       ENE=totfree(NCONF(IGR,1))
31       DO 72 JGR=IGR+1,NGR
32       EN1=totfree(NCONF(JGR,1))
33       IF (EN1.LT.ENE) THEN
34         LI1=LICZ(IGR)
35         LI2=LICZ(JGR)
36         LI=MAX0(LI1,LI2)
37         DO 73 I=1,LI   
38         NCO=NCONF(IGR,I)
39         NCONF(IGR,I)=NCONF(JGR,I)
40         NCONF(JGR,I)=NCO
41    73   CONTINUE
42         ENE=EN1
43         LICZ(IGR)=LI2
44         LICZ(JGR)=LI1
45       ENDIF
46    72 CONTINUE
47    71 CONTINUE
48       DO 81 IGR=1,NGR
49       LI=LICZ(IGR)
50       DO 82 I=1,LI 
51    82 IASS(NCONF(IGR,I))=IGR
52    81 CONTINUE
53       if (lgrp) then
54         do i=1,ncon
55           iass_tot(i,icut)=iass(i)
56 c          write (iout,*) icut,i,iass(i),iass_tot(i,icut)
57         enddo
58       endif
59       RETURN
60       END