source: trunk/SRC/ReadWrite/idl-NetCDF/ncdf_listvars.pro @ 361

Last change on this file since 361 was 308, checked in by smasson, 17 years ago

minor improvement

  • Property svn:keywords set to Id
File size: 953 bytes
Line 
1;+
2; @file_comments
3; give back the liste of variables included in a NetCDF file
4;
5; @categories
6; NetCDF
7;
8; @param input {in}{required}{type=salar string or long integer}
9; the name of the file or its Id (defined by a previus call to
10; ncdf_open or ncdf_create)
11; Note that if input corresponds to the file name, ncdf_listvars will
12; open and close the file automatically.
13;
14; @returns
15; a vector string containing the name of the variables
16;
17; @examples
18; IDL> varnames = ncdf_listvars('toto.nc')
19;   or
20; IDL> i=ncdf_open('toto.nc')
21; IDL> varnames = ncdf_listvars(id)
22;
23; @history
24;
25;
26; @version
27; $Id$
28;
29;-
30FUNCTION ncdf_listvars, input
31;
32  compile_opt idl2, strictarrsubs
33;
34  IF size(input, /type) EQ 7 THEN ncid = ncdf_open(input) ELSE ncid = input
35 
36  n = (ncdf_inquire(ncid)).nvars
37  names = strarr(n)
38  for i = 0, n-1 do names[i] = (ncdf_varinq(ncid, i)).name
39 
40  IF size(input, /type) EQ 7 THEN ncdf_close, ncid
41
42  return, names
43 
44END
Note: See TracBrowser for help on using the repository browser.