主题:[讨论]【基本功训练 02】数组作为形参的问题
Intel Fortran 11.1 帮助文档中有如下例子:
Fortran-specific Analysis
The source checker is able to detect issues with the following:
Mismatched type, rank, shape, or/and size of an argument
Incorrect usage of ALLOCATABLE arrays
Inconsistency in COMMON blocks
The following example illustrates Fortran-specific analysis.
subroutine foo(m)
implicit none
integer:: i ! for loop
integer:: m(2, 3)
do i = 1, 3
write(*, *) m(:,i)
end do
return
end subroutine
program main
implicit none
integer:: i
integer:: n(3, 2)
do i=1, 2
n(:, i) = i
end do
call foo(n)
! shapes of argument #1 and dummy argument are different.
do i = 1, 2
write(*, *) n(:,i)
end do
stop
end program main
但很遗憾,IVF11.1 并不能给出警告信息,您有什么办法呢?
可以从程序(修改代码)和编译器(修改编译器选项)两个方面来谈谈。
Fortran-specific Analysis
The source checker is able to detect issues with the following:
Mismatched type, rank, shape, or/and size of an argument
Incorrect usage of ALLOCATABLE arrays
Inconsistency in COMMON blocks
The following example illustrates Fortran-specific analysis.
subroutine foo(m)
implicit none
integer:: i ! for loop
integer:: m(2, 3)
do i = 1, 3
write(*, *) m(:,i)
end do
return
end subroutine
program main
implicit none
integer:: i
integer:: n(3, 2)
do i=1, 2
n(:, i) = i
end do
call foo(n)
! shapes of argument #1 and dummy argument are different.
do i = 1, 2
write(*, *) n(:,i)
end do
stop
end program main
但很遗憾,IVF11.1 并不能给出警告信息,您有什么办法呢?
可以从程序(修改代码)和编译器(修改编译器选项)两个方面来谈谈。