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
Click For Summary

Discussion Overview

The discussion revolves around a Fortran program that is generating an error 299, specifically related to the ordering of statements in the code. Participants are exploring the implications of the error and suggesting potential solutions to reorder the statements correctly.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes encountering an error 299 at a specific line in their Fortran program, indicating a statement ordering issue with the PARAMETER statement.
  • Another participant suggests moving the PARAMETER and DIMENSION statements before the OPEN statement to resolve the error.
  • A different participant notes that the same error occurs for the DIMENSION statement, implying that the ordering issue persists.
  • Further advice is provided to reorder the initial lines of the program to ensure that declarations precede executable statements.
  • One participant comments on the spelling of "intergrate," noting it is not a word in English, although this is not relevant to the compiler's function.
  • A participant shares a reference for Fortran programming, which may assist others in understanding the language better.

Areas of Agreement / Disagreement

Participants generally agree on the need to reorder the statements to resolve the error, but there is no consensus on the effectiveness of the proposed solutions, as one participant continues to encounter the same error after attempting the suggestions.

Contextual Notes

The discussion highlights the importance of statement ordering in Fortran, particularly the requirement that declaration statements must precede executable statements. However, specific assumptions about the program's structure and other potential errors are not fully explored.

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:
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 22 ·
Replies
22
Views
5K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K