********************************************************************************
*                                                                              * 
*  2DHF version 1-2003                                                         *
*  Copyright (C) 1996  Jacek Kobus, Leif Laaksonen, Dage Sundholm              *
*                                                                              *
*  This software may be used and distributed according to the terms            *
*  of the GNU General Public License, see README and COPYING.                  *
*                                                                              *
********************************************************************************
c ### setmaxunit ###
c
c     Determines and sets maximum unit number allowed
c
      subroutine setmaxunit
      implicit integer*4 (i-n)
      implicit real*8 (a-h,o-z)
      include 'commons8.inc'
      do i=99,1000 
         iunit=i
         open(iunit,status='scratch',form='unformatted',err=100)
         close(iunit)
      enddo
      maxunit=1000
      return
 100  maxunit=i-1
      return
      end
