Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Euler Method in Fortran - HELP

  1. Oct 30, 2008 #1
    Euler Method in Fortran - HELP!!

    Using Euler method I want to calculate the equation below, deltat=0.3, 10 times.

    Problem: When n=1, Yn1(1) is calculated right. But, in the following steps it should assume that Yn(2)=Yn1(1) and the program is assuming Yn(2)=0, as well as Yn(3)=0,...and so on
    Please, can someone help me?

    Program Exercise1
    ! This Program will solve the ODE bellow using Euler Method ...
    ! dy(t)
    ! ______ = 2y(t) + t^2 + t
    ! dt
    ! Declaration of Variables
    Implicit none
    Real:: deltat1

    Integer:: ts1,n,time
    Real:: Yn1(1:11),Yn(1:11),tn(1:11)

    do n=1,ts1


    write (*,*) Yn1(n)



  2. jcsd
  3. Oct 30, 2008 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Re: Euler Method in Fortran - HELP!!

    first move the assignment statements for deltat and ts1 outside of your loop. You also have not initialize tn(0).

    I am very uneasy with your incrementing your time variable in step with the Euler method iterations.

    I think you should put the Euler loop inside of a time step loop. So you want to iterate a Euler loop at EACH time step.

    You may want to look closely at the result of your time step calculation, is it producing what you want it to?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook