File netcdf-fortran.spec of Package netcdf-fortran

#
# spec file
#
# 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 https://bugs.opensuse.org/
#


%global flavor @BUILD_FLAVOR@%{nil}

%define _do_check 1

%global pname netcdf-fortran
%global ver 4.5.3
%global _ver 4_5_3
%define sonum   7

%if 0%{?sle_version} >= 150200
%define DisOMPI1 ExclusiveArch:  do_not_build
%endif
%if !0%{?is_opensuse} && 0%{?sle_version:1}
 %if 0%{?sle_version} < 150200
  %define DisOMPI3 ExclusiveArch:  do_not_build
 %endif
 %if 0%{?sle_version} < 150300
  %define DisOMPI4 ExclusiveArch:  do_not_build
 %endif
%endif

ExcludeArch:    i586 %arm s390

%if "%flavor" == ""
ExclusiveArch:  do_not_build
%define package_name %pname
%define compiler_family gnu
%endif

ExcludeArch:    s390 s390x %ix86

#%%{bcond_with staticlibs}

%if "%flavor" == "gnu-hpc"
%global compiler_family gnu
%undefine c_f_ver
%{bcond_without hpc}
%{bcond_with mpi}
%endif

%if "%flavor" == "gnu-openmpi4-hpc"
%{?DisOMPI4}
%global compiler_family gnu
%undefine c_f_ver
%global mpi_flavor openmpi
%global mpi_ver 4
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu-openmpi5-hpc"
%{?DisOMPI5}
%global compiler_family gnu
%undefine c_f_ver
%global mpi_flavor openmpi
%global mpi_ver 5
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu-mvapich2-hpc"
%global compiler_family gnu
%undefine c_f_ver
%global mpi_flavor mvapich2
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu-mpich-hpc"
%global compiler_family gnu
%undefine c_f_ver
%global mpi_flavor mpich
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu7-hpc"
%global compiler_family gnu
%{bcond_without hpc}
%global c_f_ver 7
%endif

%if "%flavor" == "gnu7-openmpi4-hpc"
%{?DisOMPI4}
%global compiler_family gnu
%global mpi_flavor openmpi
%global mpi_ver 4
%global c_f_ver 7
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu7-openmpi5-hpc"
%{?DisOMPI5}
%global compiler_family gnu
%global mpi_flavor openmpi
%global mpi_ver 5
%global c_f_ver 7
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu7-mvapich2-hpc"
%global compiler_family gnu
%global mpi_flavor mvapich2
%global c_f_ver 7
%{bcond_without hpc}
%{bcond_without mpi}
%endif

%if "%flavor" == "gnu7-mpich-hpc"
%global compiler_family gnu
%global mpi_flavor mpich
%global c_f_ver 7
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu8-hpc"
%global compiler_family gnu
%{bcond_without hpc}
%global c_f_ver 8
%endif

%if "%flavor" == "gnu8-openmpi4-hpc"
%{?DisOMPI4}
%global compiler_family gnu
%global mpi_flavor openmpi
%global mpi_ver 4
%global c_f_ver 8
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu8-openmpi5-hpc"
%{?DisOMPI5}
%global compiler_family gnu
%global mpi_flavor openmpi
%global mpi_ver 5
%global c_f_ver 8
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu8-mvapich2-hpc"
%global compiler_family gnu
%global mpi_flavor mvapich2
%global c_f_ver 8
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu8-mpich-hpc"
%global compiler_family gnu
%global mpi_flavor mpich
%global c_f_ver 8
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu9-hpc"
%global compiler_family gnu
%{bcond_without hpc}
%global c_f_ver 9
%undefine mpi_flavor
%endif

%if "%flavor" == "gnu9-openmpi4-hpc"
%{?DisOMPI4}
%global compiler_family gnu
%global mpi_flavor openmpi
%global mpi_ver 4
%global c_f_ver 9
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu9-openmpi5-hpc"
%{?DisOMPI5}
%global compiler_family gnu
%global mpi_flavor openmpi
%global mpi_ver 5
%global c_f_ver 9
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu9-mvapich2-hpc"
%global compiler_family gnu
%global mpi_flavor mvapich2
%global c_f_ver 9
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu9-mpich-hpc"
%global compiler_family gnu
%global mpi_flavor mpich
%global c_f_ver 9
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu10-hpc"
%global compiler_family gnu
%{bcond_without hpc}
%global c_f_ver 10
%undefine mpi_flavor
%endif

