pro read_ncvar, infile, dn, d, cb_title, mns, mxs ;==================================================== ; Check arguments ;==================================================== if n_elements(infile) eq 0 then begin print, 'Provide input file name' progexit endif dummy = findfile(infile, count=count) if (count eq 0) then begin print,'Input file: '+infile+' cannot be found' progexit endif ;open the netcdf file ncid = ncdf_open(infile) ;if variable name not entered ;write out the variable id and name ;THEN have the user choose if n_elements(dn) eq 0 then begin get_ncdf_varnum, ncid, vid endif else begin ;ELSE get the data variable requested vid = ncdf_varid( ncid, dn) endelse ;read in the data from the netcdf file ncdf_varget, ncid, vid, val ; transform val if it is an array with 2+ dimensions ndim = size(val,/n_dimensions) if ndim gt 1 then begin d = transpose( val ) endif else begin d = val endelse ;get the long variable name ncdf_attget, ncid, vid, 'long_name', cb_title ;get the plot range min and max if variable has plot_range varinq = ncdf_varinq( ncid, vid ) if varinq.natts gt 3 then begin ncdf_attget, ncid, vid, 'plot_range', val mns = val[0] mxs = val[1] endif ;close the netcdf file ncdf_close, ncid ;======================================== return end