File dakota.spec of Package dakota

#
# spec file for package dakota
#
# Copyright (c) 2019 SUSE LINUX 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 https://bugs.opensuse.org/
#

%define so_ver 12

# Optionally build using the trilinos package in science. This
# requires the '--with trilinos' build flag
%bcond_with trilinos

# NOTE: This disables all post installation checks
BuildRequires:  -post-build-checks

%define _buildshell /bin/bash

Name:           dakota
Version:        6.9
Release:        0
Summary:        Explore and predict with confidence
License:        GPL-2.0-only
Group:          Development/Libraries/C and C++
Url:            https://dakota.sandia.gov/
Source:         https://dakota.sandia.gov/sites/default/files/distributions/public/%{name}-%{version}-release-public.src.tar.gz
# PATCH-FIX-UPSTREAM - known to developers via mailing lists
Patch1:         JEGA.patch
# PATCH-FIX-OPENSUSE - satisfy rpmlint about determining dependency
# from shebang
Patch2:         env-script.patch
# PATCH-FIX-OPENSUSE - satisfy rpmlint about determining dependency
# from shebang
Patch3:         shebang.patch
# PATCH-FEATURE-UPSTREAM - Allows libraries to be installed in
# arch-dependent directories (lib->lib64). not yet known if upstream
# is interested.
Patch4:         install-destination.patch
Recommends:     %{name}-examples

BuildRequires:  blas-devel
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran
BuildRequires:  lapack-devel
BuildRequires:  perl
BuildRequires:  python2
BuildRequires:  python2-numpy-devel
%{?with_trilinos:BuildRequires:  trilinos-devel}

# FIXME: This should be pulled in by trilinos-devel, but currently is not
%{?with_trilinos:BuildRequires:  libtrilinos12}

BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_regex-devel
BuildRequires:  libboost_serialization-devel
%if 0%{?suse_version} <= 1510
BuildRequires:  libboost_signals-devel
%endif
BuildRequires:  libboost_system-devel


%description
The Dakota project delivers both state-of-the-art research and robust,
usable software for optimization and UQ. Broadly, the Dakota
software advanced parametric analyses enable design exploration,
model calibration, risk analysis, and quantification of margins and
uncertainty with computational models. The Dakota toolkit provides a
flexible, extensible interface between such simulation codes and its
iterative systems analysis methods, which include:

- optimization with gradient and nongradient-based methods;
- uncertainty quantification with sampling, reliability, stochastic
  expansion, and epistemic methods;
- parameter estimation using nonlinear least squares (deterministic)
  or Bayesian inference (stochastic); and
- sensitivity/variance analysis with design of experiments and
  parameter study methods.

These capabilities may be used on their own or as components within
advanced strategies such as hybrid optimization, surrogate-based
optimization, mixed integer nonlinear programming, or optimization
under uncertainty.

NOTE: The version in this package has NOT been compiled with MPI
support.

%package -n libdakota%{so_ver}
Summary:        Shared Libraries for %{name}
Group:          System/Libraries

%description  -n libdakota%{so_ver}
This packae contains the shared libraries for %{name}.

%package examples
Summary:        Examples for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description examples
This package contains examples included with %{name}.

%package devel
Summary:        Development Files for %{name}
Group:          Development/Libraries/C and C++

%description devel
This package contains development files necessary for developing
applications based on %{name}.

%prep
%setup -q -n %{name}-%{version}.0.src

%patch1
%patch2
%patch3
%patch4

%build
%cmake \
    '-DCMAKE_SHARED_LINKER_FLAGS=-Wl,--as-needed -Wl,-z,now' \
    -DDakota_INSTALL_CMAKE_DIR:PATH=%{_lib}/cmake/%{name} \
    -DPYTHON_EXECUTABLE:PATH=/usr/bin/python2 \
    -DDAKOTA_PYTHON:BOOL=ON \
    -DDAKOTA_EXAMPLES_INSTALL:PATH=%{_lib}/%{name} \
    -DDakota_LIB_INSTALL_DIR:PATH=%{_lib} \
    -DDakota_INCLUDE_INSTALL_DIR:PATH=include/%{name} \
    -DDAKOTA_ENABLE_TESTS:BOOL=OFF \
%if 0%{with trilinos}
    -DCMAKE_CXX_FLAGS:STRING='-I/usr/include/trilinos' \
