#! /bin/sh /usr/share/dpatch/dpatch-run
## 321-support-gfortran.dpatch by <kmccarty@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Support compilation with gfortran. Patch thanks to Harald Vogt
@DPATCH@
diff -urNad cernlib-2005.dfsg~/src/mathlib/gen/c/rteq464.F cernlib-2005.dfsg/src/mathlib/gen/c/rteq464.F
--- cernlib-2005.dfsg~/src/mathlib/gen/c/rteq464.F 1996-04-01 10:01:53.000000000 -0500
+++ cernlib-2005.dfsg/src/mathlib/gen/c/rteq464.F 2006-09-07 15:06:08.249547206 -0400
@@ -45,7 +45,16 @@
MT=3
Z(1)=SQRT(SQRT(-D))
Z(2)=-Z(1)
+#if !defined(CERNLIB_GFORTRAN)
Z(3)=SQRT(-Z(1)**2)
+#else
+* Using gfortran the following sqrt yields an inconsistent result
+* if the imaginary part is a "negative zero"
+* gfortran is conform with the Fortran ISO 2003 standard (1.6.1)
+* Therefore if the imaginary part is a "negative zero"
+* it must be replaced by a "positive zero" to be consistent
+ if (imag(-z(1)**2) .eq. 0) z(3)=SQRT(real(-z(1)**2)+i*0)
+#endif
Z(4)=-Z(3)
ENDIF
DC=(-R12*D)**3
@@ -94,9 +103,21 @@
W1=SQRT(U(K1)+I*0)
W2=SQRT(U(K2)+I*0)
ELSE
+#if !defined(CERNLIB_GFORTRAN)
MT=3
W1=SQRT(U(2)+I*U(3))
W2=SQRT(U(2)-I*U(3))
+#else
+* For gfortran see above
+ MT=3
+ IF (U(3) .NE. 0.) THEN
+ W1=SQRT(U(2)+I*U(3))
+ W2=SQRT(U(2)-I*U(3))
+ ELSE
+ W1=SQRT(U(2)+I*0)
+ W2=W1
+ ENDIF
+#endif
ENDIF
W3=0
IF(W1*W2 .NE. 0) W3=-Q/(8*W1*W2)
diff -urNad cernlib-2005.dfsg~/src/mathlib/gen/v/nranf.F cernlib-2005.dfsg/src/mathlib/gen/v/nranf.F
--- cernlib-2005.dfsg~/src/mathlib/gen/v/nranf.F 1996-04-01 10:02:54.000000000 -0500
+++ cernlib-2005.dfsg/src/mathlib/gen/v/nranf.F 2006-09-07 15:06:08.250546993 -0400
@@ -14,10 +14,12 @@
VECTOR(I) = RNDM(I)
100 CONTINUE
RETURN
- ENTRY NRANIN (V)
+ END
+ SUBROUTINE NRANIN (V)
CALL RDMIN(V)
RETURN
- ENTRY NRANUT (V)
+ END
+ SUBROUTINE NRANUT (V)
CALL RDMOUT(V)
RETURN
END
diff -urNad cernlib-2005.dfsg~/src/packlib/hbook/chbook/Imakefile cernlib-2005.dfsg/src/packlib/hbook/chbook/Imakefile
--- cernlib-2005.dfsg~/src/packlib/hbook/chbook/Imakefile 1999-11-15 08:25:58.000000000 -0500
+++ cernlib-2005.dfsg/src/packlib/hbook/chbook/Imakefile 2006-09-07 15:06:08.250546993 -0400
@@ -13,7 +13,19 @@
#endif
#if defined(CERNLIB_LINUX)
+EXTRA_DEFINES := $(EXTRA_DEFINES) -D_SVID_SOURCE
+#endif
+
+#if defined(CERNLIB_LINUX) && !defined(CERNLIB_QMLXIA64)
+EXTRA_DEFINES := $(EXTRA_DEFINES) -Df2cFortran
+#endif
+
+#if defined(CERNLIB_QMLXIA64)
+#if defined(CERNLIB_GFORTRAN)
+EXTRA_DEFINES := $(EXTRA_DEFINES) -DgFortran
+#else
EXTRA_DEFINES := $(EXTRA_DEFINES) -Df2cFortran
#endif
+#endif
SubdirLibraryTarget(NullParameter,NullParameter)