×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Problem with Simpson's Rule Function

## Problem with Simpson's Rule Function

(OP)
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
REAL, DIMENSION :: (0:n)

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!

Thanks!

### RE: Problem with Simpson's Rule Function

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

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!