NASA Logo, National Aeronautics and Space Administration
SPDF

CDF (V3.5.0 beta version) Patch for Matlab for Version R2007a and later


If you get error messages reading a CDF file or are not happy with CDF file reading time, we strongly encourage you to download the patch on this page. The patch fixes a lot of problems (see below for details), and it's significantly faster than the cdfread function supplied in all Matlab releases (including Matlab R2007b). Our performance test against a CDF file from the ulysses mission brought the reading time down to 8 seconds from 10 minutes. Please note: this patch applies only for Matlab version R2007a and later. .  CDF logo

The patch available on this page has been sent to the Matlab development team for inclusion into a future Matlab release.

What's Included in the Patch

  • The cdfread routine occasionally chokes on some CDF files and issues an error message "Undefined function or method 'rdivide' for input arguments of type 'cell'.".
  • The cdfinfo and cdfread routines do not understand the CDF_EPOCH16 data type and issue an error message.
  • The cdfread routine doesn't properly handle an array of CDF_EPOCH values.
  • The cdfread routine reads one record at a time instead of reading all the records in one scoop/read. As a result, the variable data reading time, if there are a lot of records to read, will take a long time that may not be acceptable to many users.
  • A couple of new information is included from the cdfinfo module. Both the CDF library version and the patch version are added to the returned structure from the call. Use "help cdfinfo" for information.
  • Some new options were added in cdfread module. Use "help cdfread" for information. Modification was also made so data returned from a 1-D variable can be displayed as M-by-N where M is the number of records and N the number of elements, regardless of file's row/column-major.
  • New options were added to cdfwrite module. Use "help cdfwrite" for information. Also, modified the code so 3-D or more variables can be created properly.
  • A new module: cdfupdate is added. Use "help cdfupdate" for information.
  • A few new modules are added to enhance the functionality and handle the new data types: CDF_INT8 and CDF_TIME_TT2000. New modules are: breakdowntt2000, cdfleapsecondsinfo, computett2000, datenumtott2000, encodett2000, epoch16todatenum, epochtodatenum, parsett2000 and tt2000todatenum.  CDF logo Use "help " for their information.

Download and Installation Instructions

Latest patch created in October 2012 with beta CDF Version 3.5.0 and MATLAB patch version 3.5.0.0. You can enter "cdfinfo()" within matlab to see the CDF library and MATLAB patch versions.  CDF logo

Windows:

  1. Download one of following self-extracting files:
  2. Download leap second table leap second table.
  3. Double-click the downloaded file to extract the files included in the patch to a directory.
  4. Add lib folder in the installed directory to the PATH environment variable:

    set PATH <patch_install_dir>\lib;%PATH%

    where <patch_install_dir> is the installed directory.

  5. Set environment variable CDF_LEAPSECONDSTABLE to the downloaded leap second table. This table will overwrite the hard-coded one embedded in the CDF library. The step is necessary when a new leap second is added and the shared library is not upgraded. Need to set the environment variable when running CDF modules under MATLAB.
  6. Invoke Matlab and issue the following command at the Matlab prompt:

    addpath '<patch_install_dir>'

    For example, if the patch is installed under C:\matlab_cdf350_patch, the command should be

    addpath 'C:\matlab_cdf350_patch'

  7. Use Matlab as usual (e.g. data=cdfread('test.cdf','combinerecords', true)).

Mac OS X:

  1. Download one of the the following compressed tar files:
  2. Download leap second table leap second table.
  3. Move the Matlab-CDF-Patch directory in the downloaded file to the directory you want the patch to be installed under.
  4. Extract the files in the patch using the following command:

    tar zxvf <downloaded compressed tar file>

  5. Set environment variable CDF_LEAPSECONDSTABLE to the downloaded leap second table. This table will overwrite the hard-coded one embedded in the CDF library. The step is necessary when a new leap second is added and the shared library is not upgraded. Need to set the environment variable when running CDF modules under MATLAB.
  6. Invoke Matlab and issue the following command at the Matlab prompt:

    addpath '<patch_install_dir>'

    For example, if the patch is installed under /Users/davidh, the command should be

    addpath '/Users/davidh/Matlab_CDF350_Patch'

  7. Use Matlab as usual (e.g. data=cdfread('test.cdf','combinerecords', true)).

Linux / Solaris:

  1. Download one of the following compressed tar files:

  2. Download leap second table leap second table.
  3. Go to the directory where you want the patch to be installed under.
  4. Extract the files in the patch using the following command:

    tar zxvf <downloaded compressed tar file>

  5. Set environment variable CDF_LEAPSECONDSTABLE to the downloaded leap second table. This table will overwrite the hard-coded one embedded in the CDF library. The step is necessary when a new leap second is added and the shared library is not upgraded. Need to set the environment variable when running CDF modules under MATLAB.
  6. Invoke Matlab and issue the following command at the Matlab prompt:

    addpath '<patch_install_dir>'

    For example, if the patch is installed under /home/davidh, the command should be

    addpath '/home/davidh/matlab_cdf350_patch'

  7. Use Matlab as usual (e.g. data=cdfread('test.cdf','combinerecords', true)).

If you have any questions or encounter problems, please send an email to cdfsupport and we'll respond as soon as possible.