1 | ;+ |
---|
2 | ; NAME: |
---|
3 | ; read_gribtable |
---|
4 | ; |
---|
5 | ; PURPOSE: |
---|
6 | ; Read contents of a gribtable. Gribtables are located |
---|
7 | ; in the gribtables subdirectory of HIPHOP |
---|
8 | ; |
---|
9 | ; CATEGORY: |
---|
10 | ; HIPHOP, GRIB, ECMWF |
---|
11 | ; |
---|
12 | ; CALLING SEQUENCE: |
---|
13 | ; read_gribtable,tablename,parmtabl=parmtabl |
---|
14 | ; |
---|
15 | ; EXAMPLE: |
---|
16 | ; tablename='ectab_128' |
---|
17 | ; |
---|
18 | ; INPUTS: |
---|
19 | ; tablename : the full path name of a gribtable file |
---|
20 | ; |
---|
21 | ; OPTIONAL INPUT PARAMETERS: |
---|
22 | ; |
---|
23 | ; KEYWORD INPUT PARAMETERS: |
---|
24 | ; |
---|
25 | ; OUTPUTS: |
---|
26 | ; parmtable : the parameter table |
---|
27 | ; |
---|
28 | ; COMMON BLOCKS: |
---|
29 | ; |
---|
30 | ; SIDE EFFECTS: |
---|
31 | ; |
---|
32 | ; RESTRICTIONS: |
---|
33 | ; |
---|
34 | ; PROCEDURE: |
---|
35 | ; |
---|
36 | ; MODIFICATION HISTORY: |
---|
37 | ; |
---|
38 | ; Dominik Brunner, Apr 2000 |
---|
39 | ;- |
---|
40 | PRO read_gribtable,tablename,parmtabl=parmtabl,center=center,$ |
---|
41 | subcenter=subcenter,tablnum=tablnum |
---|
42 | |
---|
43 | ON_ERROR,2 |
---|
44 | |
---|
45 | parmtabl=StrArr(3,256) |
---|
46 | center=-1 |
---|
47 | subcenter=-1 |
---|
48 | tablnum=-1 |
---|
49 | ; First Subscript (3) is [name,description,units] |
---|
50 | ; Second (256) is defined size of a parameter table |
---|
51 | |
---|
52 | IF n_elements(tablename) EQ 0 THEN return |
---|
53 | |
---|
54 | openr,lun,tablename,/get |
---|
55 | |
---|
56 | line='' |
---|
57 | ; read first line which (eventually) contains information |
---|
58 | ; about center, subcenter and table number |
---|
59 | readf,lun,line |
---|
60 | parts=STR_SEP(line,':') |
---|
61 | IF n_elements(parts) GT 3 THEN BEGIN |
---|
62 | center=fix(parts[1]) |
---|
63 | subcenter=fix(parts[2]) |
---|
64 | tablnum=fix(parts[3]) |
---|
65 | ENDIF ELSE BEGIN |
---|
66 | IF n_elements(parts) GE 3 THEN parmtabl[0:1,fix(parts[0])]=parts[1:2] $ |
---|
67 | ELSE IF n_elements(parts) EQ 2 THEN parmtabl[0,fix(parts[0])]=parts[1] |
---|
68 | ENDELSE |
---|
69 | |
---|
70 | ; loop over remaining lines |
---|
71 | REPEAT BEGIN |
---|
72 | readf,lun,line |
---|
73 | parts=STR_SEP(line,':') |
---|
74 | IF n_elements(parts) GE 3 THEN parmtabl[0:1,fix(parts[0])]=parts[1:2] $ |
---|
75 | ELSE IF n_elements(parts) EQ 2 THEN parmtabl[0,fix(parts[0])]=parts[1] |
---|
76 | END UNTIL EOF(lun) |
---|
77 | |
---|
78 | free_lun,lun |
---|
79 | |
---|
80 | ; fill up missing varible names |
---|
81 | index=WHERE(parmtabl[0,*] EQ '',count) |
---|
82 | IF count GT 0 THEN parmtabl[0,index]='var'+strcompress(index,/rem) |
---|
83 | |
---|
84 | END |
---|