From b9d7608ce6081b097a9631efeef527238eb9a01e Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Feb 10 2012 18:16:08 +0000 Subject: Enable MPI builds --- diff --git a/netcdf-mpi.patch b/netcdf-mpi.patch new file mode 100644 index 0000000..97b8111 --- /dev/null +++ b/netcdf-mpi.patch @@ -0,0 +1,17 @@ +diff -up netcdf-4.1.3/libdispatch/parallel.c.mpi netcdf-4.1.3/libdispatch/parallel.c +--- netcdf-4.1.3/libdispatch/parallel.c.mpi 2011-06-10 07:35:00.000000000 -0600 ++++ netcdf-4.1.3/libdispatch/parallel.c 2012-02-10 10:46:18.229286019 -0700 +@@ -29,13 +29,8 @@ nc_create_par(const char *path, int cmod + !(cmode & NC_PNETCDF)) + return NC_EINVAL; + +-#ifdef HAVE_MPI_COMM_F2C +- comm_c = MPI_Comm_f2c(comm); +- info_c = MPI_Info_f2c(info); +-#else + comm_c = (MPI_Comm)comm; + info_c = (MPI_Info)info; +-#endif + + data.comm = comm_c; + data.info = info_c; diff --git a/netcdf-postdeps.patch b/netcdf-postdeps.patch new file mode 100644 index 0000000..07fda04 --- /dev/null +++ b/netcdf-postdeps.patch @@ -0,0 +1,32 @@ +diff -up netcdf-4.1.3/configure.postdeps netcdf-4.1.3/configure +--- netcdf-4.1.3/configure.postdeps 2011-06-17 14:52:05.000000000 -0600 ++++ netcdf-4.1.3/configure 2012-02-07 21:41:30.207617024 -0700 +@@ -21293,15 +21293,16 @@ if { { eval echo "\"\$as_me\":${as_linen + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no +- ++set -x + for p in `eval "$output_verbose_link_cmd"`; do + case ${prev}${p} in + + -L* | -R* | -l*) +- # Some compilers place space between "-{L,R}" and the path. ++ # Some compilers place space between "-{L,R,l}" and the path. + # Remove the space. + if test $p = "-L" || +- test $p = "-R"; then ++ test $p = "-R" || ++ test $p = "-l"; then + prev=$p + continue + fi +@@ -21370,7 +21371,7 @@ if { { eval echo "\"\$as_me\":${as_linen + + esac + done +- ++set +x + # Clean up. + rm -f a.out a.exe + else diff --git a/netcdf.spec b/netcdf.spec index 27d2a31..4b41425 100644 --- a/netcdf.spec +++ b/netcdf.spec @@ -1,6 +1,6 @@ Name: netcdf Version: 4.1.3 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Libraries for the Unidata network Common Data Form Group: Applications/Engineering @@ -12,6 +12,10 @@ Source0: http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-%{versio Patch0: netcdf-pkgconfig.patch #Strip FFLAGS from nc-config Patch1: netcdf-fflags.patch +# Fix issue parsing mpif90 output +Patch2: netcdf-postdeps.patch +# Upstream patch to fix mpi issue +Patch3: netcdf-mpi.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: gcc-gfortran, gawk @@ -21,6 +25,29 @@ BuildRequires: zlib-devel %ifnarch s390 s390x %{arm} BuildRequires: valgrind %endif +#mpiexec segfaults if ssh is not present +#https://trac.mcs.anl.gov/projects/mpich2/ticket/1576 +BuildRequires: openssh-clients + +%global with_mpich2 1 +%global with_openmpi 1 +%if 0%{?rhel} +%ifarch ppc64 +# No mpich2 on ppc64 in EL +%global with_mpich2 0 +%endif +%endif +%ifarch s390 s390x +# No openmpi on s390(x) +%global with_openmpi 0 +%endif + +%if %{with_mpich2} +%global mpi_list mpich2 +%endif +%if %{with_openmpi} +%global mpi_list %{?mpi_list} openmpi +%endif %description NetCDF (network Common Data Form) is an interface for array-oriented @@ -77,38 +104,162 @@ Requires: %{name} = %{version}-%{release} This package contains the netCDF static libs. +%if %{with_mpich2} +%package mpich2 +Summary: NetCDF mpich2 libraries +Group: Development/Libraries +Requires: mpich2 +BuildRequires: mpich2-devel +BuildRequires: hdf5-mpich2-devel >= 1.8.4 + +%description mpich2 +NetCDF parallel mpich2 libraries + + +%package mpich2-devel +Summary: NetCDF mpich2 development files +Group: Development/Libraries +Requires: %{name}-mpich2%{?_isa} = %{version}-%{release} +Requires: mpich2 +Requires: gcc-gfortran%{_isa} +Requires: pkgconfig +Requires: hdf5-mpich2-devel +Requires: libcurl-devel + +%description mpich2-devel +NetCDF parallel mpich2 development files + + +%package mpich2-static +Summary: NetCDF mpich2 static libraries +Group: Development/Libraries +Requires: %{name}-mpich2-devel%{?_isa} = %{version}-%{release} + +%description mpich2-static +NetCDF parallel mpich2 static libraries +%endif + + +%if %{with_openmpi} +%package openmpi +Summary: NetCDF openmpi libraries +Group: Development/Libraries +Requires: openmpi +BuildRequires: openmpi-devel +BuildRequires: hdf5-openmpi-devel >= 1.8.4 + +%description openmpi +NetCDF parallel openmpi libraries + + +%package openmpi-devel +Summary: NetCDF openmpi development files +Group: Development/Libraries +Requires: %{name}-openmpi%{_isa} = %{version}-%{release} +Requires: openmpi-devel +Requires: gcc-gfortran%{_isa} +Requires: pkgconfig +Requires: hdf5-openmpi-devel +Requires: libcurl-devel + +%description openmpi-devel +NetCDF parallel openmpi development files + + +%package openmpi-static +Summary: NetCDF openmpi static libraries +Group: Development/Libraries +Requires: %{name}-openmpi-devel%{?_isa} = %{version}-%{release} + +%description openmpi-static +NetCDF parallel openmpi static libraries +%endif + + %prep %setup -q %patch0 -p1 -b .pkgconfig %patch1 -p1 -b .fflags +%patch2 -p1 -b .postdeps +%patch3 -p1 -b .mpi %build +#Do out of tree builds +%global _configure ../configure +#Common configure options +%global configure_opts \\\ + --enable-shared \\\ + --enable-netcdf-4 \\\ + --enable-dap \\\ + --enable-ncgen4 \\\ + --enable-extra-example-tests \\\ + --disable-dap-remote-tests \\\ +%{nil} + +# Serial build export F77="gfortran" export FC="gfortran" export FFLAGS="${RPM_OPT_FLAGS}" export FCFLAGS="$FFLAGS" -%configure \ - --enable-shared \ - --enable-netcdf-4 \ - --enable-dap \ - --enable-ncgen4 \ - --enable-extra-example-tests \ - --disable-dap-remote-tests +mkdir build +pushd build +ln -s ../configure . +%configure %{configure_opts} make %{?_smp_mflags} +popd + +# MPI builds +export CC=mpicc +export CXX=mpicxx +export F77=mpif90 +export FC=mpif90 +# netcdf gets confused about Fortran type +export CPPFLAGS=-DpgiFortran +for mpi in %{mpi_list} +do + mkdir $mpi + pushd $mpi + module load $mpi-%{_arch} + ln -s ../configure . + %configure %{configure_opts} \ + --libdir=%{_libdir}/$mpi/lib \ + --bindir=%{_libdir}/$mpi/bin \ + --sbindir=%{_libdir}/$mpi/sbin \ + --includedir=%{_includedir}/$mpi-%{_arch} \ + --datarootdir=%{_libdir}/$mpi/share \ + --mandir=%{_libdir}/$mpi/share/man \ + --enable-parallel-tests + make %{?_smp_mflags} + module purge + popd +done %install -make install DESTDIR=${RPM_BUILD_ROOT} +make -C build install DESTDIR=${RPM_BUILD_ROOT} mkdir -p ${RPM_BUILD_ROOT}%{_fmoddir} /bin/mv ${RPM_BUILD_ROOT}%{_includedir}/*.mod \ ${RPM_BUILD_ROOT}%{_fmoddir} /bin/rm -f ${RPM_BUILD_ROOT}%{_libdir}/*.la /bin/rm -f ${RPM_BUILD_ROOT}%{_infodir}/dir +for mpi in %{mpi_list} +do + module load $mpi-%{_arch} + make -C $mpi install DESTDIR=${RPM_BUILD_ROOT} + rm $RPM_BUILD_ROOT/%{_libdir}/$mpi/lib/*.la + module purge +done %check -make check +make -C build check +for mpi in mpich2 openmpi +do + module load $mpi-%{_arch} + make -C $mpi check + module purge +done %clean @@ -129,7 +280,6 @@ fi %files -%defattr(-,root,root,-) %doc COPYRIGHT README %{_bindir}/nccopy %{_bindir}/ncdump @@ -140,7 +290,6 @@ fi %{_infodir}/* %files devel -%defattr(-,root,root,-) %{_bindir}/nc-config %{_includedir}/ncvalues.h %{_includedir}/netcdf.h @@ -153,11 +302,55 @@ fi %{_mandir}/man3/* %files static -%defattr(-,root,root,-) %{_libdir}/*.a +%if %{with_mpich2} +%files mpich2 +%doc COPYRIGHT README +%{_libdir}/mpich2/bin/nccopy +%{_libdir}/mpich2/bin/ncdump +%{_libdir}/mpich2/bin/ncgen +%{_libdir}/mpich2/bin/ncgen3 +%{_libdir}/mpich2/lib/*.so.* +%doc %{_libdir}/mpich2/share/man/man1/*.1* + +%files mpich2-devel +%{_libdir}/mpich2/bin/nc-config +%{_includedir}/mpich2-%{_arch} +%{_libdir}/mpich2/lib/*.so +%{_libdir}/mpich2/lib/pkgconfig/%{name}.pc +%doc %{_libdir}/mpich2/share/man/man3/*.3* + +%files mpich2-static +%{_libdir}/mpich2/lib/*.a +%endif + +%if %{with_openmpi} +%files openmpi +%doc COPYRIGHT README +%{_libdir}/openmpi/bin/nccopy +%{_libdir}/openmpi/bin/ncdump +%{_libdir}/openmpi/bin/ncgen +%{_libdir}/openmpi/bin/ncgen3 +%{_libdir}/openmpi/lib/*.so.* +%doc %{_libdir}/openmpi/share/man/man1/*.1* + +%files openmpi-devel +%{_libdir}/openmpi/bin/nc-config +%{_includedir}/openmpi-%{_arch} +%{_libdir}/openmpi/lib/*.so +%{_libdir}/openmpi/lib/pkgconfig/%{name}.pc +%doc %{_libdir}/openmpi/share/man/man3/*.3* + +%files openmpi-static +%{_libdir}/openmpi/lib/*.a +%endif + %changelog +* Wed Feb 1 2012 Orion Poplawski - 4.1.3-3 +- Enable MPI builds + * Thu Aug 11 2011 Peter Robinson - 4.1.3-2 - Add ARM to valgrind excludes