********************************************************************************
*                                                                              * 
*  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 ### wrec ###
c
      subroutine wrec(irec,ngrid,axyz)
      implicit integer*4 (i-n)
      implicit real*8 (a-h,o-z)
      include 'commons8.inc'        
      dimension axyz(ngrid)
      iunit=irec+30
      if (iunit.gt.maxunit) then
         write(*,910)
         stop "wrec"
 910     format('wrec: maximum unit number exceeded ',
     &        '(see User''s Guide)')
      endif

      open(iunit,status='unknown',form='unformatted')
      rewind(iunit)
      write (iunit,err=900) axyz
      close(iunit)
      return
 900  write(iout6,*) 'error detected when writing exchange',  
     &     ' potential',irec
      stop 'wrec'
      end
