cdo does not do what it is supposed to do

Bug #1023329 reported by marcofgalli
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cdo (Debian)
Fix Released
Unknown
cdo (Ubuntu)
Fix Released
Undecided
Unassigned
Precise
Won't Fix
Undecided
Unassigned

Bug Description

[IMPACT]

By default installed cdo lost data in grib1 files due to using grib_api instead of cgribex. Support for grub1 files in grib_api is experimental and unstable according to upstream:

https://code.zmaw.de/boards/1/topics/1540

The fix is to compile the package with the flag --enable-cgribex

[TESTCASE]

 * Install cdo package $ sudo apt-get install cdo
 * Download and test how it works with grib1 files
   $ wget https://code.zmaw.de/attachments/3103/t2m_ei_1979.grb
   $ cdo sellonlatbox,23,31,-25,-31 t2m_ei_1979.grb tagliato_t2m_ei_1979.grb
   $ wget ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib/wgrib.c
   $ gcc -o wgrib wgrib.c
   $ ./wgrib -v tagliato_t2m_ei_1979 | head -n 8
1:0:D=1979010100:2T:sfc:kpds=167,1,0:anl:type=analysis:winds are N/S:"2 metre temperature [K]

The 'anl' word in the output means it has just lost the hour data

 * Update package
 * Rerun the test
  $ ./wgrib -v tagliato_t2m_ei_1979 | head -n 81:0:D=1979010100:2T:sfc:kpds=167,1,0:3hr:type=analysis:winds are N/S:"2 metre temperature [K]

Now instead of 'anl' it has '3hr'

[Regression Potential]

 * There is a bug in Debian:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=633934

Which introduced the bug to fix a behavior with grub2 files, however since grub2 files has nothing to do with cgribex it's unlikely to provoke it.

* It may fail if people try to use the program with non common grub1 files

https://code.zmaw.de/boards/1/topics/713#message-716

[Other Info]

 * The --enable-cgribex flag has been enabled in Debian since it provides a better default for general use

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=695009

Related branches

Revision history for this message
Javier López (javier-lopez) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. Please answer this question:

* What specific steps should we take to recreate this bug?

I've read both reports (this and the one you made in upstream) and still don't know what specific steps I need to do to recreate it, could you provide the so called 'GRIB 1 datafile'?

I've seen that you used:

  $ cdo sellonlatbox,23,31,-25,-31 t2m_ei_1979.grb tagliato_t2m_ei_1979.grb

To test cdo, could you provide both the wrong and right output?, or any other hint to detect that the program has run successfully?

The latest version in Ubuntu of the cdo program is 1.5.6.1+dfsg.1-2ubuntu2, and in other ubuntu releases:

       cdo | 1.5.3.dfsg.1-2 precise
       cdo | 1.5.4+dfsg.1-4build1 quantal
       cdo | 1.5.6.1+dfsg.1-2ubuntu2 raring

So there is a good change that in the latest Ubuntu release it works as expected, if that's the case (we'll know when we can verify the error) we'll need to cherry pick the solution to add it to the Ubuntu precise version (SRU [0])

Again, thanks for your time invested in Ubuntu, have a nice day.

[0] https://wiki.ubuntu.com/StableReleaseUpdates

---
Ubuntu Bug Squad volunteer triager
http://wiki.ubuntu.com/BugSquad

Revision history for this message
Benjamin Kerensa (bkerensa) wrote :

Marked incomplete pending more information from Reporter.

Changed in cdo (Ubuntu):
status: New → Incomplete
Revision history for this message
marcofgalli (marcofgalli) wrote :
Download full text (8.8 KiB)

Dear Javier, thank you for the tests on this bug.

I will post hereafter a "short and quick" way to reproduce the bug, and a more detailed one. First of all, in both cases, it is necessary to get the input example data file to process. This is here:

https://code.zmaw.de/attachments/3103/t2m_ei_1979.grb

In order to let the bug come out, change the working directory to the one where you downloared t2m_ei_1979.grb and type:

cdo sellonlatbox,23,31,-25,-31 t2m_ei_1979.grb tagliato_t2m_ei_1979.grb

This command produces, in the same working directory, the file tagliato_t2m_ei_1979.grb, which has the wrong indication of the time in the metadata section of the data it contains. The only above command enlights the misfunctioning.

In order to understand why this behaviour of cdo is wrong, I report here more details about the problem I wanted to solve, what I expected and what I got in turn.

