×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • 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.

Students Click Here

Problem with Simpson's Rule Function

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! bigears

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.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close