7c7
<       real am(3, 3)
---
>       real am(3,3)
9c9
<       maxcyc=50
---
>       maxcyc=MAXCYCLE
34c34
<       rn = 1. / float(nm)
---
>       rn = 1. / real(nm)
43,45c43,45
<           xb1(1,j) = xf(1,j,i)
<           xb1(2,j) = xf(2,j,i)
<           xb1(3,j) = xf(3,j,i)
---
>           do k=1,3
>             xb1(k,j) = xf(k,j,i)
>           end do
49,51c49,51
<           tmp(1,j,i) = xb1(1,j)
<           tmp(2,j,i) = xb1(2,j)
<           tmp(3,j,i) = xb1(3,j)
---
>           do k=1,3
>             tmp(k,j,i) = xb1(k,j)
>           end do
60,63c60,64
<           rms = 0.
<           do j = 1, nf
<             rms = rms + (wt(j,k) * ((((xb1(1,j) - xf(1,j,k)) ** 2) + ((xb1(2,j
<      &      ) - xf(2,j,k)) ** 2)) + ((xb1(3,j) - xf(3,j,k)) ** 2)))
---
>           rms=0.
>           do j=1,nf
>             rms=rms + (wt(j,k) * ((((xb1(1,j) - xf(1,j,k)) ** 2) +
>      +                             ((xb1(2,j) - xf(2,j,k)) ** 2)) +
>      +                             ((xb1(3,j) - xf(3,j,k)) ** 2)))
65c66
<           distm(i,k) = sqrt(rms / float(nf))
---
>           distm(i,k)=sqrt(rms/real(nf))
69,70c70,71
<       do i = 1, mmols
<         do j = 1, mmols
---
>       do i=1, mmols
>         do j=1, mmols
77c78
<       nm1 = nm + 1
---
>       nm1=nm+1
79,82c80,83
<       do j = 1, nf
<         xf(1,j,nm1) = xb1(1,j)
<         xf(2,j,nm1) = xb1(2,j)
<         xf(3,j,nm1) = xb1(3,j)
---
>       do j=1,nf
>         do k=1,3
>           xf(k,j,nm1) = xb1(k,j)   ! was xf(1,j,nm1) = xb1(1,j)  jpo 9-5-96
>         end do
84a86,87
> C fit each structure to each structure in a pairwise manner
> C
97a101
> C
100,102c104,106
<           xf(1,j,k) = coords(1,na(j,k),k)
<           xf(2,j,k) = coords(2,na(j,k),k)
<           xf(3,j,k) = coords(3,na(j,k),k)
---
>           do i=1,3
>             xf(i,j,k) = coords(i,na(j,k),k)
>           end do
106c110
<       do i = 1, nm
---
>       do i=1, nm
110,112d113
< C
< C rotate, etc, the hetatom coords by the same transformation
< C
114a116,117
> C
>       return
47c47
<       if(chk1.ne.0.or.chk2.ne.0) then
---
>       if( chk1 .ne. 0 .or. chk2 .ne. 0) then
63c63
<         if(chk1.eq.0) then
---
>         if (chk1 .eq. 0) then
16c16,18
< C Modified by jpo and pjt
---
> C (Modified by jpo and pjt)
> C There is code from I. Haneef, and from Steve Remmington (from Frodo)
> C in here as well.
31a34
>       logical DOREPAIR
46a50
>       DOREPAIR=.false.
80a85,86
>           else if (BUFFER(2:2) .eq. 'r') then
>             DOREPAIR=.true. 
191a198
>       write (IO,'(''# repair sidechains:          '',L2)') DOREPAIR
201c208
<         call mchain(i, fname(i), nff)
---
>         call mchain(i, fname(i), nff, DOREPAIR)
259,262d265
< C write out secondary structure
< C
<       call secstr(istruc)
< C
287,288c290,291
<       write (IO,'(A)') SPACER
<       write (IO,'(A)') SPACER
---
> C     write (IO,'(A)') SPACER
> C     write (IO,'(A)') SPACER
307,309c310
<         call blkfil()
<         call svrlen()
<         call dump(bifil, seqfil, istruc)
---
>         write (STDERR,'(''mnyfit: unimplemented option (136)'')')
3c3
< c     SUBROUTINE TO FIT THE COORD SET XA(3,N) TO THE SET XB(3,N)
---
> c     SUBROUTINE TO FIT THE COORD SET X2(3,N) TO THE SET X1(3,N)
21,22c21,22
<       dimension umat(3, 3), rm(3, 3), wt1(maxats), x1(3, maxats), x2(3, 
<      &maxats)
---
>       dimension umat(3,3), rm(3,3), wt1(maxats), x1(3,maxats), x2(3,maxats)
> C
24c24
<         write(STDERR,'(''mnyfit: number of points < 3'')')
---
>         write(STDERR,'(''mnyfit: number of points < 3 : '',I2)') NF
26a27
> C
28,35c29,38
<       do 20 i = 1, 3
<       do 10 j = 1, 3
<       umat(i,j) = 0.0
<    10 continue
<       do 20 j = 1, n
<       do 20 k = 1, 3
<       umat(i,k) = umat(i,k) + (x1(i,j) * x2(k,j))
<    20 continue
---
>         do i = 1, 3
>           do j = 1, 3
>             umat(i,j) = 0.0
>           end do
>           do j = 1, n
>             do k = 1, 3
>               umat(i,k) = umat(i,k) + (x1(i,j) * x2(k,j))
>             end do
>           end do
>         end do
37,44c40,49
<       do 40 i = 1, 3
<       do 30 j = 1, 3
<       umat(i,j) = 0.0
<    30 continue
<       do 40 j = 1, n
<       do 40 k = 1, 3
<       umat(i,k) = umat(i,k) + ((wt1(j) * x1(i,j)) * x2(k,j))
<    40 continue
---
>         do i = 1, 3
>           do j = 1, 3
>             umat(i,j) = 0.0
>           end do
>           do j = 1, n
>             do k = 1, 3
>               umat(i,k) = umat(i,k) + ((wt1(j) * x1(i,j)) * x2(k,j))
>             end do
>           end do
>         end do
46,47d50
< c--   FIT IT
< c
48a52
> C
49a54
> C
3c3
< C prints out pairwise distance matirix for superposition
---
> C prints out pairwise distance matrix for superposition
9c9
< C problems her with lengths of names etc. Will have to live with truncation
---
> C problems here with lengths of names etc. Will have to live with truncation (for now)
17,18c17,21
<         write (IO,'(''# '',A9,30(1X,F5.3))')
<      +        NAMES(I)(1:NLL),(MAT(I,K),K=1,N) 
---
> C
> C note hardcoded format length here (50 on 9-5-96)
> C
>         write (IO,'(''# '',I3,1X,A9,50(1X,F5.3))')
>      +        I,NAMES(I)(1:NLL),(MAT(I,K),K=1,N) 
20c23,26
<       write (IO,'(''# Framework'',30(1X,F5.3))') (MAT(N,K),K=1,N) 
---
> C
> C note hardcoded format length here (50 on 9-5-96)
> C
>       write (IO,'(''#     Framework'',50(1X,F5.3))') (MAT(N,K),K=1,N) 
1c1
<       subroutine mchain(ION, fil, nff)
---
>       subroutine mchain(ION, fil, nff, DOREPAIR)
9a10
>       logical DOREPAIR
18,19c19
<       open (unit=ii, form='FORMATTED', file=fil, status='OLD',
<      +      err=900) 
---
>       open (unit=ii, form='FORMATTED', file=fil, status='OLD', err=900) 
30c30
<     1 read(unit=ii, fmt=601, end=300) card
---
>     1 read (unit=ii, fmt=601, end=300) card
79c79
<       call sort(ION)
---
>       call sort(ION, DOREPAIR)
83c83,84
<       do 590 ij = 1, numran
---
> C
>       do ij = 1, numran
85c86,87
<   590 continue
---
>       end do
> C
87,123c89,126
<       if (i1 .gt. numran) goto 7
<       if (staran .and. endran) then
<       if (numres(j,ION) .ne. range(i1,2,ION)(2:6)) then
<       staran = .false.
< c     WRITE (STDERR,606)I1,RANGE(I1,1,ION),RANGE(I1,2,ION),RANLEN(I1)
<       endran = .false.
<   606 format(//5hRANGE,2x,i2,5x,a6,6h  TO  ,a6,5x,i4,6h ATOMS)
<       i1 = i1 + 1
<       end if
<       end if
<       if (range(i1,1,ION)(2:6) .eq. numres(j,ION)) then
<       staran = .true.
<       end if
<       if (range(i1,2,ION)(2:6) .eq. numres(j,ION)) then
<       endran = .true.
<       end if
<     7 if (select .eq. 'CA  ') then
<       if (atnam(j,ION) .eq. ' CA ') then
<       else
<       goto 200
<       end if
<       else if (select .eq. 'MAIN') then
<       if ((((atnam(j,ION) .eq. ' N  ') .or. (atnam(j,ION) .eq. ' CA '))
<      & .or. (atnam(j,ION) .eq. ' C  ')) .or. (atnam(j,ION) .eq. ' O  ')) 
<      &then
<       continue
<       else
<       goto 200
<       end if
<       end if
<       if (staran) then
<       ranlen(i1) = ranlen(i1) + 1
<       k = k + 1
<       na(k,ION) = j
< c     write(STDERR, fmt=*) k, numres(j,ION), namres(j,ION), atnam(j,ION), 
< c     &ranlen(i1)
<       end if
---
>         if (i1 .gt. numran) goto 7
>         if (staran .and. endran) then
>           if (numres(j,ION) .ne. range(i1,2,ION)(2:6)) then
>             staran = .false.
> c           WRITE (STDERR,606)I1,RANGE(I1,1,ION),RANGE(I1,2,ION),RANLEN(I1)
>             endran = .false.
>   606       format(//5hRANGE,2x,i2,5x,a6,6h  TO  ,a6,5x,i4,6h ATOMS)
>             i1 = i1 + 1
>           end if
>         end if
>         if (range(i1,1,ION)(2:6) .eq. numres(j,ION)) then
>           staran = .true.
>         end if
>         if (range(i1,2,ION)(2:6) .eq. numres(j,ION)) then
>           endran = .true.
>         end if
>     7   if (select .eq. 'CA  ') then
>           if (atnam(j,ION) .eq. ' CA ') then
>             continue
>           else
>             goto 200
>           end if
>         else if (select .eq. 'MAIN') then
>         if ((((atnam(j,ION) .eq. ' N  ') .or. (atnam(j,ION) .eq. ' CA '))
>      &   .or. (atnam(j,ION) .eq. ' C  ')) .or. (atnam(j,ION) .eq. ' O  ')) 
>      &    then
>             continue
>           else
>             goto 200
>           end if
>         end if
>         if (staran) then
>           ranlen(i1) = ranlen(i1) + 1
>           k = k + 1
>           na(k,ION) = j
> c         write(STDERR, fmt=*) k, numres(j,ION), namres(j,ION), atnam(j,ION), 
> c         &ranlen(i1)
>         end if
5,6c5,6
<       PARAMETER (MAXMOL=30)
<       parameter (STDERR=0, STDOUT=6)
---
>       include 'mnyfit.h'
> c      PARAMETER (MAXMOL=30)
5c5,9
<       implicit none
---
> C jpo 23-4-96 (added mnyfit.h dependency)
> C
> c      implicit none
>       include 'mnyfit.h'
> C
38,39c42,48
<       implicit none
<       real x1(3, 1), x2(3, 1), X3(3,1)
---
> C jpo 23-4-96 adfded het.h and mnyfit.h
> C
> c      implicit none
>       include 'mnyfit.h'
>       include 'het.h'
> C
>       real x1(3, MAXATS, MAXMOL), x2(3, MAXATS, MAXMOL), X3(3, MAXHET, MAXMOL)
46c55
<           c=c+x1(j,i)
---
>           c=c+x1(j,i,1)
50c59
<           x1(j,i)=x1(j,i)-c
---
>           x1(j,i,1)=x1(j,i,1)-c
53c62
<           x2(j,i)=x2(j,i)-c
---
>           x2(j,i,1)=x2(j,i,1)-c
56c65
<           x3(j,i)=x3(j,i)-c
---
>           x3(j,i,1)=x3(j,i,1)-c
1,2c1,2
< c******************************************************************
< c********************************************************
---
>       subroutine qikfit(umat, rm)
> c
12d11
<       subroutine qikfit(umat, rm)
13a13
> C
1,4c1,9
< c     ******************************************************************
< c     ******************************************************************
<       subroutine rmsfit(x1, x2, rms, n, iw, wt)
<       real x1(3, 1), x2(3, 1), wt(1)
---
>       subroutine rmsfit(x1, x2, rms, n, iw, wtjpo)
> C
> C 25-4-96: jpo added includes and redimensioned relevant arrays
> C
>       include 'mnyfit.h'
> C
>       real x1(3, MAXATS, MAXMOL), x2(3, MAXATS, MAXMOL), WTJPO(MAXATS)
>       real WW
> C
6,11c11,16
<       rms = 0.
<       do 1 i = 1, n
<       rms = ((rms + ((x1(1,i) - x2(1,i)) ** 2)) + ((x1(2,i) - x2(2,i))
<      & ** 2)) + ((x1(3,i) - x2(3,i)) ** 2)
<     1 continue
<       rms = sqrt(rms / float(n))
---
>         rms = 0.0
>         do i = 1, n
>           rms = ((rms + ((x1(1,i,1) - x2(1,i,1)) ** 2)) + ((x1(2,i,1) - x2(2,i,1))
>      &    ** 2)) + ((x1(3,i,1) - x2(3,i,1)) ** 2)
>         end do
>         rms = sqrt(rms / float(n))
13,20c18,26
<       ww = 0.
<       rms = 0.
<       do 2 i = 1, n
<       ww = ww + wt(i)
<       rms = rms + (wt(i) * ((((x1(1,i) - x2(1,i)) ** 2) + ((x1(2,i) - x2
<      &(2,i)) ** 2)) + ((x1(3,i) - x2(3,i)) ** 2)))
<     2 continue
<       rms = sqrt(rms / ww)
---
>         ww=0.
>         rms=0.
>         do i=1,n
>           ww=ww+wtjpo(i)
>           rms=rms + (wtjpo(i) * ((((x1(1,i,1) - x2(1,i,1)) ** 2)
>      -                          + ((x1(2,i,1) - x2(2,i,1)) ** 2))
>      -                          + ((x1(3,i,1) - x2(3,i,1)) ** 2)))
>         end do
>         rms=sqrt(rms / ww)
21a28,30
> C
>       return
> C
22a32
> 
1c1
<       subroutine sort(ION)
---
>       subroutine sort(ION, DOREPAIR)
24c24
<       logical found
---
>       logical found, DOREPAIR
158,162c158,164
<       if (notfnd .gt. 0) then
<         write (STDOUT,'(''#       this sidechain will be repaired from '',A4)')
<      +         order(nr,notfnd - 4)
<         call repair(nr, len(nr), notfnd, xtemp, xref, 1)
<         natr = len(nr)
---
>       if (DOREPAIR) then
>         if (notfnd .gt. 0) then
>           write (STDOUT,'(''#       this sidechain will be repaired from '',A4)')
>      +           order(nr,notfnd - 4)
>           call repair(nr, len(nr), notfnd, xtemp, xref, 1)
>           natr = len(nr)
>         end if
