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