|||
FORTRAN中的数组声明可以有如下几种类型:Explicit-shape Array, Assumed-shape Array, Assumed-size Array, and Deferred-size Array
Explicit-shape array: An explicit-shape array is declared with explicit values for the bounds in each dimension of the array(显式指定数组各维的上下界).
Both automatic array and adjustable array are explicit-shape arrays.
Automatic Array: an automatic array is an explicit shape array that is a local variable. Automaticarrays are only allowed in function and subroutine subprograms, and are declared in the specification part of the subprogram. At least one bound of an automatic array must be a nonconstant specification expression. The bounds are determined when the subprogram is called.(自动数组是子程序的局地变量,在子程序内部声明,数组维数中至少一维由子程序的参数传递获得,其他维可在子程序中指定)
Adjustable Array: an adjustable array is an explicit shape array that is a dummy argument to a subprogram. At least one bound of an adjustable array must be a nonconstant specification expression. The bounds are determined when the subprogram is called.(局地可调数组是子程序的传递参数之一,同时可调数组维数中至少一维由子程序参数传递获得)
Assumed-shape array: an assumed-shape array is a dummy argument array that assumes the shape of its associated actual argument array(假定形状数组通常在子程序内部声明,指定维数/rank,但不指定维的大小).
Assumed-size array: an assumed-size array is a dummy argument array that assumes the size (only) of its associated actual argument array; the rank and extents can differ for the actual and dummy arrays(假定大小数组通常在子程序中声明,可以指定1维或多维的大小).
Deferred-shape array: a deferred-shape array is an array pointer or an allocatable array(递延形状数组指数组指针或可分配数组,数组的维数和各维大小在指针赋值时或使用allocate语句时获得).
不同类型数组的存储结构不一样,比如Local Adjustable Array是stack array(栈型数组),而Deferred-shape array就是heap array (堆型数组)。stack的大小具有平台依赖性,因此程序中出现较大的局部数组时,可能会出现“segmentation fault”(即所谓的栈溢出,stack overflow),此时要么人为增加系统栈大小,要么将数组存储结构更改为堆结构。同时,两种数据结构在存取效率等多方面具有显著差异。
可参考:
[1] http://metman.info/blog/2013/08/12/fortransheng-ming-shu-zu-guo-da-wen-ti-jie-jue-ban-fa/
[2] http://metman.info/blog/2013/05/31/segmentation-faultchan-sheng-gen-ben-yuan-yin/
[3] http://bbs.csdn.net/topics/390147637
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-28 18:28
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社