File wgrib2.spec of Package wgrib2
#
# spec file for package wgrib2
#
# Copyright (c) 2025 SUSE LLC
#
# 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/
#
#---on 32bit archs, not all prerequisites are available, therefore disable build for them:
ExcludeArch: %{ix86} %{arm}
%define sover 0
%define libname libwgrib2-%{sover}
%bcond_with proj
Name: wgrib2
Version: 3.7.0
Release: 0
Summary: Utility to read and write grib2 files
License: 0BSD AND GPL-3.0-only
Group: Productivity/Scientific/Other
URL: https://github.com/NOAA-EMC/wgrib2
Source: https://github.com/NOAA-EMC/wgrib2/archive/refs/tags/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0: 419f09aebd2f9219f88853ca6d85c3458f208bf1.patch
Patch1: soversion.patch
BuildRequires: blas-devel
BuildRequires: cmake
BuildRequires: diffutils
BuildRequires: gcc-fortran
BuildRequires: lapack-devel
BuildRequires: libaec-devel
BuildRequires: nceplibs-g2c-devel
BuildRequires: nceplibs-ip-devel
%if 0%{?suse_version}
BuildRequires: netcdf
BuildRequires: netcdf-devel
%endif
BuildRequires: zlib-devel
%if %{with proj}
BuildRequires: proj-devel
%endif
%description
Wgrib2 is a utility and library for manipulating grib2 files. It has the following abilities:
- inventory and read grib2 files
- create subsets
- create regional subsets by cookie cutter or projections
- export to ieee, text, binary, CSV, netcdf and mysql
- import to ieee, text, binary, and netcdf
- write of new grib2 fields
- parallel processing by using threads (OpenMP)
- parallel processing by flow-based programming
%package -n %{libname}
Summary: Library for manipulating grib2 files
Group: Productivity/Scientific/Other
%package devel
Summary: Headers and development files for %{libname}
Group: Development/Libraries/C and C++
Requires: %{libname} = %{version}
%description -n %{libname}
This is the library interface of wgrib2.
%description devel
This package contains the files needed for compiling programs using the %{libname} library.
%prep
%autosetup -p1
%build
# wgrib2 is not yet ported to use proj version > 7, only enable proj for Leap 15.6 for now
%if %{with proj} && 0%{?sle_version} == 150600 && 0%{?is_opensuse}
export CFLAGS="%{optflags} -flto=auto -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H"
%else
export CFLAGS="%{optflags} -flto=auto"
%endif
%cmake \
-DCMAKE_Fortran_FLAGS="%{optflags}%{?_fmoddir: -I%{_fmoddir}} -Wno-tabs" \
-DUSE_OPENMP=ON \
-DUSE_REGEX=ON \
-DUSE_IPOLATES=ON \
-DUSE_AEC=ON \
-DUSE_G2CLIB_LOW=ON \
-DUSE_G2CLIB_HIGH=ON \
%if %{with proj} && 0%{?sle_version} == 150600 && 0%{?is_opensuse}
-DUSE_PROJ4=ON \
-DCMAKE_EXE_LINKER_FLAGS="-lproj" \
-DCMAKE_MODULE_LINKER_FLAGS="-lproj" \
-DCMAKE_SHARED_LINKER_FLAGS="-lproj" \
%endif
%if 0%{?suse_version}
-DUSE_NETCDF=ON \
%endif
-DUSE_TIGGE=ON \
-DMAKE_FTN_API=ON
%cmake_build
%install
%cmake_install
%check
%define _smp_mflags -j1
%ctest
%ldconfig_scriptlets -n %{libname}
%files
%doc README.md docs/formats.doc docs/user_guide.md
%doc docs/tricks.cheap docs/tricks.ncep docs/tricks.wgrib2
%{_bindir}/wgrib2
%files -n %{libname}
%{_libdir}/libwgrib2.so.*
%{_libdir}/libwgrib2_ftn_api.so.*
%files devel
%{_libdir}/libwgrib2.so
%{_libdir}/libwgrib2_ftn_api.so
%{_includedir}/wgrib2.h
%{_includedir}/wgrib2_api.h
%{_includedir}/wgrib2_meta.h
%{_includedir}/wgrib2api.mod
%{_includedir}/wgrib2lowapi.mod
%{_libdir}/cmake/wgrib2/
%changelog