Silverfrost FTN95, Programma written in Fortran and giving error 299

  • Context: Fortran 
  • Thread starter Thread starter xaria181
  • Start date Start date
  • Tags Tags
    Error Fortran
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 6K views
xaria181
Messages
3
Reaction score
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
 
Physics news on Phys.org
Probably move the PARAMETER and DIMENSION statements before the OPEN statement.
 
Well,it's giving exactly the same error 299 for the next line,which is dimension x(n),y(n)...
 
Reorder the first few lines of your program like so:
Code:
program intergrate
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
parameter (n=100001)
dimension x(n),y(n)

open(10,file="500Ktr.rox")
.
.
.
The compiler is telling you that declarations, such as the parameter and dimension statements, have to occur before any executable statements, such as open(...)

BTW, "intergrate" is not a word in English. The compiler won't care, but you should.
 
Thanks a lot for your advice...!I'll try for it! :smile: