################# arcos.f
################# ave_restr1.F
################# ave_restr1_slow.F
################# ave_restr.F
42,44d41
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
46,48d42
< #ifdef MPI
<       endif
< #endif
################# blas1.f
################# boxshift.f
################# calc_rmsgdt.F
34,35d33
<       integer listmin(maxchain)
<       common /permutacja/ listmin
45c43
<       write (iout,*) "calc_rmsgdt:",me," indstart",indstart(me),
---
>       write (iout,*) "calc_rmsgdt: me," indstart",indstart(me),
################# cartprint.f
################# chainbuild.f
################# chain_clusters.F
################# chain_symmetry.F
2,3c2
<      &    chain_length,npermchain,tabpermchain,nchain_group,nequiv,
<      &  iequiv,mapchain)
---
>      &    chain_length,npermchain,tabpermchain)
10,13d8
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
23d17
<       integer maxequiv
71,73d64
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
80,82d70
< #ifdef MPI
<       endif
< #endif
90,92d77
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
97,99d81
< #ifdef MPI
<       endif
< #endif
101,122d82
< c
< c No need to determine permutations if superposition Algorithm 1 or 2 are used
< c
<       if (ialg.gt.0) return
<       
<       maxequiv=maxval(nequiv,1)
< c      write (2,*) "maxequiv",maxequiv
< c
< c Set ialg at 1 if too many permutations woudl be involved.
< c
<       if (maxequiv.ge.6) then
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
<         write (iout,*) "Too many chain permutations (max",maxequiv,
<      &   "!) switching to Algorithm 1."
< #ifdef MPI
<         endif
< #endif
<         ialg=1
<         return
<       endif 
159,161d118
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
167,169d123
< #ifdef MPI
<       endif
< #endif
################# cinfo.f
2c2
< C 0 0 32663
---
> C 0 40376 1024
6,7c6,7
<       write(iout,*)'Version 0.0 build 32663'
<       write(iout,*)'compiled Thu Jun 12 13:58:35 2025'
---
>       write(iout,*)'Version 0.40376 build 1024'
>       write(iout,*)'compiled Mon Aug 25 08:03:07 2025'
17a18,19
>       write(iout,*)'OPT = -CB -g -mcmodel=medium -shared-intel'
>       write(iout,*)'OPTE = ${OPT}'
25,42d26
<       write(iout,*)'object_superpos = \\'
<       write(iout,*)'	minimize_p.o\\'
<       write(iout,*)'	sumsld.o\\'
<       write(iout,*)'	cored.o\\'
<       write(iout,*)'	fitsq.o\\'
<       write(iout,*)'	rmdd.o\\'
<       write(iout,*)'	rmscalc.o \\'
<       write(iout,*)'	rmscalc_alg1.o\\'
<       write(iout,*)'	rmscalc_alg2.o\\'
<       write(iout,*)'	mindist.o\\'
<       write(iout,*)'	suplen.o\\'
<       write(iout,*)'	CM_shift.o\\'
<       write(iout,*)'	initial_quat.o \\'
<       write(iout,*)'	difconf.o \\'
<       write(iout,*)'	pair_present.o \\'
<       write(iout,*)'	quatrot.o \\'
<       write(iout,*)'	quaternion_derivatives.o\\'
<       write(iout,*)'	gaussdiff-anal.o'
################# CM_shift.F
################# contact.f
1a2
>       implicit none
8a10
>       real*8 dist
10a13,14
>       integer i,j,iti,itj,kkk,i1,i2,it1,it2
>       real*8 rcomp
15a20
>         if (iti.eq.ntyp1) cycle
17a23,24
>           if (itj.eq.ntyp1) cycle
> c          write (iout,*) "i",i," j",j," iti",iti," itj",itj
26c33
< c         print *,'rcomp=',rcomp,' dist=',dist(nres+i,nres+j)
---
> c          write(2,*)i,j,'r comp=',rcomp,' dist=',dist(nres+i,nres+j)
44a52
>       write (iout,*) "end contact"
################# contfunc.f
################# convert.f
################# cored.f
################# dfa.F
################# difconf.F
################# dpmeps.f
################# edis.F
505c505
< c      write (iout,*) "link_start",link_start," link_end",link_end
---
>       write (iout,*) "link_start",link_start," link_end",link_end
522,523c522,523
< c        write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
< c     &    dhpb(i),dhpb1(i),forcon(i)
---
>         write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj,
>      &    dhpb(i),dhpb1(i),forcon(i)
530,541c530
<         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)
< c           ehpb=ehpb+2*eij
<            ehpb=ehpb+eij
<          endif
< cd          write (iout,*) "eij",eij
< cd   &   ' waga=',waga,' fac=',fac
< !        else if (ii.gt.nres .and. jj.gt.nres) then
<         else
---
>         if (.not.dyn_ss .and. i.le.nss) cycle
544,562c533,551
< c          dd=dist(c(1,ii),c(1,jj))
<           dd=dist(ii,jj)
<           if (irestr_type(i).eq.11) then
<             if (slope.eq.0.0d0) then
<               ehpbi=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
<             else
<               ehpbi=fordepth(i)!**4.0d0
<      &           *rlornmr2(dd,dhpb(i),dhpb1(i),forcon(i),slope)
<               fac=fordepth(i)!**4.0d0
<      &           *rlornmr2prim(dd,dhpb(i),dhpb1(i),forcon(i),slope)/dd
<             endif
<             ehpb=ehpb+ehpbi
<             if (energy_dec) write (iout,'(a6,2i5,6f10.3,i5)')
<      &        "edisL",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),
<      &        ehpbi,irestr_type(i)
<           else if (irestr_type(i).eq.10) then
---
> c        dd=dist(c(1,ii),c(1,jj))
>         dd=dist(ii,jj)
>         if (irestr_type(i).eq.11) then
>           if (slope.eq.0.0d0) then
>             ehpbi=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
>           else
>             ehpbi=fordepth(i)!**4.0d0
>      &         *rlornmr2(dd,dhpb(i),dhpb1(i),forcon(i),slope)
>             fac=fordepth(i)!**4.0d0
>      &         *rlornmr2prim(dd,dhpb(i),dhpb1(i),forcon(i),slope)/dd
>           endif
>           ehpb=ehpb+ehpbi
>           if (energy_dec) write (iout,'(a6,2i5,6f10.3,i5)')
>      &      "edisL",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),
>      &      ehpbi,irestr_type(i)
>         else if (irestr_type(i).eq.10) then
564,582c553,571
<             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,8f15.8,i5)') 
<      &        "edisX",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),
<      &        xlscore(i),wboltzd,-wboltzd*xlscore(i)*dlog(aux),
<      &       irestr_type(i)
<           else if (irestr_type(i).eq.13) then
< c            write (iout,*) "edis:",i,ihpb(i),jhpb(i),irestr_type(i)
<             call Xlinkene(ihpb(i),jhpb(i),ibecarb(i),irestr_type(i),eij)
<             ehpb=ehpb+eij
<           else if (irestr_type(i).eq.2) then
---
>           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,8f15.8,i5)') 
>      &      "edisX",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),
>      &      xlscore(i),wboltzd,-wboltzd*xlscore(i)*dlog(aux),
>      &     irestr_type(i)
>         else if (irestr_type(i).eq.13) then
> c          write (iout,*) "edis:",i,ihpb(i),jhpb(i),irestr_type(i)
>           call Xlinkene(ihpb(i),jhpb(i),ibecarb(i),irestr_type(i),eij)
>           ehpb=ehpb+eij
>         else if (irestr_type(i).eq.2) then
584,589c573,578
<             ehpbi=forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
<             fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
<             ehpb=ehpb+ehpbi
<             if (energy_dec) write(iout,'(a6,2i5,5f10.3,i5)') 
<      &      "edisQ",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),ehpbi
<           else
---
>           ehpbi=forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
>           fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
>           ehpb=ehpb+ehpbi
>           if (energy_dec) write(iout,'(a6,2i5,5f10.3,i5)') 
>      &    "edisQ",ii,jj,dd,dhpb(i),dhpb1(i),forcon(i),ehpbi
>         else
591c580
<             rdis=dd-dhpb(i)
---
>           rdis=dd-dhpb(i)
593c582
<             waga=forcon(i)
---
>           waga=forcon(i)
595,598c584,587
<             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)
---
>           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)
602,603c591,592
<             fac=waga*rdis/dd
<           endif
---
>           fac=waga*rdis/dd
>         endif
605,607c594,596
<           do j=1,3
<             ggg(j)=fac*(c(j,jj)-c(j,ii))
<           enddo
---
>         do j=1,3
>           ggg(j)=fac*(c(j,jj)-c(j,ii))
>         enddo
611,623c600,607
<           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)
---
>         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)
625a610,613
>         do k=1,3
>           ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
>           ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
>         enddo
################# enecalc.F
33c33
< c      write (iout,*) me," indstart",indstart(me)," indend",indend(me)
---
>       write (iout,*) me," indstart",indstart(me)," indend",indend(me)
################# energy_p_new.F
199a200,205
>       ess=0.0d0
>       if (.not.dyn_ss) then
>         call ess_fixed(ess)
>       else
>         call ess_dyn(ess)
>       endif
216c222
<      & +wdfa_beta*edfabet
---
>      & +wdfa_beta*edfabet+wss*ess
228c234
<      & +wdfa_beta*edfabet
---
>      & +wdfa_beta*edfabet+wss*ess
242c248
<      & +wdfa_beta*edfabet
---
>      & +wdfa_beta*edfabet+wss*ess
254c260
<      & +wdfa_beta*edfabet
---
>      & +wdfa_beta*edfabet+wss*ess
296a303
>       energia(32)=ess
528a536
>       ess = energia(32)
547c555
<      &  ethetacnstr,ebr*nss,Uconst,wumb,eliptran,wliptran,Eafmforc,
---
>      &  ethetacnstr,ess,Uconst,wumb,eliptran,wliptran,Eafmforc,
605c613
<      &  ethetacnstr,ebr*nss,Uconst,wumb,eliptran,wliptran,Eafmforc,
---
>      &  ethetacnstr,ess,Uconst,wumb,eliptran,wliptran,Eafmforc,
1158,1177c1166
<             IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
<               call dyn_ssbond_ene(i,j,evdwij)
<               evdw=evdw+evdwij
< C            write (iout,'(a6,2i5,0pf7.3,a3,2f10.3)')
< C     &                        'evdw',i,j,evdwij,' ss',evdw,evdw_t
< C triple bond artifac removal
<              do k=j+1,iend(i,iint)
< C search over all next residues
<               if (dyn_ss_mask(k)) then
< C check if they are cysteins
< C              write(iout,*) 'k=',k
<               call triple_ssbond_ene(i,j,k,evdwij)
< C call the energy function that removes the artifical triple disulfide
< C bond the soubroutine is located in ssMD.F
<               evdw=evdw+evdwij
< C             write (iout,'(a6,2i5,0pf7.3,a3,2f10.3)')
< C     &                        'evdw',i,j,evdwij,'tss',evdw,evdw_t
<               endif!dyn_ss_mask(k)
<              enddo! k
<             ELSE
---
>             IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) cycle
1297d1285
<             ENDIF    ! dyn_ss            
################# fitsq.f
################# gaussdiff-anal.F
################# gaussdiff.F
################# geomout.F
################# gnmr1.f
################# hc.f
################# icant.f
################# inbox.F
12c12
<       double precision boxside(3),aux,aux1
---
>       double precision boxside(3),aux
54,71c54
<           aux1=dint(cmchain(j,i)/boxside(j))
< #ifdef DEBUG
<           write (iout,*) "ij",i,j," cmchain",cmchain(j,i),
<      &      " boxside",boxside(j)," aux",aux," aux1",aux1
< #endif
<           if (aux.lt.0.0d0) then
<             aux=-(aux1-1.0d0)*boxside(j)
<           else
<             aux=-aux1*boxside(j)
<           endif
< #ifdef DEBUG
<           write (iout,*) "aux",aux,aux/boxside(j)
< #endif
< c          if (aux.lt.0.0d0) then
< c             aux=aux+boxside(j)
< c          else if (aux.gt.boxside(j)) then
< c             aux=aux-boxside(j)
< c          endif
---
>           if (aux.lt.0.0d0) aux=aux+boxside(j)
75,76c58,59
<             c(j,k)=c(j,k)+aux!-cmchain(j,i)
<             c(j,k+nres)=c(j,k+nres)+aux!-cmchain(j,i)
---
>             c(j,k)=c(j,k)+aux-cmchain(j,i)
>             c(j,k+nres)=c(j,k+nres)+aux-cmchain(j,i)
79c62
<           cmchain(j,i)=cmchain(j,i)+aux
---
>           cmchain(j,i)=aux
115,117d97
<           c(1,k+nres)=c(1,k+nres)+ixmin*boxxsize
<           c(2,k+nres)=c(2,k+nres)+iymin*boxysize
<           c(3,k+nres)=c(3,k+nres)+izmin*boxzsize
119d98
< #ifdef DEBUG
122d100
< #endif
################# initialize_p.F
297c297,298
<      1   "EDFABET"/
---
>      1   "EDFABET",
>      2   "ESS"/
308c309
<      &   "WDFAT","WDFAN","WDFAB"/
---
>      &   "WDFAT","WDFAN","WDFAB","WSS"/
311c312
<       data nprint_ene /31/
---
>       data nprint_ene /32/
313c314
<      & 24,15,26,27,28,29,30,31,22,23,25,20/
---
>      & 24,15,26,27,28,29,30,31,22,23,25,20,32/
315c316
<       data nprint_ene /30/
---
>       data nprint_ene /31/
317c318
<      & 24,15,26,27,28,29,30,31,22,23,25,20,0/
---
>      & 24,15,26,27,28,29,30,31,22,23,25,20,32,0/
319c320
<       data nprint_ene /30/
---
>       data nprint_ene /31/
321c322
<      & 24,15,26,27,28,29,30,31,22,23,25,20,0/
---
>      & 24,15,26,27,28,29,30,31,22,23,25,20,32,0/
323c324
<       data nprint_ene /29/
---
>       data nprint_ene /31/
325c326
<      & 24,15,26,27,28,29,30,31,22,23,25,20,2*0/
---
>      & 24,15,26,27,28,29,30,31,22,23,25,20,32,0/
329c330
<       data nprint_ene /27/
---
>       data nprint_ene /28/
331c332
<      & 24,15,26,27,22,23,25,20,4*0/
---
>      & 24,15,26,27,22,23,25,20,32,4*0/
333c334
<       data nprint_ene /26/
---
>       data nprint_ene /27/
335c336
<      & 24,15,26,27,22,23,25,20,5*0/
---
>      & 24,15,26,27,22,23,25,20,32,5*0/
337c338
<       data nprint_ene /26/
---
>       data nprint_ene /27/
339c340
<      & 24,15,26,27,22,23,25,20,5*0/
---
>      & 24,15,26,27,22,23,25,20,32,5*0/
341c342
<       data nprint_ene /25/
---
>       data nprint_ene /26/
343c344
<      & 24,15,26,27,22,23,25,20,6*0/
---
>      & 24,15,26,27,22,23,25,20,32,6*0/
351,355d351
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
<       include 'COMMON.CONTROL'
418,420d413
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
428,430d420
< #ifdef MPI
<       endif
< #endif
438,440d427
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
447,449d433
< #ifdef MPI
<       endif
< #endif
472,474d455
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
482,484d462
< #ifdef MPI
<       endif
< #endif
504,506d481
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
508,516d482
< #ifdef MPI
<       endif
< #endif
< #ifdef MPI
<       call MPI_Type_contiguous(9,MPI_DOUBLE_PRECISION,MPI_OBROT,IERROR)
<       call MPI_Type_commit(MPI_OBROT,IERROR)
<       call MPI_Type_contiguous(maxchain,MPI_INTEGER,MPI_PERM,IERROR)
<       call MPI_Type_commit(MPI_PERM,IERROR)
< #endif
524,527d489
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
529d490
<       include 'COMMON.CONTROL'
552,554d512
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
556,558d513
< #ifdef MPI
<       endif
< #endif
566,568d520
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
570,572d521
< #ifdef MPI
<       endif
< #endif
581,584d529
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
588d532
<       include 'COMMON.CONTROL'
593,595d536
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
600,602d540
< #ifdef MPI
<       endif
< #endif
609,612d546
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
625,627d558
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
633,635d563
< #ifdef MPI
<       endif
< #endif
################# initial_quat.F
################# intcor.f
################# int_from_cart1.f
################# iperm.f
################# lbfgs_driver.F
################# linpack.f
################# main_clust.F
21,23d20
< #ifndef RESUP
<       include 'COMMON.SUPCLUST'
< #endif
38,41d34
< #ifndef RESUP
<       double precision obrot_buff(3,3,maxdist)
<       integer list_buff(maxchain,maxdist)
< #endif
57d49
<       character*80 tytul
64c56
<         write(*,*) "SEVERE ERROR - Can't initialize MPI."
---
>         write(iout,*) "SEVERE ERROR - Can't initialize MPI."
69c61
<         write (*,*) "Error - too many processors",
---
>         write (2,*) "Error - too many processors",
71c63
<         write (*,*) "Increase MaxProcs and recompile"
---
>         write (2,*) "Increase MaxProcs and recompile"
79,81d70
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
83,85d71
< #ifdef MPI
<       endif
< #endif
88d73
<       call promienie
120,122d104
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
129,131d110
< #ifdef MPI
<       endif
< #endif
133,135d111
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
137,143c113
< #ifdef MPI
<       endif
< #endif
<       else if (avenmr) then
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
---
>       else if (avenmr.or.avecont) then
145,147d114
< #ifdef MPI
<       endif
< #endif
149,152c116
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       write (iout,*) 
---
>       if (me.eq.Master) write (iout,*) 
155,157d118
< #ifdef MPI
<       endif
< #endif
166,168d126
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
170,187c128
< #ifdef MPI
<       endif
< #endif
< #ifdef DEBUG
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       do i=1,ncon
<         write (iout,*) "Conformation",i
<         do j=1,nres
<           write (iout,'(i3,3f10.5,5x,3f10.5)') j,allcart(:,j,i),
<      &     allcart(:,j+nres,i)
<         enddo
<       enddo
< #ifdef MPI
<       endif
< #endif
< #endif
---
>       
189,192d129
<       theta_ent_safe=theta_ent
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
194,196c131
< #ifdef MPI
<       endif
< #endif
---
>       theta_ent_safe=theta_ent
198,200d132
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
203,205d134
<       endif
< #endif
< #ifdef MPI
217,219d145
<         do i=1,ncon
<           list_conf(i)=i
<         enddo
273,275d198
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
280,282d202
< #ifdef MPI
<       endif
< #endif
317,328d236
< #ifdef DEBUG
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       write (iout,*) "list_conf",ncon_work
<       do i=1,ncon_work
<         write (iout,'(2i5)') i,list_conf(i)
<       enddo
< #ifdef MPI
<       endif
< #endif
< #endif
334c242
<         if (refstr.gt.0 .and. out_rms.gt.0) call out_rmsgdt(NCON,iT)
---
>         if (refstr.gt.1 .and. out_rms.gt.0) call out_rmsgdt(NCON,iT)
340,341c248
<         write (iout,*) "avenmr"
<         call ave_restr_all(ncon_work)
---
>         call ave_restr_all(ncon)
343c250
<         if (me.eq.Master) call print_ave_restr_all(ncon_work,iT)
---
>         if (me.eq.Master) call print_ave_restr_all(ncon,iT)
345c252
<         call print_ave_restr_all(ncon_work,iT)
---
>         call print_ave_restr_all(ncon,iT)
347a255
>       if (avecont) call ave_contact_all(ncon)
351,353d258
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
355,357d259
< #ifdef MPI
<         endif
< #endif
367,369d268
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
371,373d269
< #ifdef MPI
<       endif
< #endif
388c284
<           DISS(IND1)=DIFCONF(I,J,ind1)
---
>           DISS(IND1)=DIFCONF(I,J)
396,398d291
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
401,403d293
< #ifdef MPI
<       endif
< #endif
407d296
< #ifdef MPI
409,410c298
<       if (me.eq.Master .or. .not.out1file)
<      &  write (iout,*) "ndis",ndis," scount",scount(me)," ind1",ind1
---
> 
412,416c300
<         diss_buf(ijk)=diss(ijk)
< #ifndef RESUP
<         list_buff(:,ijk)=listmin_all(:,ijk)
<         obrot_buff(:,:,ijk)=obrot_all(:,:,ijk)
< #endif
---
>       diss_buf(ijk)=diss(ijk)
418c302,305
< c      WRITE (iout,*) "Wchodze do call MPI_Gatherv"
---
> 
> 
> #ifdef MPI
>       WRITE (iout,*) "Wchodze do call MPI_Gatherv"
420,450c307
<      &  scount(0),idispl(0),MPI_REAL,Master,MPI_COMM_WORLD, IERROR)
< #ifndef RESUP
<       call MPI_Gatherv(list_buff(1,1),scount_buf,MPI_PERM,
<      &  listmin_all(1,1),
<      &  scount(0),idispl(0),MPI_PERM,Master,MPI_COMM_WORLD, IERROR)
<       call MPI_Gatherv(obrot_buff(1,1,1),scount_buf,MPI_OBROT,
<      &  obrot_all(1,1,1),
<      &  scount(0),idispl(0),MPI_OBROT,Master,MPI_COMM_WORLD, IERROR)
< #ifdef DEBUG
<       if (me.eq.Master .or. .not.out1file) then
<         write (iout,*) "Optimal permutations"
<         ind1=0
<         do i=1,ncon_work-1
<           do j=i+1,ncon_work
<             ind1=ind1+1
<             write (iout,'(3i5)') i,j,ind1
<             write (iout,'(16i5)') listmin_all(:nchain,ind1)
<           enddo
<         enddo
<         write (iout,*) "Optimal rotations"
<         ind1=0
<         do i=1,ncon_work-1
<           do j=i+1,ncon_work
<             ind1=ind1+1
<             write (iout,'(3i5)') i,j,ind1
<             write (iout,'(3(3f10.5/))') obrot_all(:,:,ind1)
<           enddo
<         enddo
<       endif
< #endif
< #endif
---
>      &     scount(0),idispl(0),MPI_REAL,Master,MPI_COMM_WORLD, IERROR)
459d315
<         ind1=0
462,464c318,319
<             IND=IOFFSET(NCON_work,I,J)
<             ind1=ind1+1
<             write (jrms,'(2i5,2f10.5)') i,j,diss(IND1),
---
>             IND=IOFFSET(NCON,I,J)
>             write (jrms,'(2i5,2f10.5)') i,j,diss(IND),
469,475d323
< #ifdef PDBOUT
<       do i=1,ncon_work
<         c(:,:2*nres)=allcart(:,:2*nres,i)
<         write (tytul,'(a,i5)') "Conformation",i
<         call pdbout(energy(0,i),0.0d0,tytul)
<       enddo
< #endif
590d437
<       close(80,status="delete")
623a471,495
>       double precision function difconf(icon,jcon)
>       implicit none
>       include 'DIMENSIONS'
>       include 'sizesclu.dat'
>       include 'COMMON.CONTROL'
>       include 'COMMON.CLUSTER'
>       include 'COMMON.CHAIN' 
>       include 'COMMON.INTERACT'
>       include 'COMMON.VAR'
>       include 'COMMON.IOUNITS'
>       integer ipermmin
>       double precision przes(3),obrot(3,3)
>       double precision rmscalc
>       integer icon,jcon,k,l
> c      write (iout,*) "DIFCONF: ICON",icon," JCON",jcon
>       do k=1,2*nres
>         do l=1,3
>           cref(l,k)=allcart(l,k,icon)
>           c(l,k)=allcart(l,k,jcon)
>         enddo 
>       enddo
>       difconf=rmscalc(c(1,1),cref(1,1),przes,obrot,ipermmin)
>       RETURN
>       END
> C------------------------------------------------------------------------------
638,639c510
< c      write (iout,1000) (k,k=i,nlim)
<       write (iout,1000) (list_conf(k),k=i,nlim)
---
>       write (iout,1000) (k,k=i,nlim)
658,659c529
< c      write (iout,1010) j,(b(k),k=1,jlim-i+1)
<       write (iout,1010) list_conf(j),(b(k),k=1,jlim-i+1)
---
>       write (iout,1010) j,(b(k),k=1,jlim-i+1)
################# make_conf_list.F
################# matmult.f
################# mindist.F
################# minimize_p.F
################# misc.f
################# nmr_hpos.F
################# noyes.f
################# odlodc.f
################# oligomer.f
################# out_rms.F
################# pair_present.f
################# parmread.F
8,11d7
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
37c33
< c      write (iout,*) "PARMREAD tor_mode",tor_mode
---
>       write (iout,*) "PARMREAD tor_mode",tor_mode
40c36
< c      write (iout,*) "lprint ",lprint
---
>       write (iout,*) "lprint ",lprint
75,77d70
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
92,94d84
< #ifdef MPI
<       endif
< #endif
174,176d163
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
205,207d191
< #ifdef MPI
<       endif
< #endif
255,257d238
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
259,261d239
< #ifdef MPI
<       endif
< #endif
340,342d317
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
383,385d357
< #ifdef MPI
<       endif
< #endif
397,399d368
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
410,412d378
< #ifdef MPI
<       endif
< #endif
478,480d443
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
513,515d475
< #ifdef MPI
<       endif
< #endif
550,552d509
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
565,567d521
< #ifdef MPI
<       endif
< #endif
676,678d629
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
706,708d656
< #ifdef MPI
<       endif
< #endif
785,787d732
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
819,821d763
< #ifdef MPI
<       endif
< #endif
843,845d784
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
848,850d786
< #ifdef MPI
<       endif
< #endif
854,856d789
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
861,863d793
< #ifdef MPI
<       endif
< #endif
949,950c879,880
< c        write(iout,*) "TU DOCHODZE"
< c        print *,"JESTEM"
---
>         write(iout,*) "TU DOCHODZE"
>         print *,"JESTEM"
957,959d886
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
984,986d910
< #ifdef MPI
<       endif
< #endif
1005,1007d928
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1017,1019d937
< #ifdef MPI
<       endif
< #endif
1031,1033d948
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1035,1037d949
< #ifdef MPI
<       endif
< #endif
1070,1072d981
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1093,1095d1001
< #ifdef MPI
<       endif
< #endif
1109,1111d1014
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1115,1117d1017
<       endif
< #endif
< #ifdef MPI
1160,1162d1059
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1201,1203d1097
< #ifdef MPI
<       endif
< #endif
1210,1212d1103
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1215,1217d1105
< #ifdef MPI
<       endif
< #endif
1219,1221d1106
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1223,1225d1107
< #ifdef MPI
<       endif
< #endif
1254,1256d1135
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1260,1262d1138
< #ifdef MPI
<       endif
< #endif
1296,1298d1171
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1318,1320d1190
< #ifdef MPI
<       endif
< #endif
1407,1409d1276
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1430,1432d1296
< #ifdef MPI
<       endif
< #endif
1436,1438d1299
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1444,1446d1304
< #ifdef MPI
<       endif
< #endif
1459,1461d1316
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1464,1466d1318
< #ifdef MPI
<       endif
< #endif
1474,1476d1325
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1479,1481d1327
< #ifdef MPI
<       endif
< #endif
1485,1487d1330
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1490,1492d1332
< #ifdef MPI
<       endif
< #endif
1497,1499d1336
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1508,1510d1344
< #ifdef MPI
<       endif
< #endif
1515,1517d1348
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1527,1529d1357
< #ifdef MPI
<       endif
< #endif
1553,1555d1380
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1566,1568d1390
< #ifdef MPI
<       endif
< #endif
1574,1576d1395
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1587,1589d1405
< #ifdef MPI
<       endif
< #endif
1608,1610d1423
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1615,1617d1427
< #ifdef MPI
<       endif
< #endif
1673,1675d1482
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1681,1683d1487
< #ifdef MPI
<       endif
< #endif
1726,1728d1529
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1736,1738d1536
< #ifdef MPI
<       endif
< #endif
1761,1763d1558
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1765,1767d1559
< #ifdef MPI
<       endif
< #endif
1783,1786c1575
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       if (lprint) then
---
> C      if (lprint) then
1793,1796c1582
<       endif
< #ifdef MPI
<       endif
< #endif
---
> C      endif
1847,1850d1632
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
1903,1905d1684
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1933,1935d1711
< #ifdef MPI
<       endif
< #endif
1944,1947d1719
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
1971,1973d1742
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1975,1977d1743
< #ifdef MPI
<       endif
< #endif
1984,1986d1749
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1990,1992d1752
< #ifdef MPI
<       endif
< #endif
1996c1756
< c      write (iout,*) "After CAX"
---
>       write (iout,*) "After CAX"
2005c1765
< c        write (iout,*) "bond ityp1 ityp2",ityp1,ityp2
---
>         write (iout,*) "bond ityp1 ityp2",ityp1,ityp2
2008c1768
< c      write (iout,*) "After XX"
---
>       write (iout,*) "After XX"
2017,2019d1776
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
2021,2023d1777
< #ifdef MPI
<         endif
< #endif
2028c1782
< c      write (iout,*) "After angle"
---
>       write (iout,*) "After angle"
2037c1791
< c        write (iout,*) "dihedral ityp1 ityp2",ityp1,ityp2
---
>         write (iout,*) "dihedral ityp1 ityp2",ityp1,ityp2
2040c1794
< c      write (iout,*) "After dihedral"
---
>       write (iout,*) "After dihedral"
2042,2044d1795
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
2081,2083d1831
< #ifdef MPI
<       endif
< #endif
################# permut.F
################# pinorm.f
################# printmat.f
################# probabl.F
54c54
< c      write (iout,*) me," indstart",indstart(me)," indend",indend(me)
---
>       write (iout,*) me," indstart",indstart(me)," indend",indend(me)
168c168
< c          if (recalc_rms) then
---
>           if (recalc_rms) then
170,171c170
< c            rmstb(iref,i)=rmsnat(i,iref)
<             rmstb(iref,i)=rmsdev
---
>             rmstb(iref,i)=rmsnat(i,iref)
173c172
< c          endif
---
>           endif
197,200c196,199
< c        if (dyn_ss) then
< c          write (iout,*) "nss",nss,
< c     &      " idssb,jdssb",(idssb(k),jdssb(k),k=1,nss)
< c        endif
---
>         if (dyn_ss) then
>           write (iout,*) "nss",nss,
>      &      " idssb,jdssb",(idssb(k),jdssb(k),k=1,nss)
>         endif
367d365
<       if (Me.eq.Master) then
372d369
<       endif
################# promienie.F
################# quaternion_derivatives.f
################# quatrot.F
################# read_constr_homology.F
################# read_coords.F
86d85
<         call CM_shift(icon)
170c169
< c          write (iout,*) "xdrfopen: iret",iret
---
>           write (iout,*) "xdrfopen: iret",iret
207c206
< c            write (iout,*) "xdrfopen: iret",iret
---
>             write (iout,*) "xdrfopen: iret",iret
450d448
<             call inbox
503,505c501
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
---
> 
507,509c503
< #ifdef MPI
<       endif
< #endif
---
> 
919c913
< c        call flush(iout)
---
>         call flush(iout)
921,922d914
<         call chain_clusters(ij)
<         call CM_shift(ij)
################# readpdb.F
################# readpdb-mult.F
################# read_ref_str.F
################# readrtns.F
7,10d6
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
26,27d21
<       include 'COMMON.GAUSSWIDTH'
<       include 'COMMON.GEO'
28a23,25
> #ifdef MPL
>       include 'COMMON.INFO'
> #endif
29a27
>       double precision pi
48,50d45
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
52,54d46
< #ifdef MPI
<       endif
< #endif
59,61d50
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
64,66d52
< #ifdef MPI
<       endif
< #endif
74,76d59
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
79,81d61
< #ifdef MPI
<       endif
< #endif
88,90d67
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
93,95d69
< #ifdef MPI
<       endif
< #endif
98,100d71
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
108,110d78
< #ifdef MPI
<       endif
< #endif
113,115d80
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
117,119d81
< #ifdef MPI
<       endif
< #endif
130a93
>       pi=3.141592d0
138,140d100
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
142,144d101
< #ifdef MPI
<       endif
< #endif
161,163d117
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
165,167d118
< #ifdef MPI
<       endif
< #endif
172,174d122
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
177,179d124
< #ifdef MPI
<       endif
< #endif
181,183d125
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
185,187d126
< #ifdef MPI
<       endif
< #endif
188a128
>       avecont = index(controlcard,"AVECONT").gt.0
201,203d140
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
205,227d141
< #ifdef MPI
<       endif
< #endif
<       call readi(controlcard,'IALG',ialg,0)
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       write (iout,*) "IALG",ialg
< #ifdef MPI
<       endif
< #endif
<       call reada(controlcard,'SIGMA2',sigma2,8.0d0)
<       call readi(controlcard,'NQ',nq,2)
<       deltaq=1.0d0/nq
<       coeff_sig=dsqrt(dwapi*sigma2)/2
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       write (iout,*) "NQ",NQ," DELTAQ",deltaq
<       write (iout,*) "SIGMA2",sigma2," coeff_sig",coeff_sig
< #ifdef MPI
<       endif
< #endif
232,234d145
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
236,238d146
< #ifdef MPI
<       endif
< #endif
245,247d152
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
249,251d153
< #ifdef MPI
<       endif
< #endif
253,255d154
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
258,260d156
< #ifdef MPI
<       endif
< #endif
264,266d159
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
268,270d160
< #ifdef MPI
<       endif
< #endif
276,278d165
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
281,283d167
< #ifdef MPI
<       endif
< #endif
287,289d170
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
291,293d171
< #ifdef MPI
<       endif
< #endif
304,306d181
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
313,315d187
< #ifdef MPI
<       endif
< #endif
319,321d190
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
324,326d192
< #ifdef MPI
<       endif
< #endif
337,340d202
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
392a255
>       call reada(weightcard,'WSS',wss,1.0D0)
436a300
> #ifdef SCAL_SS
439,444c303,312
<         akcm=akcm*wstrain/wsc
<         akth=akth*wstrain/wsc
<         akct=akct*wstrain/wsc
<         v1ss=v1ss*wstrain/wsc
<         v2ss=v2ss*wstrain/wsc
<         v3ss=v3ss*wstrain/wsc
---
>         akcm=akcm*whpb/wsc
>         akth=akth*whpb/wsc
>         akct=akct*whpb/wsc
>         v1ss=v1ss*whpb/wsc
>         v2ss=v2ss*whpb/wsc
>         v3ss=v3ss*whpb/wsc
> #else
>         ss_depth=ebr-0.25*eps(1,1)
>         Ht=Ht-0.25*eps(1,1)
> #endif
446,449c314,317
<         ss_depth=ebr/wstrain-0.25*eps(1,1)*wsc/wstrain
<       endif
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
---
> #ifdef SCAL_SS
>         ss_depth=ebr/whpb-0.25*eps(1,1)*wsc/whpb
> #else
>         ss_depth=ebr-0.25*eps(1,1)
450a319
>       endif
462,464d330
< #ifdef MPI
<       endif
< #endif
492,494c358
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
---
>       weights(32)=wss
497,500c361
<      &  wturn4,wturn6,wsccor
< #ifdef MPI
<       endif
< #endif
---
>      &  wturn4,wturn6,wsccor,wss
519c380,381
<      & 'WSCCOR= ',f10.6,' (SC-backbone torsinal correalations)')
---
>      & 'WSCCOR= ',f10.6,' (SC-backbone torsinal correalations)'/
>      & 'WSS=    ',f10.6,' (disulfide bridges)')
522,524d383
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
538,540d396
< #ifdef MPI
<       endif
< #endif
549,551d404
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
558,560d410
< #ifdef MPI
<       endif
< #endif
595,597d444
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
602,604d448
< #ifdef MPI
<       endif
< #endif
614,616d457
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
622,624d462
< #ifdef MPI
<       endif
< #endif
626,635c464
<      &    chain_length,npermchain,tabpermchain,nchain_group,nequiv,
<      &  iequiv,mapchain)
< 
<       if (ialg.eq.0) then
< 
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       write (iout,'(2a)') "All permutations of equivalent chains",
<      & " will be searched for best superposition."
---
>      &    chain_length,npermchain,tabpermchain)
644,681d472
< #ifdef MPI
<       endif
< #endif
< 
<       else if (ialg.eq.1) then
< 
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       write (iout,'(2a)') "Optimal chain matching will be determined",
<      &  " by orientation scanning (Algorithm 1)."
< #ifdef MPI
<       endif
< #endif
< 
<       else if (ialg.eq.2) then
< 
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       write (iout,'(2a)') "Superposition by Gaussian distance ",
<      &  "minimization (Algorithm 2)."
< #ifdef MPI
<       endif
< #endif
< 
<       else
< 
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       write (iout,*) "Error: Illegal superposition algorithm."
< #ifdef MPI
<       endif
< #endif
<       stop "Illegal superposition algorithm."
< 
<       endif
686,688d476
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
690,692d477
< #ifdef MPI
<       endif
< #endif
709,716d493
<       call suplen
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
<       write (iout,*) "len_sup",len_sup
< #ifdef MPI
<       endif
< #endif
728,730d504
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
737,739d510
< #ifdef MPI
<         endif
< #endif
752,754d522
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
762,764d529
< #ifdef MPI
<         endif
< #endif
785,787d549
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
799,801d560
< #ifdef MPI
<       endif
< #endif
820,822d578
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
830,832d585
< #ifdef MPI
<       endif
< #endif
862,864d614
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
875,877d624
< #ifdef MPI
<       endif
< #endif
885,887d631
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
889,891d632
< #ifdef MPI
<       endif
< #endif
909,911d649
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
913,915d650
< #ifdef MPI
<       endif
< #endif
969,971d703
< #ifdef MPI
<           if (me.eq.Master .or. .not.out1file) then
< #endif
973,975d704
< #ifdef MPI
<           endif
< #endif
977,979d705
< #ifdef MPI
<           if (me.eq.Master .or. .not.out1file) then
< #endif
981,983d706
< #ifdef MPI
<           endif
< #endif
989,991d711
< #ifdef MPI
<             if (me.eq.Master .or. .not.out1file) then
< #endif
995,997d714
< #ifdef MPI
<             endif
< #endif
999,1001d715
< #ifdef MPI
<           if (me.eq.Master .or. .not.out1file) then
< #endif
1003,1005d716
< #ifdef MPI
<           endif
< #endif
1050,1053d760
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
1065a773,775
> #ifdef MPL
>       include 'COMMON.INFO'
> #endif
1079,1081d788
< #ifdef MPI
<           if (me.eq.Master .or. .not.out1file) then
< #endif
1086,1088d792
< #ifdef MPI
<           endif
< #endif
1111,1113d814
< #ifdef MPI
<               if (me.eq.Master .or. .not.out1file) then
< #endif
1116,1118d816
< #ifdef MPI
<               endif
< #endif
1120a819,821
> #ifdef MPL
> 	      call mp_stopall(error_msg)
> #else
1121a823
> #endif
1297d998
<       include "COMMON.MPI"
1298a1000
>       include "COMMON.MPI"
1304d1005
<       character*3 cout1file
1308d1008
<       call getenv('OUT1FILE',cout1file)
1315d1014
<       out1file=index(ucase(cout1file),'YES').gt.0
1342,1344d1040
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1349,1351d1044
< #ifdef MPI
<       endif
< #endif
1421,1424d1113
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
1477,1479d1165
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1481,1483d1166
< #ifdef MPI
<       endif
< #endif
1492,1494d1174
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
1500,1502d1179
< #ifdef MPI
<         endif
< #endif
1505,1507d1181
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
1509,1511d1182
< #ifdef MPI
<         endif
< #endif
1522,1524d1192
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1535,1537d1202
< #ifdef MPI
<       endif
< #endif
1539,1541d1203
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1545,1547d1206
< #ifdef MPI
<       endif
< #endif
1583,1585d1241
< #ifdef MPI
<             if (me.eq.Master .or. .not.out1file) then
< #endif
1588,1590d1243
< #ifdef MPI
<              endif
< #endif
1630,1632d1282
< #ifdef MPI
<             if (me.eq.Master .or. .not.out1file) then
< #endif
1635,1637d1284
< #ifdef MPI
<             endif
< #endif
1642,1644d1288
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
1647,1649d1290
< #ifdef MPI
<       endif
< #endif
1726,1728d1366
< #ifdef MPI
<           if (me.eq.Master .or. .not.out1file) then
< #endif
1737,1739d1374
< #ifdef MPI
<           endif
< #endif
1770,1772d1404
< #ifdef MPI
<           if (me.eq.Master .or. .not.out1file) then
< #endif
1776,1778d1407
< #ifdef MPI
<           endif
< #endif
1833,1835d1461
< #ifdef MPI
<           if (me.eq.Master .or. .not.out1file) then
< #endif
1840,1842d1465
< #ifdef MPI
<           endif
< #endif
1846c1469
< c          write (iout,*) controlcard(:ilen(controlcard))
---
>           write (iout,*) controlcard(:ilen(controlcard))
1855,1857d1477
< #ifdef MPI
<           if (me.eq.Master .or. .not.out1file) then
< #endif
1868,1870d1487
< #ifdef MPI
<           endif
< #endif
1893,1895d1509
< #ifdef MPI
<           if (me.eq.Master .or. .not.out1file) then
< #endif
1898,1900d1511
< #ifdef MPI
<           endif
< #endif
1909,1911d1519
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
1916,1918d1523
< #ifdef MPI
<         endif
< #endif
1945,1947d1549
< #ifdef MPI
<             if (me.eq.Master .or. .not.out1file) then
< #endif
1952,1954d1553
< #ifdef MPI
<              endif
< #endif
1983,1985d1581
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
1991,1993d1586
< #ifdef MPI
<         endif
< #endif
2000,2002d1592
< #ifdef MPI
<             if (me.eq.Master .or. .not.out1file) then
< #endif
2007,2009d1596
< #ifdef MPI
<             endif
< #endif
2011,2013d1597
< #ifdef MPI
<             if (me.eq.Master .or. .not.out1file) then
< #endif
2017,2019d1600
< #ifdef MPI
<             endif
< #endif
2027,2029d1607
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
2035,2037d1612
< #ifdef MPI
<         endif
< #endif
2046,2048d1620
< #ifdef MPI
<             if (me.eq.Master .or. .not.out1file) then
< #endif
2054,2056d1625
< #ifdef MPI
<             endif
< #endif
2061,2063d1629
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
2068,2070d1633
< #ifdef MPI
<         endif
< #endif
2079,2082d1641
< #ifdef MPI
<       include "mpif.h"
<       include "COMMON.MPI"
< #endif
2084d1642
<       include 'COMMON.CONTROL'
2095,2097d1652
< #ifdef MPI
<         if (me.eq.Master .or. .not.out1file) then
< #endif
2100,2102d1654
< #ifdef MPI
<         endif
< #endif
2132d1683
<       include 'COMMON.MPI'
2141c1692
< c      write (iout,*) "Calling read_saxs nsaxs",nsaxs
---
>       write (iout,*) "Calling read_saxs nsaxs",nsaxs
2156,2158d1706
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
2163,2165d1710
< #ifdef MPI
<       endif
< #endif
2170,2172d1714
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
2174,2176d1715
< #ifdef MPI
<       endif
< #endif
2198,2200d1736
< #ifdef MPI
<       if (me.eq.Master .or. .not.out1file) then
< #endif
2205,2207d1740
< #ifdef MPI
<       endif
< #endif
################# refsys.f
################# rescode.f
################# rmdd.f
################# rmscalc1.F
################# rmscalc_alg1.F
################# rmscalc_alg2.F
################# rmscalc.F
################# rmsnat.f
12,13d11
<       integer listmin(maxchain)
<       common /permutacja/ listmin
15,26c13
<       if (ialg.eq.0) then
<         rmsnat=rmscalc(c(1,1),cref_pdb(1,1,iref),przes,obrot,ipermmin)
<         listmin(:nchain)=tabpermchain(:nchain,ipermmin)
<       else if (ialg.eq.1) then
<         rmsnat=rmscalc_alg1(c(1,1),cref_pdb(1,1,iref),przes,obrot)
<       else if (ialg.eq.2) then
<         rmsnat=rmscalc_alg2(c(1,1),cref_pdb(1,1,iref),przes,obrot)
<       else
<         write (iout,*) "RMSNAT: illegal superposition algorithm",
<      &   ialg
<         stop "RMSNAT: illegal superposition algorithm"
<       endif
---
>       rmsnat=rmscalc(c(1,1),cref_pdb(1,1,iref),przes,obrot,ipermmin)
################# seq2chains.f
################# setup_var.f
################# src.f
################# srtclust.f
124d123
<         sumprob=0.0d0
################# ssMD.F
936a937,1074
> c--------------------------------------------------------------------------
>       subroutine ess_dyn(ess)
> C
> C This subroutine calculates the dynamic SSbond energy.
> C
>       implicit real*8 (a-h,o-z)
>       include 'DIMENSIONS'
>       include "DIMENSIONS.COMPAR"
>       include 'COMMON.CONTROL'
>       include 'COMMON.GEO'
>       include 'COMMON.VAR'
>       include 'COMMON.LOCAL'
>       include 'COMMON.CHAIN'
>       include 'COMMON.DERIV'
>       include 'COMMON.NAMES'
>       include 'COMMON.INTERACT'
>       include 'COMMON.IOUNITS'
>       include 'COMMON.CALC'
>       include 'COMMON.SBRIDGE'
>       common /srutu/icall
>       integer icant,xshift,yshift,zshift
>       external icant
> c     print *,'Entering ESS_DYN nnt=',nnt,' nct=',nct
>       ess=0.0d0
>       ind=0
>       do i=iatsc_s,iatsc_e
>         itypi=iabs(itype(i))
>         if (itypi.eq.ntyp1) cycle
>         itypi1=iabs(itype(i+1))
>         xi=c(1,nres+i)
>         yi=c(2,nres+i)
>         zi=c(3,nres+i)
> C returning the ith atom to box
>         call to_box(xi,yi,zi)
>         call lipid_layer(xi,yi,zi,sslipi,ssgradlipi)
>         dxi=dc_norm(1,nres+i)
>         dyi=dc_norm(2,nres+i)
>         dzi=dc_norm(3,nres+i)
>         dsci_inv=vbld_inv(i+nres)
> C
> C Calculate SC interaction energy.
> C
>         do iint=1,nint_gr(i)
>           do j=istart(i,iint),iend(i,iint)
>             IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
>               call dyn_ssbond_ene(i,j,evdwij)
>               ess=ess+evdwij
>               if (energy_dec) write (iout,'(6hSSbond,2i5,f10.5,$)')
>      &          i,j,evdwij
> C            write (iout,'(a6,2i5,0pf7.3,a3,2f10.3)')
> C     &                        'evdw',i,j,evdwij,' ss',evdw,evdw_t
> C triple bond artifac removal
>              do k=j+1,iend(i,iint)
> C search over all next residues
>               if (dyn_ss_mask(k)) then
> C check if they are cysteins
> C              write(iout,*) 'k=',k
>               call triple_ssbond_ene(i,j,k,evdwij)
>               if (energy_dec) write (iout,'(i5,f10.5,$)') k,evdwij
> C call the energy function that removes the artifical triple disulfide
> C bond the soubroutine is located in ssMD.F
>               ess=ess+evdwij
> C             write (iout,'(a6,2i5,0pf7.3,a3,2f10.3)')
> C     &                        'evdw',i,j,evdwij,'tss',evdw,evdw_t
>               endif!dyn_ss_mask(k)
>              enddo! k
>              if (energy_dec) write (iout,'()')
>             ENDIF
>           enddo
>         enddo
>       enddo
>       return
>       end
> c------------------------------------------------------------------------------
>       subroutine ess_fixed(ess)
> C 
> C Evaluate bridge-strain energy and its gradient in virtual-bond and SC vectors.
> C
> c      implicit real*8 (a-h,o-z)
>       implicit none
> #ifdef MPI
>       include 'mpif.h'
> #endif
>       include 'DIMENSIONS'
> c      include 'COMMON.SETUP'
>       include 'COMMON.SBRIDGE'
>       include 'COMMON.CHAIN'
>       include 'COMMON.DERIV'
>       include 'COMMON.VAR'
>       include 'COMMON.INTERACT'
>       include 'COMMON.IOUNITS'
>       include 'COMMON.CONTROL'
> c      include 'COMMON.TIME1'
>       double precision ess
>       integer i,j,k,l,ii,iii,jj,jjj,iti,itj
>       double precision eij
> c      double precision time00,time01
>       do i=link_start,link_end
>         if (i.gt.nss) cycle
> 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.
>         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
> C 15/02/13 CC dynamic SSbond - additional check
> c          write (2,*) "i",iii,iabs(itype(iii))," j",jjj,
> c     &      iabs(itype(jjj))
>         if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
>      &      iabs(itype(jjj)).eq.1) then
>          call ssbond_ene(iii,jjj,eij)
> c           ehpb=ehpb+2*eij
>          ess=ess+eij
>          if (energy_dec) write (iout,*) "static SSbond:",iii,jjj,eij
> cd          write (iout,*) "eij",eij
> cd   &   ' waga=',waga,' fac=',fac
> !        else if (ii.gt.nres .and. jj.gt.nres) then
>         endif
>       enddo
>       return
>       end
################# stopx.F
################# sumsld.f
################# suplen.f
################# timer.f
################# timing.F
16a17,76
>       logical function stopx(nf)
> C
> C     ..................................................................
> C
> C     *****PURPOSE...
> C     THIS FUNCTION MAY SERVE AS THE STOPX (ASYNCHRONOUS INTERRUPTION)
> C     FUNCTION FOR THE NL2SOL (NONLINEAR LEAST-SQUARES) PACKAGE AT
> C     THOSE INSTALLATIONS WHICH DO NOT WISH TO IMPLEMENT A
> C     DYNAMIC STOPX.
> C
> C     *****ALGORITHM NOTES...
> C     AT INSTALLATIONS WHERE THE NL2SOL SYSTEM IS USED
> C     INTERACTIVELY, THIS DUMMY STOPX SHOULD BE REPLACED BY A
> C     FUNCTION THAT RETURNS .TRUE. IF AND ONLY IF THE INTERRUPT
> C     (BREAK) KEY HAS BEEN PRESSED SINCE THE LAST CALL ON STOPX.
> C
> C     $$$ MODIFIED FOR USE AS  THE TIMER ROUTINE.
> C     $$$                              WHEN THE TIME LIMIT HAS BEEN
> C     $$$ REACHED     STOPX IS SET TO .TRUE  AND INITIATES (IN ITSUM)
> C     $$$ AND ORDERLY EXIT OUT OF SUMSL.  IF ARRAYS IV AND V ARE
> C     $$$ SAVED, THE SUMSL ROUTINES CAN BE RESTARTED AT THE SAME
> C     $$$ POINT AT WHICH THEY WERE INTERRUPTED.
> C
> C     ..................................................................
> C
>       include 'DIMENSIONS'
>       integer nf
>       logical ovrtim
>       include 'COMMON.IOUNITS'
>       include 'COMMON.TIME1'
> #ifdef MPL
>       include 'COMMON.INFO'
>       integer Kwita
> 
> cd    print *,'Processor',MyID,' NF=',nf
> #endif
>       if (ovrtim()) then
> C Finish if time is up.
>          stopx = .true.
> #ifdef MPL
>       else if (mod(nf,100).eq.0) then
> C Other processors might have finished. Check this every 100th function 
> C evaluation.
> cd       print *,'Processor ',MyID,' is checking STOP: nf=',nf
>          call recv_stop_sig(Kwita)
>          if (Kwita.eq.-1) then
>            write (iout,'(a,i4,a,i5)') 'Processor',
>      &     MyID,' has received STOP signal in STOPX; NF=',nf
>            write (*,'(a,i4,a,i5)') 'Processor',
>      &     MyID,' has received STOP signal in STOPX; NF=',nf
>            stopx=.true.
>          else
>            stopx=.false.
>          endif
> #endif
>       else
>          stopx = .false.
>       endif
>       return
>       end
34,40d93
< #ifdef MPI
<       include 'DIMENSIONS'
<       include 'sizesclu.dat'
<       include "mpif.h"
<       integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE)
<       include "COMMON.MPI"
< #endif
42,44d94
< #ifdef MPI
<       tcpu=MPI_Wtime()-stime    
< #else
101,102c151,155
<       real etime
<       call cpu_time(etime)
---
>       real timar(2), etime
>       seconds = etime(timar)
> Cd    print *,'seconds=',seconds,' stime=',stime
> C      usrsec = timar(1)
> C      syssec = timar(2)
105d157
< #endif
################# TMscore.F
65,66d64
<       integer listmin(maxchain)
<       common /permutacja/ listmin
73d70
<       double precision rmsnat
236,239c233,234
< c      DO II=1,NPERMCHAIN
< c Determine the best permutation
<       rmsd=rmsnat(jcon,iref)
< c
---
>       DO II=1,NPERMCHAIN
> 
309,311c304,306
<           xa(nnsup)=c(1,listmin(i))
<           ya(nnsup)=c(2,listmin(i))
<           za(nnsup)=c(3,listmin(i))
---
>           xa(nnsup)=c(1,iperm(i,ii))
>           ya(nnsup)=c(2,iperm(i,ii))
>           za(nnsup)=c(3,iperm(i,ii))
439c434
< c      rmsd=rmsd_ali
---
>       rmsd=rmsd_ali
441,447c436,442
< c      if (ii.eq.1 .or. rmsd.lt.rmsd_min) then
< c        rmsd_min=rmsd
< c        tmscore_min=tmscore
< c        gdt_ts_min=gdt_ts
< c        gdt_ha_min=gdt_ha
< c        ipermmin=ii
< c      endif
---
>       if (ii.eq.1 .or. rmsd.lt.rmsd_min) then
>         rmsd_min=rmsd
>         tmscore_min=tmscore
>         gdt_ts_min=gdt_ts
>         gdt_ha_min=gdt_ha
>         ipermmin=ii
>       endif
449c444
< c      ENDDO
---
>       ENDDO
451,454c446,449
< c      rmsd=rmsd_min
< c      tmscore=tmscore_min
< c      gdt_ts=gdt_ts_min
< c      gdt_ha=gdt_ha_min
---
>       rmsd=rmsd_min
>       tmscore=tmscore_min
>       gdt_ts=gdt_ts_min
>       gdt_ha=gdt_ha_min
################# track.F
################# work_partition.F
11d10
<       include "COMMON.CONTROL"
23d21
<         if (me.eq.Master .or. .not.out1file) then
25d22
<         endif
72d68
<           if (me.eq.Master .or. .not.out1file) then
76d71
<           endif
80c75
<       if (lprint .and. (me.eq.Master.or..not.out1file)) then
---
>       if (lprint) then
################# wrtclust.F
34d33
<       double precision emin1,emin
246a246,256
> c Write conformations of the family i to PDB files
>           ncon_out=1
>           do while (ncon_out.lt.printpdb(icut) .and.
>      &     ncon_out.lt.licz(i).and.
>      &     totfree(nconf(i,ncon_out+1))-EMIN1.LE.ECUT)
>             ncon_out=ncon_out+1
> c            write (iout,*) i,ncon_out,nconf(i,ncon_out),
> c     &        totfree(nconf(i,ncon_out)),emin1,ecut
>           enddo
> c          write (iout,*) "ncon_out",ncon_out
> c          call flush(iout)
251c261,288
<           call family_out(ncon,i,icut,printpdb,ib)
---
>           do j=1,ncon_out
>             icon=nconf(i,j)
>             do ii=1,2*nres
>               do k=1,3
>                 c(k,ii)=allcart(k,ii,icon)
>               enddo
>             enddo
>             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
>             call center
>             call inbox
>             call pdbout(totfree(icon)/beta_h(ib),rmstb(1,icon),titel)
>             write (ipdb,'("TER")')
>           enddo
258,259c295
<           call ave_coord(ncon,i)
<           cref(:,:2*nres)=c(:,:2*nres)
---
>           call ave_coord(i)
580c616
<       subroutine ave_coord(ncon,igr)
---
>       subroutine ave_coord(igr)
586,588d621
< #ifndef RESUP
<       include 'COMMON.SUPCLUST'
< #endif
598c631
<       double precision rmscalc,rmscalc_alg1,rmscalc_alg2
---
>       double precision rmscalc
600,617c633,638
<       integer i,ii,j,k,icon,jcon,igr,ipermmin,ichain,kk1,kk2,li
<       double precision rms,boltz,qpart,cwork(3,maxres2),
<      &  cref1(3,maxres2),caux(3,maxres2)
<       double precision rmscheck
<       double precision rmsd_dist,rmsd_fitsq
<       common /RMSD/ rmsd_dist,rmsd_fitsq
<       integer listmin(maxchain)
<       common /permutacja/ listmin
<       integer ind,ioffset
<       integer ncon
<       przes=0.0d0
< #ifdef DEBUG
<       write (iout,*) "AVE_COORD: igr",igr
< #endif
<       icon=nconf(igr,1)
< c      write (iout,*) "icon",icon
<       eref=totfree(icon)
<       boltz = dexp(-totfree(icon)+eref)
---
>       integer i,ii,j,k,icon,jcon,igr,ipermmin
>       double precision rms,boltz,qpart,cwork(3,maxres2),cref1(3,maxres2)
> c      write (iout,*) "AVE_COORD: igr",igr
>       jcon=nconf(igr,1)
>       eref=totfree(jcon)
>       boltz = dexp(-totfree(jcon)+eref)
621,623c642,644
<           caux(j,i)=allcart(j,i,icon)*boltz
<           cref1(j,i)=allcart(j,i,icon)
<           csq(j,i)=allcart(j,i,icon)**2*boltz
---
>           c(j,i)=allcart(j,i,jcon)*boltz
>           cref1(j,i)=allcart(j,i,jcon)
>           csq(j,i)=allcart(j,i,jcon)**2*boltz
634,661c655,660
< #ifdef DEBUG
<         write (iout,*) "cref1 and cwork"
<         do i=1,nres
<           if (itype(i).eq.ntyp1) cycle
<           write (iout,'(i5,3f10.5,5x,3f10.5)') i,cref1(:,i),cwork(:,i)
<         enddo 
< #endif
< #ifdef RESUP
<         if (ialg.eq.0) then
<           rms=rmscalc(cwork(1,1),cref1(1,1),przes,obrot,ipermmin)
<           listmin(:nchain)=tabpermchain(:nchain,ipermmin)
<         else if (ialg.eq.1) then
<           rms=rmscalc_alg1(cwork(1,1),cref1(1,1),przes,obrot)
<         else if (ialg.eq.2) then
<           rms=rmscalc_alg2(cwork(1,1),cref1(1,1),przes,obrot)
<         else
<           write (iout,*) "AVE_COORD: illegal superposition algorithm",
<      &     ialg
<           stop "AVE_COORD: illegal superposition algorithm"
<         endif 
< #ifdef DEBUG
<         write (iout,*) "Superpose:",icon,jcon
<         write (iout,*) "k",k," rms",rms," ipermmin",ipermmin
<         write (iout,*) "listmin",listmin(:nchain)
<         do i=1,3
<           write (iout,'(i3,f10.5,5x,3f10.5)')i,przes(i),
<      &      (obrot(i,j),j=1,3)
<         enddo
---
>         rms=rmscalc(cwork(1,1),cref1(1,1),przes,obrot,ipermmin)
> c        write (iout,*) "rms",rms," ipermmin",ipermmin
> c        do i=1,3
> c          write (iout,'(i3,f10.5,5x,3f10.5)')i,przes(i),
> c     &      (obrot(i,j),j=1,3)
> c        enddo
666,693d664
< #endif
< #else
<         if (icon.gt.jcon) then
<           ind=IOFFSET(NCON,jcon,icon)
<           listmin(:nchain)=listmin_all(:nchain,ind)
<           obrot(:,:)=obrot_all(:,:,ind)
<         else
<           ind=IOFFSET(NCON,icon,jcon) 
<           do i=1,nchain
<             listmin(listmin_all(i,ind))=i
<           enddo
<           do i=1,3
<             do j=1,3
<               obrot(i,j)=obrot_all(j,i,ind)
<             enddo
<           enddo
<         endif
<         rms=diss(ind)
< #ifdef DEBUG
<         write (iout,*) "Restore info:",icon,jcon
<         write (iout,*) "k",k," rms",rms," ipermmin",ipermmin
<         write (iout,*) "listmin",listmin(:nchain)
<         do i=1,3
<           write (iout,'(i3,f10.5,5x,3f10.5)')i,przes(i),
<      &      (obrot(i,j),j=1,3)
<         enddo
< #endif
< #endif
696,709c667,669
< c        write (iout,*) "listmin",listmin(:nchain)
< c        call flush(iout)
<         do ichain=1,nchain
<           li=listmin(ichain)
<           do i=1,chain_length(ichain)
< c            write (iout,*) "ichain",ichain," i",i," li",li
<             kk1=chain_border(1,ichain)+i-1
<             kk2=chain_border(1,li)+i-1
<             xx(:,kk1)=allcart(:,kk2,jcon)
<             xx(:,kk1+nres)=allcart(:,kk2+nres,jcon)
< #ifdef DEBUG
<             write (iout,'(2(i5,3f10.5,5x))') kk1,(xx(j,kk1),j=1,3),
<      &        kk2,(xx(j,kk1+nres),j=1,3)
< #endif
---
>         do i=1,2*nres
>           do j=1,3
>             xx(j,i)=allcart(j,i,jcon)
714,717c674,675
< #ifdef DEBUG
<           write (iout,'(i5,2(3f10.5,5x))') i,(cwork(j,i),j=1,3),
<      &    (xx(j,i),j=1,3)
< #endif
---
> c          write (iout,'(i5,2(3f10.5,5x))') i,(cwork(j,i),j=1,3),
> c     &    (allcart(j,i,jcon),j=1,3)
720c678
<             caux(j,i)=caux(j,i)+cwork(j,i)*boltz
---
>             c(j,i)=c(j,i)+cwork(j,i)*boltz
725d682
< #ifdef RMS_CHECK
727,739c684,690
<         rmscheck=0.0d0
<         ii=0
<         do ichain=1,nchain
<           do i=1,chain_length(ichain)
<           ii=ii+1
<           kk1=chain_border(1,ichain)+i-1
<           do j=1,3
<             rmscheck=rmscheck+(cwork(j,kk1)-cref1(j,kk1))**2
<           enddo  
<           enddo
<         enddo
<         write (iout,*) "rmscheck",dsqrt(rmscheck/ii),rms
< #endif
---
> c        rmscheck=0.0d0
> c        do i=nnt,nct
> c          do j=1,3
> c            rmscheck=rmscheck+(cwork(j,i)-cref1(j,i))**2
> c          enddo  
> c        enddo
> c        write (iout,*) "rmscheck",dsqrt(rmscheck/(nct-nnt+1)),rms
743c694
<           c(j,i)=caux(j,i)/qpart
---
>           c(j,i)=c(j,i)/qpart
746d696
< #ifdef DEBUG
748,751d697
<         if (itype(i).ne.ntyp1) 
<      &   write (iout,'(i5,3f10.5,5x,3f10.5)') i,(c(j,i),j=1,3),
<      &    (cref1(j,i),j=1,3)
< #endif
753,767d698
< #ifdef RMS_CHECK
< c rms check of the average str
<         rmscheck=0.0d0
<         ii=0
<         do ichain=1,nchain
<           do i=1,chain_length(ichain)
<           ii=ii+1
<           kk1=chain_border(1,ichain)+i-1
<           do j=1,3
<             rmscheck=rmscheck+(c(j,kk1)-cref1(j,kk1))**2
<           enddo  
<           enddo
<         enddo
<         write (iout,*) "rmscheck ave",dsqrt(rmscheck/ii)
< #endif
801,806d731
<       double precision rmscalc,rmscalc_alg1,rmscalc_alg2
<       integer ipermmin,li,kk1,kk2,ichain
<       integer listmin(maxchain)
<       common /permutacja/ listmin
<       integer listmin_min(maxchain)
<       przes=0.0d0
835a761,763
>       write (iout,'(/a,i5,a,i5,a,f10.5)') 
>      &  "Family",igr," fittest conformation",list_conf(jconmin),
>      &  " penalty",rmsmin
838,875c766
<           xx(j,i)=c(j,i)
<           yy(j,i)=allcart(j,i,jconmin)
<         enddo
<       enddo
<       if (ialg.eq.0) then
<         rms=rmscalc(yy(1,1),xx(1,1),przes,obrot,ipermmin)
<         listmin(:nchain)=tabpermchain(:nchain,ipermmin)
<       else if (ialg.eq.1) then
<         rms=rmscalc_alg1(yy(1,1),xx(1,1),przes,obrot)
<       else if (ialg.eq.2) then
<         rms=rmscalc_alg2(yy(1,1),xx(1,1),przes,obrot)
<       else
<         write(iout,*)"CLOSEST_COORD: illegal superposition algorithm",
<      &   ialg
<         stop "CLOSEST_COORD: illegal superposition algorithm"
<       endif 
<       do ichain=1,nchain
<         li=listmin(ichain)
<         do i=1,chain_length(ichain)
< c          write (iout,*) "ichain",ichain," i",i," li",li
<           kk1=chain_border(1,ichain)+i-1
<           kk2=chain_border(1,li)+i-1
<           xx(:,kk1)=allcart(:,kk2,jcon)
<           xx(:,kk1+nres)=allcart(:,kk2+nres,jcon)
< #ifdef DEBUG
<           write (iout,'(2(i5,3f10.5,5x))') kk1,(xx(j,kk1),j=1,3),
<      &      kk2,(xx(j,kk1+nres),j=1,3)
< #endif
<         enddo
<       enddo
<       call matvec(cwork,obrot,xx,2*nres)
<       do i=1,2*nres
< #ifdef DEBUG
<         write (iout,'(i5,2(3f10.5,5x))') i,(cwork(j,i),j=1,3),
<      &    (xx(j,i),j=1,3)
< #endif
<         do j=1,3
<           c(j,i)=cwork(j,i)+przes(j)
---
>           c(j,i)=allcart(j,i,jconmin)
878,880d768
<       write (iout,'(/a,i5,a,i5,a,f10.5)') 
<      &  "Family",igr," fittest conformation",list_conf(jconmin),
<      &  " penalty",rmsmin
903,905d790
< #ifndef RESUP
<       include 'COMMON.SUPCLUST'
< #endif
910,912c795,797
<       double precision przes(3),obrot(3,3),przes_min(3),obrot_min(3,3)
<       integer i,ii,j,k,icon,jcon,jconmin,igr,ipermmin,ichain,li,kk1,kk2
<       double precision rms,rmsmin,rmscheck,cwork(3,maxres2)
---
>       double precision przes(3),obrot(3,3)
>       integer i,ii,j,k,icon,jcon,jconmin,igr,ipermmin
>       double precision rms,rmsmin,cwork(3,maxres2)
914,939c799
<       double precision rmscalc,rmscalc_alg1,rmscalc_alg2
<       integer listmin(maxchain)
<       common /permutacja/ listmin
<       integer listmin_min(maxchain)
< #ifdef RESUP
<       if (licz(igr).eq.1) then
< #endif
<         jconmin=nconf(igr,1)
<         c(:,:2*nres)=allcart(:,:2*nres,jconmin)
<         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
<         return
< #ifdef RESUP
<       endif
< 
<       przes=0.0d0
---
>       double precision rmscalc
942,944c802
< #ifdef DEBUG
<       write (iout,*) "CLOSEST_COORD: Average coords RESUP",jconmin
< #endif
---
> c      write (iout,*) "CLOSEST_COORD: Average coords"
946,951d803
< c      write (iout,*) "cref and c"
<       do i=1,2*nres
<         do j=1,3
<           xx(j,i)=cref(j,i)
<         enddo
<       enddo
956c808
< c            xx(j,i)=cref(j,i)
---
>             xx(j,i)=c(j,i)
959d810
< c          write (iout,'(i5,3f10.5,5x,3f10.5)') i,xx(:,i),yy(:,i)
961,972c812
<         if (ialg.eq.0) then
<           rms=rmscalc(yy(1,1),xx(1,1),przes,obrot,ipermmin)
<           listmin(:nchain)=tabpermchain(:nchain,ipermmin)
<         else if (ialg.eq.1) then
<           rms=rmscalc_alg1(yy(1,1),xx(1,1),przes,obrot)
<         else if (ialg.eq.2) then
<           rms=rmscalc_alg2(yy(1,1),xx(1,1),przes,obrot)
<         else
<           write(iout,*)"CLOSEST_COORD: illegal superposition algorithm",
<      &     ialg
<           stop "CLOSEST_COORD: illegal superposition algorithm"
<         endif 
---
>         rms=rmscalc(xx(1,1),yy(1,1),przes,obrot,ipermmin)
977,979d816
<           przes_min=przes
<           obrot_min=obrot
<           listmin_min(:nchain)=listmin(:nchain)
982,1004c819,820
< #ifdef DEBUG
<       write (iout,*) "jconmin",jconmin," rmsmin",rmsmin,
<      &  " listmin",listmin_min(:nchain)
<       do i=1,3
<         write (iout,'(i3,f10.5,5x,3f10.5)')i,przes_min(i),
<      &    (obrot_min(i,j),j=1,3)
<       enddo
< #endif
<       do ichain=1,nchain
<         li=listmin_min(ichain)
<         do i=1,chain_length(ichain)
< c          write (iout,*) "ichain",ichain," i",i," li",li
<           kk1=chain_border(1,ichain)+i-1
<           kk2=chain_border(1,li)+i-1
<           yy(:,kk1)=allcart(:,kk2,jconmin)
<           yy(:,kk1+nres)=allcart(:,kk2+nres,jconmin)
< #ifdef DEBUG
<           write (iout,'(2(i5,3f10.5,5x))') kk1,(yy(j,kk1),j=1,3),
<      &      kk2,(xx(j,kk1+nres),j=1,3)
< #endif
<         enddo
<       enddo
<       call matvec(cwork,obrot_min,yy,2*nres)
---
> c      write (iout,*) "rmsmin",rmsmin," rms",rms
>       call flush(iout)
1006,1009d821
< #ifdef DEBUG
<         write (iout,'(i5,2(3f10.5,5x))') i,(cwork(j,i),j=1,3),
<      &    (yy(j,i),j=1,3)
< #endif
1011c823
<           c(j,i)=cwork(j,i)+przes_min(j)
---
>           c(j,i)=allcart(j,i,jconmin)
1014,1029d825
< #ifdef RMS_CHECK
< c rms check
<       rmscheck=0.0d0
<       ii=0
<       do ichain=1,nchain
<         do i=1,chain_length(ichain)
<         ii=ii+1
<         kk1=chain_border(1,ichain)+i-1
<         write (iout,'(i5,3f10.5,5x,3f10.5)') kk1,c(:,kk1),cref(:,kk1)
<         do j=1,3
<           rmscheck=rmscheck+(c(j,kk1)-cref(j,kk1))**2
<         enddo  
<         enddo
<       enddo
<       write (iout,*) "rmscheck",dsqrt(rmscheck/ii),rmsmin
< #endif
1045d840
< #endif
1061,1065c856,857
<       ii=0
<       do i=1,nres
<         if (itype(i).eq.ntyp1) cycle
<         ii=ii+1
<         do j=1,3
---
>       do j=1,3
>         do i=1,nres
1070c862
<         przes(j)=przes(j)/ii
---
>         przes(j)=przes(j)/nres
1136,1291d927
<       enddo
<       return
<       end
< c----------------------------------------------------------------------
<       subroutine family_out(ncon,igr,icut,printpdb,ib)
<       implicit none
<       include 'DIMENSIONS'
<       include 'sizesclu.dat'
<       include 'COMMON.CONTROL'
<       include 'COMMON.CLUSTER'
< #ifndef RESUP
<       include 'COMMON.SUPCLUST'
< #endif
<       include 'COMMON.CHAIN'
<       include 'COMMON.INTERACT'
<       include 'COMMON.VAR'
<       include 'COMMON.TEMPFAC'
<       include 'COMMON.IOUNITS'
<       include 'COMMON.SBRIDGE'
<       include 'COMMON.HEADER'
<       include 'COMMON.FREE'
<       integer PRINTPDB(max_cut)
<       integer ib,icut
<       double precision przes(3),obrot(3,3)
<       double precision eref
<       double precision rmscalc,rmscalc_alg1,rmscalc_alg2
<       integer ncon
<       integer i,ii,j,k,icon,jcon,igr,ipermmin,ichain,kk1,kk2,li
<       double precision rms,cref1(3,maxres2),xx(3,maxres2),
<      & cwork(3,maxres2)
<       double precision rmscheck
<       double precision rmsd_dist,rmsd_fitsq
<       common /RMSD/ rmsd_dist,rmsd_fitsq
<       integer listmin(maxchain)
<       common /permutacja/ listmin
<       integer ncon_out
<       double precision emin1
<       integer ind,ioffset
< #ifdef DEBUG
<       write (iout,*) "FAMILY_OUT: IGR",igr
< c      call flush(iout)
< #endif
<       przes=0.0d0
<       icon=nconf(igr,1)
<       emin1=totfree(icon)
< c Write conformations of the family i to PDB files
<       ncon_out=1
<       do while (ncon_out.lt.printpdb(icut) .and.
<      &  ncon_out.lt.licz(igr).and.
<      &  totfree(nconf(igr,ncon_out+1))-EMIN1.LE.ECUT)
<         ncon_out=ncon_out+1
<       enddo
< c      write (iout,*) "ncon_out",ncon_out," printpdb",printpdb(icut)
<       cref1(:,:2*nres)=allcart(:,:2*nres,icon)
<       c(:,:2*nres)=cref1(:,:2*nres)
<       call center
<       call inbox
<       call pdbout(totfree(icon)/beta_h(ib),rmstb(1,icon),titel)
<       do k=2,ncon_out
<         jcon=nconf(igr,k)
< c        write (iout,*) "k",k," jcon",jcon
<         do i=1,2*nres
<           do j=1,3
<             cwork(j,i)=allcart(j,i,jcon)
<           enddo
<         enddo
< #ifdef RESUP
<         if (ialg.eq.0) then
<           rms=rmscalc(cwork(1,1),cref1(1,1),przes,obrot,ipermmin)
<           listmin(:nchain)=tabpermchain(:nchain,ipermmin)
<         else if (ialg.eq.1) then
<           rms=rmscalc_alg1(cwork(1,1),cref1(1,1),przes,obrot)
<         else if (ialg.eq.2) then
<           rms=rmscalc_alg2(cwork(1,1),cref1(1,1),przes,obrot)
<         else
<           write (iout,*) "AVE_COORD: illegal superposition algorithm",
<      &     ialg
<           stop "AVE_COORD: illegal superposition algorithm"
<         endif 
< #ifdef DEBUG
<         write (iout,*) "After superposition",icon,jcon
<         write (iout,*) "k",k," rms",rms," ipermmin",ipermmin
<         write (iout,*) "listmin",listmin(:nchain)
<         do i=1,3
<           write (iout,'(i3,f10.5,5x,3f10.5)')i,przes(i),
<      &      (obrot(i,j),j=1,3)
<         enddo
< #endif
< #else
<         if (icon.gt.jcon) then
<           ind=IOFFSET(NCON,jcon,icon)
<           listmin(:nchain)=listmin_all(:nchain,ind)
<           obrot(:,:)=obrot_all(:,:,ind)
<         else
<           ind=IOFFSET(NCON,icon,jcon) 
<           do i=1,nchain
<             listmin(listmin_all(i,ind))=i
<           enddo
<           do i=1,3
<             do j=1,3
<               obrot(i,j)=obrot_all(j,i,ind)
<             enddo
<           enddo
<         endif
<         rms=diss(ind)
< #ifdef DEBUG
<         write(iout,*) "Restoring info",icon,jcon
<         write (iout,*) "k",k," rms",rms," ipermmin",ipermmin
<         write (iout,*) "listmin",listmin(:nchain)
<         do i=1,3
<           write (iout,'(i3,f10.5,5x,3f10.5)')i,przes(i),
<      &      (obrot(i,j),j=1,3)
<         enddo
< #endif
< #endif 
<         do ichain=1,nchain
<           li=listmin(ichain)
<           do i=1,chain_length(ichain)
< c            write (iout,*) "ichain",ichain," i",i," li",li
<             kk1=chain_border(1,ichain)+i-1
<             kk2=chain_border(1,li)+i-1
<             xx(:,kk1)=allcart(:,kk2,jcon)
<             xx(:,kk1+nres)=allcart(:,kk2+nres,jcon)
< #ifdef DEBUG
<             write (iout,'(2(i5,3f10.5,5x))') kk1,(xx(j,kk1),j=1,3),
<      &        kk2,(xx(j,kk1+nres),j=1,3)
< #endif
<           enddo
<         enddo
<         call matvec(cwork,obrot,xx,2*nres)
<         do i=1,2*nres
< #ifdef DEBUG
<           write (iout,'(i5,2(3f10.5,5x))') i,(cwork(j,i),j=1,3),
<      &    (xx(j,i),j=1,3)
< #endif
<           do j=1,3
<             c(j,i)=cwork(j,i)+przes(j)
<           enddo
<         enddo
<         nss=nss_all(jcon)
<         if (dyn_ss) then
<         do i=1,nss
<           ihpb(i)=iss(ihpb_all(i,jcon))+nres
<           jhpb(i)=iss(jhpb_all(i,jcon))+nres
< c          write (iout,*) ihpb(k),jhpb(k)
<         enddo
<         else
<         do i=1,nss
<           ihpb(i)=ihpb_all(i,jcon)
<           jhpb(i)=jhpb_all(i,jcon)
< c          write (iout,*) ihpb(k),jhpb(k)
<         enddo
<         endif
<         call center
<         call inbox
<         call pdbout(totfree(jcon)/beta_h(ib),rmstb(1,jcon),titel)
################# xlinks.F
