fortran双精度的准确性

时间:2018-05-22 19:43:47

标签: fortran double

当我创建epsilons然后将它们写入具有其他值的文件时,我有这个代码。问题是我在文件中得到的epsilons值与原件不是很接近。 这是代码

open(unit=3,file='Avner_Yakov_4_q3.txt')
    v0 = 38 ! 85 mph
    t_max = x_max/v0;
    h = 0.1
    phi = pi/4
    write(3,*) 'calc  order    eps       delta-y      delta-z   mone-f'
    write(3,*) '------------------------------------------------------'
    eps1 = (/ 1d-1, 1d-3, 1d-5, 1d-7 /)
    do i=1,4
        r = solve_ball(h, t_max, eps1(i), v0, phi,'rk2')
        z_max(2) = r(3,ubound(r,2))
        y_max(2) = r(2,ubound(r,2))
        write(3,"(1i3,1i7,3E12.2,1i6)") i, 2, eps1(i), abs(y_max(2)-y_max(1)), abs(z_max(2)-z_max(1)), ubound(r,2)
     !deallocate (r)
    end do
    do i=1,4
        r = solve_ball(h, t_max, eps1(i), v0, phi,'rk3')
        z_max(2) = r(3,ubound(r,2))
        y_max(2) = r(2,ubound(r,2))
        write(3,"(1i3,1i7,3E12.2,1i6)") i+4, 3, eps1(i), abs(y_max(2)-y_max(1)), abs(z_max(2)-z_max(1)), ubound(r,2)
    !  deallocate (r)
    end do
    close(unit=3)

输出

calc  order    eps       delta-y      delta-z   mone-f
 ------------------------------------------------------
  1      2    0.99E-01    0.14E-01    0.74E-01     5
  2      2    0.59E-03    0.19E-01    0.10E+00     7
  3      2    0.42E-05    0.91E-02    0.48E-01    50
  4      2    0.24E-07    0.61E-03    0.32E-02   476
  5      3    0.99E-01    0.34E-01    0.18E+00    28
  6      3    0.59E-03    0.24E-01    0.13E+00     8
  7      3    0.22E-05    0.77E-02    0.41E-01    10
  8      3    0.84E-08    0.45E-02    0.24E-01    50

0 个答案:

没有答案