%if "%flavor" == "gnu10-openmpi4-hpc"
%{?DisOMPI4}
%global compiler_family gnu
%global mpi_flavor openmpi
%global mpi_ver 4
%global c_f_ver 10
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu10-openmpi5-hpc"
%{?DisOMPI5}
%global compiler_family gnu
%global mpi_flavor openmpi
%global mpi_ver 5
%global c_f_ver 10
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu10-mvapich2-hpc"
%global compiler_family gnu
%global mpi_flavor mvapich2
%global c_f_ver 10
%{bcond_without hpc}
%endif

%if "%flavor" == "gnu10-mpich-hpc"
%global compiler_family gnu
%global mpi_flavor mpich
%global c_f_ver 10
%{bcond_without hpc}
%endif

%if "%{flavor}" == "openmpi4"
%{?DisOMPI4}
%define mpi_flavor openmpi
%define mpi_ver 4
%{bcond_with hpc}
%endif

%if "%{flavor}" == "openmpi5"
%{?DisOMPI5}
%define mpi_flavor openmpi
%define mpi_ver 5
%bcond_with hpc
%endif

%{?mpi_flavor:%{bcond_without mpi}}%{!?mpi_flavor:%{bcond_with mpi}}
%{?with_hpc:%{!?compiler_family:%global compiler_family gnu}}
%{?with_mpi:%{!?mpi_flavor:error "No MPI family specified!"}}

# openmpi 1 was called just "openmpi" in Leap 15.x/SLE15
%if 0%{?suse_version} >= 1550 || "%{mpi_flavor}" != "openmpi"  || "%{mpi_ver}" != "1"
%define mpi_ext %{?mpi_ver}
%endif

%if %{with hpc}
ExcludeArch:    %ix86
%{hpc_init -c %compiler_family %{?c_f_ver:-v %{c_f_ver}} %{?with_mpi:-m {%mpi_flavor}} %{?mpi_ver:-V %{mpi_ver}} %{?ext:-e %{ext}}}
%define package_name %{hpc_package_name %_ver}
%define libname(s:)   lib%{pname}%{hpc_package_name_tail %_ver}
%define p_prefix %hpc_prefix
%define p_bindir %hpc_bindir
%define p_libdir %hpc_libdir
%define p_mandir %hpc_mandir
%define p_includedir %hpc_includedir
%else
%define package_name %{pname}%{p_suffix}
%define libname(s:)   lib%{pname}%{-s*}%{?p_suffix}
 %if %{without mpi}
%define p_prefix %_prefix
%define p_bindir %_bindir
%define p_libdir %_libdir
%define p_mandir %_mandir
%define p_includedir %_includedir
 %else
%define p_prefix /usr/%{_lib}/mpi/gcc/%{mpi_flavor}%{?mpi_ext}
%define p_bindir %{p_prefix}/bin
%define p_libdir %{p_prefix}/%{_lib}
%define p_mandir %{p_prefix}/share/man
%define p_includedir %{p_prefix}/include
 %endif
%endif
%define p_suffix %{?with_mpi:-%{mpi_flavor}%{?mpi_ext}}

%define purpose_compiler %{?nil:%{!?with_hpc:.}
%{?with_hpc:built for the %{compiler_family} compiler%{?c_f_ver: version %c_f_ver}.}
}

%define purpose() This package contains %{?with_mpi:the %{mpi_flavor}%{?mpi_ver} version of }%{**}%{purpose_compiler}

%define limit_cores(c:) %{?_smp_mflags: %(a=1;
              b=$(sed -se "s/.*-j[[:space:]]*\\([[:digit:]]\\+\\).*/\\1/" <<< %_smp_mflags);
              [ $b -le $a ] || b=$a ;
              sed -se "s/\\(.*-j[[:space:]]*\\)[[:digit:]]\\+\\(.*\\)/\\1$b/" <<< %_smp_mflags )}

%define hpc_upcase_trans_hyph() %(echo %{**} | tr [a-z] [A-Z] | tr '-' '_')

