微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

数据类型的 Fortran 警告

如何解决数据类型的 Fortran 警告

我为在 Fortran 中求解一组方程(Thomas 算法)的子程序编写了主程序。这是一组简单方程的代码

Program Thomas
implicit none
integer i
integer,parameter :: n=2

real,dimension(n) :: a,b,c,d,x

a(1)=0
a(2)=0
b(1)=1
b(2)=2
c(1)=0
c(2)=0
d(1)=5
d(2)=10

call solve_tridiag(a,x,n)

do i = n-1,1,-1
  print*,x(i)
end do

end program

subroutine solve_tridiag(a,n)
  implicit none
!    a - sub-diagonal (means it is the diagonal below the main diagonal)
!    b - the main diagonal
!    c - sup-diagonal (means it is the diagonal above the main diagonal)
!    d - right part
!    x - the answer
!    n - number of equations

    integer,parameter :: r8 = kind(1.d0)

    integer,intent(in) :: n
    real(r8),dimension(n),intent(in) :: a,d
    real(r8),intent(out) :: x
    real(r8),dimension(n) :: cp,dp
    real(r8) :: m
    integer i

    ! initialize c-prime and d-prime
    cp(1) = c(1)/b(1)
    dp(1) = d(1)/b(1)
 ! solve for vectors c-prime and d-prime
     do i = 2,n
       m = b(i)-cp(i-1)*a(i)
       cp(i) = c(i)/m
       dp(i) = (d(i)-dp(i-1)*a(i))/m
     end do
 ! initialize x
     x(n) = dp(n)
 ! solve for x from the vectors c-prime and d-prime
    do i = n-1,-1
      x(i) = dp(i)-cp(i)*x(i+1)
    end do

   end subroutine solve_tridiag

当我编译程序时,我收到此警告:

warning FOR4227: argument A (number 1) in reference to procedure SOLVE_TRIDIAG from procedure THOMAS incorrect: has the wrong data type

warning FOR4227: argument B (number 2) in reference to procedure SOLVE_TRIDIAG from procedure THOMAS incorrect: has the wrong data type

warning FOR4227: argument C (number 3) in reference to procedure SOLVE_TRIDIAG from procedure THOMAS incorrect: has the wrong data type

warning FOR4227: argument D (number 4) in reference to procedure SOLVE_TRIDIAG from procedure THOMAS incorrect: has the wrong data type

warning FOR4227: argument X (number 5) in reference to procedure SOLVE_TRIDIAG from procedure THOMAS incorrect: has the wrong data type

当我运行它时,我遇到了一个运行时错误。数据类型有什么问题?以及运行时错误的原因是什么?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。