NCL Home > Documentation > Functions > Metadata routines

getfiledimnames

Returns a list of dimension names for the given file.

Available in version 6.5.0 and later.

Prototype

	function getfiledimnames (
		thefile  : file   
	)

	return_val [*] :  string

Arguments

thefile

A reference to a file created from a call to addfile or addfiles. The file referenced must be one in the supported file format list.

Description

This function returns a list of dimension names on a given supported file that was opened with addfile or addfiles. If a dimension is not named, then this function returns the default missing value for a string for that dimension.

Note: since addfiles returns a variable of type "list", you must subscript the list before calling this function. See the examples below.

If the dimension sizes are also desired, then getfiledimsizes returns the dimension sizes in the same order as the dimension names returned from this function.

This function is an alias for getvardims. It was created for consistency and meaningfulness with other getfilexxxx functions. See the NCL file I/O list for a full list of functions and procedures associated with file input/output.

See Also

getfiledimsizes, getfileatts, getfilevarnames, getfilevardimsizes, getfilevardimnames, getfilevaratts, getfilevartypes, getvardimnames, addfile, addfiles

Examples

Example 1

Assume you have a netCDF file where "ncdump -h 0360-01.nc" yields:

  netcdf 0360-01 {
  dimensions:
    time = UNLIMITED ; // (1 currently)
    nlon = 320 ;
    nlat = 384 ;
    z_t = 40 ;
    z_w = 40 ;
    tracers = 2 ;
    nchar = 80 ;
    d2 = 2 ;
    [SNIP]

To retrieve the dimension names from the file, you can use the following code snippet. You can also use the equivalent function, getfiledimnames:

  f      = addfile ("0360-01.nc" , "r")
  dNames = getfiledimnames(f)     ; NCL V6.5.0 and later
; dNames = getvardims(f)          ; NCL V6.4.0 and earlier
  dSizes = getfiledimsizes(f)  
  print (dNames+"   "+dSizes)
Output:

   time       1
   nlon     320
   nlat     384
   z_t       40
   z_w       40
   tracers    2
   nchar     80
   d2         2

Example 2

To return the dimension names on one line, use str_join:

  f      = addfile ("slp_1988mm.nc","r")
  dNames = getfiledimnames(f)     ; NCL V6.5.0 and later
; dNames = getvardims(f)          ; NCL V6.4.0 and earlier
  dSizes = getfiledimsizes(f)
  print (str_join(dNames,", "))
  print (str_join(""+dSizes," x "))
Output:

     lat, lon, time
     73 x 144 x 12