×
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

Rungen-Kutta 4 order method. Severe 161: Array bounds exceeded.

Rungen-Kutta 4 order method. Severe 161: Array bounds exceeded.

Rungen-Kutta 4 order method. Severe 161: Array bounds exceeded.

(OP)
So here I am trying to solve Rayleigh's differential equation using Rungen-Kutta 4th order analytic method.

This is what the exercise gives me: X(0 to 40), Y1(0)=0.1, Y2(0)=0, H=0.1, μ=0.5

This is what I ve written and gives me this error:

CODE -->

IMPLICIT REAL*8(A-K,O-Z)
	DIMENSION X(401)
	DIMENSION Y1(401)
	DIMENSION Y2(401)

	
	F2(X,Y1,Y2)=0.5D0*Y2-(0.5D0/3.0D0*(Y2**3))-Y1

	H=0.1D0
	X(0)=0
	Y1(0)=0.01D0
	Y2(0)=0


	DO I=1,400
	X(I)=X(I-1)+H
	END DO


	DO I=0,400

	K1=H*Y2(I)
	L1=H*F2(X(I),Y1(I),Y2(I))
	K2=H*(Y2(I)+L1/2.0D0)
	L2=H*F2(X(I)+H/2.0D0,Y1(I)+K1/2.0D0,Y2(I)+L1/2.0D0)
	K3=H*(Y2(I)+L2/2.0D0)
	L3=H*F2(X(I)+(H/2.0D0),Y1(I)+(K2/2.0D0),Y2(I)+(L2/2.0D0))
	K4=H*(Y2(I)+L3)
	L4=H*F2(X(I)+H,Y1(I)+K3,Y2(I)+L3)
	
	Y1(I+1)=Y1(I)+(1.0D0/6.0D0)*(K1+2.0D0*K2+2.0D0*K3+K4)
	Y2(I+1)=Y2(I)+(1.0D0/6.0D0)*(K1+2.0D0*K2+2.0D0*K3+K4)
	END DO
	
	WRITE(*,30)X(I),Y1(I),Y2(I)
30	FORMAT(2X,F8.6,2X,F8.6,2X,F8.6)
	

	STOP
	END 

Any ideas why am I exceeding array bounds?

RE: Rungen-Kutta 4 order method. Severe 161: Array bounds exceeded.

By default, Fortran arrays begin from 1. You need to change the array declarations

CODE

DIMENSION X(0:400)
	DIMENSION Y1(0:400)
	DIMENSION Y2(0:400) 

RE: Rungen-Kutta 4 order method. Severe 161: Array bounds exceeded.

(OP)
Thank you man, it worked!
Kudos to you, much appreciated!

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