pro makeindexlbl ; Paul Withers, 2008.01.18 ; Center for Space Physics, Boston University ; Make INDEX.LBL file common bigpdsblock ;maxstrlen = bigpdsstruct.maxstrlen ;blankline = bigpdsstruct.blankline outfile = bigpdsstruct.outfileindexlbl preamble = strarr(21) junk='' i=0L openr, lun1, 'toplevelpdsdir/INDEX/' + 'INDEX.TAB', /get_lun while not eof(lun1) do begin readf, lun1, junk i=i+1 endwhile free_lun, lun1 nlinesinindextab = strcompress(string(i), /remove_all) ;help, junk ;print, junk contents = str_sep(junk, ',') ncols = n_elements(contents) ; Check this =9 , bigpdsstruct.ncolsindex startpos = lonarr(ncols) i=1 while i lt ncols do begin startpos(i) = total(strlen(contents(0:i-1)))+i if strmid(contents(i),1,1) eq '"' then startpos(i)=startpos(i)+1 ; strmid(contents(i),XXX,1) has XXX=1 because of a leading space ; Add one for the " i=i+1 endwhile startpos(1:*) = startpos(1:*)+2 ; adding on the ", " comma/space startpos(0)=startpos(0)+1 if strmid(contents(0),0,1) eq '"' then startpos(0)=startpos(0)+1 ; strmid(contents(i),XXX,1) has XXX=0 because there is no leading space ; Start byte for all entries, corrected for " usefullength = lonarr(ncols) i=0 while i lt ncols do begin teststring = contents(i) if i ne 0 then teststring = strmid(teststring,1,1e8) if strmid(teststring,0,1) eq '"' then teststring = strmid(teststring,1,1e8) if strmid(teststring,strlen(teststring)-1,1) eq '"' then $ teststring = strmid(teststring,0,strlen(teststring)-1) usefullength(i) = strlen(teststring) ;help, teststring i=i+1 endwhile strstartpos = strcompress(string(startpos), /remove_all) strusefullength = strcompress(string(usefullength), /remove_all) preamble(0) = 'PDS_VERSION_ID = PDS3' preamble(1) = 'RECORD_TYPE = FIXED_LENGTH' preamble(2) = 'RECORD_BYTES = 152' preamble(3) = 'FILE_RECORDS = ' + nlinesinindextab preamble(4) = '^INDEX_TABLE = "INDEX.TAB"' preamble(5) = 'PRODUCT_ID = "ODY-ACC-INDEX"' preamble(6) = 'PRODUCT_NAME = "Data File Index for Volume ' + $ bigpdsstruct.volumeid + '"' preamble(7) = 'PRODUCT_CREATION_TIME = ' + $ bigpdsstruct.productcreationdateyyyymmdd preamble(8) = 'DESCRIPTION = "This table contains the PDS-required index for all' preamble(9) = ' data files on ' + $ bigpdsstruct.volumeid + '.' preamble(10) = ' It includes file location, size, and PDS' preamble(11) = ' identification information."' preamble(12) = ' ' preamble(13) = 'OBJECT = INDEX_TABLE' preamble(14) = ' NAME = "Volume Index"' preamble(15) = ' INTERCHANGE_FORMAT = ASCII' preamble(16) = ' ROWS = ' + nlinesinindextab preamble(17) = ' COLUMNS = ' + bigpdsstruct.ncolsindex preamble(18) = ' ROW_BYTES = 152' preamble(19) = ' INDEX_TYPE = SINGLE' preamble(20) = ' ' mainmeat = strarr(85) i=0 objstart = ' OBJECT = COLUMN' objname = ' NAME = ' objdt = ' DATA_TYPE = ' objsb = ' START_BYTE = ' objby = ' BYTES = ' objfm = ' FORMAT = ' objdesc = ' DESCRIPTION = ' objblds = ' ' objend = ' END_OBJECT' countcols=0 mainmeat(i) = objstart & i=i+1 mainmeat(i) = objname + 'PATH_NAME' & i=i+1 mainmeat(i) = objdt + 'CHARACTER' & i=i+1 mainmeat(i) = objsb + strstartpos(countcols) & i=i+1 mainmeat(i) = objby + strusefullength(countcols) & i=i+1 mainmeat(i) = objfm + '"A' + strusefullength(countcols) + '"' & i=i+1 mainmeat(i) = objdesc + '"Path to the given file, in UNIX format (i.e., slashes' & i=i+1 mainmeat(i) = objblds + 'separate directory names)"' & i=i+1 mainmeat(i) = objend & i=i+1 mainmeat(i) = ' ' & i=i+1 countcols=countcols+1 mainmeat(i) = objstart & i=i+1 mainmeat(i) = objname + 'FILE_NAME' & i=i+1 mainmeat(i) = objdt + 'CHARACTER' & i=i+1 mainmeat(i) = objsb + strstartpos(countcols) & i=i+1 mainmeat(i) = objby + strusefullength(countcols) & i=i+1 mainmeat(i) = objfm + '"A' + strusefullength(countcols) + '"' & i=i+1 mainmeat(i) = objdesc + '"Name of the data file, in upper-case, with extension"' & i=i+1 mainmeat(i) = objend & i=i+1 mainmeat(i) = ' ' & i=i+1 countcols=countcols+1 mainmeat(i) = objstart & i=i+1 mainmeat(i) = objname + 'PRODUCT_ID' & i=i+1 mainmeat(i) = objdt + 'CHARACTER' & i=i+1 mainmeat(i) = objsb + strstartpos(countcols) & i=i+1 mainmeat(i) = objby + strusefullength(countcols) & i=i+1 mainmeat(i) = objfm + '"A' + strusefullength(countcols) + '"' & i=i+1 mainmeat(i) = objdesc + '"Unique product identifier"' & i=i+1 mainmeat(i) = objend & i=i+1 mainmeat(i) = ' ' & i=i+1 countcols=countcols+1 mainmeat(i) = objstart & i=i+1 mainmeat(i) = objname + 'DATA_SET_ID' & i=i+1 mainmeat(i) = objdt + 'CHARACTER' & i=i+1 mainmeat(i) = objsb + strstartpos(countcols) & i=i+1 mainmeat(i) = objby + strusefullength(countcols) & i=i+1 mainmeat(i) = objfm + '"A' + strusefullength(countcols) + '"' & i=i+1 ;mainmeat(i) = objsb + '38' & i=i+1 ;mainmeat(i) = objby + bigpdsstruct.dsibytes & i=i+1 ;mainmeat(i) = objfm + bigpdsstruct.dsiformat & i=i+1 ;;mainmeat(i) = objby + '15' & i=i+1 ;;mainmeat(i) = objfm + '"A15"' & i=i+1 mainmeat(i) = objdesc + 'PDS catalog number which identifies files considered' & i=i+1 mainmeat(i) = objblds + 'part of a single data set"' & i=i+1 mainmeat(i) = ' ' & i=i+1 countcols=countcols+1 mainmeat(i) = objstart & i=i+1 mainmeat(i) = objname + 'TARGET_NAME' & i=i+1 mainmeat(i) = objdt + 'CHARACTER' & i=i+1 mainmeat(i) = objsb + strstartpos(countcols) & i=i+1 mainmeat(i) = objby + strusefullength(countcols) & i=i+1 mainmeat(i) = objfm + '"A' + strusefullength(countcols) + '"' & i=i+1 ;mainmeat(i) = objsb + bigpdsstruct.nullstartbytes & i=i+1 ;;mainmeat(i) = objsb + '53' & i=i+1 ;mainmeat(i) = objby + '6' & i=i+1 ;mainmeat(i) = objfm + '"A6"' & i=i+1 mainmeat(i) = objdesc + '"Target body of observation"' & i=i+1 mainmeat(i) = objend & i=i+1 mainmeat(i) = ' ' & i=i+1 countcols=countcols+1 mainmeat(i) = objstart & i=i+1 mainmeat(i) = objname + 'START_TIME' & i=i+1 mainmeat(i) = objdt + 'CHARACTER' & i=i+1 mainmeat(i) = objsb + strstartpos(countcols) & i=i+1 mainmeat(i) = objby + strusefullength(countcols) & i=i+1 mainmeat(i) = objfm + '"A' + strusefullength(countcols) + '"' & i=i+1 ;mainmeat(i) = objsb + bigpdsstruct.nullstartbytes & i=i+1 ;;mainmeat(i) = objsb + '59' & i=i+1 ;mainmeat(i) = objby + '25' & i=i+1 ;mainmeat(i) = objfm + '"A25"' & i=i+1 mainmeat(i) = objdesc + '"UTC start time of observation"' & i=i+1 mainmeat(i) = objend & i=i+1 mainmeat(i) = ' ' & i=i+1 countcols=countcols+1 mainmeat(i) = objstart & i=i+1 mainmeat(i) = objname + 'STOP_TIME' & i=i+1 mainmeat(i) = objdt + 'CHARACTER' & i=i+1 mainmeat(i) = objsb + strstartpos(countcols) & i=i+1 mainmeat(i) = objby + strusefullength(countcols) & i=i+1 mainmeat(i) = objfm + '"A' + strusefullength(countcols) + '"' & i=i+1 ;mainmeat(i) = objsb + bigpdsstruct.nullstartbytes & i=i+1 ;;mainmeat(i) = objsb + '84' & i=i+1 ;mainmeat(i) = objby + '25' & i=i+1 ;mainmeat(i) = objfm + '"A25"' & i=i+1 mainmeat(i) = objdesc + '"UTC stop time of observation"' & i=i+1 mainmeat(i) = objend & i=i+1 mainmeat(i) = ' ' & i=i+1 countcols=countcols+1 mainmeat(i) = objstart & i=i+1 mainmeat(i) = objname + 'RECORD_BYTES' & i=i+1 mainmeat(i) = objdt + 'ASCII_INTEGER' & i=i+1 mainmeat(i) = objsb + strstartpos(countcols) & i=i+1 mainmeat(i) = objby + strusefullength(countcols) & i=i+1 mainmeat(i) = objfm + '"I' + strusefullength(countcols) + '"' & i=i+1 ;mainmeat(i) = objsb + bigpdsstruct.nullstartbytes & i=i+1 ;;mainmeat(i) = objsb + '109' & i=i+1 ;mainmeat(i) = objby + '5' & i=i+1 ;mainmeat(i) = objfm + '"A5"' & i=i+1 mainmeat(i) = objdesc + '"Number of bytes in a single data record"' & i=i+1 mainmeat(i) = objend & i=i+1 mainmeat(i) = ' ' & i=i+1 countcols=countcols+1 mainmeat(i) = objstart & i=i+1 mainmeat(i) = objname + 'FILE_RECORDS' & i=i+1 mainmeat(i) = objdt + 'ASCII_INTEGER' & i=i+1 mainmeat(i) = objsb + strstartpos(countcols) & i=i+1 mainmeat(i) = objby + strusefullength(countcols) & i=i+1 mainmeat(i) = objfm + '"I' + strusefullength(countcols) + '"' & i=i+1 ;mainmeat(i) = objsb + bigpdsstruct.nullstartbytes & i=i+1 ;;mainmeat(i) = objsb + '114' & i=i+1 ;mainmeat(i) = objby + '6' & i=i+1 ;mainmeat(i) = objfm + '"A6"' & i=i+1 mainmeat(i) = objdesc + '"Number of records in the file"' & i=i+1 mainmeat(i) = objend & i=i+1 mainmeat(i) = ' ' & i=i+1 countcols=countcols+1 mainmeat(i) = 'END_OBJECT = INDEX_TABLE' & i=i+1 mainmeat(i) = ' ' & i=i+1 mainmeat(i) = 'END' & i=i+1 ;help, i i=0 while i lt n_elements(preamble) do begin if strlen(preamble(i)) ge bigpdsstruct.maxstrlen then stop preamble(i) = preamble(i) + bigpdsstruct.blankline junk = strmid(preamble(i),0,bigpdsstruct.maxstrlen) preamble(i) = junk i=i+1 endwhile i=0 while i lt n_elements(mainmeat) do begin if strlen(mainmeat(i)) ge bigpdsstruct.maxstrlen then stop mainmeat(i) = mainmeat(i) + bigpdsstruct.blankline junk = strmid(mainmeat(i),0,bigpdsstruct.maxstrlen) mainmeat(i) = junk i=i+1 endwhile junk='' openw, lun1, outfile, /get_lun i=0 while i lt n_elements(preamble) do begin printf, lun1, preamble(i) i=i+1 endwhile i=0 while i lt n_elements(mainmeat) do begin printf, lun1, mainmeat(i) i=i+1 endwhile free_lun, lun1 end