Code covered by the BSD License  

Highlights from
NetCDF/GRIB reader

Be the first to rate this file! 51 Downloads (last 30 days) File Size: 5.57 MB File ID: #21579

NetCDF/GRIB reader

by

 

25 Sep 2008 (Updated )

A collection of functions to read GRIB and netCDF files

| Watch this File

File Information
Description

MATLAB-CDI is a collection of MATLAB functions that import/read GRIB and netCDF files through high-level function calls that follows an unified syntax. The package supports a subset of the full GRIB and netCDF format specification typically produced by climate models.

Technically speaking, MATLAB-CDI consists of mex-interfaces to the CDI library that read GRIB/netCDF. CDI is the basic library underlying the famous CDO (Climate Data Operators) developed by Max-Planck Institut für Meteorologie in Hamburg. The MATLAB-CDI interface package has been developed by The MathWorks Consulting on behalf of the Rossby Centre, SMHI.

MATLAB-CDI has been compiled and tested under Linux and Windows. The Linux installation is straightforward, while the Windows installation in the worst case requires experience of how to compile and install programs in a Linux-like environment such as cygwin or MinGW. (Actually, it's not the MATLAB-CDI package that causes the problems, it's the netCDF and CDI libraries that need to be compiled under Windows, nothing for the faint-of-heart.)

MATLAB release MATLAB 7.3 (R2006b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
10 Jun 2014 Juan

Hello, when I try to compile it, I have this error:
>> compile
COMPILING cdi_varlist...

C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL: Error: Could not find specified options file
'lib-mingw/mexopts.bat'.

Error using mex (line 206)
Unable to complete successfully.

Error in compile (line 41)
mex -f lib-mingw/mexopts.bat cdi_varlist.c cdi_mx.c -Iinclude -Llib-mingw -lcdi -lnetcdf

Any idea to fix it? Thanks you very much!

20 May 2014 Ian Dragaud

How can i save grib file?

04 Apr 2014 Megan

I use this program all the time in MATLAB R2012a - works great for me.
Question: Can someone please direct me to an example nametable? I have a nametable I am trying to use, but everytime I try to reference it in my code, I get an error that states:
"Error using cdi_readall
Could not read nametable file: invalid file."

Thanks, Megan

22 May 2013 Andy ONeill

Klaus,
I have MATLAB 2012b and MATLAB compiler runtime v717, but it won't complile. I get the following:
Error using mex (line 206)
Unable to complete successfully.

Error in compile (line 41)
mex -f lib-mingw/mexopts.bat cdi_varlist.c cdi_mx.c -Iinclude -Llib-mingw -lcdi -lnetcdf

I have no mexopts.bat. Can you help?
Thanks,
Andy

24 Apr 2013 Rich Signell

Folks interested in reading GRIB1, GRIB2, NetCDF, HDF and OPeNDAP using a unified syntax might want to check out
http://nctoolbox.github.io/nctoolbox/
there are no mexfiles either!

18 Aug 2011 Van

Does this reader read grib2 data format or only grib 1? I also encountered this problem when compiling:

COMPILING cdi_varlist...
/usr/bin/ld: cannot find -lcdi
collect2: ld returned 1 exit status

mex: link of 'cdi_varlist.mexa64' failed.

Van

08 Jul 2011 Julie

Ok, it works, sorry. I reinstalled CDI and now it works...

07 Jul 2011 Julie

Hello everyone,

I was able run the file 'compile.m' successfully. However when I call the following function
c = cdi_varlist(filename,[]);
I get the following
error: cdi_varlist: No such file or directory
Although I'm pretty sure the file name and path is correct. I identified the error coming from the file cdi_mx.c at the following line
streamID = streamOpenRead(szInputFilename);
So basically 'streamOpenRead' cannot open my file although the path and the name are correct. I tried with and without the file extension (.grb). Also, no capabilities to read the contents of the file (e.g. \private\...) are actually required.

Does anybody know why it does not work?

10 Aug 2010 Matias

A few tips...

In 64-bit systems:
Be sure to compile netcdi, and cdf libraries with -fPIC enabled.

In newer versions of MATLAB: open cdi_mx.c and replace the obsolete function mxErrMsgIdAndTxt with something else (or just comment out). I succesfully used mexprintf instead.

07 Apr 2010 Martin

this package didn't compile in Matlab R2009b and R2010a with following error:

>> compile
COMPILING cdi_varlist...
cdi_mx.c: In function ‘getLevel’:
cdi_mx.c:431: warning: incompatible implicit declaration of built-in function ‘modf’
cdi_mx.o: In function `readmeta':
cdi_mx.c:(.text+0x1457): undefined reference to `mxErrMsgIdAndTxt'
cdi_mx.c:(.text+0x14e3): undefined reference to `mxErrMsgIdAndTxt'
collect2: ld returned 1 exit status

mex: link of ' "cdi_varlist.mexa64"' failed.

??? Error using ==> mex at 221
Unable to complete successfully.

Error in ==> compile at 15
mex cdi_varlist.c cdi_mx.c -Iinclude -Llib64 -lcdi -lnetcdf

It cleanly compiled on R2008b, though.

02 Jun 2009 TideMan

Well, the mexw32's didn't work in Matlab 2006a on Win XP. They gave an "Invalid MEX-file.." message. So, I guess I'm screwed unless I go to all that trouble to compile myself, which looks like a daunting process. Could you possibly provide a Win32 binary package?

01 Jun 2009 YU

Hello Klaus Wyser,
1) I have a probleme of compilation:
run 'compile'
COMPILING cdi_varlist...
cdi_mx.c: In function 'getLevel':
cdi_mx.c:431: warning: incompatible implicit declaration of built-in function 'modf'
/usr/bin/ld: cannot find -lcdi
collect2: ld returned 1 exit status
mex: link of 'cdi_varlist.mexglx' failed.
2)I've coped my own compile "libcdi.a",and "libnetcdf.a" under the directory "lib64".
3)I have the cdi_readall.mexw32 cdi_readfield.mexw32 cdi_readfull.mexw32 cdi_readmeta.mexw32 cdi_varlist.mexw32.
But my machine is i686. So i think i must have the mex file in mexw64??
Thanks avance!
Jingmei

Updates
26 May 2009

Removed GPL, added BSD license

Contact us