Routines (alphabetical) > Routines: N > NCDF Routines > NCDF_GROUPDEF

# NCDF_GROUPDEF

The NCDF_GROUPDEF function creates a new empty group and assigns it a name.

The NetCDF 4 format allows you to create groups within data files to better organize the data within the file. After defining a group, you can define variables, attributes, and dimensions within the group.

## Examples

The following example creates a NCDF 4 file in IDL’s current working directory, and adds parent and child groups to the file.

; Create a file in IDL's current working directory
filename = FILEPATH('nc_groupdef_file.nc')
id = NCDF_CREATE(filename, /NETCDF4_FORMAT, /CLOBBER)
; Create two groups at the root level of the file
g1 = NCDF_GROUPDEF(id, 'group1')
g2 = NCDF_GROUPDEF(id, 'group2')
; Create a child group inside of the two
; previously-created groups
g11 = NCDF_GROUPDEF(g1, 'group1-sub1')
g21 = NCDF_GROUPDEF(g2, 'group2-sub1')
NCDF_CLOSE, id

## Syntax

Result = NCDF_GROUPDEF( Cdfid, Name )

## Return Value

Returns the ID of the newly-created group.

## Arguments

### Cdfid

The NetCDF ID of the parent group, returned from a previous call to NCDF_OPEN, NCDF_CREATE, or NCDF_GROUPDEF.

### Name

A scalar string containing the new group name.

## Keywords

None

## Version History

8.0 | Introduced

## See Also

NCDF_DIMIDSINQ, NCDF_FULLGROUPNAME, NCDF_GROUPNAME, NCDF_VARIDSINQ