Group2 Convection Exercise

From Interactive System for Ice sheet Simulation
Jump to: navigation, search
	program convection
 
	implicit none
 
	real, parameter :: dt = 0.005
	real, parameter :: dx = 0.01
	real, parameter :: tend = 4.0
	real, parameter :: xend = 10.0
	real, dimension(int(tend/dt)+1) :: sumu 
	integer :: intt = int(tend/dt)
	integer :: intx = int(xend/dx)
	real, dimension(int(tend/dt)+1,int(xend/dx)+1)  :: u, uExact, uDiff
	integer :: t,i
	real, dimension(int(xend/dx)+1)::xarr=(/((t-1)*dx,t=1,int(xend/dx)+1)/)
	real, parameter :: v = 1.0
 
	u(:,:) = 0
	where(xarr.ge.4.5.and.xarr.le.5.5)
		u(1,:)=1
	end where
	sumu(1) = sum(u(1,:))
!	write (*,*) u(1,:)
 
	do t=2, intt+1
		u(t,1)=0.
		u(t,2:intx)=0.5*(u(t-1,3:intx+1)+u(t-1,1:intx-1)) &
			-v*dt*(u(t-1,3:intx+1)-u(t-1,1:intx-1))/(2*dx)
!		write (*,*) u(t,:)
		sumu(t) = sum(u(t,:))
	end do
	write (*,*) sumu
	end program