File libadjoint.spec of Package libadjoint
#
# spec file for package libadjoint
#
# Copyright (c) 2024 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 http://bugs.opensuse.org/
#
%define sover 2017
%global flavor @BUILD_FLAVOR@%{nil}
%if !0%{?is_opensuse} && 0%{?sle_version:1} && 0%{?sle_version} < 150200
%define DisOMPI3 ExclusiveArch: do_not_build
%endif
%if 0%{?suse_version} > 1550
%define DisOMPI3 ExclusiveArch: do_not_build
%endif
%if !0%{?is_opensuse} && 0%{?sle_version:1} && 0%{?sle_version} < 150600
%define DisOMPI4 ExclusiveArch: do_not_build
%endif
%if "%flavor" == ""
ExclusiveArch: do_not_build
%endif
%if "%flavor" == "openmpi3"
%{?DisOMPI3}
%define mpi_family openmpi
%define mpi_ver 3
%endif
%if "%flavor" == "openmpi4"
%{?DisOMPI4}
%define mpi_family openmpi
%define mpi_ver 4
%endif
%if "%flavor" == "openmpi5"
%{?DisOMPI5}
%define mpi_family openmpi
%define mpi_ver 5
%endif
%if 0%{?mpi_family:1}
%{bcond_without mpi}
%else
%{bcond_with mpi}
%endif
%if %{with mpi}
%define my_prefix %{_libdir}/mpi/gcc/%{mpi_family}%{?mpi_ver}
%define my_libdir %{my_prefix}/%{_lib}
%define libname libadjoint%{sover}-%{mpi_family}%{?mpi_ver}
%else
%define my_prefix %{_prefix}
%define my_libdir %{_libdir}
%define libname libadjoint%{sover}
%endif
Name: libadjoint
Version: 2017.2.0
Release: 0
License: LGPL-3.0-only
Summary: A library for adjoining computational models
URL: https://bitbucket.org/dolfin-adjoint/libadjoint
Group: Development/Libraries/C and C++
Source0: https://bitbucket.org/dolfin-adjoint/libadjoint/downloads/%{name}-%{version}.tar.gz
Patch0: fix-python-install.patch
# PATCH-FIX-OPENSUSE
Patch1: 0001-Remove-broken-EPSMonitorSet-call.patch
BuildRequires: blas-devel
BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: lapack-devel
BuildRequires: libstdc++-devel
#BuildRequires: python3-devel
BuildRequires: python-rpm-macros
BuildRequires: python3-xml
%if %{with mpi}
BuildRequires: %{mpi_family}%{?mpi_ver}-devel
BuildRequires: petsc-%{mpi_family}%{?mpi_ver}-devel
BuildRequires: slepc-%{mpi_family}%{?mpi_ver}-devel
# FIXME: resolve ambiguity
BuildRequires: parpack-%{mpi_family}%{?mpi_ver}-devel
%else
BuildRequires: petsc-devel
BuildRequires: slepc-devel
BuildRequires: arpack-devel
%endif
BuildRequires: suitesparse-devel
%description
Libadjoint is a library for adjointing computational models. It aims to
make adjointing models easy (or rather, as easy as possible). Its fundamental
abstraction is that a model is a sequence of linear solves.
It provides an API by which the model developer may build a "tape" of
what the model does, in terms of the linear solves that it executes.
This tape may then be "rewound" by libadjoint to compute the adjoint
equation associated with every forward linear solve. It may also
be "replayed", to compare the genuine forward model output against
libadjoint's interpretation of the forward model.
The library is mainly used by dolfin-adjoint.
%package -n %{libname}
Summary: A library for adjoining computational models - openmpi support
Group: Development/Libraries/C and C++
%if %{with mpi}
Requires: %{mpi_family}%{?mpi_ver}
Requires: libpetsc3-%{mpi_family}%{?mpi_ver}
Requires: libslepc3-%{mpi_family}%{?mpi_ver}
%endif
%description -n %{libname}
Libadjoint is a library for adjointing computational models. It aims to
make adjointing models easy (or rather, as easy as possible). Its fundamental
abstraction is that a model is a sequence of linear solves.
It provides an API by which the model developer may build a "tape" of
what the model does, in terms of the linear solves that it executes.
This tape may then be "rewound" by libadjoint to compute the adjoint
equation associated with every forward linear solve. It may also
be "replayed", to compare the genuine forward model output against
libadjoint's interpretation of the forward model.
The library is mainly used by dolfin-adjoint.
This package contains the binaries build with openmpi support.
%package -n %{name}%{?mpi_family:-%{mpi_family}%{?mpi_ver}}-devel
Summary: A library for adjointing computational models - openmpi support
Group: Development/Libraries/C and C++
Requires: %{libname} = %{version}
%if %{with mpi}
Requires: petsc-%{mpi_family}%{?mpi_ver}-devel
Requires: slepc-%{mpi_family}%{?mpi_ver}-devel
Requires: %{mpi_family}%{?mpi_ver}-devel
%else
Requires: petsc-devel
Requires: slepc-devel
%endif
%description -n %{name}%{?mpi_family:-%{mpi_family}%{?mpi_ver}}-devel
Libadjoint is a library for adjointing computational models. This package
contains the development headers needed to link against libadjoint build
with openmpi support.
%package -n python3-%{name}%{?mpi_family:-%{mpi_family}%{?mpi_ver}}
Summary: A library for adjointing computational models (python bindings w/ openmpi)
Group: Development/Languages/Python
Requires: %{libname} = %{version}
%if %{without mpi}
BuildArch: noarch
%endif
%description -n python3-%{name}%{?mpi_family:-%{mpi_family}%{?mpi_ver}}
Libadjoint is a library for adjointing computational models. This package
contains the Python bindings for the library (generated by ctypes) with
openmpi support.
%prep
%autosetup -n %{name} -p1
sed -i -e 's/\r//' README.md
%build
%define petsc_ver %(rpm -q petsc-%{mpi_family}%{?mpi_ver}-devel --queryformat %%{VERSION})
# export CC=mpicc CXX=mpic++ FC=mpif90
ls %{my_prefix}/bin/
ls %{my_libdir}/petsc/3.*/
export PETSC_DIR=`echo %{my_libdir}/petsc/3.*/*`
export SLEPC_DIR=`echo %{my_libdir}/slepc/3.*/*`
%cmake \
-DPYTHON_EXECUTABLE=/usr/bin/python3 \
-DCMAKE_INSTALL_PREFIX:PATH=%{my_prefix} \
-DINSTALL_LIB_DIR:PATH=%{_lib} \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=OFF \
-DDOLFIN_SKIP_BUILD_TESTS:BOOL=ON \
%{nil}
%cmake_build
%install
%cmake_install
rm -f %{buildroot}%{my_libdir}/*.a
%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig
%files -n %{libname}
%doc AUTHORS README.md
%license LICENSE
%{my_libdir}/*.so.%{sover}*
%files -n %{name}%{?mpi_family:-%{mpi_family}%{?mpi_ver}}-devel
%dir %{my_prefix}/include/%{name}
%{my_prefix}/include/%{name}/*
%{my_libdir}/*.so
%files -n python3-%{name}%{?mpi_family:-%{mpi_family}%{?mpi_ver}}
%if %{with mpi}
%dir %{my_prefix}/lib
%endif
%dir %{my_prefix}/lib/python%{py3_ver}
%dir %{my_prefix}/lib/python%{py3_ver}/site-packages/
%dir %{my_prefix}/lib/python%{py3_ver}/site-packages/%{name}
%{my_prefix}/lib/python%{py3_ver}/site-packages/%{name}/*
%{my_prefix}/lib/python%{py3_ver}/site-packages/%{name}-*.egg-info
%changelog