Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/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

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
Oop fortran中作为对象属性的数组-是否禁用协数组?_Oop_Fortran_Fortran90 - Fatal编程技术网

Oop fortran中作为对象属性的数组-是否禁用协数组?

Oop fortran中作为对象属性的数组-是否禁用协数组?,oop,fortran,fortran90,Oop,Fortran,Fortran90,我正在使用GNU gfortran(gfortran-v4.8.2),在使用数组作为对象属性时遇到了问题。我的意思是: type test_type real*8 test_array(10,20) end type test_type type (test_type) example_test_type 稍后,当我尝试分配test_数组的元素时: example_test_type%test_array[0,1] = 99 编译器抱怨(致命错误): 致命错误:在(1)处禁用协同阵列

我正在使用GNU gfortran(gfortran-v4.8.2),在使用数组作为对象属性时遇到了问题。我的意思是:

type test_type
  real*8 test_array(10,20)
end type test_type

type (test_type) example_test_type
稍后,当我尝试分配test_数组的元素时:

example_test_type%test_array[0,1] = 99 
编译器抱怨(致命错误):

致命错误:在(1)处禁用协同阵列,使用-fcoarray=启用

据我所知,coarray是为促进对并行编程的支持而设计的,我在这里绝对不想这样做


有什么想法吗?

您在这句话中使用了错误类型的括号/大括号/括号(圈出一个):

example_test_type%test_array[0,1] = 99 
应该是哪一个

example_test_type%test_array(0,1) = 99 
[]
用于将co索引指定到co数组中,因此会出现令人困惑的错误消息


接下来,引用数组的元素
(0,1)
时会出现问题,因为默认情况下,Fortran索引从1开始。

在此语句中使用了错误类型的括号/大括号/圆括号(圈一):

example_test_type%test_array[0,1] = 99 
应该是哪一个

example_test_type%test_array(0,1) = 99 
[]
用于将co索引指定到co数组中,因此会出现令人困惑的错误消息


接下来,您将遇到引用数组元素
(0,1)
的问题,因为默认情况下,Fortran索引从1开始。

对于这样的问题,我唯一的意见是在继续编程之前购买并阅读它。几乎不必购买Metcalf&Reid(尽管它很有用);仔细阅读类型声明可能会给您带来启示。也许会对您有所帮助。对于这样的问题,我唯一的意见是在继续编程之前购买并阅读它。几乎没有必要购买Metcalf&Reid(尽管它很有用);仔细阅读类型声明可能会给你带来启示。也许会对你有所帮助。啊!是的,似乎有固定的东西。我的问题是,编译器说除非我通过这个-fcoarray标志,否则不允许使用coarray。通过更改此语法,我是否仍在使用coarray?为什么编译器没有抱怨?不,如果您没有使用
[]
对表达式进行索引,则无论您是否指定了co-array编译选项,您都没有使用co-array。遵循@KyleKanos的建议或搜索其他最新的Fortran参考。啊!是的,似乎有固定的东西。我的问题是,编译器说除非我通过这个-fcoarray标志,否则不允许使用coarray。通过更改此语法,我是否仍在使用coarray?为什么编译器没有抱怨?不,如果您没有使用
[]
对表达式进行索引,则无论您是否指定了co-array编译选项,您都没有使用co-array。遵循@KyleKanos的建议或搜索其他最新的Fortran参考。