Merge branch 'devel' of mmka.chem.univ.gda.pl:unres into devel
authorAdam Liwo <adam@matrix.chem.cornell.edu>
Mon, 18 Jun 2012 14:08:46 +0000 (10:08 -0400)
committerAdam Liwo <adam@matrix.chem.cornell.edu>
Mon, 18 Jun 2012 14:08:46 +0000 (10:08 -0400)
merge adam->devel (2nd attempt)
Conflicts:
.gitignore
bin/unres/MD/unres_ifort_MPICH_GAB.exe
examples/unres/MD/ff_gab/1L2Y_minim.inp
source/cluster/wham/src/DIMENSIONS.COMPAR
source/cluster/wham/src/include_unres/COMMON.INTERACT
source/cluster/wham/src/include_unres/COMMON.SBRIDGE
source/cluster/wham/src/include_unres/COMMON.TORSION
source/unres/src_MD/cinfo.f
source/unres/src_MIN/Makefile
source/xdrfpdb/src-M/xdrf
source/xdrfpdb/src/xdrf
source/xdrfpdb/src/xdrf2ang.f
source/xdrfpdb/src/xdrf2pdb-m.F

18 files changed:
1  2 
.gitignore
examples/unres/MD/ff_gab/1L2Y_minim.inp
source/cluster/wham/src/DIMENSIONS.COMPAR
source/cluster/wham/src/energy_p_new.F
source/cluster/wham/src/include_unres/COMMON.INTERACT
source/cluster/wham/src/include_unres/COMMON.SBRIDGE
source/cluster/wham/src/include_unres/COMMON.TORSION
source/unres/src_MD-M/unres.F
source/unres/src_MD/Makefile_MPICH_ifort
source/unres/src_MD/cinfo.f
source/unres/src_MD/energy_p_new_barrier.F
source/unres/src_MD/readrtns.F
source/unres/src_MIN/energy_p_new_barrier.F
source/wham/src/energy_p_new.F
source/xdrfpdb/src-M/xdrf2pdb-m.F
source/xdrfpdb/src/Makefile
source/xdrfpdb/src/xdrf2ang.f
source/xdrfpdb/src/xdrf2pdb-m.F

diff --combined .gitignore
@@@ -1,4 -1,17 +1,24 @@@
++<<<<<<< HEAD
 +*.[oa] 
 +*~
 +*.swp
 +*.[eo][0-9][0-9][0-9][0-9]*
++=======
+ # ignore compiled stuff
+ *.[oa]
+ # ignore texteditors
+ *.swp
+ *~
+ # ignore build dir
+ build/
+ # ignored dirs form adasko
+ gradcheck/
+ mapcheck/
+ run/
+ sympcheck/
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
@@@ -1,6 -1,6 +1,11 @@@
  1L2Y
++<<<<<<< HEAD
 +SEED=-3059743 REFSTR PDBREF MINIMIZE
 +
++=======
+ SEED=-3059743 PDBREF ENE
+ maxmin=1000
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
  WLONG=1.35279 WSCP=1.59304 WELEC=0.71534 WBOND=1.00000 WANG=1.13873            &
  WSCLOC=0.16258 WTOR=1.98599 WTORD=1.57069 WCORRH=0.42887 WCORR5=0.00000        &
  WCORR6=0.00000 WEL_LOC=0.16036 WTURN3=1.68722 WTURN4=0.66230 WTURN6=0.00000    &
@@@ -2,6 -2,11 +2,14 @@@
  *
  * Array dimensions for level-based conformation comparison program:
  *
++<<<<<<< HEAD
++=======
+ * Max. number of conformations in the data set.
+ *
+       integer maxconf
+       PARAMETER (MAXCONF=maxstr_proc)
+ *
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
  * Max. number levels of comparison
  *
        integer maxlevel
        implicit real*8 (a-h,o-z)
        include 'DIMENSIONS'
        include 'sizesclu.dat'
-       include "DIMENSIONS.COMPAR"
+ c      include "DIMENSIONS.COMPAR"
        parameter (accur=1.0d-10)
        include 'COMMON.GEO'
        include 'COMMON.VAR'
        implicit real*8 (a-h,o-z)
        include 'DIMENSIONS'
        include 'sizesclu.dat'
-       include "DIMENSIONS.COMPAR"
+ c      include "DIMENSIONS.COMPAR"
        include 'COMMON.GEO'
        include 'COMMON.VAR'
        include 'COMMON.LOCAL'
        implicit real*8 (a-h,o-z)
        include 'DIMENSIONS'
        include 'sizesclu.dat'
-       include "DIMENSIONS.COMPAR"
+ c      include "DIMENSIONS.COMPAR"
        include 'COMMON.GEO'
        include 'COMMON.VAR'
        include 'COMMON.LOCAL'
        implicit real*8 (a-h,o-z)
        include 'DIMENSIONS'
        include 'sizesclu.dat'
-       include "DIMENSIONS.COMPAR"
+ c      include "DIMENSIONS.COMPAR"
        include 'COMMON.GEO'
        include 'COMMON.VAR'
        include 'COMMON.LOCAL'
        implicit real*8 (a-h,o-z)
        include 'DIMENSIONS'
        include 'sizesclu.dat'
-       include "DIMENSIONS.COMPAR"
+ c      include "DIMENSIONS.COMPAR"
        include 'COMMON.GEO'
        include 'COMMON.VAR'
        include 'COMMON.LOCAL'
@@@ -2794,16 -2794,16 +2794,16 @@@ C Evaluate bridge-strain energy and it
  C
        implicit real*8 (a-h,o-z)
        include 'DIMENSIONS'
 -      include 'sizesclu.dat'
        include 'COMMON.SBRIDGE'
        include 'COMMON.CHAIN'
        include 'COMMON.DERIV'
        include 'COMMON.VAR'
        include 'COMMON.INTERACT'
 +      include 'COMMON.IOUNITS'
        dimension ggg(3)
        ehpb=0.0D0
 -cd    print *,'edis: nhpb=',nhpb,' fbr=',fbr
 -cd    print *,'link_start=',link_start,' link_end=',link_end
 +cd      write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
 +cd      write(iout,*)'link_start=',link_start,' link_end=',link_end
        if (link_end.eq.0) return
        do i=link_start,link_end
  C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
@@@ -2818,85 -2818,43 +2818,85 @@@ C iii and jjj point to the residues fo
            iii=ii
            jjj=jj
          endif
 +c        write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
 +c     &    dhpb(i),dhpb1(i),forcon(i)
  C 24/11/03 AL: SS bridges handled separately because of introducing a specific
  C    distance and angle dependent SS bond potential.
          if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
            call ssbond_ene(iii,jjj,eij)
            ehpb=ehpb+2*eij
 +cd          write (iout,*) "eij",eij
 +        else if (ii.gt.nres .and. jj.gt.nres) then
 +c Restraints from contact prediction
 +          dd=dist(ii,jj)
 +          if (dhpb1(i).gt.0.0d0) then
 +            ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +            fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
 +c            write (iout,*) "beta nmr",
 +c     &        dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +          else
 +            dd=dist(ii,jj)
 +            rdis=dd-dhpb(i)
 +C Get the force constant corresponding to this distance.
 +            waga=forcon(i)
 +C Calculate the contribution to energy.
 +            ehpb=ehpb+waga*rdis*rdis
 +c            write (iout,*) "beta reg",dd,waga*rdis*rdis
 +C
 +C Evaluate gradient.
 +C
 +            fac=waga*rdis/dd
 +          endif  
 +          do j=1,3
 +            ggg(j)=fac*(c(j,jj)-c(j,ii))
 +          enddo
 +          do j=1,3
 +            ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
 +            ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
 +          enddo
 +          do k=1,3
 +            ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
 +            ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
 +          enddo
          else
  C Calculate the distance between the two points and its difference from the
  C target distance.
 -        dd=dist(ii,jj)
 -        rdis=dd-dhpb(i)
 +          dd=dist(ii,jj)
 +          if (dhpb1(i).gt.0.0d0) then
 +            ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +            fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
 +c            write (iout,*) "alph nmr",
 +c     &        dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +          else
 +            rdis=dd-dhpb(i)
  C Get the force constant corresponding to this distance.
 -        waga=forcon(i)
 +            waga=forcon(i)
  C Calculate the contribution to energy.
 -        ehpb=ehpb+waga*rdis*rdis
 +            ehpb=ehpb+waga*rdis*rdis
 +c            write (iout,*) "alpha reg",dd,waga*rdis*rdis
  C
  C Evaluate gradient.
  C
 -        fac=waga*rdis/dd
 +            fac=waga*rdis/dd
 +          endif
  cd      print *,'i=',i,' ii=',ii,' jj=',jj,' dhpb=',dhpb(i),' dd=',dd,
  cd   &   ' waga=',waga,' fac=',fac
 -        do j=1,3
 -          ggg(j)=fac*(c(j,jj)-c(j,ii))
 -        enddo
 +            do j=1,3
 +              ggg(j)=fac*(c(j,jj)-c(j,ii))
 +            enddo
  cd      print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
  C If this is a SC-SC distance, we need to calculate the contributions to the
  C Cartesian gradient in the SC vectors (ghpbx).
 -        if (iii.lt.ii) then
 +          if (iii.lt.ii) then
            do j=1,3
              ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
              ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
            enddo
 -        endif
 -        do j=iii,jjj-1
 +          endif
            do k=1,3
 -            ghpbc(k,j)=ghpbc(k,j)+ggg(k)
 +            ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
 +            ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
            enddo
 -        enddo
          endif
        enddo
        ehpb=0.5D0*ehpb
