c=====================================================================
c ==================================================
c         Copyright And License Agreement
c ==================================================
c
c MMSQ Version 1.0, 4th of april 1991.
c
c You may copy and distribute copies of the complete MMSQ source
c code as you receive it, in any medium, provided that you
c conspicuously and appropriately publish on each file a valid
c copyright notice "Copyright (C) 1991 Rob Hooft, Utrecht
c University"; keep intact the notices on all files that refer to
c this License Agreement and give other recipients of MMSQ a copy
c of this license agreement along with the program. You may charge
c a distribution fee for the physical act of transferring a copy. 
c
c You may copy and distribute MMSQ in object code or executable
c form under the terms mentioned above provided that you also
c accompany it with the complete corresponding machine-readable
c source code, which must also be distributed under the terms
c mentioned above.
c
c You may not copy, sublicense, distribute or transfer MMSQ except 
c as expressly provided under this license agreement.
c
c (This license agreement has been modelled after the 
c GNU GENERAL PUBLIC LICENSE)
c
c=====================================================================
      program square_nonebusy

c==============Read Square.dat file=======================================

      include 'square.inc'

c==============Rebuild the square-file====================================

      call waitbinfile(2)

      do j1=0,i1
        do j2=0,i2      
          nr=(i2+1)*j1+j2+1
          read(2,rec=nr) rec
          if (rec.busy1h.or.rec.busy1l.or.rec.busy2h.or.rec.busy2l) 
     1        then
            rec.busy1h=.false.
            rec.busy1l=.false.
            rec.busy2h=.false.
            rec.busy2l=.false.
            write(*,*) 'Re-enabled record ',nr
            write(2,rec=nr) rec
          endif
        enddo
      enddo          
      close(2)
      write(*,*) 'Square-file rebuilt.'
      end
