willis@auvax.UUCP (11/01/87)
I've been teaching the students in my introductory FORTRAN course
about the EXTERNAL statement. To give them a simple example of its
use I generated the following program to do numerical integration and
attempted to compile it under Microsoft Fortran V4.0. I'm not that
impressed by this product since its optimizer seems to produce crap code
on a regular basis, but I'm unfortunately stuck with it.. Anyway I
compiled using
fl /Od
the following program and got the amazing response
Compiler error (assertion): file %Z%%M%:%I%, line 811 source=-1
Compiler error (assertion): file %Z%%M%:%I%, line 811 source=-1
Compiler error (assertion): file %Z%%M%:%I%, line 811 source=-1
Compiler error (assertion): file %Z%%M%:%I%, line 811 source=-1
Compiler error (assertion): file @(#)omf_ms.c:1.108, line 2619 source=-1
Compiler error (assertion): file @(#)omf_ms.c:1.108, line 2619 source=-1
fatal error F1003: error count exceeds 5; stopping compilation
Am I doing something wrong? Maybe someone can tell me what the
%Z%%M%:%I% is going on?! Here's the code:
PROGRAM APPROX
*********************************************************************
* This program approximates the integral of a function over the
* interval [a,b] using the rectangle method. The approximation is
* calculated by the function subprogram DEFINT. The integrand, the
* interval of integration and the number of subintervals are passed
* as arguments to DEFINT.
* Variables used are:
* A, B : the endpoints of the interval of integration
* SUBS : the number of subintervals used
*********************************************************************
REAL A, B, POLY
INTEGER SUBS
EXTERNAL POLY
PRINT*, 'ENTER THE INTERVAL ENDPOINTS AND THE # OF SUBINTERVALS'
READ*, A, B, SUBS
PRINT 10, SUBS, DEFINT(POLY, A, B, SUBS)
10 FORMAT(1X, 'RECTANGLE APPROXIMATION WITH ', I3,
+ ' SUBINTERVALS IS ',F10.4)
STOP
END
REAL FUNCTION DEFINT(F, A, B, N)
*********************************************************************
* This function uses the rectangle method to compute the integral
* of function F over the interval [A, B] using N subintervals.
* variables used are:
* N : the number of subintervals used
* I : a counter
* DELX : the length of the subintervals
* X : midpoint of one of the subintervals
*********************************************************************
INTEGER N, I
REAL DELX, X, A, B
DELX = (B - A) / N
DEFINT = 0.0
X = A + DELX / 2.0
DO 10 I = 1, N
DEFINT = DEFINT + F(X)
X = X + DELX
10 CONTINUE
DEFINT = DEFINT * DELX
RETURN
END
REAL FUNCTION POLY(X)
*********************************************************************
* The integrand, or function F(X) we are trying to integrate,
* is defined here.
* variables used:
* X : a value of x
*********************************************************************
REAL X
POLY = X **2 + 3 * X + 2
RETURN
END
Any assistance is appreciated.
Tony Willis
Athabasca University ...{ubc-vision,ihnp4}!alberta!auvax!willis uucp
Box 10,000 usercdir@ualtamts BITNET
Athabasca, Alberta TOG 2R0
Canada (403) 675-6221 whelan@nmsu-ee.UUCP (Mike Whelan AFIT) (11/06/87)
In response to the problem with the Microsoft Compiler, try declaring all of your REAL variables first. For some reason, the Microsoft Complier has problems when allocating space for variables if this is not done.