code31.f90
来自「Fortran 90 and HPF Programs Related to t」· F90 代码 · 共 47 行
F90
47 行
!!!!!!!!!!!!!!!!!!!!!!!!!!! Program 3.1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! Please Note: !! !! (1) This computer program is written by Tao Pang in conjunction with !! his book, "An Introduction to Computational Physics," published !! by Cambridge University Press in 1997. !! !! (2) No warranties, express or implied, are made for this program. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!PROGRAM ONE_D_MOTION2!! Simplest predictor-corector algorithm applied to a particle in one! dimension under an elastic force. Copyright (c) Tao Pang 1997.! IMPLICIT NONE INTEGER, PARAMETER :: N=101,IN=5 INTEGER :: I REAL :: PI,DT REAL, DIMENSION (N) :: T,V,X! PI = 4.0*ATAN(1.0) DT =2.0*PI/100 X(1)=0.0 T(1)=0.0 V(1)=1.0! DO I = 1, N-1 T(I+1) = I*DT!! Predictor for position and velocity! X(I+1) = X(I)+V(I)*DT V(I+1) = V(I)-X(I)*DT!! Corrector for position and velocity! X(I+1) = X(I)+(V(I)+V(I+1))*DT/2.0 V(I+1) = V(I)-(X(I)+X(I+1))*DT/2.0 END DO WRITE(6,"(3F16.8)") (T(I),X(I),V(I),I=1,N,IN)END PROGRAM ONE_D_MOTION2
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?