我正在尝试以下代码,它只是添加了两个数组构造函数来获取一维数组。但是,根据这些表达式中是否使用one
(隐含的DO循环外部),gfortran-5.3对于(1),(3)和(6)的结果不正确。另一方面,ifort-14.0和Sun fortran 8.7给出了所有病例的正确结果。奇怪的是,如果我尝试一个类似但更复杂的表达式,甚至Sun fortran开始表现得很奇怪(即,它在编译时会被冻结......)所以我想知道我是否在这些表达式中使用了一些错误或危险的语法。任何的想法...? (顺便说一句,如果我在两者之间只留下一个构造函数,它们总是按预期工作。)
program main
implicit none
integer :: k
integer, dimension(2), parameter :: zero = [0,0], one = [1,1]
integer, parameter :: N = 1
print *, [ one, ( zero, k=1,N) ] + [ ( zero, k=1,N), one ] !! (1)
print *, [ [1, 1], ( zero, k=1,N) ] + [ ( zero, k=1,N), [1, 1] ] !! (2)
print *, [ one, ([0, 0],k=1,N) ] + [ ([0, 0],k=1,N), one ] !! (3)
print *, [ [1, 1], ([0, 0],k=1,N) ] + [ ([0, 0],k=1,N), [1, 1] ] !! (4)
print *, [ 1, 1, ( 0, 0, k=1,N) ] + [ ( 0, 0, k=1,N), 1, 1 ] !! (5)
print *, [ one, ( 0, 0, k=1,N) ] + [ ( 0, 0, k=1,N), one ] !! (6)
print *, [ (one, k=1,1), (zero, k=1,N) ] + [ (zero, k=1,N), (one, k=1,1) ] !! (7)
endprogram
ifort14.0和Sun Fortran 8.7的结果:
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
gfortran-5.3的结果:
1 1 0 1
1 1 1 1
1 1 0 1
1 1 1 1
1 1 1 1
1 1 0 1
1 1 1 1
答案 0 :(得分:1)
使用关联构造
时,结果与预期一致<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng:app="myApp">
<div ng-controller="HelloCntl">
<ul>
<li ng-repeat="friend in friends">
<span>{{friend.name | customFilter}}</span>
<span>{{friend.phone}}</span>
</li>
</ul>
</div>
</div>
使用GNU Fortran(Debian 5.3.1-14)5.3.1 20160409我得到
program main
use, intrinsic :: iso_fortran_env, only: &
compiler_version, &
compiler_options
implicit none
integer :: k
!integer, dimension(2), parameter :: zero = [0,0], one = [1,1]
integer, parameter :: N = 1
associate( zero => [0,0], one => [1,1] )
print *, [ one, ( zero, k=1,N) ] + [ ( zero, k=1,N), one ] !! (1)
print *, [ [1, 1], ( zero, k=1,N) ] + [ ( zero, k=1,N), [1, 1] ] !! (2)
print *, [ one, ([0, 0],k=1,N) ] + [ ([0, 0],k=1,N), one ] !! (3)
print *, [ [1, 1], ([0, 0],k=1,N) ] + [ ([0, 0],k=1,N), [1, 1] ] !! (4)
print *, [ 1, 1, ( 0, 0, k=1,N) ] + [ ( 0, 0, k=1,N), 1, 1 ] !! (5)
print *, [ one, ( 0, 0, k=1,N) ] + [ ( 0, 0, k=1,N), one ] !! (6)
print *, [ (one, k=1,1), (zero, k=1,N) ] + [ (zero, k=1,N), (one, k=1,1) ] !! (7)
end associate
print *, 'This result was compiled by ', &
compiler_version(), ' using the options ', &
compiler_options()
end program