@@@ -4249,7 -4207,7 +4249,7 @@@ c       write (iout,*) 'i=',i,' gloc=',
        do i=1,ndih_constr
          itori=idih_constr(i)
          phii=phi(itori)
 -        difi=phii-phi0(i)
 +        difi=pinorm(phii-phi0(i))
          if (difi.gt.drange(i)) then
            difi=difi-drange(i)
            edihcnstr=edihcnstr+0.25d0*ftors*difi**4
            edihcnstr=edihcnstr+0.25d0*ftors*difi**4
            gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
          endif
 -!        write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
 -!     &    rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
 +c        write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
 +c     &    rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
        enddo
 -!      write (iout,*) 'edihcnstr',edihcnstr
 +      write (iout,*) 'edihcnstr',edihcnstr
        return
        end
  c------------------------------------------------------------------------------
@@@ -4331,26 -4289,24 +4331,26 @@@ c       write (iout,*) 'i=',i,' gloc=',
        enddo
  ! 6/20/98 - dihedral angle constraints
        edihcnstr=0.0d0
 +c      write (iout,*) "Dihedral angle restraint energy"
        do i=1,ndih_constr
 -        print *,"i",i
          itori=idih_constr(i)
          phii=phi(itori)
 -        difi=phii-phi0(i)
 +        difi=pinorm(phii-phi0(i))
 +c        write (iout,'(2i5,4f8.3,2e14.5)') i,itori,rad2deg*phii,
 +c     &    rad2deg*difi,rad2deg*phi0(i),rad2deg*drange(i)
          if (difi.gt.drange(i)) then
            difi=difi-drange(i)
            edihcnstr=edihcnstr+0.25d0*ftors*difi**4
            gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
 +c          write (iout,*) 0.25d0*ftors*difi**4
          else if (difi.lt.-drange(i)) then
            difi=difi+drange(i)
            edihcnstr=edihcnstr+0.25d0*ftors*difi**4
            gloc(itori-3,icg)=gloc(itori-3,icg)+ftors*difi**3
 +c          write (iout,*) 0.25d0*ftors*difi**4
          endif
 -!        write (iout,'(2i5,2f8.3,2e14.5)') i,itori,rad2deg*phii,
 -!     &    rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
        enddo
 -!      write (iout,*) 'edihcnstr',edihcnstr
 +c      write (iout,*) 'edihcnstr',edihcnstr
        return
        end
  c----------------------------------------------------------------------------
@@@ -6239,18 -6195,18 +6239,18 @@@ c--------------------------------------
        logical lprn
        common /kutas/ lprn
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\           /j\       
- C        /   \         /   \      
- C       /| o |         | o |\     
- C     \ j|/k\|  /   \  |/k\|l /   
- C      \ /   \ /     \ /   \ /    
- C       o     o       o     o                
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C         /l\           /j\                                                    C
+ C        /   \         /   \                                                   C
+ C       /| o |         | o |\                                                  C
+ C     \ j|/k\|  /   \  |/k\|l /                                                C
+ C      \ /   \ /     \ /   \ /                                                 C
+ C       o     o       o     o                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
        itk=itortyp(itype(k))
        s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
@@@ -6346,18 -6302,18 +6346,18 @@@ c--------------------------------------
        logical lprn
        common /kutas/ lprn
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C     \   /l\           /j\   /   
- C      \ /   \         /   \ /    
- C       o| o |         | o |o     
- C     \ j|/k\|      \  |/k\|l     
- C      \ /   \       \ /   \      
- C       o             o                      
- C       i             i                     
- C
+ C                                                                              C 
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C     \   /l\           /j\   /                                                C
+ C      \ /   \         /   \ /                                                 C
+ C       o| o |         | o |o                                                  C
+ C     \ j|/k\|      \  |/k\|l                                                  C
+ C      \ /   \       \ /   \                                                   C
+ C       o             o                                                        C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  cd      write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
  C AL 7/4/01 s1 would occur in the sixth-order moment, 
@@@ -6530,18 -6486,18 +6530,18 @@@ c--------------------------------------
        double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
        logical swap
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\   /   \   /j\       
- C        /   \ /     \ /   \      
- C       /| o |o       o| o |\     
- C       j|/k\|  /      |/k\|l /   
- C        /   \ /       /   \ /    
- C       /     o       /     o                
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C         /l\   /   \   /j\                                                    C
+ C        /   \ /     \ /   \                                                   C
+ C       /| o |o       o| o |\                                                  C
+ C       j|/k\|  /      |/k\|l /                                                C
+ C        /   \ /       /   \ /                                                 C
+ C       /     o       /     o                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  C
  C 4/7/01 AL Component s1 was removed, because it pertains to the respective 
@@@ -6648,18 -6604,18 +6648,18 @@@ c--------------------------------------
       & auxvec1(2),auxmat1(2,2)
        logical swap
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\   /   \   /j\       
- C        /   \ /     \ /   \      
- C       /| o |o       o| o |\     
- C     \ j|/k\|      \  |/k\|l     
- C      \ /   \       \ /   \      
- C       o     \       o     \                
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C         /l\   /   \   /j\                                                    C
+ C        /   \ /     \ /   \                                                   C
+ C       /| o |o       o| o |\                                                  C
+ C     \ j|/k\|      \  |/k\|l                                                  C
+ C      \ /   \       \ /   \                                                   C
+ C       o     \       o     \                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  C
  C 4/7/01 AL Component s1 was removed, because it pertains to the respective 
@@@ -19,7 -19,8 +19,15 @@@ C 12/1/95 Array EPS included in the COM
       & r0d(ntyp,2),rpp(2,2),epp(2,2),elpp6(2,2),elpp3(2,2),
       & eps_scp(20,2),rscp(20,2),eps_orig(ntyp,ntyp)
  c 12/5/03 modified 09/18/03 Bond stretching parameters.
++<<<<<<< HEAD
 +      double precision vbldp0,vbldsc0,akp,aksc,abond0
 +      integer nbondterm
 +      common /stretch/ vbldp0,vbldsc0(maxbondterm,ntyp),akp,
 +     & aksc(maxbondterm,ntyp),abond0(maxbondterm,ntyp),nbondterm(ntyp)
++=======
+       double precision vbldp0,vbldsc0,akp,aksc,abond0,distchainmax
+       integer nbondterm
+       common /stretch/ vbldp0,vbldsc0(maxbondterm,ntyp),akp,
+      & aksc(maxbondterm,ntyp),abond0(maxbondterm,ntyp),
+      & distchainmax,nbondterm(ntyp)
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
@@@ -1,10 -1,9 +1,19 @@@
        double precision ebr,d0cm,akcm,akth,akct,v1ss,v2ss,v3ss,dhpb,
++<<<<<<< HEAD
 +     & dhpb1,forcon,weidis
 +      integer ns,nss,nfree,iss,ihpb,jhpb,nhpb,link_start,link_end,
 +     & ibecarb
 +      common /sbridge/ ebr,d0cm,akcm,akth,akct,v1ss,v2ss,v3ss,ns,nss,
 +     &  nfree,iss(maxss)
 +      common /links/ dhpb(maxdim),dhpb1(maxdim),forcon(maxdim),
 +     & ihpb(maxdim),jhpb(maxdim),ibecarb(maxdim),nhpb
++=======
+      & forcon,weidis
+       integer ns,nss,nfree,iss,ihpb,jhpb,nhpb,link_start,link_end
+       common /sbridge/ ebr,d0cm,akcm,akth,akct,v1ss,v2ss,v3ss,ns,nss,
+      &  nfree,iss(maxss)
+       common /links/ dhpb(maxdim),forcon(maxdim),ihpb(maxdim),
+      & jhpb(maxdim),nhpb
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
        common /restraints/ weidis
        common /links_split/ link_start,link_end
