git: 1afb7cd5cdc7 - main - science/abinit: Add MPI options; Fix run-time failures due to wrong version

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Fri, 30 Aug 2024 17:51:00 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1afb7cd5cdc7ba233f6960f1cec714333a4ec76c

commit 1afb7cd5cdc7ba233f6960f1cec714333a4ec76c
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-08-30 16:23:38 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-08-30 17:50:55 +0000

    science/abinit: Add MPI options; Fix run-time failures due to wrong version
    
    MPI options NOMPI MPICH OPENMPI are added, MPICH is a default.
    
    As it turned out, openmpi is also currently broken on FreeBSD due
    to failure to allocate shmem backing memory.
    
    The abinit failure to determine version is also fixed.
    It used UNKNOWN as version which caused run-time failure to save data.
    
    PR:             281122
    Reported by:    Ramon <rcuscoptc@gmail.com> (run-time failure due to UNKNOWN version)
---
 science/abinit/Makefile | 63 +++++++++++++++++++++++++++++++++++--------------
 1 file changed, 45 insertions(+), 18 deletions(-)

diff --git a/science/abinit/Makefile b/science/abinit/Makefile
index 1ee395d138f0..bf8fe2fe8d9d 100644
--- a/science/abinit/Makefile
+++ b/science/abinit/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	abinit
 DISTVERSION=	10.0.7
+PORTREVISION=	1
 CATEGORIES=	science
 
 MAINTAINER=	yuri@FreeBSD.org
@@ -55,29 +56,43 @@ PORTDOCS=	*
 
 BINARY_ALIAS=	git=false
 
-OPTIONS_DEFINE=			DOCS OPENMP OPENMPI
-OPTIONS_DEFAULT=		OPENMP OPENMPI
+OPTIONS_DEFINE=			DOCS OPENMP
+OPTIONS_DEFAULT=		MPICH
+OPTIONS_RADIO=			MPIX
+OPTIONS_RADIO_MPIX=		NOMPI MPICH OPENMPI
 
 OPENMP_CONFIGURE_ENABLE=	openmp
 OPENMP_LDFLAGS=			-lomp
 
-OPENMPI_CONFIGURE_WITH=		mpi=yes
-# BROKEN with MPICH4: see <https://github.com/abinit/abinit/issues/61>
-# To set back to mpich when this issue will be fixed.
+MIX_DESC=			MPI options
+
+NOMPI_DESC=			Do not use MPI
+NOMPI_CONFIGURE_ON=		CC_LDFLAGS="${LDFLAGS}" CXX_LDFLAGS="${LDFLAGS}"	\
+				FC_LDFLAGS="${LDFLAGS}" CFLAGS="${CFLAGS}"
+
 OPENMPI_USES=			mpi:openmpi
-# fftw3 not enabled because libfftw3_mpi is required but not packaged
-OPENMPI_VARS=			FCFLAGS+="`pkg-config --cflags ompi-fort`"
-OPENMPI_CONFIGURE_ENV=		CC_LDFLAGS="${MPI_LIBS} ${LDFLAGS}"	\
-				CXX_LDFLAGS="${MPI_LIBS} ${LDFLAGS}"	\
-				FC_LDFLAGS="${MPI_LIBS} ${LDFLAGS}"	\
-				CFLAGS="${MPI_CFLAGS} ${CFLAGS}  ${CFLAGS_F2018}"	\
-				MPI_CPPFLAGS="${MPI_CFLAGS}"	\
-				MPI_FCFLAGS="`pkg-config --cflags ompi-fort`"	\
-				MPI_LIBS="${MPI_LIBS}"	\
+OPENMPI_CONFIGURE_ON=		mpi=yes
+OPENMPI_VARS=			FCFLAGS+="`pkg-config --cflags ompi-fort`" \
+				CFLAGS+="${MPI_CFLAGS}" \
+				LDFLAGS+="${MPI_LDFLAGS}"
+OPENMPI_CONFIGURE_ENV=		${MPIX_CONFIGURE_ENV} \
+				MPI_FCFLAGS="`pkg-config --cflags ompi-fort`"
+
+MPICH_USES=			mpi:mpich
+MPICH_CONFIGURE_ON=		mpi=yes
+MPICH_VARS=			FFLAGS+=-I${LOCALBASE}/include FCFLAGS+=-I${LOCALBASE}/include	\
+				CONFIGURE_ENV+=MPI_LIBS="`pkg-config --libs mpich` -lmpifort"	\
+				CONFIGURE_ENV+MPI_LDFLAGS="`pkg-config --libs mpich` -lmpifort"
+MPICH_CONFIGURE_ENV=		${MPIX_CONFIGURE_ENV}
+
+MPIX_CONFIGURE_ENV=		CC_LDFLAGS="${MPI_LIBS} ${LDFLAGS}" \
+				CXX_LDFLAGS="${MPI_LIBS} ${LDFLAGS}" \
+				FC_LDFLAGS="${MPI_LIBS} ${LDFLAGS}" \
+				CFLAGS="${MPI_CFLAGS} ${CFLAGS} ${CFLAGS_F2018}" \
+				MPI_CPPFLAGS="${MPI_CFLAGS}" \
+				MPI_LIBS="${MPI_LIBS}" \
 				MPI_LDFLAGS="${MPI_LIBS}"
 # When OpenMPI is enabled, put its related variables 1st to avoid conflicts with MPICH
-OPENMPI_CONFIGURE_ENV_OFF=	CC_LDFLAGS="${LDFLAGS}" CXX_LDFLAGS="${LDFLAGS}"	\
-				FC_LDFLAGS="${LDFLAGS}" CFLAGS="${CFLAGS}"
 
 .if defined(WITH_LEVMAR)
 # --with-levmar seems deprecated
@@ -92,8 +107,11 @@ CONFIGURE_ARGS+=	--with-levmar
 FCFLAGS+=	-fallow-argument-mismatch # see https://github.com/abinit/abinit/issues/41
 .endif
 
-pre-configure:
-	(cd ${WRKSRC} && ./autogen.sh)
+pre-configure: # version lines below are workaround for https://github.com/abinit/abinit/issues/75
+	@cd ${WRKSRC} && \
+		${ECHO} ${PORTVERSION} > .version && \
+		${REINPLACE_CMD} -e 's|UNKNOWN|${PORTVERSION}|' ${WRKSRC}/config/scripts/git-version-gen && \
+		./autogen.sh
 
 post-install-DOCS-on:
 	${REINPLACE_CMD} -e 's|/usr/bin/env  python|${PYTHON_CMD}|'	\
@@ -105,4 +123,13 @@ post-install-DOCS-on:
 pre-test:
 	${TOUCH} ${TEST_WRKSRC}/make.log
 
+test-long: # run all examples from tutorial/Input
+	@cd ${WRKSRC}/tests/tutorial/Input && \
+		for abi in `${LS} *.abi`; do \
+			${ECHO} "===> Running example $$abi" && \
+			${SETENV} PATH=${STAGEDIR}${PREFIX}/bin:${PATH} ABI_PSPDIR=${WRKSRC}/tests/Psps_for_tests abinit $$abi; \
+		done
+
+# fftw3 not enabled because libfftw3_mpi is required but not packaged
+
 .include <bsd.port.post.mk>