输入子程序时出现分段错误。 在调试器中,我可以执行下列代码段中的第一个call RK_sub_step
。 一旦进入子程序,就会发生段错误。进入Fortran子程序时出现Segfault错误
module RK_mod
type(MyType), dimension(1:2) :: q0, q1, q2
contains
subroutine RK_sub_step(src, alpha, dest)
real(8), dimension(:) :: alpha
type(MyType), dimension(1:2,size(alpha)) :: src
type(MyType), dimension(1:2), intent(inout) :: dest
! compute dest from alpha and src
end subroutine
subroutine RK()
real(8) alpha(3)
call RK_sub_step((/q0/), (/alpha(1)/), q1) ! <- Segfault here
call RK_sub_step((/q0, q1/), alpha(2:3), q2)
end subroutine
end module
任何想法我可能做错了什么?
编辑:
现在我设法绕过通过创建独立的子程序的段错误,我可以打电话为
call RK_sub_step1(q0, alpha(1), q1)
call RK_sub_step2(q0, q1, alpha(2:3), q2)
call RK_sub_step4(q0, q1, q2, q3, alpha(4:8), q0)
但我仍然不知道,如果有可能只有一个像上面进一步子程序,或者为什么这是不可能的。