[67] | 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 |
---|
[114] | 42 | ; |
---|
| 43 | compile_opt idl2, strictarrsubs |
---|
| 44 | ; |
---|
[67] | 45 | |
---|
| 46 | ON_ERROR,2 |
---|
| 47 | |
---|
| 48 | parmtabl=StrArr(3,256) |
---|
| 49 | center=-1 |
---|
| 50 | subcenter=-1 |
---|
| 51 | tablnum=-1 |
---|
| 52 | ; First Subscript (3) is [name,description,units] |
---|
| 53 | ; Second (256) is defined size of a parameter table |
---|
| 54 | |
---|
| 55 | IF n_elements(tablename) EQ 0 THEN return |
---|
| 56 | |
---|
| 57 | openr,lun,tablename,/get |
---|
| 58 | |
---|
| 59 | line='' |
---|
| 60 | ; read first line which (eventually) contains information |
---|
| 61 | ; about center, subcenter and table number |
---|
| 62 | readf,lun,line |
---|
| 63 | parts=STR_SEP(line,':') |
---|
| 64 | IF n_elements(parts) GT 3 THEN BEGIN |
---|
| 65 | center=fix(parts[1]) |
---|
| 66 | subcenter=fix(parts[2]) |
---|
| 67 | tablnum=fix(parts[3]) |
---|
| 68 | ENDIF 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] |
---|
| 71 | ENDELSE |
---|
| 72 | |
---|
| 73 | ; loop over remaining lines |
---|
| 74 | REPEAT 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] |
---|
| 79 | END UNTIL EOF(lun) |
---|
| 80 | |
---|
| 81 | free_lun,lun |
---|
| 82 | |
---|
| 83 | ; fill up missing varible names |
---|
| 84 | index=WHERE(parmtabl[0,*] EQ '',count) |
---|
| 85 | IF count GT 0 THEN parmtabl[0,index]='var'+strcompress(index,/rem) |
---|
| 86 | |
---|
| 87 | END |
---|