是否有可能将复杂数组的实部传递给Fortran中的子程序而不将实部存储在另一个数组中并传递给它?例如代替
Z = complex array; X = real(Z) call foo(X)
请执行下列操作
Z = complex array call foo(real(Z))
这给了我一个编译错误!我正在使用intel编译器ifort .
当然,它有效:
module testmod implicit none integer, parameter :: dp = kind(1.0d0) contains subroutine realsub(array) real(dp), intent(in) :: array(:) print *, array end subroutine realsub end module testmod program testprog use testmod implicit none complex(dp) :: array(3) array(:) = [ (1.0_dp, 1.0_dp), (3.0_dp, 2.0_dp), (-1.0_dp, 3.0_dp) ] call realsub(real(array)) end program testprog
1 回答
当然,它有效: