File superlu_dist.spec of Package superlu_dist

#
# spec file for package superlu_dist
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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/
#

%if 0%{?sles_version}
%define _mvapich2 1
%endif
%if 0%{?suse_version}
%define _openmpi 1
# We are using openmpi4
%define ompi_major 4
%endif

%define _mpi %{?_openmpi:openmpi%{ompi_major}} %{?_mvapich2:mvapich2}

%define major   3
%define libname libsuperlu_dist

Name:           superlu_dist
Version:        3.2
Release:        0
Summary:        A general purpose library for the direct solution of linear equations
License:        LGPL-2.1
Group:          Development/Libraries/Parallel
Url:            http://crd-legacy.lbl.gov/~xiaoye/SuperLU/
Source0:        %{name}_%{version}.tar.gz
# PATCH-FIX-UPSTREAM superlu_dist-3.1-no-return_in_non-void.patch
Patch0:         superlu_dist-3.1-no-return_in_non-void.patch
# PATCH-FIX-UPSTREAM superlu_dist-3.1-sequence-point.patch
Patch1:         superlu_dist-3.1-sequence-point.patch
# PATCH-FIX-UPSTREAM superlu_dist-3.2-implicit-fortify-decl.patch
Patch2:         superlu_dist-3.2-implicit-fortify-decl.patch
# PATCH-FIX-UPSTREAM superlu_dist-3.2-64-bit-portability.patch
Patch3:         superlu_dist-3.2-64-bit-portability.patch
# PATCH-FIX-OPENSUSE superlu_dist-3.2-make.patch
Patch4:         superlu_dist-3.2-make.patch
# PATCH-FIX-UPSTREAM superlu_dist-3.2-example-no-return-in-non-void.patch
Patch5:         superlu_dist-3.2-example-no-return-in-non-void.patch
BuildRequires:  fdupes
BuildRequires:  blas-devel
BuildRequires:  gcc-fortran
BuildRequires:  scotch-devel
%if 0%{?_openmpi}
BuildRequires:  openmpi-devel
BuildRequires:  ptscotch-openmpi%{ompi_major}-devel
%endif
%if 0%{?_mvapich2}
BuildRequires:  mvapich2-devel
BuildRequires:  ptscotch-mvapich2-devel
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
SuperLU is a general purpose library for the direct solution of large, sparse,
nonsymmetric systems of linear equations on high performance machines. The 
library is written in C and is callable from either C or Fortran. The library
routines will perform an LU decomposition with partial pivoting and triangular
system solves through forward and back substitution. The LU factorization routines
can handle non-square matrices but the triangular solves are performed only for
square matrices. The matrix columns may be preordered (before factorization)
either through library or user supplied routines. This preordering for sparsity 
is completely separate from the factorization. Working precision iterative
refinement subroutines are provided for improved backward stability. Routines
are also provided to equilibrate the system, estimate the condition number,
calculate the relative backward error, and estimate error bounds for the refined
solutions. 


%if 0%{?_openmpi}
%package -n %{libname}%{major}-openmpi%{ompi_major}
Summary:        A general purpose library for the direct solution of linear equations
Group:          System/Libraries
Provides:       %{libname}%{major}-openmpi = %{version}

%description -n %{libname}%{major}-openmpi%{ompi_major}
SuperLU is a general purpose library for the direct solution of large, sparse,
nonsymmetric systems of linear equations on high performance machines. The 
library is written in C and is callable from either C or Fortran. The library
routines will perform an LU decomposition with partial pivoting and triangular
system solves through forward and back substitution. The LU factorization routines
can handle non-square matrices but the triangular solves are performed only for
square matrices. The matrix columns may be preordered (before factorization)
either through library or user supplied routines. This preordering for sparsity 
is completely separate from the factorization. Working precision iterative
refinement subroutines are provided for improved backward stability. Routines
are also provided to equilibrate the system, estimate the condition number,
calculate the relative backward error, and estimate error bounds for the refined
solutions. 

This package contains the parallel version of the library for openmpi.

%package openmpi%{ompi_major}-devel
Summary:        Development and header files for %{name}
Group:          Development/Libraries/Parallel
Requires:       %{libname}%{major}-openmpi = %{version}
Provides:       %{name}-openmpi-devel = %{version}
Requires:       openmpi-devel

%description openmpi%{ompi_major}-devel
This package contains the development and header files for %{name}.

%package example-openmpi%{ompi_major}
Summary:        Example programs for %{name}
Group:          Development/Libraries/Parallel
Provides:       %{name}-example-openmpi = %{version}

%description example-openmpi%{ompi_major}
This package contains several examples programs using %{name}.

The matrix data required by some of the programs can be found in the
documentation directory /usr/share/doc/packages/%{name}-example-openmpi.
%endif

%if 0%{?_mvapich2}
%package -n %{libname}%{major}-mvapich2
Summary:        A general purpose library for the direct solution of linear equations
Group:          System/Libraries

%description -n %{libname}%{major}-mvapich2
SuperLU is a general purpose library for the direct solution of large, sparse,
nonsymmetric systems of linear equations on high performance machines. The 
library is written in C and is callable from either C or Fortran. The library
routines will perform an LU decomposition with partial pivoting and triangular
system solves through forward and back substitution. The LU factorization routines
can handle non-square matrices but the triangular solves are performed only for
square matrices. The matrix columns may be preordered (before factorization)
either through library or user supplied routines. This preordering for sparsity 
is completely separate from the factorization. Working precision iterative
refinement subroutines are provided for improved backward stability. Routines
are also provided to equilibrate the system, estimate the condition number,
calculate the relative backward error, and estimate error bounds for the refined
solutions. 

