Code covered by the BSD License  

Highlights from
NetCDF/GRIB reader

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

NetCDF/GRIB reader

by Klaus Wyser

 

25 Sep 2008 (Updated 26 May 2009)

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  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
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

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?

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.

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 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?

08 Jul 2011 Julie

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

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

Please login to add a comment or rating.
Updates
26 May 2009

Removed GPL, added BSD license

Tag Activity for this File
Tag Applied By Date/Time
grib Klaus Wyser 22 Oct 2008 10:21:43
netcdf Klaus Wyser 22 Oct 2008 10:21:43
cdi Klaus Wyser 22 Oct 2008 10:21:43
general Klaus Wyser 22 Oct 2008 10:21:43
earth sciences Klaus Wyser 22 Oct 2008 10:21:43
grib Karl 21 Sep 2009 14:56:38
cdi UPM arnaldo 24 Nov 2009 02:02:37
grib Karthik 15 Dec 2009 17:23:43
grib Michael Gausa 28 Dec 2010 15:59:46
grib Luciano Raso 15 Jul 2011 05:22:33
grib Jorge 07 Sep 2011 23:12:57
netcdf Patrice 28 Oct 2011 03:57:40
grib Debashis Nath 11 Nov 2011 01:53:37

Contact us at files@mathworks.com