- #1
xaria181
- 3
- 0
Hello everybody.I have a problem with a program I wrote in Fortran.The program is this and it is giving me the error 299 at line 4(parameter (n-100001)) saying -Statement ordering error - PARAMETER cannot appear after executable statements. What can I do to fix the problem?? :-(
program intergrate
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
open(10,file="500Ktr.rox")
parameter (n=100001)
dimension x(n),y(n)
write(*,*)'enter number of points <100000'
read(*,*)nd
if(nd.gt.n)stop 'number of points > 100000 !'
write(*,*)'enter left and right limits'
read(*,*)a,b
a=1.d0
b=2.d0
step=(b-a)/dfloat(nd)
write(*,*)
write(*,*)
write(*,*)'integration with step=',step
write(*,*)
write(*,*)
do i=1,nd
read(10,*)thesi,TPK_x
x(i)=thesi
y(i)=TPK_x
end do
call traper(x,y,nd,x(1),x(nd),result)
rr=dexp(2.d0*b)-dexp(2.d0*a)/2.d0+5.d0/3.d0*(a**3-b**3)
write(*,*)
write(*,*)
write(*,*)'result=',result,' analytically=',rr
write(*,*)
write(*,*)
end
c
SUBROUTINE TRAPER (X,Y,N,AA,BB,RE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(N),Y(N)
DATA ZERO/0.D0/
C
RE=ZERO
SD=ZERO
IF(AA .EQ. BB .OR. N .LT. 2) RETURN
A=AA
B=BB
IF(AA .LT. BB) GO TO 1
A=BB
B=AA
1 CONTINUE
DO 40 I1 = 2,N
I=I1
IF(X(I) .GE. A) GO TO 41
40 CONTINUE
41 CONTINUE
DO 42 J1 = 2,N
J=J1
IF(X(J) .GE. B) GO TO 43
42 CONTINUE
43 WI1=(X(I)-A)**2/(X(I)-X(I-1))
WI=(1.0D0+(A-X(I-1))/(X(I)-X(I-1)))*(X(I)-A)
WJ1=(1.0D0+(X(J)-B)/(X(J)-X(J-1)))*(B-X(J-1))
WJ=(B-X(J-1))**2/(X(J)-X(J-1))
IF(I .NE. J) GO TO 2
WI1=WI1+WJ1+X(I-1)-X(I)
WI=WI+WJ+X(I-1)-X(I)
WJ1=ZERO
WJ =ZERO
GO TO 10
2 IF(I .NE. J-1) GO TO 3
WI=WI+WJ1
WJ1=ZERO
GO TO 10
3 WI=WI+X(I+1)-X(I)
WJ1=WJ1+X(J-1)-X(J-2)
IF(I .EQ. J-2) GO TO 10
LI=I+1
LJ=J-2
DO 4 L = LI,LJ
RE=RE+(X(L+1)-X(L-1))*Y(L)
4 CONTINUE
10 RE=RE+WI1*Y(I-1)+WI*Y(I)+WJ1*Y(J-1)+WJ*Y(J)
RE=0.5D0*RE
IF(AA .GT. BB) RE=-RE
C
RETURN
END
program intergrate
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
open(10,file="500Ktr.rox")
parameter (n=100001)
dimension x(n),y(n)
write(*,*)'enter number of points <100000'
read(*,*)nd
if(nd.gt.n)stop 'number of points > 100000 !'
write(*,*)'enter left and right limits'
read(*,*)a,b
a=1.d0
b=2.d0
step=(b-a)/dfloat(nd)
write(*,*)
write(*,*)
write(*,*)'integration with step=',step
write(*,*)
write(*,*)
do i=1,nd
read(10,*)thesi,TPK_x
x(i)=thesi
y(i)=TPK_x
end do
call traper(x,y,nd,x(1),x(nd),result)
rr=dexp(2.d0*b)-dexp(2.d0*a)/2.d0+5.d0/3.d0*(a**3-b**3)
write(*,*)
write(*,*)
write(*,*)'result=',result,' analytically=',rr
write(*,*)
write(*,*)
end
c
SUBROUTINE TRAPER (X,Y,N,AA,BB,RE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION X(N),Y(N)
DATA ZERO/0.D0/
C
RE=ZERO
SD=ZERO
IF(AA .EQ. BB .OR. N .LT. 2) RETURN
A=AA
B=BB
IF(AA .LT. BB) GO TO 1
A=BB
B=AA
1 CONTINUE
DO 40 I1 = 2,N
I=I1
IF(X(I) .GE. A) GO TO 41
40 CONTINUE
41 CONTINUE
DO 42 J1 = 2,N
J=J1
IF(X(J) .GE. B) GO TO 43
42 CONTINUE
43 WI1=(X(I)-A)**2/(X(I)-X(I-1))
WI=(1.0D0+(A-X(I-1))/(X(I)-X(I-1)))*(X(I)-A)
WJ1=(1.0D0+(X(J)-B)/(X(J)-X(J-1)))*(B-X(J-1))
WJ=(B-X(J-1))**2/(X(J)-X(J-1))
IF(I .NE. J) GO TO 2
WI1=WI1+WJ1+X(I-1)-X(I)
WI=WI+WJ+X(I-1)-X(I)
WJ1=ZERO
WJ =ZERO
GO TO 10
2 IF(I .NE. J-1) GO TO 3
WI=WI+WJ1
WJ1=ZERO
GO TO 10
3 WI=WI+X(I+1)-X(I)
WJ1=WJ1+X(J-1)-X(J-2)
IF(I .EQ. J-2) GO TO 10
LI=I+1
LJ=J-2
DO 4 L = LI,LJ
RE=RE+(X(L+1)-X(L-1))*Y(L)
4 CONTINUE
10 RE=RE+WI1*Y(I-1)+WI*Y(I)+WJ1*Y(J-1)+WJ*Y(J)
RE=0.5D0*RE
IF(AA .GT. BB) RE=-RE
C
RETURN
END