This package contains the parallel version of the library for mvapich2.

%package mvapich2-devel
Summary:        Development and header files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{libname}%{major}-mvapich2 = %{version}
Requires:       mvapich2-devel

%description mvapich2-devel
This package contains the development and header files for %{name}.

%package example-mvapich2
Summary:        Example programs for %{name}
Group:          Development/Libraries/Parallel

%description example-mvapich2
This package contains several examples programs using %{name}.

The matrix data required by some of the programs can be found in the
documentation directory /usr/share/doc/packages/%{name}-example-mvapich2.
%endif

%package doc
Summary:        Documentation files for %{name}
Group:          Documentation/Other

%description doc
This package contains the html and pdf documentation files for %{name}.

%prep
%setup -q -n SuperLU_DIST_%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1

set -- *
for mpi in %_mpi; do
 mkdir $mpi
 cp -ap "$@" $mpi
done

%build
for mpi in %_mpi; do
cd $mpi
(
    # Source mpivars to setup PATH, LD_LIBRARY_PATH, etc.
    . %{_libdir}/mpi/gcc/$mpi/bin/mpivars.sh
    make superlulib DSuperLUroot=$PWD \
         CC=mpicc \
         FORTRAN=mpif90

    mkdir tmp
    (cd tmp; ar x ../lib/libsuperlu_dist_%{version}.a)
    mpif90 -z muldefs -shared -Wl,-soname=%{libname}.so.%{major} -o lib/%{libname}.so.%{version} tmp/*.o
    pushd lib
    ln -s %{libname}.so.%{version} %{libname}.so
    popd

    # build the examples
    make example DSuperLUroot=$PWD \
         CC=mpicc \
         FORTRAN=mpif90
)
cd ..
done


%install
for mpi in %_mpi; do
cd $mpi

mkdir -p %{buildroot}%{_libdir}/mpi/gcc/$mpi/%_lib
mkdir -p %{buildroot}%{_libdir}/mpi/gcc/$mpi/bin
mkdir -p %{buildroot}%{_libdir}/mpi/gcc/$mpi/include

cd EXAMPLE
install -m755 p[dz]drive p[dz]drive[1-9] \
	      p[dz]drive_ABglobal p[dz]drive[1-9]_ABglobal \
              %{buildroot}%{_libdir}/mpi/gcc/$mpi/bin
cd ..

install -m644 SRC/Cnames.h SRC/dcomplex.h SRC/machines.h SRC/psymbfact.h \
              SRC/superlu_ddefs.h SRC/superlu_defs.h SRC/superlu_enum_consts.h \
              SRC/superlu_zdefs.h SRC/supermatrix.h SRC/util_dist.h \
              %{buildroot}%{_libdir}/mpi/gcc/$mpi/include/

install -m 755 lib/libsuperlu_dist.so.%{version} %{buildroot}%{_libdir}/mpi/gcc/$mpi/%_lib
pushd %{buildroot}%{_libdir}/mpi/gcc/$mpi/%_lib
ln -s libsuperlu_dist.so.%{version} libsuperlu_dist.so.3
ln -s libsuperlu_dist.so.%{version} libsuperlu_dist.so
popd

cd ..
done

# For doc package
mv EXAMPLE example
sed -i 's/\r//' example/typescript
# aprun is for Cray systems
sed -i 's/aprun/mpirun/g' example/README

%clean
rm -rf %{buildroot}

%if 0%{?_openmpi}
%post -n %{libname}%{major}-openmpi%{ompi_major} -p /sbin/ldconfig

%postun -n %{libname}%{major}-openmpi%{ompi_major} -p /sbin/ldconfig
%endif

%if 0%{?_mvapich2}
%post -n %{libname}%{major}-mvapich2 -p /sbin/ldconfig

%postun -n %{libname}%{major}-mvapich2 -p /sbin/ldconfig
%endif


%if 0%{?_openmpi}
%files -n %{libname}%{major}-openmpi%{ompi_major}
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/openmpi%{ompi_major}/%_lib/*.so.*

%files openmpi%{ompi_major}-devel
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/openmpi%{ompi_major}/%_lib/*.so
%{_libdir}/mpi/gcc/openmpi%{ompi_major}/include/*.h

%files example-openmpi%{ompi_major}
%defattr(-,root,root,-)
%doc example/*.rua example/*.cua example/README
%{_libdir}/mpi/gcc/openmpi%{ompi_major}/bin/*
%endif

%if 0%{?_mvapich2}
%files -n %{libname}%{major}-mvapich2
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/mvapich2/%_lib/*.so.*

%files mvapich2-devel
%defattr(-,root,root,-)
%{_libdir}/mpi/gcc/mvapich2/%_lib/*.so
%{_libdir}/mpi/gcc/mvapich2/include/*.h

%files example-mvapich2
%defattr(-,root,root,-)
%doc example/*.rua example/*.cua example/README
%{_libdir}/mpi/gcc/mvapich2/bin/*
%endif

%files doc
%defattr(-,root,root,-)
%doc DOC/html DOC/ug.pdf example README

%changelog
openSUSE Build Service is sponsored by