anchor.diff:        dimension x1(ndim),y1(ndim),z1(ndim),nn1(ndim)
         dimension x2(ndim),y2(ndim),z2(ndim),nn2(ndim)
   
  -      logical read_score
  -      read_score = .FALSE.
  +cjmht
  +      integer score_type
  +      logical fcheck
  +      score_type=0
  +      fcheck = .FALSE.
   
   **********************************************************************
   ****  check if we are reading a score matrix or processing rmsds
   **********************************************************************
  -      inquire(file='score.matrix',exist=read_score)
  -      if (read_score) then
  +      inquire(file='score.matrix',exist=fcheck)
  +      if (fcheck) then
             write(*,*)"Scores will be read from file: score.matrix"
  -      else
  +          score_type=1
  +      endif
  +      inquire(file='TM.score',exist=fcheck)
  +      if (fcheck) then
  +          write(*,*)"TM scores will be used"
  +          if (score_type .ne. 0) then
  +              write(*,*)'Cannot use score.matrix and TM.score!'
  +              STOP 1
  +          endif
  +          score_type=2
  +      endif
  +      if (score_type .eq. 0) then
             write(*,*)"Calculating RMSD scores"
         endif
   
  
positive.code:       real rmsd_delta
        double precision rmsd_a
  !     local variables
        double precision scored,RMSD_min,RMSD_max
        real armsd,rmsd2_a
        integer i,j,k,n_rmsd
  
        RMSD_min=0.0
        RMSD_max=50.0
        rmsd_a=0
        rmsd2_a=0
        n_rmsd=0
  
negative.code:          mark(i)=1
        enddo
        
  cjmht Calculate the amat with the all-by-all scores
        if (score_type .eq. 1) then
            call read_score_matrix(nst,n_str,amat,rmsd_delta, rmsd_a)
        elseif (score_type .eq. 2) then
            call tm_score_all(ndim,nst,n_str,Lch,x,y,z,amat,rmsd_delta,
       &                      rmsd_a)
        else
            call rmsd_score_all(ndim,nst,w,n_str,Lch,x,y,z,amat,
       &                        rmsd_delta,rmsd_a)
        endif
  
  cjmht write out the score matrix
        open(30,file='spicker.matrix',status='unknown') !scores
        do i=1,n_str
           do j=i,n_str
           write(30,2000)i-1,j-1,amat(i,j)
           enddo
        enddo
        close(30)
  2000  format(i4,2x,i4,2x,f9.4)
  
  ******** reset RMSD_cutoff parameters:
        if(n_para.eq.-1)then      !parameters for ab inito modeling
  