source: trunk/SRC/ToBeReviewed/LECTURE/GRIB/read_gribtable.pro

Last change on this file was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1;+
2; @file_comments
3; Read contents of a gribtable. Gribtables are located
4; in the gribtables subdirectory of HIPHOP
5;
6; @categories
7;
8; @param TABLENAME {in}{required}
9; The full path name of a gribtable file
10;
11; @keyword PARMTABL
12;
13; @keyword CENTER
14;
15; @keyword SUBCENTER
16;
17; @keyword TABLNUM
18;
19; @returns
20;
21; @uses
22;
23; @restrictions
24;
25; @examples
26;
27;   IDL> tablename='ectab_128'
28;
29; @history
30; Dominik Brunner, Apr 2000
31;
32; @version
33; $Id$
34;-
35PRO read_gribtable, tablename, PARMTABL=parmtabl, CENTER=center,$
36                   SUBCENTER=subcenter, TABLNUM=tablnum
37;
38  compile_opt idl2, strictarrsubs
39;
40
41ON_ERROR,2
42
43parmtabl=StrArr(3,256)
44center=-1
45subcenter=-1
46tablnum=-1
47; First Subscript (3) is [name,description,units]
48; Second  (256) is defined size of a parameter table
49
50IF n_elements(tablename) EQ 0 THEN return
51
52openr,lun,tablename,/get
53
54line=''
55; read first line which (eventually) contains information
56; about center, subcenter and table number
57readf,lun,line
58parts=STR_SEP(line,':')
59IF n_elements(parts) GT 3 THEN BEGIN
60  center=fix(parts[1])
61  subcenter=fix(parts[2])
62  tablnum=fix(parts[3])
63ENDIF ELSE BEGIN
64  IF n_elements(parts) GE 3 THEN parmtabl[0:1,fix(parts[0])]=parts[1:2] $
65  ELSE IF n_elements(parts) EQ 2 THEN parmtabl[0,fix(parts[0])]=parts[1]
66ENDELSE
67
68; loop over remaining lines
69REPEAT BEGIN
70  readf,lun,line
71  parts=STR_SEP(line,':')
72  IF n_elements(parts) GE 3 THEN parmtabl[0:1,fix(parts[0])]=parts[1:2] $
73  ELSE IF n_elements(parts) EQ 2 THEN parmtabl[0,fix(parts[0])]=parts[1]
74END UNTIL EOF(lun)
75
76free_lun,lun
77
78; fill up missing variable names
79index=WHERE(parmtabl[0,*] EQ '',count)
80IF count GT 0 THEN parmtabl[0,index]='var'+strcompress(index,/rem)
81
82END
Note: See TracBrowser for help on using the repository browser.