CDF_CREATE

The CDF_CREATE function creates a new Common Data Format file with the given filename and dimensions. If successful, this function returns the CDF ID for the new file.

Note that when you create a CDF file, you must specify both encoding and decoding methods. Encoding specifies the method used to write data to the CDF file. Decoding specifies the method used to retrieve data from the CDF file and pass it to an application (IDL, for example). Encoding and decoding methods are specified by setting the XXX _ENCODING and XXX _DECODING keywords to CDF_CREATE. If no decoding method is specified, the decoding method is set to be the same as the encoding method.

All CDF encoding and decodings can be written or read on all platforms, but matching the encoding with the architecture used provides the best performance. If you work in a single-platform environment most of the time, select HOST_ENCODING for maximum performance. If you know that the CDF file will be transported to a computer using another architecture, specify the encoding for the target architecture or specify NETWORK_ENCODING (the default). Specifying the target architecture provides maximum performance on that architecture; specifying NETWORK_ENCODING provides maximum flexibility.

For more discussion on CDF encoding/decoding methods and combinations, see sections 2.2.7 ("Encoding") and 2.2.8 ("Decoding") of the version 2.6 CDF User's Guide .

Calling Sequence

Result = CDF_CREATE( Filename , [ Dimensions ])

Arguments

Filename

A scalar string containing the name of the file to be created. Note that if the desired filename has a .cdf ending, you can omit the extension and specify just the first part of the filename. For example, specifying "mydata" would open the file mydata.cdf .

Dimensions

A vector of values specifying size of each rVariable dimension. If no dimensions are specified, then the file will contain a single scalar per record (i.e., a 0-dimensional CDF).

Keywords

ALPHAOSF1_ENCODING
ALPHAOSF1_DECODING

Set this keyword to indicate DEC ALPHA/OSF1 data encoding/decoding.

ALPHAVMSD_ENCODING
ALPHAVMSD_DECODING

Set this keyword to indicate DEC ALPHA/VMS data encoding/decoding using Digital's D_FLOAT representation.

ALPHAVMSG_ENCODING
ALPHAVMSG_DECODING

Set this keyword to indicate DEC ALPHA/VMS data encoding/decoding using Digital's G_FLOAT representation.

CLOBBER

Set this keyword to erase the existing file (if the file already exists) before creating the new version. Note that if the existing file has been corrupted, the CLOBBER operation may fail, causing IDL to display an error message. In this case you must manually delete the existing file from outside IDL.

COL_MAJOR

Set this keyword to specify column major (IDL-like) array ordering for variable storage.

HOST_ENCODING
HOST_DECODING

Set this keyword to select that the file will use native data encoding/decoding.

HP_ENCODING
HP_DECODING

Set this keyword to select HP 9000 data encoding/decoding.

IBMRS_ENCODING
IBMRS_DECODING

Set this keyword to select IBM RS/6000 series data encoding/decoding.

IBMPC_ENCODING
IBMPC_DECODING

Set this keyword to select IBM PC data encoding/decoding.

SGI_ENCODING
SGI_DECODING

Set this keyword to select SGI (MIPSEB) data encoding/decoding (Silicon Graphics Iris and Power series).

DECSTATION_ENCODING
DECSTATION_DECODING

Set this keyword to select Decstation (MIPSEL) data encoding/decoding.

MAC_ENCODING
MAC_DECODING

Set this keyword to select Macintosh data encoding/decoding.

MULTI_FILE

Set this keyword to cause all CDF control information and attribute entry data to be placed in one .cdf file, with a separate file created for each defined variable. If the variable in an rVariable, then the variable files will have extensions of .v0 , .v1 , etc. ; zVariables will be stored in files with extensions of .z0 , .z1 , etc. This is the default format, and is usually more efficient than the SINGLE_FILE format. See section 2.2.7 ("Format") in the version 2.6 CDF User's Guide for more information. If both SINGLE_FILE and MULTI_FILE are set the file will be created in the MULTI_FILE format.

MULTI_FILE Example:

id=CDF_CREATE('multi', /MULTI_FILE)

CDF_CONTROL, id, GET_FORMAT=cdf_format

HELP, cdf_format

IDL prints:

CDF_FORMAT STRING = 'MULTI_FILE'

NETWORK_ENCODING
NETWORK_DECODING

Set this keyword to select network-transportable data encoding/decoding (XDR). This is the default method.

NEXT_ENCODING
NEXT_DECODING

Set this keyword to select NeXT data encoding/decoding.

ROW_MAJOR

Set this keyword to specify row major (C-like) array ordering for variable storage. This is the default.

SINGLE_FILE

Set this keyword to cause all CDF information (control information, attribute entry data, variable data, etc.) to be written to a single .cdf file. The default is to use the MULTI_FILE format where a separate file is created for each variable. See section 2.2.7 ("Format") of the version 2.6 CDF User's Guide for more information.

SUN_ENCODING
SUN_DECODING

Set this keyword to select SUN data encoding/decoding.

Example

Use the following command to create a 10-element by 20-element CDF using network encoding and Sun decoding:

id = CDF_CREATE('cdf_create.cdf', [10,20], /NETWORK_ENCODING, $

    /SUN_DECODING)

..... ; other cdf commands.

CDF_CLOSE, id ; close the file.

Now suppose that we decide to use HP_DECODING instead. We can use the CLOBBER keyword to delete the existing file when creating the new file:

id = CDF_CREATE('cdf_create.cdf', [10,20], /NETWORK_ENCODING, $

    /HP_DECODING, /CLOBBER)

..... ; other cdf commands.

CDF_CLOSE, id ; close the file.

The new file is written over the existing file. Use the following command to delete the file:

CDF_DELETE, id