以下 Fortran 代码有什么问题? (gfortran) (1) 处的 DTIO 虚拟参数必须是一个假定形状数组
What's wrong with the following Fortran code? (gfortran) DTIO dummy argument at (1) must be an ASSUMED SHAPE ARRAY
我有以下代码:
module scheme
type, abstract :: scheme_object
contains
procedure, pass :: generic_scheme_print => print_scheme_object
generic, public :: write (formatted) => generic_scheme_print
end type scheme_object
abstract interface
subroutine packageable_procedure( )
import scheme_object
end subroutine packageable_procedure
end interface
contains
subroutine print_scheme_object(this, unit, iotype, v_list, iostat, iomsg)
class(scheme_object), intent(in) :: this
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list (:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
iostat = 1
end subroutine print_scheme_object
subroutine packaged_cons( )
end subroutine packaged_cons
function make_primitive_procedure_object( proc1 ) result( retval )
class(scheme_object), pointer :: retval
procedure(packageable_procedure), pointer :: proc1
end function make_primitive_procedure_object
subroutine ll_setup_global_environment()
procedure(packageable_procedure), pointer :: proc1
class(scheme_object), pointer :: proc_obj_to_pack
proc1 => packaged_cons
proc_obj_to_pack => make_primitive_procedure_object( proc1 )
end subroutine ll_setup_global_environment
end module scheme
program main
end program main
这段代码在 ifort 19.1.1.217 20200306 上编译良好,运行但什么也不做(如预期的那样)。
但是,使用 gfortran 编译它失败并显示一条神秘的错误消息:
16 | subroutine print_scheme_object(this, unit, iotype, v_list, iostat, iomsg)
| 1
Error: DTIO dummy argument at (1) must be an ASSUMED SHAPE ARRAY
将 "v_list" 声明的长度更改为任何整数会产生两条相同的消息:
16 | subroutine print_scheme_object(this, unit, iotype, v_list, iostat, iomsg)
| 1
Error: DTIO dummy argument at (1) must be an ASSUMED SHAPE ARRAY
16 | subroutine print_scheme_object(this, unit, iotype, v_list, iostat, iomsg)
| 1
Error: DTIO dummy argument at (1) must be an ASSUMED SHAPE ARRAY
问题出在哪里?
我不确定这是否是一个正确的答案,但是...
您的代码是正确的,但暴露了特定编译器中的错误。
我有以下代码:
module scheme
type, abstract :: scheme_object
contains
procedure, pass :: generic_scheme_print => print_scheme_object
generic, public :: write (formatted) => generic_scheme_print
end type scheme_object
abstract interface
subroutine packageable_procedure( )
import scheme_object
end subroutine packageable_procedure
end interface
contains
subroutine print_scheme_object(this, unit, iotype, v_list, iostat, iomsg)
class(scheme_object), intent(in) :: this
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list (:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
iostat = 1
end subroutine print_scheme_object
subroutine packaged_cons( )
end subroutine packaged_cons
function make_primitive_procedure_object( proc1 ) result( retval )
class(scheme_object), pointer :: retval
procedure(packageable_procedure), pointer :: proc1
end function make_primitive_procedure_object
subroutine ll_setup_global_environment()
procedure(packageable_procedure), pointer :: proc1
class(scheme_object), pointer :: proc_obj_to_pack
proc1 => packaged_cons
proc_obj_to_pack => make_primitive_procedure_object( proc1 )
end subroutine ll_setup_global_environment
end module scheme
program main
end program main
这段代码在 ifort 19.1.1.217 20200306 上编译良好,运行但什么也不做(如预期的那样)。
但是,使用 gfortran 编译它失败并显示一条神秘的错误消息:
16 | subroutine print_scheme_object(this, unit, iotype, v_list, iostat, iomsg)
| 1
Error: DTIO dummy argument at (1) must be an ASSUMED SHAPE ARRAY
将 "v_list" 声明的长度更改为任何整数会产生两条相同的消息:
16 | subroutine print_scheme_object(this, unit, iotype, v_list, iostat, iomsg)
| 1
Error: DTIO dummy argument at (1) must be an ASSUMED SHAPE ARRAY
16 | subroutine print_scheme_object(this, unit, iotype, v_list, iostat, iomsg)
| 1
Error: DTIO dummy argument at (1) must be an ASSUMED SHAPE ARRAY
问题出在哪里?
我不确定这是否是一个正确的答案,但是...
您的代码是正确的,但暴露了特定编译器中的错误。