* Sample program for gtool_history/gtool5        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 )                       ! ã‚°ãƒªãƒƒãƒ‰æ•°
        parameter( nt=200 )                      ! æ™‚é–“ã‚¹ãƒ†ãƒƒãƒ—æ•°
        parameter( ndisp=10 )                    ! å‡ºåŠ›é–“éš”
      double precision  dx, dt, kappa
        parameter( dx=1.0/(nx-1))                ! ã‚°ãƒªãƒƒãƒ‰é–“éš”
        parameter( dt=0.0005 )                   ! æ™‚é–“é–“éš”
        parameter( kappa=1.0D0 )                 ! ç†±æ‹¡æ•£ä¿‚æ•°
      double precision x(nx)                     ! åº§æ¨™å¤‰æ•°
      double precision temp(nx), temp1(nx)       ! æ¸©åº¦

      integer i,it                               ! ä½œæ¥å¤‰æ•°

      do i=1,nx
        x(i)=dx*(i-1)                            ! åº§æ¨™å€¤è¨å®š
      enddo

      do i=1,nx
        temp(i) = exp(-((x(i)-0.5)/0.1)**2)      ! åˆæœŸå€¤è¨å®š
      enddo

      do it=1,nt                                 ! æ™‚é–“ç©åˆ†
         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                      ! å¤‰æ•°å‡ºåŠ›
            write(6,*)temp                       ! å¤‰æ•°å‡ºåŠ›
         endif
      enddo

      stop
      end