* Sample program for gtool_history/gtool4        2001/02/27 S.Takehiro
* 
* Solving diffusion equation 
*     du/dt = kappa d^2 u/dx^2
* for giving values of u at x=0 and 1. 
*
      program diffeq

      integer nx, nt, ndisp
        parameter( nx=30 )                       ! $B%0%j%C%I?t(B
        parameter( nt=200 )                      ! $B;~4V%9%F%C%W?t(B
        parameter( ndisp=10 )                    ! $B=PNO4V3V(B
      double precision  dx, dt, kappa
        parameter( dx=1.0/(nx-1))                ! $B%0%j%C%I4V3V(B
        parameter( dt=0.0005 )                   ! $B;~4V4V3V(B
        parameter( kappa=1.0D0 )                 ! $BG.3H;678?t(B
      double precision x(nx)                     ! $B:BI8JQ?t(B
      double precision temp(nx), temp1(nx)       ! $B29EY(B

      integer i,it                               ! $B:n6HJQ?t(B

      do i=1,nx
        x(i)=dx*(i-1)                            ! $B:BI8CM@_Dj(B
      enddo

      do i=1,nx
        temp(i) = exp(-((x(i)-0.5)/0.1)**2)      ! $B=i4|CM@_Dj(B
      enddo

      do it=1,nt                                 ! $B;~4V@QJ,(B
         do i=2,nx-1
            temp1(i) = temp(i) 
     &               + kappa*(temp(i+1)-2*temp(i)+temp(i-1))
     &                   /dx**2*dt
         enddo
         do i=1,nx
            temp(i) = temp1(i)
         enddo

         if ( mod(nt,ndisp) .eq. 0 ) then
            write(6,*)it*dt                      ! $BJQ?t=PNO(B
            write(6,*)temp                       ! $BJQ?t=PNO(B
         endif
      enddo

      stop
      end
