diff -uNr src.ORIG/config/MacOSX.cf src/config/MacOSX.cf
--- src.ORIG/config/MacOSX.cf	2005-05-29 00:21:17.000000000 +0900
+++ src/config/MacOSX.cf	2005-05-29 00:20:25.000000000 +0900
@@ -143,6 +143,7 @@
 #define CERNLIB_PPC
 #define CERNLIB_QMGLIBC
 #define CERNLIB_MACOSX
+#define CERNLIB_GFORTRAN
 
 #define X11Includes             -I/usr/X11R6/include
 
diff -uNr src.ORIG/geant321/block/flkdt5.F src/geant321/block/flkdt5.F
--- src.ORIG/geant321/block/flkdt5.F	1995-10-24 19:19:36.000000000 +0900
+++ src/geant321/block/flkdt5.F	2005-05-29 02:38:22.000000000 +0900
@@ -91,7 +91,11 @@
 *     Particle  names                                                  *
       DATA ANAMZ1 /'NNPI', 'ANPPI', 'ANNPI', ' ETS  ',' PAP  ',' PAN  ',
      & 'APN', 'DEO   ', 'S+2030', 'AN*-14', 'AN*014','KONPI ','AKOPPI',
+#if !defined(CERNLIB_GFORTRAN)
      & 3*'BLANK' /
+#else
+     & 'BLANK', 'BLANK', 'BLANK' /
+#endif
 *     Name of decay channel                                            *
       DATA ZKNM41/'NNPI0','PNPI-','APPPI+','ANNPI+','ANPPI0','APNPI+',
      & 'ANNPI0','APPPI0','ANPPI-'/
@@ -116,7 +120,12 @@
      & 'APETA ','AN=P+ ','AN-PO ','ANOPO ','APRHOO','ANRHO-','ANETA ',
      & 'AN-P+ ','AN0PO ','AN+P- ','APRHO+','ANRHO0',
      & 'KONPIO','KOPPI-','K+NPI-','AKOPPO','AKONP+','K-PPI+',
+#if !defined(CERNLIB_GFORTRAN)
      & 9*'BLANK'/
+#else
+     & 'BLANK', 'BLANK', 'BLANK', 'BLANK', 'BLANK',
+     & 'BLANK', 'BLANK', 'BLANK', 'BLANK'/
+#endif
 *
       DO 10 J=1,16
          AMZ(J)=AMZ1(J)
diff -uNr src.ORIG/geant321/geocad/gweucl.F src/geant321/geocad/gweucl.F
--- src.ORIG/geant321/geocad/gweucl.F	1995-10-24 19:20:47.000000000 +0900
+++ src/geant321/geocad/gweucl.F	2005-05-29 02:50:05.000000000 +0900
@@ -308,7 +308,11 @@
       WRITE (CHMAIL,11200) FILEXT(1:IT+9)
       CALL GMAIL (1,1)
 *
+#if !defined(CERNLIB_GFORTRAN)
 10000 FORMAT (1H!,/,A,/,1H!)
+#else
+10000 FORMAT ('!',/,A,/,'!')
+#endif
 *
 10100 FORMAT ('TMED',2(1X,I3,1X,1H',A20,1H'))
 10200 FORMAT ('ROTM',1X,I3,6(1X,F8.3))
diff -uNr src.ORIG/geant321/gheisha/dlpnuc.F src/geant321/gheisha/dlpnuc.F
--- src.ORIG/geant321/gheisha/dlpnuc.F	1995-10-24 19:21:06.000000000 +0900
+++ src/geant321/gheisha/dlpnuc.F	2005-05-29 02:54:03.000000000 +0900
@@ -28,7 +28,17 @@
    10 L=LT(LEVEL)
       R=RT(LEVEL)
       LEVEL=LEVEL-1
+#if !defined(CERNLIB_GFORTRAN)
    20 IF(R.LE.L) IF(LEVEL) 50,50,10
+#else
+   20 IF(R.LE.L) THEN
+         IF(LEVEL.LE.0) THEN
+            GO TO 50
+         ELSE
+            GO TO 10
+         ENDIF
+      ENDIF
+#endif
 C
 C   SUBDIVIDE THE INTERVAL L,R
 C     L : LOWER LIMIT OF THE INTERVAL (INPUT)
diff -uNr src.ORIG/geant321/gheisha/dlpsor.F src/geant321/gheisha/dlpsor.F
--- src.ORIG/geant321/gheisha/dlpsor.F	1995-10-24 19:21:01.000000000 +0900
+++ src/geant321/gheisha/dlpsor.F	2005-05-29 02:56:18.000000000 +0900
@@ -31,7 +31,17 @@
    10 L=LT(LEVEL)
       R=RT(LEVEL)
       LEVEL=LEVEL-1
+#if !defined(CERNLIB_GFORTRAN)
    20 IF(R.LE.L) IF(LEVEL) 50,50,10
+#else
+   20 IF(R.LE.L) THEN
+         IF(LEVEL.LE.0) THEN
+            GO TO 50
+         ELSE
+            GO TO 10
+         ENDIF
+      ENDIF
+#endif
 C
 C   SUBDIVIDE THE INTERVAL L,R
 C     L : LOWER LIMIT OF THE INTERVAL (INPUT)
diff -uNr src.ORIG/geant321/peanut/bimsel.F src/geant321/peanut/bimsel.F
--- src.ORIG/geant321/peanut/bimsel.F	1997-10-17 19:00:03.000000000 +0900
+++ src/geant321/peanut/bimsel.F	2005-05-29 03:07:25.000000000 +0900
@@ -46,7 +46,7 @@
      &     AUSFL , ZUSFL , BNDSAV, RADHLP, BFCHLP, BIMCLM, PRCOLP,
      &     PRCOLN, IBTOLD, ICTOLD, KPROJ , NTRIAL, ITFRMI
       SAVE SBHAL0, SBSKI0, SBCEN0, SBCEN1, SBSKI1, SBHAL1
-#ifndef CERNLIB_WINNT
+#if !defined(CERNLIB_WINNT) && !defined(CERNLIB_GFORTRAN)
       SAVE
 #endif
       DATA IBTOLD, ICTOLD / 2*0 /
diff -uNr src.ORIG/geant321/peanut/pfnclv.F src/geant321/peanut/pfnclv.F
--- src.ORIG/geant321/peanut/pfnclv.F	1996-09-30 23:25:47.000000000 +0900
+++ src/geant321/peanut/pfnclv.F	2005-05-29 03:09:40.000000000 +0900
@@ -157,7 +157,11 @@
 *----------------------------------------------------------------------*
 *----------------------------------------------------------------------*
 *
+#if !defined(CERNLIB_GFORTRAN)
       ENTRY NCLVFX
+#else
+      ENTRY NCLVFX()
+#endif
       NCLVFX = PIPIPI
       DO 5000 N=1,NPRNUC
          I = IPRNUC (N)
diff -uNr src.ORIG/graflib/higz/ig/ighatc.F src/graflib/higz/ig/ighatc.F
--- src.ORIG/graflib/higz/ig/ighatc.F	1996-02-14 22:10:34.000000000 +0900
+++ src/graflib/higz/ig/ighatc.F	2005-05-29 01:11:02.000000000 +0900
@@ -69,7 +69,13 @@
       NTSAV=INTR
       CALL ISELNT(0)
 *
+#if !defined(CERNLIB_GFORTRAN)
       DO 70 YCUR=YMAX,YMIN,-DY
+#else
+      NY = (YMAX-YMIN)/DY
+      DO 70 IYCUR=0,NY
+         YCUR = YMAX - IYCUR*DY 
+#endif
          NBI=0
          DO 20 I=2,N+1
             I2=I
diff -uNr src.ORIG/graflib/higz/ikernel/iopks.F src/graflib/higz/ikernel/iopks.F
--- src.ORIG/graflib/higz/ikernel/iopks.F	2004-07-22 23:35:57.000000000 +0900
+++ src/graflib/higz/ikernel/iopks.F	2005-05-29 01:14:23.000000000 +0900
@@ -120,7 +120,11 @@
       CHARACTER*16 TCARD
 *
       CALL UHTOC(
+#if defined(CERNLIB_QRTHOLL)
      + 40HVERSION  1.29/04   10/06/04                 
+#else
+     + 'VERSION  1.29/04   10/06/04             '   
+#endif
 #if !defined(CERNLIB_CRAY)
      +,4,TCARD,16)
 #endif
diff -uNr src.ORIG/mathlib/gen/b/Imakefile src/mathlib/gen/b/Imakefile
--- src.ORIG/mathlib/gen/b/Imakefile	1996-05-01 22:21:33.000000000 +0900
+++ src/mathlib/gen/b/Imakefile	2005-05-29 02:06:28.000000000 +0900
@@ -1,11 +1,19 @@
 DoIncludePackage(gen)
 #include "pilot.h"
 
+#if !defined(CERNLIB_GFORTRAN)
 SRCS_F=	asinh64.F atg.F binom64.F dplnml.F prmfct.F rplnml.F rsrtnt64.F
+#else
+SRCS_F=	asinh64.F atg.F binom64.F dplnml.F prmfct.F rplnml.F
+#endif
 
 #if defined(CERNLIB_DOUBLE)
+#if !defined(CERNLIB_GFORTRAN)
 SRCS_F:= $(SRCS_F) asinh.F binom.F rsrtnt.F 
 #else
+SRCS_F:= $(SRCS_F) asinh.F binom.F
+#endif
+#else
 SRCS_F:= $(SRCS_F) asinh128.F binom128.F rsrtnt128.F
 #endif
 
diff -uNr src.ORIG/mathlib/gen/b/rsrtnt64.F src/mathlib/gen/b/rsrtnt64.F
--- src.ORIG/mathlib/gen/b/rsrtnt64.F	1996-04-02 00:01:51.000000000 +0900
+++ src/mathlib/gen/b/rsrtnt64.F	2005-05-29 01:42:41.000000000 +0900
@@ -117,7 +117,11 @@
         ENDIF
        ELSE
         IF(N .EQ. 1) THEN
+#if !defined(CERNLIB_GFORTRAN)
          ASSIGN 11 TO JMP1
+#else
+         JMP1 = 11
+#endif
          GO TO 10
    11    IF(K .EQ. 0) THEN
           H=H
@@ -174,13 +178,21 @@
            H=2*((H1+B*U)/RT(U)-(H1+B*V)/RT(V))/DELTA
            LB1=11
           ELSEIF(K .EQ. 2) THEN
+#if !defined(CERNLIB_GFORTRAN)
            ASSIGN 12 TO JMP1
+#else
+           JMP1 = 12
+#endif
            GO TO 10
    12      H1=DELTA-B**2
            H2=2*A*B
            H=(((H1*U-H2)/RT(U)-(H1*V-H2)/RT(V))/DELTA+H)/C
           ELSEIF(K .EQ. 3) THEN
+#if !defined(CERNLIB_GFORTRAN)
            ASSIGN 13 TO JMP1
+#else
+           JMP1 = 12
+#endif
            GO TO 10
    13      H1=C*DELTA
            G1=A*C
@@ -217,7 +229,11 @@
         ENDIF
        ELSE
         IF(N .EQ. 1) THEN
+#if !defined(CERNLIB_GFORTRAN)
          ASSIGN 21 TO JMP2
+#else
+         JMP2 = 21
+#endif
          GO TO 20
    21    IF(K .EQ. -1) THEN
           H=H
@@ -257,7 +273,11 @@
            IF(U. LT. -X0) H=-H
           ENDIF
          ELSE
+#if !defined(CERNLIB_GFORTRAN)
           ASSIGN 22 TO JMP2
+#else
+          JMP2 = 22
+#endif
           GO TO 20
    22     IF(K .EQ. -1) THEN
            H1=B*C
@@ -298,7 +318,17 @@
       ELSE
        H=(ASIN((C2*U+B)/RTD)-ASIN((C2*V+B)/RTD))/SQRT(-C)
       ENDIF
+#if !defined(CERNLIB_GFORTRAN)
       GO TO JMP1, (11,12,13)
+#else
+      if (jmp1 .eq. 11) then
+         go to 11
+      else if (jmp1 .eq. 12) then
+         go to 12
+      else if (jmp1 .eq. 13) then
+         go to 13
+      endif
+#endif
 
    20 IF(C .EQ. 0) THEN
        IF(B .EQ. 0) THEN
@@ -326,7 +356,15 @@
         IF(U .LT. 0 .AND. V .LT. 0) H=-H
        ENDIF
       ENDIF
+#if !defined(CERNLIB_GFORTRAN)
       GO TO JMP2, (21,22)
+#else
+      if (jmp2 .eq. 21) then
+         go to 21
+      else if (jmp2 .eq. 22) then
+         go to 22
+      endif
+#endif
 
     9 RES=SIGN(R1,V1-U1)*H
       LRL=LLL
diff -uNr src.ORIG/mathlib/gen/c/rexpin64.F src/mathlib/gen/c/rexpin64.F
--- src.ORIG/mathlib/gen/c/rexpin64.F	1997-09-04 21:10:28.000000000 +0900
+++ src/mathlib/gen/c/rexpin64.F	2005-05-29 02:12:24.000000000 +0900
@@ -117,7 +117,7 @@
        ENTRY REXPIE
 #endif
 #if defined(CERNLIB_DOUBLE)
-#  ifdef CERNLIB_MSSTDCALL
+#  if defined(CERNLIB_MSSTDCALL) || defined(CERNLIB_GFORTRAN)
        ENTRY DEXPIE(x)
 #  else
        ENTRY DEXPIE
diff -uNr src.ORIG/mathlib/gen/j/map.F src/mathlib/gen/j/map.F
--- src.ORIG/mathlib/gen/j/map.F	1996-04-02 00:02:51.000000000 +0900
+++ src/mathlib/gen/j/map.F	2005-05-29 02:17:20.000000000 +0900
@@ -69,13 +69,26 @@
        Y1=Y(I)
        YS=YS+Y1
        J=INT((Y1-YL)/YD)+2
+#if defined(CERNLIB_QRTHOLL)
       IF(YP.LT.0.) CALL VFILL(LINE(K),1,1H.)
       CALL VFILL(LINE(1),1,1HI)
+#else
+      IF(YP.LT.0.) CALL VFILL(LINE(K),1,'.')
+      CALL VFILL(LINE(1),1,'I')
+#endif
       LINE(103)=LINE(1)
        IF(MOD(N,10).NE.0)GO TO 12
+#if defined(CERNLIB_QRTHOLL)
       CALL VFILL(LINE(1),1,1H+)
+#else
+      CALL VFILL(LINE(1),1,'+')
+#endif
       LINE(103)=LINE(1)
+#if defined(CERNLIB_QRTHOLL)
    12 CALL VFILL(LINE(J),1,1H*)
+#else
+   12 CALL VFILL(LINE(J),1,'*')
+#endif
        WRITE(6,13)N,X,Y1,LINE
    13 FORMAT(I6,1X,2E10.3,2X,103A1)
    11 CALL VBLANK(LINE(J),1)
diff -uNr src.ORIG/mathlib/gen/m/sortdq.F src/mathlib/gen/m/sortdq.F
--- src.ORIG/mathlib/gen/m/sortdq.F	1996-04-02 00:02:51.000000000 +0900
+++ src/mathlib/gen/m/sortdq.F	2005-05-29 02:21:46.000000000 +0900
@@ -24,7 +24,17 @@
    10 L=LT(LEVEL)
       R=RT(LEVEL)
       LEVEL=LEVEL-1
+#if !defined(CERNLIB_GFORTRAN)
    20 IF(R.LE.L) IF(LEVEL) 90,90,10
+#else
+   20 IF(R.LE.L) THEN
+         IF(LEVEL.LE.0) THEN
+            GO TO 90
+         ELSE 
+            GO TO 10
+         ENDIF
+      ENDIF
+#endif
 C
 C   SUBDIVIDE THE INTERVAL L,R
 C     L : LOWER LIMIT OF THE INTERVAL (INPUT)
diff -uNr src.ORIG/mathlib/gen/m/sortiq.F src/mathlib/gen/m/sortiq.F
--- src.ORIG/mathlib/gen/m/sortiq.F	1996-04-02 00:02:51.000000000 +0900
+++ src/mathlib/gen/m/sortiq.F	2005-05-29 02:23:38.000000000 +0900
@@ -23,7 +23,18 @@
    10 L=LT(LEVEL)
       R=RT(LEVEL)
       LEVEL=LEVEL-1
+#if !defined(CERNLIB_GFORTRAN)
    20 IF(R.LE.L) IF(LEVEL) 90,90,10
+#else
+   20 IF(R.LE.L) THEN
+         IF(LEVEL.LE.0) THEN
+            GO TO 90
+         ELSE 
+            GO TO 10
+         ENDIF
+      ENDIF
+#endif
+
 C
 C   SUBDIVIDE THE INTERVAL L,R
 C     L : LOWER LIMIT OF THE INTERVAL (INPUT)
diff -uNr src.ORIG/mathlib/gen/m/sortrq.F src/mathlib/gen/m/sortrq.F
--- src.ORIG/mathlib/gen/m/sortrq.F	1996-04-02 00:02:52.000000000 +0900
+++ src/mathlib/gen/m/sortrq.F	2005-05-29 02:24:09.000000000 +0900
@@ -21,7 +21,18 @@
    10 L=LT(LEVEL)
       R=RT(LEVEL)
       LEVEL=LEVEL-1
+#if !defined(CERNLIB_GFORTRAN)
    20 IF(R.LE.L) IF(LEVEL) 90,90,10
+#else
+   20 IF(R.LE.L) THEN
+         IF(LEVEL.LE.0) THEN
+            GO TO 90
+         ELSE 
+            GO TO 10
+         ENDIF
+      ENDIF
+#endif
+
 C
 C   SUBDIVIDE THE INTERVAL L,R
 C     L : LOWER LIMIT OF THE INTERVAL (INPUT)
diff -uNr src.ORIG/mathlib/gen/v/v107z0.inc src/mathlib/gen/v/v107z0.inc
--- src.ORIG/mathlib/gen/v/v107z0.inc	2000-06-08 18:57:22.000000000 +0900
+++ src/mathlib/gen/v/v107z0.inc	2005-05-29 02:28:54.000000000 +0900
@@ -17,7 +17,11 @@
 *
 
 #if defined(CERNLIB_LNX)||defined(CERNLIB_ALLIANT)||defined(CERNLIB_DECS)||defined(CERNLIB_MACMPW)||defined(CERNLIB_SGI)
+#if !defined(CERNLIB_GFORTRAN)
       DATA IZ0/'33000000'X/
+#else
+      DATA IZ0/X'33000000'/
+#endif
 
 #elif defined(CERNLIB_APOLLO)
       DATA IZ0/16#33000000/
diff -uNr src.ORIG/mclibs/eurodec/fragmt/ordstk.F src/mclibs/eurodec/fragmt/ordstk.F
--- src.ORIG/mclibs/eurodec/fragmt/ordstk.F	1996-03-09 01:58:52.000000000 +0900
+++ src/mclibs/eurodec/fragmt/ordstk.F	2005-05-29 03:13:58.000000000 +0900
@@ -26,7 +26,17 @@
    10 L=LT(LEVEL)
       R=RT(LEVEL)
       LEVEL=LEVEL-1
+#if !defined(CERNLIB_GFORTRAN)
    20 IF (R.LE.L) IF (LEVEL) 80,80,10
+#else
+   20 IF (R.LE.L) THEN
+         IF (LEVEL.LE.0) THEN
+            GO TO 80 
+         ELSE 
+            GO TO 10
+         ENDIF
+      ENDIF
+#endif
 C--
 C--   SUBDIVIDE THE INTERVAL L,R
 C--   L : LOWER LIMIT OF THE INTERVAL (INPUT)
diff -uNr src.ORIG/mclibs/herwig/code/hwbcon.F src/mclibs/herwig/code/hwbcon.F
--- src.ORIG/mclibs/herwig/code/hwbcon.F	1996-12-03 23:16:47.000000000 +0900
+++ src/mclibs/herwig/code/hwbcon.F	2005-05-31 02:34:20.000000000 +0900
@@ -7,6 +7,9 @@
 C     MAKES COLOUR CONNECTIONS BETWEEN JETS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER IHEP,IST,ID,JC,JD,JHEP,LHEP
       IF (IERROR.NE.0) RETURN
       DO 20 IHEP=1,NHEP