@@@ -4,8 -4,8 +4,13 @@@ C Torsional constants of the rotation a
        common/torsion/v0(maxtor,maxtor),v1(maxterm,maxtor,maxtor),
       &    v2(maxterm,maxtor,maxtor),vlor1(maxlor,maxtor,maxtor),
       &    vlor2(maxlor,maxtor,maxtor),vlor3(maxlor,maxtor,maxtor),
++<<<<<<< HEAD
 +     &    itortyp(ntyp),ntortyp,nterm(maxtor,maxtor),nlor(maxtor,maxtor) 
 +     &    ,nterm_old
++=======
+      &    itortyp(ntyp),ntortyp,nterm(maxtor,maxtor),
+      &    nlor(maxtor,maxtor),nterm_old
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
  C 6/23/01 - constants for double torsionals
        double precision v1c,v1s,v2c,v2s
        integer ntermd_1,ntermd_2
@@@ -188,7 -188,6 +188,7 @@@ c--------------------------------------
        common /srutu/ icall
        double precision energy(0:n_ene)
        double precision energy_long(0:n_ene),energy_short(0:n_ene)
 +      double precision varia(maxvar)
        if (indpdb.eq.0) call chainbuild
        time00=MPI_Wtime()
        call chainbuild_cart
@@@ -600,11 -599,11 +600,11 @@@ c Broadcast the order to compute intern
        write (istat,'(a5,20a12)')"#    ",
       &   (wname(print_order(i)),i=1,nprint_ene)
        write (istat,'("#    ",20(1pe12.4))')
-          (weights(print_order(i)),i=1,nprint_ene)
+      &   (weights(print_order(i)),i=1,nprint_ene)
        if (refstr) then
          write (istat,'(a5,20a12)')"#    ",
       &   (ename(print_order(i)),i=1,nprint_ene),
-      &   ,"ETOT total","RMSD","nat.contact","nnt.contact"
+      &   "ETOT total","RMSD","nat.contact","nnt.contact"
        else
          write (istat,'(a5,14a12)')"#    ",
       &   (ename(print_order(i)),i=1,nprint_ene),"ETOT total"
@@@ -1,9 -1,21 +1,9 @@@
 -#-DCRYST_TOR
 -# -DPROCOR
 -#           -DTSCSC
 -#-DTIMING \
 -# -DCRYST_BOND -DCRYST_THETA -DCRYST_SC 
 -# -DMOMENT
 -#-DPARVEC 
 -#-DPARINT -DPARINTDER  
 -
 -#INSTALL_DIR = /users/local/mpi64/mpich-1.2.7p1/
 -#INSTALL_DIR = /users/local/mpich2-1.3.1/
  INSTALL_DIR = /users/software/mpich-1.2.7p1_intel-10.1_em64_ssh
 -#INSTALL_DIR = /users/software/mpich2.x86_64/
  
  
  FC= ifort
  
- OPT =  -O3 -ip -w 
+ OPT =  -g -ip -w -CB 
  
  FFLAGS = -c ${OPT} -I$(INSTALL_DIR)/include 
  FFLAGS1 = -c -w -g -d2 -CA -CB -I$(INSTALL_DIR)/include 
@@@ -1,30 -1,29 +1,47 @@@
  C DO NOT EDIT THIS FILE - IT HAS BEEN GENERATED BY COMPINFO.C
++<<<<<<< HEAD
 +C 2 5 66
 +      subroutine cinfo
 +      include 'COMMON.IOUNITS'
 +      write(iout,*)'++++ Compile info ++++'
 +      write(iout,*)'Version 2.5 build 66'
 +      write(iout,*)'compiled Thu Jun 14 06:40:11 2012'
 +      write(iout,*)'compiled by adam@matrix.chem.cornell.edu'
++=======
+ C 2 5 295
+       subroutine cinfo
+       include 'COMMON.IOUNITS'
+       write(iout,*)'++++ Compile info ++++'
+       write(iout,*)'Version 2.5 build 295'
+       write(iout,*)'compiled Mon Jun 18 05:08:20 2012'
+       write(iout,*)'compiled by aks255@matrix.chem.cornell.edu'
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
        write(iout,*)'OS name:    Linux '
        write(iout,*)'OS release: 2.6.34.9-69.fc13.x86_64 '
        write(iout,*)'OS version:',
       & ' #1 SMP Tue May 3 09:23:03 UTC 2011 '
        write(iout,*)'flags:'
++<<<<<<< HEAD
 +      write(iout,*)'FC = ifort'
 +      write(iout,*)'FFLAGS = -c ${OPT} -I$(INSTALL_DIR)/include'
++=======
+       write(iout,*)'INSTALL_DIR = /users/software/mpich-1.2.7p1_int...'
+       write(iout,*)'FC= ifort'
+       write(iout,*)'OPT =  -g -ip -w -CB '
+       write(iout,*)'FFLAGS = -c ${OPT} -I$(INSTALL_DIR)/include '
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
        write(iout,*)'FFLAGS1 = -c -w -g -d2 -CA -CB -I$(INSTALL_DIR)...'
 -      write(iout,*)'FFLAGS2 = -c -w -g -O0 -I$(INSTALL_DIR)/include  '
 +      write(iout,*)'FFLAGS2 = -c -w -g -O0 -I$(INSTALL_DIR)/include'
        write(iout,*)'FFLAGSE = -c -w -O3 -ipo -ipo_obj  -opt_report ...'
 -      write(iout,*)'LIBS = -L$(INSTALL_DIR)/lib -lmpich xdrf/libxdr...'
 +      write(iout,*)'CC = cc'
 +      write(iout,*)'CFLAGS = -DLINUX -DPGI -c'
 +      write(iout,*)'OPT =  -O3 -ip -w'
 +      write(iout,*)'LIBS = -Lxdrf -lxdrf'
        write(iout,*)'ARCH = LINUX'
        write(iout,*)'PP = /lib/cpp -P'
        write(iout,*)'object = unres.o arcos.o cartprint.o chainbuild...'
        write(iout,*)'GAB: CPPFLAGS = -DPROCOR -DLINUX -DPGI -DUNRES ...'
 -      write(iout,*)'GAB: BIN = ../../../bin/unres/MD/unres_ifort_MP...'
 +      write(iout,*)'GAB: BIN = ../../../bin/unres/MD/unres_ifort_si...'
        write(iout,*)'E0LL2Y: CPPFLAGS = -DPROCOR -DLINUX -DPGI -DUNR...'
        write(iout,*)'E0LL2Y: BIN = ../../../bin/unres/MD/unres_ifort...'
        write(iout,*)'++++ End of compile info ++++'
@@@ -471,7 -471,7 +471,7 @@@ cMS$ATTRIBUTES C ::  proc_pro
        include 'mpif.h'
  #endif
        double precision gradbufc(3,maxres),gradbufx(3,maxres),
-      &  glocbuf(4*maxres),gradbufc_sum(3,maxres)
+      &  glocbuf(4*maxres),gradbufc_sum(3,maxres),gloc_scbuf(3,maxres)
        include 'COMMON.SETUP'
        include 'COMMON.IOUNITS'
        include 'COMMON.FFIELD'
        include 'COMMON.CONTROL'
        include 'COMMON.TIME1'
        include 'COMMON.MAXGRAD'
+       include 'COMMON.SCCOR'
  #ifdef TIMING
  #ifdef MPI
        time01=MPI_Wtime()
@@@ -755,7 -756,6 +756,6 @@@ c      endd
       &   +wturn3*gel_loc_turn3(i)
       &   +wturn6*gel_loc_turn6(i)
       &   +wel_loc*gel_loc_loc(i)
-      &   +wsccor*gsccor_loc(i)
        enddo
  #ifdef DEBUG
        write (iout,*) "gloc after adding corr"
          do i=1,4*nres
            glocbuf(i)=gloc(i,icg)
          enddo
