pro radioflux ON_IOERROR,bail ; Open PREVFLUX.NOA file to verify that it exists filename = !defaults.ephemdir+'prevflux.noa' openr,lun,/get_lun,filename ; Read the relevant lines from the file line = '' datlines = strarr(10) while (not EOF(lun)) do begin readf,lun,line if (strpos(line,':Solar_Radio_Flux:') eq 0) then begin datlines[0] = line readf,lun,line ; Skip next two lines readf,lun,line for i = 0, 8 do begin readf,lun,line datlines[i+1] = line endfor free_lun,lun goto,done endif endwhile bail: ; Error occurred if (lun) then free_lun,lun print,'RADIOFLUX: Error, file '+filename $ +' does not exist or has wrong format' return done: ; PREVFLUX.NOA lines read. Get date mon = '' reads,datlines[0],yr,mon,da,format='(19X,I4,1X,A3,1X,I2)' curdoy = yr+dayofyr(yr,mon,da)/1000. ; Now open database file to append to, RADIOFLUX.NOA, and read date of ; last section ON_IOERROR,bail filename = !defaults.ephemdir+'radioflux.noa' openr,lun,/get_lun,filename hed = strarr(5) readf,lun,hed ; Skip header lines line = '' skiplines = strarr(10) ; Read sections of file until an EOF occurs while (not EOF(lun)) do begin readf,lun,line reads,line,yr,mon,da,format='(19X,I4,1X,A3,1X,I2)' thisdoy = yr+dayofyr(yr,mon,da)/1000. readf,lun,skiplines endwhile free_lun,lun ; THISDOY contains the last DOY of the file, so check that it is ; earlier than the date in the file to be appended. This ensures ; that old files do not get repeatedly appended when something ; goes wrong with retrieving a new file. if (thisdoy ge curdoy) then begin print,'RADIOFLUX: Warning, file PREVFLUX.NOA is an old file. Not appended.' return endif ; Looks okay, so reopen RADIOFLUX.NOA and append the lines openu,lun,/get_lun,filename,/append printf,lun,datlines,format='(a)' printf,lun free_lun,lun return en