arcos.f
boxshift.f
cartprint.f
chainbuild.f
chain_symmetry.F
cinfo.f
2c2
< C 0 40376 648
---
> C 0 40376 456
6,7c6,7
<       write(iout,*)'Version 0.40376 build 648'
<       write(iout,*)'compiled Mon Oct 30 16:08:24 2023'
---
>       write(iout,*)'Version 0.40376 build 456'
>       write(iout,*)'compiled Wed Dec 27 07:13:37 2023'
17,19c17,19
<       write(iout,*)'OPT = -O2 -ip -w -mcmodel=medium'
<       write(iout,*)'OPTE = -O3 -ip -w -mcmodel=medium'
<       write(iout,*)'OPT = -CB -g -mcmodel=medium'
---
>       write(iout,*)'OPT = -O2 -ip -mcmodel=medium '
>       write(iout,*)'OPTE = -O3 -ip -mcmodel=medium '
>       write(iout,*)'OPT = -CB -g -mcmodel=medium -shared-intel'
23c23
<       write(iout,*)'LIBS = -L$(INSTALL_DIR)/lib -lmpich xdrf/libxdr...'
---
>       write(iout,*)'LIBS = -L$(INSTALL_DIR)/lib -lmpi xdrf/libxdrf.a'
26c26
<       write(iout,*)'GAB: BIN = ~/bin/unres_clustMD_ifort_MPICH-okea...'
---
>       write(iout,*)'GAB: BIN = ~/unres/bin/unres_clustMD_ifort_MPIC...'
28c28
<       write(iout,*)'4P: BIN = ~/bin/unres_clustMD_ifort_MPICH-okean...'
---
>       write(iout,*)'4P: BIN = ~/unres/bin/unres_clustMD_ifort_MPICH...'
30c30
<       write(iout,*)'E0LL2Y: BIN = ~/bin/unres_clustMD_ifort_MPICH-o...'
---
>       write(iout,*)'E0LL2Y: BIN = ~/unres/bin/unres_clustMD_ifort_M...'
32c32
<       write(iout,*)'E0LL2Y_DFA: BIN = ~/bin/unres_clustMD_ifort_MPI...'
---
>       write(iout,*)'E0LL2Y_DFA: BIN = ~/unres/bin/unres_clustMD_ifo...'
34c34
<       write(iout,*)'NEWCORR: BIN = ~/bin/unres_clustMD_ifort_MPICH-...'
---
>       write(iout,*)'NEWCORR: BIN = ~/unres/bin/unres_clustMD_ifort_...'
36c36
<       write(iout,*)'NEWCORR5D: BIN = ~/bin/unres_clustMD_ifort_MPIC...'
---
>       write(iout,*)'NEWCORR5D: BIN = ../../../../bin/cluster/unres_...'
38c38
<       write(iout,*)'NEWCORR_DFA: BIN = ~/bin/unres_clustMD_ifort_MP...'
---
>       write(iout,*)'NEWCORR_DFA: BIN = ~/unres/bin/unres_clustMD_if...'
40c40
<       write(iout,*)'NEWCORR5D_DFA: BIN = ~/bin/unres_clustMD_ifort_...'
---
>       write(iout,*)'NEWCORR5D_DFA: BIN = ~/unres/bin/unres_clustMD_...'
contact.f
convert.f
dfa.F
edis.F
energy_p_new.F
72a73,77
> C Calculate the disulfide-bridge and other energy and the contributions
> C from other distance constraints.
> cd    print *,'Calling EHPB'
>       call edis(ehpb)
> cd    print *,'EHPB exitted succesfully.'
129,133c134
< C Calculate the disulfide-bridge and other energy and the contributions
< C from other distance constraints.
< cd    print *,'Calling EHPB'
<       call edis(ehpb)
< cd    print *,'EHPB exitted succesfully.'
---
> 
339,340d339
<      &               +wscloc*gscloc(j,i)
<      &               +wstrain*ghpbdc(j,i)
365,366d363
<      &               +wscloc*gscloc(j,i)
<      &               +wstrain*ghpbdc(j,i)
385,387c382,383
<      &                  wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)
<      &                 +wscloc*gsclocx(j,i)
<      &                 +wsccor*fact(2)*gsccorx(j,i)
---
>      &                  wstrain*ghpbx(j,i)+wcorr*gradxorr(j,i)+
>      &                  wsccor*fact(2)*gsccorx(j,i)
413,414d408
<      &               +wscloc*gscloc(j,i)
<      &               +wstrain*ghpbdc(j,i)
2448c2442
<           ees=ees+eesij*sss*faclipij2
---
>           ees=ees+eesij*faclipij2
2453c2447
<           ees=ees+eesij*sss*faclipij2
---
>           ees=ees+eesij*faclipij2
4000a3995,4236
>       subroutine edis(ehpb)
> C 
> C Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
> C
>       implicit real*8 (a-h,o-z)
>       include 'DIMENSIONS'
>       include 'COMMON.SBRIDGE'
>       include 'COMMON.CHAIN'
>       include 'COMMON.DERIV'
>       include 'COMMON.VAR'
>       include 'COMMON.INTERACT'
>       include 'COMMON.CONTROL'
>       include 'COMMON.IOUNITS'
>       dimension ggg(3),ggg_peak(3,1000)
>       ehpb=0.0D0
>       ggg=0.0d0
> c 8/21/18 AL: added explicit restraints on reference coords
> c      write (iout,*) "restr_on_coord",restr_on_coord
>       if (restr_on_coord) then
> 
>       do i=nnt,nct
>         ecoor=0.0d0
>         if (itype(i).eq.ntyp1) cycle
>         do j=1,3
>           ecoor=ecoor+(c(j,i)-cref(j,i))**2
>           ghpbc(j,i)=ghpbc(j,i)+bfac(i)*(c(j,i)-cref(j,i))
>         enddo
>         if (itype(i).ne.10) then
>           do j=1,3
>             ecoor=ecoor+(c(j,i+nres)-cref(j,i+nres))**2
>             ghpbx(j,i)=ghpbx(j,i)+bfac(i)*(c(j,i+nres)-cref(j,i+nres))
>           enddo
>         endif
>         if (energy_dec) write (iout,*)
>      &     "i",i," bfac",bfac(i)," ecoor",ecoor
>         ehpb=ehpb+0.5d0*bfac(i)*ecoor
>       enddo
> 
>       endif
> C      write (iout,*) ,"link_end",link_end,constr_dist
> cd      write(iout,*)'edis: nhpb=',nhpb,' fbr=',fbr
> c      write(iout,*)'link_start=',link_start,' link_end=',link_end,
> c     &  " constr_dist",constr_dist
>       if (link_end.eq.0.and.link_end_peak.eq.0) return
>       do i=link_start_peak,link_end_peak
>         ehpb_peak=0.0d0
> c        print *,"i",i," link_end_peak",link_end_peak," ipeak",
> c     &   ipeak(1,i),ipeak(2,i)
>         do ip=ipeak(1,i),ipeak(2,i)
>           ii=ihpb_peak(ip)
>           jj=jhpb_peak(ip)
>           dd=dist(ii,jj)
>           iip=ip-ipeak(1,i)+1
> C iii and jjj point to the residues for which the distance is assigned.
> c          if (ii.gt.nres) then
> c            iii=ii-nres
> c            jjj=jj-nres 
> c          else
> c            iii=ii
> c            jjj=jj
> c          endif
>           if (ii.gt.nres) then
>             iii=ii-nres
>           else
>             iii=ii
>           endif
>           if (jj.gt.nres) then
>             jjj=jj-nres
>           else
>             jjj=jj
>           endif
>           aux=rlornmr1(dd,dhpb_peak(ip),dhpb1_peak(ip),forcon_peak(ip))
>           aux=dexp(-scal_peak*aux)
>           ehpb_peak=ehpb_peak+aux
>           fac=rlornmr1prim(dd,dhpb_peak(ip),dhpb1_peak(ip),
>      &      forcon_peak(ip))*aux/dd
>           do j=1,3
>             ggg_peak(j,iip)=fac*(c(j,jj)-c(j,ii))
>           enddo
>           if (energy_dec) write (iout,'(a6,3i5,6f10.3,i5)')
>      &      "edisL",i,ii,jj,dd,dhpb_peak(ip),dhpb1_peak(ip),
>      &      forcon_peak(ip),fordepth_peak(ip),ehpb_peak
>         enddo
> c        write (iout,*) "ehpb_peak",ehpb_peak," scal_peak",scal_peak
>         ehpb=ehpb-fordepth_peak(ipeak(1,i))*dlog(ehpb_peak)/scal_peak
>         do ip=ipeak(1,i),ipeak(2,i)
>           iip=ip-ipeak(1,i)+1
>           do j=1,3
>             ggg(j)=ggg_peak(j,iip)/ehpb_peak
>           enddo
>           ii=ihpb_peak(ip)
>           jj=jhpb_peak(ip)
> C iii and jjj point to the residues for which the distance is assigned.
> c          if (ii.gt.nres) then
> c            iii=ii-nres
> c            jjj=jj-nres 
> c          else
> c            iii=ii
> c            jjj=jj
> c          endif
>           if (ii.gt.nres) then
>             iii=ii-nres
>           else
>             iii=ii
>           endif
>           if (jj.gt.nres) then
>             jjj=jj-nres
>           else
>             jjj=jj
>           endif
>           if (iii.lt.ii) then
>             do j=1,3
>               ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
>             enddo
>           endif
>           if (jjj.lt.jj) then
>             do j=1,3
>               ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
>             enddo
>           endif
>           do k=1,3
>             ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
>             ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
>           enddo
>         enddo
>       enddo
>       do i=link_start,link_end
> C If ihpb(i) and jhpb(i) > NRES, this is a SC-SC distance, otherwise a
> C CA-CA distance used in regularization of structure.
>         ii=ihpb(i)
>         jj=jhpb(i)
> C iii and jjj point to the residues for which the distance is assigned.
> c        if (ii.gt.nres) then
> c          iii=ii-nres
> c          jjj=jj-nres 
> c        else
> c          iii=ii
> c          jjj=jj
> c        endif
>         if (ii.gt.nres) then
>           iii=ii-nres
>         else
>           iii=ii
>         endif
>         if (jj.gt.nres) then
>           jjj=jj-nres
>         else
>           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.
> C        if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
> C     & iabs(itype(jjj)).eq.1) then
> cmc        if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
> C 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
>         if (.not.dyn_ss .and. i.le.nss) then
> C 15/02/13 CC dynamic SSbond - additional check
>           if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
>      &        iabs(itype(jjj)).eq.1) then
>            call ssbond_ene(iii,jjj,eij)
>            ehpb=ehpb+2*eij
>          endif
> cd          write (iout,*) "eij",eij
> cd   &   ' waga=',waga,' fac=',fac
> !        else if (ii.gt.nres .and. jj.gt.nres) then
>         else 
> C Calculate the distance between the two points and its difference from the
> C target distance.
>           dd=dist(ii,jj)
>           if (irestr_type(i).eq.11) then
>             ehpb=ehpb+fordepth(i)!**4.0d0
>      &           *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
>             fac=fordepth(i)!**4.0d0
>      &           *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
>             if (energy_dec) write (iout,'(a6,2i5,6f10.3,i5)')
>      &        "edisL",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),
>      &        ehpb,irestr_type(i)
>           else if (irestr_type(i).eq.10) then
> c AL 6//19/2018 cross-link restraints
>             xdis = 0.5d0*(dd/forcon(i))**2
>             expdis = dexp(-xdis)
> c            aux=(dhpb(i)+dhpb1(i)*xdis)*expdis+fordepth(i)
>             aux=(dhpb(i)+dhpb1(i)*xdis*xdis)*expdis+fordepth(i)
> c            write (iout,*)"HERE: xdis",xdis," expdis",expdis," aux",aux,
> c     &          " wboltzd",wboltzd
>             ehpb=ehpb-wboltzd*xlscore(i)*dlog(aux)
> c            fac=-wboltzd*(dhpb1(i)*(1.0d0-xdis)-dhpb(i))
>             fac=-wboltzd*xlscore(i)*(dhpb1(i)*(2.0d0-xdis)*xdis-dhpb(i))
>      &           *expdis/(aux*forcon(i)**2)
>             if (energy_dec) write(iout,'(a6,2i5,6f10.3,i5)') 
>      &        "edisX",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),
>      &        -wboltzd*xlscore(i)*dlog(aux),irestr_type(i)
>           else if (irestr_type(i).eq.2) then
> c Quartic restraints
>             ehpb=ehpb+forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
>             if (energy_dec) write(iout,'(a6,2i5,5f10.3,i5)') 
>      &      "edisQ",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),
>      &      forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i)),irestr_type(i)
>             fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
>           else
> c Quadratic restraints
>             rdis=dd-dhpb(i)
> C Get the force constant corresponding to this distance.
>             waga=forcon(i)
> C Calculate the contribution to energy.
>             ehpb=ehpb+0.5d0*waga*rdis*rdis
>             if (energy_dec) write(iout,'(a6,2i5,5f10.3,i5)') 
>      &      "edisS",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),
>      &       0.5d0*waga*rdis*rdis,irestr_type(i)
> C
> C Evaluate gradient.
> C
>             fac=waga*rdis/dd
>           endif
> c Calculate Cartesian gradient
>           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
>             do j=1,3
>               ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
>             enddo
>           endif
>           if (jjj.lt.jj) then
>             do j=1,3
>               ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
>             enddo
>           endif
>           do k=1,3
>             ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
>             ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
>           enddo
>         endif
>       enddo
>       return
>       end
> C--------------------------------------------------------------------------
4055c4291
<      &  +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi!+ebr
---
>      &  +v1ss*cosphi+v2ss*cosphi*cosphi+v3ss*cosphi*cosphi*cosphi
5007,5008d5242
< c AL 3/30/2022 single-residue chain does not have sidechain rotamers
<       if (nnt.eq.nct) return
5010,5049c5244
<         it=iabs(itype(i))
<         if (it.eq.ntyp1 .or. it.eq.10) cycle
< c AL 3/30/2022 handle the cases of an isolated-residue chain
<         if (i.eq.nnt .and. itype(i+1).eq.ntyp1) cycle
<         if (i.eq.nct .and. itype(i-1).eq.ntyp1) cycle
< !        costtab(i+1) =dcos(theta(i+1))
< !        sinttab(i+1) =dsqrt(1-costtab(i+1)*costtab(i+1))
< #ifdef SC_END
<         if (i.eq.nct .or. itype(i+1).eq.ntyp1) then
< c AL 3/30/2022 handle a sidechain of a loose C-end
<           cossc1=scalar(dc_norm(1,i-1),dc_norm(1,i+nres))
<           sumene=arotam_end(0,1,it)+
<      &      tschebyshev(1,nterm_scend(1,it),arotam_end(1,1,it),cossc1)
<           escloc=escloc+sumene
<           gradene=gradtschebyshev(0,nterm_scend(1,it)-1,
<      &       arotam_end(1,1,it),cossc1)
<           gscloc(:,i-1)=gscloc(:,i-1)+
<      &      vbld_inv(i)*(dC_norm(:,i+nres)-dC_norm(:,i-1)
<      &       *cossc1)*gradene
<           gsclocx(:,i)=gsclocx(:,i)+vbld_inv(i+nres)*
<      &       (dC_norm(:,i-1)-dC_norm(:,i+nres)*cossc1)*gradene
<           if (energy_dec) write (2,'(2hC  ,a3,i6,2(a,f10.5))')
<      &     restyp(it),i," angle",rad2deg*dacos(cossc1)," escloc",sumene
<         else if (i.eq.nnt .or. itype(i-1).eq.ntyp1) then
< c AL 3/30/2022 handle a sidechain of a loose N-end
<           cossc=scalar(dc_norm(1,i),dc_norm(1,i+nres))
<           sumene=arotam_end(0,2,it)+
<      &      tschebyshev(1,nterm_scend(2,it),arotam_end(1,2,it),cossc)
<           escloc=escloc+sumene
<           gradene=gradtschebyshev(0,nterm_scend(2,it)-1,
<      &       arotam_end(1,2,it),cossc)
<           gscloc(:,i)=gscloc(:,i)+
<      &       vbld_inv(i+1)*(dC_norm(:,i+nres)-dC_norm(:,i)
<      &       *cossc)*gradene
<           gsclocx(:,i)=gsclocx(:,i)+vbld_inv(i+nres)*
<      &       (dC_norm(:,i)-dC_norm(:,i+nres)*cossc)*gradene
<           if (energy_dec) write (2,'(2hN  ,a3,i6,2(a,f10.5))')
<      &     restyp(it),i," angle",rad2deg*dacos(cossc)," escloc",sumene
<         else
< #endif
---
>         if (itype(i).eq.ntyp1) cycle
5337,5339d5531
< #ifdef SC_END
<       endif
< #endif
5856,5860d6047
<         if (itype(i-1).eq.ntyp1) cycle
<         iti=iabs(itortyp(itype(i-1)))
<         sinthet=dsin(theta(i))
<         costhet=dcos(theta(i))
< c        costhet=costtab(i)
5862,5874d6048
< #if !defined(SC_END) || defined(THETA_CORR)
<         if (itype(i-2).eq.ntyp1 .or. itype(i).eq.ntyp1) then
<         etheta = etheta + 1.0d7*gnmr1(costhet,-0.9d0,0.9d0)
<         aux = 1.0d7*gnmr1prim(costhet,-0.9d0,0.9d0)
< c        glocangdc(:,i-2)=glocangdc(:,i-2) + aux*dcosttab(:,1,i)
< c        glocangdc(:,i-1)=glocangdc(:,i-1) + aux*dcosttab(:,2,i)
<         if (lprn)
<      &  write (iout,'(2hD ,a3,i7,2i3," angle",f10.2," energy ",f10.5)')
<      &    restyp(itype(i-1)),i-1,itype(i-1),iti,dacos(costhet)*rad2deg,
<      &    1.0d7*gnmr1(costhet,-0.9d0,0.9d0)
< 
<         else
< #else
5877,5878c6051,6053
< #endif
< c        iti=iabs(itortyp(itype(i-1)))
---
>         iti=iabs(itortyp(itype(i-1)))
>         sinthet=dsin(theta(i))
>         costhet=dcos(theta(i))
5891,5893d6065
< #if !defined(SC_END) || defined(THETA_CORR)
<         endif
< #endif
9404c9576
<       integer i,iint,j,k,l,ii,jj,inii,injj
---
>       integer i,iint,j,k,l
9411c9583
<       double precision dk,dijCACA,dijCASC,dijSCCA,dijSCSC,dij,dij0,
---
>       double precision dk,dijCACA,dijCASC,dijSCCA,dijSCSC,
9414,9418c9586
<      & auxX,auxX1,CACAgrad,CACAgrad1,sigmaCACA,threesig
<       integer nei(maxres),inei(100,maxres)
<       double precision rnei(maxres),rneiprim(maxres),
<      & rnei_tot_prim,radtab(maxres),radtabprim(100,maxres),
<      & dnei_inv(100,maxres)
---
>      & auxX,auxX1,CACAgrad,Cnorm
9422,9423d9589
<       double precision x,xx,xprim,diffd
<       double precision fcont,fprimcont
9425d9590
<       rnei_mid_bound=(rnei_min_bound+rnei_max_bound)/2
9445,9490d9609
< c 7/11/2020 Adam: determine the neighbors 
<       do i=nnt,nct
<         rnei(i)=0.0d0
<         nei(i)=0
<         rnei_tot_prim=0.0d0
<         do j=1,100
<           inei(j,i)=0
<           rneiprim(j)=0.0d0
<         enddo
<         if (itype(i).eq.ntyp1) cycle
<         do j=nnt,nct
<           if (j.eq.i. or. itype(j).eq.ntyp1) cycle
<           dij=dist(i,j)
<           dij0=0.5d0*(restok(itype(i))+restok(itype(j)))+1.0d0
<           call gcont(dij,dij0,1.0d0,0.1d0,fcont,fprimcont)
<           rnei(i)=rnei(i)+fcont
<           if (fcont.gt.0.0d0) then
<             nei(i)=nei(i)+1
<             inei(nei(i),i)=j
<             rneiprim(nei(i))=fprimcont
<             dnei_inv(nei(i),i)=1.0d0/dij
<           endif
<         enddo
<         x=2*(rnei(i)-rnei_mid_bound)/(rnei_max_bound-rnei_min_bound)
<         if (x.gt.0.0d0) then
<           call Gbounds(x,xx,xprim,1.0d-2)
<         else
<           call Gbounds(-x,xx,xprim,1.0d-2)
<           xx=-xx  
<         endif 
< c        write (iout,*) "rnei",rnei(i)," x",x," xx",xx
<         rnei(i)=rnei_mid_bound+(rnei_max_bound-rnei_min_bound)*xx/2
<         radtab(i)=restok(itype(i))/scal_rad
<      &    +sigmamax-(sigmamax-sigmamin)*(xx+1.0d0)/2
<         do j=1,nei(i)
<           radtabprim(j,i)=-(sigmamax-sigmamin)/
<      &        (rnei_max_bound-rnei_min_bound)*xprim*rneiprim(j)
<         enddo 
< #ifdef DEBUG
<         write (iout,'(a3,i6,f8.3,f8.3,f8.3)') 
<      &    restyp(itype(i)),i,rnei(i),restok(itype(i)),radtab(i)
<         write (iout,'(i4,5x,20i4)') nei(i),(inei(j,i),j=1,nei(i))
<         write (iout,'(10f8.5)') (rneiprim(j),j=1,nei(i))
<         write (iout,'(10f8.5)') (radtabprim(j,i),j=1,nei(i))
< #endif
<       enddo
9495a9615
> #ifdef ALLSAXS
9497,9500c9617,9623
<            sigma2CACA=4*dijCACA**2/(radtab(i)+radtab(j))**2
< c           write (iout,*) "scal_rad",scal_rad," restok",restok(itype(j))
< c     &       ,restok(itype(i)),"sigma",1.0d0/dsqrt(sigma2CACA)
<            IF (saxs_cutoff.eq.0.0d0) THEN
---
>            dijCASC=dist(i,j+nres)
>            dijSCCA=dist(i+nres,j)
>            dijSCSC=dist(i+nres,j+nres)
>            sigma2CACA=2.0d0/(pstok**2)
>            sigma2CASC=4.0d0/(pstok**2+restok(itype(j))**2)
>            sigma2SCCA=4.0d0/(pstok**2+restok(itype(i))**2)
>            sigma2SCSC=4.0d0/(restok(itype(j))**2+restok(itype(i))**2)
9503,9504c9626,9687
<              diffd = dlog(dijCACA)-dlog(dk)
<              expCACA = dexp(-0.5d0*sigma2CACA*diffd**2)
---
>              expCACA = dexp(-0.5d0*sigma2CACA*(dijCACA-dk)**2)
>              if (itype(j).ne.10) then
>              expCASC = dexp(-0.5d0*sigma2CASC*(dijCASC-dk)**2)
>              else
>              endif
>              expCASC = 0.0d0
>              if (itype(i).ne.10) then
>              expSCCA = dexp(-0.5d0*sigma2SCCA*(dijSCCA-dk)**2)
>              else 
>              expSCCA = 0.0d0
>              endif
>              if (itype(i).ne.10 .and. itype(j).ne.10) then
>              expSCSC = dexp(-0.5d0*sigma2SCSC*(dijSCSC-dk)**2)
>              else
>              expSCSC = 0.0d0
>              endif
>              Pcalc(k) = Pcalc(k)+expCACA+expCASC+expSCCA+expSCSC
> #ifdef DEBUG
>              write(iout,*) "i j k Pcalc",i,j,Pcalc(k)
> #endif
>              CACAgrad = sigma2CACA*(dijCACA-dk)*expCACA
>              CASCgrad = sigma2CASC*(dijCASC-dk)*expCASC
>              SCCAgrad = sigma2SCCA*(dijSCCA-dk)*expSCCA
>              SCSCgrad = sigma2SCSC*(dijSCSC-dk)*expSCSC
>              do l=1,3
> c CA CA 
>                aux = CACAgrad*(C(l,j)-C(l,i))/dijCACA
>                PgradC(k,l,i) = PgradC(k,l,i)-aux
>                PgradC(k,l,j) = PgradC(k,l,j)+aux
> c CA SC
>                if (itype(j).ne.10) then
>                aux = CASCgrad*(C(l,j+nres)-C(l,i))/dijCASC
>                PgradC(k,l,i) = PgradC(k,l,i)-aux
>                PgradC(k,l,j) = PgradC(k,l,j)+aux
>                PgradX(k,l,j) = PgradX(k,l,j)+aux
>                endif
> c SC CA
>                if (itype(i).ne.10) then
>                aux = SCCAgrad*(C(l,j)-C(l,i+nres))/dijSCCA
>                PgradX(k,l,i) = PgradX(k,l,i)-aux
>                PgradC(k,l,i) = PgradC(k,l,i)-aux
>                PgradC(k,l,j) = PgradC(k,l,j)+aux
>                endif
> c SC SC
>                if (itype(i).ne.10 .and. itype(j).ne.10) then
>                aux = SCSCgrad*(C(l,j+nres)-C(l,i+nres))/dijSCSC
>                PgradC(k,l,i) = PgradC(k,l,i)-aux
>                PgradC(k,l,j) = PgradC(k,l,j)+aux
>                PgradX(k,l,i) = PgradX(k,l,i)-aux
>                PgradX(k,l,j) = PgradX(k,l,j)+aux
>                endif
>              enddo ! l
>            enddo ! k
> #else
>            dijCACA=dist(i,j)
>            sigma2CACA=scal_rad**2*0.25d0/
>      &        (restok(itype(j))**2+restok(itype(i))**2)
> 
>            IF (saxs_cutoff.eq.0) THEN
>            do k=1,nsaxs
>              dk = distsaxs(k)
>              expCACA = dexp(-0.5d0*sigma2CACA*(dijCACA-dk)**2)
9506,9509c9689
<              CACAgrad = sigma2CACA*diffd*(diffd+1.0d0)/dijCACA*expCACA
<              CACAgrad1 = -sigma2CACA/(radtab(i)+radtab(j))
<      &        *diffd*diffd*expCACA
< c             CACAgrad1=0.0d0
---
>              CACAgrad = sigma2CACA*(dijCACA-dk)*expCACA
9515,9534d9694
<              do ii=1,nei(i)
<                inii=inei(ii,i)
< c               aux=CACAgrad1*radtabprim(ii,i)/dist(i,inii)
<                aux=CACAgrad1*radtabprim(ii,i)*dnei_inv(ii,i)
< c               write (iout,*) "ii",i,j,k,ii,inii,dist(i,inii),aux
<                do l=1,3
<                  PgradC(k,l,i)=PgradC(k,l,i)-aux*(C(l,inii)-C(l,i))
<                 PgradC(k,l,inii)=PgradC(k,l,inii)+aux*(C(l,inii)-C(l,i))
<                enddo
<              enddo
<              do jj=1,nei(j)
<                injj=inei(jj,j)
< c               aux=CACAgrad1*radtabprim(jj,j)/dist(j,injj)
<                aux=CACAgrad1*radtabprim(jj,j)*dnei_inv(jj,j)
< c               write (iout,*) "jj",i,j,k,jj,injj,dist(i,injj),aux
<                do l=1,3
<                  PgradC(k,l,j)=PgradC(k,l,j)-aux*(C(l,injj)-C(l,j))
<                 PgradC(k,l,injj)=PgradC(k,l,injj)+aux*(C(l,injj)-C(l,j))
<                enddo
<              enddo
9537c9697
<            rrr = saxs_cutoff*(restok(itype(i))+restok(itype(j)))/2
---
>            rrr = saxs_cutoff*2.0d0/dsqrt(sigma2CACA)
9540d9699
<              diffd = dlog(dijCACA)-dlog(dk)
9545,9548c9704
<              if (energy_dec) write(iout,'(a4,3i5,8f10.4)') 
<      &          'saxs',i,j,k,dijCACA,restok(itype(i)),restok(itype(j)),
<      &          1.0d0/dsqrt(sigma2CACA),rrr,dk,sss2,ssgrad2
<              expCACA = dexp(-0.5d0*sigma2CACA*diffd**2)*sss2
---
>              expCACA = dexp(-0.5d0*sigma2CACA*(dijCACA-dk)**2)*sss2
9553,9556c9709,9710
<              CACAgrad = sigma2CACA*diffd*(diffd+1.0d0)/dijCACA*expCACA
<      &            -ssgrad2*expCACA/sss2
<              CACAgrad1 = -sigma2CACA/(radtab(i)+radtab(j))
<      &        *diffd*diffd*expCACA
---
>              CACAgrad = -sigma2CACA*(dijCACA-dk)*expCACA+
>      &             ssgrad2*expCACA/sss2
9560,9561c9714,9715
<                PgradC(k,l,i) = PgradC(k,l,i)-aux
<                PgradC(k,l,j) = PgradC(k,l,j)+aux
---
>                PgradC(k,l,i) = PgradC(k,l,i)+aux
>                PgradC(k,l,j) = PgradC(k,l,j)-aux
9563,9582d9716
<              do ii=1,nei(i)
<                inii=inei(ii,i)
< c               aux=CACAgrad1*radtabprim(ii,i)/dist(i,inii)
<                aux=CACAgrad1*radtabprim(ii,i)*dnei_inv(ii,i)
< c               write (iout,*) "ii",i,j,k,ii,inii,dist(i,inii),aux
<                do l=1,3
<                  PgradC(k,l,i)=PgradC(k,l,i)-aux*(C(l,inii)-C(l,i))
<                 PgradC(k,l,inii)=PgradC(k,l,inii)+aux*(C(l,inii)-C(l,i))
<                enddo
<              enddo
<              do jj=1,nei(j)
<                injj=inei(jj,j)
< c               aux=CACAgrad1*radtabprim(jj,j)/dist(j,injj)
<                aux=CACAgrad1*radtabprim(jj,j)*dnei_inv(jj,j)
< c               write (iout,*) "jj",i,j,k,jj,injj,dist(i,injj),aux
<                do l=1,3
<                  PgradC(k,l,j)=PgradC(k,l,j)-aux*(C(l,injj)-C(l,j))
<                 PgradC(k,l,injj)=PgradC(k,l,injj)+aux*(C(l,injj)-C(l,j))
<                enddo
<              enddo
9584a9719
> #endif
9694c9829
<       double precision PgradC(3,maxres),PgradX(3,maxres),PcalcC,logPtot
---
>       double precision PgradC(3,maxres),PgradX(3,maxres),Pcalc_,logPtot
9701c9836
<      & auxX,auxX1
---
>      & auxX,auxX1,Cnorm
9719c9854
<         PcalcC=0.0d0
---
>         Pcalc_=0.0d0
9741c9876
<           PcalcC = PcalcC+expCASPH+expSCSPH
---
>           Pcalc_ = Pcalc_+expCASPH+expSCSPH
9743,9744c9878,9879
<           write(*,*) "processor i j PcalcC",
<      &       MyRank,i,j,dijCASPH,dijSCSPH, PcalcC
---
>           write(*,*) "processor i j Pcalc",
>      &       MyRank,i,j,dijCASPH,dijSCSPH, Pcalc_
9756,9757c9891,9892
<             gsaxsc(l,i)=gsaxsc(l,i)+PgradC(l,i)/PcalcC
<             gsaxsx(l,i)=gsaxsx(l,i)+PgradX(l,i)/PcalcC
---
>             gsaxsc(l,i)=gsaxsc(l,i)+PgradC(l,i)/Pcalc_
>             gsaxsx(l,i)=gsaxsx(l,i)+PgradX(l,i)/Pcalc_
9760,9761c9895,9896
<         logPtot = logPtot - dlog(PcalcC) 
< c        print *,"me",me,MyRank," j",j," logPcalcC",-dlog(PcalcC),
---
>         logPtot = logPtot - dlog(Pcalc_) 
> c        print *,"me",me,MyRank," j",j," logPcalc",-dlog(Pcalc_),
fitsq.f
geomout.F
14,18c14,16
<       character*1 chainid(0:61)/'0','A','B','C','D','E','F','G','H','I',
<      & 'J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y',
<      & 'Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
<      & 'p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5',
<      & '6','7','8','9'/
---
>       character*1 chainid(32) /'A','B','C','D','E','F','G','H','I','J',
>      & 'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
>      & '1','2','3','4','5','6'/
21,42d18
<       do i=1,nss
< c        write (iout,*) "i",i," ihpb",ihpb(i),jhpb(i)
<         ici=ireschain(ihpb(i)-nres)
<         icj=ireschain(jhpb(i)-nres)
< c        write (iout,*) "ici",ici," icj",icj
<         iri=ihpb(i)-chain_border(1,ici)+1-nres
<         irj=jhpb(i)-chain_border(1,icj)+1-nres
<         ici = mod(ici,60)+1
<         icj = mod(icj,60)+1
< c        write (iout,*) ihpb(i),ici,iri,jhpb(i),icj,irj
<         write(ipdb,'(a6,i4,1x,a3,1x,a1,i5,4x,a3,1x,a1,i5,38x,f5.2)')
<      &    'SSBOND',i,'CYS',chainid(ici),iri,'CYS',chainid(icj),irj,
<      &    dist(ihpb(i),jhpb(i))
<       enddo
<       write (ipdb,'(6hCRYST1,3f9.3,3f7.2,1x,1hP,i2,i12)') 
<      & boxxsize,boxysize,boxzsize,90.00,90.00,90.00,1,1          
<       write (ipdb,'(6hORIGX1,4x,3f10.5,f15.5)') 1.0,0.0,0.0,0.0
<       write (ipdb,'(6hORIGX2,4x,3f10.5,f15.5)') 0.0,1.0,0.0,0.0
<       write (ipdb,'(6hORIGX2,4x,3f10.5,f15.5)') 0.0,0.0,1.0,0.0
<       write (ipdb,'(6hSCALE1,4x,3f10.5,f15.5)') 1.0,0.0,0.0,0.0
<       write (ipdb,'(6hSCALE2,4x,3f10.5,f15.5)') 1.0,0.0,0.0,0.0
<       write (ipdb,'(6hSCALE3,4x,3f10.5,f15.5)') 1.0,0.0,0.0,0.0
59,60c35
<         ici = mod(ichain,61)
<         write (ipdb,10) iatom,restyp(iti),chainid(ici),
---
>         write (ipdb,10) iatom,restyp(iti),chainid(ichain),
64c39
<           write (ipdb,20) iatom,restyp(iti),chainid(ici),
---
>           write (ipdb,20) iatom,restyp(iti),chainid(ichain),
160,161c135,136
<       write (iout,'(7a)') '  Res     ','         d','     Theta',
<      & '       Phi','       Dsc','     Alpha','      Omega'
---
>       write (iout,'(6a)') '  Res  ','     Theta','       Phi',
>      & '       Dsc','     Alpha','      Omega'
164,166c139,140
<         write (iout,'(a3,i7,6f10.3)') restyp(iti),i,vbld(i),
<      &     rad2deg*theta(i),rad2deg*phi(i),vbld(nres+i),rad2deg*alph(i),
<      &     rad2deg*omeg(i)
---
>         write (iout,'(a3,i4,5f10.3)') restyp(iti),i,rad2deg*theta(i),
>      &     rad2deg*phi(i),dsc(iti),rad2deg*alph(i),rad2deg*omeg(i)
223d196
<       include 'COMMON.SBRIDGE'
227,229d199
< c      print *,"CARTOUT",igr,i," NSS",nss_all(i)," ihpb,jhpb",
< c     & (ihpb_all(j,i),jhpb_all(j,i),j=1,nss_all(i))
<       if (dyn_ss) then
231,235c201
<      & nss_all(i),(iss(ihpb_all(j,i)),iss(jhpb_all(j,i)),j=1,nss_all(i))
<       else
<       write (igeom,'(i4,$)')
<      & nss_all(i),(ihpb_all(j,i)-nres,jhpb_all(j,i)-nres,j=1,nss_all(i))
<       endif
---
>      &  nss_all(i),(ihpb_all(j,i),jhpb_all(j,i),j=1,nss_all(i))
gnmr1.f
4c4
<       integer wykl /4/
---
>       double precision wykl /4.0d0/
18c18
<       integer wykl /4/
---
>       double precision wykl /4.0d0/
32c32,33
<       harmonic=(y-ymax)*(y-ymax)
---
>       double precision wykl /2.0d0/
>       harmonic=(y-ymax)**wykl
38c39,40
<       harmonicprim=2*(y-ymax)
---
>       double precision wykl /2.0d0/
>       harmonicprim=(y-ymax)*wykl
41a44
> c---------------------------------------------------------------------------------
45c48
<       integer wykl /4/
---
>       double precision wykl /4.0d0/
59c62
<       integer wykl /4/
---
>       double precision wykl /4.0d0/
71,261c74
< c------------------------------------------------------------------------------
< C 6/20/2020 by Adam: introducing linear ramp
<       double precision function rlornmr2(y,ymin,ymax,sigma,slope)
<       implicit none
<       double precision y,ymin,ymax,sigma,slope
<       integer wykl /4/
< c      double precision slope /1.0d-2/
< c f(x,a)=(x**4*(1+a*abs(x)))/(1+x**4)
<       if (y.lt.ymin) then
<         rlornmr2=(ymin-y)**wykl*(1.0d0+slope*dlog(dcosh(ymin-y)))/
<      &    ((ymin-y)**wykl+sigma**wykl)
<       else if (y.gt.ymax) then
<         rlornmr2=(y-ymax)**wykl*(1.0d0+slope*dlog(dcosh(y-ymax)))/
<      &    ((y-ymax)**wykl+sigma**wykl)
<       else
<         rlornmr2=0.0d0
<       endif
<       return
<       end
< c--------------------------------------  --------------------------------------
<       double precision function rlornmr2prim(y,ymin,ymax,sigma,slope)
<       implicit none
<       double precision y,ymin,ymax,sigma,slope
<       integer wykl /4/
< c      double precision slope /1.0d-2/
<       if (y.lt.ymin) then
<         rlornmr2prim=
<      &   -(ymin-y)**(wykl-1)*(1.0d0+slope*dlog(dcosh(ymin-y)))
<      &   *sigma**wykl*wykl/((ymin-y)**wykl+sigma**wykl)**2-
<      & slope*(ymin-y)**wykl*dtanh((ymin-y))/((ymin-y)**wykl+sigma**wykl)
<       else if (y.gt.ymax) then
<        rlornmr2prim=(y-ymax)**(wykl-1)*(1.0d0+slope*dlog(dcosh(y-ymax)))
<      &   *sigma**wykl*wykl/((y-ymax)**wykl+sigma**wykl)**2+
<      & slope*(y-ymax)**wykl*dtanh((y-ymax))/((y-ymax)**wykl+sigma**wykl)
<       else
<         rlornmr2prim=0.0d0
<       endif
<       return
<       end
< c------------------------------------------------------------------------------
<       subroutine sub_rlornmr1(y,ymin,ymax,sigma,penalty,penaltyprim)
<       implicit none
<       double precision y,ymin,ymax,sigma
<       double precision penalty,penaltyprim
<       double precision dif,dif3,dif4,fac,sigma4
<       sigma4=sigma*sigma
<       sigma4=sigma4*sigma4
<       if (y.lt.ymin) then
<         dif = ymin-y
<         dif3=dif*dif*dif
<         dif4=dif3*dif  
<         fac=dif/(dif4+sigma4)
<         penalty=dif3*fac
<         penaltyprim=-4*sigma4*dif*fac*fac
<       else if (y.gt.ymax) then
<         dif = y-ymax
<         dif3=dif*dif*dif
<         dif4=dif3*dif
<         fac=dif/(dif4+sigma4)
<         penalty=dif3*fac
<         penaltyprim=4*sigma4*dif*fac*fac
<       else
<         penalty=0.0d0
<         penaltyprim=0.0d0
<       endif
<       return
<       end
< c------------------------------------------------------------------------------
< C 6/20/2020 by Adam: introducing linear ramp
<       subroutine sub_rlornmr2(y,ymin,ymax,sigma,slope,
<      & penalty,penaltyprim)
<       implicit none
<       double precision y,ymin,ymax,sigma,slope
<       double precision penalty,penaltyprim
<       double precision dif,dif3,dif4,fac,sigma4,edif,edif1,slopefac
<       sigma4=sigma*sigma
<       sigma4=sigma4*sigma4
<       if (y.lt.ymin) then
<         dif = ymin-y
<         dif3=dif*dif*dif
<         dif4=dif3*dif
<         edif=dexp(dif)
<         edif1=1.0d0/edif
<         slopefac=1.0d0+slope*dlog(0.5d0*(edif+edif1))
<         fac=dif/(dif4+sigma4)
<         penalty=dif3*fac*slopefac
<         penaltyprim=-4*sigma4*dif*fac*fac*slopefac
<      &   -slope*(edif-edif1)/(edif+edif1)*dif3*fac
<       else if (y.gt.ymax) then
<         dif = y-ymax
<         dif3=dif*dif*dif
<         dif4=dif3*dif
<         edif=dexp(dif)
<         edif1=1.0d0/edif
<         slopefac=1.0d0+slope*dlog(0.5d0*(edif+edif1))
<         fac=dif/(dif4+sigma4)
<         penalty=dif3*fac*slopefac
<         penaltyprim=4*sigma4*dif*fac*fac*slopefac
<      &   +slope*(edif-edif1)/(edif+edif1)*dif3*fac
<       else
<         penalty=0.0d0
<         penaltyprim=0.0d0
<       endif
<       return
<       end
< c------------------------------------------------------------------------------
< C 6/20/2020 by Adam: introducing linear ramp
<       subroutine sub_rlornmr3(y,ymin,ymax,sigma,slope,
<      & penalty,penaltyprim)
<       implicit none
<       double precision y,ymin,ymax,sigma,slope
<       double precision penalty,penaltyprim
<       double precision dif,dif3,dif4,fac,sigma4,edif,edif1,slopefac
<       sigma4=sigma*sigma
<       sigma4=sigma4*sigma4
<       if (y.lt.ymin) then
<         dif = ymin-y
<         dif3=dif*dif*dif
<         dif4=dif3*dif
<         slopefac=1.0d0+slope*dif
<         fac=dif/(dif4+sigma4)
<         penalty=dif3*fac*slopefac
<         penaltyprim=-4*sigma4*dif*fac*fac*slopefac-slope*dif3*fac
<       else if (y.gt.ymax) then
<         dif = y-ymax
<         dif3=dif*dif*dif
<         dif4=dif3*dif
<         slopefac=1.0d0+slope*dif
<         fac=dif/(dif4+sigma4)
<         penalty=dif3*fac*slopefac
<         penaltyprim=4*sigma4*dif*fac*fac*slopefac+slope*dif3*fac
<       else
<         penalty=0.0d0
<         penaltyprim=0.0d0
<       endif
<       return
<       end
< c------------------------------------------------------------------------------
<       subroutine sub_rlor2nmr1(y,ymin,ymax,sigma,penalty,penaltyprim)
<       implicit none
<       double precision y,ymin,ymax,sigma
<       double precision penalty,penaltyprim
<       double precision dif,dif2,fac,sigma2
<       sigma2=sigma*sigma
<       if (y.lt.ymin) then
<         dif = ymin-y
<         dif2=dif*dif
<         fac=1.0d0/(dif2+sigma2)
<         penalty=dif2*fac
<         penaltyprim=-2*sigma2*dif*fac*fac
<       else if (y.gt.ymax) then
<         dif = y-ymax
<         dif2=dif*dif
<         fac=1.0d0/(dif2+sigma2)
<         penalty=dif2*fac
<         penaltyprim=2*sigma2*dif*fac*fac
<       else
<         penalty=0.0d0
<         penaltyprim=0.0d0
<       endif
<       return
<       end
< c------------------------------------------------------------------------------
< C 6/20/2020 by Adam: introducing linear ramp
<       subroutine sub_rlor2nmr3(y,ymin,ymax,sigma,slope,
<      & penalty,penaltyprim)
<       implicit none
<       double precision y,ymin,ymax,sigma,slope
<       double precision penalty,penaltyprim
<       double precision dif,dif2,fac,sigma2,slopefac
<       sigma2=sigma*sigma
<       if (y.lt.ymin) then
<         dif = ymin-y
<         dif2=dif*dif
<         slopefac=1.0d0+slope*dif
<         fac=1.0d0/(dif2+sigma2)
<         penalty=dif2*fac*slopefac
<         penaltyprim=(-2*sigma2*dif*fac*slopefac-slope*dif2)*fac
<       else if (y.gt.ymax) then
<         dif = y-ymax
<         dif2=dif*dif
<         slopefac=1.0d0+slope*dif
<         fac=1.0d0/(dif2+sigma2)
<         penalty=dif2*fac*slopefac
<         penaltyprim=(2*sigma2*dif*fac*slopefac+slope*dif2)*fac
<       else
<         penalty=0.0d0
<         penaltyprim=0.0d0
<       endif
<       return
<       end
---
> 
hc.f
icant.f
inbox.F
initialize_p.F
20,23d19
< #ifdef MPI
<       include "COMMON.SETUP"
<       nfgtasks=1
< #endif
50d45
<       irotam_end=43
63,67d57
<       itube=45
< c file with NMR parameters
<       inmr=46
< c file with Xlink parameters
<       ixlnk=47
184c174
<       do i=1,max_cyst
---
>       do i=1,maxss
264d253
<       data proton  /'HN','HA','HB','HG','HD','HE','HZ','HH',5*'H*'/
529d517
<       include 'COMMON.NMR'
intcor.f
int_from_cart1.f
35,36d34
< c        write (iout,'(i5,3f10.5,5x,3f10.5)') i,(c(j,i),j=1,3),
< c     &   (c(j,i+nres),j=1,3)
iperm.f
main_clust.F
39,40c39,40
<       integer ilen
<       external ilen      
---
>       character*80 structure/'Structure'/
>       
42a43
>       double precision rmsnat
68,69d68
<       call nmrpar_read
<       call xlinkpar_read
153d151
< 
165a164,165
>       write (iout,*) 'ncon_work',ncon_work
>       call flush(iout)
206,207c206
<       open(80,file=scratchdir(:ilen(scratchdir))//'/distance',
<      &  form='unformatted')
---
>       open(80,file='/tmp/distance',form='unformatted')
matmult.f
misc.f
nmr_hpos.F
noyes.f
oligomer.f
parmread.F
493,522d492
< #ifdef SC_END
<       nterm_scend=0
<       arotam_end=0.0d0
<       read (irotam_end,*) ijunk
< c      write (iout,*) "ijunk",ijunk
<       do i=1,ntyp
<         if (i.eq.10) cycle
<         do j=1,2
<           read (irotam_end,'(a)')
<           read (irotam_end,*) nterm_scend(j,i)
< c          write (iout,*) "i",i," j",j," nterm",nterm_scend(j,i)
<           do k=0,nterm_scend(j,i)
<             read (irotam_end,*) ijunk,arotam_end(k,j,i)
< c            write (iout,*) "k",k," arotam",arotam_end(k,j,i)
<           enddo
<         enddo
<       enddo
<       if (lprint) then
<         write (iout,'(a)')
<      &    "Parameters of the local potentials of sidechain ends"
<         do i=1,ntyp
<           write (iout,'(5x,9x,2hp-,a3,6x,9x,a3,2h-p)')
<      &     restyp(i),restyp(i)
<           do j=0,max0(nterm_scend(1,i),nterm_scend(2,i))
<             write (iout,'(i5,2f20.10)')
<      &        j,arotam_end(j,1,i),arotam_end(j,2,i)
<           enddo
<         enddo
<       endif
< #endif
1628,1831d1597
<       end
< c------------------------------------------------------------------------
<       subroutine nmrpar_read(*)
<       implicit real*8 (a-h,o-z)
<       include 'DIMENSIONS'
<       include 'COMMON.IOUNITS'
<       include 'COMMON.CHAIN'
<       include 'COMMON.INTERACT'
<       include 'COMMON.GEO'
<       include 'COMMON.LOCAL'
<       include 'COMMON.TORSION'
<       include 'COMMON.FFIELD'
<       include 'COMMON.NAMES'
<       include 'COMMON.SBRIDGE'
<       include 'COMMON.SCCOR'
<       include 'COMMON.SCROT'
<       include 'COMMON.FREE'
<       include 'COMMON.SHIELD'
<       include 'COMMON.CONTROL'
<       include 'COMMON.LANGEVIN'
<       include 'COMMON.NMR'
<       character*12 str
< C Read NMR parameters to calculate distance restraints.
< c E. Lubecka, January 2020
< 
<       read (inmr,*) str
< c read parametres for HN
<       read (inmr,*) ihnparm,str
<       do i=1,ihnparm
<         read (inmr,*,end=120,err=120) jj,str,hn_parm(i)
<       enddo
< c read parametres for HA Gly
<       read (inmr,*) ihaGparm,str
<       do i=1,ihaGparm
<         read (inmr,*,end=120,err=120) jj,str,haGly_parm(i)
<       enddo
< c read parametres for HA Pro
<       read (inmr,*) ihaPparm,str
<       do i=1,ihaPparm
<         read (inmr,*,end=120,err=120) jj,str,haPro_parm(i)
<       enddo
< c read parametres for others HA 
<       read (inmr,*) ihaparm,str
<       do i=1,ihaparm
<         read (inmr,*,end=120,err=120) jj,str,ha_parm(i)
<       enddo
< c read parametres for HB
<       read (inmr,*) ihbparm,str
<       do i=1,ihbparm
<         read (inmr,*,end=120,err=120) jj,str,hb_parm(i)
<       enddo
< c Sidechain protons higher than HB; projections on CA-SC axis
<       do i=1,ntyp
<         read(inmr,*,end=120,err=120) nproton(i),
<      &    (protpos(j,i),j=3,nproton(i))
<       enddo
<       write (iout,*) "Parameters of NMR:"
<       write (iout,*) "parametrs of HN atoms"
<       do i=1,ihnparm
<         write (iout,'(i4,f8.3)') i,hn_parm(i)
<       enddo
<       write (iout,*) "parametrs of glycine HA"
<       do i=1,ihaGparm
<       write (iout,'(i4,f8.3)') i,haGly_parm(i)
<       enddo
<       write (iout,*) "parametrs of proline HA"
<       do i=1,ihaPparm
<         write (iout,'(i4,f8.3)') i,haPro_parm(i)
<       enddo
<       write (iout,*) "parametrs of other HAs"
<       do i=1,ihaparm
<         write (iout,'(i4,f8.3)') i,ha_parm(i)
<       enddo
<       write (iout,*) "parametrs of HBs"
<       do i=1,ihbparm
<         write (iout,'(i4,f8.3)') i,hb_parm(i)
<       enddo
<       write (iout,*) "Sidechain proton projections"
<       write (iout,'(4hRes ,12a8)') (proton(i),i=3,8)
<       do i=1,ntyp
<         write (iout,'(a4,12f8.3)') 
<      &    restyp(i),(protpos(j,i),j=3,nproton(i))
<       enddo
<       return
<   120 write (iout,*) "Error reading NMR parameters"
<       return 1
<       end
< c------------------------------------------------------------------------
<       subroutine xlinkpar_read(*)
<       implicit none
<       include 'DIMENSIONS'
<       include 'COMMON.IOUNITS'
<       include 'COMMON.CHAIN'
<       include 'COMMON.INTERACT'
<       include 'COMMON.GEO'
<       include 'COMMON.LOCAL'
<       include 'COMMON.TORSION'
<       include 'COMMON.FFIELD'
<       include 'COMMON.NAMES'
<       include 'COMMON.SBRIDGE'
<       include 'COMMON.SCCOR'
<       include 'COMMON.SCROT'
<       include 'COMMON.CONTROL'
<       include 'COMMON.XLINKS'
<       logical lprint
<       character*4 res1,res2
<       integer rescode
<       character*4 linknam
<       integer i,j,k,ityp1,ityp2,ijunk
<       integer findxlink
<       double precision rjunk
< c Xlink parameters Mateusz, Chun, Zhou
< c
<       read (ixlnk,*) nxlinks
<       write (iout,*) "nxlinks",nxlinks
<       read (ixlnk,*)
<       read (ixlnk,*)
<       do i=1,nxlinks
<         read (ixlnk,*) res1,res2,namlink(i),ijunk,(rjunk,k=1,3*ijunk)
<         ixlink(1,i)=rescode(0,res1,0)
<         ixlink(2,i)=rescode(0,res2,0)
<         write (iout,*) "ixlink",ixlink(1,i),ixlink(2,i)," nbondterm",
<      &    nbondterm(ixlink(1,i)),nbondterm(ixlink(2,i))
<         rxlink(1,i)=rjunk/vbldsc0(nbondterm(ixlink(1,i)),ixlink(1,i))
<         read (ixlnk,*)ijunk,(rjunk,k=1,3*ijunk)
<         rxlink(2,i)=rjunk/vbldsc0(nbondterm(ixlink(2,i)),ixlink(2,i))
<       enddo
<       write (iout,*) "After CAX"
<       read (ixlnk,*)
<       read (ixlnk,*)
<       read (ixlnk,*)
<       do i=1,nxlinks
<         read (ixlnk,*) res1,res2,linknam,nbxlink(i),
<      &   (alink(k,i),aklink(k,i),dxlink(k,i),k=1,nbxlink(i))
<         ityp1=rescode(0,res1,0)
<         ityp2=rescode(0,res2,0)
<         write (iout,*) "bond ityp1 ityp2",ityp1,ityp2
<         if (findxlink(ityp1,ityp2,linknam).ne.i) return1
<       enddo    
<       write (iout,*) "After XX"
<       read (ixlnk,*)
<       read (ixlnk,*)
<       read (ixlnk,*)
<       do i=1,nxlinks
<         read (ixlnk,*) res1,res2,linknam,ntxlink(1,i),
<      &   v0tlink(1,i),(axlink(k,1,i),bxlink(k,1,i),k=1,ntxlink(1,i))
<         ityp1=rescode(0,res1,0)
<         ityp2=rescode(0,res2,0)
<         write (iout,*) "angle ityp1 ityp2",ityp1,ityp2
<         if (findxlink(ityp1,ityp2,linknam).ne.i) return1
<         read (ixlnk,*) ntxlink(2,i),
<      &   v0tlink(2,i),(axlink(k,2,i),bxlink(k,2,i),k=1,ntxlink(2,i))
<       enddo
<       write (iout,*) "After angle"
<       read (ixlnk,*)
<       read (ixlnk,*)
<       read (ixlnk,*)
<       do i=1,nxlinks
<         read (ixlnk,*) res1,res2,linknam,ngxlink(i),
<      &   v0glink(i),(vglink(k,i),k=1,ngxlink(i))
<         ityp1=rescode(0,res1,0)
<         ityp2=rescode(0,res2,0)
<         write (iout,*) "dihedral ityp1 ityp2",ityp1,ityp2
<         if (findxlink(ityp1,ityp2,linknam).ne.i) return1
<       enddo
<       write (iout,*) "After dihedral"
<       lprint = .true.
<       if (lprint) then
<         write (iout,*) 
<         write (iout,*) "Parameters of crosslinks"
<         write (iout,*) "Link-bond parameters"
<         write (iout,"(3x,'res1 res2 link   ratio1  ratio2  ',
<      &   6('    a0  ','     k  ','    d0    '))") 
<         do i=1,nxlinks
<           write (iout,'(i2,1x,2(a4,1x),1x,a4,2f8.4,6(2x,3f8.4))') i,
<      &     restyp(ixlink(1,i)),restyp(ixlink(2,i)),namlink(i),
<      &     rxlink(1,i),rxlink(2,i),(alink(k,i),aklink(k,i),dxlink(k,i),
<      &     k=1,nbxlink(i))
<         enddo
<         write (iout,*)
<         write (iout,*) "Link-angle parameters"
<         write (iout,"(3x,'res1 res2 link ','    V0theta',
<      &   6('     atheta ','  btheta'))")
<         do i=1,nxlinks
<           write (iout,'(i2,1x,2(a4,1x),1x,a4,2x,f9.3,6(2x,2f9.3))') i,
<      &     restyp(ixlink(1,i)),restyp(ixlink(2,i)),namlink(i),
<      &     v0tlink(1,i),
<      &     (axlink(k,1,i),bxlink(k,1,i),k=1,ntxlink(1,i))
<           write (iout,'(18x,2x,f9.3,6(2x,2f9.3))') v0tlink(2,i),
<      &     (axlink(k,2,i),bxlink(k,2,i),k=1,ntxlink(2,i))
<         enddo
<         write (iout,*)
<         write (iout,*) "Link-dihedral parameters"
<         write (iout,"(3x,'res1 res2 link    V0gamma  ',$)")
<         write (iout,"(6(' Vgamma',i1,2x))") (k,k=1,6) 
<         do i=1,nxlinks
<           write (iout,'(i2,1x,2(a4,1x),1x,a4,6(2x,f8.4))') i,
<      &     restyp(ixlink(1,i)),restyp(ixlink(2,i)),namlink(i),
<      &     v0glink(i),(vglink(k,i),k=1,ngxlink(i))
<         enddo
<         write (iout,*)
<         lprint=.false.
<       endif
<       return
permut.F
pinorm.f
printmat.f
probabl.F
19d18
<       include "COMMON.NMR"
40,41d38
<       double precision rmsnat
<       external rmsnat
52,53c49,50
< c      write (iout,*) "PROBABL: ncon",ncon
< c      call flush(iout)
---
> C      write (iout,*) "ncon",ncon
> C      call flush(iout)
135,140d131
<         if (dyn_ss) then
<         do j=1,nss
<           idssb(j)=ihpb_all(j,i)
<           jdssb(j)=jhpb_all(j,i)
<         enddo 
<         else
145,152d135
<         endif
< #ifdef DEBUG
<         write (iout,*) "conformation", i," before etotal"
<         if (dyn_ss) then
<           write (iout,*) "nss",nss,
<      &      " idssb,jdssb",(idssb(k),jdssb(k),k=1,nss)
<         endif
< #endif
163,167d145
<           if (recalc_rms) then
< c            write (2,*) "original     rms",i,rmstb(i)
<             rmstb(i)=rmsnat(i)
< c            write (2,*) "recalculated rms",i,rmstb(i)
<           endif
170,179d147
<         if (atimeave.gt.0) then
< #ifdef DEBUG
<           write (iout,*) "conformation",i,ii,
<      &    " restraint energy",energia(15),
<      &    " replaced with time-ave restraint energy",energy(ii)
< #endif
<           totfree(i)=totfree(i)+energy(ii)-energia(15)
<           energia(0)=totfree(i)
<           energia(15)=energy(ii)
<         endif
187,190d154
<         if (dyn_ss) then
<           write (iout,*) "nss",nss,
<      &      " idssb,jdssb",(idssb(k),jdssb(k),k=1,nss)
<         endif
257,264d220
<         if (recalc_rms) then
<           do i=1,scount(me)
<             buffer(i)=rmstb(i)
<           enddo
<           call MPI_Gatherv(buffer(1),scount(me),MPI_DOUBLE_PRECISION,
<      &     rmstb(1),scount(0),idispl(0),MPI_DOUBLE_PRECISION,Master,
<      &     MPI_COMM_WORLD,IERROR)
<         endif
281,282c237,238
<           write (iout,'(2i5,5f10.5)') i,list_conf(i),fdimless(i),
<      &     gdt_ts_tb(i),gdt_ha_tb(i),tmscore_tb(i),rmstb(i)
---
>           write (iout,'(2i5,4f10.5)') i,list_conf(i),fdimless(i),
>      &     gdt_ts_tb(i),gdt_ha_tb(i),tmscore_tb(i)
read_constr_homology.F
260,261c260,261
<               ii=ii+1
<               l_homo(k,ii)=.false.
---
> c              ii=ii+1
> c              l_homo(k,ii)=.false.
read_coords.F
20,21c20,21
<       integer i,j,jj,jjj,jj_old,icount,k,kk,l,ii,if,ib,
<      &  nn,nn1,inan
---
>       integer i,j,jj,jjj,jj_old,icount,k,kk,l,ii,iii,itraj,if,ib,
>      &  nn,nn1,inan,nfrag
34a35,37
>       integer isize
>       real time,potE,uconst,uconst_back,t_bath,qfrag(100)
>       double precision rmsnat
52,54c55,56
< c 4/7.03 AL Store the time-average restraint energy
<       lenrec=12*(nres+nct-nnt+1)+4*(ns+2)+24
<       lenrec_in=12*(nres+nct-nnt+1)+4*(ns+2)+24
---
>       lenrec=12*(nres+nct-nnt+1)+4*(2*nss+2)+16
>       lenrec_in=12*(nres+nct-nnt+1)+4*(2*nss+2)+24
62c64
< #ifdef OLDFORMAT
---
> #ifdef CHUJ
131c133
<       return
---
> 
155a158
>           if (.not.canon) then
161d163
<           prec=10000.0
171a174,175
>           endif
>           prec=10000.0
190a195,297
>         if (canon) then
>           do itraj=0,ntraj-1
>             write(liczba,'(i3.3)') itraj
>             intinname=prefintin(:ilen(prefintin))//'_MD'//liczba//'.cx'
>             write (iout,*) "Processing canonical trajectory",itraj
>             write (iout,'(a)') intinname(:ilen(intinname))
>             call xdrfopen(ixdrf,intinname, "r", iret)
>             write (iout,*) "xdrfopen: iret",iret
>             if (iret.eq.0) then
>               write (iout,*) "Error: coordinate file ",
>      &         intinname(:ilen(intinname))," does not exist."
>               call flush(iout)
> #ifdef MPI
>               call MPI_ABORT(MPI_COMM_WORLD,IERROR,ERRCODE)
> #endif
>               stop
>             endif
>             if (iret.eq.0) stop
> c            print *,"iret",iret
> c            print *,"itrajstart",itrajstart," itrajend",itrajend
>             kk = 0
>             do while (itrajstart.eq.0 .or. kk.lt.itrajend)
>               call xdrffloat(ixdrf, time, iret)
> c              print *,"time",time," iret",iret
>               if (iret.eq.0) exit
>               kk = kk + 1
>               call xdrffloat(ixdrf, potE, iret)
>               call xdrffloat(ixdrf, uconst, iret)
> c              print *,"potE",potE," uconst",uconst
>               call xdrffloat(ixdrf, uconst_back, iret)
> c              print *,"uconst_back",uconst_back
>               call xdrffloat(ixdrf, t_bath, iret)
> c              print *,"t_bath",t_bath
>               call xdrfint(ixdrf, nss, iret)
>               do j=1,nss
>                 call xdrfint(ixdrf, ihpb(j), iret)
>                 call xdrfint(ixdrf, jhpb(j), iret)
>               enddo
> c              print *,"nss",nss
>               call xdrfint(ixdrf, nfrag, iret)
>               do j=1,nfrag
>                 call xdrffloat(ixdrf, qfrag(j), iret)
>               enddo
> c              print *,"nfrag",nfrag
>               prec=10000.0
> 
>               isize=0
>               call xdrf3dfcoord(ixdrf, csingle, isize, prec, iret)
> c             write (*,'(e15.8,2e15.5,f12.5,$)') time,potE,uconst,t_bath
> c             write (*,'(i4,$)') nss,(ihpb(j),jhpb(j),j=1,nss)
> c             write (*,'(i4,20f7.4)') nfrag,(qfrag(i),i=1,nfrag)
> c             write (*,'(8f10.5)') ((csingle(k,j),k=1,3),j=1,isize)
>               if (kk.ge.itrajstart .and. mod(kk,itrajfreq).eq.0) then
>                 i=i+1
>                 if (i.gt.maxconf) then
>                   write (iout,*) "Error: too many conformations ",
>      &           "(",maxconf,") maximum."
> #ifdef MPI
>                   call MPI_Abort(MPI_COMM_WORLD,errcode,ierror)
> #endif
>                   stop
>                 endif
>                 if (isize .ne. nres+nct-nnt+1) then
>                   print *,"Error: inconsistent sizes",
>      &              isize,nres+nct-nnt+1
>                 endif
>                 energy(jj+1)=potE
>                 do ii=1,nres
>                   do j=1,3
>                     c(j,ii)=csingle(j,ii)
>                   enddo
>                 enddo
>                 iii = 0
>                 do ii=nnt,nct
>                   iii = iii + 1
>                   do j=1,3
>                     c(j,ii+nres)=csingle(j,iii+nres)
>                   enddo
>                 enddo
>                 if (refstr) rmstb(i)=rmsnat(i)
> c                call oligomer
> #ifdef DEBUG
>                 write (iout,'(5hREAD ,i5,3f15.4,i10)') 
>      &           jj+1,energy(jj+1),entfac(jj+1),
>      &           rmstb(jj+1),iscor
>                  write (iout,*) "Conformation",jjj+1,jj+1
>                 write (iout,'(8f10.5)')((c(j,ii),j=1,3),ii=1,nres)
>                 write (iout,'(8f10.5)')((c(j,ii+nres),j=1,3),ii=nnt,nct)
>                 call flush(iout)
> #endif
>                 call add_new_cconf(jjj,jj,jj_old,icount,Next)
>               endif
>             enddo ! kk
>             write (iout,*) i-1," conformations read from file ",
>      &       intinname(:ilen(intinname))
>             write (iout,*) jj," conformations read so far"
> #if (defined(AIX) && !defined(JUBL))
>             call xdrfclose_(ixdrf, iret)
> #else
>             call xdrfclose(ixdrf, iret)
> #endif
>           enddo ! itraj
>         else
221,244c328,340
<             if (dyn_ss) then
<               do k=1,nss
<                 call xdrfint(ixdrf, idssb(k), iret)
<                 call xdrfint(ixdrf, jdssb(k), iret)
<                 idssb(k)=idssb(k)
<                 jdssb(k)=jdssb(k)
<                 ihpb(k)=iss(idssb(k))+nres
<                 jhpb(k)=iss(jdssb(k))+nres 
< #ifdef DEBUG
<                 write (iout,*) "jj",jj+1," dyn_ss:",idssb(k),
<      &            jdssb(k),ihpb(k),jhpb(k)
< #endif
<               enddo
<             else
<               do k=1,nss
<                 call xdrfint(ixdrf, ihpb(k), iret)
<                 if (iret.eq.0) goto 101
<                 call xdrfint(ixdrf, jhpb(k), iret)
<                 if (iret.eq.0) goto 101
< #ifdef DEBUG
<                 write (iout,*) "jj",jj+1," stat_ss:",ihpb(k),jhpb(k)
< #endif
<               enddo
<             endif
---
>             do j=1,nss
>            if (dyn_ss) then
>             call xdrfint(ixdrf, idssb(j), iret)
>             call xdrfint(ixdrf, jdssb(j), iret)
>         idssb(j)=idssb(j)-nres
>         jdssb(j)=jdssb(j)-nres
>            else
>               call xdrfint_(ixdrf, ihpb(j), iret)
>               if (iret.eq.0) goto 101
>               call xdrfint_(ixdrf, jhpb(j), iret)
>               if (iret.eq.0) goto 101
>            endif
>             enddo
260,262c356,357
< #ifdef DEBUG
<             write (iout,*) "nss",nss
<             write (iout,*) "iret",iret
---
> c            write (iout,*) "iret",iret
> c            write (iout,*) "nss",nss
264d358
< #endif
266,283c360,363
< #ifdef DEBUG
<             write (iout,*) "dyn_ss",dyn_ss
< #endif
<             if (dyn_ss) then
<               do k=1,nss
<                 call xdrfint(ixdrf, idssb(k), iret)
<                 call xdrfint(ixdrf, jdssb(k), iret)
<                 idssb(k)=idssb(k)
<                 jdssb(k)=jdssb(k)
<                 ihpb(k)=iss(idssb(k))+nres
<                 jhpb(k)=iss(jdssb(k))+nres
< c                ihpb(k)=iss(idssb(k))+nres
< c                jhpb(k)=iss(jdssb(k))+nres 
<               enddo
< #ifdef DEBUG
<               write (iout,*) "jj",jj+1," dyn_ss nss:",nss," bonds",
<      &            (idssb(k),jdssb(k),ihpb(k),jhpb(k),k=1,nss)
< #endif
---
>             do k=1,nss
>            if (dyn_ss) then
>             call xdrfint(ixdrf, idssb(k), iret)
>             call xdrfint(ixdrf, jdssb(k), iret)
285,294c365,368
<               do k=1,nss
<                 call xdrfint(ixdrf, ihpb(k), iret)
<                 if (iret.eq.0) goto 101
<                 call xdrfint(ixdrf, jhpb(k), iret)
<                 if (iret.eq.0) goto 101
<               enddo
< #ifdef DEBUG
<               write (iout,*) "jj",jj+1," stat_ss nss:",nss," bonds",
<      &          (ihpb(k),jhpb(k),k=1,nss)
< #endif
---
>               call xdrfint(ixdrf, ihpb(k), iret)
>               if (iret.eq.0) goto 101
>               call xdrfint(ixdrf, jhpb(k), iret)
>               if (iret.eq.0) goto 101
295a370
>             enddo
323d397
< C#define DEBUG
329,330c403,404
<           write (iout,'(8f10.5)') ((c(j,i),j=1,3),i=1,nres)
<           write (iout,'(8f10.5)') ((c(j,i+nres),j=1,3),i=nnt,nct)
---
>           write (iout,'(8f10.5)') ((c(j,ii),j=1,3),ii=1,nres)
>           write (iout,'(8f10.5)') ((c(j,ii+nres),j=1,3),ii=nnt,nct)
333d406
< c#undef DEBUG
335a409
>         endif
344c418
<           call xdrfclose_(ixdrf, iret)
---
>           if (.not.canon) call xdrfclose_(ixdrf, iret)
346c420
<           call xdrfclose(ixdrf, iret)
---
>           if (.not.canon) call xdrfclose(ixdrf, iret)
432c506
<         if ((vbld(j).lt.2.0d0 .or. vbld(j).gt.8.0d0)
---
>         if ((vbld(j).lt.2.0d0 .or. vbld(j).gt.5.0d0)
442,449c516,522
< c          write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct)
< c          write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct)
< c          write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres)
< c          write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres)
< c          write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1)
< c          write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1)
<           call intout
<           write (iout,*)
---
>           write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct)
>           write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct)
>           write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres)
>           write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres)
>           write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1)
>           write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1)
>           write (iout,*) 
457,459c530,532
<         itj=iabs(itype(j))
<         if (itj.eq.10 .or. itj.eq.ntyp1) cycle
<         if ((vbld(nres+j)-dsc(itj)).gt.2.0d0) then
---
>         itj=itype(j)
>         if (itype(j).ne.10 .and. (vbld(nres+j)-dsc(iabs(itj))).gt.2.0d0
>      &  .and. itype(j).ne.ntyp1) then
466,472c539,544
< c          write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct)
< c          write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct)
< c          write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres)
< c          write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres)
< c          write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1)
< c          write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1)
<           call intout
---
>           write (iout,'(8f10.4)') (vbld(k),k=nnt+1,nct)
>           write (iout,'(8f10.4)') (vbld(k),k=nres+nnt,nres+nct)
>           write (iout,'(8f10.4)') (rad2deg*theta(k),k=3,nres)
>           write (iout,'(8f10.4)') (rad2deg*phi(k),k=4,nres)
>           write (iout,'(8f10.4)') (rad2deg*alph(k),k=2,nres-1)
>           write (iout,'(8f10.4)') (rad2deg*omeg(k),k=2,nres-1)
545,550d616
<       if (dyn_ss) then
<       do i=1,nss
<         ihpb_all(i,icount)=idssb(i)
<         jhpb_all(i,icount)=jdssb(i)
<       enddo
<       else
555d620
<       endif
585c650
<       call MPI_Send(ihpb_all(1,1),icount*maxss,MPI_INTEGER,
---
>       call MPI_Send(ihpb_all(1,1),icount,MPI_INTEGER,
587c652
<       call MPI_Send(jhpb_all(1,1),icount*maxss,MPI_INTEGER,
---
>       call MPI_Send(jhpb_all(1,1),icount,MPI_INTEGER,
593,594d657
<       call MPI_Send(energy(jj_old),icount,MPI_DOUBLE_PRECISION,
<      &    Next,580,MPI_COMM_WORLD,IERROR)
641c704
<       call MPI_Recv(ihpb_all(1,1),icount*maxss,MPI_INTEGER,
---
>       call MPI_Recv(ihpb_all(1,1),icount,MPI_INTEGER,
643c706
<       call MPI_Send(ihpb_all(1,1),icount*maxss,MPI_INTEGER,
---
>       call MPI_Send(ihpb_all(1,1),icount,MPI_INTEGER,
645c708
<       call MPI_Recv(jhpb_all(1,1),icount*maxss,MPI_INTEGER,
---
>       call MPI_Recv(jhpb_all(1,1),icount,MPI_INTEGER,
647c710
<       call MPI_Send(jhpb_all(1,1),icount*maxss,MPI_INTEGER,
---
>       call MPI_Send(jhpb_all(1,1),icount,MPI_INTEGER,
657,660d719
<       call MPI_Recv(energy(jj_old),icount,MPI_DOUBLE_PRECISION,
<      &  Previous,580,MPI_COMM_WORLD,STATUS,IERROR)
<       call MPI_Send(energy(jj_old),icount,MPI_DOUBLE_PRECISION,
<      &  Next,580,MPI_COMM_WORLD,IERROR)
674,675d732
<         write (iout,'(16i5)') nss_all(i),(ihpb_all(j,i),jhpb_all(j,i),
<      &     j=1,nss_all(i))
701d757
<       double precision rjunk
706a763
> C#define DEBUG
711c768
< c      write (iout,*) "len=",len," form=",form," acc=",acc
---
>       write (iout,*) "len=",len," form=",form," acc=",acc
722,724c779,781
< c        if (dyn_ss) then
< c        read(icbase,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres),
< c     &    ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres),
---
>         if (dyn_ss) then
>         read(icbase,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres),
>      &    ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres),
726,727c783,784
< c     &    entfac(ii),rmstb(ii)
< c        else
---
>      &    entfac(ii),rmstb(ii)
>         else
730,733c787,789
<      &    nss_all(ij),(ihpb_all(i,ij),jhpb_all(i,ij),i=1,nss_all(ij)),
<      &    entfac(ii),energy(ii),rjunk
< c     &    entfac(ii),rmstb(ii)
< c         endif
---
>      &    nss_all(ij),(ihpb_all(i,ij),jhpb_all(i,ij),i=1,nss),
>      &    entfac(ii),rmstb(ii)
>          endif
739c795
<         write (iout,'(2e15.5)') entfac(ii)
---
>         write (iout,'(2e15.5)') entfac(ij)
741c797
<      &    jhpb_all(i,ij),i=1,nss_all(ij))
---
>      &    jhpb_all(i,ij),i=1,nss)
743a800
> C#undef DEBUG
746c803
< c      call flush(iout)
---
>       call flush(iout)
776c833
< c      write (iout,*) "lenrec",lenrec
---
>       write (iout,*) "lenrec",lenrec
789,791c846,848
< c       if (dyn_ss) then
< c        write(unit_out,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres),
< c     &    ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres),
---
>        if (dyn_ss) then
>         write(unit_out,rec=iii) ((allcart(j,i,ij),j=1,3),i=1,nres),
>      &    ((allcart(j,i,ij),j=1,3),i=nnt+nres,nct+nres),
793,794c850,851
< c     &    entfac(ii),rmstb(ii)
< c        else
---
>      &    entfac(ii),rmstb(ii)
>         else
798,799c855,856
<      &    entfac(ii),energy(ii),rmstb(ii)
< c       endif
---
>      &    entfac(ii),rmstb(ii)
>        endif
805,806c862,863
<         write (iout,'(16i5)') nss_all(ij),(ihpb_all(i,ij),
<      &   jhpb_all(i,ij),i=1,nss_all(ij))
---
>         write (iout,'(16i5)') nss_all(ij),(ihpb(i,ij),jhpb(i,ij),i=1,
>      &   nss_all(ij))
readpdb.F
readpdb-mult.F
28d27
<       ishift=0
34a34,35
>       ibeg=1
>       ishift1=0
327c328
<         write (iout,'(a3,1x,i4,3f8.3,5x,3f8.3)')
---
>         write (iout,'(a3,1x,i6,3f8.3,5x,3f8.3)')
676c677
<         write (iout,'(a3,1x,i4,3f8.3,5x,3f8.3)') 
---
>         write (iout,'(a3,1x,i6,3f8.3,5x,3f8.3)') 
read_ref_str.F
30d29
<       integer itmp(maxres)
33,35d31
<       do i=1,nres
<         itmp(i)=itype(i)
<       enddo
55c51
<         do i=1,nres0
---
>         do i=1,nres
158c154
<        write (iout,'(a,i3,a,i3,a,i3,a)')
---
>        write (iout,'(a,i6,a,i6,a,i6,a)')
readrtns.F
21d20
<       include 'COMMON.NMR'
31c30,36
<       dyn_ss = index(controlcard,"DYN_SS").gt.0
---
>       canon=index(controlcard,'CANON').gt.0
>       if (canon) then
>         call readi(controlcard,'NTRAJ',ntraj,1)
>         call readi(controlcard,'ITRAJSTART',itrajstart,1)
>         call readi(controlcard,'ITRAJEND',itrajend,maxconf)
>         call readi(controlcard,'ITRAJFREQ',itrajfreq,1)
>       endif
34d38
<       recalc_rms = index(controlcard,'RECALC_RMS').gt.0
156,162c160
<       call reada(controlcard,'NEI_MIN',rnei_min_bound,4.0d0)
<       call reada(controlcard,'NEI_MAX',rnei_max_bound,10.0d0)
<       call reada(controlcard,'SRADMIN',sigmamin,0.0d0)
<       call reada(controlcard,'SRADMAX',sigmamax,4.5d0)
<       rnei_mid_bound=(rnei_min_bound+rnei_max_bound)/2
<       if (nsaxs.gt.0) then
<         write (iout,*) "Number of SAXS restraints",NSAXS," SAXS_MODE",
---
>       write (iout,*) "Number of SAXS restraints",NSAXS," SAXS_MODE",
164,171d161
<         write (iout,*) "Minimum number of neighbors",rnei_min_bound
<         write (iout,*) "Maximum number of neighbors",rnei_max_bound
<         write (iout,*) "Minimum solvation radius",sigmamin
<         write (iout,*) "Maximum solvation radius",sigmamax
<       endif
<       call readi(controlcard,"TIME_AVE",atimeave,0)
<       if (atimeave.gt.0) write (iout,*)
<      & "Penalty function values from time-averaged restraints used"
255,261d244
< #define PAWEL
< #ifdef PAWEL
<       call reada(weightcard,"ATRISS",atriss,50000.0D0)
<       call reada(weightcard,"BTRISS",btriss,0.05D0)
<       call reada(weightcard,"CTRISS",ctriss,0.01D0)
<       call reada(weightcard,"DTRISS",dtriss,125000.0D0)
< #else
266d248
< #endif
424a407,414
>       chain_border1(1,1)=1
>       chain_border1(2,1)=chain_border(2,1)+1
>       do i=2,nchain-1
>         chain_border1(1,i)=chain_border(1,i)-1
>         chain_border1(2,i)=chain_border(2,i)+1
>       enddo
>       if (nchain.gt.1) chain_border1(1,nchain)=chain_border(1,nchain)-1
>       chain_border1(2,nchain)=nres
428c418
<      &    chain_border(2,i)
---
>      &    chain_border(2,i),chain_border1(1,i),chain_border1(2,i)
704,705d693
<       else if (nss.gt.0) then
<         call hpb_partition
903,941c891
< c----------------------------------------------------------------------------
<       subroutine reads(rekord,lancuch,wartosc,default)
<       implicit none
<       character*(*) rekord,lancuch,wartosc,default
<       character*80 aux
<       integer ilen,lenlan,lenrec,iread,ireade
<       external ilen
<       logical iblnk
<       external iblnk
<       lenlan=ilen(lancuch)
<       lenrec=ilen(rekord)
<       iread=index(rekord,lancuch(:lenlan)//"=")
< c      print *,"rekord",rekord," lancuch",lancuch
< c      print *,"iread",iread," lenlan",lenlan," lenrec",lenrec
<       if (iread.eq.0) then
<         wartosc=default
<         return
<       endif
<       iread=iread+lenlan+1
< c      print *,"iread",iread
< c      print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
<       do while (iread.le.lenrec .and. iblnk(rekord(iread:iread)))
<         iread=iread+1
< c      print *,"|",rekord(iread:iread),"|",iblnk(rekord(iread:iread))
<       enddo
< c      print *,"iread",iread
<       if (iread.gt.lenrec) then
<          wartosc=default
<         return
<       endif
<       ireade=iread+1
< c      print *,"ireade",ireade
<       do while (ireade.lt.lenrec .and.
<      &   .not.iblnk(rekord(ireade:ireade)))
<         ireade=ireade+1
<       enddo
<       wartosc=rekord(iread:ireade)
<       return
<       end
---
> 
1019,1022d968
< #ifdef SC_END
<       call getenv('ROTPAR_END',rotname_end)
<       open (irotam_end,file=rotname_end,status='old')
< #endif
1049,1074d994
< C
< C 3/19/21 Read XLINK parameters.
< C
<       call getenv('XLINKPAR',xlinkname)
< #if defined(WINIFL) || defined(WINPGI)
<       open (ixlnk,file=xlinkname,status='old',readonly,shared)
< #elif (defined CRAY)  || (defined AIX)
<       open (ixlnk,file=xlinkname,status='old',action='read')
< #elif (defined G77)
<       open (ixlnk,file=xlinkname,status='old')
< #else
<       open (ixlnk,file=xlinkname,status='old',readonly)
< #endif
< C
< C 1/15/20 Read NMR parameters EL.
< C
<       call getenv('NMRPAR',nmrname)
< #if defined(WINIFL) || defined(WINPGI)
<       open (inmr,file=nmrname,status='old',readonly,shared)
< #elif (defined CRAY)  || (defined AIX)
<       open (inmr,file=nmrname,status='old',action='read')
< #elif (defined G77)
<       open (inmr,file=nmrname,status='old')
< #else
<       open (inmr,file=nmrname,status='old',readonly)
< #endif
1079c999
<       implicit none
---
>       implicit real*8 (a-h,o-z)
1080a1001,1003
> #ifdef MPI
>       include 'mpif.h'
> #endif
1085,1086d1007
<       include 'COMMON.NMR'
<       include 'COMMON.NAMES'
1088,1095c1009,1012
<       include 'COMMON.XLINKS'
<       integer i,j,k,ii,jj,itemp,link_type,iiend,jjend,kk,iihpb,jjhpb
<       integer nfrag_,npair_,ndist_,ifrag_(2,100),ipair_(2,1000)
<       double precision wfrag_(100),wpair_(1000)
<       double precision ddjk,dist,dist_cut,fordepthmax
<       double precision fordepth_peak_,forcon_peak_,protdist_min
<       character*5000 controlcard
<       character*3 att1,att2
---
>       integer ifrag_(2,100),ipair_(2,100)
>       double precision wfrag_(100),wpair_(100)
>       character*500 controlcard
>       logical lprn /.true./
1097d1013
<       logical protcheck
1100,1105d1015
<       integer nnpeak,npeak_prev
<       integer findxlink
<       character*4 linkname
<       integer itypi,itypj
<       integer ilen
<       external ilen
1113d1022
< c      print *, "WCHODZE" 
1115,1117d1023
<       do i=0,4
<         xlink(2,i)=4*xlink(2,i)
<       enddo
1120d1025
<       restr_on_coord=.false.
1123,1126d1027
<       npeak=0
<       ipeak=0
<       nhpb_peak=0
<  
1133,1149c1034
<       if (restr_type.eq.10) 
<      &  call reada(controlcard,'WBOLTZD',wboltzd,0.591d0)
<       if (restr_type.eq.12) then
<         call reada(controlcard,'SCAL_PEAK',scal_peak,5.0d0)
<         call reada(controlcard,'SLOPE_PEAK',slope_peak,0.0d0)
<         call reada(controlcard,'FORDEPTH_PEAK',fordepth_peak_,2.0d0)
<         call reada(controlcard,'FORCON_PEAK',forcon_peak_,1.0d0)
<         call reada(controlcard,'PROTDIST_MIN',protdist_min,2.0d0)
<         write (iout,*) "SCAL_PEAK",scal_peak
<         write (iout,*) "PEAK RESTRAINT SLOPE",slope_peak
<         write (iout,*) "PEAK WELL DEPTH",fordepth_peak_
<         write (iout,*) "PEAK WELL THICKNESS",forcon_peak_
<         write (iout,*) "PROTDIST_MIN",protdist_min
<       else 
<         call reada(controlcard,'SLOPE',slope,0.0d0)
<         write (iout,*) "RESTRAINT SLOPE",slope
<       endif
---
>       call readi(controlcard,"NFRAG",nfrag_,0)
1154a1040,1043
>       if (restr_type.eq.10) 
>      &  call reada(controlcard,'WBOLTZD',wboltzd,0.591d0)
>       if (restr_type.eq.12)
>      &  call reada(controlcard,'SCAL_PEAK',scal_peak,5.0d0)
1159c1048,1050
<       if (restr_type.eq.10) write (iout,*) "WBOLTZD",wboltzd
---
>       normalize = index(controlcard,"NORMALIZE").gt.0
>       write (iout,*) "WBOLTZD",wboltzd
>       write (iout,*) "SCAL_PEAK",scal_peak
1169,1172c1060,1069
<       normalize = index(controlcard,"NORMALIZE").gt.0
<       if (nfrag_.gt.0 .or. restr_type.eq.4 .or. restr_type.eq.5) 
<      & write (iout,*) 
<      &   "Distance restraints as generated from reference structure"
---
>       if (nfrag_.gt.0 .or. restr_type.eq.4 .or. restr_type.eq.5) then
>         nres0=nres
>         read(inp,'(a)') pdbfile
>         write (iout,*) 
>      & "Distance restraints will be constructed from structure ",pdbfile
>         open(ipdbin,file=pdbfile,status='old',err=11)
>         call readpdb(.true.)
>         nres=nres0
>         close(ipdbin)
>       endif
1249c1146
<             write (iout,'(a,3i5,f8.2,1pe12.2)') "+dist.restr ",
---
>             write (iout,'(a,3i5,f8.2,f10.1)') "+dist.restr ",
1255c1152
<       write (iout,*) "ndist",ndist_
---
> c      print *,ndist_
1257,1259d1153
<       npeak=0
<       npeak_prev=0
<       ii=0
1261d1154
< c       for NMR restraints
1263,1320c1156,1165
< c          read (inp,*) hpb_peak(1,nhpb_peak+1),hpb_peak(2,nhpb_peak+1),
< c     &    npeak,hpb_peak(5,nhpb_peak+1),att1,att2
<          read (inp,*) ihpb_peak(1,nhpb_peak+1),jhpb_peak(1,nhpb_peak+1),
<      &    nnpeak,dhpb1_peak(nhpb_peak+1),att1,att2
< c 6/12/2020 Adam: Remove restraints within same residue
<          if (ihpb_peak(1,nhpb_peak+1).eq.jhpb_peak(1,nhpb_peak+1)) cycle
<          ii=ii+1
<          if (nnpeak.ne.npeak_prev) then
<            npeak=npeak+1
<            num_peak(npeak)=nnpeak
<            npeak_prev=nnpeak
<          endif
< c         write(iout,*)ihpb_peak(1,nhpb_peak+1),jhpb_peak(1,nhpb_peak+1),
< c     &    npeak,dhpb_peak(nhpb_peak+1),dhpb1_peak(nhpb_peak+1),att1,att2
< c          dhpb_peak(nhpb_peak+1)=2.0d0
<           dhpb_peak(nhpb_peak+1)=protdist_min
< c          forcon_peak(nhpb_peak+1)=1.0d0
<           forcon_peak(nhpb_peak+1)=forcon_peak_
< c          fordepth_peak(nhpb_peak+1)=2.0d0
<           fordepth_peak(nhpb_peak+1)=fordepth_peak_
<           ihpb_peak(2,nhpb_peak+1)=maxnmrType+1
<           if (att1.eq.'H') ihpb_peak(2,nhpb_peak+1)=0
<           if (att1.eq.'HA' .or. att1.eq.'QA' .or. att1.eq.'HA2' .or.
<      &        att1.eq.'HA3') ihpb_peak(2,nhpb_peak+1)=1
<           if (att1.eq.'HB1' .or. att1.eq.'HB2' .or. att1.eq.'HB3' .or.
<      &        att1.eq.'QB' .or. att1.eq.'HB') ihpb_peak(2,nhpb_peak+1)=2
<           if (att1.eq.'HG1' .or. att1.eq.'HG2' .or. att1.eq.'HG3' .or.
<      &        att1.eq.'QG' .or. att1.eq.'HG') ihpb_peak(2,nhpb_peak+1)=3
<           if (att1.eq.'HD1' .or. att1.eq.'HD2' .or. att1.eq.'HD3' .or.
<      &        att1.eq.'QD' .or. att1.eq.'HD') ihpb_peak(2,nhpb_peak+1)=4
<           if (att1.eq.'HE1' .or. att1.eq.'HE2' .or. att1.eq.'HE3' .or.
<      &        att1.eq.'QE' .or. att1.eq.'HE') ihpb_peak(2,nhpb_peak+1)=5
<           if (att1.eq.'HZ1' .or. att1.eq.'HZ2' .or. att1.eq.'HZ3' .or.
<      &        att1.eq.'QZ' .or. att1.eq.'HZ') ihpb_peak(2,nhpb_peak+1)=6
<           if (att1.eq.'HH1' .or. att1.eq.'HH2' .or. att1.eq.'HH3' .or.
<      &        att1.eq.'QH' .or. att1.eq.'HH') ihpb_peak(2,nhpb_peak+1)=7
< 
<           jhpb_peak(2,nhpb_peak+1)=maxnmrType+1
<           if (att2.eq.'H') jhpb_peak(2,nhpb_peak+1)=0
<           if (att2.eq.'HA' .or. att2.eq.'QA' .or. att2.eq.'HA2' .or.
<      &        att2.eq.'HA3') jhpb_peak(2,nhpb_peak+1)=1
<           if (att2.eq.'HB1' .or. att2.eq.'HB2' .or. att2.eq.'HB3' .or.
<      &        att2.eq.'QB' .or. att2.eq.'HB') jhpb_peak(2,nhpb_peak+1)=2
<           if (att2.eq.'HG1' .or. att2.eq.'HG2' .or. att2.eq.'HG3' .or.
<      &        att2.eq.'QG' .or. att2.eq.'HG') jhpb_peak(2,nhpb_peak+1)=3
<           if (att2.eq.'HD1' .or. att2.eq.'HD2' .or. att2.eq.'HD3' .or.
<      &        att2.eq.'QD' .or. att2.eq.'HD') jhpb_peak(2,nhpb_peak+1)=4
<           if (att2.eq.'HE1' .or. att2.eq.'HE2' .or. att2.eq.'HE3' .or.
<      &        att2.eq.'QE' .or. att2.eq.'HE') jhpb_peak(2,nhpb_peak+1)=5
<           if (att2.eq.'HZ1' .or. att2.eq.'HZ2' .or. att2.eq.'HZ3' .or.
<      &        att2.eq.'QZ' .or. att2.eq.'HZ') jhpb_peak(2,nhpb_peak+1)=6
<           if (att2.eq.'HH1' .or. att2.eq.'HH2' .or. att2.eq.'HH3' .or.
<      &        att2.eq.'QH' .or. att2.eq.'HH') jhpb_peak(2,nhpb_peak+1)=7
< 
<           if (ihpb_peak(1,nhpb_peak+1).le.0.0d0.or.
<      &        jhpb_peak(1,nhpb_peak+1).le.0.0d0)cycle
< c          if (forcon_peak(nhpb_peak+1).le.0.0d0.or.
< c     &      fordepth_peak(nhpb_peak+1).le.0.0d0)cycle
---
>           read (inp,*) ihpb_peak(nhpb_peak+1),jhpb_peak(nhpb_peak+1),
>      &    dhpb_peak(nhpb_peak+1),dhpb1_peak(nhpb_peak+1),
>      &    ibecarb_peak(nhpb_peak+1),forcon_peak(nhpb_peak+1),
>      &    fordepth_peak(nhpb_peak+1),npeak
> c          write(iout,*) ihpb_peak(nhpb_peak+1),jhpb_peak(nhpb_peak+1),
> c     &    dhpb_peak(nhpb_peak+1),dhpb1_peak(nhpb_peak+1),
> c     &    ibecarb_peak(nhpb_peak+1),forcon_peak(nhpb_peak+1),
> c     &    fordepth_peak(nhpb_peak+1),npeak
>           if (forcon_peak(nhpb_peak+1).le.0.0d0.or.
>      &      fordepth_peak(nhpb_peak+1).le.0.0d0)cycle
1323,1329c1168,1181
<           if (ipeak(1,npeak).eq.0) ipeak(1,npeak)=ii
<           ipeak(2,npeak)=ii
<           if (nnt.gt.1) then
<             if (ihpb_peak(2,nhpb_peak).gt.0) 
<      &         ihpb_peak(1,nhpb_peak)=ihpb_peak(1,nhpb_peak)+nnt-1
<             if (jhpb_peak(2,nhpb_peak).gt.0) 
<      &         jhpb_peak(1,nhpb_peak)=jhpb_peak(1,nhpb_peak)+nnt-1
---
>           if (ipeak(1,npeak).eq.0) ipeak(1,npeak)=i
>           ipeak(2,npeak)=i
>           write (iout,'(a,5i5,2f8.2,2f10.5,i5)') "+dist.restr ",
>      &     nhpb_peak,ihpb_peak(nhpb_peak),jhpb_peak(nhpb_peak),
>      &     ibecarb_peak(nhpb_peak),npeak,dhpb_peak(nhpb_peak),
>      &     dhpb1_peak(nhpb_peak),forcon_peak(nhpb_peak),
>      &     fordepth_peak(nhpb_peak),irestr_type_peak(nhpb_peak)
>           if (ibecarb_peak(nhpb_peak).eq.3) then
>             jhpb_peak(nhpb_peak)=jhpb_peak(nhpb_peak)+nres
>           else if (ibecarb_peak(nhpb_peak).eq.2) then
>             ihpb_peak(nhpb_peak)=ihpb_peak(nhpb_peak)+nres
>           else if (ibecarb_peak(nhpb_peak).eq.1) then
>             ihpb_peak(nhpb_peak)=ihpb_peak(nhpb_peak)+nres
>             jhpb_peak(nhpb_peak)=jhpb_peak(nhpb_peak)+nres
1331,1363d1182
<           proton1(nhpb_peak)=att1
<           proton2(nhpb_peak)=att2
<           write (iout,'(a,4i5,f5.1,2i5,2a5)') "+dist.restr ",
<      &     nhpb_peak,ihpb_peak(1,nhpb_peak),jhpb_peak(1,nhpb_peak),
<      &     npeak,dhpb1_peak(nhpb_peak),ihpb_peak(2,nhpb_peak),
<      &     jhpb_peak(2,nhpb_peak),att1,att2
<           if (.not.protcheck(ihpb_peak(1,nhpb_peak),
<      &         ihpb_peak(2,nhpb_peak)) ) stop 
<           if (.not.protcheck(jhpb_peak(1,nhpb_peak),
<      &         jhpb_peak(2,nhpb_peak)) ) stop 
< c#ifdef MPI
< c          if (.not.out1file .or. me.eq.king)
< c     &    write (iout,'(a,5i5,2f8.2,2f10.5,i5)') "+dist.restr ",
< c     &     nhpb_peak,ihpb_peak(nhpb_peak),jhpb_peak(nhpb_peak),
< c     &     ibecarb_peak(nhpb_peak),npeak,dhpb_peak(nhpb_peak),
< c     &     dhpb1_peak(nhpb_peak),forcon_peak(nhpb_peak),
< c     &     fordepth_peak(nhpb_peak),irestr_type_peak(nhpb_peak)
< c#else
< c          write (iout,'(a,5i5,2f8.2,2f10.5,i5)') "+dist.restr ",
< c     &     nhpb_peak,ihpb_peak(nhpb_peak),jhpb_peak(nhpb_peak),
< c     &     ibecarb_peak(nhpb_peak),npeak,dhpb_peak(nhpb_peak),
< c     &     dhpb1_peak(nhpb_peak),forcon_peak(nhpb_peak),
< c     &     fordepth_peak(nhpb_peak),irestr_type_peak(nhpb_peak)
< c#endif
< c          if (ibecarb_peak(nhpb_peak).eq.3) then
< c            jhpb_peak(nhpb_peak)=jhpb_peak(nhpb_peak)+nres
< c          else if (ibecarb_peak(nhpb_peak).eq.2) then
< c            ihpb_peak(nhpb_peak)=ihpb_peak(nhpb_peak)+nres
< c          else if (ibecarb_peak(nhpb_peak).eq.1) then
< c            ihpb_peak(nhpb_peak)=ihpb_peak(nhpb_peak)+nres
< c            jhpb_peak(nhpb_peak)=jhpb_peak(nhpb_peak)+nres
< c          endif
< 
1366c1185
<      &     dhpb1(nhpb+1),ibecarb(nhpb+1),forcon(nhpb+1),fordepth(nhpb+1)
---
>      &     dhpb1(nhpb+1),ibecarb(i),forcon(nhpb+1),fordepth(nhpb+1)
1419a1239,1242
> c          if (ibecarb(nhpb).gt.0) then
> c            ihpb(nhpb)=ihpb(nhpb)+nres
> c            jhpb(nhpb)=jhpb(nhpb)+nres
> c          endif
1432,1453d1254
<         else if (restr_type.eq.13) then
< c Cross-links, sidechain ends
<           call card_concat(controlcard)
<           write (iout,*) controlcard(:ilen(controlcard))
<           call readi(controlcard,"ILINK",ihpb(nhpb+1),0)
<           call readi(controlcard,"JLINK",jhpb(nhpb+1),0)
<           call reads(controlcard,"BRIDGE",linkname," ")
<           nhpb=nhpb+1
<           irestr_type(nhpb)=13
<           itypi=itype(ihpb(nhpb))
<           itypj=itype(jhpb(nhpb))
<           ibecarb(nhpb)=findxlink(iabs(itypi),iabs(itypj),linkname)
<           write (iout,*) "link",itypi,itypj,ibecarb(nhpb),linkname
<           if (ibecarb(nhpb).eq.0) then
<             write (iout,'(a,2(1x,a4,i7),1x,a4)')
<      &      "ERROR! Wrong cross link ",
<      &      restyp(itypi),ihpb(nhpb),restyp(itypj),jhpb(nhpb),linkname
<             stop
<           endif
<           write (iout,'(a,4i5,1x,a5,i5)') "+dist.restr ",
<      &     nhpb,ihpb(nhpb),jhpb(nhpb),ibecarb(nhpb),linkname,
<      &     irestr_type(nhpb)
1464a1266,1269
> c          if (ibecarb(nhpb).gt.0) then
> c            ihpb(nhpb)=ihpb(nhpb)+nres
> c            jhpb(nhpb)=jhpb(nhpb)+nres
> c          endif
1476c1281
<           write (iout,'(a,4i5,f8.2,f10.1)') "+dist.restr ",
---
>         write (iout,'(a,4i5,f8.2,f10.1)') "+dist.restr ",
1548c1353
<         write (iout,'(/a,i5,a/a5,2a10,a5,2a10,3a10,2a5)')
---
>         write (iout,'(/a,i5,a/4a5,2a8,3a10,a5)')
1551,1552c1356,1357
<      &  "   Nr","    res1  ","    res2  "," beta","   d1","   d2",
<      &  "    k","    V","  score"," type"
---
>      &  "   Nr"," res1"," res2"," beta","   d1","   d2","    k","    V",
>      &  "  score"," type"
1554,1570c1359,1361
<           if (irestr_type(i).ne.13) then
<             iihpb=ihpb(i)
<             jjhpb=jhpb(i)
<             if (iihpb.gt.nres) iihpb=iihpb-nres
<             if (jjhpb.gt.nres) jjhpb=jjhpb-nres
<             write(iout,'(i5,1x,2(a4,i5,1x),i5,2f10.6,3f10.5,2i5)')i-nss,
<      &       restyp(itype(iihpb)),iihpb,restyp(itype(jjhpb)),jjhpb,
<      &       ibecarb(i),dhpb(i),dhpb1(i),forcon(i),fordepth(i),
<      &       xlscore(i),irestr_type(i)
<           else
<             write (iout,'(i5,1x,2(a4,i5,1x),46x,a4,i5)')i-nss,
<      &       restyp(itype(ihpb(i))),ihpb(i),restyp(itype(jhpb(i))),
<      &       jhpb(i),namlink(ibecarb(i)),irestr_type(i)
<           endif
< c          write (iout,'(4i5,2f8.2,3f10.5,2i5)')i-nss,ihpb(i),jhpb(i),
< c     &  ibecarb(i),dhpb(i),dhpb1(i),forcon(i),fordepth(i),xlscore(i),
< c     &  irestr_type(i)
---
>           write (iout,'(4i5,2f8.2,3f10.5,i5)')i-nss,ihpb(i),jhpb(i),
>      &  ibecarb(i),dhpb(i),dhpb1(i),forcon(i),fordepth(i),xlscore(i),
>      &  irestr_type(i)
1573,1640c1364,1365
<       if (npeak.gt.0) then
<         write (iout,'(/a,i5,a/2a5,2a8,2a6,4a8,a5)')
<      &  "The following",npeak,
<      &  " NMR peak restraints have been imposed:",
<      &  "Group"," Peak","    res1","   res2"," prot1"," prot2",
<      &  "      d1","      d2","       k","       V"," type"
<         do i=1,npeak
< c          write (iout,*) i,ipeak(1,i),ipeak(2,i)
< c          call flush(iout)
<           do j=ipeak(1,i),ipeak(2,i)
<             iihpb=ihpb_peak(1,j)
<             jjhpb=jhpb_peak(1,j)
<             if (ihpb_peak(2,j).eq.0) iihpb=iihpb+1
<             if (jhpb_peak(2,j).eq.0) jjhpb=jjhpb+1
<             write (iout,'(2i6,2(a4,i4),2a6,4f8.2,i5)')i,j,
<      &       restyp(itype(iihpb)),iihpb,restyp(itype(jjhpb)),jjhpb,
<      &       proton(ihpb_peak(2,j)),proton(jhpb_peak(2,j)),
<      &       dhpb_peak(j),dhpb1_peak(j),
<      &       forcon_peak(j),fordepth_peak(i),irestr_type_peak(j)
<           enddo
<           write (iout,*) 
<         enddo
< #ifdef DEBUG
<         write (iout,*) "The ipeak array"
<         do i=1,npeak
<           write (iout,'(3i10)' ) i,ipeak(1,i),ipeak(2,i)
<         enddo
< #endif
<       endif
<       return
<       end
< c-------------------------------------------------------------------------------
<       logical function protcheck(ires,iproton)
<       implicit none
<       include 'DIMENSIONS'
<       include 'COMMON.IOUNITS'
<       include 'COMMON.NAMES'
<       include 'COMMON.NMR'
<       include 'COMMON.INTERACT'
<       integer ires,iproton
< c      write (iout,*) "protcheck",ires,iproton
< c      call flush(iout)
<       if (iproton.gt.nproton(iabs(itype(ires))) 
<      &  .or. iproton.gt.2.and.protpos(iproton,iabs(itype(ires)))
<      &    .eq.0.0d0) then
<          write (iout,*) "Residue ",restyp(itype(ires)),ires,
<      &   " does not have ",proton(iproton)
<         protcheck=.false.
<       else
<         protcheck=.true.
<       endif
<       return
<       end
< c-------------------------------------------------------------------------------
<       integer function findxlink(itypi,itypj,linknam)
<       implicit none
<       include 'DIMENSIONS'
<       include 'COMMON.XLINKS'
<       integer itypi,itypj,k
<       character*4 linknam
<       do k=1,nxlinks
<         if (itypi.eq.ixlink(1,k).and.itypj.eq.ixlink(2,k)
<      &      .and.linknam.eq.namlink(k)) then
<           findxlink=k
<           return
<         endif
<       enddo
<       findxlink=0
---
>       call hpb_partition
>       call flush(iout)
1641a1367,1368
>    11 write (iout,*)"read_dist_restr: error reading reference structure"
>       stop
refsys.f
rescode.f
rmscalc.F
rmsnat.f
seq2chains.f
setup_var.f
srtclust.f
ssMD.F
499,500c499,500
<         gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(l)
<         gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(l)
---
>         gvdwc(l,i)=gvdwc(l,i)-gg(l)+gg_lipi(k)
>         gvdwc(l,j)=gvdwc(l,j)+gg(l)+gg_lipj(k)
554d553
<       include "COMMON.SETUP"
815,880d813
< #define PAWEL
< #ifdef PAWEL
<       if ((iabs(j-i).le.2).or.(iabs(i-k).le.2)) then
<       eij1=0.0d0
<       else
<       eij1=dtriss/(atriss*(rij-rik)**2+btriss*(rij+rik)**6+ctriss)
<       endif
< C second case jth atom is center
<       if ((iabs(j-i).le.2).or.(iabs(j-k).le.2)) then
<       eij2=0.0d0
<       else
<       eij2=dtriss/(atriss*(rij-rjk)**2+btriss*(rij+rjk)**6+ctriss)
<       endif
< C the third case kth atom is the center
<       if ((iabs(i-k).le.2).or.(iabs(j-k).le.2)) then
<       eij3=0.0d0
<       else
<       eij3=dtriss/(atriss*(rik-rjk)**2+btriss*(rik+rjk)**6+ctriss)
<       endif
<       eij=eij1+eij2+eij3
< C The energy penalty calculated now time for the gradient part
< C derivative over rij
<       fac=-eij1**2/dtriss*(2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5)
<      &-eij2**2/dtriss*(2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)
<             gg(1)=xij*fac/rij
<             gg(2)=yij*fac/rij
<             gg(3)=zij*fac/rij
<       do m=1,3
<         gvdwx(m,i)=gvdwx(m,i)-gg(m)
<         gvdwx(m,j)=gvdwx(m,j)+gg(m)
<       enddo
<       do l=1,3
<         gvdwc(l,i)=gvdwc(l,i)-gg(l)
<         gvdwc(l,j)=gvdwc(l,j)+gg(l)
<       enddo
< C now derivative over rik
<       fac=-eij1**2/dtriss*
<      &(-2.0*atriss*(rij-rik)+6.0*btriss*(rij+rik)**5)
<      &-eij3**2/dtriss*(2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
<             gg(1)=xik*fac/rik
<             gg(2)=yik*fac/rik
<             gg(3)=zik*fac/rik
<       do m=1,3
<         gvdwx(m,i)=gvdwx(m,i)-gg(m)
<         gvdwx(m,k)=gvdwx(m,k)+gg(m)
<       enddo
<       do l=1,3
<         gvdwc(l,i)=gvdwc(l,i)-gg(l)
<         gvdwc(l,k)=gvdwc(l,k)+gg(l)
<       enddo
< C now derivative over rjk
<       fac=-eij2**2/dtriss*
<      &(-2.0*atriss*(rij-rjk)+6.0*btriss*(rij+rjk)**5)-
<      &eij3**2/dtriss*(-2.0*atriss*(rik-rjk)+6.0*btriss*(rik+rjk)**5)
<             gg(1)=xjk*fac/rjk
<             gg(2)=yjk*fac/rjk
<             gg(3)=zjk*fac/rjk
<       do m=1,3
<         gvdwx(m,j)=gvdwx(m,j)-gg(m)
<         gvdwx(m,k)=gvdwx(m,k)+gg(m)
<       enddo
<       do l=1,3
<         gvdwc(l,j)=gvdwc(l,j)-gg(l)
<         gvdwc(l,k)=gvdwc(l,k)+gg(l)
<       enddo
< #else
934d866
< #endif
timing.F
TMscore.F
37c37
<       PARAMETER(nmax=5000)
---
>       PARAMETER(nmax=maxres)
699c699,700
<       PARAMETER(nmax=5000)
---
>       include 'DIMENSIONS'
>       PARAMETER(nmax=maxres)
track.F
work_partition.F
22a23
>         call flush(iout)
wrtclust.f
19d18
<       include 'COMMON.NMR'
22,23d20
<       include 'COMMON.INTERACT'
<       include 'COMMON.NAMES'
29,30c26
<       logical viol_nmr,viol_nmr_gross
<       character*1 restr_viol(0:2) /' ','m','M'/
---
>       logical viol_nmr
33,34d28
<       double precision rvec(3)
<       character*4 resi,resj
35a30
>       write (iout,*) "wrtclust refstr",refstr
96a92
> c      write (iout,*) "ecut",ecut
98d93
< c      write (iout,*) "ecut",ecut," emin",emin
104c99
< c          if (jj.eq.1) exit
---
>           if (jj.eq.1) exit
147c142
<       write (iout,'(a,f7.2,a,3(a,f7.4))') "Cluster averages: RMSD",
---
>       write (iout,'(a,f5.2,a,3(a,f7.4))') "Cluster averages: RMSD",
181,186d175
< c              print *,"igr",igr," icon",icon," nss",nss_all(icon)
<               if (dyn_ss) then
<               call briefout(igr,iscore(icon),totfree(icon)/beta_h(ib),
<      &          totfree_gr(igr),nss_all(icon),iss(ihpb_all(1,icon)),
<      &          iss(jhpb_all(1,icon)),cfname)
<               else
188,189c177,178
<      &          totfree_gr(igr),nss_all(icon),ihpb_all(1,icon)-nres,
<      &          jhpb_all(1,icon)-nres,cfname)
---
>      &          totfree_gr(igr),nss_all(icon),ihpb_all(1,icon),
>      &          jhpb_all(1,icon),cfname)
191d179
<               endif
231c219
< c          call flush(iout)
---
>           call flush(iout)
243,258d230
<             nss=nss_all(icon)
< c            write (iout,*) "GROUP",i," ICON",icon," nss",nss
< c            write (*,*) "GROUP",i," ICON",icon," nss",nss
<             if (dyn_ss) then
<             do k=1,nss
<               ihpb(k)=iss(ihpb_all(k,icon))+nres
<               jhpb(k)=iss(jhpb_all(k,icon))+nres
< c              write (iout,*) ihpb(k),jhpb(k)
<             enddo
<             else
<             do k=1,nss
<               ihpb(k)=ihpb_all(k,icon)
<               jhpb(k)=jhpb_all(k,icon)
< c              write (iout,*) ihpb(k),jhpb(k)
<             enddo
<             endif
260d231
<             call inbox
262c233
<             write (ipdb,'("TER")')
---
> c            write (ipdb,'("TER")')
273d243
<           call inbox
275c245
<           write (ipdb,'("TER")')
---
> c          write (ipdb,'("TER")')
285,287c255,257
< c            write (iout,*) "Cluster",i
<             call TMscore_sub(rmsd,gdt_ts_closest(i),gdt_ha_closest(i),
<      &      tmscore_closest(i),cfname,.true.)
---
> c            write (iout,*) "Cluster",i," rms",rms_closest(i)
> c            call TMscore_sub(rmsd,gdt_ts_closest(i),gdt_ha_closest(i),
> c     &      tmscore_closest(i),cfname,.true.)
308,309c278
<             if (irestr_type(j).eq.10 .or. irestr_type(j).eq. 11 
<      &           .or. irestr_type(j).eq.13 ) then
---
>             if (irestr_type(j).eq.10 .or. irestr_type(j).eq. 11) then
331d299
< 
333d300
<           nviolpeak_gross=0
338,341c305
<           call int_from_cart1(.false.)
<           call vec_and_deriv
<           call nmr_hpos(.false.)
<           do j=1,npeak
---
>           do j=link_start_peak,link_end_peak
343d306
<             viol_nmr_gross=.true.
345,367c308,316
<               ii=ihpb_peak(1,ip)
<               iti=ihpb_peak(2,ip)
<               jj=jhpb_peak(1,ip)
<               itj=jhpb_peak(2,ip)
<               call hdist(ii,iti,jj,itj,dd,rvec)
<               iresi=ii-nnt+1
<               iresj=jj-nnt+1
<               if (iti.eq.0) then
<                 iresi=iresi+1
<                 resi=restyp(itype(ii+1))
<               else
<                 resi=restyp(itype(ii))
<               endif
<               if (itj.eq.0) then
<                 iresj=iresj+1
<                 resj=restyp(itype(jj+1))
<               else
<                 resj=restyp(itype(jj))
<               endif
<               if (dd.le.dhpb1_peak(ip)) then
<                 iviol=0
<               else if (dd.le.dhpb1_peak(ip)+2.0d0) then
<                 iviol=1
---
>               ii=ihpb_peak(ip)
>               jj=jhpb_peak(ip)
>               dd=dist(ii,jj)
> c              iip=ip-ipeak(1,j)+1
> C iii and jjj point to the residues for which the distance is assigned.
>               if (ii.gt.nres) then
>                 iii=ii-nres
>                 jjj=jj-nres 
>                 iiib=1
369c318,320
<                 iviol=2
---
>                 iii=ii
>                 jjj=jj
>                 iiib=0
371,374c322
<               write (jrms,'(2(a3,i5,1x),i5,2f8.2,2a6,2x,a1)')
<      &         resi,iresi,resj,iresj,num_peak(j),dd,dhpb1_peak(ip),
<      &         proton1(ip),proton2(ip),restr_viol(iviol)
<               if (dd.le.dhpb1_peak(ip)) then
---
>               if (dd.lt.dhpb1_peak(ip)) then
376,378c324,325
<                 viol_nmr_gross=.false.
<               else if (dd.le.dhpb1_peak(ip)+2.0d0) then
<                 viol_nmr_gross=.false.
---
> c                write (iout,*) j,iii,jjj,iiib
>                 write (jrms,'(4i6)') j,iii,jjj,iiib
381d327
<             write (jrms,*) 
386,388d331
<             if (viol_nmr_gross) then
<               nviolpeak_gross=nviolpeak_gross+1
<             endif
391c334
<            write (iout,'(a,i5,2h (f6.2,2h%))')
---
>            write (iout,'(a,i5,2h (f8.4,2h%))')
394,398c337,338
<             write (iout,'(a,i5,2h (f6.2,2h%))')
<      &    "Number of grossly violated NMR restraints (upper_limit+2A):",
<      &      nviolpeak_gross,100*(nviolpeak_gross+0.)/npeak
<             write (iout,'(a)')"List of violated restraints:"
<             write (iout,'(16i5)') (list_peak_viol(j),j=1,nviolpeak)
---
>            write (iout,'(a)')"List of violated restraints:"
>            write (iout,'(16i5)') (list_peak_viol(j),j=1,nviolpeak) 
401,473d340
< 
<           nviolpeak=0
<           nviolpeak_gross=0
<           write (NUMM,'(bz,i4.4)') i
<           cfname=prefixp(:ilen(prefixp))//"_T"//ctemper(:ilen(ctemper))
<      &    //"K_"//NUMM(:ilen(NUMM))//'.nmrave'
<           open(jrms,file=cfname)
<           call ave_restr(i)
<           itot=0
<           do j=1,npeak
<             viol_nmr=.true.
<             viol_nmr_gross=.true.
<             do ip=ipeak(1,j),ipeak(2,j)
<               itot=itot+1
<               dd = dnmr_xave0(itot)
<               ii=ihpb_peak(1,ip)
<               iti=ihpb_peak(2,ip)
<               jj=jhpb_peak(1,ip)
<               itj=jhpb_peak(2,ip)
<               iresi=ii-nnt+1
<               iresj=jj-nnt+1
<               if (iti.eq.0) then
<                 iresi=iresi+1
<                 resi=restyp(itype(ii+1))
<               else
<                 resi=restyp(itype(ii))
<               endif
<               if (itj.eq.0) then
<                 iresj=iresj+1
<                 resj=restyp(itype(jj+1))
<               else
<                 resj=restyp(itype(jj))
<               endif
<               if (dd.le.dhpb1_peak(ip)) then
<                 iviol=0
<               else if (dd.le.dhpb1_peak(ip)+2.0d0) then
<                 iviol=1
<               else
<                 iviol=2
<               endif
<               write (jrms,'(2(a3,i5,1x),i5,2f8.2,2a6,2x,a1)')
<      &         resi,iresi,resj,iresj,num_peak(j),dd,dhpb1_peak(ip),
<      &         proton1(ip),proton2(ip),restr_viol(iviol)
<               if (dd.le.dhpb1_peak(ip)) then
<                 viol_nmr=.false.
<                 viol_nmr_gross=.false.
<               else if (dd.le.dhpb1_peak(ip)+2.0d0) then
<                 viol_nmr_gross=.false.
<               endif
<             enddo
<             write (jrms,*) 
<             if (viol_nmr) then
<               nviolpeak=nviolpeak+1
<               list_peak_viol(nviolpeak)=j
<             endif
<             if (viol_nmr_gross) then
<               nviolpeak_gross=nviolpeak_gross+1
<             endif
<           enddo
<           if (nviolpeak.gt.0) then
<            write (iout,'(a,i5,2h (f6.2,2h%))')
<      &      "Number of violated NMR cluster-averaged restraints:",
<      &      nviolpeak,100*(nviolpeak+0.)/npeak
<             write (iout,'(2a,i5,2h (f6.2,2h%))')
<      &       "Number of cluster-averaged grossly violated",
<      &       " NMR restraints (upper_limit+2A):",
<      &      nviolpeak_gross,100*(nviolpeak_gross+0.)/npeak
<             write (iout,'(a)')
<      &     "List of cluster-averaged violated restraints:"
<             write (iout,'(16i5)') (list_peak_viol(j),j=1,nviolpeak)
<           endif
<           close(jrms)
< 
496d362
<           call inbox
498c364
<           write (ipdb,'("TER")')
---
> c          write (ipdb,'("TER")')
504,508d369
<         Cnorm=0.0d0
<         do j=1,nsaxs-1
<           Cnorm=Cnorm+(distsaxs(j+1)-distsaxs(j))*
<      &         (Psaxs(j+1)+Psaxs(j))/2
<         enddo
514c375
<           write (99,'(21h#distance        exp.,10f12.5)') 
---
>           write (99,'(5h#     ,10f10.5)') 
517c378
<             write (99,'(f9.4,20e12.4)') distsaxs(j),Psaxs(j)/Cnorm,
---
>             write (99,'(f6.2,10f10.5)') distsaxs(j),
579c440
<       include 'COMMON.SBRIDGE'
---
>       logical non_conv
616a478
> c        if (non_conv) print *,non_conv,icon,jcon
634d495
<         nss=0
677c538
<       include 'COMMON.SBRIDGE'
---
>       logical non_conv
683d543
< c      double precision energia(0:max_ene),escloc
694,696d553
< c      call etotal(energia(0))
<       call vec_and_deriv
< c      write (iout,*) energia(1)+energia(21),energia(2),energia(15)
703,707c560,562
<       rms=wsaxs*esaxs_constr+wstrain*ehpb
<       if (constr_dist.eq.12) rms=rms+edihcnstr
< c      write (iout,*) "k",k," jcon",list_conf(jcon),
< c     & "Esaxs_constr",esaxs_constr,
< c     & " Ehpb",ehpb," Edihcnstr",edihcnstr," rms",rms
---
>       rms=wsaxs*esaxs_constr+wstrain*ehpb+edihcnstr
> c      write (iout,*) "Esaxs_constr",esaxs_constr," Ehpb",ehpb,
> c     & " Edihcnstr",edihcnstr
713,715c568
<       write (iout,'(/a,i5,a,i5,a,f10.5)') 
<      &  "Family",igr," fittest conformation",list_conf(jconmin),
<      &  " penalty",rmsmin
---
>       write (iout,*) "fittest conformation",jconmin," penalty",rmsmin
721,732d573
<       nss=nss_all(jconmin)
<       if (dyn_ss) then
<       do k=1,nss
<         ihpb(k)=iss(ihpb_all(k,jconmin))+nres
<         jhpb(k)=iss(jhpb_all(k,jconmin))+nres
<       enddo
<       else
<       do k=1,nss
<         ihpb(k)=ihpb_all(k,jconmin)
<         jhpb(k)=jhpb_all(k,jconmin)
<       enddo
<       endif
746c587
<       include 'COMMON.SBRIDGE'
---
>       logical non_conv
765a607
>         if (non_conv) print *,non_conv,icon,jcon
778,791d619
<       nss=nss_all(jconmin)
<       if (dyn_ss) then
<       do k=1,nss
<         ihpb(k)=iss(ihpb_all(k,jconmin))+nres
<         jhpb(k)=iss(jhpb_all(k,jconmin))+nres
< c        write (iout,*) "k",k," ihpb",ihpb(k)," jhpb",jhpb(k)
<       enddo
<       else
<       do k=1,nss
<         ihpb(k)=ihpb_all(k,jconmin)
<         jhpb(k)=jhpb_all(k,jconmin)
< c        write (iout,*) "k",k," ihpb",ihpb(k)," jhpb",jhpb(k)
<       enddo
<       endif
819,878d646
<         enddo
<         c(1,i)=c(1,i)+boxxsize/2
<         c(2,i)=c(2,i)+boxysize/2
<         c(3,i)=c(3,i)+boxysize/2
<       enddo
<       return
<       end
< c------------------------------------------------------------------------------
<       subroutine ave_restr(igr)
<       implicit none
<       include 'DIMENSIONS'
<       include 'sizesclu.dat'
<       include 'COMMON.CONTROL'
<       include 'COMMON.CLUSTER'
<       include 'COMMON.CHAIN'
<       include 'COMMON.INTERACT'
<       include 'COMMON.VAR'
<       include 'COMMON.TEMPFAC'
<       include 'COMMON.IOUNITS'
<       include 'COMMON.SBRIDGE'
<       include 'COMMON.NMR'
<       integer igr
<       integer i,ii,j,jj,iti,itj,k,jcon,itot,ip
<       double precision boltz,qpart,eref,dd,rvec(3),onesix
< c      write (iout,*) "AVE_RESTR: igr",igr
<       onesix=-1.0d0/6.0d0
<       jcon=nconf(igr,1)
<       eref=totfree(jcon)
<       qpart=0.0d0
<       dnmr_xave0=0.0d0
<       DO K=1,LICZ(IGR)
<         jcon=nconf(igr,k)
<         do i=1,2*nres
<           do j=1,3
<             c(j,i)=allcart(j,i,jcon)
<           enddo
<         enddo
<         boltz=dexp(-totfree(jcon)+eref)
<         qpart = qpart + boltz
<         call int_from_cart1(.false.)
<         call vec_and_deriv
<         call nmr_hpos(.false.)
<         itot=0
<         do j=1,npeak
<           do ip=ipeak(1,j),ipeak(2,j)
<             itot=itot+1
<             ii=ihpb_peak(1,ip)
<             iti=ihpb_peak(2,ip)
<             jj=jhpb_peak(1,ip)
<             itj=jhpb_peak(2,ip)
<             call hdist(ii,iti,jj,itj,dd,rvec)
<             dnmr_xave0(itot)=dnmr_xave0(itot)+1.0d0/dd**6*boltz
<           enddo
<         enddo
<       enddo
<       itot=0
<       do j=1,npeak
<         do ip=ipeak(1,j),ipeak(2,j)
<           itot=itot+1
<           dnmr_xave0(itot)=(dnmr_xave0(itot)/qpart)**onesix
xlinks.F
COMMON.CHAIN
2,3c2,3
<      & nchain,chain_border,chain_length,ireschain,npermchain,
<      & tabpermchain,ishift_pdb,iz_sc,nres_chomo
---
>      & nchain,chain_border,chain_border1,chain_length,ireschain,
>      & npermchain,tabpermchain,ishift_pdb,iz_sc,nres_chomo
15c15
<      & chain_border(2,maxchain),nchain
---
>      & chain_border(2,maxchain),chain_border1(2,maxchain),nchain
COMMON.CLUSTER
COMMON.CONTACTS.org
COMMON.CONTROL
3c3,4
<      & constr_dist,shield_mode,tor_mode,constr_homology,homol_nset
---
>      & constr_dist,shield_mode,tor_mode,constr_homology,homol_nset,
>      & ntraj,itrajstart,itrajend,itrajfreq
8c9
<      & unres_pdb,recalc_rms
---
>      & unres_pdb,canon
16c17,18
<      & out_template_coord,out_template_restr,recalc_rms
---
>      & out_template_coord,out_template_restr,canon,ntraj,itrajstart,
>      & itrajend,itrajfreq
COMMON.DFA
COMMON.FFIELD
COMMON.FREE
COMMON.GEO
COMMON.HEADER
COMMON.HOMOLOGY
6c6
<       common /homol/  waga_homology(48),
---
>       common /homol/  waga_homology(10),
COMMON.HOMRESTR
COMMON.IOUNITS
14c14
<      &        iliptranpar,itube,inmr,ixlnk,irotam_end
---
>      &        iliptranpar
18c18
<      &        iliptranpar,itube,inmr,ixlnk,irotam_end
---
>      &        iliptranpar
40,41c40
<      &       fouriername,elename,sidename,scpname,patname,liptranname,
<      &       tubename,nmrname,xlinkname,rotname_end
---
>      &       fouriername,elename,sidename,scpname,patname,liptranname
43,44c42
<      &       fouriername,elename,sidename,scpname,patname,liptranname,
<      &       tubename,nmrname,xlinkname,rotname_end
---
>      &       fouriername,elename,sidename,scpname,patname,liptranname
COMMON.LANGEVIN
COMMON.MCM
COMMON.MINIM
COMMON.MPI
COMMON.NAMES
0a1
>       common /names/ restyp(-ntyp1:ntyp1),onelet(-ntyp1:ntyp1)
3,6d3
<       common /names/ restyp(-ntyp1:ntyp1),
<      &               onelet(-ntyp1:ntyp1)
<       character*4 proton(0:maxnmrType)
<       common /proton_names/ proton
COMMON.SAXS
3,8c3,7
<       double precision Psaxs(maxsaxs),Pcalc(maxSAXS),Cnorm,
<      & distsaxs(maxsaxs),CSAXS(3,maxsaxs),wsaxs0,scal_rad,saxs_cutoff,
<      & rnei_min_bound,rnei_max_bound,rnei_mid_bound,sigmamin,sigmamax
<       common /saxsretr/Psaxs,Pcalc,Cnorm,distsaxs,csaxs,Wsaxs0,scal_rad,
<      & saxs_cutoff,rnei_min_bound,rnei_max_bound,rnei_mid_bound,
<      & sigmamin,sigmamax,nsaxs,saxs_mode
---
>       double precision Psaxs(maxsaxs),Pcalc(maxsaxs),distsaxs(maxsaxs),
>      &  CSAXS(3,maxsaxs),scal_rad,wsaxs0,saxs_cutoff
>       common /saxsretr/ Psaxs,Pcalc,distsaxs,csaxs,Wsaxs0,scal_rad,
>      &  saxs_cutoff,nsaxs,saxs_mode
> 
COMMON.SCCOR
COMMON.SCROT
4,7d3
< c 3/30/2022 AL: add variables for end side chains
<       integer nterm_scend(2,ntyp)
<       double precision arotam_end(0:8,2,ntyp)
<       common /scrot_end/ arotam_end,nterm_scend
COMMON.SCROT.safe
COMMON.SHIELD
3c3
<      & buff_shield,wshield,grad_shield_loc            
---
>      & grad_shield_loc,buff_shield,wshield            
COMMON.TEMPFAC
COMMON.THREAD
COMMON.TIME1
COMMON.TORSION.org
COMMON.VAR
COMMON.XLINKS