@@ -57,7 +60,12 @@
           JMOHEP(2,IHEP)=LHEP
         ELSE
 C---COULDN'T FIND PARTNER OF IHEP
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWBCON',100,*999)
+#else
+          call hwwarn('HWBCON',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
       ENDIF
   20  CONTINUE
diff -uNr src.ORIG/mclibs/herwig/code/hwbded.F src/mclibs/herwig/code/hwbded.F
--- src.ORIG/mclibs/herwig/code/hwbded.F	1996-12-03 23:16:47.000000000 +0900
+++ src/mclibs/herwig/code/hwbded.F	2005-05-31 02:34:39.000000000 +0900
@@ -8,6 +8,9 @@
 C     IF (IOPT.EQ.2) CLEAN UP EVENT RECORD AFTER SHOWERING
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWBVMC,HWRGEN,HWUALF,HWUSQR,X(3),W,WMAX,WSUM,
      & X1MIN,X1MAX,X2MIN,X2MAX,QSCALE,GAMFAC,GLUFAC,R(3,3),CS,SN,M(3),
      & E(3),LAMBDA,A,B,C,PTSQ,EM,P1(5),P2(5),PVRT(4),EPS,MASDEP
@@ -22,8 +25,14 @@
         IF (EMIT.NE.0) RETURN
         ICMF=0
         DO 10 IHEP=1,NHEP
+#if !defined(CERNLIB_GFORTRAN)
  10       IF (ICMF.EQ.0 .AND. ISTHEP(IHEP).EQ.110 .AND.
      &    JDAHEP(2,IHEP).EQ.JDAHEP(1,IHEP)+1) ICMF=IHEP
+#else
+             IF (ICMF.EQ.0 .AND. ISTHEP(IHEP).EQ.110 .AND.
+     &    JDAHEP(2,IHEP).EQ.JDAHEP(1,IHEP)+1) ICMF=IHEP
+ 10       continue
+#endif
         IF (ICMF.EQ.0) RETURN
         EM=PHEP(5,ICMF)
         IF (EM.LT.2*HWBVMC(1)) RETURN
@@ -225,6 +234,11 @@
  410    CONTINUE
         EMIT=0
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWBDED',500,*999)
+#else
+        call hwwarn('HWBDED',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
  999  END
diff -uNr src.ORIG/mclibs/herwig/code/hwbdis.F src/mclibs/herwig/code/hwbdis.F
--- src.ORIG/mclibs/herwig/code/hwbdis.F	1996-12-03 23:16:47.000000000 +0900
+++ src/mclibs/herwig/code/hwbdis.F	2005-05-31 02:34:39.000000000 +0900
@@ -9,6 +9,9 @@
 C     IF (IOPT.EQ.2) CLEAN UP EVENT RECORD AFTER SHOWERING
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWBVMC,HWUALF,HWULDO,P1(5),P2(5),P3(5),
      & PCMF(5),L(5),R(3,3),Q,XBJ,RN,XPMIN,XPMAX,XP,ZPMIN,ZPMAX,ZP,FAC,
      & X1,X2,XTSQ,XT,PTSQ,SIN1,SIN2,W1,W2,CFAC,PDFOLD(13),PDFNEW(13),
@@ -27,8 +30,14 @@
         IF (EMIT.EQ.NEVHEP+NWGTS) RETURN
         ICMF=0
         DO 10 IHEP=1,NHEP
+#if !defined(CERNLIB_GFORTRAN)
  10       IF (ICMF.EQ.0 .AND. ISTHEP(IHEP).EQ.110 .AND.
      &    JDAHEP(2,IHEP).EQ.JDAHEP(1,IHEP)+1) ICMF=IHEP
+#else
+             IF (ICMF.EQ.0 .AND. ISTHEP(IHEP).EQ.110 .AND.
+     &    JDAHEP(2,IHEP).EQ.JDAHEP(1,IHEP)+1) ICMF=IHEP
+ 10       continue
+#endif
         IF (ICMF.EQ.0) RETURN
         IIN=JMOHEP(2,ICMF)
         IOUT=JDAHEP(2,ICMF)
@@ -157,7 +166,12 @@
         ISTAT=7
         CALL HWSFUN(XBJ,Q,IDHW(IHAD),NSTRU,PDFOLD,2)
         ISTAT=ITEMP
+#if !defined(CERNLIB_GFORTRAN)
         IF (PDFOLD(ID).LE.0) CALL HWWARN('HWBDIS',100,*999)
+#else
+        IF (PDFOLD(ID).LE.0) call hwwarn('HWBDIS',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
         IF (XP.GT.XBJ) THEN
           CALL HWSFUN(XBJ/XP,SCALE,IDHW(IHAD),NSTRU,PDFNEW,2)
           FAC=CFAC/(2*PIFAC) * HWUALF(1,SCALE) * FAC *
@@ -466,6 +480,11 @@
      $       CALL HWVZRO(4,VHEP(1,JDAHEP(1,IOUT)+1))
         EMIT=0
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWBDIS',500,*999)
+#else
+        call hwwarn('HWBDIS',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
  999  END
diff -uNr src.ORIG/mclibs/herwig/code/hwbfin.F src/mclibs/herwig/code/hwbfin.F
--- src.ORIG/mclibs/herwig/code/hwbfin.F	1996-12-03 23:16:47.000000000 +0900
+++ src/mclibs/herwig/code/hwbfin.F	2005-05-31 02:34:20.000000000 +0900
@@ -8,6 +8,9 @@
 C     AND COPIES INTO /HEPEVT/ IN COLOUR ORDER.
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER IHEP,ID,IJET,KHEP,IPAR,JPAR,NXPAR,IP,JP
       IF (IERROR.NE.0) RETURN
 C---SAVE VIRTUAL PARTON DATA
@@ -60,7 +63,12 @@
       ENDIF
    10 CONTINUE
 C---COULDN'T FIND COLOUR PARTNER
+#if !defined(CERNLIB_GFORTRAN)
       CALL HWWARN('HWBFIN',1,*999)
+#else
+      call hwwarn('HWBFIN',1,iret)
+        if (iret .eq. 1) go to 999
+#endif
    15 JPAR=JCOPAR(1,IPAR)
       KHEP=KHEP+1
       ID=IDPAR(IPAR)
diff -uNr src.ORIG/mclibs/herwig/code/hwbgen.F src/mclibs/herwig/code/hwbgen.F
--- src.ORIG/mclibs/herwig/code/hwbgen.F	1996-12-03 23:16:47.000000000 +0900
+++ src/mclibs/herwig/code/hwbgen.F	2005-05-31 02:34:39.000000000 +0900
@@ -9,6 +9,9 @@
 C     G.MARCHESINI & B.R.WEBBER, NUCL. PHYS. B238(1984)1
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWULDO,HWRGAU,EINHEP,ERTXI,RTXI,XF
       INTEGER NTRY,LASHEP,IHEP,NRHEP,ID,IST,JHEP,KPAR,I,J,IRHEP(NMXJET),
      & IRST(NMXJET)
@@ -17,7 +20,14 @@
       IF (IERROR.NE.0) RETURN
       IF (IPRO.EQ.80) RETURN
 C---CHECK THAT EMSCA IS SET
+#if !defined(CERNLIB_GFORTRAN)
       IF (EMSCA.LE.ZERO) CALL HWWARN('HWBGEN',200,*999)
+#else
+      if (EMSCA.LE.ZERO) then
+          call hwwarn('HWBGEN',200,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       IF (HARDME) THEN
 C---FORCE A BRANCH INTO THE `DEAD ZONE' IN E+E-
         IF (IPROC/10.EQ.10) CALL HWBDED(1)
@@ -27,7 +37,14 @@
       NTRY=0
       LASHEP=NHEP
    10 NTRY=NTRY+1
+#if !defined(CERNLIB_GFORTRAN)
       IF (NTRY.GT.NETRY) CALL HWWARN('HWBGEN',ISLENT*100,*999)
+#else
+      if (NTRY.GT.NETRY) then
+          call hwwarn('HWBGEN',ISLENT*100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       NRHEP=0
       NHEP=LASHEP
       FROST=.FALSE.
@@ -51,8 +68,13 @@
         DO 15 J=1,2
         DO 15 I=1,2
         JMOPAR(I,J)=0
+#if !defined(CERNLIB_GFORTRAN)
    15   JCOPAR(I,J)=0
 C---SET UP EVOLUTION SCALE AND FRAME
+#else
+           JCOPAR(I,J)=0
+   15   continue
+#endif
         JHEP=JMOHEP(2,IHEP)
         IF (ID.EQ.13) THEN
           IF (HWRLOG(HALF)) JHEP=JDAHEP(2,IHEP)
@@ -63,7 +85,12 @@
           IF (ID.LT.7.OR.(ID.GT.208.AND.ID.LT.215)) JHEP=JDAHEP(2,IHEP)
         ENDIF
         IF (JHEP.EQ.0) THEN
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWBGEN',1,*999)
+#else
+          call hwwarn('HWBGEN',1,iret)
+        if (iret .eq. 1) go to 999
+#endif
           JHEP=IHEP
         ENDIF
         JCOPAR(1,1)=JHEP
@@ -176,7 +203,12 @@
       IF (FROST) THEN
 C---BAD JET: RESTORE PARTONS AND RE-EVOLVE
          DO 120 I=1,NRHEP
+#if !defined(CERNLIB_GFORTRAN)
   120    ISTHEP(IRHEP(I))=IRST(I)
+#else
+           ISTHEP(IRHEP(I))=IRST(I)
+  120    continue
+#endif
          GOTO 10
       ENDIF
 C---CONNECT COLOURS
diff -uNr src.ORIG/mclibs/herwig/code/hwbjco.F src/mclibs/herwig/code/hwbjco.F
--- src.ORIG/mclibs/herwig/code/hwbjco.F	1996-12-03 23:16:47.000000000 +0900
+++ src/mclibs/herwig/code/hwbjco.F	2005-05-31 02:34:39.000000000 +0900
@@ -7,6 +7,9 @@
 C     COMBINES JETS WITH REQUIRED KINEMATICS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWULDO,EPS,PTX,PTY,PF,PTINF,PTCON,CN,CP,SP,PP0,
      & PM0,ET0,DET,ECM,EMJ,EMP,EMS,DMS,ES,DPF,ALF,AL(2),ET(2),PP(2),
      & PT(3),PB(5),PC(5),PQ(5),PR(5),PS(5),RR(3,3),RS(3,3),ETC,
@@ -38,12 +41,24 @@
           IP1=JDAHEP(1,ICM)
           IP2=JDAHEP(2,ICM)
         ENDIF
+#if !defined(CERNLIB_GFORTRAN)
         IF (IP1.NE.IP) CALL HWWARN('HWBJCO',100,*999)
+#else
+        if (IP1.NE.IP) then
+          call hwwarn('HWBJCO',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         NP=0
         DO 30 JHEP=IP1,IP2
         NP=NP+1
         IPAR(NP)=JHEP
+#if !defined(CERNLIB_GFORTRAN)
   30    IJET(NP)=JDAHEP(1,JHEP)
+#else
+           IJET(NP)=JDAHEP(1,JHEP)
+  30    continue
+#endif
         GOTO 50
       ENDIF
   40  CONTINUE
@@ -55,7 +70,14 @@
       RETURN
   50  IF (LJET.EQ.131) THEN
 C---SPACELIKE JETS: FIND SPACELIKE PARTONS
+#if !defined(CERNLIB_GFORTRAN)
         IF (NP.NE.2) CALL HWWARN('HWBJCO',103,*999)
+#else
+        if (NP.NE.2) then
+          call hwwarn('HWBJCO',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C---special for DIS: FIND BOOST AND ROTATION FROM LAB TO BREIT FRAME
         IF (DISPRO.AND.BREIT) THEN
           IP=2
@@ -63,7 +85,12 @@
           CALL HWVDIF(4,PHEP(1,JMOHEP(1,ICM)),PHEP(1,JDAHEP(1,ICM)),PB)
           CALL HWUMAS(PB)
 C---IF Q**2<10**-2, SOMETHING MUST HAVE ALREADY GONE WRONG
+#if !defined(CERNLIB_GFORTRAN)
           IF (PB(5)**2.LT.1.D-2) CALL HWWARN('HWBJCO',102,*999)
+#else
+          IF (PB(5)**2.LT.1.D-2) call hwwarn('HWBJCO',102,iret)
+        if (iret .eq. 1) go to 999
+#endif
           CALL HWVSCA(4,PB(5)**2/HWULDO(PHEP(1,IP),PB),PHEP(1,IP),PBR)
           CALL HWVSUM(4,PB,PBR,PBR)
           CALL HWUMAS(PBR)
@@ -82,9 +109,19 @@
         ELSE
           IST=134+IP
           DO 60 IHEP=MHEP,NHEP
+#if !defined(CERNLIB_GFORTRAN)
   60      IF (ISTHEP(IHEP).EQ.IST) GOTO 70
 C---COULDN'T FIND SPACELIKE PARTON
+#else
+             IF (ISTHEP(IHEP).EQ.IST) GOTO 70
+  60      continue
+#endif
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWBJCO',101,*999)
+#else
+          call hwwarn('HWBJCO',101,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
   70    CALL HWVSCA(3,PF,PHEP(1,IHEP),PS)
         IF (PTINT(3,IP).GT.0.) THEN
@@ -104,7 +141,12 @@
           PTCON=PR(1)**2+PR(2)**2
           KP=JMOHEP(2,JP)
           IF (KP.EQ.0) THEN
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWBJCO',1,*999)
+#else
+            call hwwarn('HWBJCO',1,iret)
+        if (iret .eq. 1) go to 999
+#endif
             PTINF=0.
           ELSE
             CALL HWVEQU(4,PHEP(1,KP),PB)
@@ -146,13 +188,23 @@
         IEND(IP)=KHEP
         DO 80 JHEP=IHEP,KHEP
         CALL HWUROF(RS,PHEP(1,JHEP),PHEP(1,JHEP))
+#if !defined(CERNLIB_GFORTRAN)
   80    CALL HWUROF(RS,VHEP(1,JHEP),VHEP(1,JHEP))
+#else
+           CALL HWUROF(RS,VHEP(1,JHEP),VHEP(1,JHEP))
+  80    continue
+#endif
         PP(IP)=PHEP(4,IHEP)+PF*PHEP(3,IHEP)
         ET(IP)=PHEP(1,IHEP)**2+PHEP(2,IHEP)**2-PHEP(5,IHEP)**2
 C---REDEFINE HARD CM
         PTX=PTX+PHEP(1,IHEP)
         PTY=PTY+PHEP(2,IHEP)
+#if !defined(CERNLIB_GFORTRAN)
   90    PF=-PF
+#else
+           PF=-PF
+  90    continue
+#endif
         PHEP(1,ICM)=PTX
         PHEP(2,ICM)=PTY
 C---special for DIS: keep lepton momenta fixed
@@ -217,10 +269,20 @@
             CALL HWUROB(RBR,VHEP(1,IHEP),VHEP(1,IHEP))
             CALL HWULB4(PBR,VHEP(1,IHEP),VHEP(1,IHEP))
           ENDIF
+#if !defined(CERNLIB_GFORTRAN)
   100     ISTHEP(IHEP)=ISTHEP(IHEP)+10
+#else
+            ISTHEP(IHEP)=ISTHEP(IHEP)+10
+  100     continue
+#endif
           CALL HWVDIF(4,VHEP(1,IPAR(2)),VHEP(1,IJET(2)),DISP)
           DO 110 IHEP=IJET(2),IEND(2)
+#if !defined(CERNLIB_GFORTRAN)
   110     CALL HWVSUM(4,DISP,VHEP(1,IHEP),VHEP(1,IHEP))
+#else
+            CALL HWVSUM(4,DISP,VHEP(1,IHEP),VHEP(1,IHEP))
+  110     continue
+#endif
           IF (IEND(2).GT.IJET(2)+1) ISTHEP(IJET(2)+1)=100
           CALL HWVSUM(4,PHEP(1,IJT),PHEP(1,IJET(2)),PC)
           CALL HWVSUM(4,PHEP(1,IP1),PHEP(1,IJET(2)),PHEP(1,ICM))
@@ -244,10 +306,20 @@
            DO 120 IHEP=IJT,IEND(2)
            CALL HWULOF(PB,PHEP(1,IHEP),PHEP(1,IHEP))
            CALL HWULF4(PB,VHEP(1,IHEP),VHEP(1,IHEP))
+#if !defined(CERNLIB_GFORTRAN)
   120      ISTHEP(IHEP)=ISTHEP(IHEP)+10
+#else
+             ISTHEP(IHEP)=ISTHEP(IHEP)+10
+  120      continue
+#endif
            CALL HWVDIF(4,VHEP(1,IPAR(2)),VHEP(1,IJT),DISP)
            DO 130 IHEP=IJT,IEND(2)
+#if !defined(CERNLIB_GFORTRAN)
   130      CALL HWVSUM(4,DISP,VHEP(1,IHEP),VHEP(1,IHEP))
+#else
+             CALL HWVSUM(4,DISP,VHEP(1,IHEP),VHEP(1,IHEP))
+  130      continue
+#endif
            IF (IEND(2).GT.IJT+1) ISTHEP(IJT+1)=100
            ISTHEP(IJET(1))=ISTHEP(IJET(1))+10
            CALL HWVSUM(2,PHEP(3,IPAR(1)),PHEP(3,IJT),PHEP(3,ICM))
@@ -275,10 +347,20 @@
           DO 140 IHEP=IJT,IEND(IP)
           CALL HWULOF(PB,PHEP(1,IHEP),PHEP(1,IHEP))
           CALL HWULF4(PB,VHEP(1,IHEP),VHEP(1,IHEP))
+#if !defined(CERNLIB_GFORTRAN)
   140     ISTHEP(IHEP)=ISTHEP(IHEP)+10
+#else
+            ISTHEP(IHEP)=ISTHEP(IHEP)+10
+  140     continue
+#endif
           CALL HWVDIF(4,VHEP(1,IPAR(IP)),VHEP(1,IJT),DISP)
           DO 150 IHEP=IJT,IEND(IP)
+#if !defined(CERNLIB_GFORTRAN)
   150     CALL HWVSUM(4,DISP,VHEP(1,IHEP),VHEP(1,IHEP))
+#else
+            CALL HWVSUM(4,DISP,VHEP(1,IHEP),VHEP(1,IHEP))
+  150     continue
+#endif
           IF (IEND(IP).GT.IJT+1) THEN
             ISTHEP(IJT+1)=100
           ELSEIF (IEND(IP).EQ.IJT) THEN
@@ -302,7 +384,12 @@
           PQ(5)=PHEP(5,ICM)
           IF (NP.GT.2) THEN
             DO 170 KP=3,NP
+#if !defined(CERNLIB_GFORTRAN)
   170       CALL HWVSUM(4,PHEP(1,IPAR(KP)),PQ,PQ)
+#else
+              CALL HWVSUM(4,PHEP(1,IPAR(KP)),PQ,PQ)
+  170       continue
+#endif
           ENDIF
           LP=1
         ENDIF
@@ -319,7 +406,17 @@
           PM(KP)= EMJ**2
 C---N.B. ROUNDING ERRORS HERE AT HIGH ENERGIES
           PJ(KP)=(HWULDO(PHEP(1,IPAR(KP)),PQ)/ECM)**2-EMP**2
+#if !defined(CERNLIB_GFORTRAN)
+#if !defined(CERNLIB_GFORTRAN)
   180     IF (PJ(KP).LE.0.) CALL HWWARN('HWBJCO',104,*999)
+#else
+            IF (PJ(KP).LE.0.) CALL HWWARN('HWBJCO',104,*999)
+  180     continue
+#endif
+#else
+  180     IF (PJ(KP).LE.0.) call hwwarn('HWBJCO',104,iret)
+        if (iret .eq. 1) go to 999
+#endif
           PF=1.
           IF (JETRAD) THEN
 C---JETS DID RADIATE
@@ -333,12 +430,27 @@
             DO 190 KP=LP,NP
             ES=SQRT(PF*PJ(KP)+PM(KP))
             EMS=EMS+ES
+#if !defined(CERNLIB_GFORTRAN)
   190       DMS=DMS+PJ(KP)/ES
+#else
+              DMS=DMS+PJ(KP)/ES
+  190       continue
+#endif
             DPF=2.*EMS/DMS
             IF (DPF.GT.PF) DPF=0.9*PF
             PF=PF-DPF
+#if !defined(CERNLIB_GFORTRAN)
   200       IF (ABS(DPF).LT.EPS) GOTO 210
+#else
+              IF (ABS(DPF).LT.EPS) GOTO 210
+  200       continue
+#endif
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWBJCO',105,*999)
+#else
+            call hwwarn('HWBJCO',105,iret)
+        if (iret .eq. 1) go to 999
+#endif
           ENDIF
   210     CONTINUE
         ENDIF
@@ -378,7 +490,12 @@
           CALL HWUROT(PR, ONE,ZERO,RS)
           JP=JMOHEP(2,KP)
           IF (JP.EQ.0) THEN
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWBJCO',2,*999)
+#else
+            call hwwarn('HWBJCO',2,iret)
+        if (iret .eq. 1) go to 999
+#endif
             PTINF=0.
           ELSE
             CALL HWVEQU(4,PHEP(1,JP),PS)
@@ -445,7 +562,12 @@
           CALL HWULB4(PBR,VHEP(1,JHEP),VHEP(1,JHEP))
         ENDIF
         CALL HWVSUM(4,VHEP(1,JHEP),VHEP(1,IPAR(IP)),VHEP(1,JHEP))
+#if !defined(CERNLIB_GFORTRAN)
   220   ISTHEP(JHEP)=ISTHEP(JHEP)+10
+#else
+          ISTHEP(JHEP)=ISTHEP(JHEP)+10
+  220   continue
+#endif
         IF (KHEP.GT.IHEP+1) THEN
           ISTHEP(IHEP+1)=100
         ELSEIF (KHEP.EQ.IHEP) THEN
diff -uNr src.ORIG/mclibs/herwig/code/hwbmas.F src/mclibs/herwig/code/hwbmas.F
--- src.ORIG/mclibs/herwig/code/hwbmas.F	1996-12-03 23:16:47.000000000 +0900
+++ src/mclibs/herwig/code/hwbmas.F	2005-05-31 02:34:39.000000000 +0900
@@ -64,7 +64,12 @@
   10     CONTINUE
       ENDIF
       DO 20 IPAR=2,NPAR
+#if !defined(CERNLIB_GFORTRAN)
   20  PPAR(5,IPAR)=HWUSQR(PPAR(5,IPAR))
+#else
+         PPAR(5,IPAR)=HWUSQR(PPAR(5,IPAR))
+  20  continue
+#endif
       PPAR(1,2)=0.
       PPAR(2,2)=0.
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwbran.F src/mclibs/herwig/code/hwbran.F
--- src.ORIG/mclibs/herwig/code/hwbran.F	1996-12-03 23:16:47.000000000 +0900
+++ src/mclibs/herwig/code/hwbran.F	2005-05-31 02:34:39.000000000 +0900
@@ -8,6 +8,9 @@
 C     INTO NPAR+1 AND NPAR+2, AND INCREASES NPAR BY TWO
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWBVMC,HWRGEN,HWUALF,HWUTAB,HWRUNI,HWULDO,PMOM,
      & QNOW,QLST,QKTHR,RN,QQBAR,DQQ,QGTHR,SNOW,QSUD,ZMIN,ZMAX,ZRAT,WMIN,
      & QLAM,Z1,Z2,ETEST,ZTEST,ENOW,XI,XIPREV,EPREV,QMAX,QGAM,SLST,SFNL,
@@ -24,8 +27,14 @@
       IF (SUDORD.NE.1.AND.BETA0(3).EQ.ZERO) THEN
         DO 100 M=3,6
           BETA0(M)=(11.*CAFAC-2.*M)*0.5
+#if !defined(CERNLIB_GFORTRAN)
  100      BETAP(M)=(17.*CAFAC**2-(5.*CAFAC+3.*CFFAC)*M)
      &            /BETA0(M)*0.25/PIFAC
+#else
+            BETAP(M)=(17.*CAFAC**2-(5.*CAFAC+3.*CFFAC)*M)
+     &            /BETA0(M)*0.25/PIFAC
+ 100      continue
+#endif
         DO 120 N=1,5
           DO 110 M=4,6
             IF (M.LE.N) THEN
@@ -106,7 +115,14 @@
         ENDIF
         NTRY=0
     5   NTRY=NTRY+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NTRY.GT.NBTRY) CALL HWWARN('HWBRAN',100,*999)
+#else
+        if (NTRY.GT.NBTRY) then
+          call hwwarn('HWBRAN',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IF (ID.EQ.13) THEN
 C--GLUON -> QUARK+ANTIQUARK OPTION
           IF (QLST.GT.QCDL3) THEN
@@ -118,8 +134,13 @@
 C---FIND IN WHICH FLAVOUR INTERVAL THE UPPER LIMIT LIES
                 NF=3
                 DO 200 M=MAX(3,N),NFLAV
+#if !defined(CERNLIB_GFORTRAN)
  200              IF (QLST.GT.RMASS(M)) NF=M
 C---CALCULATE THE FORM FACTOR
+#else
+                    IF (QLST.GT.RMASS(M)) NF=M
+ 200              continue
+#endif
                 IF (NF.EQ.MAX(3,N)) THEN
                   SFNL=((BETAP(NF)+1/HWUALF(1,QKTHR))/
      $                 (BETAP(NF)+1/HWUALF(1,QLST)))**(1/BETA0(NF))
@@ -142,7 +163,12 @@
                 ELSEIF (RN.GE.SLST) THEN
                   NN=MAX(3,N)
                   DO 210 M=MAX(3,N)+1,NF-1
+#if !defined(CERNLIB_GFORTRAN)
  210                IF (RN.GE.SLST/SQRK(M,N)) NN=M
+#else
+                      IF (RN.GE.SLST/SQRK(M,N)) NN=M
+ 210                continue
+#endif
                 ELSE
                   NN=0
                   QQBAR=QCDL3
@@ -160,7 +186,14 @@
                   ALF=HWUALF(1,QQBAR)
                   IF (ABS(ALF-TARG).GT.ACCUR) THEN
                     NTRY=NTRY+1
+#if !defined(CERNLIB_GFORTRAN)
                     IF (NTRY.GT.NBTRY) CALL HWWARN('HWBRAN',101,*999)
+#else
+                    if (NTRY.GT.NBTRY) then
+          call hwwarn('HWBRAN',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
                     QQBAR=QQBAR*(1+3*PIFAC*(ALF-TARG)
      $                   /(BETA0(NN)*ALF**2*(1+BETAP(NN)*ALF)))
                     GOTO 7
@@ -212,7 +245,12 @@
               SNOW=HWUTAB(SUD(1,IS),QEV(1,IS),NQEV,QLST,1)/RN
               QSUD=HWUTAB(QEV(1,IS),SUD(1,IS),NQEV,SNOW,1)
               IF (QSUD.GT.QLST) THEN
+#if !defined(CERNLIB_GFORTRAN)
                 CALL HWWARN('HWBRAN',1,*999)
+#else
+                call hwwarn('HWBRAN',1,iret)
+        if (iret .eq. 1) go to 999
+#endif
                 QSUD=-1
               ENDIF
             ENDIF
@@ -416,7 +454,14 @@
           PPAR(5,KPAR)=PPAR(1,2)**2
           PMOM=0
         ENDIF
+#if !defined(CERNLIB_GFORTRAN)
         IF (PMOM.LT.-1E-6) CALL HWWARN('HWBRAN',104,*999)
+#else
+        if (PMOM.LT.-1E-6) then
+          call hwwarn('HWBRAN',104,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IF (PMOM.LT.0) PMOM=0
         PPAR(3,KPAR)=SQRT(PMOM)
         JDAPAR(1,KPAR)=0
diff -uNr src.ORIG/mclibs/herwig/code/hwbsud.F src/mclibs/herwig/code/hwbsud.F
--- src.ORIG/mclibs/herwig/code/hwbsud.F	1996-12-03 23:16:48.000000000 +0900
+++ src/mclibs/herwig/code/hwbsud.F	2005-05-31 02:34:39.000000000 +0900
@@ -7,6 +7,9 @@
 C     COMPUTES (OR READS) TABLES OF SUDAKOV FORM FACTORS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWUGAU,HWBVMC,HWBSUG,HWBSU1,HWBSU2,G1,G2,QRAT,
      & QLAM,POWER,AFAC,QMIN,QFAC,QNOW,ZMIN,ZMAX,Q1,QCOLD,VGOLD,VQOLD,
      & RMOLD(6),ACOLD,ZLO,ZHI
@@ -36,7 +39,12 @@
           IF (ZHI.GT.ZLO) G1=G1+HWUGAU(HWBSUG,LOG(ZLO),LOG(ZHI),ACCUR)
     5   CONTINUE
         SUD(IQ,1)=EXP(AFAC*G1)
+#if !defined(CERNLIB_GFORTRAN)
    10   QEV(IQ,1)=QNOW
+#else
+           QEV(IQ,1)=QNOW
+   10   continue
+#endif
         AFAC=3.*CFFAC/BETAF
 C--QUARK FORM FACTORS.
 C--IS=2,3,4,5,6,7 FOR U/D,S,C,B,T,V
@@ -74,7 +82,12 @@
           IF (ZHI.GT.ZLO) G2=G2+HWUGAU(HWBSU2,ZLO,ZHI,ACCUR)
    13   CONTINUE
         SUD(IQ,IS)=EXP(AFAC*(G1+G2))
+#if !defined(CERNLIB_GFORTRAN)
    14   QEV(IQ,IS)=QNOW
+#else
+           QEV(IQ,IS)=QNOW
+   14   continue
+#endif
    15   CONTINUE
         QCOLD=QCDLAM
         VGOLD=VGCUT
@@ -87,7 +100,12 @@
         NFOLD=NFLAV
         SDOLD=SUDORD
         DO 16 IS=1,NSUD
+#if !defined(CERNLIB_GFORTRAN)
    16   RMOLD(IS)=RMASS(IS)
+#else
+           RMOLD(IS)=RMASS(IS)
+   16   continue
+#endif
       ELSE
         IF (LRSUD.GT.0) THEN
           IF (IPRINT.NE.0) WRITE (6,17) LRSUD
@@ -98,22 +116,102 @@
           CLOSE(UNIT=LRSUD)
         ENDIF
 C---CHECK THAT RELEVANT PARAMETERS ARE UNCHANGED
+#if !defined(CERNLIB_GFORTRAN)
         IF (QCDLAM.NE.QCOLD) CALL HWWARN('HWBSUD',501,*999)
+#else
+        if (QCDLAM.NE.QCOLD) then
+          call hwwarn('HWBSUD',501,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (VGCUT .NE.VGOLD) CALL HWWARN('HWBSUD',502,*999)
+#else
+        if (VGCUT .NE.VGOLD) then
+          call hwwarn('HWBSUD',502,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (VQCUT .NE.VQOLD) CALL HWWARN('HWBSUD',503,*999)
+#else
+        if (VQCUT .NE.VQOLD) then
+          call hwwarn('HWBSUD',503,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (ACCUR .NE.ACOLD) CALL HWWARN('HWBSUD',504,*999)
+#else
+        if (ACCUR .NE.ACOLD) then
+          call hwwarn('HWBSUD',504,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (INTER .NE.INOLD) CALL HWWARN('HWBSUD',505,*999)
+#else
+        if (INTER .NE.INOLD) then
+          call hwwarn('HWBSUD',505,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (NQEV  .NE.NQOLD) CALL HWWARN('HWBSUD',506,*999)
+#else
+        if (NQEV  .NE.NQOLD) then
+          call hwwarn('HWBSUD',506,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (NSUD  .NE.NSOLD) CALL HWWARN('HWBSUD',507,*999)
+#else
+        if (NSUD  .NE.NSOLD) then
+          call hwwarn('HWBSUD',507,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (NCOLO .NE.NCOLD) CALL HWWARN('HWBSUD',508,*999)
+#else
+        if (NCOLO .NE.NCOLD) then
+          call hwwarn('HWBSUD',508,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (NFLAV .NE.NFOLD) CALL HWWARN('HWBSUD',509,*999)
+#else
+        if (NFLAV .NE.NFOLD) then
+          call hwwarn('HWBSUD',509,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (SUDORD.NE.SDOLD) CALL HWWARN('HWBSUD',510,*999)
+#else
+        if (SUDORD.NE.SDOLD) then
+          call hwwarn('HWBSUD',510,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C---CHECK MASSES AND THAT TABLES ARE BIG ENOUGH FOR THIS RUN
         DO 18 IS=1,NSUD
           IF (RMASS(IS).NE.RMOLD(IS))
+#if !defined(CERNLIB_GFORTRAN)
      &      CALL HWWARN('HWBSUD',510+IS,*999)
+#else
+     &      call hwwarn('HWBSUD',510+IS,iret)
+        if (iret .eq. 1) go to 999
+#endif
           IF (QEV(NQEV,IS).LT.QLIM.AND.HWBVMC(IS)+QG.LT.QLIM)
+#if !defined(CERNLIB_GFORTRAN)
      &      CALL HWWARN('HWBSUD',500,*999)
+#else
+     &      call hwwarn('HWBSUD',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
    18   CONTINUE
       ENDIF
       IF (LWSUD.GT.0) THEN
diff -uNr src.ORIG/mclibs/herwig/code/hwbtim.F src/mclibs/herwig/code/hwbtim.F
--- src.ORIG/mclibs/herwig/code/hwbtim.F	1996-12-03 23:16:48.000000000 +0900
+++ src/mclibs/herwig/code/hwbtim.F	2005-05-31 02:34:20.000000000 +0900
@@ -12,6 +12,9 @@
 C     Ses Nucl. Phys. B304 (1988) 794 & Comp. Phys. Comm. 58 (1990) 271.
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,DMIN,PT,EIKON,EINUM,EIDEN1,EIDEN2,EISCR,
      & WT,SPIN,Z1,Z2,PRMAX,CAZ,CX,SX,ROHEP(3),RMAT(3,3),ZERO2(2)
       INTEGER INITBR,INTERF,IPAR,JPAR,KPAR,LPAR,MPAR,NTRY,JOLD
@@ -37,7 +40,12 @@
       ELSE
          KPAR=JPAR-1
          IF (JMOPAR(1,KPAR).NE.IPAR)
+#if !defined(CERNLIB_GFORTRAN)
      &   CALL HWWARN('HWBTIM',100,*999)
+#else
+     &   call hwwarn('HWBTIM',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
 C        Generate Rho''
          CALL HWBAZF(IPAR,KPAR,RHOPAR(1,IPAR),PHIPAR(1,IPAR),
      &                         DECPAR(1,KPAR),RHOPAR(1,JPAR))
@@ -94,7 +102,14 @@
          PRMAX=(1.+ABS(WT))*EIKON
          NTRY=0
    50    NTRY=NTRY+1
+#if !defined(CERNLIB_GFORTRAN)
          IF (NTRY.GT.NBTRY) CALL HWWARN('HWBTIM',101,*999)
+#else
+         if (NTRY.GT.NBTRY) then
+          call hwwarn('HWBTIM',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
          CALL HWRAZM( ONE,CX,SX)
          CALL HWUROT(PPAR(1,JPAR),CX,SX,RMAT)
 C Determine the angle between the branching planes
diff -uNr src.ORIG/mclibs/herwig/code/hwccut.F src/mclibs/herwig/code/hwccut.F
--- src.ORIG/mclibs/herwig/code/hwccut.F	1996-12-03 23:16:48.000000000 +0900
+++ src/mclibs/herwig/code/hwccut.F	2005-05-31 02:34:39.000000000 +0900
@@ -98,7 +98,12 @@
       CALL HWULOB(PC,PA,PB)
       CALL HWULOB(PCL,PB,PHEP(1,LHEP))
       DO 50 J=1,4
+#if !defined(CERNLIB_GFORTRAN)
   50  PHEP(J,JHEP)=PCL(J)-PHEP(J,KHEP)-PHEP(J,LHEP)-PHEP(J,MHEP)
+#else
+         PHEP(J,JHEP)=PCL(J)-PHEP(J,KHEP)-PHEP(J,LHEP)-PHEP(J,MHEP)
+  50  continue
+#endif
       PHEP(5,JHEP)=QM1
       CALL HWVEQU(4,VHEP(1,LHEP),VHEP(1,MHEP))
 C Construct new vertex positions
diff -uNr src.ORIG/mclibs/herwig/code/hwcdec.F src/mclibs/herwig/code/hwcdec.F
--- src.ORIG/mclibs/herwig/code/hwcdec.F	1996-12-03 23:16:48.000000000 +0900
+++ src/mclibs/herwig/code/hwcdec.F	2005-05-31 02:34:20.000000000 +0900
@@ -7,6 +7,9 @@
 C     DECAYS CLUSTERS INTO PRIMARY HADRONS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER JCL,KCL,IP,JP,KP,IST,ID1,ID2,ID3
       IF (IERROR.NE.0) RETURN
       IF (IPROC/1000.EQ.9.OR.IPROC/1000.EQ.5) THEN
@@ -27,7 +30,12 @@
             IP=JDAHEP(2,KP)
           ENDIF
           KCL=JDAHEP(1,IP)
+#if !defined(CERNLIB_GFORTRAN)
           IF (ISTHEP(KCL)/10.NE.16) CALL HWWARN('HWCDEC',100,*999)
+#else
+          IF (ISTHEP(KCL)/10.NE.16) call hwwarn('HWCDEC',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
           ISTHEP(KCL)=164
           GOTO 20
         ENDIF
diff -uNr src.ORIG/mclibs/herwig/code/hwcfor.F src/mclibs/herwig/code/hwcfor.F
--- src.ORIG/mclibs/herwig/code/hwcfor.F	1996-12-03 23:16:48.000000000 +0900
+++ src/mclibs/herwig/code/hwcfor.F	2005-05-31 02:34:39.000000000 +0900
@@ -9,6 +9,9 @@
 C     MHS's cluster vertices
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWULDO,HWVDOT,HWRGEN,HWUPCM,DCL0,DCL(4),DCL1,
      & DFAC,DISP1(4),DISP2(4),DMAX,PCL(5),DOT1,DOT2,FAC,VCLUS,SCA1,SCA2,
      & EM0,EM1,EM2,PC0,PC1
@@ -30,7 +33,12 @@
       IF (IERROR.NE.0) RETURN
 C Look for partons to cluster
       DO 10 IBHEP=1,NHEP
+#if !defined(CERNLIB_GFORTRAN)
   10  IF (ISTHEP(IBHEP).GE.150.AND.ISTHEP(IBHEP).LE.154) GOTO 20
+#else
+         IF (ISTHEP(IBHEP).GE.150.AND.ISTHEP(IBHEP).LE.154) GOTO 20
+  10  continue
+#endif
       IBCL=1
       GOTO 130
 C Allow for clour rearrangement of primary clusters
@@ -88,7 +96,12 @@
         IF (JHEP.NE.JBHEP) GOTO 30
         IF (NRECO.NE.0) THEN
           DO 50 IHEP=IBHEP,NHEP
+#if !defined(CERNLIB_GFORTRAN)
   50      JDAHEP(2,IHEP)=ABS(JDAHEP(2,IHEP))
+#else
+             JDAHEP(2,IHEP)=ABS(JDAHEP(2,IHEP))
+  50      continue
+#endif
         ENDIF
       ENDIF
 C Find (adjusted) cluster positions using MHS prescription
@@ -140,8 +153,14 @@
         SCA1=MAX(ONE,ONE+FAC)
         SCA2=MAX(ONE,ONE-FAC)
         DO 60 I=1,4
+#if !defined(CERNLIB_GFORTRAN)
   60    VCLUS(I,JHEP)=.5*(VHEP(I,JHEP)+VHEP(I,KHEP)
      &                   +SCA1*DISP1(I)+SCA2*DISP2(I))
+#else
+           VCLUS(I,JHEP)=.5*(VHEP(I,JHEP)+VHEP(I,KHEP)
+     &                   +SCA1*DISP1(I)+SCA2*DISP2(I))
+  60    continue
+#endif
       ENDIF
   70  CONTINUE
 C First chop up beam/target clusters
@@ -229,7 +248,12 @@
       IF (LCL.GT.NHEP) LCL=LCL-MCL
       IF (LCL.EQ.JCL) THEN
         IF (EM0.GE.EM1+RMIN(1,1)) GOTO 150
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWCFOR',101,*999)
+#else
+        call hwwarn('HWCFOR',101,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
       IF (ISTHEP(LCL).LT.163.OR.ISTHEP(LCL).GT.165) GOTO 140
 C Rescale momenta in 2-cluster CoM
@@ -260,10 +284,20 @@
         CALL HWDTWO(PCL,PHEP(1,JCL),PHEP(1,LCL),PC1,TWO,.TRUE.)
         GOTO 150
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWCFOR',102,*999)
+#else
+        call hwwarn('HWCFOR',102,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
   140 CONTINUE
+#if !defined(CERNLIB_GFORTRAN)
       CALL HWWARN('HWCFOR',103,*999)
+#else
+      call hwwarn('HWCFOR',103,iret)
+        if (iret .eq. 1) go to 999
+#endif
   150 CONTINUE
       ISTAT=60
 C Non-partons labelled as partons (ie photons) should get copied
diff -uNr src.ORIG/mclibs/herwig/code/hwcgsp.F src/mclibs/herwig/code/hwcgsp.F
--- src.ORIG/mclibs/herwig/code/hwcgsp.F	1996-12-03 23:16:49.000000000 +0900
+++ src/mclibs/herwig/code/hwcgsp.F	2005-05-31 02:34:39.000000000 +0900
@@ -8,10 +8,20 @@
 C     BRANCHING INTO LIGHT (I.E. U OR D) Q-QBAR PAIRS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,PF
       INTEGER HWRINT,IHEP,JHEP,KHEP,LHEP,MHEP,ID,J,IST
       EXTERNAL HWRGEN,HWRINT
+#if !defined(CERNLIB_GFORTRAN)
       IF (NGSPL.EQ.0) CALL HWWARN('HWCGSP',400,*999)
+#else
+      if (NGSPL.EQ.0) then
+          call hwwarn('HWCGSP',400,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       LHEP=NHEP-1
       MHEP=NHEP
       DO 100 IHEP=1,NHEP
@@ -21,13 +31,28 @@
         IF (ISTHEP(JHEP).EQ.155) THEN
           JHEP=JDAHEP(1,JDAHEP(2,JHEP))
           DO 10 J=JDAHEP(1,JHEP),JDAHEP(2,JHEP)
+#if !defined(CERNLIB_GFORTRAN)
   10      IF (ISTHEP(J).EQ.149.AND.JDAHEP(2,J).EQ.0) GOTO 20
+#else
+             IF (ISTHEP(J).EQ.149.AND.JDAHEP(2,J).EQ.0) GOTO 20
+  10      continue
+#endif
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWCGSP',100,*999)
+#else
+          call hwwarn('HWCGSP',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
   20      JHEP=J
         ENDIF
         KHEP=JDAHEP(2,IHEP)
 C---CHECK FOR DECAYED HEAVY QUARKS
+#if !defined(CERNLIB_GFORTRAN)
         IF (ISTHEP(KHEP).EQ.155)  CALL HWWARN('HWCGSP',101,*999)
+#else
+        IF (ISTHEP(KHEP).EQ.155)  call hwwarn('HWCGSP',101,iret)
+        if (iret .eq. 1) go to 999
+#endif
         IF (IDHW(IHEP).EQ.13) THEN
 C---SPLIT A GLUON
           LHEP=LHEP+2
diff -uNr src.ORIG/mclibs/herwig/code/hwchad.F src/mclibs/herwig/code/hwchad.F
--- src.ORIG/mclibs/herwig/code/hwchad.F	1996-12-03 23:16:49.000000000 +0900
+++ src/mclibs/herwig/code/hwchad.F	2005-05-31 02:34:20.000000000 +0900
@@ -9,6 +9,9 @@
 C     (IN SPECIAL CLUSTER CODE - SEE HWCFLA)
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,EM0,EM1,EM2,EMADU,EMSQ,PCMAX,PCM,PTEST,
      & PCQK,PP(5),EMLOW,RMAT(3,3),CT,ST,CX,SX
       INTEGER HWRINT,JCL,ID1,ID2,ID3,ID,IR1,IR2,NTRY,IDMIN,IMAX,I,MHEP,
@@ -24,7 +27,14 @@
       IF (ABS(EM0-EM1).LT.0.001) THEN
 C---SINGLE-HADRON CLUSTER
         NHEP=NHEP+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NHEP.GT.NMXHEP) CALL HWWARN('HWCHAD',100,*999)
+#else
+        if (NHEP.GT.NMXHEP) then
+          call hwwarn('HWCHAD',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IDHW(NHEP)=IR1
         IDHEP(NHEP)=IDPDG(IR1)
         ISTHEP(NHEP)=191
@@ -80,7 +90,12 @@
           IF (PCM.GT.0.) GOTO 70
           NTRY=NTRY+1
           IF (NTRY.LE.NDTRY+50) GOTO 60
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWCHAD',101,*999)
+#else
+          call hwwarn('HWCHAD',101,iret)
+        if (iret .eq. 1) go to 999
+#endif
 C---DECAY IS ALLOWED
   70      PCM=PCM*(EMSQ-(EM1-EM2)**2)
           IF (NTRY.GT.NCTRY) GOTO 80
@@ -95,11 +110,25 @@
         ENDIF
 C---DECAY IS CHOSEN.  GENERATE DECAY MOMENTA
 C   AND PUT PARTICLES IN /HEPEVT/
+#if !defined(CERNLIB_GFORTRAN)
   80    IF (PCM.LT.0.) CALL HWWARN('HWCHAD',102,*999)
+#else
+  80    if (PCM.LT.0.) then
+          call hwwarn('HWCHAD',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         PCM=0.5*SQRT(PCM)/EM0
         MHEP=NHEP+1
         NHEP=NHEP+2
+#if !defined(CERNLIB_GFORTRAN)
         IF (NHEP.GT.NMXHEP) CALL HWWARN('HWCHAD',103,*999)
+#else
+        if (NHEP.GT.NMXHEP) then
+          call hwwarn('HWCHAD',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         PHEP(5,MHEP)=EM1
         PHEP(5,NHEP)=EM2
         IF (CLDIR.NE.0) THEN
diff -uNr src.ORIG/mclibs/herwig/code/hwdbos.F src/mclibs/herwig/code/hwdbos.F
--- src.ORIG/mclibs/herwig/code/hwdbos.F	1996-12-03 23:16:49.000000000 +0900
+++ src/mclibs/herwig/code/hwdbos.F	2005-05-31 02:34:21.000000000 +0900
@@ -10,13 +10,21 @@
 C     IF BOSON CAME FROM W+1JET, GIVE IT THE CORRECT DECAY CORRELATIONS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWRUNI,HWUPCM,HWULDO,R(3,3),CV,CA,BR,PCM,
      & PBOS(5),PMAX,PROB,RRLL,RLLR
       INTEGER HWRINT,IBOS,IPAIR,ICMF,IOPT,IHEL,IMOTH,I,IQRK,IANT,ID,IQ
       LOGICAL QUARKS
       EXTERNAL HWRGEN,HWRUNI,HWUPCM,HWULDO,HWRINT
       IF (IDHW(IBOS).LT.198.OR.IDHW(IBOS).GT.200)
+#if !defined(CERNLIB_GFORTRAN)
      &  CALL HWWARN('HWDBOS',101,*999)
+#else
+     &  call hwwarn('HWDBOS',101,iret)
+        if (iret .eq. 1) go to 999
+#endif
       QUARKS=.FALSE.
 C---SEE IF IT IS PART OF A PAIR
       IMOTH=JMOHEP(1,IBOS)
@@ -58,7 +66,14 @@
         PHEP(5,NHEP+1)=RMASS(IDN(1))
         PHEP(5,NHEP+2)=RMASS(IDN(2))
         PCM=HWUPCM(PHEP(5,IBOS),PHEP(5,NHEP+1),PHEP(5,NHEP+2))
+#if !defined(CERNLIB_GFORTRAN)
         IF (PCM.LT.0) CALL HWWARN('HWDBOS',103,*999)
+#else
+        if (PCM.LT.0) then
+          call hwwarn('HWDBOS',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IF (IDHW(IBOS).EQ.200) THEN
           ID=IDN(1)
           IF (ID.GT.120) ID=ID-110
@@ -85,7 +100,14 @@
      &             HWULDO(PHEP(1,IQRK),PHEP(1,NHEP+2))**2)+
      &       RLLR*(HWULDO(PHEP(1,IANT),PHEP(1,NHEP+2))**2+
      &             HWULDO(PHEP(1,IQRK),PHEP(1,NHEP+1))**2)
+#if !defined(CERNLIB_GFORTRAN)
         IF (PROB.GT.PMAX.OR.PROB.LT.0) CALL HWWARN('HWDBOS',104,*999)
+#else
+        if (PROB.GT.PMAX.OR.PROB.LT.0) then
+          call hwwarn('HWDBOS',104,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IF (PMAX*HWRGEN(0).GT.PROB) GOTO 1
       ELSE
 C---SELECT HELICITY, UNLESS IT IS THE SECOND OF A HIGGS DECAY (EPR)
@@ -97,7 +119,12 @@
           IF (RHOHEP(1,IBOS)+RHOHEP(2,IBOS)+RHOHEP(3,IBOS).GT.0)
      &    GOTO 20
         ENDIF
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWDBOS',1,*999)
+#else
+        call hwwarn('HWDBOS',1,iret)
+        if (iret .eq. 1) go to 999
+#endif
         RHOHEP(1,IBOS)=1.
         RHOHEP(2,IBOS)=1.
         RHOHEP(3,IBOS)=1.
@@ -114,7 +141,14 @@
       PHEP(5,NHEP+1)=RMASS(IDN(1))
       PHEP(5,NHEP+2)=RMASS(IDN(2))
       PCM=HWUPCM(PHEP(5,IBOS),PHEP(5,NHEP+1),PHEP(5,NHEP+2))
+#if !defined(CERNLIB_GFORTRAN)
       IF (PCM.LT.0) CALL HWWARN('HWDBOS',102,*999)
+#else
+      if (PCM.LT.0) then
+          call hwwarn('HWDBOS',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       CALL HWRAZM(PCM*SQRT(1-COSTH**2),PHEP(1,NHEP+1),PHEP(2,NHEP+1))
       PHEP(3,NHEP+1)=PCM*COSTH
       PHEP(4,NHEP+1)=SQRT(PHEP(5,NHEP+1)**2+PCM**2)
diff -uNr src.ORIG/mclibs/herwig/code/hwdboz.F src/mclibs/herwig/code/hwdboz.F
--- src.ORIG/mclibs/herwig/code/hwdboz.F	1996-12-03 23:16:50.000000000 +0900
+++ src/mclibs/herwig/code/hwdboz.F	2005-05-31 02:34:39.000000000 +0900
@@ -8,6 +8,9 @@
 C     IOPT=2 TO RESET COUNTERS, 1 FOR BOSON PAIR, 0 FOR ANY OTHERS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,BRMODE(12,3),CV,CA,BR,BRLST,BRCOM,FACZ,
      & FACW
       INTEGER HWRINT,IDBOS,IDEC,IDMODE(2,12,3),IFER,IANT,IOPT,I1,I2,
@@ -32,7 +35,14 @@
       DATA FACW,FACZ/2*0.0/
       IF (FACZ.EQ.0) FACZ=SQRT(SWEIN)
       IF (FACW.EQ.0) FACW=0.5/SQRT(2D0)
+#if !defined(CERNLIB_GFORTRAN)
       IF (IDBOS.LT.198.OR.IDBOS.GT.200) CALL HWWARN('HWDBOZ',101,*999)
+#else
+      if (IDBOS.LT.198.OR.IDBOS.GT.200) then
+          call hwwarn('HWDBOZ',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C---IF THIS IS A NEW EVENT SINCE LAST TIME, ZERO COUNTERS
       IF (NWGTS.NE.NWGLST .OR.(GENEV.NEQV.GENLST).OR. IOPT.EQ.2) THEN
         NPAIR=0
@@ -42,10 +52,24 @@
         IF (IOPT.EQ.2) RETURN
       ENDIF
       NUMDEC=NUMDEC+1
+#if !defined(CERNLIB_GFORTRAN)
       IF (NUMDEC.GT.MODMAX) CALL HWWARN('HWDBOZ',102,*999)
+#else
+      if (NUMDEC.GT.MODMAX) then
+          call hwwarn('HWDBOZ',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C---IF PAIR OPTION SPECIFIED FOR THE FIRST TIME, MAKE CHOICE
       IF (IOPT.EQ.1) THEN
+#if !defined(CERNLIB_GFORTRAN)
         IF (NUMDEC.GT.MODMAX-1) CALL HWWARN('HWDBOZ',103,*999)
+#else
+        if (NUMDEC.GT.MODMAX-1) then
+          call hwwarn('HWDBOZ',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IF (NPAIR.EQ.0) THEN
           IF (HWRGEN(1).GT.0.5) THEN
             MODTMP=MODBOS(NUMDEC+1)
@@ -113,7 +137,12 @@
 C   (RESULT IS NOT WELL-DEFINED AFTER THE FIRST CALL OF A PAIR)
       BR=0
       DO 20 IDEC=I1,I2
+#if !defined(CERNLIB_GFORTRAN)
  20     BR=BR+BRMODE(IDEC,IDBOS-197)
+#else
+           BR=BR+BRMODE(IDEC,IDBOS-197)
+ 20     continue
+#endif
       IF (IOPT.EQ.1) THEN
         IF (NPAIR.NE.0) THEN
           I1LST=I1
@@ -122,7 +151,12 @@
         ELSE
           BRCOM=0
           DO 30 IDEC=MAX(I1,I1LST),MIN(I2,I2LST)
+#if !defined(CERNLIB_GFORTRAN)
  30         BRCOM=BRCOM+BRMODE(IDEC,IDBOS-197)
+#else
+               BRCOM=BRCOM+BRMODE(IDEC,IDBOS-197)
+ 30         continue
+#endif
           BR=2*BR*BRLST - BRCOM**2
         ENDIF
       ENDIF
diff -uNr src.ORIG/mclibs/herwig/code/hwdcle.F src/mclibs/herwig/code/hwdcle.F
--- src.ORIG/mclibs/herwig/code/hwdcle.F	1996-12-03 23:16:53.000000000 +0900
+++ src/mclibs/herwig/code/hwdcle.F	2005-05-31 02:34:21.000000000 +0900
@@ -7,6 +7,9 @@
 C INTERFACE TO QQ-CLEO MONTE CARLO (LS 11/12/91)
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER IHEP,IIHEP,NHEPHF,QQLMAT
       LOGICAL QQLERR
       CHARACTER*8 NAME
@@ -118,7 +121,14 @@
       IF(FSTEVT) THEN
 C---INITIALIZE QQ-CLEO
         CALL QQINIT(QQLERR)
+#if !defined(CERNLIB_GFORTRAN)
         IF(QQLERR) CALL HWWARN('HWDEUR',500,*999)
+#else
+        if (QQLERR) then
+          call hwwarn('HWDEUR',500,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       ENDIF
 C---CONSTRUCT THE HADRON FOR QQ-CLEO
 C NOTE: THE IDPDG CODE IS PROVIDED THROUGH THE QQLMAT ROUTINE
diff -uNr src.ORIG/mclibs/herwig/code/hwdeur.F src/mclibs/herwig/code/hwdeur.F
--- src.ORIG/mclibs/herwig/code/hwdeur.F	1996-12-03 23:16:53.000000000 +0900
+++ src/mclibs/herwig/code/hwdeur.F	2005-05-31 02:34:21.000000000 +0900
@@ -7,6 +7,9 @@
 C INTERFACE TO EURODEC PACKAGE (LS 10/29/91)
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER IHEP,IIHEP,NHEPHF,IEUPDG,IPDGEU
       CHARACTER*8 NAME
 C---EURODEC COMMON'S : INITIAL INPUT
@@ -94,6 +97,13 @@
       VHEP(2,NHEP)=EUSECV(2,IIHEP)
       VHEP(3,NHEP)=EUSECV(3,IIHEP)
       VHEP(4,NHEP)=0.
+#if !defined(CERNLIB_GFORTRAN)
       IF (IIHEP.GT.NTMAX) CALL HWWARN('HWDEUR',99,*999)
+#else
+      if (IIHEP.GT.NTMAX) then
+          call hwwarn('HWDEUR',99,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
    40 CONTINUE
   999 END
diff -uNr src.ORIG/mclibs/herwig/code/hwdfiv.F src/mclibs/herwig/code/hwdfiv.F
--- src.ORIG/mclibs/herwig/code/hwdfiv.F	1996-12-03 23:16:53.000000000 +0900
+++ src/mclibs/herwig/code/hwdfiv.F	2005-05-31 02:34:21.000000000 +0900
@@ -12,7 +12,14 @@
       EXTERNAL HWRGEN
       B=P0(5)-P1(5)
       C=P2(5)+P3(5)+P4(5)+P5(5)
+#if !defined(CERNLIB_GFORTRAN)
       IF (B.LT.C) CALL HWWARN('HWDFIV',100,*999)
+#else
+      if (B.LT.C) then
+          call hwwarn('HWDFIV',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       AA=(P0(5)+P1(5))**2
       BB=B**2
       CC=C**2
diff -uNr src.ORIG/mclibs/herwig/code/hwdfor.F src/mclibs/herwig/code/hwdfor.F
--- src.ORIG/mclibs/herwig/code/hwdfor.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwdfor.F	2005-05-31 02:34:21.000000000 +0900
@@ -11,7 +11,14 @@
       EXTERNAL HWRGEN
       B=P0(5)-P1(5)
       C=P2(5)+P3(5)+P4(5)
+#if !defined(CERNLIB_GFORTRAN)
       IF (B.LT.C) CALL HWWARN('HWDFOR',100,*999)
+#else
+      if (B.LT.C) then
+          call hwwarn('HWDFOR',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       AA=(P0(5)+P1(5))**2
       BB=B**2
       CC=C**2
diff -uNr src.ORIG/mclibs/herwig/code/hwdhad.F src/mclibs/herwig/code/hwdhad.F
--- src.ORIG/mclibs/herwig/code/hwdhad.F	1996-12-03 23:16:53.000000000 +0900
+++ src/mclibs/herwig/code/hwdhad.F	2005-05-31 02:34:40.000000000 +0900
@@ -7,6 +7,9 @@
 C     GENERATES DECAYS OF UNSTABLE HADRONS AND LEPTONS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWULDO,RN,BF,COSANG,RSUM,DIST(4),VERTX(4),
      & PMIX,WTMX,WTMX2,XS,DOT1,DOT2
       INTEGER IHEP,ID,MHEP,IDM,I,IDS,IM,MO,IPDG
@@ -21,7 +24,14 @@
      &  JDAHEP(1,IHEP).EQ.IHEP.AND.JDAHEP(2,IHEP).EQ.IHEP) THEN
 C---COPY COLOUR SINGLET CMF
         NHEP=NHEP+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NHEP.GT.NMXHEP) CALL HWWARN('HWDHAD',100,*999)
+#else
+        if (NHEP.GT.NMXHEP) then
+          call hwwarn('HWDHAD',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         CALL HWVEQU(5,PHEP(1,IHEP),PHEP(1,NHEP))
         CALL HWVEQU(4,VHEP(1,IHEP),VHEP(1,NHEP))
         IDHW(NHEP)=IDHW(IHEP)
@@ -78,7 +88,14 @@
                 IDM=ID
               ENDIF
 C Introduce a decaying neutral b-meson
+#if !defined(CERNLIB_GFORTRAN)
               IF (NHEP+1.GT.NMXHEP) CALL HWWARN('HWDHAD',101,*999)
+#else
+              if (NHEP+1.GT.NMXHEP) then
+          call hwwarn('HWDHAD',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
               MHEP=NHEP+1
               ISTHEP(MHEP)=ISTHEP(IHEP)
               ISTHEP(IHEP)=200
@@ -115,13 +132,25 @@
           DO 10 I=1,NMODES(IDM)
           BF=BF+BRFRAC(IM)
           IF (BF.GE.RN) GOTO 20
+#if !defined(CERNLIB_GFORTRAN)
   10      IM=LNEXT(IM)
+#else
+             IM=LNEXT(IM)
+  10      continue
+#endif
           CALL HWWARN('HWDHAD',50,*20)
   20      IF ((IDKPRD(1,IM).GE.1.AND.IDKPRD(1,IM).LE.13).OR.
      &        (IDKPRD(3,IM).GE.1.AND.IDKPRD(3,IM).LE.13)) THEN
 C Partonic decay of a heavy-(b,c)-hadron, store details
             NQDK=NQDK+1
+#if !defined(CERNLIB_GFORTRAN)
             IF (NQDK.GT.NMXQDK) CALL HWWARN('HWDHAD',102,*999)
+#else
+            if (NQDK.GT.NMXQDK) then
+          call hwwarn('HWDHAD',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
             LOCQ(NQDK)=MHEP
             IMQDK(NQDK)=IM
             CALL HWVEQU(4,VERTX,VTXQDK(1,NQDK))
@@ -129,7 +158,12 @@
           ELSE
 C Exclusive decay, add decay products to event record
             IF (NHEP+NPRODS(IM).GT.NMXHEP)
+#if !defined(CERNLIB_GFORTRAN)
      &        CALL HWWARN('HWDHAD',103,*999)
+#else
+     &        call hwwarn('HWDHAD',103,iret)
+        if (iret .eq. 1) go to 999
+#endif
             JDAHEP(1,MHEP)=NHEP+1
             DO 30 I=1,NPRODS(IM)
             NHEP=NHEP+1
@@ -139,7 +173,12 @@
             JMOHEP(1,NHEP)=MHEP
             JMOHEP(2,NHEP)=JMOHEP(2,MHEP)
             PHEP(5,NHEP)=RMASS(IDKPRD(I,IM))
+#if !defined(CERNLIB_GFORTRAN)
   30        CALL HWVEQU(4,VERTX,VHEP(1,NHEP))
+#else
+               CALL HWVEQU(4,VERTX,VHEP(1,NHEP))
+  30        continue
+#endif
             JDAHEP(2,MHEP)=NHEP
           ENDIF
 C Next choose momenta:
@@ -154,7 +193,12 @@
               MO=JMOHEP(1,MHEP)
               RSUM=0
               DO 40 I=1,3
+#if !defined(CERNLIB_GFORTRAN)
   40          RSUM=RSUM+RHOHEP(I,MO)
+#else
+                 RSUM=RSUM+RHOHEP(I,MO)
+  40          continue
+#endif
               IF (RSUM.GT.0) THEN
                 RSUM=RSUM*HWRGEN(3)
                 IF (RSUM.LT.RHOHEP(1,MO)) THEN
@@ -207,11 +251,21 @@
             CALL HWDFIV(PHEP(1,MHEP  ),PHEP(1,NHEP-4),PHEP(1,NHEP-3),
      &                  PHEP(1,NHEP-2),PHEP(1,NHEP-1),PHEP(1,NHEP))
           ELSE
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWDHAD',104,*999)
+#else
+            call hwwarn('HWDHAD',104,iret)
+        if (iret .eq. 1) go to 999
+#endif
           ENDIF
         ENDIF
       ENDIF
   100 CONTINUE
 C---MAY HAVE OVERFLOWED /HEPEVT/
+#if !defined(CERNLIB_GFORTRAN)
       CALL HWWARN('HWDHAD',105,*999)
+#else
+      call hwwarn('HWDHAD',105,iret)
+        if (iret .eq. 1) go to 999
+#endif
   999 END
diff -uNr src.ORIG/mclibs/herwig/code/hwdhig.F src/mclibs/herwig/code/hwdhig.F
--- src.ORIG/mclibs/herwig/code/hwdhig.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwdhig.F	2005-05-31 02:34:40.000000000 +0900
@@ -10,6 +10,9 @@
 C                     FOR EMH=GAMINP. STORE RESULT IN GAMINP.
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWDHGF,HWRGEN,HWRUNI,HWUSQR,HWUPCM,GAMINP,EMH,
      & EMF,COLFAC,ENF,K1,K0,BET0,BET1,GAM0,GAM1,SCLOG,CFAC,XF,EM,GAMLIM,
      & GAM,XW,EMW,XZ,EMZ,YW,YZ,EMI,TAUT,TAUW,WIDHIG,VECDEC,EMB,GAMB,
@@ -27,10 +30,29 @@
       IF (GAMINP.EQ.0) THEN
         IHIG=0
         DO 10 I=1,NHEP
+#if !defined(CERNLIB_GFORTRAN)
  10       IF (IHIG.EQ.0.AND.IDHW(I).EQ.201.AND.ISTHEP(I).EQ.1) IHIG=I
+#else
+             IF (IHIG.EQ.0.AND.IDHW(I).EQ.201.AND.ISTHEP(I).EQ.1) IHIG=I
+ 10       continue
+#endif
+#if !defined(CERNLIB_GFORTRAN)
         IF (IHIG.EQ.0) CALL HWWARN('HWDHIG',101,*999)
+#else
+        if (IHIG.EQ.0) then
+          call hwwarn('HWDHIG',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         EMH=PHEP(5,IHIG)
+#if !defined(CERNLIB_GFORTRAN)
         IF (EMH.LE.0) CALL HWWARN('HWDHIG',102,*999)
+#else
+        if (EMH.LE.0) then
+          call hwwarn('HWDHIG',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         EMSCA=EMH
       ELSE
         EMH=GAMINP
@@ -44,7 +66,12 @@
 C---NLL CORRECTION TO QUARK DECAY RATE (HHG eq 2.6-9)
       ENF=0
       DO 1 I=1,6
+#if !defined(CERNLIB_GFORTRAN)
  1      IF (2*RMASS(I).LT.EMH) ENF=ENF+1
+#else
+            IF (2*RMASS(I).LT.EMH) ENF=ENF+1
+ 1      continue
+#endif
       K1=5/PIFAC**2
       K0=3/(4*PIFAC**2)
       BET0=(11*CAFAC-2*ENF)/3
@@ -107,10 +134,27 @@
       WIDHIG=0
       DO 200 IPART=1, 12
         IF (IPART.LT.12) BRHIG(IPART)=BRHIG(IPART)*ENHANC(IPART)**2
+#if !defined(CERNLIB_GFORTRAN)
  200    WIDHIG=WIDHIG+BRHIG(IPART)
+#else
+          WIDHIG=WIDHIG+BRHIG(IPART)
+ 200    continue
+#endif
+#if !defined(CERNLIB_GFORTRAN)
       IF (WIDHIG.EQ.0) CALL HWWARN('HWDHIG',103,*999)
+#else
+      if (WIDHIG.EQ.0) then
+          call hwwarn('HWDHIG',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       DO 300 IPART=1, 12
+#if !defined(CERNLIB_GFORTRAN)
  300    BRHIG(IPART)=BRHIG(IPART)/WIDHIG
+#else
+          BRHIG(IPART)=BRHIG(IPART)/WIDHIG
+ 300    continue
+#endif
       IF (EM.NE.RMASS(201)) THEN
 C---SET UP W*W*/Z*Z* LOOKUP TABLES
         EM=EMH
@@ -141,7 +185,12 @@
         IF (BRHIG(IMODE).LT.HWRGEN(0)) GOTO 500
       ENDIF
 C---SEE IF SPECIFIED DECAY IS POSSIBLE
+#if !defined(CERNLIB_GFORTRAN)
       IF (BRHIG(IMODE).EQ.0) CALL HWWARN('HWDHIG',104,*999)
+#else
+      IF (BRHIG(IMODE).EQ.0) call hwwarn('HWDHIG',104,iret)
+        if (iret .eq. 1) go to 999
+#endif
       IF (IMODE.LE.6) THEN
         IDEC=IMODE
       ELSEIF (IMODE.LE.9) THEN
@@ -205,7 +254,14 @@
       ENDIF
 C---DO DECAY
       PCM=HWUPCM(EMH,PHEP(5,NHEP+1),PHEP(5,NHEP+2))
+#if !defined(CERNLIB_GFORTRAN)
       IF (PCM.LT.0) CALL HWWARN('HWDHIG',105,*999)
+#else
+      if (PCM.LT.0) then
+          call hwwarn('HWDHIG',105,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       CALL HWDTWO(PHEP(1,IHIG),PHEP(1,NHEP+1),PHEP(1,NHEP+2),
      &            PCM,TWO,.TRUE.)
       NHEP=NHEP+2
diff -uNr src.ORIG/mclibs/herwig/code/hwdhqk.F src/mclibs/herwig/code/hwdhqk.F
--- src.ORIG/mclibs/herwig/code/hwdhqk.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwdhqk.F	2005-05-31 02:34:40.000000000 +0900
@@ -7,6 +7,9 @@
 C     Performs weak decays of heavy quarks: 0 -> W + 3,  W -> 1 + 2(bar)
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWULDO,RN,BF,EMMX,EMWSQ,GMWSQ,EMLIM,PW(4),
      & EMTST
       INTEGER IST(3),IHEP,IS,ID,IM,I,LHEP,MHEP
@@ -28,9 +31,21 @@
         DO 20 I=1,NMODES(ID)
         BF=BF+BRFRAC(IM)
         IF (BF.GE.RN) GOTO 30
+#if !defined(CERNLIB_GFORTRAN)
   20    IM=LNEXT(IM)
+#else
+           IM=LNEXT(IM)
+  20    continue
+#endif
         CALL HWWARN('HWDHQK',50,*30)
+#if !defined(CERNLIB_GFORTRAN)
   30    IF (NHEP+4.GT.NMXHEP) CALL HWWARN('HWDHQK',100,*999)
+#else
+  30    if (NHEP+4.GT.NMXHEP) then
+          call hwwarn('HWDHQK',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C Make a copy of decaying heavy (anti-)quark
         NHEP=NHEP+1
         ISTHEP(NHEP)=155
@@ -41,7 +56,12 @@
         IF (IDHEP(IHEP).GT.0) THEN
 C Re-set pointer of quark's colour mother
           IF (JDAHEP(2,JMOHEP(2,IHEP)).NE.IHEP)
+#if !defined(CERNLIB_GFORTRAN)
      &      CALL HWWARN('HWDHQK',98,*999)
+#else
+     &      call hwwarn('HWDHQK',98,iret)
+        if (iret .eq. 1) go to 999
+#endif
           JDAHEP(2,JMOHEP(2,IHEP))=NHEP
 C and pointer of flavour partner
           IF (JMOHEP(2,JDAHEP(2,IHEP)).EQ.IHEP)
@@ -49,7 +69,12 @@
         ELSE
 C Re-set pointer of anti-quark's colour daughter
           IF (JMOHEP(2,JDAHEP(2,IHEP)).NE.IHEP)
+#if !defined(CERNLIB_GFORTRAN)
      &      CALL HWWARN('HWDHQK',99,*999)
+#else
+     &      call hwwarn('HWDHQK',99,iret)
+        if (iret .eq. 1) go to 999
+#endif
           JMOHEP(2,JDAHEP(2,IHEP))=NHEP
 C and pointer of anti-flavour partner
           IF (JDAHEP(2,JMOHEP(2,IHEP)).EQ.IHEP)
@@ -77,8 +102,13 @@
         JMOHEP(2,NHEP)=MHEP
         JDAHEP(1,NHEP)=0
         JDAHEP(2,NHEP)=MHEP
+#if !defined(CERNLIB_GFORTRAN)
   40    PHEP(5,NHEP)=RMASS(IDKPRD(I,IM))
 C Assign production vertex to 3 (and W)
+#else
+           PHEP(5,NHEP)=RMASS(IDKPRD(I,IM))
+  40    continue
+#endif
         CALL HWUDKL(ID,PHEP(1,IHEP),VHEP(1,NHEP))
         CALL HWVSUM(4,VHEP(1,IHEP),VHEP(1,NHEP),VHEP(1,NHEP))
         IF (NME(IM).EQ.130) THEN
diff -uNr src.ORIG/mclibs/herwig/code/hwdhvy.F src/mclibs/herwig/code/hwdhvy.F
--- src.ORIG/mclibs/herwig/code/hwdhvy.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwdhvy.F	2005-05-31 02:34:40.000000000 +0900
@@ -9,6 +9,9 @@
 C     or, quarkonia -> 2-gluons, q-qbar, 3-gluons, or 2-gluons + photon.
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWULDO,HWRGEN,XS,XB,EMWSQ,GMWSQ,EMLIM,PW(4),
      & EMTST,X1,X2,X3,TEST
       INTEGER IST(3),I,IHEP,IM,ID,IDQ,IQ,IS,J
@@ -20,7 +23,12 @@
       IHEP=LOCQ(I)
       IF (ISTHEP(IHEP).EQ.199) GOTO 100
       IM=IMQDK(I)
+#if !defined(CERNLIB_GFORTRAN)
       IF (NHEP+NPRODS(IM).GT.NMXHEP) CALL HWWARN('HWDHVY',100,*999)
+#else
+      IF (NHEP+NPRODS(IM).GT.NMXHEP) call hwwarn('HWDHVY',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
       IF (IDKPRD(4,IM).NE.0) THEN
 C Weak decay of meson or baryon
 C Idenitify decaying heavy quark and spectator
@@ -53,10 +61,22 @@
           IQ=NHEP+2
         ELSE
 C Decay not recognized
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWDHVY',100,*999)
+#else
+          call hwwarn('HWDHVY',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
 C Label constituents
+#if !defined(CERNLIB_GFORTRAN)
         IF (NHEP+5.GT.NMXHEP) CALL HWWARN('HWDHVY',101,*999)
+#else
+        if (NHEP+5.GT.NMXHEP) then
+          call hwwarn('HWDHVY',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         ISTHEP(IHEP)=199
         JDAHEP(1,IHEP)=NHEP+1
         JDAHEP(2,IHEP)=NHEP+2
@@ -83,7 +103,12 @@
         ISTHEP(NHEP)=IST(J)
         JMOHEP(1,NHEP)=IQ
         JDAHEP(1,NHEP)=0
+#if !defined(CERNLIB_GFORTRAN)
   10    PHEP(5,NHEP)=RMASS(IDKPRD(J,IM))
+#else
+           PHEP(5,NHEP)=RMASS(IDKPRD(J,IM))
+  10    continue
+#endif
         JMOHEP(2,NHEP-2)=NHEP-1
         JDAHEP(2,NHEP-2)=NHEP-1
         JMOHEP(2,NHEP-1)=NHEP-2
@@ -132,7 +157,12 @@
         JMOHEP(1,NHEP)=IHEP
         JDAHEP(1,NHEP)=0
         PHEP(5,NHEP)=RMASS(IDKPRD(J,IM))
+#if !defined(CERNLIB_GFORTRAN)
   30    CALL HWVZRO(4,VHEP(1,NHEP))
+#else
+           CALL HWVZRO(4,VHEP(1,NHEP))
+  30    continue
+#endif
         JDAHEP(2,IHEP)=NHEP
 C Establish colour connections and select momentum configuration
         IF (NPRODS(IM).EQ.3) THEN
diff -uNr src.ORIG/mclibs/herwig/code/hwdidp.F src/mclibs/herwig/code/hwdidp.F
--- src.ORIG/mclibs/herwig/code/hwdidp.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwdidp.F	2005-05-31 02:34:40.000000000 +0900
@@ -17,7 +17,12 @@
 C---LEPTONS HAVE ID CODES 121-132
       IF (N.EQ.4) ID=ID0+120
       IF (RN.LT.FR) GOTO 30
+#if !defined(CERNLIB_GFORTRAN)
    10 ID=ID+2
+#else
+         ID=ID+2
+   10 continue
+#endif
       ID=ID-2
    30 HWDIDP=ID
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwdthr.F src/mclibs/herwig/code/hwdthr.F
--- src.ORIG/mclibs/herwig/code/hwdthr.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwdthr.F	2005-05-31 02:34:21.000000000 +0900
@@ -14,7 +14,14 @@
       A=P0(5)+P1(5)
       B=P0(5)-P1(5)
       C=P2(5)+P3(5)
+#if !defined(CERNLIB_GFORTRAN)
       IF (B.LT.C) CALL HWWARN('HWDTHR',100,*999)
+#else
+      if (B.LT.C) then
+          call hwwarn('HWDTHR',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       D=ABS(P2(5)-P3(5))
       AA=A*A
       BB=B*B
diff -uNr src.ORIG/mclibs/herwig/code/hwegam.F src/mclibs/herwig/code/hwegam.F
--- src.ORIG/mclibs/herwig/code/hwegam.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwegam.F	2005-05-31 02:34:21.000000000 +0900
@@ -8,6 +8,9 @@
 C     ELSE EQUIVALENT PHOTON APPROX FROM INCOMING E+, E-, MU+ OR MU-
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWRUNI,EGMIN,ZMIN,ZMAX,ZGAM,SS,ZMI,ZMA,
      & PPL,PMI,QT2,Q2,QQMIN,QQMAX,S0,A
       INTEGER IHEP,IHADIS,HQ
@@ -15,7 +18,14 @@
       EXTERNAL HWRGEN,HWRUNI
       DATA EGMIN/5.D0/
       IF (IERROR.NE.0)  RETURN
+#if !defined(CERNLIB_GFORTRAN)
       IF (IHEP.LT.1.OR.IHEP.GT.2) CALL HWWARN('HWEGAM',500,*999)
+#else
+      if (IHEP.LT.1.OR.IHEP.GT.2) then
+          call hwwarn('HWEGAM',500,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       SS=PHEP(5,3)
       IF (IHEP.EQ.1) THEN
         IHADIS=2
@@ -64,7 +74,14 @@
           ZMAX = ONE
         ELSE
 C---UNKNOWN PROCESS: USE ENERGY CUTOFF, AND WARN USER
+#if !defined(CERNLIB_GFORTRAN)
           IF (FSTWGT) CALL HWWARN('HWEGAM',1,*999)
+#else
+          if (FSTWGT) then
+          call hwwarn('HWEGAM',1,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           ZMIN = EGMIN / PHEP(4,IHEP)
           ZMAX = ONE
         ENDIF
diff -uNr src.ORIG/mclibs/herwig/code/hweisr.F src/mclibs/herwig/code/hweisr.F
--- src.ORIG/mclibs/herwig/code/hweisr.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hweisr.F	2005-05-31 02:34:21.000000000 +0900
@@ -7,6 +7,9 @@
 C     GENERATES AN ISR PHOTON FROM INCOMING E+, E-, MU+ OR MU-
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,QSQMAX,QSQMIN,A,B,B1,B2,B3,B4,B5,B6,B7,B8,
      $ R,AA,T0,T1,C1,C2,T,Z(2),QSQ(2),PHI(2),C
       INTEGER IHEP,I,J
@@ -15,7 +18,14 @@
 C---IF ZMXISR IS ZERO, THERE CAN BE NO ISR
       IF (ZMXISR.EQ.0 .OR. IPRO.GT.3) RETURN
 C---CHECK CONSISTENCY OF TMNISR AND ZMXISR
+#if !defined(CERNLIB_GFORTRAN)
       IF (ZMXISR**2.LT.TMNISR) CALL HWWARN('HWEISR',200,*999)
+#else
+      if (ZMXISR**2.LT.TMNISR) then
+          call hwwarn('HWEISR',200,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C---CALCULATE VIRTUALITY LIMITS
       QSQMAX=4*PHEP(4,IHEP)**2
       QSQMIN=PHEP(5,IHEP)**2
@@ -167,7 +177,12 @@
 C---EVERYTHING WAS GENERATED LAST TIME
       ELSE
 C---ROUTINE CALLED UNEXPECTEDLY
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWEISR',201,*999)
+#else
+        call hwwarn('HWEISR',201,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
 C---IF Z IS TOO LARGE THERE IS NO EMISSION
       IF (Z(IHEP).GT.ZMXISR) RETURN
diff -uNr src.ORIG/mclibs/herwig/code/hwepro.F src/mclibs/herwig/code/hwepro.F
--- src.ORIG/mclibs/herwig/code/hwepro.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwepro.F	2005-05-31 02:34:21.000000000 +0900
@@ -8,6 +8,9 @@
 C     OTHERWISE, CHOOSES AND LOADS ALL VARIABLES FOR HARD PROCESS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN
       EXTERNAL HWRGEN
       IF (IERROR.NE.0)  RETURN
@@ -180,13 +183,23 @@
         WRITE (6,40)
  40     FORMAT (1X,' IPROC=92** is no longer supported.'
      &         /1X,' Please use IPROC=91** instead.')
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWEPRO',500,*999)
+#else
+        call hwwarn('HWEPRO',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ELSEIF(IPRO.EQ.95) THEN
 C---HIGGS PRODUCTION VIA W FUSION IN E P
         CALL HWHIGW
       ELSE
 C---UNKNOWN PROCESS
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWEPRO',102,*999)
+#else
+        call hwwarn('HWEPRO',102,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
  30   IF (GENEV) THEN
         IF (NOWGT) EVWGT=AVWGT
@@ -205,21 +218,47 @@
         IF (EVWGT.GT.WBIGST) THEN
           WBIGST=EVWGT
           IF (NOWGT.AND.WBIGST.GT.WGTMAX) THEN
+#if !defined(CERNLIB_GFORTRAN)
             IF (NEVHEP.NE.0) CALL HWWARN('HWEPRO',1,*999)
+#else
+            if (NEVHEP.NE.0) then
+          call hwwarn('HWEPRO',1,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
             WGTMAX=WBIGST*1.1
             WRITE (6,99) WGTMAX
           ENDIF
         ELSEIF (EVWGT.LT.0.) THEN
+#if !defined(CERNLIB_GFORTRAN)
           IF (EVWGT.LT.-1.D-9) CALL HWWARN('HWEPRO',3,*999)
+#else
+          if (EVWGT.LT.-1.D-9) then
+          call hwwarn('HWEPRO',3,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           EVWGT=0.
         ENDIF
         IF (NEVHEP.NE.0) THEN
 C---LOW EFFICIENCY WARNINGS:
 C   RESET AT 1 PER CENT, STOP AT 1 PER MILLE
           IF (NWGTS.GT.100*NEVHEP) THEN
+#if !defined(CERNLIB_GFORTRAN)
             IF (NWGTS.GT.1000*NEVHEP) CALL HWWARN('HWEPRO',200,*999)
+#else
+            if (NWGTS.GT.1000*NEVHEP) then
+          call hwwarn('HWEPRO',200,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
             IF (MOD(NWGTS,10000).EQ.0) THEN
+#if !defined(CERNLIB_GFORTRAN)
               CALL HWWARN('HWEPRO',2,*999)
+#else
+              call hwwarn('HWEPRO',2,iret)
+        if (iret .eq. 1) go to 999
+#endif
               WGTMAX=WBIGST*1.1
               WRITE (6,99) WGTMAX
             ENDIF
diff -uNr src.ORIG/mclibs/herwig/code/hwetwo.F src/mclibs/herwig/code/hwetwo.F
--- src.ORIG/mclibs/herwig/code/hwetwo.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwetwo.F	2005-05-31 02:34:40.000000000 +0900
@@ -7,6 +7,9 @@
 C     SETS UP 2->2 HARD SUBPROCESS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWUPCM,PA,PCM
       INTEGER ICMF,IBM,I,J,K,IHEP
       EXTERNAL HWUPCM
@@ -51,9 +54,21 @@
       ISTHEP(IHEP)=110+I
       JMOHEP(1,IHEP)=ICMF
       JDAHEP(I-2,ICMF)=IHEP
+#if !defined(CERNLIB_GFORTRAN)
    20 PHEP(5,IHEP)=RMASS(IDN(I))
+#else
+         PHEP(5,IHEP)=RMASS(IDN(I))
+   20 continue
+#endif
       PCM=HWUPCM(PHEP(5,NHEP+3),PHEP(5,NHEP+4),PHEP(5,NHEP+5))
+#if !defined(CERNLIB_GFORTRAN)
       IF (PCM.LT.0.) CALL HWWARN('HWETWO',103,*999)
+#else
+      if (PCM.LT.0.) then
+          call hwwarn('HWETWO',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       IHEP=NHEP+4
       PHEP(4,IHEP)=SQRT(PCM**2+PHEP(5,IHEP)**2)
       PHEP(3,IHEP)=PCM*COSTH
@@ -68,6 +83,11 @@
       K=ICO(I)
       IF (K.GT.2) K=K+1
       JMOHEP(2,NHEP+J)=NHEP+K
+#if !defined(CERNLIB_GFORTRAN)
    30 JDAHEP(2,NHEP+K)=NHEP+J
+#else
+         JDAHEP(2,NHEP+K)=NHEP+J
+   30 continue
+#endif
       NHEP=NHEP+5
   999 END
diff -uNr src.ORIG/mclibs/herwig/code/hwhbgf.F src/mclibs/herwig/code/hwhbgf.F
--- src.ORIG/mclibs/herwig/code/hwhbgf.F	1996-12-03 23:16:54.000000000 +0900
+++ src/mclibs/herwig/code/hwhbgf.F	2005-05-31 02:34:40.000000000 +0900
@@ -39,6 +39,9 @@
 C
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,LEP,Y,Q2,SHAT,Z,PHI,AJACOB,DSIGMA,ME,MP,
      & ML,MREMIF(18),MFIN1(18),MFIN2(18),RS,SMA,W2,RSHAT,FSIGMA(18),
      & SIGSUM,PROB,PRAN,PVRT(4),X
@@ -58,7 +61,14 @@
         ELSEIF (IDHW(1).GE.127.AND.IDHW(1).LE.132) THEN
           LEP=-ONE
         ENDIF
+#if !defined(CERNLIB_GFORTRAN)
         IF (LEP.EQ.ZERO) CALL HWWARN('HWHBGF',500,*999)
+#else
+        if (LEP.EQ.ZERO) then
+          call hwwarn('HWHBGF',500,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IPROO=MOD(IPROC,100)/10
         IF (IPROO.EQ.0.OR.IPROO.EQ.4) THEN
           IQK=MOD(IPROC,10)
@@ -74,7 +84,12 @@
           IFL=0
           CHARGD=.FALSE.
         ELSE
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWHBGF',501,*999)
+#else
+          call hwwarn('HWHBGF',501,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
 C
         LEPFIN = IDHW(1)
@@ -194,7 +209,12 @@
           IDHW(NHEP+5)=164
           IDHW(NHEP+6)=13
         ELSE
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWHBGF',503,*999)
+#else
+          call hwwarn('HWHBGF',503,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
       ELSE
 C---Charged current event of specified flavours
@@ -207,9 +227,14 @@
       ENDIF
 C
       DO 1 I=NHEP+1,NHEP+6
+#if !defined(CERNLIB_GFORTRAN)
     1 IDHEP(I)=IDPDG(IDHW(I))
 C
 C---Codes common for all processes
+#else
+          IDHEP(I)=IDPDG(IDHW(I))
+    1 continue
+#endif
       ISTHEP(NHEP+1)=111
       ISTHEP(NHEP+2)=112
       ISTHEP(NHEP+3)=110
diff -uNr src.ORIG/mclibs/herwig/code/hwhbki.F src/mclibs/herwig/code/hwhbki.F
--- src.ORIG/mclibs/herwig/code/hwhbki.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhbki.F	2005-05-31 02:34:21.000000000 +0900
@@ -9,6 +9,9 @@
 C     jet evolution.
 C----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWUECM,HWUPCM,HWUSQR,LEP,Y,Q2,SHAT,Z,PHI,AJACOB,
      & DSIGMA,ME,MP,ML,MREMIF(18),MFIN1(18),MFIN2(18),RS,SMA,W2,RSHAT,
      & PGAMMA(5),SG,MF1,MF2,EP,PP,EL,PL,E1,E2,Q1,COSBET,SINBET,COSTHE,
@@ -47,15 +50,32 @@
       PP = PGAM
       A = (W2+Q2-MP**2)/TWO
       PPROT = (A*PGAM-EGAM*SQRT(A**2+MP**2*Q2))/Q2
+#if !defined(CERNLIB_GFORTRAN)
       IF (PPROT.LT.ZERO) CALL HWWARN('HWHBKI',101,*999)
+#else
+      if (PPROT.LT.ZERO) then
+          call hwwarn('HWHBKI',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       EPROT = SQRT(PPROT**2+MP**2)
+#if !defined(CERNLIB_GFORTRAN)
       IF ((EPROT+PPROT).LT.(EP+PP)) CALL HWWARN('HWHBKI',102,*999)
+#else
+      IF ((EPROT+PPROT).LT.(EP+PP)) call hwwarn('HWHBKI',102,iret)
+        if (iret .eq. 1) go to 999
+#endif
       EL = ( PGAM / PPROT * SMA - Q2 ) / TWO
      +     / (EGAM + PGAM / PPROT * EPROT)
       IF (EL.GT.ME) THEN
         PL = SQRT ( EL**2 - ME**2 )
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN ('HWHBKI',103,*999)
+#else
+        call hwwarn('HWHBKI',103,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
       COSBET = (TWO * EPROT * EL - SMA) / (TWO * PPROT * PL)
       IF ( ABS(COSBET) .GE. ONE ) THEN
@@ -66,7 +86,12 @@
       ENDIF
       SG = ME**2 + MPART**2 + Q2 + TWO * RSHAT * EL
       IF (SG.LE.(RSHAT+ML)**2 .OR. SG.GE.(RS-MREMIN)**2)
+#if !defined(CERNLIB_GFORTRAN)
      +    CALL HWWARN ('HWHBKI',104,*999)
+#else
+     +    call hwwarn('HWHBKI',104,iret)
+        if (iret .eq. 1) go to 999
+#endif
       Q1 = HWUPCM( RSHAT, MF1, MF2)
       E1 = SQRT(Q1**2+MF1**2)
       E2 = SQRT(Q1**2+MF2**2)
diff -uNr src.ORIG/mclibs/herwig/code/hwhbrn.F src/mclibs/herwig/code/hwhbrn.F
--- src.ORIG/mclibs/herwig/code/hwhbrn.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhbrn.F	2005-05-31 02:36:52.000000000 +0900
@@ -10,6 +10,9 @@
 C     to the cross-section
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRUNI,HWRGEN,HWUPCM,LEP,Y,Q2,SHAT,Z,PHI,AJACOB,
      & DSIGMA,ME,MP,ML,MREMIF(18),MFIN1(18),MFIN2(18),RS,SMA,W2,RSHAT,
      & MF1,MF2,YMIN,YMAX,YJAC,Q2INF,Q2SUP,Q2JAC,EMW2,ZMIN,ZMAX,ZJAC,
@@ -106,7 +109,12 @@
               EMMAF(I) = MIN(EMMAX,RS-ML-MREMIN)
               IF (EMMIF(I).GT.EMMAF(I)) THEN
                 INCLUD(I)=.FALSE.
+#if !defined(CERNLIB_GFORTRAN)
                 CALL HWWARN('HWHBRN',3,*999)
+#else
+                call hwwarn('HWHBRN',3,iret)
+        if (iret .eq. 1) go to 999
+#endif
                 GOTO 100
               ENDIF
               WMIF(I) = EMMIF(I)+MREMIF(I)
@@ -116,7 +124,12 @@
      +                         PINC*PLMAX)/SMA
               IF (YMIF(I).GT.YMAX) THEN
                 INCLUD(I)=.FALSE.
+#if !defined(CERNLIB_GFORTRAN)
                 CALL HWWARN('HWHBRN',4,*999)
+#else
+                call hwwarn('HWHBRN',4,iret)
+        if (iret .eq. 1) go to 999
+#endif
                 GOTO 100
               ENDIF
             ENDIF
@@ -168,7 +181,14 @@
 C   Approximation
    10     NTRY=0
    20     NTRY=NTRY+1
+#if !defined(CERNLIB_GFORTRAN)
           IF (NTRY.GT.NETRY) CALL HWWARN('HWHBRN',50,*10)
+#else
+          IF (NTRY.GT.NETRY) then
+            CALL HWWARN('HWHBRN',50,iret)
+            if (iret.eq.1) go to 10
+          endif
+#endif
           Y = (YMIN/YMAX)**HWRGEN(1)*YMAX
           IF (ONE+(ONE-Y)**2.LT.TWO*HWRGEN(2)) GOTO 20
           YJAC=(TWO*LOG(YMAX/YMIN)-TWO*(YMAX-YMIN)
diff -uNr src.ORIG/mclibs/herwig/code/hwhbsg.F src/mclibs/herwig/code/hwhbsg.F
--- src.ORIG/mclibs/herwig/code/hwhbsg.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhbsg.F	2005-05-31 02:34:21.000000000 +0900
@@ -8,6 +8,9 @@
 C     Scale for structure functions and alpha_s selected by BGSHAT
 C----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWUALF,HWUAEM,LEP,Y,Q2,SHAT,Z,PHI,AJACOB,DSIGMA,
      & ME,MP,ML,MREMIF(18),MFIN1(18),MFIN2(18),RS,SMA,W2,RSHAT,
      & SFUN(13),ALPHA,LDSIG,DLQ(7),SG,XG,MF1,MF2,MSUM,MDIF,MPRO,FFUN,
@@ -53,7 +56,14 @@
         IF (IFL.EQ.164) EMSCA=SQRT(-U)
       ENDIF
       ALPHAS = HWUALF(1,EMSCA)
+#if !defined(CERNLIB_GFORTRAN)
       IF (ALPHAS.GE.ONE.OR.ALPHAS.LE.ZERO) CALL HWWARN('HWHBSG',51,*888)
+#else
+      if (ALPHAS.GE.ONE.OR.ALPHAS.LE.ZERO) then
+          call hwwarn('HWHBSG',51,iret)
+          if (iret .eq. 1) go to 888
+        endif
+#endif
 C---structure functions
       ETA = (SHAT+Q2)/SMA/Y
       IF (ETA.GT.ONE) ETA=ONE
diff -uNr src.ORIG/mclibs/herwig/code/hwhdis.F src/mclibs/herwig/code/hwhdis.F
--- src.ORIG/mclibs/herwig/code/hwhdis.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhdis.F	2005-05-31 02:34:40.000000000 +0900
@@ -7,6 +7,9 @@
 C     DEEP INELASTIC LEPTON-HADRON SCATTERING: MEAN EVWGT = SIGMA IN NB
 C----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWRUNI,HWUPCM,PRAN,PROB,SAMP,SIG,Q2,
      & XBJ,Y,W,S,MLEP,MHAD,MLSCAT,LEP,YMIN,YMAX,XXMAX,Q2JAC,XXJAC,
      & JACOBI,A1,A2,A3,B1,B2,PCM,PCMEP,PCMLW,PCMEQ,PCMLQ,COSPHI,PA,
@@ -35,7 +38,12 @@
         ELSEIF (IDHW(1).GE.127.AND.IDHW(1).LE.132) THEN
           LEP=-ONE
         ELSE
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWHDIS',500,*999)
+#else
+          call hwwarn('HWHDIS',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
         DCHRG=FLOAT(MOD(IDHW(1)  ,2))
         DNEUT=FLOAT(MOD(IDHW(1)+1,2))
@@ -49,7 +57,12 @@
         IF (CHARGD) THEN
           IF ((EPOLN(3)-PPOLN(3)).EQ.1.) THEN
              WRITE(6,5)
+#if !defined(CERNLIB_GFORTRAN)
              CALL HWWARN('HWHDIS',501,*999)
+#else
+             call hwwarn('HWHDIS',501,iret)
+        if (iret .eq. 1) go to 999
+#endif
   5          FORMAT(1X,'WARNING: Cross-section is zero for the',
      &                ' specified lepton helicity')
           ENDIF
@@ -158,14 +171,24 @@
         PCMEQ=HWUPCM(SQRT(SHAT),MLEP,RMASS(IDN(2)))
         PCMLQ=HWUPCM(SQRT(SHAT),MLSCAT,RMASS(IDN(4)))
         IF (PCMLQ.LT.0.) THEN
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWHDIS',101,*999)
+#else
+          call hwwarn('HWHDIS',101,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ELSEIF (PCMLQ.EQ.0.) THEN
           COSTH=ZERO
         ELSE
           COSTH=(TWO*SQRT(PCMEQ**2+MLEP**2)*SQRT(PCMLQ**2+MLSCAT**2)
      &         -(Q2+MLEP**2+MLSCAT**2))/(TWO*PCMEQ*PCMLQ)
         ENDIF
+#if !defined(CERNLIB_GFORTRAN)
         IF (ABS(COSTH).GT.ONE) CALL HWWARN('HWHDIS',102,*999)
+#else
+        IF (ABS(COSTH).GT.ONE) call hwwarn('HWHDIS',102,iret)
+        if (iret .eq. 1) go to 999
+#endif
         IDCMF=15
         CALL HWETWO
       ELSE
@@ -237,8 +260,13 @@
         CALL HWSFUN(XBJ,EMSCA,IDHW(IHAD),NSTRU,DISF,2)
 C---SWITCH OFF ANY FLAVOURS THAT ARE BELOW THRESHOLD
         DO 90 I=1,12
+#if !defined(CERNLIB_GFORTRAN)
  90     IF (W.LT.2*RMASS(I)) DISF(I,1)=0
 C---EVALUATE DIFFERENTIAL CROSS SECTION
+#else
+           IF (W.LT.2*RMASS(I)) DISF(I,1)=0
+ 90     continue
+#endif
         IF (CHARGD) THEN
           PROP=RMASS(198)**2/(Q2+RMASS(198)**2)
           EFACT=FACT*(HWUAEM(-Q2)*PROP)**2/XBJ
diff -uNr src.ORIG/mclibs/herwig/code/hwhdyp.F src/mclibs/herwig/code/hwhdyp.F
--- src.ORIG/mclibs/herwig/code/hwhdyp.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhdyp.F	2005-05-31 04:20:14.000000000 +0900
@@ -10,6 +10,10 @@
 C     MEAN EVWGT = SIGMA IN NB
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+      double precision pthtst
+#endif
       DOUBLE PRECISION HWRGEN,HWRUNI,HWUAEM,EPS,C1,C2,C3,EMSQZ,EMGMZ,
      & EMSQZP,EMGMZP,CQF(7,6,16),QPOW,RPOW,A01,A1,A02,A2,A03,A3,CRAN,
      & EMJ1,EMJ2,EMJ3,EMJAC,FACT,QSQ,HCS,FACTR,RCS,EXTRA,PMAX,PTHETA
@@ -47,7 +51,12 @@
             JLMN=11
             JLMX=16
           ELSE
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWHDYP',500,*999)
+#else
+            call hwwarn('HWHDYP',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
           ENDIF
 C Set up parameters for importance sampling:
 C sum of power law and two Breit-Wigners (relative weights C1,C2,C3)
@@ -55,9 +64,30 @@
           C2=ONE
           C3=ZERO
           IF (ZPRIME) C3=ONE
+#if !defined(CERNLIB_GFORTRAN)
           IF (EMPOW.EQ.1) CALL HWWARN('HWHDYP',501,*999)
+#else
+          if (EMPOW.EQ.1) then
+          call hwwarn('HWHDYP',501,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
           IF (C2.EQ.0) CALL HWWARN('HWHDYP',502,*999)
+#else
+          if (C2.EQ.0) then
+          call hwwarn('HWHDYP',502,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
           IF (C3.EQ.0.AND.ZPRIME) CALL HWWARN('HWHDYP',503,*999)
+#else
+          if (C3.EQ.0.AND.ZPRIME) then
+          call hwwarn('HWHDYP',503,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           QPOW=-EMPOW+1
           RPOW=1/QPOW
           EMSQZ=RMASS(200)**2
@@ -123,6 +153,7 @@
   40    CONTINUE
   50    CONTINUE
       ENDIF
+C#if 0
 C
       HCS=0.
       DO 90 I=1,2
@@ -183,7 +214,15 @@
   100 COSTH=HWRUNI(0,-ONE,ONE)
       PTHETA=CQF(1,IQ,JF)*(1.+COSTH**2)+CQF(3,IQ,JF)*COSTH
      &      +EXTRA*(1.-COSTH)
+#if !defined(CERNLIB_GFORTRAN)
       IF (PTHETA.LT.PMAX*HWRGEN(1)) GOTO 100
+#else
+      pthtst = HWRGEN(1)
+      pthtst = pthtst * pmax
+      if (ptheta.lt.pthtst) then
+         goto 100
+      endif
+#endif
       IF (ID1.GT.ID2) COSTH=-COSTH
       IDCMF=200
       CALL HWETWO
diff -uNr src.ORIG/mclibs/herwig/code/hwhegg.F src/mclibs/herwig/code/hwhegg.F
--- src.ORIG/mclibs/herwig/code/hwhegg.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhegg.F	2005-05-31 02:34:21.000000000 +0900
@@ -11,6 +11,9 @@
 C     AND TIMES BRANCHING FRACTION IF WW
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWULDO,EMSQ,BETA,S,T,U,TMIN,TMAX,TRAT,
      & DSDT,PROB,X,Z(2),ZMIN,ZMAX,PCMIN,PCMAX,PCFAC,PLOGMI,PLOGMA,PTCMF,
      & Q,PC,BLOG,EMCMIN,EMCMAX,EMLMIN,EMLMAX,WGT(6),RWGT,CV,CA,BR,QT(2),
@@ -54,7 +57,12 @@
           NQ=1
           NADD=1
         ELSE
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWHEGG',200,*999)
+#else
+          call hwwarn('HWHEGG',200,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
 C-----SPLIT ELECTRONS TO PHOTONS
         NHEP=3
@@ -129,7 +137,14 @@
         JGAM=3-IGAM
 C-----CHOOSE ITS PT
  30     NTRY=NTRY+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NTRY.GT.NBTRY) CALL HWWARN('HWHEGG',100,*999)
+#else
+        if (NTRY.GT.NBTRY) then
+          call hwwarn('HWHEGG',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         QT(IGAM)=(PCM(IGAM)/PCF(IGAM))**HWRGEN(2)
         PROB=(QT(IGAM)**2/(QT(IGAM)**2+1))**2
         QT(IGAM)=QT(IGAM)*PCF(IGAM)
@@ -212,7 +227,14 @@
         IF (IHPRO.LE.9) THEN
 C-------FOR FFBAR, CHOOSE T ACCORDING TO -SHAT/T
  60       NTRY=NTRY+1
+#if !defined(CERNLIB_GFORTRAN)
           IF (NTRY.GT.NBTRY) CALL HWWARN('HWHEGG',101,*999)
+#else
+          if (NTRY.GT.NBTRY) then
+          call hwwarn('HWHEGG',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           T=TRAT**HWRGEN(3)*TMIN
           U=-T-SHAT
 C-------REWEIGHT TO CORRECT DISTRIBUTION
@@ -224,7 +246,14 @@
         ELSE
 C-------FOR WW, CHOOSE T ACCORDING TO (SHAT/T)**2
  70       NTRY=NTRY+1
+#if !defined(CERNLIB_GFORTRAN)
           IF (NTRY.GT.NBTRY) CALL HWWARN('HWHEGG',102,*999)
+#else
+          if (NTRY.GT.NBTRY) then
+          call hwwarn('HWHEGG',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           T=TMAX/(1-(1-TRAT)*HWRGEN(4))
           U=-T-SHAT
 C-------REWEIGHT TO CORRECT DISTRIBUTION
diff -uNr src.ORIG/mclibs/herwig/code/hwhegw.F src/mclibs/herwig/code/hwhegw.F
--- src.ORIG/mclibs/herwig/code/hwhegw.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhegw.F	2005-05-31 02:34:40.000000000 +0900
@@ -8,6 +8,9 @@
 C     BASED ON BOSON GLUON FUSION OF ABBIENDI AND STANCO
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,GMASS,EV(3),RV,LEP,Y,Q2,SHAT,Z,PHI,AJACOB,
      & DSIGMA,ME,MP,ML,MREMIF(18),MFIN1(18),MFIN2(18),RS,SMA,W2,RSHAT
       INTEGER LEPFIN,ID1,ID2,I,IQK,IFLAVU,IFLAVD,IMIN,IMAX,IFL,IPROO
@@ -28,8 +31,13 @@
         IDHW(8)=ID1
         IDHW(9)=ID2
         DO 1 I=4,9
+#if !defined(CERNLIB_GFORTRAN)
     1   IDHEP(I)=IDPDG(IDHW(I))
 C
+#else
+            IDHEP(I)=IDPDG(IDHW(I))
+    1   continue
+#endif
         IFLAVD=ID1
         IFLAVU=ID2-6
 C
@@ -118,11 +126,28 @@
         ELSEIF (IDHW(1).GE.127.AND.IDHW(1).LE.132) THEN
           LEP=-1.
         ENDIF
+#if !defined(CERNLIB_GFORTRAN)
         IF (LEP.EQ.0) CALL HWWARN('HWHEGW',500,*999)
+#else
+        if (LEP.EQ.0) then
+          call hwwarn('HWHEGW',500,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C---program only works if beam and target are charge conjugates
+#if !defined(CERNLIB_GFORTRAN)
         IF (LEP*(IDHW(2)-IDHW(1)).NE.6) CALL HWWARN('HWHEGW',501,*999)
+#else
+        IF (LEP*(IDHW(2)-IDHW(1)).NE.6) call hwwarn('HWHEGW',501,iret)
+        if (iret .eq. 1) go to 999
+#endif
 C---program only works for equal energy beams colliding
+#if !defined(CERNLIB_GFORTRAN)
         IF (PHEP(3,3).NE.0) CALL HWWARN('HWHEGW',503,*999)
+#else
+        IF (PHEP(3,3).NE.0) call hwwarn('HWHEGW',503,iret)
+        if (iret .eq. 1) go to 999
+#endif
 C
 C---FINAL STATE IS ALWAYS SET UP AS IF PARTICLE IS BEFORE ANTI-PARTICLE
 C   AND THEN INVERTED IF NECESSARY
@@ -148,7 +173,14 @@
           ID1  = 121
           ID2  = 128
 C---INTERFERENCE TERMS IN EE -> EE NUE NUEB  NEGLECTED: SIGMA UNRELIABLE
+#if !defined(CERNLIB_GFORTRAN)
           IF (FSTWGT) CALL HWWARN('HWHEGW',1,*999)
+#else
+          if (FSTWGT) then
+          call hwwarn('HWHEGW',1,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         ELSEIF (IQK.EQ.8) THEN
           IFLAVU=124
           IFLAVD=123
@@ -160,7 +192,12 @@
           ID1  = 125
           ID2  = 132
         ELSE
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWHEGW',504,*999)
+#else
+          call hwwarn('HWHEGW',504,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
         IF (IQK.GT.0) THEN
           IF (IQK.LE.6) IQK=0
diff -uNr src.ORIG/mclibs/herwig/code/hwhegx.F src/mclibs/herwig/code/hwhegx.F
--- src.ORIG/mclibs/herwig/code/hwhegx.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhegx.F	2005-05-31 02:34:40.000000000 +0900
@@ -110,8 +110,13 @@
 C---SUM ALL TENSOR CONTRIBUTIONS
       DO 10 I=1,4
       DO 10 J=1,4
+#if !defined(CERNLIB_GFORTRAN)
  10     DSIGMA=DSIGMA + C(I,J)*D(I,J)
 C---CALCULATE TOTAL SUMMED AND AVERAGED MATRIX ELEMENT SQUARED
+#else
+           DSIGMA=DSIGMA + C(I,J)*D(I,J)
+ 10     continue
+#endif
       DSIGMA = DSIGMA * 2*CFAC*(4*PIFAC*ALPHEM)**3/SWEIN**2
 C---CALCULATE DIFFERENTIAL CROSS-SECTION
       DSIGMA = DSIGMA * GEV2NB*PHOTON/(512*PIFAC**4*ETA*EMSSQ)
diff -uNr src.ORIG/mclibs/herwig/code/hwhepa.F src/mclibs/herwig/code/hwhepa.F
--- src.ORIG/mclibs/herwig/code/hwhepa.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhepa.F	2005-05-31 02:34:40.000000000 +0900
@@ -29,7 +29,12 @@
           IQ=MAXFL
    11     IQ1=MAPQ(IQ)
           DO 20 I=1,7
+#if !defined(CERNLIB_GFORTRAN)
    20     CLF(I)=CLQ(I,IQ)
+#else
+             CLF(I)=CLQ(I,IQ)
+   20     continue
+#endif
         ELSE
           IQ1=ID1
         ENDIF
diff -uNr src.ORIG/mclibs/herwig/code/hwhepg.F src/mclibs/herwig/code/hwhepg.F
--- src.ORIG/mclibs/herwig/code/hwhepg.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhepg.F	2005-05-31 02:34:40.000000000 +0900
@@ -11,6 +11,9 @@
 C     EVWGT=sig(e^-e^+ --> qqbar g) in nb
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWUALF,HWUAEM,HWULDO,HWDPWT,Q2NOW,Q2LST,
      & PHASP,QGMAX,QGMIN,FACTR,QM2,CLF(7),ORDER,PRAN,PQWT,QQG,QBG,SUM,
      & RUT,QQLM,QQLP,QBLM,QBLP,DYN1,DYN2,DYN3,DYN4,DYN5,DYN6,XQ2,X2SUM,
@@ -80,7 +83,14 @@
         IF (Q2NOW.NE.Q2LST) THEN
           Q2LST=Q2NOW
           PHASP=3.*THMAX-2.
+#if !defined(CERNLIB_GFORTRAN)
           IF (PHASP.LE.0.) CALL HWWARN('HWHEPG',400,*999)
+#else
+          if (PHASP.LE.0.) then
+          call hwwarn('HWHEPG',400,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           QGMAX=.5*Q2NOW*THMAX
           QGMIN=.5*Q2NOW*(1.-THMAX)
           FACTR=GEV2NB*FLOAT(NCOLO)*CFFAC*HWUALF(1,EMSCA)
@@ -114,7 +124,12 @@
           IQ=MAXFL
    11     IQ1=MAPQ(IQ)
           DO 20 I=1,7
+#if !defined(CERNLIB_GFORTRAN)
    20     CLF(I)=CLQ(I,IQ)
+#else
+             CLF(I)=CLQ(I,IQ)
+   20     continue
+#endif
         ELSEIF (Q2NOW.GT.4*QM2/(2*THMAX-1)) THEN
           IQ1=ID1
         ELSE
diff -uNr src.ORIG/mclibs/herwig/code/hwhew0.F src/mclibs/herwig/code/hwhew0.F
--- src.ORIG/mclibs/herwig/code/hwhew0.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhew0.F	2005-05-31 02:34:40.000000000 +0900
@@ -37,7 +37,12 @@
       PR(2,1)=PR(5,1)*SC*COS(F)
       PR(1,1)=PR(5,1)*SC*SIN(F)
       DO 7 I=1,3
+#if !defined(CERNLIB_GFORTRAN)
 7     PR(I,2)=-PR(I,1)
+#else
+          PR(I,2)=-PR(I,1)
+7     continue
+#endif
       G=0.
       IF(IP.EQ.1)G=(D-C)*LOG((D+CX)/(D-CR))
       IF(IP.EQ.2)G=(D*D-C*C)/D*LOG((D+1.D0)/(D-1.D0))
diff -uNr src.ORIG/mclibs/herwig/code/hwhew1.F src/mclibs/herwig/code/hwhew1.F
--- src.ORIG/mclibs/herwig/code/hwhew1.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhew1.F	2005-05-31 02:34:40.000000000 +0900
@@ -16,7 +16,12 @@
   10  CONTINUE
       DO 20 J=1,4
       DO 30 K=1,(NPART-2)
+#if !defined(CERNLIB_GFORTRAN)
   30  PCM(J,K)=P(J,K+2)
+#else
+         PCM(J,K)=P(J,K+2)
+  30  continue
+#endif
       PCM(J,NPART-1)=-P(J,1)
       PCM(J,NPART)=-P(J,2)
   20  CONTINUE
diff -uNr src.ORIG/mclibs/herwig/code/hwhew2.F src/mclibs/herwig/code/hwhew2.F
--- src.ORIG/mclibs/herwig/code/hwhew2.F	1996-12-03 23:16:55.000000000 +0900
+++ src/mclibs/herwig/code/hwhew2.F	2005-05-31 02:34:40.000000000 +0900
@@ -26,7 +26,12 @@
 C FOLLOWING DO LOOP IS TO CONVERT TO OUR STANDARD INDEXING
       DO 1 L=1,NPART
       DO 1 IJ=1,4
+#if !defined(CERNLIB_GFORTRAN)
 1     P(IJ,L)=PPCM(IJ,L)
+#else
+          P(IJ,L)=PPCM(IJ,L)
+1     continue
+#endif
       DO 2 II=1,7
       WRN(II)=ONE
       IF(P(4,II).LT.ZERO) WRN(II)=-ONE
@@ -83,6 +88,11 @@
       DO 60 J=IPP1,NPART
       H(I,J)=-H(J,I)
       CH(I,J)=-CH(J,I)
+#if !defined(CERNLIB_GFORTRAN)
    60 D(I,J)=D(J,I)
+#else
+         D(I,J)=D(J,I)
+   60 continue
+#endif
       RETURN
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwhew3.F src/mclibs/herwig/code/hwhew3.F
--- src.ORIG/mclibs/herwig/code/hwhew3.F	1996-12-03 23:16:56.000000000 +0900
+++ src/mclibs/herwig/code/hwhew3.F	2005-05-31 02:34:40.000000000 +0900
@@ -50,6 +50,11 @@
 C 1 LEPTON FLAVOR IF APPROPRIATE FOR NFINAL CHOICE
       RKW=0.25D0/XW**2
       DO 6 I=1,4
+#if !defined(CERNLIB_GFORTRAN)
 6     AMPWW(I)=AMP2*COLFAC(I)*RKW*RKW
+#else
+          AMPWW(I)=AMP2*COLFAC(I)*RKW*RKW
+6     continue
+#endif
       RETURN
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwheww.F src/mclibs/herwig/code/hwheww.F
--- src.ORIG/mclibs/herwig/code/hwheww.F	1996-12-03 23:16:56.000000000 +0900
+++ src/mclibs/herwig/code/hwheww.F	2005-05-31 02:34:40.000000000 +0900
@@ -7,6 +7,9 @@
 C     E+E- -> W+W-/Z0Z0 (BASED ON ZOLTAN KUNSZT'S PROGRAM)
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       COMPLEX ZH,ZCH,ZD
       DOUBLE PRECISION HWUAEM,HWRGEN,HWUPCM,ETOT,STOT,FLUXW,GAMM,GIMM,
      & WM2,WXMIN,WX1MAX,WX2MAX,FJAC1,FJAC2,WX1,WX2,WMM1,WMM2,XXM,W2BO,
@@ -108,9 +111,19 @@
  50           CONTINUE
  60         CONTINUE
             DO 70 I=1,12
+#if !defined(CERNLIB_GFORTRAN)
  70           BRZED(I)=BRZED(I)/BRTOT
+#else
+                 BRZED(I)=BRZED(I)/BRTOT
+ 70           continue
+#endif
           ELSE
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWHEWW',500,*999)
+#else
+            call hwwarn('HWHEWW',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
           ENDIF
           GAMM=WMASS*WWIDTH
           GIMM=1.D0/GAMM
diff -uNr src.ORIG/mclibs/herwig/code/hwhiga.F src/mclibs/herwig/code/hwhiga.F
--- src.ORIG/mclibs/herwig/code/hwhiga.F	1996-12-03 23:16:56.000000000 +0900
+++ src/mclibs/herwig/code/hwhiga.F	2005-05-31 02:38:38.000000000 +0900
@@ -10,6 +10,10 @@
 C     Only top loop included. A factor (alpha_s**3*alpha_W) is extracted
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+      double complex imag
+#endif
       DOUBLE COMPLEX HWHIGB,HWHIGC,HWHIGD,HWHIG5,HWHIG1,HWHIG2,BI(4),
      & CI(7),DI(3),EPSI,TAMP(7)
       DOUBLE PRECISION S,T,U,EMH2,WTQQ,WTQG,WTGQ,WTGG,EMW2,RNGLU,RNQRK,
@@ -42,7 +46,12 @@
 C Small mass approximation in loops
          NOMASS=.TRUE.
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
          CALL HWWARN('HWHIGA',500,*999)
+#else
+         call hwwarn('HWHIGA',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
 C Include only top quark contribution
       EMQ2=RMASS(6)**2
@@ -73,8 +82,13 @@
       TAMP(7)=HWHIG5(U,T,S,EMH2,EMQ2,3,0,6,0,0,0)
       DO 20 I=1,7
       TAMPI(I)= REAL(TAMP(I))
+#if !defined(CERNLIB_GFORTRAN)
   20  TAMPR(I)=-IMAG(TAMP(I))
 C Square and add prefactors
+#else
+         TAMPR(I)=-IMAG(TAMP(I))
+  20  continue
+#endif
       WTGG=0.03125*FLOAT(NCOLO*(NCOLO**2-1))
      &    *(TAMPR(1)**2+TAMPI(1)**2+TAMPR(2)**2+TAMPI(2)**2
      &     +TAMPR(3)**2+TAMPI(3)**2+TAMPR(4)**2+TAMPI(4)**2)*FLUXGG
diff -uNr src.ORIG/mclibs/herwig/code/hwhigb.F src/mclibs/herwig/code/hwhigb.F
--- src.ORIG/mclibs/herwig/code/hwhigb.F	1996-12-03 23:16:56.000000000 +0900
+++ src/mclibs/herwig/code/hwhigb.F	2005-05-31 04:38:33.000000000 +0900
@@ -2,7 +2,35 @@
 *CMZ :-        -23/08/94  13.22.29  by  Mike Seymour
 *-- Author :    Ulrich Baur & Nigel Glover, adapted by Ian Knowles
 C-----------------------------------------------------------------------
+#if !defined(CERNLIB_GFORTRAN)
       FUNCTION HWHIGB(NOMASS,S,T,EH2,EQ2)
+#else
+      FUNCTION HWHIGB(NOMASS,S,T,EH2,EQ2)
+      LOGICAL NOMASS
+      DOUBLE PRECISION S,T,EQ2,EH2
+      double complex hwhigb
+      hwhigb = hwhigsub(0,nomass,s,t,eth2,eq2)
+      return
+      end
+
+      FUNCTION HWHIGC(NOMASS,S,T,EH2,EQ2)
+      LOGICAL NOMASS
+      DOUBLE PRECISION S,T,EQ2,EH2
+      double complex hwhigc
+      hwhigc = hwhigsub(1,nomass,s,t,eth2,eq2)
+      return
+      end
+
+      FUNCTION HWHIGD(NOMASS,S,T,EH2,EQ2)
+      LOGICAL NOMASS
+      DOUBLE PRECISION S,T,EQ2,EH2
+      double complex hwhigd
+      hwhigd = hwhigsub(2,nomass,s,t,eth2,eq2)
+      return
+      end
+
+      FUNCTION HWHIGSUB(mode,NOMASS,S,T,EH2,EQ2)
+#endif
 C-----------------------------------------------------------------------
 C     One loop scalar integrals, used in HWHIGJ.
 C     If NOMASS=.TRUE. use a small mass approx. for particle in loop.
@@ -14,6 +42,15 @@
       LOGICAL NOMASS
       EXTERNAL HWULI2,HWUCI2
       COMMON/SMALL/EPSI
+#if defined(CERNLIB_GFORTRAN)
+      integer mode
+      double complex hwhigsub
+      if (mode .eq. 1) then
+         goto 1
+      else if (mode. eq. 2) then
+         goto 2
+      endif
+#endif
 C-----------------------------------------------------------------------
 C     B_0(2p1.p2=S;mq,mq)
 C-----------------------------------------------------------------------
@@ -34,9 +71,16 @@
      &                *(TWO*DLOG(DSQRT(RAT)+DSQRT(RAT-ONE))-PII)
          ENDIF
       ENDIF
+#if defined(CERNLIB_GFORTRAN)
+      hwhigsub = HWHIGB
+#endif
       RETURN
 C-----------------------------------------------------------------------
+#if !defined(CERNLIB_GFORTRAN)
       ENTRY HWHIGC(NOMASS,S,T,EH2,EQ2)
+#else
+ 1    continue
+#endif
 C-----------------------------------------------------------------------
 C     C_0(p{1,2}^2=0,2p1.p2=S;mq,mq,mq)
 C-----------------------------------------------------------------------
@@ -57,9 +101,16 @@
             HWHIGC=TWO*(COSH**2-PIFAC**2/FOUR-PII*COSH)/S
          ENDIF
       ENDIF
+#if defined(CERNLIB_GFORTRAN)
+      hwhigsub = HWHIGC
+#endif
       RETURN
 C-----------------------------------------------------------------------
+#if !defined(CERNLIB_GFORTRAN)
       ENTRY HWHIGD(NOMASS,S,T,EH2,EQ2)
+#else
+ 2    continue
+#endif
 C-----------------------------------------------------------------------
 C     D_0(p{1,2,3}^2=0,p4^2=EH2,2p1.p2=S,2p2.p3=T;mq,mq,mq,mq)
 C-----------------------------------------------------------------------
@@ -98,5 +149,8 @@
      &         *(LOG(EQ2+EPSI)-LOG(EQ2+EPSI-S*XP*XM)
      &          +LOG(EQ2+EPSI-EH2*XP*XM)-LOG(EQ2+EPSI-T*XP*XM)))
       ENDIF
+#if defined(CERNLIB_GFORTRAN)
+      hwhigsub = HWHIGD
+#endif
       RETURN
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwhigj.F src/mclibs/herwig/code/hwhigj.F
--- src.ORIG/mclibs/herwig/code/hwhigj.F	1996-12-03 23:16:56.000000000 +0900
+++ src/mclibs/herwig/code/hwhigj.F	2005-05-31 02:34:40.000000000 +0900
@@ -30,7 +30,12 @@
          IF (IDEC.EQ.0) THEN
             BR=0.
             DO 10 I=1,6
+#if !defined(CERNLIB_GFORTRAN)
   10        BR=BR+BRHIG(I)
+#else
+               BR=BR+BRHIG(I)
+  10        continue
+#endif
          ELSEIF (IDEC.EQ.10) THEN
             CALL HWDBOZ(198,ID1,ID2,CV,CA,BR,1)
             CALL HWDBOZ(199,ID1,ID2,CV,CA,BR,1)
diff -uNr src.ORIG/mclibs/herwig/code/hwhigm.F src/mclibs/herwig/code/hwhigm.F
--- src.ORIG/mclibs/herwig/code/hwhigm.F	1996-12-03 23:16:56.000000000 +0900
+++ src/mclibs/herwig/code/hwhigm.F	2005-05-31 02:34:21.000000000 +0900
@@ -23,6 +23,9 @@
 C     ENDIF
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRUNI,EM,WEIGHT,EMH,DIF,FUN,THETA,T,EMHLST,W0,
      & W1,EMM,GAMEM,T0,TMIN,TMAX,THEMIN,THEMAX,ZMIN,ZMAX,Z,F,GAMOFS
       INTEGER I
@@ -59,13 +62,25 @@
         F=0
  10     IF (I.LE.20 .AND. ABS(1-F/Z).GT.1E-4) THEN
           I=I+1
+#if !defined(CERNLIB_GFORTRAN)
           IF (2*ABS(THETA).GT.PIFAC) CALL HWWARN('HWHIGM',51,*999)
+#else
+          IF (2*ABS(THETA).GT.PIFAC) call hwwarn('HWHIGM',51,iret)
+        if (iret .eq. 1) go to 999
+#endif
           T=TAN(THETA)
           F=FUN(THETA,T,T0)
           THETA=THETA-(F-Z)/DIF(T,T0)
           GOTO 10
         ENDIF
+#if !defined(CERNLIB_GFORTRAN)
         IF (I.GT.20) CALL HWWARN('HWHIGM',1,*999)
+#else
+        if (I.GT.20) then
+          call hwwarn('HWHIGM',1,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       ELSE
         THETA=HWRUNI(0,THEMIN,THEMAX)
       ENDIF
@@ -88,6 +103,11 @@
         WEIGHT=W1*GAMOFS*EMM/GAMEM *((EM**2-EMH**2)**2 + GAMEM**2)
      &                             /((EM**2-EMH**2)**2 +(GAMOFS*EMM)**2)
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWHIGM',500,*999)
+#else
+        call hwwarn('HWHIGM',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
  999  END
diff -uNr src.ORIG/mclibs/herwig/code/hwhigs.F src/mclibs/herwig/code/hwhigs.F
--- src.ORIG/mclibs/herwig/code/hwhigs.F	1996-12-03 23:16:56.000000000 +0900
+++ src/mclibs/herwig/code/hwhigs.F	2005-05-31 02:34:40.000000000 +0900
@@ -17,7 +17,12 @@
         RWGT=HWRGEN(0)*EVSUM(13)
         IDN(1)=1
         DO 10 I=1,12
+#if !defined(CERNLIB_GFORTRAN)
  10       IF (RWGT.GT.EVSUM(I)) IDN(1)=I+1
+#else
+             IF (RWGT.GT.EVSUM(I)) IDN(1)=I+1
+ 10       continue
+#endif
         IDN(2)=13
         IF (IDN(1).LE.12) IDN(2)=IDN(1)-6
         IF (IDN(1).LE. 6) IDN(2)=IDN(1)+6
@@ -53,7 +58,12 @@
           IF (IDEC.EQ.0) THEN
             BRHIGQ=0
             DO 30 I=1,6
+#if !defined(CERNLIB_GFORTRAN)
  30           BRHIGQ=BRHIGQ+BRHIG(I)
+#else
+                 BRHIGQ=BRHIGQ+BRHIG(I)
+ 30           continue
+#endif
             BR=BRHIGQ
           ELSEIF (IDEC.EQ.10) THEN
             CALL HWDBOZ(198,ID1,ID2,CV,CA,BR,1)
diff -uNr src.ORIG/mclibs/herwig/code/hwhigw.F src/mclibs/herwig/code/hwhigw.F
--- src.ORIG/mclibs/herwig/code/hwhigw.F	1996-12-03 23:16:56.000000000 +0900
+++ src/mclibs/herwig/code/hwhigw.F	2005-05-31 02:34:40.000000000 +0900
@@ -145,7 +145,12 @@
         IF (IDEC.EQ.0) THEN
           BRHIGQ=0
           DO 20 I=1,6
+#if !defined(CERNLIB_GFORTRAN)
  20         BRHIGQ=BRHIGQ+BRHIG(I)
+#else
+               BRHIGQ=BRHIGQ+BRHIG(I)
+ 20         continue
+#endif
           WEIGHT=WEIGHT*BRHIGQ
         ENDIF
         IF (IDEC.EQ.10) THEN
@@ -297,7 +302,12 @@
               IDN(2)=2*HWRINT(1,4)-1
             ENDIF
             DO 62 I=1,2
+#if !defined(CERNLIB_GFORTRAN)
  62           IF (IDN(I).GE.5) IDN(I)=IDN(I)+2
+#else
+                 IF (IDN(I).GE.5) IDN(I)=IDN(I)+2
+ 62           continue
+#endif
             PROB=DISF(IDN(1),1)*DISF(IDN(2),2)*AZZ(2)/PZZ(2)
             IF (HWRGEN(0).GT.PROB) GOTO 61
             IDN(3)=IDN(1)
diff -uNr src.ORIG/mclibs/herwig/code/hwhigz.F src/mclibs/herwig/code/hwhigz.F
--- src.ORIG/mclibs/herwig/code/hwhigz.F	1996-12-03 23:16:56.000000000 +0900
+++ src/mclibs/herwig/code/hwhigz.F	2005-05-31 02:34:40.000000000 +0900
@@ -11,6 +11,9 @@
 C     MEAN EVWGT = CROSS-SECTION (IN NB) * HIGGS BRANCHING FRACTION
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWUAEM,HWHIGY,HWRUNI,HWRGEN,HWULDO,EMZ,CVE,CAE,
      & POL1,POL2,CE1,CE2,CE3,PMAX,EMZ2,S,B,FACTR,EMH,EMFAC,EMH2,A,XP,
      & CV,CA,BRHIGQ,BR,X1,X2,FAC1,FAC2,XPP,XPPSQ,COEF,X,XSQ,PROB,C1,C2,
@@ -59,7 +62,12 @@
         IF (IDEC.EQ.0) THEN
           BRHIGQ=0
           DO 10 I=1,6
+#if !defined(CERNLIB_GFORTRAN)
  10         BRHIGQ=BRHIGQ+BRHIG(I)
+#else
+               BRHIGQ=BRHIGQ+BRHIG(I)
+ 10         continue
+#endif
           EVWGT=EVWGT*BRHIGQ
         ENDIF
 C Add Z branching fractions
@@ -94,13 +102,25 @@
         NLOOP=0
         COEF=1./((12+2*A-12*XPP+XPPSQ)*SQRT(XPPSQ-A))
  20       NLOOP=NLOOP+1
+#if !defined(CERNLIB_GFORTRAN)
           IF (NLOOP.GT.NBTRY) CALL HWWARN('HWHIGZ',101,*999)
+#else
+          if (NLOOP.GT.NBTRY) then
+          call hwwarn('HWHIGZ',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           X=XP+B*TAN(HWRUNI(1,FAC1,FAC2))
           XSQ=X**2
           PROB=COEF*((12+2*A-12*X+XSQ)*SQRT(XSQ-A))
           IF (PROB.GT.PMAX) THEN
             PMAX=1.1*PROB
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWHIGZ',1,*999)
+#else
+            call hwwarn('HWHIGZ',1,iret)
+        if (iret .eq. 1) go to 999
+#endif
             WRITE (6,21) PMAX
  21         FORMAT(7X,'NEW HWHIGZ MAX WEIGHT =',F8.4)
           ENDIF
@@ -114,7 +134,14 @@
         NLOOP=0
         COEF=(XSQ-A)/(8.*(1.-X)+XSQ+A)
  30       NLOOP=NLOOP+1
+#if !defined(CERNLIB_GFORTRAN)
           IF (NLOOP.GT.NBTRY) CALL HWWARN('HWHIGZ',102,*999)
+#else
+          if (NLOOP.GT.NBTRY) then
+          call hwwarn('HWHIGZ',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           CHIGG=HWRUNI(2,-ONE, ONE)
           PTHETA=1-COEF*CHIGG**2
         IF (PTHETA.LT.HWRGEN(1)) GOTO 30
@@ -150,7 +177,14 @@
         PHEP(5,IFER)=0
         PHEP(5,IANT)=0
  50     NLOOP=NLOOP+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NLOOP.GT.NBTRY) CALL HWWARN('HWHIGZ',103,*999)
+#else
+        if (NLOOP.GT.NBTRY) then
+          call hwwarn('HWHIGZ',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         CALL HWDTWO(PHEP(1,IZED),PHEP(1,IFER),PHEP(1,IANT),
      &              PCM,TWO,.TRUE.)
         PROB=C1*(PHEP(4,IFER)*PHEP(4,IANT)-PHEP(3,IFER)*PHEP(3,IANT))
diff -uNr src.ORIG/mclibs/herwig/code/hwhph2.F src/mclibs/herwig/code/hwhph2.F
--- src.ORIG/mclibs/herwig/code/hwhph2.F	1996-12-03 23:16:57.000000000 +0900
+++ src/mclibs/herwig/code/hwhph2.F	2005-05-31 02:34:40.000000000 +0900
@@ -47,7 +47,12 @@
         IF (DISF(13,1).GT.EPS.AND.DISF(13,2).GT.EPS) THEN
            TQSQ=0.
            DO 10 ID=1,6
+#if !defined(CERNLIB_GFORTRAN)
   10       IF (RMASS(ID).LT.RS) TQSQ=TQSQ+QFCH(ID)**2
+#else
+              IF (RMASS(ID).LT.RS) TQSQ=TQSQ+QFCH(ID)**2
+  10       continue
+#endif
            DSTU=DISF(13,1)*DISF(13,2)*FACT*HWHPPB(S,T,U)
      &         /64.*(HWUALF(1,EMSCA)*TQSQ/PIFAC)**2
         ENDIF
diff -uNr src.ORIG/mclibs/herwig/code/hwhpho.F src/mclibs/herwig/code/hwhpho.F
--- src.ORIG/mclibs/herwig/code/hwhpho.F	1996-12-03 23:16:57.000000000 +0900
+++ src/mclibs/herwig/code/hwhpho.F	2005-05-31 02:34:40.000000000 +0900
@@ -53,7 +53,12 @@
         IF (DISF(13,1).GT.EPS.AND.DISF(13,2).GT.EPS) THEN
            TQCH=0.
            DO 10 ID=1,6
+#if !defined(CERNLIB_GFORTRAN)
   10       IF (RMASS(ID).LT.RS) TQCH=TQCH+QFCH(ID)
+#else
+              IF (RMASS(ID).LT.RS) TQCH=TQCH+QFCH(ID)
+  10       continue
+#endif
            DSTU=DISF(13,1)*DISF(13,2)*FACT*HWHPPB(S,T,U)
      &         *5./768.*(HWUALF(1,EMSCA)*TQCH/PIFAC)**2
         ENDIF
diff -uNr src.ORIG/mclibs/herwig/code/hwhppm.F src/mclibs/herwig/code/hwhppm.F
--- src.ORIG/mclibs/herwig/code/hwhppm.F	1996-12-03 23:16:57.000000000 +0900
+++ src/mclibs/herwig/code/hwhppm.F	2005-05-31 02:34:40.000000000 +0900
@@ -73,7 +73,12 @@
          CALL HWSFUN(XX(2),EMSCA,IDHW(IHAD2),NSTRU,DISF(1,2),2)
          DO 10 I=1,3
          DO 10 J=1,3
+#if !defined(CERNLIB_GFORTRAN)
  10      DELT(I,J)=(QFCH(I)*U+QFCH(J)*S)**2
+#else
+            DELT(I,J)=(QFCH(I)*U+QFCH(J)*S)**2
+ 10      continue
+#endif
          C1STU=-(S**2+U**2)/(T*S**2*U**2)
          C3STU=-8.D0*T/(S**2*U**2)
       ENDIF
diff -uNr src.ORIG/mclibs/herwig/code/hwhqcd.F src/mclibs/herwig/code/hwhqcd.F
--- src.ORIG/mclibs/herwig/code/hwhqcd.F	1996-12-03 23:16:57.000000000 +0900
+++ src/mclibs/herwig/code/hwhqcd.F	2005-05-31 02:34:21.000000000 +0900
@@ -7,6 +7,9 @@
 C     QCD HARD 2->2 PROCESSES: MEAN EVWGT = SIGMA IN NB
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWRUNI,HWUALF,RS,EPS,HF,RCS,Z1,Z2,ET,EJ,
      & FACTR,S,T,U,ST,TU,US,STU,TUS,UST,EN,RN,GFLA,AF,ASTU,ASUT,AUST,
      & BF,BSTU,BSUT,BUST,BUTS,CF,CSTU,CSUT,CTSU,CTUS,DF,DSTU,DTSU,DUTS,
@@ -43,7 +46,14 @@
     3   CONTINUE
         I=NFLAV+1
     4   MAXFL=I-1
+#if !defined(CERNLIB_GFORTRAN)
         IF (MAXFL.EQ.0) CALL HWWARN('HWHQCD',100,*999)
+#else
+        if (MAXFL.EQ.0) then
+          call hwwarn('HWHQCD',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C
         T=-HF*S*(1.-COSTH)
         U=-S-T
diff -uNr src.ORIG/mclibs/herwig/code/hwhrem.F src/mclibs/herwig/code/hwhrem.F
--- src.ORIG/mclibs/herwig/code/hwhrem.F	1996-12-03 23:16:57.000000000 +0900
+++ src/mclibs/herwig/code/hwhrem.F	2005-05-31 02:34:21.000000000 +0900
@@ -8,6 +8,9 @@
 C     AND BREAK THEIR COLOUR CONNECTION IF NECESSARY
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION PCL(5)
       INTEGER IBEAM,ITARG,IHEP,NTEMP,I,ICOL,IANT
       LOGICAL LTEMP,T,COL,ANT
@@ -19,15 +22,43 @@
       ITARG=0
       DO 10 IHEP=1,NHEP
         IF (ISTHEP(IHEP).EQ.148) THEN
+#if !defined(CERNLIB_GFORTRAN)
           IF (ITARG.NE.0) CALL HWWARN('HWHREM',100,*999)
+#else
+          if (ITARG.NE.0) then
+          call hwwarn('HWHREM',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           ITARG=IHEP
         ELSEIF (ISTHEP(IHEP).EQ.147) THEN
+#if !defined(CERNLIB_GFORTRAN)
           IF (IBEAM.NE.0) CALL HWWARN('HWHREM',101,*999)
+#else
+          if (IBEAM.NE.0) then
+          call hwwarn('HWHREM',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           IBEAM=IHEP
         ENDIF
   10  CONTINUE
+#if !defined(CERNLIB_GFORTRAN)
       IF (ITARG.EQ.0) CALL HWWARN('HWHREM',102,*999)
+#else
+      if (ITARG.EQ.0) then
+          call hwwarn('HWHREM',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
       IF (IBEAM.EQ.0) CALL HWWARN('HWHREM',103,*999)
+#else
+      if (IBEAM.EQ.0) then
+          call hwwarn('HWHREM',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C---IF THEY ARE COLOUR CONNECTED, DISCONNECT THEM BY EMITTING A SOFT
 C   GLUON AND SPLITTING THAT GLUON TO LIGHT QUARKS
 C  (WHICH NORMALLY GETS DONE AS THE FIRST STAGE OF CLUSTER FORMATION)
diff -uNr src.ORIG/mclibs/herwig/code/hwhsct.F src/mclibs/herwig/code/hwhsct.F
--- src.ORIG/mclibs/herwig/code/hwhsct.F	1996-12-03 23:16:57.000000000 +0900
+++ src/mclibs/herwig/code/hwhsct.F	2005-05-31 02:34:21.000000000 +0900
@@ -15,6 +15,9 @@
 C     5 = COMPLETELY FAILED (IERROR IS ALSO NON-ZERO TO CANCEL EVENT)
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,TMPWGT,PBOOST(5),RBOOST(3,3)
       INTEGER IHEP,IBM,ITG,IBMN,ITGN,IBMT,ITGT,I,REPORT
       LOGICAL COL
@@ -169,7 +172,12 @@
 C---LOOK FOR COLOUR SINGLET GLUONS (A RARE BUT ANNOYING SPECIAL CASE)
       DO 20 IHEP=1,NHEP
         IF (IDHW(IHEP).EQ.13.AND.JMOHEP(2,IHEP).EQ.IHEP)
+#if !defined(CERNLIB_GFORTRAN)
      $       CALL HWWARN('HWHSCT',120,*999)
+#else
+     $       call hwwarn('HWHSCT',120,iret)
+        if (iret .eq. 1) go to 999
+#endif
  20   CONTINUE
       REPORT=0
  999  END
diff -uNr src.ORIG/mclibs/herwig/code/hwhv1j.F src/mclibs/herwig/code/hwhv1j.F
--- src.ORIG/mclibs/herwig/code/hwhv1j.F	1996-12-03 23:16:57.000000000 +0900
+++ src/mclibs/herwig/code/hwhv1j.F	2005-05-31 02:34:40.000000000 +0900
@@ -31,7 +31,12 @@
         DO 110 I=1,2
         DO 110 J=1,12
         DO 110 K=1,2
+#if !defined(CERNLIB_GFORTRAN)
  110      DISMAX=MAX(DISFAC(K,J,I),DISMAX)
+#else
+            DISMAX=MAX(DISFAC(K,J,I),DISMAX)
+ 110      continue
+#endif
  120    I=HWRINT(1,2)
         J=HWRINT(1,12)
         K=HWRINT(1,2)
@@ -73,7 +78,12 @@
         M=K
         IF (I.EQ.2.AND.J.LE.6) M=3-K
         DO 130 L=1,4
+#if !defined(CERNLIB_GFORTRAN)
  130      ICO(L)=ICOFLO(L,M)
+#else
+            ICO(L)=ICOFLO(L,M)
+ 130      continue
+#endif
         IDCMF=15
         COSTH=(SHAT+2*THAT-EMV2)/(SHAT-EMV2)
 C---TRICK HWETWO INTO USING THE OFF-SHELL V MASS
@@ -176,7 +186,12 @@
         DO 230 I=1,2
         DO 230 J=1,12
         DO 230 K=1,2
+#if !defined(CERNLIB_GFORTRAN)
  230      EVWGT=EVWGT+DISFAC(K,J,I)
+#else
+            EVWGT=EVWGT+DISFAC(K,J,I)
+ 230      continue
+#endif
         CSFAC=-PT*S/(XX(1)*S+U-EMV2)*EJ
      &        *(YMAX-YMIN)*XLMIN*XX(1)
 C---INCLUDE BRANCHING RATIO OF V
diff -uNr src.ORIG/mclibs/herwig/code/hwhwex.F src/mclibs/herwig/code/hwhwex.F
--- src.ORIG/mclibs/herwig/code/hwhwex.F	1996-12-03 23:16:57.000000000 +0900
+++ src/mclibs/herwig/code/hwhwex.F	2005-05-31 02:34:21.000000000 +0900
@@ -12,6 +12,9 @@
 C   (1-8) ARE WITH B FROM BEAM 1, (9-16) ARE WITH B FROM BEAM 2.
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWRUNI,DSDCOS(16),EMT2,EMT,EMW2,EMW,
      & CMFMIN,TAUMIN,TAUMLN,S,T,U,ROOTS,DSMAX
       INTEGER HWRINT,IDHWEX(2,16),I
@@ -65,7 +68,12 @@
 C---IF USER SPECIFIED SUB-PROCESS THEN ZERO ALL THE OTHERS
         IHPRO=MOD(IPROC,100)
         IF (IHPRO.GT.8) THEN
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWHWEX',1,*999)
+#else
+          call hwwarn('HWHWEX',1,iret)
+        if (iret .eq. 1) go to 999
+#endif
           IHPRO=0
         ENDIF
         DO 100 I=1,8
diff -uNr src.ORIG/mclibs/herwig/code/hwigin.F src/mclibs/herwig/code/hwigin.F
--- src.ORIG/mclibs/herwig/code/hwigin.F	1996-12-03 23:16:57.000000000 +0900
+++ src/mclibs/herwig/code/hwigin.F	2005-05-31 02:34:40.000000000 +0900
@@ -91,6 +91,7 @@
 C Note require POLN(1)**2+POLN(2)**2+POLN(3)**2 < 1.
       DO 20 I=1,3
       EPOLN(I)=0.
+#if !defined(CERNLIB_GFORTRAN)
   20  PPOLN(I)=0.
 C-----------------------------------------------------------------------
 C     Specify couplings of weak vector bosons to fermions:
@@ -108,6 +109,10 @@
 C Minimal standard model neutral vector boson couplings
 C VFCH(I,1)=(T3/2-Q*S^2_W)/(C_W*S_W);  AFCH(I,1)=T3/(2*C_W*S_W)
 C sin**2 Weinberg angle (PDG '94)
+#else
+         PPOLN(I)=0.
+  20  continue
+#endif
       SWEIN=.2319
       FAC=1./SQRT(SWEIN*(1.-SWEIN))
       DO 30 I=1,3
@@ -160,6 +165,7 @@
       DO 50 I=1,12
       BRHIG(I)=1.D0/12
       ENHANC(I)=1.D0
+#if !defined(CERNLIB_GFORTRAN)
  50   IF (I.LE.MODMAX) MODBOS(I)=0
 C
 C THE iTH GAUGE BOSON DECAY PER EVENT IS CONTROLLED BY MODBOS AS FOLLOWS
@@ -176,6 +182,10 @@
 C BOSON PAIRS (eg FROM HIGGS DECAY) ARE CHOSEN FROM MODBOS(i),MODBOS(i+1
 C
 C---CONTROL OF LARGE EMH BEHAVIOUR (SEE HWHIGM FOR DETAILS)
+#else
+         IF (I.LE.MODMAX) MODBOS(I)=0
+ 50   continue
+#endif
       IOPHIG=3
       GAMMAX=10.
 C Specicify approximation used in HWHIGA
@@ -322,8 +332,13 @@
 C   Veto cluster decays into particle type I
       VTOCDK(I)=.FALSE.
 C   Veto unstable particle decays into modes involving particle type I
+#if !defined(CERNLIB_GFORTRAN)
   60  VTORDK(I)=.FALSE.
 C---MINIMUM AND MAXIMUM S-HAT/S RANGE FOR PHOTON ISR
+#else
+         VTORDK(I)=.FALSE.
+  60  continue
+#endif
       TMNISR=1D-4
       ZMXISR=1-1D-6
 C---COLISR IS .TRUE. TO MAKE ISR PHOTONS COLLINEAR WITH BEAMS
@@ -333,8 +348,13 @@
       DO 70 N=0,4
       DO 70 J=0,4
       DO 70 L=0,3
+#if !defined(CERNLIB_GFORTRAN)
   70  REPWT(L,J,N)=1.
 C and singlet (Lambda-like) and decuplet barons
+#else
+         REPWT(L,J,N)=1.
+  70  continue
+#endif
       SNGWT=1.
       DECWT=1.
 C---A PRIORI WEIGHTS FOR D,U,S,C,B,T QUARKS AND DIQUARKS (IN THAT ORDER)
diff -uNr src.ORIG/mclibs/herwig/code/hwiodk.F src/mclibs/herwig/code/hwiodk.F
--- src.ORIG/mclibs/herwig/code/hwiodk.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwiodk.F	2005-05-31 02:34:40.000000000 +0900
@@ -12,6 +12,9 @@
 C                             0                            are set zero.
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER IUNIT,IOPT,IME,JUNIT,I,J,K,L,IDKY,ITMP(5),IDUM
       CHARACTER*8 CDK(NMXDKS),CDKPRD(5,NMXDKS),CDUM
       JUNIT=ABS(IUNIT)
@@ -26,7 +29,12 @@
           DO 10 J=1,NMODES(I)
           WRITE(JUNIT,110) IDPDG(I),BRFRAC(K),NME(K),
      &                    (IDPDG(IDKPRD(L,K)),L=1,5)
+#if !defined(CERNLIB_GFORTRAN)
   10      K=LNEXT(K)
+#else
+             K=LNEXT(K)
+  10      continue
+#endif
   20      CONTINUE
         ELSEIF (IOPT.EQ.2) THEN
           DO 40 I=1,NRES
@@ -34,7 +42,12 @@
           K=LSTRT(I)
           DO 30 J=1,NMODES(I)
           WRITE(JUNIT,120) I,BRFRAC(K),NME(K),(IDKPRD(L,K),L=1,5)
+#if !defined(CERNLIB_GFORTRAN)
   30      K=LNEXT(K)
+#else
+             K=LNEXT(K)
+  30      continue
+#endif
   40      CONTINUE
         ELSEIF (IOPT.EQ.3) THEN
           DO 60 I=1,NRES
@@ -43,34 +56,66 @@
           DO 50 J=1,NMODES(I)
           WRITE(JUNIT,130) RNAME(I),BRFRAC(K),NME(K),
      &                    (RNAME(IDKPRD(L,K)),L=1,5)
+#if !defined(CERNLIB_GFORTRAN)
   50      K=LNEXT(K)
+#else
+             K=LNEXT(K)
+  50      continue
+#endif
   60      CONTINUE
         ENDIF
       ELSEIF (IUNIT.LT.0) THEN
 C Read in the decay table and convert to HERWIG numeric format
         READ(JUNIT,100) NDKYS
+#if !defined(CERNLIB_GFORTRAN)
         IF (NDKYS.GT.NMXDKS) CALL HWWARN('HWIODK',100,*999)
+#else
+        if (NDKYS.GT.NMXDKS) then
+          call hwwarn('HWIODK',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IF (IOPT.EQ.1) THEN
           DO 70 I=1,NDKYS
           READ(JUNIT,110) IDKY,BRFRAC(I),NME(I),ITMP
           IF (IME.EQ.0.AND.NME(I).GE.100) NME(I)=0
           CALL HWUIDT(1,IDKY,IDK(I),CDUM)
           DO 70 J=1,5
+#if !defined(CERNLIB_GFORTRAN)
   70      CALL HWUIDT(1,ITMP(J),IDKPRD(J,I),CDUM)
+#else
+             CALL HWUIDT(1,ITMP(J),IDKPRD(J,I),CDUM)
+  70      continue
+#endif
         ELSEIF (IOPT.EQ.2) THEN
           DO 80 I=1,NDKYS
           READ(JUNIT,120) IDK(I),BRFRAC(I),NME(I),(IDKPRD(J,I),J=1,5)
           IF (IDK(I).LT.0.OR.IDK(I).GT.NRES) IDK(I)=20
+#if !defined(CERNLIB_GFORTRAN)
   80      IF (IME.EQ.0.AND.NME(I).GE.100) NME(I)=0
+#else
+             IF (IME.EQ.0.AND.NME(I).GE.100) NME(I)=0
+  80      continue
+#endif
         ELSEIF (IOPT.EQ.3) THEN
           DO 90 I=1,NDKYS
           READ(JUNIT,130) CDK(I),BRFRAC(I),NME(I),(CDKPRD(J,I),J=1,5)
           IF (IME.EQ.0.AND.NME(I).GE.100) NME(I)=0
           CALL HWUIDT(3,IDUM,IDK(I),CDK(I))
           DO 90 J=1,5
+#if !defined(CERNLIB_GFORTRAN)
   90      CALL HWUIDT(3,IDUM,IDKPRD(J,I),CDKPRD(J,I))
+#else
+             CALL HWUIDT(3,IDUM,IDKPRD(J,I),CDKPRD(J,I))
+  90      continue
+#endif
         ELSE
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWIODK',101,*999)
+#else
+          call hwwarn('HWIODK',101,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
       ENDIF
       CLOSE(UNIT=JUNIT)
diff -uNr src.ORIG/mclibs/herwig/code/hwmevt.F src/mclibs/herwig/code/hwmevt.F
--- src.ORIG/mclibs/herwig/code/hwmevt.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwmevt.F	2005-05-31 02:34:40.000000000 +0900
@@ -9,6 +9,9 @@
 C     SUPPRESSED BY ADDING 10000 TO IPROC
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWREXP,ENFAC,TECM,SECM,SUMM,EMCL,BMP(5),BMR(3,3)
       INTEGER HWRINT,NETC,IBT,IDBT,ID1,ID2,ID3,KHEP,LHEP,NTRY,ICMS,
      & NPPBAR,NCL,MCHT,JCL,JD1,JD2,JD3,ICH,MODC,NCHT,INHEP(2),
@@ -45,7 +48,12 @@
           INID(1,IBT)=HWRINT(1,2)
           INID(2,IBT)=HWRINT(7,8)
         ELSE
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWMEVT',100,*999)
+#else
+          call hwwarn('HWMEVT',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ENDIF
         NETC=NETC+ICHRG(IDBT)
      &    -(ICHRG(INID(1,IBT))+ICHRG(INID(2,IBT)))/3
@@ -69,7 +77,12 @@
         JBT=IBT
         IF (JDAHEP(1,IBT).NE.0) JBT=JDAHEP(1,IBT)
         CALL HWVEQU(5,PHEP(1,JBT),PHEP(1,NHEP))
+#if !defined(CERNLIB_GFORTRAN)
    12   INHEP(IBT)=NHEP
+#else
+           INHEP(IBT)=NHEP
+   12   continue
+#endif
       ELSE
 C---FIND BEAM AND TARGET CLUSTERS
         DO 20 IBT=1,2
@@ -88,7 +101,14 @@
 C---TEST FOR BOTH FOUND
         IF (INHEP(1).EQ.0) JCL=INHEP(2)
         IF (INHEP(2).EQ.0) JCL=INHEP(1)
+#if !defined(CERNLIB_GFORTRAN)
         IF (JCL.EQ.0) CALL HWWARN('HWMEVT',101,*999)
+#else
+        if (JCL.EQ.0) then
+          call hwwarn('HWMEVT',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IF (JCL.GT.0) THEN
           ISTHEP(JCL)=163
           CALL HWCFOR
@@ -103,7 +123,14 @@
 C---FIND SOFT CM MOMENTUM AND MULTIPLICITY
       NTRY=0
       NHEP=NHEP+1
+#if !defined(CERNLIB_GFORTRAN)
       IF (NHEP.GT.NMXHEP) CALL HWWARN('HWMEVT',102,*999)
+#else
+      if (NHEP.GT.NMXHEP) then
+          call hwwarn('HWMEVT',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       ICMS=NHEP
       IDHW(NHEP)=16
       IDHEP(NHEP)=0
@@ -127,7 +154,14 @@
 C---CREATE CLUSTERS
    35 NCL=NCL+1
       NHEP=NHEP+1
+#if !defined(CERNLIB_GFORTRAN)
       IF (NHEP.GT.NMXHEP) CALL HWWARN('HWMEVT',103,*999)
+#else
+      if (NHEP.GT.NMXHEP) then
+          call hwwarn('HWMEVT',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       JCL=NHEP
       IDHW(JCL)=19
       IDHEP(JCL)=91
diff -uNr src.ORIG/mclibs/herwig/code/hwmlps.F src/mclibs/herwig/code/hwmlps.F
--- src.ORIG/mclibs/herwig/code/hwmlps.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwmlps.F	2005-05-31 02:34:40.000000000 +0900
@@ -8,6 +8,9 @@
 C     RETURNS NCL=0 IF UNSUCCESSFUL
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWREXT,HWRUNG,HWUSQR,TECM,ESS,ALOGS,EPS,SUMX,
      & SUMY,PT,PX,PY,PT2,SUMPT2,SUMTM,XIMIN,XIMAX,YY,SUM1,SUM2,SUM3,
      & SUM4,EX,FY,DD,DYY,ZZ,E1,TM,SLOP(11),XI(NMXPAR)
@@ -20,7 +23,12 @@
       DATA SLOP/5.2,5.2,5.2,3.0,5.2,5.2,5.2,5.2,5.2,5.2,3.0/
 C                -   d   u   s   uu  ud  dd  us  ds  ss  c
       IF (NCL.GT.NMXPAR) THEN
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWMLPS',1,*999)
+#else
+        call hwwarn('HWMLPS',1,iret)
+        if (iret .eq. 1) go to 999
+#endif
         NCL=NMXPAR
       ENDIF
       ESS=TECM**2
@@ -42,7 +50,12 @@
       PPAR(1,I)=PX
       PPAR(2,I)=PY
       SUMX=SUMX+PPAR(1,I)
+#if !defined(CERNLIB_GFORTRAN)
   12  SUMY=SUMY+PPAR(2,I)
+#else
+         SUMY=SUMY+PPAR(2,I)
+  12  continue
+#endif
       SUMX=SUMX/NCL
       SUMY=SUMY/NCL
       SUMPT2=0.
@@ -54,7 +67,12 @@
       SUMPT2=SUMPT2+PT2
 C---STORE TRANSVERSE MASS IN PPAR(3,I) TEMPORARILY
       PPAR(3,I)=SQRT(PT2+PPAR(5,I)**2)
+#if !defined(CERNLIB_GFORTRAN)
   13  SUMTM=SUMTM+PPAR(3,I)
+#else
+         SUMTM=SUMTM+PPAR(3,I)
+  13  continue
+#endif
       IF (SUMTM.GT.TECM) GOTO 11
       DO 14 I=1,NCL
 C---Form of "reduced rapidity" distribution
@@ -81,17 +99,39 @@
       SUM1=SUM1+(TM*EX)
       SUM2=SUM2+(TM/EX)
       SUM3=SUM3+(TM*EX)*XI(I)
+#if !defined(CERNLIB_GFORTRAN)
   19  SUM4=SUM4+(TM/EX)*XI(I)
+#else
+         SUM4=SUM4+(TM/EX)*XI(I)
+  19  continue
+#endif
       FY=ALOGS-LOG(SUM1*SUM2)
       DD=(SUM3*SUM2-SUM1*SUM4)/(SUM1*SUM2)
       DYY=FY/DD
       IF(ABS(DYY/YY).LT.EPS) GOTO 20
+#if !defined(CERNLIB_GFORTRAN)
   18  YY=YY+DYY
 C---Y ITERATIONS EXCEEDED - TRY AGAIN
+#else
+         YY=YY+DYY
+  18  continue
+#endif
       IF (NTRY.LT.10) GOTO 11
       EPS=10.*EPS
+#if !defined(CERNLIB_GFORTRAN)
       IF (EPS.GT.1.) CALL HWWARN('HWMLPS',100,*999)
+#else
+      if (EPS.GT.1.) then
+          call hwwarn('HWMLPS',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
       CALL HWWARN('HWMLPS',50,*11)
+#else
+      call hwwarn('HWMLPS',50,iret)
+        if (iret .eq. 1) go to 11
+#endif
    20 YY=YY+DYY
       ZZ=LOG(TECM/SUM1)
       DO 22 I=1,NCL
diff -uNr src.ORIG/mclibs/herwig/code/hwmodk.F src/mclibs/herwig/code/hwmodk.F
--- src.ORIG/mclibs/herwig/code/hwmodk.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwmodk.F	2005-05-31 02:34:40.000000000 +0900
@@ -14,6 +14,9 @@
 C     scaled by (1.-BRTMP)/(1.-BR_OLD)
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWUPCM,BRTMP,SCALE,EPS
       INTEGER IDKTMP,IMETMP,IATMP,IBTMP,ICTMP,IDTMP,IETMP,IDKY,ITMP(5),
      & L,I,J,K,JPREV
@@ -36,12 +39,24 @@
 C If internal pointers not yet set up simply store decay
       IF (.NOT.DKPSET) THEN
         NDKYS=NDKYS+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NDKYS.GT.NMXDKS) CALL HWWARN('HWMODK',100,*999)
+#else
+        if (NDKYS.GT.NMXDKS) then
+          call hwwarn('HWMODK',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         IDK(NDKYS)=IDKY
         BRFRAC(NDKYS)=BRTMP
         NME(NDKYS)=IMETMP
         DO 20 I=1,5
+#if !defined(CERNLIB_GFORTRAN)
   20    IDKPRD(I,NDKYS)=ITMP(I)
+#else
+           IDKPRD(I,NDKYS)=ITMP(I)
+  20    continue
+#endif
       ELSE
         IF (NMODES(IDKY).GT.0) THEN
 C First search to see if mode pre-exists
@@ -55,13 +70,23 @@
      &              ITMP(3).EQ.IDKPRD(3,L).AND.
      &              ITMP(4).EQ.IDKPRD(4,L).AND.
      &              ITMP(5).EQ.IDKPRD(5,L)) GOTO 90
+#if !defined(CERNLIB_GFORTRAN)
   30        L=LNEXT(L)
+#else
+               L=LNEXT(L)
+  30        continue
+#endif
           ELSE
 C Allow for different order in matching
             L=LSTRT(IDKY)
             DO 70 I=1,NMODES(IDKY)
             DO 40 J=1,5
+#if !defined(CERNLIB_GFORTRAN)
   40        MATCH(J)=.FALSE.
+#else
+               MATCH(J)=.FALSE.
+  40        continue
+#endif
             DO 60 J=1,5
             DO 50 K=1,5
             IF (.NOT.MATCH(K).AND.ITMP(K).EQ.IDKPRD(J,L)) THEN
@@ -72,15 +97,32 @@
   60        CONTINUE
             IF (MATCH(1).AND.MATCH(2).AND.MATCH(3).AND.
      &          MATCH(4).AND.MATCH(5)) GOTO 90
+#if !defined(CERNLIB_GFORTRAN)
   70        L=LNEXT(L)
+#else
+               L=LNEXT(L)
+  70        continue
+#endif
           ENDIF
         ENDIF
 C A new mode put decay products in table
         NDKYS=NDKYS+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NDKYS.GT.NMXDKS) CALL HWWARN('HWMODK',100,*999)
+#else
+        if (NDKYS.GT.NMXDKS) then
+          call hwwarn('HWMODK',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         DO 80 I=1,5
+#if !defined(CERNLIB_GFORTRAN)
   80    IDKPRD(I,NDKYS)=ITMP(I)
 C If decay consistent set up new pointers
+#else
+           IDKPRD(I,NDKYS)=ITMP(I)
+  80    continue
+#endif
         CALL HWDCHK(IDKY,NDKYS,*980)
         IF (NMODES(IDKY).EQ.0) THEN
           LSTRT(IDKY)=NDKYS
@@ -121,7 +163,12 @@
               DO 100 I=2,NMODES(IDKY)
               J=LNEXT(J)
               IF (J.EQ.L) LNEXT(JPREV)=LNEXT(J)
+#if !defined(CERNLIB_GFORTRAN)
   100         JPREV=(J)
+#else
+                JPREV=(J)
+  100         continue
+#endif
             ENDIF
           ENDIF
           NMODES(IDKY)=NMODES(IDKY)-1
@@ -138,7 +185,12 @@
           J=LSTRT(IDKY)
           DO 110 I=1,NMODES(IDKY)
           IF (J.NE.L) BRFRAC(J)=SCALE*BRFRAC(J)
+#if !defined(CERNLIB_GFORTRAN)
   110     J=LNEXT(J)
+#else
+            J=LNEXT(J)
+  110     continue
+#endif
         ENDIF
       ENDIF
       GOTO 999
diff -uNr src.ORIG/mclibs/herwig/code/hwmult.F src/mclibs/herwig/code/hwmult.F
--- src.ORIG/mclibs/herwig/code/hwmult.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwmult.F	2005-05-31 02:34:40.000000000 +0900
@@ -36,7 +36,12 @@
             CUM(1)=1
          ELSE
             DO 12 I=1,IMAX
+#if !defined(CERNLIB_GFORTRAN)
   12        CUM(I)=CUM(I)/SUM
+#else
+               CUM(I)=CUM(I)/SUM
+  12        continue
+#endif
          ENDIF
       ENDIF
 C --- Select NCHT
@@ -46,5 +51,10 @@
       NCHT=2*I
       RETURN
   20  CONTINUE
+#if !defined(CERNLIB_GFORTRAN)
       CALL HWWARN('HWMULT',100,*999)
+#else
+      call hwwarn('HWMULT',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
   999 END
diff -uNr src.ORIG/mclibs/herwig/code/hwmwgt.F src/mclibs/herwig/code/hwmwgt.F
--- src.ORIG/mclibs/herwig/code/hwmwgt.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwmwgt.F	2005-05-31 02:34:21.000000000 +0900
@@ -7,6 +7,9 @@
 C COMPUTES WEIGHT FOR MINIMUM-BIAS EVENT
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION S,X,Y
       INTEGER IDB,IDT,IDBT
       IF (IERROR.NE.0) RETURN
@@ -51,7 +54,12 @@
         Y=3.0E-4
       ELSE
         PRINT *,' IDBT=',IDBT
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWMWGT',100,*999)
+#else
+        call hwwarn('HWMWGT',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
       S=PHEP(5,3)**2
 C---EVWGT IS NON-DIFFRACTIVE CROSS SECTION IN NANOBARNS
diff -uNr src.ORIG/mclibs/herwig/code/hwrext.F src/mclibs/herwig/code/hwrext.F
--- src.ORIG/mclibs/herwig/code/hwrext.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwrext.F	2005-05-31 02:34:22.000000000 +0900
@@ -22,6 +22,11 @@
       IF(AM.LT.AM0) AM=AM0+.001
       IF(ABS(DAM).LT..001) GOTO 2
    1  CONTINUE
+#if !defined(CERNLIB_GFORTRAN)
       CALL HWWARN('HWREXT',1,*2)
+#else
+      call hwwarn('HWREXT',1,iret)
+        if (iret .eq. 1) go to 2
+#endif
    2  HWREXT=AM
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwrgen.F src/mclibs/herwig/code/hwrgen.F
--- src.ORIG/mclibs/herwig/code/hwrgen.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwrgen.F	2005-05-31 02:45:23.000000000 +0900
@@ -10,6 +10,9 @@
       IMPLICIT NONE
       DOUBLE PRECISION HWRGEN,HWRSET,HWRGET
       INTEGER I,ISEED(2),K,IZ,JSEED(2)
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       SAVE ISEED
       DATA ISEED/12345,67890/
       K=ISEED(1)/53668
@@ -26,7 +29,12 @@
 C-----------------------------------------------------------------------
       ENTRY HWRSET(JSEED)
 C-----------------------------------------------------------------------
+#if !defined(CERNLIB_GFORTRAN)
       IF (JSEED(1).EQ.0.OR.JSEED(2).EQ.0) CALL HWWARN('HWRSET',99,*999)
+#else
+      IF (JSEED(1).EQ.0.OR.JSEED(2).EQ.0) call hwwarn('HWRSET',99,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ISEED(1)=JSEED(1)
       ISEED(2)=JSEED(2)
  999  RETURN
diff -uNr src.ORIG/mclibs/herwig/code/hwrpip.F src/mclibs/herwig/code/hwrpip.F
--- src.ORIG/mclibs/herwig/code/hwrpip.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwrpip.F	2005-05-31 02:34:41.000000000 +0900
@@ -12,6 +12,11 @@
       EXTERNAL HWRGAU
       DATA VIP,VIPWID/3*0.0,.25,.015,1.8/
       DO 10 I=1,3
+#if !defined(CERNLIB_GFORTRAN)
   10  VTXPIP(I)=HWRGAU(I,VIP(I),VIPWID(I))
+#else
+         VTXPIP(I)=HWRGAU(I,VIP(I),VIPWID(I))
+  10  continue
+#endif
       VTXPIP(4)=0.
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwrpow.F src/mclibs/herwig/code/hwrpow.F
--- src.ORIG/mclibs/herwig/code/hwrpow.F	1996-12-03 23:16:58.000000000 +0900
+++ src/mclibs/herwig/code/hwrpow.F	2005-05-31 02:34:22.000000000 +0900
@@ -15,7 +15,14 @@
       COMMON/HWRPIN/XMIN,XMAX,XPOW,FIRST
       IF (FIRST) THEN
         P=XPOW+1.
+#if !defined(CERNLIB_GFORTRAN)
         IF (P.EQ.0.) CALL HWWARN('HWRPOW',500,*999)
+#else
+        if (P.EQ.0.) then
+          call hwwarn('HWRPOW',500,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         Q=1./P
         A=XMIN**P
         B=XMAX**P-A
diff -uNr src.ORIG/mclibs/herwig/code/hwsbrn.F src/mclibs/herwig/code/hwsbrn.F
--- src.ORIG/mclibs/herwig/code/hwsbrn.F	1996-12-03 23:16:59.000000000 +0900
+++ src/mclibs/herwig/code/hwsbrn.F	2005-05-31 02:34:22.000000000 +0900
@@ -7,6 +7,9 @@
 C     DOES BRANCHING OF SPACELIKE PARTON KPAR
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWBVMC,HWRGEN,HWRUNI,HWSTAB,HWUALF,HWUTAB,HWSGQQ,
      & HWSSUD,XLAST,QNOW,QLST,QP,QMIN,QLAM,QSAV,SMAX,SLST,SNOW,RN,SUDA,
      & SUDB,ZZ,ENOW,XI,PMOM,DIST(13),DMIN,X1,X2,REJFAC,OTHXI,OTHZ,QTMP,
@@ -36,7 +39,14 @@
         VALPAR=HWSVAL(ID)
         QP=HWBVMC(ID)
         XLAST=XFACT*PPAR(4,KPAR)
+#if !defined(CERNLIB_GFORTRAN)
         IF (XLAST.GE.1.) CALL HWWARN('HWSBRN',107,*999)
+#else
+        if (XLAST.GE.1.) then
+          call hwwarn('HWSBRN',107,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C--SET UP Q BOUNDARY
         IF (VALPAR) THEN
           QMIN=QG/(1.-XLAST)
@@ -66,7 +76,14 @@
         IF (QLST.GT.QMIN.AND..NOT.NOSPAC.OR..NOT.VALPAR) THEN
           IF (QLST.LE.QMIN) THEN
 C--CHECK PHASE SPACE FOR FORCED SPLITTING OF NON-VALENCE PARTON
+#if !defined(CERNLIB_GFORTRAN)
             IF (QLST.LT.QSAV) CALL HWWARN('HWSBRN',ISLENT*105,*999)
+#else
+            if (QLST.LT.QSAV) then
+          call hwwarn('HWSBRN',ISLENT*105,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
             FORCE=.TRUE.
             QNOW=(QLST/QSAV)**HWRGEN(0)*QSAV
           ELSE
@@ -104,7 +121,14 @@
               NDEL=32
               NA=N1
   130         NB=NA+NDEL
+#if !defined(CERNLIB_GFORTRAN)
               IF (NB.GT.NQEV) CALL HWWARN('HWSBRN',103,*999)
+#else
+              if (NB.GT.NQEV) then
+          call hwwarn('HWSBRN',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
               CALL HWSFUN(XLAST,QEV(NB,IS),IDHAD,NSTRU,DIST,JNHAD)
               IF (ID.EQ.13) DIST(ID)=DIST(ID)*HWSGQQ(QEV(NB,IS))
               IF (DIST(ID).LT.DMIN) DIST(ID)=DMIN
@@ -116,7 +140,14 @@
               ELSEIF (NA.NE.N1) THEN
                 IF (SUDB.LT.SNOW) THEN
                   NDEL=NDEL/2
+#if !defined(CERNLIB_GFORTRAN)
                   IF (NDEL.EQ.0) CALL HWWARN('HWSBRN',100,*999)
+#else
+                  if (NDEL.EQ.0) then
+          call hwwarn('HWSBRN',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
                   GOTO 130
                 ENDIF
                 N1=NB
@@ -146,23 +177,47 @@
           CALL HWSFBR(XLAST,QNOW,FORCE,ID,1,ID1,ID2,IW1,IW2,ZZ)
           IF (ID1.LT.0) THEN
 C--NO PHASE SPACE FOR BRANCHING
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWSBRN',ISLENT*101,*999)
+#else
+            call hwwarn('HWSBRN',ISLENT*101,iret)
+        if (iret .eq. 1) go to 999
+#endif
           ELSEIF (ID1.EQ.0) THEN
 C--BRANCHING REJECTED: REDUCE Q AND REPEAT
             IF (NTRY.GT.NBTRY.OR.IERROR.NE.0)
+#if !defined(CERNLIB_GFORTRAN)
      $           CALL HWWARN('HWSBRN',102,*999)
+#else
+     $           call hwwarn('HWSBRN',102,iret)
+        if (iret .eq. 1) go to 999
+#endif
             QLST=QNOW
             QNOW=-1.
             GOTO 125
           ELSEIF (ID1.EQ.59) THEN
 C--ANOMALOUS PHOTON SPLITTING: ADD PT TO INTRINSIC PT AND STOP BRANCHING
+#if !defined(CERNLIB_GFORTRAN)
             IF (IDHAD.NE.59) CALL HWWARN('HWSBRN',109,*999)
+#else
+            if (IDHAD.NE.59) then
+          call hwwarn('HWSBRN',109,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
             ENOW=PPAR(4,KPAR)/XLAST
             XI=(QNOW/ENOW)**2
             QLAM=QNOW*(1.-XLAST)
             IF ((2.-XI)*QLAM**2.GT.EMSCA**2) THEN
 C--BRANCHING REJECTED: REDUCE Q AND REPEAT
+#if !defined(CERNLIB_GFORTRAN)
               IF (NTRY.GT.NBTRY) CALL HWWARN('HWSBRN',110,*999)
+#else
+              if (NTRY.GT.NBTRY) then
+          call hwwarn('HWSBRN',110,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
               QLST=QNOW
               QNOW=-1.
               GOTO 125
@@ -177,7 +232,14 @@
             GOTO 125
           ELSEIF (FORCE.AND..NOT.HWSVAL(ID1).AND.ID1.NE.13) THEN
 C--FORCED BRANCHING PRODUCED A NON-VALENCE PARTON: TRY AGAIN
+#if !defined(CERNLIB_GFORTRAN)
             IF (NTRY.GT.NBTRY) CALL HWWARN('HWSBRN',108,*999)
+#else
+            if (NTRY.GT.NBTRY) then
+          call hwwarn('HWSBRN',108,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
             QLST=QNOW
             QNOW=-1.
             GOTO 125
@@ -192,7 +254,14 @@
           IF (SUDORD.EQ.1.AND.HWUALF(2,QLAM).LT.HWRGEN(0) .OR.
      &        (2.-XI)*QLAM**2.GT.EMSCA**2.AND..NOT.FORCE) THEN
 C--BRANCHING REJECTED: REDUCE Q AND REPEAT
+#if !defined(CERNLIB_GFORTRAN)
               IF (NTRY.GT.NBTRY) CALL HWWARN('HWSBRN',104,*999)
+#else
+              if (NTRY.GT.NBTRY) then
+          call hwwarn('HWSBRN',104,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
               QLST=QNOW
               QNOW=-1.
               GOTO 125
diff -uNr src.ORIG/mclibs/herwig/code/hwsfbr.F src/mclibs/herwig/code/hwsfbr.F
--- src.ORIG/mclibs/herwig/code/hwsfbr.F	1996-12-03 23:16:59.000000000 +0900
+++ src/mclibs/herwig/code/hwsfbr.F	2005-05-31 02:34:41.000000000 +0900
@@ -72,21 +72,41 @@
       IF (ID.NE.13) THEN
 C---SPLITTING INTO QUARK
         DO 10 IP=1,ID-1
+#if !defined(CERNLIB_GFORTRAN)
    10   PROB(IP,IZ)=PSUM
+#else
+           PROB(IP,IZ)=PSUM
+   10   continue
+#endif
         IF (NONF) PSUM=PSUM+DIST(ID)*AZ*CFFAC*(1.+ZZ*ZZ)*WR
         DO 20 IP=ID,12
+#if !defined(CERNLIB_GFORTRAN)
    20   PROB(IP,IZ)=PSUM
+#else
+           PROB(IP,IZ)=PSUM
+   20   continue
+#endif
         PSUM=PSUM+DIST(13)*AZ*0.5*(ZZ*ZZ+WZ*WZ)
         PROB(13,IZ)=PSUM
       ELSE
 C---SPLITTING INTO GLUON
         DO 30 IP=1,12
         PSUM=PSUM+DIST(IP)*AZ*CFFAC*(1.+WZ*WZ)*ZR
+#if !defined(CERNLIB_GFORTRAN)
    30   PROB(IP,IZ)=PSUM
+#else
+           PROB(IP,IZ)=PSUM
+   30   continue
+#endif
         IF (NONF) PSUM=PSUM+DIST(13)*AZ*2.*CAFAC*(WZ*ZR+ZZ*WR+WZ*ZZ)
         PROB(13,IZ)=PSUM
       ENDIF
+#if !defined(CERNLIB_GFORTRAN)
    40 YY=YY+DELY
+#else
+         YY=YY+DELY
+   40 continue
+#endif
    50 PHOTPR=IDHAD.EQ.59.AND.ID.NE.13
       IF (PHOTPR) THEN
 C---ALLOW ANOMALOUS PHOTON SPLITTING
diff -uNr src.ORIG/mclibs/herwig/code/hwsfun.F src/mclibs/herwig/code/hwsfun.F
--- src.ORIG/mclibs/herwig/code/hwsfun.F	1996-12-03 23:16:59.000000000 +0900
+++ src/mclibs/herwig/code/hwsfun.F	2005-05-31 02:47:16.000000000 +0900
@@ -55,6 +55,9 @@
 C   CERN_ROOT:[DOC]PDFLIB.TXT ON VXCERN
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWSGAM,X,SCALE,XOLD,QOLD,XMWN,QSCA,SS,SMIN,S,T,
      & TMIN,TMAX,VX,AA,VT,WT,UPV,DNV,SEA,STR,CHM,BTM,TOP,GLU,WX,XQSUM,
      & DMIN,TPMIN,TPMAX,DIST(13),G(2),Q0(5),QL(5),F(5),A(6,5),
@@ -354,9 +357,23 @@
       DATA TBMIN,TTMIN/8.1905,7.4474,11.5528,10.8097/
       DATA XOLD,QOLD,IOLD,NOLD/-1.,0.,0,0/
       DATA DMIN,Q0,QL/0.,2*2.,2*2.236,2.,.2,.4,.2,.29,.177/
+#if !defined(CERNLIB_GFORTRAN)
       IF (X.LE.0.) CALL HWWARN('HWSFUN',100,*999)
+#else
+      if (X.LE.0.) then
+          call hwwarn('HWSFUN',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       XMWN=ONE-X
+#if !defined(CERNLIB_GFORTRAN)
       IF (XMWN.LE.0.) CALL HWWARN('HWSFUN',101,*999)
+#else
+      if (XMWN.LE.0.) then
+          call hwwarn('HWSFUN',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C---FREEZE THE SCALE IF REQUIRED
       SCALEF=SCALE
       IF (ISPAC.GT.0) SCALEF=MAX(SCALEF,QSPAC)
@@ -375,8 +392,22 @@
 C---FIX TO CALL SCHULER-SJOSTRAND CODE
           IF (AUTPDF(IBEAM).EQ.'SaSph') THEN
             XSP=X
+#if !defined(CERNLIB_GFORTRAN)
             IF (XSP.LE.0.) CALL HWWARN('HWSFUN',102,*999)
+#else
+            if (XSP.LE.0.) then
+          call hwwarn('HWSFUN',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
             IF (1.-XSP.LE.0.) CALL HWWARN('HWSFUN',103,*999)
+#else
+            if (1.-XSP.LE.0.) then
+          call hwwarn('HWSFUN',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
             Q2=QSCA**2
             ISET=MOD(MODPDF(IBEAM),10)
             IOP1=MOD(MODPDF(IBEAM)/10,2)
@@ -392,7 +423,12 @@
             CALL SASGAM(ISET,XSP,Q2,P2,IP2,F2GM,XPGA)
             IF (IOP1.EQ.1 .AND. ISTAT.LT.10) THEN
               DO 5 I=-6,6
+#if !defined(CERNLIB_GFORTRAN)
  5            XPGA(I)=XPVMD(I)+XPANL(I)+XPBEH(I)+XPDIR(I)
+#else
+                  XPGA(I)=XPVMD(I)+XPANL(I)+XPBEH(I)+XPDIR(I)
+ 5            continue
+#endif
             ENDIF
             UPV=XPGA(2)
             DNV=XPGA(1)
@@ -413,8 +449,22 @@
           DIST(8)=USEA
         ELSE
           XSP=X
+#if !defined(CERNLIB_GFORTRAN)
           IF (XSP.LE.0.) CALL HWWARN('HWSFUN',102,*999)
+#else
+          if (XSP.LE.0.) then
+          call hwwarn('HWSFUN',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
+#if !defined(CERNLIB_GFORTRAN)
           IF (1.-XSP.LE.0.) CALL HWWARN('HWSFUN',103,*999)
+#else
+          if (1.-XSP.LE.0.) then
+          call hwwarn('HWSFUN',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           Q2=SCALEF**2
           W2=Q2*(1-X)/X
           EMC2=4*RMASS(4)**2
@@ -463,7 +513,12 @@
             TOP=TOP*FAC
             GLU=GLU*FAC**2
           ELSE
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWSFUN',1,*999)
+#else
+            call hwwarn('HWSFUN',1,iret)
+        if (iret .eq. 1) go to 999
+#endif
           ENDIF
         ENDIF
         GOTO 900
@@ -478,7 +533,14 @@
         IF (QSCA.LT.Q0(NSET)) QSCA=Q0(NSET)
         IF (QSCA.NE.QOLD.OR.IDHAD.NE.IOLD.OR.NSET.NE.NOLD) THEN
 C---INITIALIZE
+#if !defined(CERNLIB_GFORTRAN)
           IF (NSET.LT.1.OR.NSET.GT.5) CALL HWWARN('HWSFUN',400,*999)
+#else
+          if (NSET.LT.1.OR.NSET.GT.5) then
+          call hwwarn('HWSFUN',400,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
           QOLD=QSCA
           IOLD=IDHAD
           NOLD=NSET
@@ -496,7 +558,12 @@
               IP=NSET
               DO 10 I=1,5
               DO 10 J=1,6
+#if !defined(CERNLIB_GFORTRAN)
    10         A(J,I)=B(1,J,I,IP)+S*(B(2,J,I,IP)+S*B(3,J,I,IP))
+#else
+                 A(J,I)=B(1,J,I,IP)+S*(B(2,J,I,IP)+S*B(3,J,I,IP))
+   10         continue
+#endif
               DO 20 K=1,2
               AA=ONE+A(2,K)+A(3,K)
    20         G(K)=HWSGAM(AA)/((ONE+A(2,K)*A(4,K)/AA)*HWSGAM(A(2,K))
@@ -504,7 +571,12 @@
             ELSEIF (NSET.EQ.5) THEN
               DO 21 I=1,5
               DO 21 J=1,6
+#if !defined(CERNLIB_GFORTRAN)
    21         A(J,I)=BB(1,J,I)+S*(BB(2,J,I)+S*(BB(3,J,I)+S*BB(4,J,I)))
+#else
+              A(J,I)=BB(1,J,I)+S*(BB(2,J,I)+S*(BB(3,J,I)+S*BB(4,J,I)))
+   21         continue
+#endif
               DO 22 K=1,2
               AA=ONE+A(2,K)+A(3,K)
    22         G(K)=HWSGAM(AA)/((ONE+A(2,K)/AA*(A(4,K)+
@@ -526,7 +598,12 @@
               IP=NSET+2
               DO 30 I=1,5
               DO 30 J=1,6
+#if !defined(CERNLIB_GFORTRAN)
    30         A(J,I)=B(1,J,I,IP)+S*(B(2,J,I,IP)+S*B(3,J,I,IP))
+#else
+                 A(J,I)=B(1,J,I,IP)+S*(B(2,J,I,IP)+S*B(3,J,I,IP))
+   30         continue
+#endif
               AA=ONE+A(2,1)+A(3,1)
               G(1)=HWSGAM(AA)/(HWSGAM(A(2,1))*HWSGAM(ONE+A(3,1)))
               G(2)=0.
@@ -535,8 +612,14 @@
 C
         IF (NSET.LT.3.OR.NSET.EQ.5) THEN
           DO 50 I=1,5
+#if !defined(CERNLIB_GFORTRAN)
    50     F(I)=A(1,I)*X**A(2,I)*XMWN**A(3,I)*(ONE+X*
      &        (A(4,I)+X*(A(5,I)  +  X*A(6,I))))
+#else
+             F(I)=A(1,I)*X**A(2,I)*XMWN**A(3,I)*(ONE+X*
+     &        (A(4,I)+X*(A(5,I)  +  X*A(6,I))))
+   50     continue
+#endif
           F(1)=F(1)*G(1)
           F(2)=F(2)*G(2)
           UPV=F(1)-F(2)
@@ -570,7 +653,12 @@
           XQSUM=0.
           DO 110 IT=1,6
           DO 110 IX=1,6
+#if !defined(CERNLIB_GFORTRAN)
   110     XQSUM=XQSUM+CEHLQ(IX,IT,NX,IFL,IP)*TX(IX)*TT(IT)
+#else
+            XQSUM=XQSUM+CEHLQ(IX,IT,NX,IFL,IP)*TX(IX)*TT(IT)
+  110     continue
+#endif
   120     XQ(IFL)=XQSUM*XMWN**NEHLQ(IFL,IP)
           UPV=XQ(1)
           DNV=XQ(2)
@@ -593,7 +681,12 @@
             XQSUM=0.
             DO 130 IT=1,6
             DO 130 IX=1,6
+#if !defined(CERNLIB_GFORTRAN)
   130       XQSUM=XQSUM+CEHLQ(IX,IT,NX,7,IP)*TX(IX)*TB(IT)
+#else
+              XQSUM=XQSUM+CEHLQ(IX,IT,NX,7,IP)*TX(IX)*TB(IT)
+  130       continue
+#endif
             BTM=XQSUM*XMWN**NEHLQ(7,IP)
           ENDIF
 C...SPECIAL EXPANSION FOR TOP (THRESHOLD EFFECTS)
@@ -614,7 +707,12 @@
             XQSUM=0.
             DO 150 IT=1,6
             DO 150 IX=1,6
+#if !defined(CERNLIB_GFORTRAN)
   150       XQSUM=XQSUM+CEHLQ(IX,IT,NX,8,IP)*TX(IX)*TB(IT)
+#else
+              XQSUM=XQSUM+CEHLQ(IX,IT,NX,8,IP)*TX(IX)*TB(IT)
+  150       continue
+#endif
             TOP=XQSUM*XMWN**NEHLQ(8,IP)
           ENDIF
         ENDIF
@@ -655,7 +753,12 @@
          DIST(8)=USEA+UPV
       ELSE
          PRINT *,' CALLED HWSFUN FOR IDHAD =',IDHAD
+#if !defined(CERNLIB_GFORTRAN)
          CALL HWWARN('HWSFUN',400,*999)
+#else
+         call hwwarn('HWSFUN',400,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
   900 DIST(3)=STR
       DIST(4)=CHM
diff -uNr src.ORIG/mclibs/herwig/code/hwsspc.F src/mclibs/herwig/code/hwsspc.F
--- src.ORIG/mclibs/herwig/code/hwsspc.F	1996-12-03 23:17:01.000000000 +0900
+++ src/mclibs/herwig/code/hwsspc.F	2005-05-31 02:34:41.000000000 +0900
@@ -7,6 +7,9 @@
 C     REPLACES SPACELIKE PARTONS BY SPECTATORS
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWUSQR,EMSQ,EMTR,EPAR,XPAR,QSQ
       INTEGER KHEP,IP,JP,IDH,IDP,ISP,IDSPC
       EXTERNAL HWUSQR
@@ -26,14 +29,29 @@
             ELSEIF (IDP.LT.13) THEN
               IDSPC=IDP-6
             ELSE
+#if !defined(CERNLIB_GFORTRAN)
               CALL HWWARN('HWSSPC',100,*999)
+#else
+              call hwwarn('HWSSPC',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
             ENDIF
 C---IDENTIFY SPECTATOR
 C   (1) QUARK CASE
           ELSEIF (IDP.LE.3) THEN
             DO 10 ISP=1,12
+#if !defined(CERNLIB_GFORTRAN)
   10        IF (IDH.EQ.NCLDK(LOCN(IDP,ISP))) GOTO 20
+#else
+               IF (IDH.EQ.NCLDK(LOCN(IDP,ISP))) GOTO 20
+  10        continue
+#endif
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWSSPC',101,*999)
+#else
+            call hwwarn('HWSSPC',101,iret)
+        if (iret .eq. 1) go to 999
+#endif
   20        IF (ISP.LE.3) THEN
               IDSPC=ISP+6
             ELSEIF (ISP.LE.9) THEN
@@ -45,8 +63,18 @@
           ELSEIF (IDP.GT.6.AND.IDP.LE.9) THEN
             IDP=IDP-6
             DO 30 ISP=1,12
+#if !defined(CERNLIB_GFORTRAN)
   30        IF (IDH.EQ.NCLDK(LOCN(ISP,IDP))) GOTO 40
+#else
+               IF (IDH.EQ.NCLDK(LOCN(ISP,IDP))) GOTO 40
+  30        continue
+#endif
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWSSPC',103,*999)
+#else
+            call hwwarn('HWSSPC',103,iret)
+        if (iret .eq. 1) go to 999
+#endif
             RETURN
   40        IF (ISP.LE.3) THEN
               IDSPC=ISP
@@ -60,10 +88,20 @@
             IF (IDP.EQ.13) THEN
               IDSPC=IDP
             ELSE
+#if !defined(CERNLIB_GFORTRAN)
               CALL HWWARN('HWSSPC',106,*999)
+#else
+              call hwwarn('HWSSPC',106,iret)
+        if (iret .eq. 1) go to 999
+#endif
             ENDIF
           ELSE
+#if !defined(CERNLIB_GFORTRAN)
             CALL HWWARN('HWSSPC',105,*999)
+#else
+            call hwwarn('HWSSPC',105,iret)
+        if (iret .eq. 1) go to 999
+#endif
           ENDIF
 C---REPLACE PARTON BY SPECTATOR
           IDHW(KHEP)=IDSPC
diff -uNr src.ORIG/mclibs/herwig/code/hwsval.F src/mclibs/herwig/code/hwsval.F
--- src.ORIG/mclibs/herwig/code/hwsval.F	1996-12-03 23:17:02.000000000 +0900
+++ src/mclibs/herwig/code/hwsval.F	2005-05-31 02:34:22.000000000 +0900
@@ -7,6 +7,9 @@
 C     TRUE FOR VALENCE PARTON ID IN INCOMING HADRON INHAD
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER ID,IDHAD
       LOGICAL HWSVAL
       HWSVAL=.FALSE.
@@ -24,6 +27,11 @@
       ELSEIF (IDHAD.EQ.71.OR.IDHAD.EQ.72) THEN
         IF (ID.EQ.13) HWSVAL=.TRUE.
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWSVAL',100,*999)
+#else
+        call hwwarn('HWSVAL',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
   999 END
diff -uNr src.ORIG/mclibs/herwig/code/hwualf.F src/mclibs/herwig/code/hwualf.F
--- src.ORIG/mclibs/herwig/code/hwualf.F	1996-12-03 23:17:02.000000000 +0900
+++ src/mclibs/herwig/code/hwualf.F	2005-05-31 02:34:22.000000000 +0900
@@ -12,6 +12,9 @@
 C         .EQ.3  ONE-LOOP WITH 5-FLAVOUR BETA, LAMBDA=QCDL3
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWUALF,SCALE,KAFAC,B3,B4,B5,B6,C3,C4,C5,C6,C35,
      & C45,C65,D35,RHO,RAT,RLF,DRH,EPS
       INTEGER IOPT,ITN
@@ -55,10 +58,24 @@
    10   CONTINUE
    20   QCDL3=QCDL5*EXP(0.5*D35)
       ENDIF
+#if !defined(CERNLIB_GFORTRAN)
       IF (SCALE.LE.QCDL5) CALL HWWARN('HWUALF',51,*999)
+#else
+      if (SCALE.LE.QCDL5) then
+          call hwwarn('HWUALF',51,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       RHO=2.*LOG(SCALE/QCDL5)
       IF (IOPT.EQ.3) THEN
+#if !defined(CERNLIB_GFORTRAN)
         IF (RHO.LE.D35) CALL HWWARN('HWUALF',52,*999)
+#else
+        if (RHO.LE.D35) then
+          call hwwarn('HWUALF',52,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         HWUALF=1./(B5*(RHO-D35))
         RETURN
       ENDIF
@@ -72,12 +89,26 @@
       ELSE
         RLF=B3*RHO/(1.-C3*RAT)+C35
       ENDIF
+#if !defined(CERNLIB_GFORTRAN)
       IF (RLF.LE.ZERO) CALL HWWARN('HWUALF',53,*999)
+#else
+      if (RLF.LE.ZERO) then
+          call hwwarn('HWUALF',53,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       IF (IOPT.EQ.1) THEN
         HWUALF=1./RLF
       ELSE
         HWUALF=B5*(RHO-D35)/RLF
+#if !defined(CERNLIB_GFORTRAN)
         IF (HWUALF.GT.1.) CALL HWWARN('HWUALF',54,*999)
+#else
+        if (HWUALF.GT.1.) then
+          call hwwarn('HWUALF',54,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       ENDIF
       RETURN
  999  HWUALF=ZERO
diff -uNr src.ORIG/mclibs/herwig/code/hwubpr.F src/mclibs/herwig/code/hwubpr.F
--- src.ORIG/mclibs/herwig/code/hwubpr.F	1996-12-03 23:17:02.000000000 +0900
+++ src/mclibs/herwig/code/hwubpr.F	2005-05-31 02:34:41.000000000 +0900
@@ -15,8 +15,14 @@
      &  ' ADA  P-X     P-Y     P-Z   ENERGY    MASS',
      &  '   V-X        V-Y        V-Z        V-C*T')
         DO 20 J=1,NPAR
+#if !defined(CERNLIB_GFORTRAN)
   20    WRITE(6,30) J,RNAME(ABS(IDPAR(J))),TMPAR(J),JDAPAR(1,J),
      &   (JCOPAR(I,J),I=1,4),(PPAR(I,J),I=1,5),(VPAR(I,J),I=1,4)
+#else
+           WRITE(6,30) J,RNAME(ABS(IDPAR(J))),TMPAR(J),JDAPAR(1,J),
+     &   (JCOPAR(I,J),I=1,4),(PPAR(I,J),I=1,5),(VPAR(I,J),I=1,4)
+  20    continue
+#endif
   30    FORMAT(I5,1X,A8,L2,5I4,F7.2,4F8.2,4E11.4)
       ELSE
         WRITE(6,40) INHAD,XFACT
@@ -24,8 +30,14 @@
      &  '    XFACT =',E11.3//'  IPAR ID     TM  DA1 CMO AMO CDA',
      &  ' ADA  P-X     P-Y     P-Z   ENERGY    MASS')
         DO 50 J=1,NPAR
+#if !defined(CERNLIB_GFORTRAN)
   50    WRITE(6,60) J,RNAME(ABS(IDPAR(J))),TMPAR(J),JDAPAR(1,J),
      &   (JCOPAR(I,J),I=1,4),(PPAR(I,J),I=1,5)
+#else
+           WRITE(6,60) J,RNAME(ABS(IDPAR(J))),TMPAR(J),JDAPAR(1,J),
+     &   (JCOPAR(I,J),I=1,4),(PPAR(I,J),I=1,5)
+  50    continue
+#endif
   60    FORMAT(I5,1X,A8,L2,5I4,F7.2,4F8.2)
       ENDIF
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwudks.F src/mclibs/herwig/code/hwudks.F
--- src.ORIG/mclibs/herwig/code/hwudks.F	1996-12-03 23:17:03.000000000 +0900
+++ src/mclibs/herwig/code/hwudks.F	2005-05-31 02:34:41.000000000 +0900
@@ -14,6 +14,9 @@
 C     (N.B. CP violation permits this).
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWUPCM,HWUAEM,BRSUM,EPS,SCALE,BRTMP(NMXMOD),FN,X,
      & W,Q,FAC
       INTEGER HWUANT,I,IDKY,LAST,LTMP(NMXMOD),J,L,K,M,N,INDX(NMXMOD),
@@ -31,7 +34,12 @@
 C First zero arrays
       DO 20 I=1,NMXRES
       LSTRT(I)=0
+#if !defined(CERNLIB_GFORTRAN)
   20  NMODES(I)=0
+#else
+         NMODES(I)=0
+  20  continue
+#endif
       DO 30 I=1,NMXDKS
       NPRODS(I)=0
       LNEXT(I)=0.
@@ -72,13 +80,23 @@
      &            IDKPRD(3,L).EQ.IDKPRD(3,J).AND.
      &            IDKPRD(4,L).EQ.IDKPRD(4,J).AND.
      &            IDKPRD(5,L).EQ.IDKPRD(5,J)) GOTO 100
+#if !defined(CERNLIB_GFORTRAN)
   50      L=LNEXT(L)
+#else
+             L=LNEXT(L)
+  50      continue
+#endif
         ELSE
 C Allow for different order in matching
           L=LSTRT(IDKY)
           DO 90 K=1,NMODES(IDKY)
           DO 60 M=1,5
+#if !defined(CERNLIB_GFORTRAN)
   60      MATCH(M)=.FALSE.
+#else
+             MATCH(M)=.FALSE.
+  60      continue
+#endif
           DO 80 M=1,5
           DO 70 N=1,5
           IF (.NOT.MATCH(N).AND.IDKPRD(N,L).EQ.IDKPRD(M,J)) THEN
@@ -89,11 +107,21 @@
   80      CONTINUE
           IF (MATCH(1).AND.MATCH(2).AND.MATCH(3).AND.
      &        MATCH(4).AND.MATCH(5)) GOTO 100
+#if !defined(CERNLIB_GFORTRAN)
   90      L=LNEXT(L)
+#else
+             L=LNEXT(L)
+  90      continue
+#endif
         ENDIF
         CALL HWDCHK(IDKY,J,*120)
         NMODES(IDKY)=NMODES(IDKY)+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NMODES(IDKY).GT.NMXMOD) CALL HWWARN('HWUDKS',100,*999)
+#else
+        IF (NMODES(IDKY).GT.NMXMOD) call hwwarn('HWUDKS',100,iret)
+        if (iret .eq. 1) go to 999
+#endif
         LNEXT(LAST)=J
         BRSUM=BRSUM+BRFRAC(J)
         LTMP(NMODES(IDKY))=J
@@ -125,7 +153,12 @@
           K=LSTRT(IDKY)
           DO 160 J=1,NMODES(IDKY)
           BRFRAC(K)=SCALE*BRFRAC(K)
+#if !defined(CERNLIB_GFORTRAN)
   160     K=LNEXT(K)
+#else
+            K=LNEXT(K)
+  160     continue
+#endif
         ENDIF
       ENDIF
 C Sort branching ratios into descending order and rearrange pointers
@@ -133,7 +166,12 @@
       LSTRT(IDKY)=LTMP(INDX(1))
       LNEXT(LTMP(INDX(1)))=LTMP(INDX(1))
       DO 170 J=2,NMODES(IDKY)
+#if !defined(CERNLIB_GFORTRAN)
   170 LNEXT(LTMP(INDX(J-1)))=LTMP(INDX(J))
+#else
+        LNEXT(LTMP(INDX(J-1)))=LTMP(INDX(J))
+  170 continue
+#endif
       LNEXT(LTMP(INDX(NMODES(IDKY))))=LTMP(INDX(NMODES(IDKY)))
   180 CONTINUE
 C If not a short lived particle with a decay mode then set stable
@@ -150,14 +188,24 @@
 C Set up DKLTM for light quarks
       DO 200 I=1,5
       DKLTM(I)=VMIN2/RMASS(I)**2
+#if !defined(CERNLIB_GFORTRAN)
   200 DKLTM(I+6)=DKLTM(I)
 C gluon
+#else
+        DKLTM(I+6)=DKLTM(I)
+  200 continue
+#endif
       DKLTM(13)=VMIN2/RMASS(13)**2
 C and diquarks
       DO 210 I=109,114
       DKLTM(I)=VMIN2/RMASS(I)**2
+#if !defined(CERNLIB_GFORTRAN)
   210 DKLTM(I+6)=DKLTM(I)
 C Set up DKLTM for weak bosons
+#else
+        DKLTM(I+6)=DKLTM(I)
+  210 continue
+#endif
       DKLTM(198)=EXAG*RMASS(198)/GAMW
       DKLTM(199)=DKLTM(198)
       DKLTM(200)=EXAG*RMASS(200)/GAMZ
@@ -234,8 +282,13 @@
         ELSE
 C First initialize particle matching array
           DO 230 I=1,NMODES(IPART)
+#if !defined(CERNLIB_GFORTRAN)
   230     PMATCH(I)=.FALSE.
 C Loop through antiparticle decay modes
+#else
+            PMATCH(I)=.FALSE.
+  230     continue
+#endif
           LR=LSTRT(IRES)
           DO 290 I=1,NMODES(IRES)
 C Search for conjugate mode allowing for different particle order
@@ -243,7 +296,12 @@
           DO 270 J=1,NMODES(IPART)
           IF (PMATCH(J)) GOTO 270
           DO 240 K=1,5
+#if !defined(CERNLIB_GFORTRAN)
   240     MATCH(K)=.FALSE.
+#else
+            MATCH(K)=.FALSE.
+  240     continue
+#endif
           DO 260 K=1,5
           KPRDLR=HWUANT(IDKPRD(K,LR))
           DO 250 L=1,5
@@ -255,8 +313,13 @@
   260     CONTINUE
           IF (MATCH(1).AND.MATCH(2).AND.MATCH(3).AND.
      &        MATCH(4).AND.MATCH(5)) GOTO 280
+#if !defined(CERNLIB_GFORTRAN)
   270     LP=LNEXT(LP)
 C No match found
+#else
+            LP=LNEXT(LP)
+  270     continue
+#endif
           WRITE(6,350) LR,RNAME(IRES),(RNAME(IDKPRD(J,LR)),J=1,5)
           GOTO 290
 C Match found, check branching ratios and matrix element codes
@@ -267,13 +330,23 @@
           IF (NME(LR).NE.NME(LP))
      &     WRITE(6,370) LR,RNAME(IRES),(RNAME(IDKPRD(J,LR)),J=1,5),
      &                  NME(LR),NME(LP)
+#if !defined(CERNLIB_GFORTRAN)
   290     LR=LNEXT(LR)
 C Check for unmatched modes of particle conjugate to antiparticle
+#else
+            LR=LNEXT(LR)
+  290     continue
+#endif
           LP=LSTRT(IPART)
           DO 300 I=1,NMODES(IPART)
           IF (.NOT.PMATCH(I))
      &     WRITE(6,350) LP,RNAME(IPART),(RNAME(IDKPRD(J,LP)),J=1,5)
+#if !defined(CERNLIB_GFORTRAN)
   300     LP=LNEXT(LP)
+#else
+            LP=LNEXT(LP)
+  300     continue
+#endif
         ENDIF
       ENDIF
   310 CONTINUE
diff -uNr src.ORIG/mclibs/herwig/code/hwudpr.F src/mclibs/herwig/code/hwudpr.F
--- src.ORIG/mclibs/herwig/code/hwudpr.F	1996-12-03 23:17:03.000000000 +0900
+++ src/mclibs/herwig/code/hwudpr.F	2005-05-31 02:34:41.000000000 +0900
@@ -36,7 +36,12 @@
         IF (NMODES(I).GE.2) THEN
           DO 40 J=2,NMODES(I)
           K=LNEXT(K)
+#if !defined(CERNLIB_GFORTRAN)
   40      WRITE(6,50) BRFRAC(K),NME(K),(RNAME(IDKPRD(L,K)),L=1,5)
+#else
+             WRITE(6,50) BRFRAC(K),NME(K),(RNAME(IDKPRD(L,K)),L=1,5)
+  40      continue
+#endif
   50      FORMAT(53X,F5.3,1X,I3,5(1X,A8))
         ENDIF
       ENDIF
diff -uNr src.ORIG/mclibs/herwig/code/hwueec.F src/mclibs/herwig/code/hwueec.F
--- src.ORIG/mclibs/herwig/code/hwueec.F	1996-12-03 23:17:03.000000000 +0900
+++ src/mclibs/herwig/code/hwueec.F	2005-05-31 02:34:22.000000000 +0900
@@ -8,6 +8,9 @@
 C     in llbar-->qqbar; lepton label IL=1-6: e,nu_e,mu,nu_mu,tau,nu_tau.
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION Q2
       INTEGER IL,JL,IQ
       Q2=EMSCA**2
@@ -22,5 +25,12 @@
          TQWT=TQWT+CLQ(1,MAXFL)
       ENDIF
   10  CONTINUE
+#if !defined(CERNLIB_GFORTRAN)
       IF (MAXFL.EQ.0) CALL HWWARN('HWUEEC',100,*999)
+#else
+      if (MAXFL.EQ.0) then
+          call hwwarn('HWUEEC',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
   999 END
diff -uNr src.ORIG/mclibs/herwig/code/hwuemv.F src/mclibs/herwig/code/hwuemv.F
--- src.ORIG/mclibs/herwig/code/hwuemv.F	1996-12-03 23:17:03.000000000 +0900
+++ src/mclibs/herwig/code/hwuemv.F	2005-05-31 02:34:41.000000000 +0900
@@ -14,7 +14,12 @@
       LFROM=IFROM
       LTO=ITO
       DO 100 I=1,N
+#if !defined(CERNLIB_GFORTRAN)
  100  IEDT(I)=LTO
+#else
+        IEDT(I)=LTO
+ 100  continue
+#endif
       CALL HWUEDT(-N,IEDT)
       DO 300 I=1,N
         IHEP=LTO+I
diff -uNr src.ORIG/mclibs/herwig/code/hwuepr.F src/mclibs/herwig/code/hwuepr.F
--- src.ORIG/mclibs/herwig/code/hwuepr.F	1996-12-03 23:17:03.000000000 +0900
+++ src/mclibs/herwig/code/hwuepr.F	2005-05-31 02:34:41.000000000 +0900
@@ -37,7 +37,12 @@
      & '   STATUS:',I4,'  ERROR:',I4,'  WEIGHT:',E11.4)
   20  FORMAT(/23X,A28//1X,3A40)
       DO 30 K=1,11
+#if !defined(CERNLIB_GFORTRAN)
   30  FIRST(K)=.TRUE.
+#else
+         FIRST(K)=.TRUE.
+  30  continue
+#endif
       DO 40 J=1,NHEP
       IST=ISTHEP(J)
       IS=IST/10
diff -uNr src.ORIG/mclibs/herwig/code/hwufne.F src/mclibs/herwig/code/hwufne.F
--- src.ORIG/mclibs/herwig/code/hwufne.F	1996-12-03 23:17:03.000000000 +0900
+++ src/mclibs/herwig/code/hwufne.F	2005-05-31 02:34:22.000000000 +0900
@@ -8,6 +8,9 @@
 C     CHECKING FOR ERRORS, AND PRINTING
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       LOGICAL CALLED
       COMMON/HWDBUG/CALLED
       CALLED=.TRUE.
@@ -20,7 +23,14 @@
         ELSE
           NUMERU=NUMERU+1
         ENDIF
+#if !defined(CERNLIB_GFORTRAN)
         IF (NUMER.GT.MAXER) CALL HWWARN('HWUFNE',300,*999)
+#else
+        if (NUMER.GT.MAXER) then
+          call hwwarn('HWUFNE',300,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         NEVHEP=NEVHEP-1
 C---PRINT FIRST MAXPR EVENTS
       ELSEIF (NEVHEP.LE.MAXPR) THEN
diff -uNr src.ORIG/mclibs/herwig/code/hwugau.F src/mclibs/herwig/code/hwugau.F
--- src.ORIG/mclibs/herwig/code/hwugau.F	1996-12-03 23:17:03.000000000 +0900
+++ src/mclibs/herwig/code/hwugau.F	2005-05-31 02:34:22.000000000 +0900
@@ -44,7 +44,12 @@
          BB=C1
          IF (1.+CONST*ABS(C2).NE.1.) GOTO 2
 C---TOO HIGH ACCURACY REQUESTED
+#if !defined(CERNLIB_GFORTRAN)
          CALL HWWARN('HWUGAU',500,*999)
+#else
+         call hwwarn('HWUGAU',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
     5 HWUGAU=HWUGAU+S16
       IF (BB.NE.B) GOTO 1
   999 END
diff -uNr src.ORIG/mclibs/herwig/code/hwuidt.F src/mclibs/herwig/code/hwuidt.F
--- src.ORIG/mclibs/herwig/code/hwuidt.F	1996-12-03 23:17:03.000000000 +0900
+++ src/mclibs/herwig/code/hwuidt.F	2005-05-31 02:34:22.000000000 +0900
@@ -14,6 +14,9 @@
 C     IOPT= 3 GIVEN NWIG, RETURNS IPDG AND IWIG
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER IOPT,IPDG,IWIG,I
       CHARACTER*8 NWIG
       IF (IOPT.EQ.1) THEN
@@ -28,14 +31,24 @@
   20    FORMAT(1X,'Particle not recognised, PDG code: ',I7)
         IWIG=20
         NWIG=RNAME(20)
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWUIDT',101,*999)
+#else
+        call hwwarn('HWUIDT',101,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ELSEIF (IOPT.EQ.2) THEN
         IF (IWIG.LT.0.OR.IWIG.GT.NRES) THEN
           WRITE(6,30) IWIG
   30      FORMAT(1X,'Particle not recognised, HERWIG code: ',I3)
           IPDG=0
           NWIG=RNAME(20)
+#if !defined(CERNLIB_GFORTRAN)
           CALL HWWARN('HWUIDT',102,*999)
+#else
+          call hwwarn('HWUIDT',102,iret)
+        if (iret .eq. 1) go to 999
+#endif
         ELSE
           IPDG=IDPDG(IWIG)
           NWIG=RNAME(IWIG)
@@ -53,8 +66,18 @@
   50    FORMAT(1X,'Particle not recognised, HERWIG name: ',A8)
         IWIG=20
         IPDG=0
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWUIDT',103,*999)
+#else
+        call hwwarn('HWUIDT',103,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWUIDT',404,*999)
+#else
+        call hwwarn('HWUIDT',404,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
   999 END
diff -uNr src.ORIG/mclibs/herwig/code/hwuinc.F src/mclibs/herwig/code/hwuinc.F
--- src.ORIG/mclibs/herwig/code/hwuinc.F	1996-12-03 23:17:03.000000000 +0900
+++ src/mclibs/herwig/code/hwuinc.F	2005-05-31 02:51:08.000000000 +0900
@@ -7,6 +7,9 @@
 C     COMPUTES CONSTANTS AND LOOKUP TABLES
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWBVMC,HWUALF,HWUPCM,XMIN,XMAX,XPOW,QR,DQKWT,
      & UQKWT,SQKWT,DIQWT,QMAX,PMAX,PTLIM,ETLIM,PGS,PTELM,X,QSCA,UPV,DNV,
      & USEA,DSEA,STR,CHM,BTM,TOP,GLU,VAL(20),CLMXPW,RCLPOW
@@ -101,7 +104,12 @@
         STOP
       ENDIF
       DO 120 I=1,6
+#if !defined(CERNLIB_GFORTRAN)
   120 RMASS(I+6)=RMASS(I)
+#else
+        RMASS(I+6)=RMASS(I)
+  120 continue
+#endif
       RMASS(199)=RMASS(198)
 C---A PRIORI WEIGHTS FOR QUARK AND DIQUARKS
       DQKWT=PWT(1)
@@ -124,7 +132,12 @@
       PMAX=1./PMAX
       QMAX=1./QMAX
       DO 130 I=1,3
+#if !defined(CERNLIB_GFORTRAN)
   130 QWT(I)=PWT(I)*QMAX
+#else
+        QWT(I)=PWT(I)*QMAX
+  130 continue
+#endif
       DO 140 I=1,12
   140 PWT(I)=PWT(I)*PMAX
 C  MASSES OF DIQUARKS (ASSUME BINDING NEGLIGIBLE)
@@ -135,8 +148,13 @@
       RMASS(113)=RMASS(1)+RMASS(3)
       RMASS(114)=RMASS(3)+RMASS(3)
       DO 150 I=109,114
+#if !defined(CERNLIB_GFORTRAN)
   150 RMASS(I+6)=RMASS(I)
 C  MASSES OF TOP HADRONS (ASSUME BINDING NEGLIGIBLE)
+#else
+        RMASS(I+6)=RMASS(I)
+  150 continue
+#endif
       RMASS(232)=RMASS(6)+RMASS(5)
       RMASS(233)=RMASS(6)+RMASS(1)
       RMASS(234)=RMASS(6)+RMASS(2)
@@ -152,8 +170,13 @@
       RMASS(244)=RMASS(6)+RMASS(6)
       RMASS(232)=RMASS(243)
       DO 160 I=233,242
+#if !defined(CERNLIB_GFORTRAN)
   160 RMASS(I+22)=RMASS(I)
 C Set up an array of cluster mass threholds
+#else
+        RMASS(I+22)=RMASS(I)
+  160 continue
+#endif
       CLMXPW=CLMAX**CLPOW
       RCLPOW=ONE/CLPOW
       CALL HWVZRO(144,CTHRPW(1,1))
@@ -161,8 +184,13 @@
       DO 170 J=1,6
       CTHRPW(I ,J  )=(CLMXPW+(RMASS(I    )+RMASS(J+6  ))**CLPOW)**RCLPOW
       CTHRPW(I ,J+6)=(CLMXPW+(RMASS(I    )+RMASS(J+108))**CLPOW)**RCLPOW
+#if !defined(CERNLIB_GFORTRAN)
   170 CTHRPW(I+6,J )=(CLMXPW+(RMASS(I+114)+RMASS(J+6  ))**CLPOW)**RCLPOW
 C Decay length conversion factor GEV2MM hbar.c/e
+#else
+      CTHRPW(I+6,J )=(CLMXPW+(RMASS(I+114)+RMASS(J+6  ))**CLPOW)**RCLPOW
+  170 continue
+#endif
       GEV2MM=1.D-15*SQRT(10.*GEV2NB)
 C Plank's constant/2pi (GeV.s)
       HBAR=GEV2MM/(10.*CSPEED)
@@ -409,7 +437,12 @@
                 WRITE (6,'(10X,A)')'SCHULER-SJOSTRAND PHOTON PDF SET 2M'
               ELSE
                 WRITE (6,'(10X,A)')'UNKNOWN SCHULER-SJOSTRAND PDF SET'
+#if !defined(CERNLIB_GFORTRAN)
                 CALL HWWARN('HWUINC',500,*999)
+#else
+                call hwwarn('HWUINC',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
               ENDIF
               IF (IOP1.EQ.1) THEN
                 WRITE (6,'(10X,A)') 'WITH DIRECT COMPONENT IN DIS'
@@ -472,7 +505,12 @@
       PGS=HWUPCM(RMASS(13),RMASS(I),RMASS(I))
       IF (PGS.GE.0.) NGSPL=I
       IF (PGS.GE.PGSMX) PGSMX=PGS
+#if !defined(CERNLIB_GFORTRAN)
   480 PGSPL(I)=PGS
+#else
+        PGSPL(I)=PGS
+  480 continue
+#endif
       CALL HWVZRO(6,PTINT)
       IF (IPRO.NE.80) THEN
 C---SET UP TABLES OF SUDAKOV FORM FACTORS, GIVING
@@ -484,7 +522,12 @@
         DO 490 J=2,NQEV
         IF (QEV(J,I).GT.QSPAC) GOTO 500
   490   CONTINUE
+#if !defined(CERNLIB_GFORTRAN)
   500   NSPAC(I)=J-1
+#else
+          NSPAC(I)=J-1
+  500   continue
+#endif
       ENDIF
       EVWGT=AVWGT
       ISTAT=1
diff -uNr src.ORIG/mclibs/herwig/code/hwuine.F src/mclibs/herwig/code/hwuine.F
--- src.ORIG/mclibs/herwig/code/hwuine.F	1996-12-03 23:17:04.000000000 +0900
+++ src/mclibs/herwig/code/hwuine.F	2005-05-31 02:34:22.000000000 +0900
@@ -7,6 +7,9 @@
 C     INITIALISES AN EVENT
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       DOUBLE PRECISION HWRGEN,HWRGET,DUMMY
       REAL TL
       LOGICAL CALLED
@@ -17,12 +20,24 @@
         WRITE (6,10)
  10     FORMAT (1X,'A call to the subroutine HWUFNE should be added to',
      &      /,' the main program, immediately after the call to HWMEVT')
+#if !defined(CERNLIB_GFORTRAN)
         CALL HWWARN('HWUINE',500,*999)
+#else
+        call hwwarn('HWUINE',500,iret)
+        if (iret .eq. 1) go to 999
+#endif
       ENDIF
       CALLED=.FALSE.
 C---CHECK TIME LEFT
       CALL HWUTIM(TL)
+#if !defined(CERNLIB_GFORTRAN)
       IF (TL.LT.TLOUT) CALL HWWARN('HWUINE',200,*999)
+#else
+      if (TL.LT.TLOUT) then
+          call hwwarn('HWUINE',200,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C---UPDATE RANDOM NUMBER SEED
       DUMMY = HWRGET(NRN)
       NEVHEP=NEVHEP+1
diff -uNr src.ORIG/mclibs/herwig/code/hwuli2.F src/mclibs/herwig/code/hwuli2.F
--- src.ORIG/mclibs/herwig/code/hwuli2.F	1996-12-03 23:17:04.000000000 +0900
+++ src/mclibs/herwig/code/hwuli2.F	2005-05-31 02:52:51.000000000 +0900
@@ -7,6 +7,9 @@
 C     Complex dilogarithm function, Li_2 (Spence function)
 C-----------------------------------------------------------------------
       IMPLICIT NONE
+#if defined(CERNLIB_GFORTRAN)
+      double complex imag
+#endif
       DOUBLE COMPLEX HWULI2,PROD,Y,Y2,X,Z
       DOUBLE PRECISION XR,XI,R2,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,ZETA2,
      & ZERO,ONE,HALF
diff -uNr src.ORIG/mclibs/herwig/code/hwures.F src/mclibs/herwig/code/hwures.F
--- src.ORIG/mclibs/herwig/code/hwures.F	1996-12-03 23:17:05.000000000 +0900
+++ src/mclibs/herwig/code/hwures.F	2005-05-31 02:34:41.000000000 +0900
@@ -11,6 +11,9 @@
 C     Sets CLDKWT(K) =(2J+1) spin weight normalizing largest value to 1.
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER NMXTMP
       PARAMETER (NMXTMP=20)
       DOUBLE PRECISION HWUPCM,HWUAEM,EPS,WTMX,REMMN,RWTMX,WTMP,
@@ -99,7 +102,14 @@
       DO 90 J=21,NRES
       IF (VTOCDK(J).OR.IFLAV(J).NE.MAPF(I)) GOTO 90
       NCDKS=NCDKS+1
+#if !defined(CERNLIB_GFORTRAN)
       IF (NCDKS.GT.NMXCDK) CALL HWWARN('HWURES',101,*999)
+#else
+      if (NCDKS.GT.NMXCDK) then
+          call hwwarn('HWURES',101,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       NCLDK(NCDKS)=J
       CLDKWT(NCDKS)=TWO*RSPIN(J)+ONE
       IF (CLDKWT(NCDKS).GT.WTMX) WTMX=CLDKWT(NCDKS)
@@ -117,8 +127,13 @@
 C Set scaled spin weights
       RWTMX=1./WTMX
       DO 110 J=LTMP,NCDKS
+#if !defined(CERNLIB_GFORTRAN)
   110 CLDKWT(J)=CLDKWT(J)*RWTMX
 C Swap order if lightest hadron of given flavour not first
+#else
+        CLDKWT(J)=CLDKWT(J)*RWTMX
+  110 continue
+#endif
       IF (IMN.NE.LTMP) THEN
         ITMP=NCLDK(LTMP)
         WTMP=CLDKWT(LTMP)
@@ -180,7 +195,14 @@
       ENDIF
       IF (WT.GT.EPS) THEN
         NCDKS=NCDKS+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NCDKS.GT.NMXCDK) CALL HWWARN('HWURES',102,*999)
+#else
+        if (NCDKS.GT.NMXCDK) then
+          call hwwarn('HWURES',102,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         NCLDK(NCDKS)=J
         CLDKWT(NCDKS)=WT*(TWO*RSPIN(J)+ONE)
         IF (CLDKWT(NCDKS).GT.WTMX) WTMX=CLDKWT(NCDKS)
@@ -191,7 +213,14 @@
       ENDIF
       IF (ONE-WT.GT.EPS) THEN
         NTMP=NTMP+1
+#if !defined(CERNLIB_GFORTRAN)
         IF (NTMP.GT.NMXTMP) CALL HWWARN('HWURES',103,*999)
+#else
+        if (NTMP.GT.NMXTMP) then
+          call hwwarn('HWURES',103,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
         NCDTMP(NTMP)=J
         CDWTMP(NTMP)=(ONE-WT)*(TWO*RSPIN(J)+ONE)
         IF (CDWTMP(NTMP).GT.WTMX2) WTMX2=CDWTMP(NTMP)
@@ -208,8 +237,13 @@
 C Normalize scaled spin weights
       RWTMX=1./WTMX
       DO 150 I=LTMP,NCDKS
+#if !defined(CERNLIB_GFORTRAN)
   150 CLDKWT(I)=CLDKWT(I)*RWTMX
 C Swap order if lightest hadron of flavour 11 not first
+#else
+        CLDKWT(I)=CLDKWT(I)*RWTMX
+  150 continue
+#endif
       IF (IMN.NE.LTMP) THEN
         ITMP=NCLDK(LTMP)
         WTMP=CLDKWT(LTMP)
@@ -222,14 +256,26 @@
         WRITE(6,100) 33
         CALL HWWARN('HWURES',53,*180)
       ENDIF
+#if !defined(CERNLIB_GFORTRAN)
       IF (NCDKS+NTMP.GT.NMXCDK) CALL HWWARN('HWURES',104,*999)
+#else
+      if (NCDKS+NTMP.GT.NMXCDK) then
+          call hwwarn('HWURES',104,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
 C Store hadrons for |ssbar> channel and normalize their weights
       RWTMX=1./WTMX2
       DO 170 I=1,NTMP
       J=NCDKS+I
       NCLDK(J)=NCDTMP(I)
+#if !defined(CERNLIB_GFORTRAN)
   170 CLDKWT(J)=CDWTMP(I)*RWTMX
 C Swap order if lightest hadron of flavour 33 not first
+#else
+        CLDKWT(J)=CDWTMP(I)*RWTMX
+  170 continue
+#endif
       IF (IMN2.NE.1) THEN
         ITMP=NCLDK(NCDKS+1)
         WTMP=CLDKWT(NCDKS+1)
diff -uNr src.ORIG/mclibs/herwig/code/hwusor.F src/mclibs/herwig/code/hwusor.F
--- src.ORIG/mclibs/herwig/code/hwusor.F	1996-12-03 23:17:05.000000000 +0900
+++ src/mclibs/herwig/code/hwusor.F	2005-05-31 02:34:41.000000000 +0900
@@ -10,7 +10,14 @@
 C-----------------------------------------------------------------------
       DOUBLE PRECISION A(N),B(500)
       INTEGER N,I,J,IOPT,K(N),IL(500),IR(500)
+#if !defined(CERNLIB_GFORTRAN)
       IF (N.GT.500) CALL HWWARN('HWUSOR',100,*999)
+#else
+      if (N.GT.500) then
+          call hwwarn('HWUSOR',100,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       IL(1)=0
       IR(1)=0
       DO 10 I=2,N
@@ -45,5 +52,10 @@
       GOTO 9
   30  IF(IOPT.EQ.2) RETURN
       DO 31 I=1,N
+#if !defined(CERNLIB_GFORTRAN)
   31  A(I)=B(I)
+#else
+         A(I)=B(I)
+  31  continue
+#endif
  999  END
diff -uNr src.ORIG/mclibs/herwig/code/hwusta.F src/mclibs/herwig/code/hwusta.F
--- src.ORIG/mclibs/herwig/code/hwusta.F	1996-12-03 23:17:06.000000000 +0900
+++ src/mclibs/herwig/code/hwusta.F	2005-05-31 02:34:22.000000000 +0900
@@ -7,10 +7,20 @@
 C     MAKES PARTICLE TYPE 'NAME' STABLE
 C-----------------------------------------------------------------------
       INCLUDE 'HERWIG59.INC'
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       INTEGER IPDG,IWIG
       CHARACTER*8 NAME
       CALL HWUIDT(3,IPDG,IWIG,NAME)
+#if !defined(CERNLIB_GFORTRAN)
       IF (IWIG.EQ.20) CALL HWWARN('HWUSTA',500,*999)
+#else
+      if (IWIG.EQ.20) then
+          call hwwarn('HWUSTA',500,iret)
+          if (iret .eq. 1) go to 999
+        endif
+#endif
       RSTAB(IWIG)=.TRUE.
       WRITE (6,10) IWIG,NAME
    10 FORMAT(/10X,'PARTICLE TYPE',I4,'=',A8,' SET STABLE')
diff -uNr src.ORIG/mclibs/herwig/code/hwvdif.F src/mclibs/herwig/code/hwvdif.F
--- src.ORIG/mclibs/herwig/code/hwvdif.F	1996-12-03 23:17:06.000000000 +0900
+++ src/mclibs/herwig/code/hwvdif.F	2005-05-31 02:34:41.000000000 +0900
@@ -9,5 +9,10 @@
       DOUBLE PRECISION P(N),Q(N),R(N)
       INTEGER N,I
       DO 10 I=1,N
+#if !defined(CERNLIB_GFORTRAN)
    10 R(I)=P(I)-Q(I)
+#else
+         R(I)=P(I)-Q(I)
+   10 continue
+#endif
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwvdot.F src/mclibs/herwig/code/hwvdot.F
--- src.ORIG/mclibs/herwig/code/hwvdot.F	1996-12-03 23:17:06.000000000 +0900
+++ src/mclibs/herwig/code/hwvdot.F	2005-05-31 02:34:41.000000000 +0900
@@ -10,6 +10,11 @@
       INTEGER N,I
       PQ=0.
       DO 10 I=1,N
+#if !defined(CERNLIB_GFORTRAN)
    10 PQ=PQ+P(I)*Q(I)
+#else
+         PQ=PQ+P(I)*Q(I)
+   10 continue
+#endif
       HWVDOT=PQ
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwvequ.F src/mclibs/herwig/code/hwvequ.F
--- src.ORIG/mclibs/herwig/code/hwvequ.F	1996-12-03 23:17:06.000000000 +0900
+++ src/mclibs/herwig/code/hwvequ.F	2005-05-31 02:34:41.000000000 +0900
@@ -9,5 +9,10 @@
       DOUBLE PRECISION P(N),Q(N)
       INTEGER N,I
       DO 10 I=1,N
+#if !defined(CERNLIB_GFORTRAN)
    10 Q(I)=P(I)
+#else
+         Q(I)=P(I)
+   10 continue
+#endif
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwvsca.F src/mclibs/herwig/code/hwvsca.F
--- src.ORIG/mclibs/herwig/code/hwvsca.F	1996-12-03 23:17:06.000000000 +0900
+++ src/mclibs/herwig/code/hwvsca.F	2005-05-31 02:34:41.000000000 +0900
@@ -9,5 +9,10 @@
       DOUBLE PRECISION C,P(N),Q(N)
       INTEGER N,I
       DO 10 I=1,N
+#if !defined(CERNLIB_GFORTRAN)
    10 Q(I)=C*P(I)
+#else
+         Q(I)=C*P(I)
+   10 continue
+#endif
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwvsum.F src/mclibs/herwig/code/hwvsum.F
--- src.ORIG/mclibs/herwig/code/hwvsum.F	1996-12-03 23:17:06.000000000 +0900
+++ src/mclibs/herwig/code/hwvsum.F	2005-05-31 02:34:41.000000000 +0900
@@ -9,5 +9,10 @@
       DOUBLE PRECISION P(N),Q(N),R(N)
       INTEGER N,I
       DO 10 I=1,N
+#if !defined(CERNLIB_GFORTRAN)
    10 R(I)=P(I)+Q(I)
+#else
+         R(I)=P(I)+Q(I)
+   10 continue
+#endif
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwvzro.F src/mclibs/herwig/code/hwvzro.F
--- src.ORIG/mclibs/herwig/code/hwvzro.F	1996-12-03 23:17:06.000000000 +0900
+++ src/mclibs/herwig/code/hwvzro.F	2005-05-31 02:34:41.000000000 +0900
@@ -9,5 +9,10 @@
       DOUBLE PRECISION P(N)
       INTEGER N,I
       DO 10 I=1,N
+#if !defined(CERNLIB_GFORTRAN)
    10 P(I)=0.
+#else
+         P(I)=0.
+   10 continue
+#endif
       END
diff -uNr src.ORIG/mclibs/herwig/code/hwwarn.F src/mclibs/herwig/code/hwwarn.F
--- src.ORIG/mclibs/herwig/code/hwwarn.F	1996-12-03 23:17:06.000000000 +0900
+++ src/mclibs/herwig/code/hwwarn.F	2005-05-30 18:09:44.000000000 +0900
@@ -2,7 +2,11 @@
 *CMZ :-        -26/04/91  10.18.58  by  Bryan Webber
 *-- Author :    Bryan Webber
 C-----------------------------------------------------------------------
+#if !defined(CERNLIB_GFORTRAN)
       SUBROUTINE HWWARN(SUBRTN,ICODE,*)
+#else
+      SUBROUTINE HWWARN(SUBRTN,ICODE,iret)
+#endif
 C-----------------------------------------------------------------------
 C     DEALS WITH ERRORS DURING EXECUTION
 C     SUBRTN = NAME OF CALLING SUBROUTINE
@@ -18,22 +22,45 @@
       INCLUDE 'HERWIG59.INC'
       INTEGER ICODE
       CHARACTER*6 SUBRTN
+#if defined(CERNLIB_GFORTRAN)
+      integer iret
+#endif
       IF (ICODE.GE.0) WRITE (6,10) SUBRTN,ICODE
    10 FORMAT(/' HWWARN CALLED FROM SUBPROGRAM ',A6,': CODE =',I4)
       IF (ICODE.LT.0) THEN
          IERROR=ICODE
+#if !defined(CERNLIB_GFORTRAN)
          RETURN 1
+#else
+         iret = 1
+         return
+#endif
       ELSEIF (ICODE.LT.100) THEN
          WRITE (6,20) NEVHEP,NRN,EVWGT
    20    FORMAT(' EVENT',I8,':   SEEDS =',I11,' &',I11,
      &'  WEIGHT =',E11.4/' EVENT SURVIVES. EXECUTION CONTINUES')
+#if !defined(CERNLIB_GFORTRAN)
          IF (ICODE.GT.49) RETURN 1
+#else
+         if (icode.gt.49) then
+           iret = 1
+           return
+         else
+	   iret = 0
+           return
+         endif
+#endif
       ELSEIF (ICODE.LT.200) THEN
          WRITE (6,30) NEVHEP,NRN,EVWGT
    30    FORMAT(' EVENT',I8,':   SEEDS =',I11,' &',I11,
      &'  WEIGHT =',E11.4/' EVENT KILLED.   EXECUTION CONTINUES')
          IERROR=ICODE
+#if !defined(CERNLIB_GFORTRAN)
          RETURN 1
+#else
+         iret = 1
+         return
+#endif
       ELSEIF (ICODE.LT.300) THEN
          WRITE (6,40)
    40    FORMAT(' EVENT SURVIVES.  RUN ENDS GRACEFULLY')
diff -uNr src.ORIG/mclibs/isajet/code/cteq5l.F src/mclibs/isajet/code/cteq5l.F
--- src.ORIG/mclibs/isajet/code/cteq5l.F	2001-10-08 23:03:03.000000000 +0900
+++ src/mclibs/isajet/code/cteq5l.F	2005-05-30 16:50:34.000000000 +0900
@@ -228,7 +228,12 @@
       DO 100 I = 0, NEX
          AF(I) = 0.D0
          SBX = 1.D0
+#if !defined(CERNLIB_GFORTRAN)
          DO 110 K = 0, MLFVEC(IFL)
+#else
+         NMLFV = MLFVEC(IFL)
+         DO 110 K = 0, NMLFV
+#endif
             AF(I) = AF(I) + SBX*AM(I,K,IFL)
             SBX = SB1*SBX
 110      CONTINUE
diff -uNr src.ORIG/mclibs/isajet/code/sigqcd.F src/mclibs/isajet/code/sigqcd.F
--- src.ORIG/mclibs/isajet/code/sigqcd.F	1996-12-05 02:38:26.000000000 +0900
+++ src/mclibs/isajet/code/sigqcd.F	2005-05-30 16:54:28.000000000 +0900
@@ -213,7 +213,11 @@
 250   CONTINUE
 C
 C          Gluon + heavy quark
+#if !defined(CERNLIB_GFORTRAN)
       DO 300 IQ=8,13.
+#else
+      DO 300 IQ=8,13
+#endif
         IF(.NOT.(GOQ(1,1).AND.GOQ(IQ,2))) GO TO 310
         AMQ=AMASS(IQ/2)
         AM2=AMQ**2
diff -uNr src.ORIG/mclibs/pythia/code/visaje.F src/mclibs/pythia/code/visaje.F
--- src.ORIG/mclibs/pythia/code/visaje.F	2002-04-11 01:03:24.000000000 +0900
+++ src/mclibs/pythia/code/visaje.F	2005-05-30 17:40:55.000000000 +0900
@@ -7,7 +7,9 @@
       FUNCTION VISAJE()
       IMPLICIT DOUBLE PRECISION(A-H, O-Z)
       IMPLICIT INTEGER(I-N)
+#if !defined(CERNLIB_GFORTRAN)
       CHARACTER*40 VISAJE
+#endif
  
 C...Commonblocks.
       COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200)
diff -uNr src.ORIG/packlib/kernlib/kerngen/tcgen/tcdump.F src/packlib/kernlib/kerngen/tcgen/tcdump.F
--- src.ORIG/packlib/kernlib/kerngen/tcgen/tcdump.F	1996-02-16 02:49:50.000000000 +0900
+++ src/packlib/kernlib/kerngen/tcgen/tcdump.F	2005-05-28 23:32:51.000000000 +0900
@@ -16,7 +16,11 @@
 C
 C
       CALL UBLOW (  IND,IDN,3)
+#if defined(CERNLIB_QRTHOLL)
       CALL UBLOW (3HIFH,IFM,3)
+#else
+      CALL UBLOW ('IFH',IFM,3)
+#endif
       DO 12 J=1,3
       IF (IUCOMP(IFM(J),IDN,3).EQ.0)  IFM(J)=0
    12 CONTINUE
diff -uNr src.ORIG/pawlib/comis/code/csjtjp.F src/pawlib/comis/code/csjtjp.F
--- src.ORIG/pawlib/comis/code/csjtjp.F	1996-02-27 02:16:22.000000000 +0900
+++ src/pawlib/comis/code/csjtjp.F	2005-05-28 23:39:10.000000000 +0900
@@ -101,7 +101,11 @@
       IF(N.LE.0)THEN
         N=4
         IF(N.GT.NTB)GO TO 3
+#if defined(CERNLIB_QRTHOLL)
         CALL CCOPYS(MJCHAR(4H*PAR),JST,4)
+#else
+        CALL CCOPYS(MJCHAR('*PAR'),JST,4)
+#endif
         JST=JST+4
       ENDIF
       NW=(N-1)/NBYTPW+1
diff -uNr src.ORIG/pawlib/paw/code/palogo.F src/pawlib/paw/code/palogo.F
--- src.ORIG/pawlib/paw/code/palogo.F	2004-01-13 23:33:39.000000000 +0900
+++ src/pawlib/paw/code/palogo.F	2005-05-28 23:59:15.000000000 +0900
@@ -325,7 +325,11 @@
 *
       TCARD=' '
       CALL UHTOC(
+#if defined(CERNLIB_QRTHOLL)
      + 40HPAW      2.14/04  12/01/04  10.45.00     
+#else
+     + 'PAW      2.14/04  12/01/04  10.45.00    ' 
+#endif
 #if !defined(CERNLIB_CRAY)
      +,4,TCARD,26)
 #endif
diff -uNr src.ORIG/pawlib/paw/code/paspi2.F src/pawlib/paw/code/paspi2.F
--- src.ORIG/pawlib/paw/code/paspi2.F	1996-08-21 22:58:20.000000000 +0900
+++ src/pawlib/paw/code/paspi2.F	2005-05-29 00:05:32.000000000 +0900
@@ -348,11 +348,21 @@
       CALL IGSET ('LTYP', 3.0)
 *
       IF (RZONE.LT.4.0) THEN
+#if !defined(CERNLIB_GFORTRAN)
        DO 60 R=0.1, 1.0, 0.1
+#else
+       DO 60 IR=1,10
+          R = 0.1*I
+#endif
           CALL IGARC (0.0, 0.0, R, R, 0.0, 0.0)
    60    CONTINUE
       ELSE
+#if !defined(CERNLIB_GFORTRAN)
        DO 70 R=0.25, 1.0, 0.25
+#else
+       DO 70 IR=1,4
+          R = 0.25*I
+#endif
           CALL IGARC (0.0, 0.0, R, R, 0.0, 0.0)
    70    CONTINUE
       ENDIF
diff -uNr src.ORIG/pawlib/paw/fmotif/Imakefile src/pawlib/paw/fmotif/Imakefile
--- src.ORIG/pawlib/paw/fmotif/Imakefile	1996-09-23 23:20:46.000000000 +0900
+++ src/pawlib/paw/fmotif/Imakefile	2005-05-29 00:18:38.000000000 +0900
@@ -2,7 +2,7 @@
 	ntwini.F pamloc.F pbhist.F pbhlun.F pbpiaf.F pbplun.F \ @@\
 	plotisto.F pmhist.F pminit.F show_chain.F
 
-#ifdef CERNLIB_LINUX
+#if defined(CERNLIB_LINUX) && !defined(CERNLIB_GFORTRAN)
 FORTRANOPTIONS = -fno-backslash  $(FORTRANSAVEOPTION) -fno-second-underscore
 #endif
 
diff -uNr src.ORIG/pawlib/sigma/src/siallm.F src/pawlib/sigma/src/siallm.F
--- src.ORIG/pawlib/sigma/src/siallm.F	1995-12-12 23:36:15.000000000 +0900
+++ src/pawlib/sigma/src/siallm.F	2005-05-29 01:03:06.000000000 +0900
@@ -108,9 +108,20 @@
       GO TO 37
    21 IF(N.EQ.2)GO TO 2
    22 MN1=M-N+1
+#if !defined(CERNLIB_GFORTRAN)
       IF(REAL(A(N,N)).NE.0..OR.AIMAG(A(N,N)).NE.0.)
      1 IF(ABS(REAL(A(N,N-1)/A(N,N)))+ABS(AIMAG(A(N,N-1)/A(N,N)))-1.E-9)
      2 24,24,23
+#else
+      IF (REAL(A(N,N)).NE.0..OR.AIMAG(A(N,N)).NE.0.) THEN
+         IF (ABS(REAL(A(N,N-1)/A(N,N)))+ABS(AIMAG(A(N,N-1)/A(N,N)))
+     +        -1.E-9.LE.0.) THEN
+            GO TO 24
+         ELSE 
+            GO TO 23
+         ENDIF
+      ENDIF
+#endif
    23 IF(ABS(REAL(A(N,N-1)))+ABS(AIMAG(A(N,N-1))).GE.EPS)GO TO 25
    24 LAMBDA(MN1)=A(N,N)+SHIFT(1)
       ICOUNT=0
diff -uNr src.ORIG/phtools/fowl/redat2.F src/phtools/fowl/redat2.F
--- src.ORIG/phtools/fowl/redat2.F	1996-03-23 01:42:47.000000000 +0900
+++ src/phtools/fowl/redat2.F	2005-05-30 17:52:36.000000000 +0900
@@ -170,7 +170,11 @@
       IF(HISTIT(I).EQ.BLANK) CALL UCOPY(10H..........,HISTIT(I),1)
 #endif
 #if !defined(CERNLIB_CDC)
+#if !defined(CERNLIB_GFORTRAN)
       IF(HISTIT(I).EQ.BLANK) CALL UCOPY(4H....,HISTIT(I),1)
+#else
+      IF(HISTIT(I).EQ.BLANK) CALL UCOPY('....',HISTIT(I),1)
+#endif
 #endif
    77 BINS(LMLI) = HISTIT(I)
       NHIST = MAX(NHIST,IHIST)
@@ -215,7 +219,11 @@
       IF(HISTIT(I).EQ.BLANK) CALL UCOPY(10H..........,HISTIT(I),1)
 #endif
 #if !defined(CERNLIB_CDC)
+#if !defined(CERNLIB_GFORTRAN)
       IF(HISTIT(I).EQ.BLANK) CALL UCOPY(4H....,HISTIT(I),1)
+#else
+      IF(HISTIT(I).EQ.BLANK) CALL UCOPY('....',HISTIT(I),1)
+#endif
 #endif
   187 BINS(LNEXT+I-1) = HISTIT(I)
       GOTO 89