%{?hpc_init:%{hpc_init -c %compiler_family %{?c_f_ver:-v %{c_f_ver}} %{?with_mpi:-m %mpi_flavor %{?mpi_ver:-V %mpi_ver}}}}
%{!?hpc_package_name_tail:%define hpc_package_name_tail %{nil}}

Name:           %package_name
Summary:        Command-line programs for the NetCDF scientific data format
License:        NetCDF
Group:          Productivity/Scientific/Other
Version:        %ver
Release:        0
URL:            https://www.unidata.ucar.edu/software/netcdf/
Source:         https://github.com/Unidata/netcdf-fortran/archive/v%{version}.tar.gz#/%{pname}-%{version}.tar.gz

BuildRequires:  gawk
BuildRequires:  libcurl-devel >= 7.18.0
BuildRequires:  m4
BuildRequires:  pkg-config
BuildRequires:  zlib-devel >= 1.2.5
%if %{without hpc}
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran
BuildRequires:  hdf5%{?with_mpi:-%{mpi_flavor}%{?mpi_ver}}-devel
BuildRequires:  hdf5%{p_suffix}-devel
BuildRequires:  libhdf5_hl%{p_suffix}
BuildRequires:  netcdf%{?with_mpi:-%{mpi_flavor}%{?mpi_ver}}-devel >= 4.7.4
 %if %{with mpi}
BuildRequires:  %{mpi_flavor}%{?mpi_ext}-devel
 %endif
%else
BuildRequires:  %{compiler_family}%{?c_f_ver}-compilers-hpc-macros-devel
BuildRequires:  %{compiler_family}-compilers-hpc
BuildRequires:  hdf5-%{compiler_family}%{?c_f_ver}%{?with_mpi:-%{mpi_flavor}%{?mpi_ver}}-hpc-devel
BuildRequires:  lua-lmod
BuildRequires:  netcdf-%{compiler_family}%{?c_f_ver}%{?with_mpi:-%{mpi_flavor}%{?mpi_ver}}-hpc-devel >= 4.7.4
BuildRequires:  suse-hpc
 %if %{with mpi}
BuildRequires:  %{mpi_flavor}%{?mpi_ver}-%{compiler_family}%{?c_f_ver}-hpc-macros-devel
 %endif
%endif
Requires:       %{libname}%{hpc_package_name_tail %_ver} = %{version}

%description
NetCDF is a set of software libraries and self-describing,
machine-independent data formats that support the creation, access,
and sharing of array-oriented scientific data.

This package contains the %{flavor} version of utility functions for
working with NetCDF files.

%package -n     %{libname -s %{sonum}}
Summary:        Shared libraries for the NetCDF scientific data format
Group:          System/Libraries
Provides:       %{libname} = %{version}
Obsoletes:      %{libname} < %{version}
%if %{with hpc}
%{?hpc_requires}
%{requires_eq libnetcdf-%{compiler_family}%{?c_f_ver}%{?with_mpi:-%{mpi_flavor}%{?mpi_ver}}-hpc}
%endif

%description -n %{libname -s %{sonum}}
NetCDF is a set of software libraries and self-describing,
machine-independent data formats that support the creation, access,
and sharing of array-oriented scientific data.

NetCDF (network Common Data Form) is an interface for array-oriented
data access and a collection of software libraries
for C, Fortran, C++, and Perl that provides an implementation of the
interface. The NetCDF library also defines a machine-independent
format for representing scientific data. Together, the interface,
library, and format support the creation, access, and sharing of
scientific data.

NetCDF data is:
   - Self-Describing: A NetCDF file includes information about the
     data it contains.
   - Network-transparent:  A NetCDF file is represented in a form that
     can be accessed by computers with different ways of storing
     integers, characters, and floating-point numbers.
   - Direct-access:  A small subset of a large dataset may be accessed
     efficiently, without first reading through all the preceding
     data.
   - Appendable:  Data can be appended to a NetCDF dataset along one
     dimension without copying the dataset or redefining its
     structure. The structure of a NetCDF dataset can be changed,
     though this sometimes causes the dataset to be copied.
   - Sharable:  One writer and multiple readers may simultaneously
     access the same NetCDF file.

This package contains all files needed to create projects that use
%{?mpi_flavor:the %mpi_flavor version of} NetCDF.

