pro netcdf_reader, infile, outfile ; William Johnston ; Computational Physics Inc ; For Naval Research Laboratory, Remote Sensing Division (Windsat) Code 7223 ; ; This procedure reads all variables from the netcdf file INFILE ; then saves them in an IDL save file called OUTFILE ; After calling this procedure, type RESTORE,OUTFILE to reload it into IDL ; Note: this will overwrite any variables you have with identical names ; ; Since we don't know what variables (or even how many) are in the file, ; resaving them in an easily readable format is the best we can do if n_elements(outfile) eq 0 then outfile = infile + '.dat' fileid=ncdf_open(infile) ;ncdf_varget,fileid,ncdf_varid(fileid,'wind_speed'),wind_speed ; { NDIMS:0L, NVARS:0L, NGATTS:0L, RECDIM:0L } nc_ct = ncdf_inquire(fileid) ; ATTNAME = NCDF_ATTNAME( Cdfid [, Varid] , Attnum [, /GLOBAL]) ; NCDF_DIMINQ, Cdfid,Dimid, Name,Size ; in: Cdfid,Dimid, out: Name,Size ; Result = NCDF_VARINQ(Cdfid, Varid) ; { NAME:"", DATATYPE:"", NDIMS:0L, NATTS:0L, DIM:LONARR(NDIMS) } names=strarr(nc_ct.nvars) for i=0,nc_ct.nvars-1 do begin names[i] = (ncdf_varinq(fileid,i)).name res = execute("ncdf_varget,fileid," + strtrim(i,2) + ',' + names[i]) endfor res = execute("save," + strjoin(names,',') + ",filename='" + outfile + "'") end