Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.mrao.cam.ac.uk/~rachael/compphys/examples/euler.f90
Дата изменения: Tue Oct 18 17:08:16 2005
Дата индексирования: Tue Oct 2 10:48:25 2012
Кодировка:

Поисковые слова: вторая космическая скорость
! Program to demonstrate the Euler method on
! dy/dx = y over the interval [0,1]

program euler

implicit none

integer, parameter :: n = 10 ! number of divisions
integer, parameter :: dp = kind(1.0d0) ! kind for double precision
integer :: i ! loop counter
real(dp) :: x, y, h ! integration variables

! interval spacing
h = 1.0_dp / n

! initial condition y(0) = 1
y = 1.0_dp

! open file for results
open(10,file='euler.dat')

! perform Euler method
do i = 0, n
x = i * h
write(10,*) x, y
y = y + h * f(x,y)
end do

! close file
close(10)

contains

! this function provides the value of dybydx at (x,y)
real(dp) function f(x,y)

real(dp), intent(in) :: x, y

f = y

end function f

end program euler