File cdo.spec of Package cdo
#
# spec file for package cdo
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
#---eccodes does not support 32-bit archs, disable them:
ExcludeArch: %{ix86} %{arm}
%bcond_without grib
%bcond_without plot
Name: cdo
Version: 2.5.3
Release: 0
Summary: A program for manipulating GRIB/NetCDF/SERVICE/EXTRA/IEG files
License: BSD-3-Clause
Group: Productivity/Scientific/Other
URL: https://code.zmaw.de/projects/cdo
Source0: https://code.mpimet.mpg.de/attachments/download/30045/cdo-%{version}.tar.gz
# PATCH-FIX-OPENSUSE deregister.patch
Patch0: deregister.patch
%if 0%{?suse_version} > 1500 || 0%{?fedora_version}
BuildRequires: gcc-c++
%else
#---we need a GCC version which supports C++20:
%define gccversion 11
BuildRequires: gcc%{gccversion}
BuildRequires: gcc%{gccversion}-c++
%endif
BuildRequires: hdf5-devel >= 1.8.8
BuildRequires: libcurl-devel
BuildRequires: netcdf-devel
BuildRequires: perl
BuildRequires: proj-devel
BuildRequires: udunits2-devel
BuildRequires: zlib-devel
%if %{with grib} || 0%{?fedora_version}
BuildRequires: libaec-devel
BuildRequires: libsz2-devel
%endif
%if %{with grib}
BuildRequires: eccodes-devel
%endif
%if %{with plot}
BuildRequires: Magics-devel
BuildRequires: libxml2-devel
%endif
Recommends: bash-completion
%description
CDO (Climate Data Operators) is a collection of command line Operators
to manipulate and analyse Climate and NWP model Data.
Supported data formats are GRIB 1/2, netCDF 3/4, SERVICE, EXTRA and IEG.
There are more than 600 operators available.
%prep
%autosetup -p1
%build
%if 0%{?suse_version} <= 1500 && ! 0%{?fedora_version}
export CC=gcc-%{gccversion}
export CXX=g++-%{gccversion}
%endif
%if %{with plot}
export CFLAGS="%{optflags} -O3 -fno-strict-aliasing -I/usr/include/magics"
export CXXFLAGS="%{optflags} -O3 -fno-strict-aliasing -I/usr/include/magics"
export CPPFLAGS="%{optflags} -I/usr/include/magics"
%else
export CFLAGS="%{optflags} -O3 -fno-strict-aliasing"
export CXXFLAGS="%{optflags} -O3 -fno-strict-aliasing"
%endif
%configure --with-netcdf \
--with-proj \
--with-zlib \
--with-hdf5 \
--with-curl \
%if %{with grib}
--enable-grib \
--with-eccodes \
--with-szlib \
%else
--disable-grib \
%endif
%if %{with plot}
--with-magics \
--with-libxml2 \
%endif
--with-udunits2 LOGNAME=abuild HOST=OBS
%make_build
%install
%make_install
install -D -m 644 contrib/cdoCompletion.bash \
%{buildroot}%{_datadir}/bash-completion/completions/%{name}
%check
%make_build check AM_COLOR_TESTS=no VERBOSE=1
%files
%license LICENSE
%doc README NEWS OPERATORS ChangeLog
%doc doc/cdo.pdf doc/cdo_eca.pdf doc/cdo_magics.pdf doc/cdo_refcard.pdf
%{_bindir}/%{name}
%{_datadir}/bash-completion/completions/%{name}
%changelog