%if %{with hpc}
%{hpc_master_package -l -L -n %{libname}%{hpc_package_name_tail}}
%endif

%package devel
Summary:        Development files for %{name}
Group:          Development/Libraries/Parallel
Requires:       %{libname}%{hpc_package_name_tail %_ver} = %{version}
Requires:       libcurl-devel >= 7.18.0
Requires:       pkgconfig
Requires:       zlib-devel >= 1.2.5
%{?hpc_requires_devel}
%if %{with hpc}
%{requires_eq netcdf-%{compiler_family}%{?c_f_ver}%{?with_mpi:-%{mpi_flavor}%{?mpi_ver}}-hpc-devel}
%else
Requires:       netcdf-%{?with_mpi:%{mpi_flavor}%{?mpi_ver}}-devel
%endif
Obsoletes:      %{name} < %{version}-%{release}
Provides:       %{name} = %{version}-%{release}

%description devel
NetCDF is a set of software libraries and self-describing,
machine-independent data formats that support the creation, access,
and sharing of array-oriented scientific data.

This package contains all files needed to create projects that use
%{?mpi_flavor:the %mpi_flavor version of} NetCDF.

%if %{with hpc}
%{hpc_master_package devel -O netcdf-fortran%{?hpc_package_name_tail}}
%endif

%package devel-static
Summary:        Static development files for %{name}
Group:          Development/Libraries/Parallel
Requires:       %{name}-devel = %{version}
#Requires:       hdf-devel
%if %{with hpc}
%{requires_eq hdf5-%{compiler_family}%{?c_f_ver}%{?with_mpi:-%{mpi_flavor}%{?mpi_ver}}-hpc-devel}
%endif
Requires:       libcurl-devel >= 7.18.0
Requires:       zlib-devel >= 1.2.5

%description devel-static
NetCDF is a set of software libraries and self-describing,
machine-independent data formats that support the creation, access,
and sharing of array-oriented scientific data.

This package contains the static libraries for
%{?mpi_flavor:the %mpi_flavor version of} NetCDF.

%prep
%{?with_hpc: %hpc_debug}
%setup -q -n %{pname}-%{version}

# Create baselib.conf dynamically (non-HPC build only).
%if %{without hpc}
cat > %{_sourcedir}/baselibs.conf  <<EOF
%{libname -s %{sonum}}
EOF
%endif

# Fix spurious-executable-perm RPMLINT warning
chmod a-x RELEASE_NOTES.md

%build
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects
%{?with_hpc:%{hpc_setup}}
%{?with_hpc:module load netcdf}

%{?_smp_mflags:%global _smp_mflags %{limit_cores -c 8}}

%if %{without mpi}
export CC=gcc CXX=g++ FC=gfortran F77=gfortran
%else
export CC=%{!?with_hpc:/usr/%_lib/mpi/gcc/%{mpi_flavor}%{?mpi_ext}/bin/}mpicc
export FC=%{!?with_hpc:/usr/%_lib/mpi/gcc/%{mpi_flavor}%{?mpi_ext}/bin/}mpif90
export F77=%{!?with_hpc:/usr/%_lib/mpi/gcc/%{mpi_flavor}%{?mpi_ext}/bin/}mpif77
export CXX=%{!?with_hpc:/usr/%_lib/mpi/gcc/%{mpi_flavor}%{?mpi_ext}/bin/}mpic++
%endif

# definition to be checked:
%{!?with_hpc:export NETCDF_INC=/usr/%_lib/mpi/gcc/%{mpi_flavor}%{?mpi_ext}/include}
%{!?with_hpc:export NETCDF_LIB=/usr/%_lib/mpi/gcc/%{mpi_flavor}%{?mpi_ext}/lib64}
%{!?with_hpc:export HDF5_LIB=$NETCDF_LIB}

export CFLAGS="%{optflags} %{?with_hpc:-I$NETCDF_INC -L$NETCDF_LIB -lnetcdf -L$HDF5_LIB -lhdf5}"
export FCFLAGS="%{optflags} -std=legacy"
export FFLAGS=$FCFLAGS
export CPPFLAGS=$CFLAGS
export LDFLAGS="-L$NETCDF_LIB -lnetcdf -L$HDF5_LIB -lhdf5"

