;+ ; @file_comments ; Read contents of a gribtable. Gribtables are located ; in the gribtables subdirectory of HIPHOP ; ; @categories ; ; ; @param TABLENAME {in}{required} ; The full path name of a gribtable file ; ; @keyword PARMTABL ; ; ; @keyword CENTER ; ; ; @keyword SUBCENTER ; ; ; @keyword TABLNUM ; ; ; @returns ; ; ; @uses ; ; ; @restrictions ; ; ; @examples ; IDL> tablename='ectab_128' ; ; @history ; Dominik Brunner, Apr 2000 ; ; @version ; $Id$ ;- PRO read_gribtable, tablename, PARMTABL=parmtabl, CENTER=center,$ SUBCENTER=subcenter, TABLNUM=tablnum ; compile_opt idl2, strictarrsubs ; ON_ERROR,2 parmtabl=StrArr(3,256) center=-1 subcenter=-1 tablnum=-1 ; First Subscript (3) is [name,description,units] ; Second (256) is defined size of a parameter table IF n_elements(tablename) EQ 0 THEN return openr,lun,tablename,/get line='' ; read first line which (eventually) contains information ; about center, subcenter and table number readf,lun,line parts=STR_SEP(line,':') IF n_elements(parts) GT 3 THEN BEGIN center=fix(parts[1]) subcenter=fix(parts[2]) tablnum=fix(parts[3]) ENDIF ELSE BEGIN IF n_elements(parts) GE 3 THEN parmtabl[0:1,fix(parts[0])]=parts[1:2] $ ELSE IF n_elements(parts) EQ 2 THEN parmtabl[0,fix(parts[0])]=parts[1] ENDELSE ; loop over remaining lines REPEAT BEGIN readf,lun,line parts=STR_SEP(line,':') IF n_elements(parts) GE 3 THEN parmtabl[0:1,fix(parts[0])]=parts[1:2] $ ELSE IF n_elements(parts) EQ 2 THEN parmtabl[0,fix(parts[0])]=parts[1] END UNTIL EOF(lun) free_lun,lun ; fill up missing variable names index=WHERE(parmtabl[0,*] EQ '',count) IF count GT 0 THEN parmtabl[0,index]='var'+strcompress(index,/rem) END