Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Simpson's Rule Function

Status
Not open for further replies.

AeroTrippy

Technical User
Dec 3, 2013
1
US
hey guys,
I have been racking my brain about this, so hopefully you can help me out a bit. This is my function for Simpson's 3/8 rule.


REAL FUNCTION Simpson38(v,h,n)

IMPLICIT NONE

REAL :: s1, s2, s3
REAL, INTENT(in) :: v,h
INTEGER, INTENT(in) :: n
INTEGER :: i,j,k
[highlight #FCE94F]REAL, DIMENSION :: (0:n)[/highlight]


s1=0
s2=0
s3=0


DO i=1,(n-2),3

s1=s1+v(i)

END DO


DO j=2,(n-1),3

s2=s2+v(j)

END DO


DO k=3,(n-3),3

s3=s3+v(k)

END DO

Simpson38= (3*h/8)*(v(0)+3*(s1)+3*(s2)+2*(s3)+v(n))


END FUNCTION

The highlighted part is what I am confused about. My TA told me to insert this line but it keeps giving me error#5082: Syntax error, found '(' when expecting one of: %FILL <IDENTIFIER>

The purpose of the program is to be able to read any data file and depending on the number of points it will either use this function or Simpson's 1/3. Any idea what goes in that line? Any help is greatly appreciated! If you need any more info, let me know! [bigears]

Thanks!
 
Try replacing your declarations with this.
Code:
INTEGER, INTENT(in) :: n
REAL, INTENT(in) :: h
REAL, DIMENSION(0:n) :: v

INTEGER :: i,j,k
REAL :: s1, s2, s3
I like declaring first the arguments passed to the function and THEN the variables local to the function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top