Viewing contents of file '../idllib/iuedac/iuelib/pro/getlist.pro'
;******************************************************************************
;+
;*NAME:
;
;    GETLIST    (General IDL Library 01)  October 3, 1980
;
;*CLASS:
;
;    i/o
;
;*CATEGORY:
;
;*PURPOSE:
;
;     Procedure to read variables previously written by procedure SAVLIST.
;
;*CALLING SEQUENCE:
;
;     GETLIST,FILNAM,DATA
;
;*PARAMETERS:
;
;     FILNAM  (REQ) (I) (0) (S)
;             Required input string containing the name of the .SAV 
;             file created by SAVLIST
;
;     DATA    (REQ) (O) (1 2) (B I L F D)
;             Required output parameter containing the data stored in
;             FILNAM.SAV
;
;*EXAMPLES:
;
;*SYSTEM VARIABLES USED:
;
;    none
;
;*INTERACTIVE INPUT:
;
;*SUBROUTINES CALLED:
;
;    DECOMPOSE
;    PARCHECK
;    PLATFORM
;
;*FILES USED:
;
;      FILNAM.SAV is read
;
;*SIDE EFFECTS:
;
;*RESTRICTIONS:
;
;*NOTES:
;
;	tested with IDL Version 2.1.0 (sunos sparc)  	 7 Aug 91
;	tested with IDL Version 2.1.0 (ultrix mispel)	N/A
;	tested with IDL Version 2.1.0 (vms vax)      	 7 Aug 91
;
;*PROCEDURE:
;
;    The presence of the file on disk is verified.
;    The initial record of the file is read to determine the 
;    number of dimensions in the data stored, as well as the data type.
;    The next record is read to find the number of elements in each
;    dimension.
;    The output variable is defined with appropriate dimension and type,
;    and the data are read into it. 
;
;*INF_1:
;
;*MODIFICATION HISTORY:
;
;    Oct  3 1980  D.Lindler  GSFC  initial version
;    Mar 10 1988  CAG  GSFC  add VAX RDAF-style prolog, printout of calling 
;                            sequence when no parameters are given, and 
;                            check for correct number of parameters.
;    6-24-88 RWT correct call to PARCHECK and use GET_LUN 
;    3-04-91 PJL modified for unix/sun; removed !ERR; replaced FORRD with
;		 READU; updated type codes (NTYPE)
;    4-09-91 GRA added vms branch and /segmented keyword for file open
;                statement.
;    6-21-91 PJL cleaned up; tested on SUN and VAX; updated prolog
;    8- 7-91 PJL added version number; tested on SUN and VAX; updated prolog
;    8 Jun 94  PJL  replace !version with PLATFORM
;
;-
;*****************************************************************************
 pro getlist,filnam,data                              
;
;check the parameters
;
 npar = n_params(0)
 if (npar eq 0) then begin
    print,'GETLIST,FILNAM,DATA'
    retall
 endif  ; npar eq 0
 parcheck,npar,2,'GETLIST'
;
 decompose,filnam,disk,uic,name,extn,vers
 platform,dummy,sysos=sys
;
; open input data set
;
;;; if !version.os eq 'vms' then begin
;;;    openr,un,disk+uic+name+'.sav'+vers,/get_lun,/segmented,ERROR=err
;;; endif else begin
;;;    openr,un,disk+uic+name+'.sav',/get_lun,/f77_unformatted,ERROR=err
;;; endelse  ; !version.os
 if (sys eq 'vms') then $
    openr,un,disk+uic+name+'.sav'+vers,/get_lun,/segmented,error=err else $
    openr,un,disk+uic+name+'.sav',/get_lun,/f77_unformatted,error=err
 if (err ne 0) then begin                          ; data set not found
    print,'Input data set not found'
    print,'ACTION:  Returning'
    free_lun,un
    retall
 endif  ; err
 ndim  = 0
 ntype = 0
 n1 = 0
 n2 = 0
;
; read info on size and type of data
;
 readu,un,ndim,ntype                     ; read # of dimensions, data type   
 if ndim gt 0 then readu,un,n1                         ; first dimension
 if ndim gt 1 then readu,un,n2                         ; second dimension
;
; scalar variable
;
 if ndim eq 0 then begin
    if ntype eq 1 then data = 0b       ; byte
    if ntype eq 2 then data = 0        ; integer
    if ntype eq 4 then data = 0.0      ; floating-point
    if ntype eq 3 then data = 0l       ; longword integer
    if ntype eq 5 then data = 0.0d     ; double-precision
 endif ;  if ndim eq 0
;
; one dimensional array
;
 if ndim eq 1 then begin
    if ntype eq 1 then data = bytarr(n1)
    if ntype eq 2 then data = intarr(n1)
    if ntype eq 4 then data = fltarr(n1)
    if ntype eq 3 then data = lonarr(n1)
    if ntype eq 5 then data = dblarr(n1)
 endif ;  if ndim eq 1
;
; two dimensional array
;
 if ndim eq 2 then begin
    if ntype eq 1 then data = bytarr(n1,n2)
    if ntype eq 2 then data = intarr(n1,n2)
    if ntype eq 4 then data = fltarr(n1,n2)
    if ntype eq 3 then data = lonarr(n1,n2)
    if ntype eq 5 then data = dblarr(n1,n2)
 endif ;  if ndim eq 2
;
; read data portion of input file
;
 readu,un,data
 free_lun,un
;
 return
 end  ; getlist