# Group five, parabolic, explicit

From Interactive System for Ice sheet Simulation

Revision as of 12:42, 5 August 2009 by Brian anderson (Talk | contribs)

program main implicit none real, parameter :: dx = 0.1, dt = 0.005125, tend = 1.025, pi=3.1415926 integer :: Nx, Nt, n real, allocatable :: x(:), u(:,:) integer :: i ! size of time and space domain Nt=floor(tend/dt)+1 Nx=floor(1/dx)+1 allocate(u(Nx,Nt),x(Nx)) ! x domain ! initial condition do i=1,Nx x(i) = (i-1) * dx u(i,1) = sin (pi * x(i)) enddo do n=1,Nt-1 do i=2,Nx-1 u(i,n+1) = u(i,n)+dt/dx/dx*(u(i-1,n)-2*u(i,n)+u(i+1,n)) enddo write (*,*) (u(i,n),i=1,Nx) enddo end program