Merge branch 'adasko' into devel
authorAdam Kazimierz Sieradzan <adasko@sun1.chem.univ.gda.pl>
Wed, 27 Jun 2012 11:53:41 +0000 (07:53 -0400)
committerAdam Kazimierz Sieradzan <adasko@sun1.chem.univ.gda.pl>
Wed, 27 Jun 2012 11:53:41 +0000 (07:53 -0400)
Conflicts:
.gitignore
bin/unres/MD/unres_ifort_MPICH_GAB.exe
source/cluster/wham/src/DIMENSIONS.COMPAR
source/cluster/wham/src/Makefile
source/wham/src/Makefile
source/wham/src/cinfo.f
source/wham/src/tmptmp

1  2 
source/cluster/wham/src/energy_p_new.F
source/unres/src_MD/cinfo.f
source/wham/src/energy_p_new.F

        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----------------------------------------------------------------------------
@@@ -4453,26 -4409,55 +4453,55 @@@ 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+fact*j*(v2ij*cosphi-v1ij*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)
-         gsccor_loc(i-3)=gloci
+      &  (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
        return
        end
  c------------------------------------------------------------------------------
@@@ -6239,18 -6224,18 +6268,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 -6331,18 +6375,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 -6515,18 +6559,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 -6633,18 +6677,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 
@@@ -1,10 -1,10 +1,10 @@@
  C DO NOT EDIT THIS FILE - IT HAS BEEN GENERATED BY COMPINFO.C
- C 2 5 295
+ C 2 5 297
        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,*)'Version 2.5 build 297'
+       write(iout,*)'compiled Mon Jun 25 07:29:48 2012'
        write(iout,*)'compiled by aks255@matrix.chem.cornell.edu'
        write(iout,*)'OS name:    Linux '
        write(iout,*)'OS release: 2.6.34.9-69.fc13.x86_64 '
        write(iout,*)'OPT =  -g -ip -w -CB '
        write(iout,*)'FFLAGS = -c ${OPT} -I$(INSTALL_DIR)/include '
        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 ++++'
@@@ -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
@@@ -4536,26 -4494,57 +4536,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)
-         gsccor_loc(i-3)=gloci
+      &  (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------------------------------------------------------------------------------
@@@ -6322,18 -6311,18 +6353,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 -6418,18 +6460,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 -6602,18 +6644,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 -6720,18 +6762,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