ac7dc71
#! /bin/sh /usr/share/dpatch/dpatch-run
ac7dc71
## 321-support-gfortran.dpatch by  <kmccarty@debian.org>
ac7dc71
##
ac7dc71
## All lines beginning with `## DP:' are a description of the patch.
f20e8e9
## DP: Support compilation with gfortran.  Patch thanks to Harald Vogt, plus:
f20e8e9
## DP: - Extra hack to IOSTAT EOF return value to support gfortran-4.3.
f20e8e9
## DP: - Work around gfortran's refusal to initialize 4-byte integer with
f20e8e9
## DP:   unsigned constant > 0x7fffffff.
ac7dc71
ac7dc71
@DPATCH@
2c503ce
diff -urNad cernlib-2006.dfsg.2~/src/mathlib/gen/c/rteq464.F cernlib-2006.dfsg.2/src/mathlib/gen/c/rteq464.F
f20e8e9
--- cernlib-2006.dfsg.2~/src/mathlib/gen/c/rteq464.F	1996-04-01 07:01:53.000000000 -0800
f20e8e9
+++ cernlib-2006.dfsg.2/src/mathlib/gen/c/rteq464.F	2008-02-11 15:40:44.000000000 -0800
ac7dc71
@@ -45,7 +45,16 @@
ac7dc71
          MT=3
ac7dc71
          Z(1)=SQRT(SQRT(-D))
ac7dc71
          Z(2)=-Z(1)
ac7dc71
+#if !defined(CERNLIB_GFORTRAN)
ac7dc71
          Z(3)=SQRT(-Z(1)**2)
ac7dc71
+#else
ac7dc71
+*        Using gfortran the following sqrt yields an inconsistent result
ac7dc71
+*        if the imaginary part is a "negative zero"
ac7dc71
+*        gfortran is conform with the Fortran ISO 2003 standard (1.6.1)
ac7dc71
+*        Therefore if the imaginary part is a "negative zero" 
ac7dc71
+*        it must be replaced by a "positive zero" to be consistent
ac7dc71
+         if (imag(-z(1)**2) .eq. 0) z(3)=SQRT(real(-z(1)**2)+i*0)
ac7dc71
+#endif
ac7dc71
          Z(4)=-Z(3)
ac7dc71
         ENDIF
ac7dc71
         DC=(-R12*D)**3
ac7dc71
@@ -94,9 +103,21 @@
ac7dc71
        W1=SQRT(U(K1)+I*0)
ac7dc71
        W2=SQRT(U(K2)+I*0)
ac7dc71
       ELSE
ac7dc71
+#if !defined(CERNLIB_GFORTRAN)
ac7dc71
        MT=3
ac7dc71
        W1=SQRT(U(2)+I*U(3))
ac7dc71
        W2=SQRT(U(2)-I*U(3))
ac7dc71
+#else
ac7dc71
+*      For gfortran see above
ac7dc71
+       MT=3
ac7dc71
+       IF (U(3) .NE. 0.)  THEN
ac7dc71
+         W1=SQRT(U(2)+I*U(3))
ac7dc71
+         W2=SQRT(U(2)-I*U(3))
ac7dc71
+       ELSE
ac7dc71
+         W1=SQRT(U(2)+I*0)
ac7dc71
+         W2=W1
ac7dc71
+       ENDIF
ac7dc71
+#endif
ac7dc71
       ENDIF
ac7dc71
       W3=0
ac7dc71
       IF(W1*W2 .NE. 0) W3=-Q/(8*W1*W2)
2c503ce
diff -urNad cernlib-2006.dfsg.2~/src/mathlib/gen/v/nranf.F cernlib-2006.dfsg.2/src/mathlib/gen/v/nranf.F
f20e8e9
--- cernlib-2006.dfsg.2~/src/mathlib/gen/v/nranf.F	1996-04-01 07:02:54.000000000 -0800
f20e8e9
+++ cernlib-2006.dfsg.2/src/mathlib/gen/v/nranf.F	2008-02-11 15:40:44.000000000 -0800
ac7dc71
@@ -14,10 +14,12 @@
ac7dc71
       VECTOR(I) = RNDM(I)
