Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Compiler errors “英特尔fortran编译错误”;此内在函数在常量表达式中无效;_Compiler Errors_Fortran_Intel Fortran - Fatal编程技术网

Compiler errors “英特尔fortran编译错误”;此内在函数在常量表达式中无效;

Compiler errors “英特尔fortran编译错误”;此内在函数在常量表达式中无效;,compiler-errors,fortran,intel-fortran,Compiler Errors,Fortran,Intel Fortran,考虑一下这个简单的程序 program main implicit none integer :: array(2,3) = transpose(reshape((/1,2,3,4,5,6/),(/ size(array, 2), size(array, 1) /))) integer i,j do i=1,2 write(*,*) array(i,:) end do end program main 使用“英特尔fortran编译器”(13.0.0版)编译时,出现错误: main.f

考虑一下这个简单的程序

program main
implicit none

integer :: array(2,3) = transpose(reshape((/1,2,3,4,5,6/),(/ size(array, 2), size(array, 1) /)))
integer i,j
do i=1,2
   write(*,*) array(i,:)
end do
end program main
使用“英特尔fortran编译器”(13.0.0版)编译时,出现错误:

main.f90(4):错误#6263:此内在函数在常量表达式中无效。[转置]

整数::数组(2,3)=转置(重塑(/1,2,3,4,5,6/),(/size(数组,2),size(数组,1/))


似乎转置不能用于常量表达式(?)。那么,有没有一种方法可以根据定义初始化数组?在我的问题中,数组相当大,因此手动转置不是一个选项。

这意味着您无法在那里定义
数组。如果你这样做

integer :: array(2,3)
integer :: i,j
array = transpose....

它将被编译。

在初始化表达式(或F2008术语中的常量表达式)中使用转置是Fortran 2003的一项功能,该编译器尚不支持

使用带有适当顺序参数的重塑是Fortran 95的一部分,由该编译器支持,可以提供与您所需的等价物:

integer :: array(2,3) = reshape([1,2,3,4,5,6], shape(array), ORDER=[2,1])

根据定义,有没有办法做到这一点?此数组作为主程序的全局变量,这似乎不允许我在模块中执行此操作。如果它没有更改,您可以将其定义为
参数
&它应该编译。