%if %{without hpc}
%configure \
     --prefix=%{p_prefix} \
     --bindir=%{p_bindir} \
     --libdir=%{p_libdir} \
     --includedir=%{p_includedir} \
     --mandir=%{p_mandir} \
%else
%hpc_configure \
    --enable-shared \
    --with-pic \
    --disable-doxygen \
    --enable-static
%endif

make %{?_smp_mflags}

%install
%if %{with hpc}
%{hpc_setup}
module load netcdf
%endif
export CFLAGS="%{optflags} -I $NETCDF_INC -L$NETCDF_LIB -lnetcdf -L$HDF5_LIB -lhdf5"
export FCFLAGS="%{optflags}"
export CPPFLAGS=$CFLAGS
export LDFLAGS="-L$NETCDF_LIB -lnetcdf -L$HDF5_LIB -lhdf5"
%if %{with mpi}
export CC="mpicc"
export FC="mpif90"
export F77="mpif77"
%endif

make install DESTDIR="%{buildroot}"

rm -f %{p_libdir}/*.la

%if %{without mpi} && %{without hpc}
# rpm macro for version checking
mkdir -p %{buildroot}%{_rpmmacrodir}
cat > %{buildroot}%{_rpmmacrodir}/macros.netcdf-fortran <<EOF
#
# RPM macros for netcdf-fortran packaging
#
%_netcdf-fortran_sonum  %{sonum}
%_netcdf-fortran_version  %{version}
EOF
%endif

%if %{without hpc}
 %if %{with mpi}
# Module files
mkdir -p %{buildroot}%{_datadir}/modules/%{pname}-%{mpi_flavor}%{?mpi_ext}
cat << EOF > %{buildroot}%{_datadir}/modules/%{pname}-%{mpi_flavor}%{?mpi_ext}/%version
#%%Module
proc ModulesHelp { } {
        global dotversion
        puts stderr "\tLoads the %{pname}-%{mpi_flavor} %version Environment"
}

module-whatis  "Loads the %{pname}-%{mpi_flavor} %version Environment."
prepend-path    PATH                %{p_bindir}
prepend-path    MANPATH             %{p_mandir}
prepend-path    LD_LIBRARY_PATH     %{p_libdir}
prepend-path    LIBRARY_PATH        %{p_libdir}
prepend-path    CPATH               %{p_includedir}
prepend-path    C_INCLUDE_PATH      %{p_includedir}
prepend-path    CPLUS_INCLUDE_PATH  %{p_includedir}
EOF

 %endif
%else
%hpc_write_modules_files
#%%Module1.0#####################################################################

proc ModulesHelp { } {

puts stderr " "
puts stderr "This module loads the NetCDF Fortran API built with the %{compiler_family} compiler toolchain."
puts stderr " "
puts stderr "Note that this build of NetCDF leverages the HDF I/O library and requires linkage"
puts stderr "against hdf5 and the native C NetCDF library. Consequently, phdf5 and the standard C"
puts stderr "version of NetCDF are loaded automatically via this module. A typical compilation"
puts stderr "example for Fortran applications requiring NetCDF is as follows:"
puts stderr " "
puts stderr "\\\$FC  -I\\\$NETCDF_FORTRAN_INC app.f90 -L\\\$NETCDF_FORTRAN_LIB -lnetcdff -L\\\$NETCDF_LIB -lnetcdf -L\\\$HDF5_LIB -lhdf5"

puts stderr "\nVersion %{version}\n"

}
module-whatis "Name: %{hpc_upcase %pname} built with %{compiler_family} toolchain %{mpi_flavor: and %{mpi_flavor}}"
module-whatis "Version: %{version}"
module-whatis "Category: runtime library"
module-whatis "Description: %{SUMMARY:0}"
module-whatis "%{url}"

# Require generic netcdf

if [ expr [ module-info mode load ] || [module-info mode display ] ] {
    if {  ![is-loaded netcdf]  } {
        module load netcdf
    }
}

set             version             %{version}

prepend-path    PATH                %{hpc_bindir}
prepend-path    MANPATH             %{hpc_mandir}
prepend-path    LD_LIBRARY_PATH     %{hpc_libdir}

setenv          %{hpc_upcase_trans_hyph %pname}_DIR        %{hpc_prefix}
if {[file isdirectory  %{hpc_bindir}]} {
setenv          %{hpc_upcase_trans_hyph %pname}_BIN        %{hpc_bindir}
}
if {[file isdirectory  %{hpc_includedir}]} {
prepend-path    LIBRARY_PATH        %{hpc_libdir}
prepend-path    CPATH               %{hpc_includedir}
prepend-path    C_INCLUDE_PATH      %{hpc_includedir}
prepend-path    CPLUS_INCLUDE_PATH  %{hpc_includedir}
prepend-path    INCLUDE                         %{hpc_includedir}
%hpc_modulefile_add_pkgconfig_path

setenv          %{hpc_upcase_trans_hyph %pname}_LIB        %{hpc_libdir}
setenv          %{hpc_upcase_trans_hyph %pname}_INC        %{hpc_includedir}
}
EOF
%endif

%if %_do_check
%check
 %if %{with hpc}
%{hpc_setup}
module load netcdf
export CFLAGS="-I $NETCDF_INC -L$NETCDF_LIB -lnetcdf -L$HDF5_LIB -lhdf5"
export CPPFLAGS=$CFLAGS
export LDFLAGS="-L$NETCDF_LIB -lnetcdf -L$HDF5_LIB -lhdf5"
  %if 0%{with mpi}
export CC="mpicc"
export FC="mpif90"
export F77="mpif77"
  %endif
make check
 %else
echo "CC: $CC"
echo "FC: $FC"
echo "F77: $F77"
  %if 0%{with mpi}
export CC=/usr/%_lib/mpi/gcc/%{mpi_flavor}%{?mpi_ext}/bin/mpicc
export FC=/usr/%_lib/mpi/gcc/%{mpi_flavor}%{?mpi_ext}/bin/mpif90
export F77=/usr/%_lib/mpi/gcc/%{mpi_flavor}%{?mpi_ext}/bin/mpif77
export NETCDF_INC=/usr/lib64/mpi/gcc/openmpi5/include
export NETCDF_LIB=/usr/lib64/mpi/gcc/openmpi5/lib64
export HDF5_LIB=/usr/lib64/mpi/gcc/openmpi5/lib64
  %else
export CC=gcc CXX=g++ FC=gfortran F77=gfortran
  %endif
export CFLAGS="-I $NETCDF_INC -L$NETCDF_LIB -lnetcdf -L$HDF5_LIB -lhdf5"
export FCFLAGS="{optflags} -std=legacy"
export FFLAGS=$FCFLAGS
export CPPFLAGS=$CFLAGS
export LDFLAGS="-L$NETCDF_LIB -lnetcdf -L$HDF5_LIB -lhdf5"
export LD_LIBRARY_PATH=$NETCDF_LIB:$LD_LIBRARY_PATH
echo "CC: $CC"
echo "FC: $FC"
echo "F77: $F77"
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"

make check
 %endif
%endif

%if %{with hpc} || %{with mpi}
%define ldconfig_args -N %p_libdir
%endif

%post -n %{libname -s %{sonum}}
/sbin/ldconfig %{?ldconfig_args}

%postun -n %{libname -s %{sonum}}
/sbin/ldconfig %{?ldconfig_args}
%{?with_hpc:%hpc_module_delete_if_default}

%files -n %{libname -s %{sonum}}
%doc COPYRIGHT README.md RELEASE_NOTES.md
%if %{with hpc}
%{hpc_dirs}
%{hpc_modules_files}
%else
 %if %{with mpi}
%dir %{_datadir}/modules
%{_datadir}/modules/%{pname}-%{mpi_flavor}%{?mpi_ext}
 %endif
%endif
%{p_libdir}/libnetcdff.so.%{sonum}*

%files devel
%{p_includedir}%{!?with_hpc:/*}
%{p_libdir}/*.so
%{?with_hpc:%hpc_pkgconfig_file}
%{p_libdir}/pkgconfig/netcdf-fortran.pc
%dir %{p_mandir}
%{p_mandir}/man3
%{p_libdir}/libnetcdff.settings

%{?with_hpc:%dir %{hpc_datadir}}
%{p_bindir}/

%files devel-static
%{p_libdir}/libnetcdff.a
%{p_libdir}/libnetcdff.la

%changelog
openSUSE Build Service is sponsored by