ac7dc71
   100 CONTINUE
ac7dc71
       RETURN
ac7dc71
-      ENTRY NRANIN (V)
ac7dc71
+      END
ac7dc71
+      SUBROUTINE NRANIN (V)
ac7dc71
       CALL RDMIN(V)
ac7dc71
       RETURN
ac7dc71
-      ENTRY NRANUT (V)
ac7dc71
+      END
ac7dc71
+      SUBROUTINE NRANUT (V)
ac7dc71
       CALL RDMOUT(V)
ac7dc71
       RETURN
ac7dc71
       END
2c503ce
diff -urNad cernlib-2006.dfsg.2~/src/packlib/hbook/chbook/Imakefile cernlib-2006.dfsg.2/src/packlib/hbook/chbook/Imakefile
f20e8e9
--- cernlib-2006.dfsg.2~/src/packlib/hbook/chbook/Imakefile	1999-11-15 05:25:58.000000000 -0800
f20e8e9
+++ cernlib-2006.dfsg.2/src/packlib/hbook/chbook/Imakefile	2008-02-11 15:40:44.000000000 -0800
ac7dc71
@@ -13,7 +13,19 @@
ac7dc71
 #endif
ac7dc71
 
ac7dc71
 #if defined(CERNLIB_LINUX)
ac7dc71
+EXTRA_DEFINES := $(EXTRA_DEFINES) -D_SVID_SOURCE
ac7dc71
+#endif
ac7dc71
+
ac7dc71
+#if defined(CERNLIB_LINUX) && !defined(CERNLIB_QMLXIA64)
ac7dc71
+EXTRA_DEFINES := $(EXTRA_DEFINES) -Df2cFortran
ac7dc71
+#endif
ac7dc71
+
ac7dc71
+#if defined(CERNLIB_QMLXIA64) 
ac7dc71
+#if defined(CERNLIB_GFORTRAN)
ac7dc71
+EXTRA_DEFINES := $(EXTRA_DEFINES) -DgFortran
ac7dc71
+#else
ac7dc71
 EXTRA_DEFINES := $(EXTRA_DEFINES) -Df2cFortran
ac7dc71
 #endif
ac7dc71
+#endif
ac7dc71
 
ac7dc71
 SubdirLibraryTarget(NullParameter,NullParameter)
2c503ce
diff -urNad cernlib-2006.dfsg.2~/src/packlib/kernlib/kerngen/unix/gfortgs/Imakefile cernlib-2006.dfsg.2/src/packlib/kernlib/kerngen/unix/gfortgs/Imakefile
f20e8e9
--- cernlib-2006.dfsg.2~/src/packlib/kernlib/kerngen/unix/gfortgs/Imakefile	2006-09-04 05:32:59.000000000 -0700
f20e8e9
+++ cernlib-2006.dfsg.2/src/packlib/kernlib/kerngen/unix/gfortgs/Imakefile	2008-02-11 15:40:44.000000000 -0800
2c503ce
@@ -1,6 +1,6 @@
ac7dc71
 
2c503ce
-SRCS_F= irndm.F qnext.F rdmin.F
f20e8e9
+SRCS_F= irndm.F qnext.F rdmin.F kernlibgetarg.F
2c503ce
 
2c503ce
-SRCS_C= lshift.c ishftr.c getarg.c
2c503ce
+SRCS_C= lshift.c ishftr.c /* getarg.c */
2c503ce
 
2c503ce
 SubdirLibraryTarget(NullParameter,NullParameter)
