;+
; Project     :	SOLAR-B - EIS
;
; Name        :	EIS_CPT_CLOSE_FILE
;
; Purpose     :	Closes file.
;
; Explanation :	If close fails then returns 0 else returns 1.
;
; Use         :	< result = eis_cpt_close_file(unit) >
;
; Inputs      :	UNIT : LONG logical unit number of file.
;
; Opt. Inputs : None.
;
; Outputs     : result : INT result 1 : ok, 0 : error
;
; Opt. Outputs:	None.
;
; Keywords    : None.
;
; Calls       : None.
;
; Common      :	None.
;
; Restrictions:	None.
;
; Side effects:	None.
;
; Category    :	EIS_CPT.
;
; Prev. Hist. :	None.
;
; Written     :	Martin Carter RAL 15/10/04
;
; Modified    :	Version 0.0, 15/10/04, MKC
;
; Version     :	Version 0.0, 15/10/04
;-
;**********************************************************

FUNCTION eis_cpt_close_file, unit

  ; set io error action

  ON_IOERROR, io_error

  ; if unit not set then dont try closing

  IF NOT KEYWORD_SET(unit) THEN RETURN, 1

  ; close file
  ; force it closed, even if error

  FREE_LUN, unit, /FORCE

  ; return ok flag

  RETURN, 1

io_error :

  ; issue routine name

  MESSAGE, 'ERROR', /INFORMATIONAL

  ; return error

  eis_cpt_message, 'IO ERROR CLOSING FILE, UNIT : '+eis_cpt_strtrim(unit)

  RETURN, 0

END





