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

Last change on this file since 114 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

  • Property svn:executable set to *
File size: 1.8 KB
Line 
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;-
40PRO read_gribtable,tablename,parmtabl=parmtabl,center=center,$
41                   subcenter=subcenter,tablnum=tablnum
42;
43  compile_opt idl2, strictarrsubs
44;
45 
46ON_ERROR,2
47
48parmtabl=StrArr(3,256)
49center=-1
50subcenter=-1
51tablnum=-1
52; First Subscript (3) is [name,description,units]
53; Second  (256) is defined size of a parameter table
54
55IF n_elements(tablename) EQ 0 THEN return
56
57openr,lun,tablename,/get
58
59line=''
60; read first line which (eventually) contains information
61; about center, subcenter and table number
62readf,lun,line
63parts=STR_SEP(line,':')
64IF n_elements(parts) GT 3 THEN BEGIN
65  center=fix(parts[1])
66  subcenter=fix(parts[2])
67  tablnum=fix(parts[3])
68ENDIF ELSE BEGIN
69  IF n_elements(parts) GE 3 THEN parmtabl[0:1,fix(parts[0])]=parts[1:2] $
70  ELSE IF n_elements(parts) EQ 2 THEN parmtabl[0,fix(parts[0])]=parts[1]
71ENDELSE
72
73; loop over remaining lines
74REPEAT BEGIN
75  readf,lun,line
76  parts=STR_SEP(line,':')
77  IF n_elements(parts) GE 3 THEN parmtabl[0:1,fix(parts[0])]=parts[1:2] $
78  ELSE IF n_elements(parts) EQ 2 THEN parmtabl[0,fix(parts[0])]=parts[1]
79END UNTIL EOF(lun)
80
81free_lun,lun
82
83; fill up missing varible names
84index=WHERE(parmtabl[0,*] EQ '',count)
85IF count GT 0 THEN parmtabl[0,index]='var'+strcompress(index,/rem)
86
87END
Note: See TracBrowser for help on using the repository browser.