Fortran Silverfrost FTN95, Programma written in Fortran and giving error 299

  • Thread starter Thread starter xaria181
  • Start date Start date
  • Tags Tags
    Error Fortran
AI Thread Summary
The discussion centers on a Fortran programming issue where an error 299 is encountered due to the incorrect ordering of statements. The error message indicates that the PARAMETER statement cannot appear after executable statements like OPEN. To resolve this, the PARAMETER and DIMENSION statements should be moved before any executable code. Additionally, it is noted that the program name "intergrate" is misspelled, which, while not affecting the compiler, is a point of concern for clarity. A resource for transitioning from Fortran 77 to Fortran 90 is also shared for further reference.
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
 
Technology 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:
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
4
Views
2K
Replies
12
Views
1K
Replies
4
Views
2K
Replies
3
Views
2K
Replies
22
Views
5K
Replies
8
Views
4K
Replies
3
Views
2K
Back
Top