The input file, t2m_ei_1979.grb, contains data in grib 1 format (see, for instance, http://en.wikipedia.org/wiki/GRIB and http://www.wmo.int/pages/prog/www/WDM/Guides/Guide-binary-2.html). I think that the difference between grib 1 and grib 2 data formats are not relevant in this context, however I'm 100% sure that the data file used here is in grib 1 (for further details, ask). The data refer to the year 1979, and they are all of two metres temperature on a spatial latitude - longitude grid over all the state of South Africa and some surrounding areas (lat -20.00 to -40.00 by 0.25, long 15.00 to 35.00 by 0.25).

They are structured as follow: at 00 and at 12 UTC of each day of the year, a forecast of two metre temperature is initialised (this procedure is called analysis, a jargon useful to interpret how cdo misfunctions); after each analysis, a forecast of two metres temperature is performed, and the data are written in the grib file every three hours up to twelve hours for each day and initialisation. Only the forecasts, and not the initial values, are reported in the grib file (so, in the original file t2m_ei_1979.grb, for each day in 1979, contains the forecasts valid at 03, 06, 09 and 12 after the initialisation at 00, and the forecasts valid at 15, 18, 21 and 24 after the initialisation at 12). It is important to underline that all this time information is contained in a special descriptive section within the grib data file itself, written, basically, as the initialisation time (called analysis time, accordingly), and forecast time (to be added up to the analysis time to get the validity time).

I typed the command

cdo sellonlatbox,23,31,-25,-31 t2m_ei_1979.grb tagliato_t2m_ei_1979.grb

because I needed to work on a smaller area than the original one. As referred in the appropriate section of the cdo user guide,

https://code.zmaw.de/embedded/cdo/1.5.5/cdo.html#x1-1070002.3.3

the command I reported above means to cut spatially the input datafile (t2m_ei_1979.grb) on a smaller area and to put the results in the output data file (tagliato_t2m_ei_1979.grb ; "tagliato" is the Italian for "it has been cut"), leaving the input untouched.

The trusted and well assessed utility command wgrib is an alternative tool to get some information for grib 1 files....

Read more...

Revision history for this message
Javier López (javier-lopez) wrote :

Hi Marco,

Thanks for the long and clear explanation, after reading it I was able to reproduce it in raring this way:

$ wget https://code.zmaw.de/attachments/3103/t2m_ei_1979.grb
$ sudo apt-get install cdo
$ cdo sellonlatbox,23,31,-25,-31 t2m_ei_1979.grb tagliato_t2m_ei_1979.grb
$ wget ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib/wgrib.c
$ gcc -o wgrib wgrib.c
$ ./wgrib -v t2m_ei_1979.grb | head -n 8
1:0:D=1979010100:2T:sfc:kpds=167,1,0:anl:type=analysis:winds are N/S:"2 metre temperature [K]
...

With the 'anl' definition after kpds=167,1,0:

After recompiling with the --enable-cgribex option it behaves as expected, with the following output:

$ ./wgrib -v t2m_ei_1979.grb | head -n 8
1:0:D=1979010100:2T:sfc:kpds=167,1,0:3hr:type=analysis:winds are N/S:"2 metre temperature [K]

I looked into the changelog and cgribex was disabled in the first place for this report:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=633934

So, I'd like to know if that error is still happening with this version, I've uploaded precise/quantal/raring patched cdo versions to my ppa so you can test them. Specifically the part that says 'Error (decodeIS) : GRIB version 2 unsupported!'

$ sudo add-apt-repository ppa:chilicuil/pmx
$ sudo apt-get update && sudo apt-get upgrade
$ rm tagliato_t2m_ei_1979.grb
$ cdo sellonlatbox,23,31,-25,-31 t2m_ei_1979.grb tagliato_t2m_ei_1979.grb
$ ./wgrib -v t2m_ei_1979.grb | head -n 8

I was able to test successfully the steps in the three ubuntu versions:

cdo - 1.5.6.1+dfsg.1-2ubuntu3 - raring
cdo - 1.5.4+dfsg.1-4build2 - quantal
cdo - 1.5.3.dfsg.1-2ubuntu1 - precise

If the patched version doesn't work with GRIB version 2 I suspect it may be difficult to be accepted in Ubuntu, probably GRIB2 will have preference over GRIB1

Have a nice day
---
Ubuntu Bug Squad volunteer triager
http://wiki.ubuntu.com/BugSquad

Changed in cdo (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
marcofgalli (marcofgalli) wrote :
Download full text (8.1 KiB)

Dear Javier,
thanks for continuing in giving me attention about this problem.

I made some tests and I succesfully made cdo work in the following versions:

cdo 1.5.6.1 (source package from the developers' site; https://code.zmaw.de/attachments/download/3605/cdo-1.5.6.1.tar.gz)
cdo 1.5.4 (since this is no more available on the developers' site, I downloaded it from http://archive.ubuntu.com/ubuntu/pool/universe/c/cdo/cdo_1.5.4+dfsg.1.orig.tar.gz ; I hope this is is conformal to the developers' original one).

I made it work on Ubuntu Quantal, it seems reasonable to me that these conclusion should hold also for other Ubuntu releases (but I'm not an IT scientist, and I won't dare state this sentence too loud! :) ).

I run cdo succesfully both on grib1 and grib2 data, getting the correct results with both versions of cdo.

I compiled the two above packages with the following compilation commands:

export CC=mpicc
configure --prefix=${HOME}/src/cdo-1.5.6.1 --with-grib-api=yes --with-netcdf=yes --with-hdf5=yes
make
make install

Of course, a different prefix value for version 1.5.4, so I did not override the resulting executable. I made the above choice of the configure options in order to stick as closer as possible to the cdo compiled for the Ubuntu Quantal repositories, but ensuring that the resulting executable was working. Of course, in order to compile cdo with those options, the following packages are needed in the compiling environment:

libhdf5-openmpi-dev
libnetcdf-dev

Actually, I do not remember why I have the MPI parallelised version of the libhdf5 package installed on my system, maybe for compatibility with some other software (maybe the same cdo). However, it peacefully coexhists with the Ubuntu repositories version of cdo, while the serial one does not.

I'm attaching to this report a sample grib 2 file, with analysis and forecasts of 2 metre temperature packaged in the same file. Unfortunately, the area of the data I had available for this report is not the same (Europe for the grib 2 data, versus the South African framework I used to rise the problem for grib 1), so the spatial cutting command must be different in the two cases.

For both versions of the cdo compiled software, I run (I am reporting only the test of version 1.5.6.1 for brevity, but I performed the same operations also for version 1.5.4, getting the same results):

${HOME}/src/cdo-1.5.6.1/bin/cdo sellonlatbox,10,15,50,40 t2m.grib2 tagliato_t2m.grib2
${HOME}/src/cdo-1.5.6.1/bin/cdo sellonlatbox,23,31,-25,-31 t2m_ei_1979.grb tagliato_t2m_ei_1979.grb
wgrib2 -v tagliato_t2m.grib2 # See further notes
wgrib -v tagliato_t2m_ei_1979.grb | head -n 8

Till this moment, I only posted the commands rather than their output. It is important to note that for grib 2 data files the wgrib utility mentioned in my previous post is not helpful anymore. Rather, there is a specific utility for grib 2 data that is the wgrib2.

The wgrib2 is downloadable from
http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/
and, more specifically, in that quite messy page, from
http://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz.v1.9.7
In order to use the wgrib2 it must be compiled. Unpack the ...

Read more...

Revision history for this message
Javier López (javier-lopez) wrote :
Download full text (4.2 KiB)

Hi Marco,

Thank you for your grib2 file and full explanation about how to test it.

I was able to pass the two testcases (grib1 - grib2) with cdo in precise/quantal/raring with the ppa version. Now let me give you my opinion about some of your questions.

> cdo 1.5.4 (since this is no more available on the developers' site, I downloaded it from http://archive.ubuntu.com/ubuntu/pool/universe/c/cdo/cdo_1.5.4+dfsg.1.orig.tar.gz ; I hope this is is conformal to the developers' original one).

Yes, the orig.* files are the upstream unmodified sources

> There is in fact one difference between the cdo available in the Ubuntu repositories and the ones I tested to write this post.

This is the 'cdo -V' output of the ppa versions:

raring:
cdo -V
Climate Data Operators version 1.5.6.1 (http://code.zmaw.de/projects/cdo)
Compiler: gcc -std=gnu99 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -pthread
 version: gcc (Ubuntu/Linaro 4.7.2-5ubuntu5) 4.7.2
    with: PTHREADS Z JASPER PROJ.4
Compiled: by buildd on mercury (i686-pc-linux-gnu) Nov 14 2012 01:16:49
     CDI library version : 1.5.6 of Nov 14 2012 01:16:37
 CGRIBEX library version : 1.5.3 of Jun 14 2012 13:22:45
GRIB_API library version : 1.9.16
  netCDF library version : 4.1.3 of May 1 2012 04:15:00 $
    HDF5 library version : 1.8.8
 SERVICE library version : 1.3.0 of Nov 14 2012 01:16:12
   EXTRA library version : 1.3.0 of Nov 14 2012 01:16:05
     IEG library version : 1.3.0 of Nov 14 2012 01:16:10
    FILE library version : 1.8.0 of Nov 14 2012 01:16:05

quantal:
cdo -V
Climate Data Operators version 1.5.4 (http://code.zmaw.de/projects/cdo)
Compiler: mpicc -std=gnu99 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC
 version: gcc: error: unrecognized command line option '-V'
    with: PTHREADS Z JASPER PROJ.4
Compiled: by buildd on actinium (i686-pc-linux-gnu) Nov 14 2012 06:51:52
     CDI library version : 1.5.4 of Nov 14 2012 06:51:44
 CGRIBEX library version : 1.5.1 of Aug 29 2011 20:30:27
GRIB_API library version : 1.9.16
  netCDF library version : 4.1.3 of May 1 2012 04:15:00 $
    HDF5 library version : 1.8.8
 SERVICE library version : 1.3.0 of Nov 14 2012 06:51:23
   EXTRA library version : 1.3.0 of Nov 14 2012 06:51:17
     IEG library version : 1.3.0 of Nov 14 2012 06:51:22
    FILE library version : 1.7.1 of Nov 14 2012 06:51:1

precise:
cdo -V
Climate Data Operators version 1.5.3 (http://code.zmaw.de/projects/cdo)
Compiler: mpicc -std=gnu99 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -fPIC
 version: gcc: error: unrecognized option '-V'
    with: PTHREADS Z JASPER PROJ.4
Compiled: by buildd on platinum (i686-pc-linux-gnu) Nov 14 2012 04:36:09
     CDI library version : 1.5.3 of Nov 14 2012 04:35:59
 CGRIBEX library version : 1.5.1 of Aug 29 2011 20:30:27
GRIB_API library version : 1.9.9
  netCDF library version : 4.1.1 of Nov 7 2011 11:30:05 $
    HDF5 library version : 1.8.4
 SERVICE library version : 1.3.0 of Nov 14 2012 04:35:34
   EXTRA library version : 1.3.0 of Nov 14 2012 04:35:28
     IEG library version : 1.3.0 of Nov 14 2012 0...

Read more...

Revision history for this message
marcofgalli (marcofgalli) wrote :

Dear Javier,
I wanted to write some message to let you know that Iam still active on this.
I just had some problems in configuring some laboratory environment where I can work without harming my real computer. I needed to set up a virtual machine to experiment. However, I had problems with the internet connectivity, and I will have no internet for all the weekend.
Moreover, I tried to configure a Raring machine, struggling so much but with no success at all. Then, I will let you have the results of my experiments with the cdo software in your ppa on Precise and Quantal, but not with Raring.
I will be back after the weekend.
I am still active on this despite I am quite busy at the moment.

Regards
Marco

Revision history for this message
marcofgalli (marcofgalli) wrote :

Dear Javier,
the cdo package in your ppa works as expected for Ubuntu 12.04. It writes good grib1, grib2 and NetCDF files.
Now I will test it also on 12.10. I'll try also to test it on 13.04, however I really struggled without coming to a success to install the system itself, so I really wonder if I can actually do that.

Regards
Marco

Revision history for this message
Javier López (javier-lopez) wrote :

Hi Marco,

Thanks for your comments , I'm requesting a merge, it's not necessary that you test in 12.10 - 13.04, I've already done it, I just wanted to know that it worked for someone else. The change is exactly the same in precise/quantal/raring.

Thanks for your time.
---
Ubuntu Bug Squad volunteer triager
http://wiki.ubuntu.com/BugSquad

Changed in cdo (Debian):
status: Unknown → New
description: updated
Changed in cdo (Debian):
status: New → Fix Released
Revision history for this message
Javier López (javier-lopez) wrote :

It was fixed by merging the package in 1.5.6.1+dfsg.1-3ubuntu1
---
Ubuntu Bug Squad volunteer triager
http://wiki.ubuntu.com/BugSquad

Changed in cdo (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
marcofgalli (marcofgalli) wrote :

Dear all, dear Javier,
just thank you for the great work that is soon going to be complete!
Recently I did not have much time to follow the evolution of the issue I raised, and I am really glad to see that your effort went on the same to fix this issue, on a not so common software.

All the best
Marco

Revision history for this message
marcofgalli (marcofgalli) wrote :

Dear all,
I just run cdo from the official repositories of raring after upgrading to the new release. Everything I tested works justo ok.
Thank you all for the effort!

Marco

no longer affects: cdo (Ubuntu Quantal)
Revision history for this message
Steve Langasek (vorlon) wrote :

The Precise Pangolin has reached end of life, so this bug will not be fixed for that release

Changed in cdo (Ubuntu Precise):
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.