NCL Home > Documentation > Functions > Group query, File I/O

getfilegrpnames

Returns an array of file group names on the given file.

Available in version 6.1.1 and later.

Prototype

	function getfilegrpnames (
		thefile [1] : 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.

Return value

This function returns an array of strings with each element containing the name of a group. The length of this array is equal to the number of groups in the file.

Description

This function is useful when accessing file groups by string name. (See Files.)

See Also

filegrpdef

Functions marked with * indicate ones added in NCL V6.5.0.

Variable query functions:

getvaratts
getvardimsizes*
getvardimnames*
getvardims

File query functions:

getfiledimsizes
getfiledimnames*
getfiledims*
getfileatts*

Variable on file query functions:

getfilevarnames
getfilevardimsizes
getfilevardimnames*
getfilevardims
getfilevartypes
isfilevardim
isfilevaratt
isfilevarcoord
isfilevardim

Examples

The following example gets all the group names from a netCDF file but it will also work for any file referenced by addfile. The dollar sign syntax used in this example is described at "NCL Variables".

    f = addfile ("X.nc" , "r")   ; could also have ccm, grb or hdf suffux
    gNames = getfilegrpnames (f) ; get names of all groups on file
      
    nNames = dimsizes (gNames)   ; number of groups on the file
      
    print (nNames)               ; print all group names on file
      
    do n=0,nNames-1              ; loop thru each group
       g = f=>$gNames(n)$        ; read the group to memory
         
       [SNIP]
         
       delete (g)
   end do