f20e8e9
diff -urNad cernlib-2006.dfsg.2~/src/packlib/kernlib/kerngen/unix/gfortgs/kernlibgetarg.F cernlib-2006.dfsg.2/src/packlib/kernlib/kerngen/unix/gfortgs/kernlibgetarg.F
f20e8e9
--- cernlib-2006.dfsg.2~/src/packlib/kernlib/kerngen/unix/gfortgs/kernlibgetarg.F	1969-12-31 16:00:00.000000000 -0800
f20e8e9
+++ cernlib-2006.dfsg.2/src/packlib/kernlib/kerngen/unix/gfortgs/kernlibgetarg.F	2008-02-11 15:40:44.000000000 -0800
2c503ce
@@ -0,0 +1,19 @@
2c503ce
+*     Wrapper GETARG routine for gfortran,
2c503ce
+*     originally written by Harald Vogt <hvogt@ifh.de>
ac7dc71
+*
f20e8e9
+*     SUBROUTINE GETARG (JARG, CHARG)
ac7dc71
+*     The following stuff is required to use gfortrans inline routine GETARG
ac7dc71
+*     It is required to avoid the calling GETARG here which conflicts
ac7dc71
+*     to the Fortran rules
f20e8e9
+*     CHARACTER    CHARG*(*)
f20e8e9
+*     CALL MYGETARG (JARG, CHARG)
f20e8e9
+*     END
ac7dc71
+
f20e8e9
+      SUBROUTINE KERNLIBGETARG (JARG, CHARG)
ac7dc71
+      CHARACTER    CHARG*(*)
ac7dc71
+*     gfortran translates the following line to a call
ac7dc71
+*     to its library routine _gfortran_getarg_i4
ac7dc71
+*     therefore it will not clash in the linking step
ac7dc71
+      CALL GETARG (JARG, CHARG)
ac7dc71
+      END
2c503ce
+ 
f20e8e9
diff -urNad cernlib-2006.dfsg.2~/src/packlib/kuip/kuip/kfor.h cernlib-2006.dfsg.2/src/packlib/kuip/kuip/kfor.h
f20e8e9
--- cernlib-2006.dfsg.2~/src/packlib/kuip/kuip/kfor.h	2006-09-15 02:35:30.000000000 -0700
f20e8e9
+++ cernlib-2006.dfsg.2/src/packlib/kuip/kuip/kfor.h	2008-02-11 15:40:44.000000000 -0800
f20e8e9
@@ -1031,7 +1031,7 @@
f20e8e9
 #if !defined(CERNLIB_GFORTRAN)
f20e8e9
 #define  Getarg           F77_NAME(getarg,GETARG)
f20e8e9
 #else
f20e8e9
-#define  Getarg           _gfortran_getarg_i4
f20e8e9
+#define  Getarg           F77_NAME(kernlibgetarg,KERNLIBGETARG)
f20e8e9
 #endif
f20e8e9
                  extern SUBROUTINE Getarg;
f20e8e9
 #define  Goparm           F77_NAME(goparm,GOPARM)
f20e8e9
diff -urNad cernlib-2006.dfsg.2~/src/packlib/zebra/fq/fzdaeof.inc cernlib-2006.dfsg.2/src/packlib/zebra/fq/fzdaeof.inc
f20e8e9
--- cernlib-2006.dfsg.2~/src/packlib/zebra/fq/fzdaeof.inc	2006-09-15 02:35:31.000000000 -0700
f20e8e9
+++ cernlib-2006.dfsg.2/src/packlib/zebra/fq/fzdaeof.inc	2008-02-11 15:40:44.000000000 -0800
f20e8e9
@@ -46,8 +46,12 @@
f20e8e9
 #elif defined(CERNLIB_WINDOWS)
f20e8e9
 *    only valid for dec fortran (e.g. not f2c + microsoft c)
f20e8e9
       PARAMETER    (IOSEOF = 36)
f20e8e9
-#elif defined(CERNLIB_GFORTRAN)
f20e8e9
+#elif defined(CERNLIB_GFORTRAN) && defined(__GNUC__) && defined(__GNUC_MINOR__)
f20e8e9
+# if (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)
f20e8e9
+      PARAMETER    (IOSEOF = 5002)
f20e8e9
+# else
f20e8e9
       PARAMETER    (IOSEOF = 3)
f20e8e9
+# endif
f20e8e9
 #elif 1
f20e8e9
       PARAMETER    (IOSEOF = -1)
f20e8e9
 #endif