Need in solving a programm in FOTRAN

  • Thread starter Sampath Emani
  • Start date
In summary: You need to explicitly specify which variable you are inputting into.In summary, the program attempted to solve an equation, but had several errors. Friends are needed to help execute the program.
  • #1
Sampath Emani
2
0
Friends,
i have written a program in FOTRAN for solving a equation [f(x0,y0)= 2*(y**2)+5]
I'm in the learning stage of FOTRAN. So please don't mind if my program has got any silly mistakes.
Please help in executing the program.

program rungekutta


print *,' DIFFERENTIAL EQUATION WITH 1 VARIABLE OF ORDER 1'

print*,"enter the value of x0"
read*,x

print*,"enter the value of y0"
read*,y

print*,"enter the value of step size"
read*,h

print*,"solution for the equation is",rk(x0,y0,h)


call runge(m,f1,n,h,x1)

end

function rk(y) result(r)

!Example: y'=(2*y^2+5)

real y,r

r = (2*(y**2)+5)
end function rk(y)

Subroutine runge(m,f1,n,h,x1)

integer f1,i,j,m,n,h

real x,w1,w2,w3,w4,x0,y;

do i=1, m
ni = (i - 1) * f1 - 1
do j=1, f1
x = x1 + h * (n + j)
w1 = h * f(x0,y0)
w2 = h * f(x0+h/2, y0+w1/2)
w3 = h * f(x0+h/2, y0+w2/2)
w4 = h * f(x0+h, y0+w3)
x = x0 + h

x = y + (w1 + w2 + w2 + w3 + w3 + w4) / 6

end do

end do

end
 
Technology news on Phys.org
  • #2
what does the subroutine runge do for you? it is not being used anywhere.

why if function rk is declared with 1 argument, you pass 3 to it?
 
  • #3
yes sir,
i do agree. but I'm not able not correct that .
Can u help me in writing the correct step.
I took an equation (2*(y**2)+5)
i want to solve this using Runge kutta.
Thanks in advance
 
  • #4
Sampath Emani said:
Friends,
i have written a program in FOTRAN for solving a equation [f(x0,y0)= 2*(y**2)+5]
I'm in the learning stage of FOTRAN. So please don't mind if my program has got any silly mistakes.
Please help in executing the program.

program rungekutta


print *,' DIFFERENTIAL EQUATION WITH 1 VARIABLE OF ORDER 1'

print*,"enter the value of x0"
read*,x

print*,"enter the value of y0"
read*,y

print*,"enter the value of step size"
read*,h

print*,"solution for the equation is",rk(x0,y0,h)


call runge(m,f1,n,h,x1)

end

function rk(y) result(r)

!Example: y'=(2*y^2+5)

real y,r

r = (2*(y**2)+5)
end function rk(y)

Subroutine runge(m,f1,n,h,x1)

integer f1,i,j,m,n,h

real x,w1,w2,w3,w4,x0,y;

do i=1, m
ni = (i - 1) * f1 - 1
do j=1, f1
x = x1 + h * (n + j)
w1 = h * f(x0,y0)
w2 = h * f(x0+h/2, y0+w1/2)
w3 = h * f(x0+h/2, y0+w2/2)
w4 = h * f(x0+h, y0+w3)
x = x0 + h

x = y + (w1 + w2 + w2 + w3 + w3 + w4) / 6

end do

end do

end

There are at least several problems that you need to rectify.
(In future, include all the error messages with your post, along with the
source.)

1. You need "IMPLICIT NONE" in the program and in each subroutine
and function.

2. What is "f"?

3. when you invoke rk, it is with 3 arguments.
Yet the function is defined with only one dummy argument.

4. You requested the input of "x0", but you read the value into "x", etc.
 
  • #5
subroutine runge

I would first commend the individual for taking the initiative to learn and write a program in FORTRAN. It is important to note that making mistakes is a natural part of the learning process and it is through these mistakes that we can improve and refine our skills.

In order to help execute the program, I would suggest the following steps:

1. Review the code and check for any syntax errors or typos. This can be done by running the program through a compiler or using an online FORTRAN editor.

2. If there are no syntax errors, try running the program with different input values to see if it produces the expected output.

3. If the program still does not work, it would be helpful to provide more information such as the specific error message or any issues encountered during execution.

Additionally, I would recommend utilizing online resources or seeking assistance from a more experienced FORTRAN programmer to help identify any potential errors and provide guidance on how to improve the program.

In summary, learning a new programming language can be challenging, but with practice and perseverance, it is possible to overcome any mistakes and improve one's skills. I wish the individual the best of luck in their FORTRAN journey.
 

1. What is FORTRAN?

FORTRAN (short for Formula Translation) is a programming language commonly used in scientific and engineering applications. It was developed in the 1950s and is still widely used today for its efficient and reliable numerical computing capabilities.

2. Why is FORTRAN still used?

FORTRAN is still used because of its strong performance in numerical calculations and its extensive library of mathematical and scientific functions. It also has a long history and a large community of users, making it a reliable and trusted language for scientific programming.

3. What is the need for solving a program in FORTRAN?

Solving a program in FORTRAN allows for the efficient and accurate computation of complex mathematical and scientific problems. It is also useful for creating simulations and models in various fields such as physics, chemistry, and engineering.

4. How do I solve a program in FORTRAN?

To solve a program in FORTRAN, you will need to write the code using the FORTRAN syntax and compile it using a FORTRAN compiler. The resulting executable file can then be run to execute the program and obtain the desired solution.

5. What are some common challenges in solving a program in FORTRAN?

Some common challenges in solving a program in FORTRAN include dealing with complex mathematical equations, managing memory and resources efficiently, and debugging errors in the code. It is important to have a good understanding of FORTRAN and its syntax to overcome these challenges.

Similar threads

  • Programming and Computer Science
2
Replies
36
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Programming and Computer Science
Replies
7
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
876
  • Programming and Computer Science
3
Replies
89
Views
4K
  • Programming and Computer Science
Replies
7
Views
1K
Replies
3
Views
3K
Replies
1
Views
537
  • Programming and Computer Science
Replies
15
Views
1K
Back
Top