pro netcdfshow,filename ; fileID = ncdf_open(filename) ; ;find the number of variables fileinq_struct = ncdf_inquire(fileID) nvars = fileinq_struct.nvars ; print,filename ; print,filename print, nvars, ' variables in file' ; 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 print, '--------------------------------------------------------' print,varndx,' ',varstruct.name, ' ',varstruct.datatype print,'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) ncdf_attget,fileID,varndx,attname,value ; print name and value to file print,attname, ' ',string(value) endfor endfor ; attribute loop end ; pro netcdfread_era, filename, variable_name, data_variable, scale_factor, add_offset, dims ; This procedure will read netCDF data and place it in an IDL variable ; INPUT: filename - a string variable that includes the filepath ; variable_name - a string that must match exactly that produced by ; ncdfshow.pro ; OUTPUT: data_variable - a user supplied variable for the data ; dims - a vector of the dimensions ; get fileID, variable ID fileID = ncdf_open(filename) varID = ncdf_varid(fileID,variable_name) ; get the data and dimensions ncdf_varget,fileID, varID, data_variable ncdf_attget,fileID, varID, 'scale_factor', scale_factor ncdf_attget,fileID, varID, 'add_offset', add_offset dims = size(data_variable,/dimensions) end ;--------------------- ;---LMDZ pro netcdfread, filename,variable_name, data_variable, dims ; This procedure will read netCDF data and place it in an IDL variable ; INPUT: filename - a string variable that includes the filepath ; variable_name - a string that must match exactly that produced by ; ncdfshow.pro ; OUTPUT: data_variable - a user supplied variable for the data ; dims - a vector of the dimensions ; get fileID, variable ID fileID = ncdf_open(filename) varID = ncdf_varid(fileID,variable_name) ; get the data and dimensions ncdf_varget,fileID, varID, data_variable dims = size(data_variable,/dimensions) end ;---------------------