Subject: Update CDO to 2.1.0 and add libaec and eccodes

From: Roman Scherer <[email-masked]>
Date: Tue, 13 Dec 2022 18:52:08 +0100

Hello Guix,

this patch series updates the Climate Data Operators package to version
2.1.0 and adds support for reading GRIB files by adding the libaec and
eccodes packages.

Could you please review the patches?

Thanks, Roman.

From 2becf2885f612579ac2b8e09c5b42c719abe3d1f Mon Sep 17 00:00:00 2001
From: r0man <[email-masked]>
Date: Sat, 3 Dec 2022 12:14:53 +0100
Subject: [PATCH 1/3] gnu: Add libaec.

* gnu/packages/geo.scm (libaec): New variable.
---
 gnu/packages/geo.scm | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index b3a5c0df3f..d2836b0358 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -128,6 +128,29 @@ (define-module (gnu packages geo)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg))
 
+(define-public libaec
+  (package
+    (name "libaec")
+    (version "1.0.6")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://gitlab.dkrz.de/k202009/libaec/-/archive/v" version
+                    "/libaec-v" version ".tar.bz2"))
+              (sha256
+               (base32
+                "1252jn3l6jcmlhng9fz5gr0f9djp16968bb87c7ilpl33srnbyri"))))
+    (build-system cmake-build-system)
+    (home-page "https://gitlab.dkrz.de/k202009/libaec")
+    (synopsis "Adaptive Entropy Coding library")
+    (description "Libaec provides fast lossless compression of 1 up to 32 bit
+wide signed or unsigned integers (samples). The library achieves best results
+for low entropy data as often encountered in space imaging instrument data or
+numerical model output from weather or climate simulations. While floating
+point representations are not directly supported, they can also be efficiently
+coded by grouping exponents and mantissa.")
+    (license (list (license:non-copyleft "file://LICENSE.txt")))))
+
 (define-public cdo
   (package
     (name "cdo")
-- 
2.38.1

From a8c693aa62cf4d5adf088493eaa95a1e9d9a06b6 Mon Sep 17 00:00:00 2001
From: r0man <[email-masked]>
Date: Sat, 3 Dec 2022 13:16:02 +0100
Subject: [PATCH 2/3] gnu: Add eccodes.

* gnu/packages/geo.scm (eccodes): New variable.
---
 gnu/packages/geo.scm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index d2836b0358..63fbfccab9 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -65,6 +65,7 @@ (define-module (gnu packages geo)
   #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages build-tools)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
@@ -79,6 +80,7 @@ (define-module (gnu packages geo)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages fonts)
   #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
@@ -122,6 +124,7 @@ (define-module (gnu packages geo)
   #:use-module (gnu packages textutils)
   #:use-module (gnu packages time)
   #:use-module (gnu packages tls)
+  #:use-module (gnu packages version-control)
   #:use-module (gnu packages web)
   #:use-module (gnu packages webkit)
   #:use-module (gnu packages wxwidgets)
@@ -151,6 +154,35 @@ (define-public libaec
 coded by grouping exponents and mantissa.")
     (license (list (license:non-copyleft "file://LICENSE.txt")))))
 
+(define-public eccodes
+  (package
+    (name "eccodes")
+    (version "2.27.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://confluence.ecmwf.int/download/attachments/45757960/eccodes-"
+                     version "-Source.tar.gz"))
+              (sha256
+               (base32
+                "16cw4v2d0kjq6gq04paqny0sh5jymn70w449mig7m5h3spzv7rgd"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:configure-flags '("-DENABLE_MEMFS=ON" "-DENABLE_PNG=ON")
+       #:validate-runpath? #f))
+    (inputs
+     (list git jasper libaec libjpeg-turbo libpng netcdf openjpeg))
+    (native-inputs
+     (list gfortran pkg-config perl python))
+    (home-page "https://confluence.ecmwf.int/display/ECC")
+    (synopsis "Library for handling the GRIB, BUFR and GTS file formats")
+    (description "ecCodes is a package developed by @acronym{ECMWF, European
+Centre for Medium-Range Weather Forecasts} which provides an application
+programming interface and a set of tools for decoding and encoding messages in
+the @acronym{WMO, World Meteorological Organization} FM-92 GRIB, WMO FM-94
+BUFR and WMO GTS abbreviated header formats.")
+    (license license:asl2.0)))
+
 (define-public cdo
   (package
     (name "cdo")
-- 
2.38.1

From 0e293f2ac917f6256c86ebe95155e6432197ed18 Mon Sep 17 00:00:00 2001
From: r0man <[email-masked]>
Date: Sat, 3 Dec 2022 13:17:57 +0100
Subject: [PATCH 3/3] gnu: cdo: Update to 2.1.0.

* gnu/packages/geo.scm (cdo): Update to 2.1.0.
---
 gnu/packages/geo.scm | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index 63fbfccab9..abfa5963b9 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -186,22 +186,36 @@ (define-public eccodes
 (define-public cdo
   (package
     (name "cdo")
-    (version "2.0.5")
+    (version "2.1.0")
     (source (origin
               (method url-fetch)
               (uri (string-append
-                    "https://code.mpimet.mpg.de/attachments/download/26823/cdo-"
+                    "https://code.mpimet.mpg.de/attachments/download/27481/cdo-"
                      version ".tar.gz"))
               (sha256
                (base32
-                "1khdbd5cmnn7qm6hcqg4md5wbq14fs6brrns8b3g18diqgqvpvpd"))))
+                "1k18llghpf3jnjn0xcnhmbg7arb1fiy854qqn9m5c1abjin38wdq"))))
     (build-system gnu-build-system)
     (arguments
      (list #:configure-flags
-           #~(list (string-append "--with-netcdf="
-                                  #$(this-package-input "netcdf")))))
+           #~(list (string-append "--with-curl="
+                                  #$(this-package-input "curl"))
+                   (string-append "--with-eccodes="
+                                  #$(this-package-input "eccodes"))
+                   (string-append "--with-fftw3="
+                                  #$(this-package-input "fftw"))
+                   (string-append "--with-hdf5="
+                                  #$(this-package-input "hdf5"))
+                   (string-append "--with-netcdf="
+                                  #$(this-package-input "netcdf"))
+                   (string-append "--with-proj="
+                                  #$(this-package-input "proj"))
+                   (string-append "--with-udunits2="
+                                  #$(this-package-input "udunits"))
+                   (string-append "--with-libxml2="
+                                  #$(this-package-input "libxml2")))))
     (inputs
-     (list netcdf))
+     (list curl eccodes fftw hdf5 libxml2 netcdf proj udunits))
     (native-inputs
      (list pkg-config))
     (home-page "https://code.mpimet.mpg.de/projects/cdo")
-- 
2.38.1