Re: [netcdf-porting] Matlab unable to call netcdf using '!'

NOTE: The netcdf-porting mailing list is no longer active. The list archives are made available for historical reasons.

On Sat, 14 Apr 2012 00:04:11 -0400, Andrew Friedman <andfried@xxxxxxxxxxxx> wrote:

Hi everyone,

This is my first time posting to a netcdf listserve - please let me know if another list would be more suitable for my question.

I am running netcdf 4.2 on Mac OS 10.7.3, installed via macports.

When I am in the shell (tcsh) on my Mac, I am able to use netcdf libraries. For example:

ncdump -h

However, in Matlab, the same command preceded by the '!' (which is supposed to directly invoke the shell) generates an error:

!ncdump -h
dyld: Library not loaded: /opt/local/lib/libnetcdf.7.dylib
 Referenced from: /opt/local/bin/ncdump
Reason: Incompatible library version: ncdump requires version 10.0.0 or later, but libnetcdf.7.dylib provides version 9.0.0 Trace/BPT trap
ncdump -h Trace/breakpoint trap

I'm unable to figure out why the command preceded by '!' in Matlab does not invoke the same netcdf libraries. I have many matlab scripts that invoke netcdf from the command line, so this is an important issue for me. I changed my Matlab search path to include the MacPorts directories, but that doesn't help.

Any ideas? I'm running Matlab R2012a (

Thanks for any suggestions,

Andrew Friedman
Graduate Student, UC Berkeley Geography

netcdf-porting mailing list
For list information, to unsubscribe, visit:

[Replying to the group]

MATLAB ships with a version of the netcdf library, it appears that a !ncdump is trying to use MATLAB's version of the library.

You mentioned you changed the 'Matlab search' path. This only effects what files the MATLAB interpreter can see. When you use a ! or the system command MATLAB passes the command on to the OS, where the MATLAB search path has no bearing. In Linux (I assume Mac's are similar), the shell environment variables like $PATH (for executables) and $LD_LIBRARY_PATH (for corresponding shared libraries) call the shots.

I guess setting the environment LD_LIBRARY_PATH equivalent for the Mac (DYLD_PATH?) to point to your local install might help. (


PS1: might be useful too.

  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-porting archives: