7. 1次元配列を用いた3次元の線図



ソースプログラム(Fortran 90,自動倍精度利用)
!******************************** ! 3D Graphic Sample No. 2 * ! 3D Line Draw * !******************************** module parm real sig,r,b end module parm program gsample7 use parm implicit none integer, parameter :: nmax = 5000 real xs(0:nmax),ys(0:nmax),zs(0:nmax) real f(3),t,dt real xmin,xmax,ymin,ymax,zmin,zmax integer i xmin = -20 xmax = 20 ymin = -20 ymax = 20 zmin = 0.0 zmax = 40.0 dt = 0.01 sig = 10 r = 28 b = 8.0/3.0 t = 0 xs(0) = 0.1 ys(0) = 0.1 zs(0) = 0.1 f(1) = xs(0) f(2) = ys(0) f(3) = zs(0) do i = 1, nmax call rkh4(3,t,dt,f) xs(i) = f(1) ys(i) = f(2) zs(i) = f(3) enddo call fr_ginit call fr_opencanvas(1,'gsample7',101) call fr_project(5.0,1) call fr_margin3d(10,20,10,80) call fr_angle3d(35.0,30.0) call fr_aspect3d(1.0,1.0,1.0,1) call fr_frame3d(xmin,xmax,ymin,ymax,zmin,zmax,3) call fr_xyzname('xxx','yyy','zzz') call fr_graph3d(xs,ys,zs,nmax+1,2,1) call fr_gend end program gsample7 subroutine equat(x,f,df) use parm implicit none real x,f(3),df(3) df(1) = sig*(f(2) - f(1)) df(2) = (r - f(3))*f(1) - f(2) df(3) = f(1)*f(2) - b*f(3) end subroutine equat ! 4th Order Runge-Kutta Integrator subroutine rkh4(n,x,h,y) implicit none integer, parameter :: nm = 3 real, parameter :: c16 = 0.16666666666666667 real y(*),z(nm),k1(nm),k2(nm),k3(nm),k4(nm) real x,h integer n,i call equat(x,y,k1) do i = 1, n z(i) = y(i) + 0.5*h*k1(i) enddo call equat(x+0.5*h,z,k2) do i = 1, n z(i) = y(i) + 0.5*h*k2(i) enddo call equat(x+0.5*h,z,k3) do i = 1, n z(i) = y(i) + h*k3(i) enddo x = x + h call equat(x,z,k4) do i = 1, n y(i) = y(i) + c16*h*(k1(i) + 2.0*(k2(i) + k3(i)) + k4(i)) enddo end subroutine rkh4


Copyright (C) Toshihiro Taguchi, Setsunan University, 2000-2012 All rights reserved.