Changeset 308 for trunk


Ignore:
Timestamp:
11/05/07 11:20:28 (17 years ago)
Author:
smasson
Message:

minor improvement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/ReadWrite/idl-NetCDF/ncdf_listvars.pro

    r157 r308  
    11;+ 
    22; @file_comments 
     3; give back the liste of variables included in a NetCDF file 
    34; 
     5; @categories  
     6; NetCDF 
    47; 
    5 ; @categories 
    6 ; 
    7 ; 
    8 ; @param NCID 
    9 ;  
     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. 
    1013; 
    1114; @returns 
    12 ; 
    13 ; 
    14 ; @restrictions 
    15 ; 
     15; a vector string containing the name of the variables 
    1616; 
    1717; @examples 
    18 ;  
     18; IDL> varnames = ncdf_listvars('toto.nc') 
     19;   or 
     20; IDL> i=ncdf_open('toto.nc') 
     21; IDL> varnames = ncdf_listvars(id) 
    1922;  
    2023; @history 
     
    2528; 
    2629;- 
    27 FUNCTION ncdf_listvars,ncid 
     30FUNCTION ncdf_listvars, input 
    2831; 
    2932  compile_opt idl2, strictarrsubs 
    3033; 
     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 
    3141 
    32 n=(ncdf_inquire(ncid)).nvars 
    33  
    34 names=strarr(n) 
    35  
    36 for i=0,n-1 do begin 
    37     names[i]=(ncdf_varinq(ncid,i)).name 
    38 endfor 
    39  
    40 return,names 
    41  
    42 end 
     42  return, names 
     43   
     44END 
Note: See TracChangeset for help on using the changeset viewer.