+ #define DEBUG
+ #ifdef DEBUG
+       write (iout,*) "gloc_sc before reduce"
+       do i=1,nres
+        do j=1,3
+         write (iout,*) i,j,gloc_sc(j,i,icg)
+        enddo
+       enddo
+ #endif
+ #undef DEBUG
+         do i=1,nres
+          do j=1,3
+           gloc_scbuf(j,i)=gloc_sc(j,i,icg)
+          enddo
+         enddo
          time00=MPI_Wtime()
          call MPI_Barrier(FG_COMM,IERR)
          time_barrier_g=time_barrier_g+MPI_Wtime()-time00
       &    MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
          call MPI_Reduce(glocbuf(1),gloc(1,icg),4*nres,
       &    MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
+         call MPI_Reduce(gloc_scbuf(1,1),gloc_sc(1,1,icg),3*nres,
+      &    MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
          time_reduce=time_reduce+MPI_Wtime()-time00
+ #define DEBUG
+ #ifdef DEBUG
+       write (iout,*) "gloc_sc after reduce"
+       do i=1,nres
+        do j=1,3
+         write (iout,*) i,j,gloc_sc(j,i,icg)
+        enddo
+       enddo
+ #endif
+ #undef DEBUG
  #ifdef DEBUG
        write (iout,*) "gloc after reduce"
        do i=1,4*nres
@@@ -1038,7 -1065,7 +1065,7 @@@ C--------------------------------------
       & 'ESC=   ',1pE16.6,' WEIGHT=',1pD16.6,' (SC local)'/
       & 'ETORS= ',1pE16.6,' WEIGHT=',1pD16.6,' (torsional)'/
       & 'ETORSD=',1pE16.6,' WEIGHT=',1pD16.6,' (double torsional)'/
 -     & 'EHBP=  ',1pE16.6,' WEIGHT=',1pD16.6,
 +     & 'EHPB=  ',1pE16.6,' WEIGHT=',1pD16.6,
       & ' (SS bridges & dist. cnstr.)'/
       & 'ECORR4=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
       & 'ECORR5=',1pE16.6,' WEIGHT=',1pD16.6,' (multi-body)'/
@@@ -4239,90 -4266,49 +4266,90 @@@ C iii and jjj point to the residues fo
            iii=ii
            jjj=jj
          endif
 -cd        write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj
 +c        write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
 +c     &    dhpb(i),dhpb1(i),forcon(i)
  C 24/11/03 AL: SS bridges handled separately because of introducing a specific
  C    distance and angle dependent SS bond potential.
          if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
            call ssbond_ene(iii,jjj,eij)
            ehpb=ehpb+2*eij
  cd          write (iout,*) "eij",eij
 +        else if (ii.gt.nres .and. jj.gt.nres) then
 +c Restraints from contact prediction
 +          dd=dist(ii,jj)
 +          if (dhpb1(i).gt.0.0d0) then
 +            ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +            fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
 +c            write (iout,*) "beta nmr",
 +c     &        dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +          else
 +            dd=dist(ii,jj)
 +            rdis=dd-dhpb(i)
 +C Get the force constant corresponding to this distance.
 +            waga=forcon(i)
 +C Calculate the contribution to energy.
 +            ehpb=ehpb+waga*rdis*rdis
 +c            write (iout,*) "beta reg",dd,waga*rdis*rdis
 +C
 +C Evaluate gradient.
 +C
 +            fac=waga*rdis/dd
 +          endif  
 +          do j=1,3
 +            ggg(j)=fac*(c(j,jj)-c(j,ii))
 +          enddo
 +          do j=1,3
 +            ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
 +            ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
 +          enddo
 +          do k=1,3
 +            ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
 +            ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
 +          enddo
          else
  C Calculate the distance between the two points and its difference from the
  C target distance.
 -        dd=dist(ii,jj)
 -        rdis=dd-dhpb(i)
 +          dd=dist(ii,jj)
 +          if (dhpb1(i).gt.0.0d0) then
 +            ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +            fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
 +c            write (iout,*) "alph nmr",
 +c     &        dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +          else
 +            rdis=dd-dhpb(i)
  C Get the force constant corresponding to this distance.
 -        waga=forcon(i)
 +            waga=forcon(i)
  C Calculate the contribution to energy.
 -        ehpb=ehpb+waga*rdis*rdis
 +            ehpb=ehpb+waga*rdis*rdis
 +c            write (iout,*) "alpha reg",dd,waga*rdis*rdis
  C
  C Evaluate gradient.
  C
 -        fac=waga*rdis/dd
 +            fac=waga*rdis/dd
 +          endif
  cd      print *,'i=',i,' ii=',ii,' jj=',jj,' dhpb=',dhpb(i),' dd=',dd,
  cd   &   ' waga=',waga,' fac=',fac
 -        do j=1,3
 -          ggg(j)=fac*(c(j,jj)-c(j,ii))
 -        enddo
 +            do j=1,3
 +              ggg(j)=fac*(c(j,jj)-c(j,ii))
 +            enddo
  cd      print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
  C If this is a SC-SC distance, we need to calculate the contributions to the
  C Cartesian gradient in the SC vectors (ghpbx).
 -        if (iii.lt.ii) then
 +          if (iii.lt.ii) then
            do j=1,3
              ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
              ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
            enddo
 -        endif
 +          endif
  cgrad        do j=iii,jjj-1
  cgrad          do k=1,3
  cgrad            ghpbc(k,j)=ghpbc(k,j)+ggg(k)
  cgrad          enddo
  cgrad        enddo
 -        do k=1,3
 -          ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
 -          ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
 -        enddo
 +          do k=1,3
 +            ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
 +            ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
 +          enddo
          endif
        enddo
        ehpb=0.5D0*ehpb
@@@ -5691,7 -5677,7 +5718,7 @@@ C Proline-Proline pair is a special cas
       &  restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
       &  (v1(j,itori,itori1),j=1,6),(v2(j,itori,itori1),j=1,6)
          gloc(i-3,icg)=gloc(i-3,icg)+wtor*gloci
- c       write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
+         write (iout,*) 'i=',i,' gloc=',gloc(i-3,icg)
        enddo
  ! 6/20/98 - dihedral angle constraints
        edihcnstr=0.0d0
@@@ -5806,6 -5792,7 +5833,7 @@@ c      do i=1,ndih_const
          else
            difi=0.0
          endif
+ c        write (iout,*) "gloci", gloc(i-3,icg)
  cd        write (iout,'(2i5,4f8.3,2e14.5)') i,itori,rad2deg*phii,
  cd     &    rad2deg*phi0(i),  rad2deg*drange(i),
  cd     &    rad2deg*difi,0.25d0*ftors*difi**4,gloc(itori-3,icg)
@@@ -5842,7 -5829,6 +5870,6 @@@ c     lprn=.true
          phii1=phi(i+1)
          gloci1=0.0D0
          gloci2=0.0D0
- C Regular cosine and sine terms
          do j=1,ntermd_1(itori,itori1,itori2)
            v1cij=v1c(1,j,itori,itori1,itori2)
            v1sij=v1s(1,j,itori,itori1,itori2)
          enddo
          gloc(i-3,icg)=gloc(i-3,icg)+wtor_d*gloci1
          gloc(i-2,icg)=gloc(i-2,icg)+wtor_d*gloci2
+ c        write (iout,*) "gloci", gloc(i-3,icg)
        enddo
        return
        end
@@@ -5909,26 -5896,57 +5937,57 @@@ C Set lprn=.true. for debuggin
  c      lprn=.true.
  c      write (iout,*) "EBACK_SC_COR",iphi_start,iphi_end,nterm_sccor
        esccor=0.0D0
-       do i=iphi_start,iphi_end
+       do i=itau_start,itau_end
          esccor_ii=0.0D0
-         itori=itype(i-2)
-         itori1=itype(i-1)
+         isccori=isccortyp(itype(i-2))
+         isccori1=isccortyp(itype(i-1))
          phii=phi(i)
+ cccc  Added 9 May 2012
+ cc Tauangle is torsional engle depending on the value of first digit 
+ c(see comment below)
+ cc Omicron is flat angle depending on the value of first digit 
+ c(see comment below)
+         
+         do intertyp=1,3 !intertyp
+ cc Added 09 May 2012 (Adasko)
+ cc  Intertyp means interaction type of backbone mainchain correlation: 
+ c   1 = SC...Ca...Ca...Ca
+ c   2 = Ca...Ca...Ca...SC
+ c   3 = SC...Ca...Ca...SCi
          gloci=0.0D0
-         do j=1,nterm_sccor
-           v1ij=v1sccor(j,itori,itori1)
-           v2ij=v2sccor(j,itori,itori1)
-           cosphi=dcos(j*phii)
-           sinphi=dsin(j*phii)
+         if (((intertyp.eq.3).and.((itype(i-2).eq.10).or.
+      &      (itype(i-1).eq.10).or.(itype(i-2).eq.21).or.
+      &      (itype(i-1).eq.21)))
+      &    .or. ((intertyp.eq.1).and.((itype(i-2).eq.10)
+      &     .or.(itype(i-2).eq.21)))
+      &    .or.((intertyp.eq.2).and.((itype(i-1).eq.10).or.
+      &      (itype(i-1).eq.21)))) cycle  
+         if ((intertyp.eq.2).and.(i.eq.4).and.(itype(1).eq.21)) cycle
+         if ((intertyp.eq.1).and.(i.eq.nres).and.(itype(nres).eq.21))
+      & cycle
+         do j=1,nterm_sccor(isccori,isccori1)
+           v1ij=v1sccor(j,intertyp,isccori,isccori1)
+           v2ij=v2sccor(j,intertyp,isccori,isccori1)
+           cosphi=dcos(j*tauangle(intertyp,i))
+           sinphi=dsin(j*tauangle(intertyp,i))
            esccor=esccor+v1ij*cosphi+v2ij*sinphi
            gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
          enddo
+         gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
+ c        write (iout,*) "WTF",intertyp,i,itype(i),v1ij*cosphi+v2ij*sinphi
+ c     &gloc_sc(intertyp,i-3,icg)
          if (lprn)
       &  write (iout,'(2(a3,2x,i3,2x),2i3,6f8.3/26x,6f8.3/)')
       &  restyp(itype(i-2)),i-2,restyp(itype(i-1)),i-1,itori,itori1,
-      &  (v1sccor(j,itori,itori1),j=1,6),(v2sccor(j,itori,itori1),j=1,6)
+      &  (v1sccor(j,intertyp,itori,itori1),j=1,6)
+      & ,(v2sccor(j,intertyp,itori,itori1),j=1,6)
          gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
+        enddo !intertyp
        enddo
+ c        do i=1,nres
+ c        write (iout,*) "W@T@F",  gloc_sc(1,i,icg),gloc(i,icg)
+ c        enddo
        return
        end
  c----------------------------------------------------------------------------
  C      Parallel       Antiparallel
  C                                             
  C          o             o         
- C         /l\           /j\       
- C        /   \         /   \      
- C       /| o |         | o |\     
+ C         /l\           /j\
+ C        /   \         /   \
+ C       /| o |         | o |\
  C     \ j|/k\|  /   \  |/k\|l /   
  C      \ /   \ /     \ /   \ /    
  C       o     o       o     o                
@@@ -8136,18 -8154,18 +8195,18 @@@ c--------------------------------------
        logical lprn
        common /kutas/ lprn
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C     \   /l\           /j\   /   
- C      \ /   \         /   \ /    
- C       o| o |         | o |o     
- C     \ j|/k\|      \  |/k\|l     
- C      \ /   \       \ /   \      
- C       o             o                      
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C     \   /l\           /j\   /                                                C
+ C      \ /   \         /   \ /                                                 C
+ C       o| o |         | o |o                                                  C                
+ C     \ j|/k\|      \  |/k\|l                                                  C
+ C      \ /   \       \ /   \                                                   C
+ C       o             o                                                        C
+ C       i             i                                                        C 
+ C                                                                              C           
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  cd      write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
  C AL 7/4/01 s1 would occur in the sixth-order moment, 
@@@ -8318,18 -8336,18 +8377,18 @@@ c--------------------------------------
        double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
        logical swap
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\   /   \   /j\       
- C        /   \ /     \ /   \      
- C       /| o |o       o| o |\     
- C       j|/k\|  /      |/k\|l /   
- C        /   \ /       /   \ /    
- C       /     o       /     o                
- C       i             i                     
- C
+ C                                                                              C 
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C 
+ C         /l\   /   \   /j\                                                    C 
+ C        /   \ /     \ /   \                                                   C
+ C       /| o |o       o| o |\                                                  C
+ C       j|/k\|  /      |/k\|l /                                                C
+ C        /   \ /       /   \ /                                                 C
+ C       /     o       /     o                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  C
  C 4/7/01 AL Component s1 was removed, because it pertains to the respective 
@@@ -8435,18 -8453,18 +8494,18 @@@ c--------------------------------------
       & auxvec1(2),auxmat1(2,2)
        logical swap
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\   /   \   /j\       
- C        /   \ /     \ /   \      
- C       /| o |o       o| o |\     
- C     \ j|/k\|      \  |/k\|l     
- C      \ /   \       \ /   \      
- C       o     \       o     \                
- C       i             i                     
- C
+ C                                                                              C                       
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C         /l\   /   \   /j\                                                    C
+ C        /   \ /     \ /   \                                                   C
+ C       /| o |o       o| o |\                                                  C
+ C     \ j|/k\|      \  |/k\|l                                                  C
+ C      \ /   \       \ /   \                                                   C 
+ C       o     \       o     \                                                  C
+ C       i             i                                                        C
+ C                                                                              C 
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  C
  C 4/7/01 AL Component s1 was removed, because it pertains to the respective 
@@@ -44,8 -44,7 +44,8 @@@ C Print restraint informatio
       &write (iout,'(a,i5,a)') "The following",nhpb-nss,
       & " distance constraints have been imposed"
        do i=nss+1,nhpb
 -        write (iout,'(3i6,f10.5)') i-nss,ihpb(i),jhpb(i),forcon(i)
 +        write (iout,'(3i6,i2,3f10.5)') i-nss,ihpb(i),jhpb(i),
 +     &     ibecarb(i),dhpb(i),dhpb1(i),forcon(i)
        enddo
  #ifdef MPI
        endif
@@@ -138,7 -137,7 +138,7 @@@ C Set up the time limit (caution! The t
        call readi(controlcard,'MAXGEN',maxgen,10000)
        call readi(controlcard,'MAXOVERLAP',maxoverlap,1000)
        call readi(controlcard,"KDIAG",kdiag,0)
 -      call readi(controlcard,"RESCALE_MODE",rescale_mode,1)
 +      call readi(controlcard,"RESCALE_MODE",rescale_mode,2)
        if(me.eq.king .or. .not. out1file .and. fg_rank.eq.0)
       & write (iout,*) "RESCALE_MODE",rescale_mode
        split_ene=index(controlcard,'SPLIT_ENE').gt.0
@@@ -1076,6 -1075,11 +1076,6 @@@ czscore          call geom_to_var(nvar,
            enddo
            call contact(.true.,ncont_ref,icont_ref,co)
          endif
 -c        write (iout,*) "constr_dist",constr_dist,nstart_sup,nsup
 -        call flush(iout)
 -        if (constr_dist.gt.0) call read_dist_constr
 -c        write (iout,*) "After read_dist_constr nhpb",nhpb
 -        call hpb_partition
          if(me.eq.king.or..not.out1file)
       &   write (iout,*) 'Contact order:',co
          if (pdbref) then
          enddo
          endif
        endif
 +c        write (iout,*) "constr_dist",constr_dist,nstart_sup,nsup
 +      if (constr_dist.gt.0) then
 +        call read_dist_constr
 +        call hpb_partition
 +      endif
 +c      write (iout,*) "After read_dist_constr nhpb",nhpb
 +c      call flush(iout)
        if (indpdb.eq.0 .and. modecalc.ne.2 .and. modecalc.ne.4
       &    .and. modecalc.ne.8 .and. modecalc.ne.9 .and. 
       &    modecalc.ne.10) then
@@@ -1813,9 -1810,6 +1813,9 @@@ c--------------------------------------
        call readi(minimcard,'MINFUN',minfun,maxmin)
        call reada(minimcard,'TOLF',tolf,1.0D-2)
        call reada(minimcard,'RTOLF',rtolf,1.0D-4)
 +      print_min_stat=min0(index(minimcard,'PRINT_MIN_STAT'),1)
 +      print_min_res=min0(index(minimcard,'PRINT_MIN_RES'),1)
 +      print_min_ini=min0(index(minimcard,'PRINT_MIN_INI'),1)
        write (iout,'(/80(1h*)/20x,a/80(1h*))') 
       &         'Options in energy minimization:'
        write (iout,'(4(a,i5),a,1pe14.5,a,1pe14.5)')
@@@ -2086,38 -2080,38 +2086,38 @@@ C Get parameter filenames and open the 
        open (isidep,file=sidename,status='old')
  #else
        open(1,file=pref_orig(:ilen(pref_orig))//'.inp',status='old',
-      &  readonly)
+      &action='read')
         open (9,file=prefix(:ilen(prefix))//'.intin',status='unknown')
  C      open (18,file=prefix(:ilen(prefix))//'.entin',status='unknown')
  C Get parameter filenames and open the parameter files.
        call getenv_loc('BONDPAR',bondname)
-       open (ibond,file=bondname,status='old',readonly)
+       open (ibond,file=bondname,status='old',action='read')
        call getenv_loc('THETPAR',thetname)
-       open (ithep,file=thetname,status='old',readonly)
+       open (ithep,file=thetname,status='old',action='read')
  #ifndef CRYST_THETA
        call getenv_loc('THETPARPDB',thetname_pdb)
        print *,"thetname_pdb ",thetname_pdb
-       open (ithep_pdb,file=thetname_pdb,status='old',readonly)
+       open (ithep_pdb,file=thetname_pdb,status='old',action='read')
        print *,ithep_pdb," opened"
  #endif
        call getenv_loc('ROTPAR',rotname)
-       open (irotam,file=rotname,status='old',readonly)
+       open (irotam,file=rotname,status='old',action='read')
  #ifndef CRYST_SC
        call getenv_loc('ROTPARPDB',rotname_pdb)
-       open (irotam_pdb,file=rotname_pdb,status='old',readonly)
+       open (irotam_pdb,file=rotname_pdb,status='old',action='read')
  #endif
        call getenv_loc('TORPAR',torname)
-       open (itorp,file=torname,status='old',readonly)
+       open (itorp,file=torname,status='old',action='read')
        call getenv_loc('TORDPAR',tordname)
-       open (itordp,file=tordname,status='old',readonly)
+       open (itordp,file=tordname,status='old',action='read')
        call getenv_loc('SCCORPAR',sccorname)
-       open (isccor,file=sccorname,status='old',readonly)
+       open (isccor,file=sccorname,status='old',action='read')
        call getenv_loc('FOURIER',fouriername)
-       open (ifourier,file=fouriername,status='old',readonly)
+       open (ifourier,file=fouriername,status='old',action='read')
        call getenv_loc('ELEPAR',elename)
-       open (ielep,file=elename,status='old',readonly)
+       open (ielep,file=elename,status='old',action='read')
        call getenv_loc('SIDEPAR',sidename)
-       open (isidep,file=sidename,status='old',readonly)
+       open (isidep,file=sidename,status='old',action='read')
  #endif
  #ifndef OLDSCP
  C
  #elif (defined G77)
        open (iscpp,file=scpname,status='old')
  #else
-       open (iscpp,file=scpname,status='old',readonly)
+       open (iscpp,file=scpname,status='old',action='read')
  #endif
  #endif
        call getenv_loc('PATTERN',patname)
  #elif (defined G77)
        open (icbase,file=patname,status='old')
  #else
-       open (icbase,file=patname,status='old',readonly)
+       open (icbase,file=patname,status='old',action='read')
  #endif
  #ifdef MPI
  C Open output file only for CG processes
@@@ -2198,6 -2192,7 +2198,7 @@@ c      print *,"Processor",myrank," fg_
  #if defined(AIX) || defined(PGI)
        if (me.eq.king .or. .not. out1file) 
       &   open(iout,file=outname,status='unknown')
+ c#define DEBUG
  #ifdef DEBUG
        if (fg_rank.gt.0) then
          write (liczba,'(i3.3)') myrank/nfgtasks
       &   status='unknown')
        endif
  #endif
+ c#undef DEBUG
        if(me.eq.king) then
         open(igeom,file=intname,status='unknown',position='append')
         open(ipdb,file=pdbname,status='unknown')
@@@ -2217,14 -2213,17 +2219,17 @@@ c1out       open(iout,file=outname,stat
  #else
        if (me.eq.king .or. .not.out1file)
       &    open(iout,file=outname,status='unknown')
+ c#define DEBUG
  #ifdef DEBUG
        if (fg_rank.gt.0) then
+         print "Processor",fg_rank," opening output file"
          write (liczba,'(i3.3)') myrank/nfgtasks
          write (ll,'(bz,i3.3)') fg_rank
          open(iout,file="debug"//liczba(:ilen(liczba))//"."//ll,
       &   status='unknown')
        endif
  #endif
+ c#undef DEBUG
        if(me.eq.king) then
         open(igeom,file=intname,status='unknown',access='append')
         open(ipdb,file=pdbname,status='unknown')
@@@ -2407,18 -2406,6 +2412,18 @@@ c      write (iout,*) "IPAIR
  c      do i=1,npair_
  c        write (iout,*) i,ipair_(1,i),ipair_(2,i),wpair_(i)
  c      enddo
 +      if (.not.refstr .and. nfrag.gt.0) then
 +        write (iout,*) 
 +     &  "ERROR: no reference structure to compute distance restraints"
 +        write (iout,*)
 +     &  "Restraints must be specified explicitly (NDIST=number)"
 +        stop 
 +      endif
 +      if (nfrag.lt.2 .and. npair.gt.0) then 
 +        write (iout,*) "ERROR: Less than 2 fragments specified",
 +     &   " but distance restraints between pairs requested"
 +        stop 
 +      endif 
        call flush(iout)
        do i=1,nfrag_
          if (ifrag_(1,i).lt.nstart_sup) ifrag_(1,i)=nstart_sup
@@@ -2493,29 -2480,21 +2498,29 @@@ c        write (iout,*) i,ifrag_(1,i),i
          endif
        enddo 
        do i=1,ndist_
 -        read (inp,*) ihpb(nhpb+1),jhpb(nhpb+1),forcon(nhpb+1)
 +        read (inp,*) ihpb(nhpb+1),jhpb(nhpb+1),dhpb(i),dhpb1(i),
 +     &     ibecarb(i),forcon(nhpb+1)
          if (forcon(nhpb+1).gt.0.0d0) then
            nhpb=nhpb+1
 -          dhpb(nhpb)=dist(ihpb(nhpb),jhpb(nhpb))
 +          if (ibecarb(i).gt.0) then
 +            ihpb(i)=ihpb(i)+nres
 +            jhpb(i)=jhpb(i)+nres
 +          endif
 +          if (dhpb(nhpb).eq.0.0d0) 
 +     &       dhpb(nhpb)=dist(ihpb(nhpb),jhpb(nhpb))
 +        endif
 +      enddo
  #ifdef MPI
 -          if (.not.out1file .or. me.eq.king)
 -     &    write (iout,'(a,3i5,f8.2,f10.1)') "+dist.constr ",
 -     &     nhpb,ihpb(nhpb),jhpb(nhpb),dhpb(nhpb),forcon(nhpb)
 -#else
 -          write (iout,'(a,3i5,f8.2,f10.1)') "+dist.constr ",
 -     &     nhpb,ihpb(nhpb),jhpb(nhpb),dhpb(nhpb),forcon(nhpb)
 +      if (.not.out1file .or. me.eq.king) then
  #endif
 -        endif
 +      do i=1,nhpb
 +          write (iout,'(a,3i5,2f8.2,i2,f10.1)') "+dist.constr ",
 +     &     i,ihpb(i),jhpb(i),dhpb(i),dhpb1(i),ibecarb(i),forcon(i)
        enddo
        call flush(iout)
 +#ifdef MPI
 +      endif
 +#endif
        return
        end
  c-------------------------------------------------------------------------------
@@@ -629,7 -629,7 +629,7 @@@ c      endd
            gradc(j,i,icg)=gradbufc(j,i)+welec*gelc(j,i)+
       &                wel_loc*gel_loc(j,i)+
       &                0.5d0*(wscp*gvdwc_scpp(j,i)+
-      &                welec*gelc_long(j,i)
+      &                welec*gelc_long(j,i)+
       &                wel_loc*gel_loc_long(j,i)+
       &                wcorr*gcorr_long(j,i)+
       &                wcorr5*gradcorr5_long(j,i)+
        logical lprn
        evdw=0.0D0
  ccccc      energy_dec=.false.
 -c     print *,'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
 +c      write(iout,*) 'Entering EGB nnt=',nnt,' nct=',nct,' expon=',expon
        evdw=0.0D0
        evdw_p=0.0D0
        evdw_m=0.0D0
@@@ -7906,18 -7906,18 +7906,18 @@@ c--------------------------------------
        logical lprn
        common /kutas/ lprn
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\           /j\       
- C        /   \         /   \      
- C       /| o |         | o |\     
- C     \ j|/k\|  /   \  |/k\|l /   
- C      \ /   \ /     \ /   \ /    
- C       o     o       o     o                
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C         /l\           /j\                                                    C
+ C        /   \         /   \                                                   C
+ C       /| o |         | o |\                                                  C
+ C     \ j|/k\|  /   \  |/k\|l /                                                C
+ C      \ /   \ /     \ /   \ /                                                 C
+ C       o     o       o     o                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
        itk=itortyp(itype(k))
        s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
@@@ -8011,18 -8011,18 +8011,18 @@@ c--------------------------------------
        logical lprn
        common /kutas/ lprn
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C     \   /l\           /j\   /   
- C      \ /   \         /   \ /    
- C       o| o |         | o |o     
- C     \ j|/k\|      \  |/k\|l     
- C      \ /   \       \ /   \      
- C       o             o                      
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C     \   /l\           /j\   /                                                C
+ C      \ /   \         /   \ /                                                 C
+ C       o| o |         | o |o                                                  C
+ C     \ j|/k\|      \  |/k\|l                                                  C
+ C      \ /   \       \ /   \                                                   C
+ C       o             o                                                        C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  cd      write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
  C AL 7/4/01 s1 would occur in the sixth-order moment, 
@@@ -8193,18 -8193,18 +8193,18 @@@ c--------------------------------------
        double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
        logical swap
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\   /   \   /j\       
- C        /   \ /     \ /   \      
- C       /| o |o       o| o |\     
- C       j|/k\|  /      |/k\|l /   
- C        /   \ /       /   \ /    
- C       /     o       /     o                
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C 
+ C         /l\   /   \   /j\                                                    C
+ C        /   \ /     \ /   \                                                   C
+ C       /| o |o       o| o |\                                                  C
+ C       j|/k\|  /      |/k\|l /                                                C
+ C        /   \ /       /   \ /                                                 C
+ C       /     o       /     o                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  C
  C 4/7/01 AL Component s1 was removed, because it pertains to the respective 
@@@ -8310,18 -8310,18 +8310,18 @@@ c--------------------------------------
       & auxvec1(2),auxmat1(2,2)
        logical swap
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\   /   \   /j\       
- C        /   \ /     \ /   \      
- C       /| o |o       o| o |\     
- C     \ j|/k\|      \  |/k\|l     
- C      \ /   \       \ /   \      
- C       o     \       o     \                
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C 
+ C         /l\   /   \   /j\                                                    C
+ C        /   \ /     \ /   \                                                   C
+ C       /| o |o       o| o |\                                                  C 
+ C     \ j|/k\|      \  |/k\|l                                                  C
+ C      \ /   \       \ /   \                                                   C
+ C       o     \       o     \                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  C
  C 4/7/01 AL Component s1 was removed, because it pertains to the respective 
@@@ -2869,16 -2869,16 +2869,16 @@@ C Evaluate bridge-strain energy and it
  C
        implicit real*8 (a-h,o-z)
        include 'DIMENSIONS'
 -      include 'DIMENSIONS.ZSCOPT'
        include 'COMMON.SBRIDGE'
        include 'COMMON.CHAIN'
        include 'COMMON.DERIV'
        include 'COMMON.VAR'
        include 'COMMON.INTERACT'
 +      include 'COMMON.IOUNITS'
        dimension ggg(3)
        ehpb=0.0D0
 -cd    print *,'edis: nhpb=',nhpb,' fbr=',fbr
 -cd    print *,'link_start=',link_start,' link_end=',link_end
 +cd      write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
 +cd      write(iout,*)'link_start=',link_start,' link_end=',link_end
        if (link_end.eq.0) return
        do i=link_start,link_end
  C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
@@@ -2893,85 -2893,43 +2893,85 @@@ C iii and jjj point to the residues fo
            iii=ii
            jjj=jj
          endif
 +c        write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
 +c     &    dhpb(i),dhpb1(i),forcon(i)
  C 24/11/03 AL: SS bridges handled separately because of introducing a specific
  C    distance and angle dependent SS bond potential.
          if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
            call ssbond_ene(iii,jjj,eij)
            ehpb=ehpb+2*eij
 +cd          write (iout,*) "eij",eij
 +        else if (ii.gt.nres .and. jj.gt.nres) then
 +c Restraints from contact prediction
 +          dd=dist(ii,jj)
 +          if (dhpb1(i).gt.0.0d0) then
 +            ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +            fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
 +c            write (iout,*) "beta nmr",
 +c     &        dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +          else
 +            dd=dist(ii,jj)
 +            rdis=dd-dhpb(i)
 +C Get the force constant corresponding to this distance.
 +            waga=forcon(i)
 +C Calculate the contribution to energy.
 +            ehpb=ehpb+waga*rdis*rdis
 +c            write (iout,*) "beta reg",dd,waga*rdis*rdis
 +C
 +C Evaluate gradient.
 +C
 +            fac=waga*rdis/dd
 +          endif  
 +          do j=1,3
 +            ggg(j)=fac*(c(j,jj)-c(j,ii))
 +          enddo
 +          do j=1,3
 +            ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
 +            ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
 +          enddo
 +          do k=1,3
 +            ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
 +            ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
 +          enddo
          else
  C Calculate the distance between the two points and its difference from the
  C target distance.
 -        dd=dist(ii,jj)
 -        rdis=dd-dhpb(i)
 +          dd=dist(ii,jj)
 +          if (dhpb1(i).gt.0.0d0) then
 +            ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +            fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
 +c            write (iout,*) "alph nmr",
 +c     &        dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
 +          else
 +            rdis=dd-dhpb(i)
  C Get the force constant corresponding to this distance.
 -        waga=forcon(i)
 +            waga=forcon(i)
  C Calculate the contribution to energy.
 -        ehpb=ehpb+waga*rdis*rdis
 +            ehpb=ehpb+waga*rdis*rdis
 +c            write (iout,*) "alpha reg",dd,waga*rdis*rdis
  C
  C Evaluate gradient.
  C
 -        fac=waga*rdis/dd
 +            fac=waga*rdis/dd
 +          endif
  cd      print *,'i=',i,' ii=',ii,' jj=',jj,' dhpb=',dhpb(i),' dd=',dd,
  cd   &   ' waga=',waga,' fac=',fac
 -        do j=1,3
 -          ggg(j)=fac*(c(j,jj)-c(j,ii))
 -        enddo
 +            do j=1,3
 +              ggg(j)=fac*(c(j,jj)-c(j,ii))
 +            enddo
  cd      print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
  C If this is a SC-SC distance, we need to calculate the contributions to the
  C Cartesian gradient in the SC vectors (ghpbx).
 -        if (iii.lt.ii) then
 +          if (iii.lt.ii) then
            do j=1,3
              ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
              ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
            enddo
 -        endif
 -        do j=iii,jjj-1
 +          endif
            do k=1,3
 -            ghpbc(k,j)=ghpbc(k,j)+ggg(k)
 +            ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
 +            ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
            enddo
 -        enddo
          endif
        enddo
        ehpb=0.5D0*ehpb
@@@ -6322,18 -6280,18 +6322,18 @@@ c--------------------------------------
        logical lprn
        common /kutas/ lprn
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\           /j\       
- C        /   \         /   \      
- C       /| o |         | o |\     
- C     \ j|/k\|  /   \  |/k\|l /   
- C      \ /   \ /     \ /   \ /    
- C       o     o       o     o                
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C         /l\           /j\                                                    C 
+ C        /   \         /   \                                                   C
+ C       /| o |         | o |\                                                  C
+ C     \ j|/k\|  /   \  |/k\|l /                                                C
+ C      \ /   \ /     \ /   \ /                                                 C
+ C       o     o       o     o                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
        itk=itortyp(itype(k))
        s1= scalar2(AEAb1(1,2,imat),CUgb2(1,i))
@@@ -6429,18 -6387,18 +6429,18 @@@ c--------------------------------------
        logical lprn
        common /kutas/ lprn
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C     \   /l\           /j\   /   
- C      \ /   \         /   \ /    
- C       o| o |         | o |o     
- C     \ j|/k\|      \  |/k\|l     
- C      \ /   \       \ /   \      
- C       o             o                      
- C       i             i                     
- C
+ C                                                                              C 
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C     \   /l\           /j\   /                                                C
+ C      \ /   \         /   \ /                                                 C
+ C       o| o |         | o |o                                                  C
+ C     \ j|/k\|      \  |/k\|l                                                  C
+ C      \ /   \       \ /   \                                                   C
+ C       o             o                                                        C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  cd      write (2,*) 'eello6_graph2: i,',i,' j',j,' k',k,' l',l
  C AL 7/4/01 s1 would occur in the sixth-order moment, 
@@@ -6613,18 -6571,18 +6613,18 @@@ c--------------------------------------
        double precision vv(2),pizda(2,2),auxmat(2,2),auxvec(2)
        logical swap
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\   /   \   /j\       
- C        /   \ /     \ /   \      
- C       /| o |o       o| o |\     
- C       j|/k\|  /      |/k\|l /   
- C        /   \ /       /   \ /    
- C       /     o       /     o                
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C
+ C         /l\   /   \   /j\                                                    C
+ C        /   \ /     \ /   \                                                   C
+ C       /| o |o       o| o |\                                                  C
+ C       j|/k\|  /      |/k\|l /                                                C
+ C        /   \ /       /   \ /                                                 C
+ C       /     o       /     o                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  C
  C 4/7/01 AL Component s1 was removed, because it pertains to the respective 
@@@ -6731,18 -6689,18 +6731,18 @@@ c--------------------------------------
       & auxvec1(2),auxmat1(2,2)
        logical swap
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
- C                                              
- C      Parallel       Antiparallel
- C                                             
- C          o             o         
- C         /l\   /   \   /j\       
- C        /   \ /     \ /   \      
- C       /| o |o       o| o |\     
- C     \ j|/k\|      \  |/k\|l     
- C      \ /   \       \ /   \      
- C       o     \       o     \                
- C       i             i                     
- C
+ C                                                                              C
+ C      Parallel       Antiparallel                                             C
+ C                                                                              C
+ C          o             o                                                     C 
+ C         /l\   /   \   /j\                                                    C
+ C        /   \ /     \ /   \                                                   C
+ C       /| o |o       o| o |\                                                  C
+ C     \ j|/k\|      \  |/k\|l                                                  C
+ C      \ /   \       \ /   \                                                   C
+ C       o     \       o     \                                                  C
+ C       i             i                                                        C
+ C                                                                              C
  CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  C
  C 4/7/01 AL Component s1 was removed, because it pertains to the respective 
        character*3 sequenc(maxres)
        character*50 tytul
        character*8 onethree,cfreq,cntraj,citraj
 +      character*3 licz
        character*8 ucase
        external ucase
 -      logical oneletter
 +      logical oneletter, iblnk
        integer rescode
        external rescode
        
        ifreq=1
 -      if (iargc().lt.3) then
 +      if (iargc().lt.5) then
          print '(2a)',
 -     &   "Usage: xdrf2pdb-m one/three seqfile cxfile [freq] [pdbfile] ",
 -     &    " [ntraj] [itraj]"
 +     &   "Usage: xdrf2pdb-m one/three seqfile cxfile ntraj itraj",
 +     &   " [pdbfile] [freq]"
          stop
        endif
        call getarg(1,onethree)
@@@ -40,7 -39,8 +40,8 @@@
     10   continue
          nres=i
          i=0
-         do while (.not.iblnk(sequenc(i+1)(1:1)))
+ c        do while (.not.iblnk(sequenc(i+1)(1:1)))
+         do while (.not.(iblnk(sequenc(i+1)(1:1))==0) )
            i=i+1
          enddo 
          nres=i
@@@ -52,7 -52,8 +53,8 @@@
     11   continue
          nres=i
          i=0
-         do while (.not.iblnk(sequenc(i+1)(1:1)))
+ c        do while (.not.iblnk(sequenc(i+1)(1:1)))
+         do while (.not.(iblnk(sequenc(i+1)(1:1))==0))
            i=i+1
          enddo 
          nres=i
@@@ -60,7 -61,7 +62,7 @@@
            itype(i)=rescode(i,sequenc(i),0)
          enddo
          print *,nres
 -        print '(a3,1x)',(sequenc(i),i=1,nres)
 +        print '(20(a3,1x))',(sequenc(i),i=1,nres)
        endif
        call getarg(3,arg)
        iext = index(arg,'.cx') - 1
          print *,"Error - not a cx file"
          stop
        endif
 -      if (iargc().gt.3) then
 -        call getarg(4,cfreq)
 -        read (cfreq,*) ifreq
 -      endif
 -      if (iargc().gt.4) then
 -        call getarg(5,pdbfile)
 -      else
 -        pdbfile=arg(:iext)//'.pdb'
 -      endif
 +      call getarg(4,cntraj)
 +      read (cntraj,*) ntraj
 +      call getarg(5,citraj)
 +      read (citraj,*) itraj
        if (iargc().gt.5) then
 -        call getarg(6,cntraj)
 -        read (cntraj,*) ntraj
 +        call getarg(6,pdbfile)
        else
 -        ntraj=1
 +        write(licz,'(bz,i3.3)') itraj
 +        pdbfile=arg(:iext)//'_'//licz//'.pdb'
        endif
        if (iargc().gt.6) then
 -        call getarg(7,citraj)
 -        read (citraj,*) itraj
 -      else
 -        itraj=1
 +        call getarg(7,cfreq)
 +        read (cfreq,*) ifreq
        endif
 -      print *,"ifreq",ifreq," ntraj",ntraj," itraj",itraj
 +c      print *,"ifreq",ifreq," ntraj",ntraj," itraj",itraj
        open(9,file=pdbfile)
        nnt = 1
        if (itype(1).eq.21) nnt = 2
  
  FC=gfortran
  
 -BINDIR = ../bin
 +BINDIR = ../../../bin
  
  #OPT =  -fast
  OPT = 
  
  FFLAGS = -c ${OPT} 
  
- CPPFLAGS = -DLINUX -DUNRES -DMP -DMPI -DSPLITELE -DPROCOR -DNEWUNRES
+ CPPFLAGS = -DNEWUNRES
  
  M4    = m4
  M4FILE        = underscore.m4
        character*8 onethree,cfreq
        character*8 ucase
        external ucase
++<<<<<<< HEAD
 +      logical oneletter,iblnk
++=======
+       logical oneletter, iblnk
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
        integer rescode
        external rescode
        
@@@ -48,6 -48,7 +52,7 @@@
          nres=i
          i=0
          do while (.not.iblnk(sequenc(i+1)(1:1)))
+ c        do while (.not.(iblnk(sequenc(i+1)(1:1)) == 0) )
            i=i+1
          enddo 
          nres=i
@@@ -60,6 -61,7 +65,7 @@@
          nres=i
          i=0
          do while (.not.iblnk(sequenc(i+1)(1:1)))
+ c        do while (.not.(iblnk(sequenc(i+1)(1:1)) == 0) )
            i=i+1
          enddo 
          nres=i
        character*3 sequenc(maxres)
        character*50 tytul
        character*8 onethree,cfreq,cntraj,citraj
 +      character*3 licz
        character*8 ucase
        external ucase
++<<<<<<< HEAD
 +      logical oneletter,iblnk
++=======
+       logical oneletter, iblnk
++>>>>>>> aebadf9023e437f497f92dfcf2303c16f60917c1
        integer rescode
        external rescode
        
        ifreq=1
 -      if (iargc().lt.3) then
 +      if (iargc().lt.5) then
          print '(2a)',
 -     &   "Usage: xdrf2pdb-m one/three seqfile cxfile [freq] [pdbfile] ",
 -     &    " [ntraj] [itraj]"
 +     &   "Usage: xdrf2pdb-m one/three seqfile cxfile ntraj itraj",
 +     &   " [pdbfile] [freq]"
          stop
        endif
        call getarg(1,onethree)
@@@ -41,6 -40,7 +45,7 @@@
          nres=i
          i=0
          do while (.not.iblnk(sequenc(i+1)(1:1)))
+ c        do while (.not.(iblnk(sequenc(i+1)(1:1)) == 0))
            i=i+1
          enddo 
          nres=i
@@@ -53,6 -53,7 +58,7 @@@
          nres=i
          i=0
          do while (.not.iblnk(sequenc(i+1)(1:1)))
+ c        do while (.not.(iblnk(sequenc(i+1)(1:1)) == 0))
            i=i+1
          enddo 
          nres=i
@@@ -60,7 -61,7 +66,7 @@@
            itype(i)=rescode(i,sequenc(i),0)
          enddo
          print *,nres
 -        print '(a3,1x)',(sequenc(i),i=1,nres)
 +        print '(20(a3,1x))',(sequenc(i),i=1,nres)
        endif
        call getarg(3,arg)
        iext = index(arg,'.cx') - 1
          print *,"Error - not a cx file"
          stop
        endif
 -      if (iargc().gt.3) then
 -        call getarg(4,cfreq)
 -        read (cfreq,*) ifreq
 -      endif
 -      if (iargc().gt.4) then
 -        call getarg(5,pdbfile)
 -      else
 -        pdbfile=arg(:iext)//'.pdb'
 -      endif
 +      call getarg(4,cntraj)
 +      read (cntraj,*) ntraj
 +      call getarg(5,citraj)
 +      read (citraj,*) itraj
        if (iargc().gt.5) then
 -        call getarg(6,cntraj)
 -        read (cntraj,*) ntraj
 +        call getarg(6,pdbfile)
        else
 -        ntraj=1
 +        write(licz,'(bz,i3.3)') itraj
 +        pdbfile=arg(:iext)//'_'//licz//'.pdb'
        endif
        if (iargc().gt.6) then
 -        call getarg(7,citraj)
 -        read (citraj,*) itraj
 -      else
 -        itraj=1
 +        call getarg(7,cfreq)
 +        read (cfreq,*) ifreq
        endif
 -      print *,"ifreq",ifreq," ntraj",ntraj," itraj",itraj
 +c      print *,"ifreq",ifreq," ntraj",ntraj," itraj",itraj
        open(9,file=pdbfile)
        nnt = 1
        if (itype(1).eq.21) nnt = 2
         call xdrffloat(ixdrf, potE, iret)
         call xdrffloat(ixdrf, uconst, iret)
         call xdrffloat(ixdrf, t_bath, iret)
+        print *,"potE",potE," uconst",uconst," t_bath",t_bath
  #ifdef NEWUNRES
         call xdrffloat(ixdrf, uconst_back, iret)
  #endif
+        print *,"uconst_back",uconst_back
         call xdrfint(ixdrf, nss, iret) 
         do j=1,nss
          call xdrfint(ixdrf, ihpb(j), iret)
         prec=10000.0
  
         isize=0
+        print *," call xdrf3coord"
         call xdrf3dfcoord(ixdrf, coord, isize, prec, iret)