       SUBROUTINE H_FLUSH_MINIH(zoff)       
C
C----------------------------------------------------------------------
C
C.IDENTIFICATION: Subroutine H_FLUSH_MINIH                 
C.LIBRARY:        GENERAL
C.AUTHOR:         L.Chiappetti - IFCTR Milano
C.VERSIONS:       0.0 - 11 Aug 92 - First version
C.VERSIONS:       1.0 - 29 Oct 92 - New error handling codes
C.PURPOSE:        flush to  disk a file mini-header           
C.METHOD:         write first record(s)
C                 error code ir returned thru VOSCOMMON               
C.SYNTAX:         CALL H_FLUSH_MINIH(zoff)              
C
C.PARAMETERS:     INTEGER       zoff          zero-record offset (output) 
C.RESTRICTIONS:   this routine is not intended to be called by the general
C                 use but will be called only by higher level routines
C.NOTES:          the first data record is zoff+1, the second zoff+2, etc.
C.FILES:          none
C.REFERENCES:     noen
C
C----------------------------------------------------------------------
C
C      INCLUDE 'implicit_none.inc'
       INTEGER  recl,zoff,ierr,i,j
       INCLUDE 'voscommon.inc'
       INCLUDE 'errors.inc'
       INCLUDE 'hcommon.inc'
C
       VOSCOMMON_ERROR=0
C      the record length is documented in mini-header itself
       RECL=MINIH_RECLEN
C
C      mini-h may extend on "zoff" records : normally zoff is 1, but for very
C      short records mini-h can span more than one
C      zoff+1 is the first data record
C      zoff is computed here and passed back to calling program
C 
       zoff=0
       DO 1 i=1,28,recl 
       zoff=zoff+1
       J=MIN(I+RECL-1,28)
       WRITE(HCOMMON_LU(HCOMMON_CURFILE),REC=zoff,IOSTAT=IERR,ERR=990)
     . MINIH_ALL(I:J)
C      write(*,*)' debug minih flush rec from ',zoff,i
 1     CONTINUE 
C      store current mini header in header buffer         
       HCOMMON_MINIH(HCOMMON_CURFILE)=MINIH_ALL  
       RETURN
C
C      Pass errors along
C
C     i/o error
 990  VOSCOMMON_SYSTEMERROR=IERR
      VOSCOMMON_ERROR=XE_WRITERR 
      RETURN
      END           
