function read_global_attr,filename,attrname,attrdata ; This function reads the named global attribute from the specified file which is written ; in the HDF or HDF-EOS format. ; ; INPUT PARAMETERS: ; filename - the full path and file name of the data file containing the attribute to ; be read ; attrname - the name of the global attribute to be read ; ; OUTPUT PARAMETERS ; attrdata - the variable in which the attribiute's value is returned ;; ; FUNCTION RETURN VALUE ; A value of 0 is returned if the read operation was successsful; -1 is returned ; in the case of failure. A message dialog box is also displayed to indicate the ; source of the failure. ; ; USAGE EXAMPLE ; ; filename = DIALOG_PICKFILE(TITLE="Select MISR Level 2 Aerosol File") ; status = read_global_attr(filename,'Start_block',start_block) sdid = HDF_SD_START(filename, /READ) if (sdid lt 0) then begin msg_text = "Problem opening data file " + filename goto, error endif attrindex = HDF_SD_ATTRFIND(sdid,attrname) if (attrindex lt 0) then begin msg_text = "Problem getting attribute index for " + attrname goto, error endif HDF_SD_ATTRINFO, sdid, attrindex, data=attrdata HDF_SD_END,sdid return,0 error: status = DIALOG_MESSAGE(msg_text,/INFORMATION,TITLE='read_global_attr message') attrdata = 0 return,-1 end