File dakota.spec of Package dakota

#
# spec file for package dakota
#
# Copyright (c) 2023 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/
#

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

Name:           dakota
Version:        6.17.0
Release:        0
Summary:        Explore and predict with confidence
License:        LGPL-2.1-or-later
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-cli.tar.gz
Recommends:     %{name}-examples

BuildRequires:  blas-devel
BuildRequires:  cmake
BuildRequires:  eigen3-devel
BuildRequires:  fdupes
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran
BuildRequires:  lapack-devel
BuildRequires:  libboost_filesystem-devel >= 1.69
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_regex-devel
BuildRequires:  libboost_serialization-devel
BuildRequires:  libboost_system-devel
BuildRequires:  perl
BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module numpy-devel}
%{?with_trilinos:BuildRequires:  trilinos-devel}

# See the following section on setting memory-related constraints
# without a '_constraints' file
#   https://en.opensuse.org/openSUSE:Specfile_guidelines
BuildRequires:  memory-constraints


%description
The Dakota project delivers both state-of-the-art research and robust,
usable software for optimization and UQ. Broadly, the Dakota
software's 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 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}-release-public-src-cli

# Remove bad .orig file
find . -name '*cmake.orig' -print -delete

%build
# Ignore bad switch statements, https://github.com/snl-dakota/dakota-packages/issues/2
%global optflags %{optflags} -Wno-error=return-type
# Remove RPATHs, all libraries are installed in %{_libdir}
%cmake \
    -DCMAKE_SHARED_LINKER_FLAGS:STRING="-Wl,--as-needed -Wl,-z,now" \
    -DCMAKE_SKIP_RPATH:BOOL=ON \
    -DDakota_INSTALL_CMAKE_DIR:PATH=%{_lib}/cmake/%{name} \
    -DPYTHON_EXECUTABLE:PATH=%python3 \
    -DDAKOTA_PYTHON:BOOL=ON \
    -DDAKOTA_EXAMPLES_INSTALL:PATH=%{_lib}/%{name} \
    -DDakota_INCLUDE_INSTALL_DIR:PATH=include/%{name} \
    -DDAKOTA_ENABLE_TESTS:BOOL=OFF \
    -DEigen3_DIR=/usr/share/eigen3/cmake \
%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 \

# Require 2GB mem per thread
%limit_build -m 2000
%cmake_build

%install
%cmake_install

%if "%{_lib}" != "lib"
# https://github.com/snl-dakota/dakota-packages/issues/3
mv %{buildroot}/%{_prefix}/lib/*.so* %{buildroot}/%{_libdir}/
mv %{buildroot}/%{_prefix}/lib/cmake/* %{buildroot}/%{_libdir}/cmake/
%endif

# Convert all instances of #!/usr/bin/env python to #!/usr/bin/python3
find %{buildroot} -type f -iname \*py -exec sed -i '1 { /env python/ s@.*@#!/usr/bin/python3@ }' '{}' \;

# set executable bit on example executables
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

# 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/official/drivers/windows_bat/simulator_script.bat
rm %{buildroot}/%{_libdir}/%{name}/examples/users/Scilab/script/Rosenbrock/scilab_rosen_bb_simulator.bat

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

# Create python .pth file for importing dakota.interfacing module
mkdir -p %{buildroot}/%{python_sitelib}
echo %{_datadir}/%{name}/Python > %{buildroot}/%{python_sitelib}/dakota.pth

# Remove duplicate files
%fdupes %{buildroot}/%{_bindir}
%fdupes %{buildroot}/%{_datadir}
%fdupes %{buildroot}/%{_libdir}/%{name}/examples

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

%files
%doc %{_datadir}/%{name}/{README,VERSION}
%license %{_datadir}/%{name}/{COPYRIGHT,LICENSE,LICENSE_HOPSPACK}
%{_bindir}/*
# Include Python and Bash bindings by default
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/Bash
%{_datadir}/%{name}/Python
%{python_sitelib}/dakota.pth
%{_libdir}/*.so.*

%files devel
%dir %{_libdir}/%{name}
%{_libdir}/*.so
%{_libdir}/cmake/*
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/plugins
%{_includedir}/*

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

%changelog
openSUSE Build Service is sponsored by