%else
    -DTrilinos_INSTALL_LIB_DIR:PATH=%{_lib} \
    -DDAKOTA_ENABLE_TEUCHOS_UNIT_TESTS:BOOL=OFF \
%endif
    #-DDAKOTA_HAVE_MPI:BOOL=ON \

%if 0%{?cmake_build:1}
    # OpenSUSE Tumbleweed
    %cmake_build
%else
    # OpenSUSE Leap 15.0
    %make_jobs
%endif

%install
%cmake_install

# set executable bit on example executables
chmod +x %{buildroot}/%{_libdir}/%{name}/examples/script_interfaces/TankExamples/tank_model/FEMTank.py
chmod +x %{buildroot}/%{_libdir}/%{name}/examples/parallelism/Case3-EvaluationTiling/MachinefileMgmt/pbs_submission
chmod +x %{buildroot}/%{_libdir}/%{name}/examples/parallelism/Case3-EvaluationTiling/OpenMPI/job_submission
chmod +x %{buildroot}/%{_libdir}/%{name}/examples/parallelism/Case4-EvaluationSubmission/post_process

chmod 0644 %{buildroot}/%{_libdir}/dakota/examples/linked_interfaces/Pyomo/diet.dat
chmod 0644 %{buildroot}/%{_libdir}/dakota/examples/linked_interfaces/linkage_spec/Dakota_3_1_2.xml
chmod 0644 %{buildroot}/%{_libdir}/dakota/examples/linked_interfaces/linkage_spec/Dakota_3_2.txt
chmod 0644 %{buildroot}/%{_libdir}/dakota/examples/script_interfaces/Rsmas/dakota_rsmas_grad_opt.in

# Delete unneeded files instead of excluding them
rm %{buildroot}/%{_bindir}/dakota.input.nspec
rm %{buildroot}/%{_bindir}/dakota.input.summary
rm %{buildroot}/%{_bindir}/dakota.xml
rm %{buildroot}/%{_bindir}/dakota.xsd

# Delete windows batch files
rm %{buildroot}/%{_libdir}/%{name}/examples/script_interfaces/Scilab/Rosenbrock/scilab_rosen_bb_simulator.bat
rm %{buildroot}/%{_libdir}/%{name}/examples/script_interfaces/generic/simulator_script.bat

# Delete Installation instructions
rm %{buildroot}/%{_datadir}/%{name}/INSTALL
rm -r %{buildroot}/%{_datadir}/%{name}/test

# Remove duplicate files
%fdupes %{buildroot}/%{_datadir}
%fdupes -s %{buildroot}
%fdupes %{buildroot}

# Fix #!/usr/bin/env python and script permissions
shopt -s extglob 
for i in $(find %{buildroot} \( -name "*.py" -o -name "*.sh" \) -a ! -type l ); do
  line=$(head -1 $i)
  case $line in
      \#\!*(\ )/usr/bin/env+(\ )python) 
      sed -i -e '1s,.*,#!/usr/bin/python,g' $i
      chmod 0755 $i ;;
      \#\!*)
      chmod 0755 $i ;;
  esac
done

%post -n lib%{name}%{so_ver} -p /sbin/ldconfig
%postun -n lib%{name}%{so_ver} -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc %{_datadir}/%{name}/README
%doc %{_datadir}/%{name}/VERSION

# Tumbleweed added a new macro for license files. See 'License files':
#   https://en.opensuse.org/openSUSE:Specfile_guidelines
%if 0%{?suse_version} < 1500
%doc %{_datadir}/%{name}/COPYRIGHT
%doc %{_datadir}/%{name}/LICENSE
%doc %{_datadir}/%{name}/LICENSE_HOPSPACK
%else
%license %{_datadir}/%{name}/COPYRIGHT
%license %{_datadir}/%{name}/LICENSE
%license %{_datadir}/%{name}/LICENSE_HOPSPACK
%endif

%{_bindir}/*


# Include Python and Bash bindings by default
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/Bash
%{_datadir}/%{name}/Python

%files -n lib%{name}%{so_ver}
%{_libdir}/*.so.*

%files devel
%{_libdir}/*.so
%{_libdir}/cmake/*
%{_includedir}/*

%files examples
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/examples


%changelog
openSUSE Build Service is sponsored by