Viewing contents of file '../idllib/iuedac/iuelib/pro/filetype.pro'
;************************************************************************
;+
;*NAME:
;
;	FILETYPE
;
;*CLASS:
;
;*CATEGORY:
;
;	IUE specific error checking and file name parsing
;
;*PURPOSE:
;
;	Procedure to verify that a file is on disk, and to
;       parse the file name.
;
;*CALLING SEQUENCE:
;
;	FILETYPE,IMAGET,DISK,PATH,NAME,EXT,VERS,NCAM,TYPE,ISN
;
;*PARAMETERS:
;
;	IMAGET  (REQ) (I)
;		string file name following IUE G.O. file convention
;
;	DISK    (REQ) (O)
;		string name of disk
;
;       ACCOUNT (REQ) (O)
;		string account for file
;
;       NAME    (REQ) (O)
;		string file name
;
;       EXT     (REQ) (O)
;		string file extension (e.g. .DAT)
;
;       VERS    (REQ) (O)
;		string version number
;
;       NCAM    (REQ) (O)
;		(integer) camera number
;
;       TYPE    (REQ) (O)
;		file type, e.g. 'H' for high dispersion
;
;       ISN     (REQ) (O)
;		image sequence number
;
;*EXAMPLES:
;
;*SYSTEM VARIABLES USED:
;
;	!err_string
;
;*INTERACTIVE INPUT:
;
;*SUBROUTINES CALLED:
;
;	PARCHECK
;	DECOMPOSE
;
;*FILES USED:
;
;*SIDE EFFECTS:
;
;*RESTRICTIONS:
;
;*NOTES:
;
;	tested with IDL Version 2.1.0 (sunos sparc)  	23 Jul 91
;	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
;	tested with IDL Version 2.1.0 (vms vax)      	23 Jul 91
;
;*PROCEDURE:
;
;	The file name is parsed, and the specified disk location
;       is searched for the .DAT file of the given name. If it is
;       not found, an error message is issued, and control is 
;       returned to the calling procedure.
;
;*I_HELP  nn:
;
;*MODIFICATION HISTORY:
;
;	Based on code in IUELO
;       Version 0: CAG 2- DEC--87
;	 1-09-91 PJL modified for sun/unix; included removing !ERR
;	 7-23-91 PJL cleaned up; added if npar equals 0 print; tested
;		     on SUN and VAX; updated prolog
;
;-
;*************************************************************************
 pro filetype,imaget,disk,path,name,ext,vers,ncam,type,isn
;
; verify that the procedure has been called correctly 
;
 npar=n_params(0)
 if npar eq 0 then begin
    print,' FILETYPE,IMAGET,DISK,PATH,NAME,EXT,VERS,NCAM,TYPE,ISN'
    retall
 endif  ; npar
 parcheck,npar,8,'FILETYPE'
;
; parse the file name
;
 decompose,imaget,disk,path,name,ext,vers
 openr,unit,/get_lun,disk + path  + name + '.dat' + vers, error=err
;
; check to see whether the file is at the specified location
; if it is not, print error message and return to calling procedure
;
 if err ne 0 then begin
    print,'Error opening input file: ',disk+path+name+'.dat'+vers
    print,'ACTION:  Returning'
    printf, -2,!err_string
    return
 endif  ; err
;
; if file is on disk, get the camera number 
;
 rec=assoc(unit,intarr(20))
 h=rec(0)
 ncam=h(3)
 if (h(2) le 50) and (h(5) ne 6) then begin
    print,'File must be a mehi-type file (type=h). action: returning'
    return
 endif  ; h(2)
;
; close the file and release the logical unit number
;
 free_lun,unit
;
; get the data type
;
 case 1 of 
    (h(2) eq 768) : type='r'   ; raw iue image
    (h(2) eq 1536): type='p'   ; photometrically corrected image
    (h(3) eq 8)   : type='f'   ; fes 1
    (h(3) eq 9)   : type='f'   ; fes 2
    (h(2) eq 1) : type='l'     ; low dispersion extracted spectrum
    (h(2) eq 55): type='s'    ; low dispersion line by line pre Oct. 1, 1985
    (h(2) eq 110): type='s'   ; low dispersion line by line post Oct. 1, 1985
    else: type='h'            ; high dispersion (LWP, 54 orders, SWP=60 orders)
 endcase  ; 1
 isn=h(4)
 return
 end  ; filetype