Main Content


Number of multifile cache buffers


numBuffers = cdflib.getVarCacheSize(cdfId,varNum)


numBuffers = cdflib.getVarCacheSize(cdfId,varNum) returns the number of cache buffers used for a variable in a Common Data Format (CDF) file.

cdfId identifies the CDF file. varNum is a numeric value that identifies the variable. Variable identifiers are zero-based.

This function applies only to multifile format CDFs. For more information about caching, see the CDF User's Guide.


Create a multifile CDF and retrieve the number of buffers being used for a variable. To run this example, you must be in a writable folder.

cdfId = cdflib.create("your_file.cdf");

% Set the format of the file to be multi-file

% Create a variable in the file
varNum = cdflib.createVar(cdfId,"Time","cdf_int1",1,[],true,[]);

% Note how the library creates a separate file for the variable
ls your_file.*
your_file.cdf  your_file.z0   
% Determine the number of cache buffers used with the variable
numBuf = cdflib.getVarCacheSize(cdfId,varNum)
numBuf =

% Clean up
clear cdfId


This function corresponds to the CDF library C API routine CDFgetzVarCacheSize.

To use this function, you must be familiar with the CDF C interface. You can access the CDF documentation at the CDF website.