pro ncdfshow,outfile
; this procedure will read and display the attributes
; for every variable found in a netCDF file
; input file will be found by an interactive search
; output file will be text of the information gathered.
; COMMAND LINE USAGE: > ncdfshow,'outfilename'
; note that 'outfilename' is a string and must be in quotes.
; With the outfile information in hand, the data can be retrieved
; using the commands below, with user input marked by '*'
; and input from the outfile marked by '#'
; the user must supply variable names to store the ID numbers
; created for the file and variable...'fileID' and 'varID' are used here.
; the user must also supply the name of a variable in which to put the data.
; here this is called 'variable_array', but any name would work.
; fileID = NCDF_OPEN('filename'*)
; varID = NCDF_VARID(fileID, 'varname'#)
; NCDF_VARGET, fileID, varID, variable_array
; note that 'filename' and 'varname' are strings and must be in quotes
; 'varname' must be exactly as provided in the netCDF file

netcdf_directory = '/Users/brianvanthull/GOES/'

; open the output file

; find input file and produce a file ID
filename = dialog_pickfile(path=netcdf_directory)
fileID = ncdf_open(filename)

;find the number of variables
fileinq_struct = ncdf_inquire(fileID)
nvars = fileinq_struct.nvars

; print output so far
printf,1, nvars, ' variables in file'
printf,1, ' '
printf,1, ' '

;loop through variables
for varndx = 0,nvars-1 do begin

   ; get the name, datatype, dims, number of attributes
     varstruct = ncdf_varinq(fileID,varndx)

   ; print the variable index, name, datatype, dims
     printf,1, '--------------------------------------------------------'
     printf,1,varndx,'    ',, '     ',varstruct.datatype
     printf,1,'dims = ',varstruct.dim

   ; loop through attributes
     for attndx = 0, varstruct.natts-1 do begin

       ; get attribute name, then use it to get the value
         attname = ncdf_attname(fileID,varndx,attndx)

       ; print name and value to file
         printf,1,attname, '     ',string(value)
     endfor ; attribute loop

endfor ; variable loop

; close in and out files

print,'output saved as ',netcdf_directory+outfile