3 Assumed-shape Array 这是比较现代的数组传递方式,称为假定形状数组。 subroutine test(a) real(8),intent(in)::a(:,:) !... end subroutine test 这种传递方式不需要传递数组的大小,使用内置的size,shape函数可以直接获得数组大小,减少了参数个数。 传递的是一个数组对象,可以进行数组的整体操作。 本身有...
搜索了一下,发现答案是有的,并且Fortran 90原生支持,这被称为assumed-shape array。主程序里数组的定义不变,但不再将数组长度作为实参。被调用的子程序需要放在module中(这通常也是子程序的标准用法,是一个好习惯),然后在子程序中,可以将a声明为假定形状的数组a(:),并用size函数来得到其长度。主程序在调用sub...
!DIR$ COPY_ASSUMED_SHAPE [array[,array]… ] The COPY_ASSUMED_SHAPE directive copies assumed-shape dummy array arguments into contiguous local temporary storage upon entry to the procedure in which the directive appears. During execution, it is the temporary storage that is used when the assumed...
Declare an allocatable, assumed-shape array b of base type TYPE(base(4, 8, 0)), ALLOCATABLE :: b(:) ! Allocate two elements to b ALLOCATE(b(2)) ! contig has a value of .FALSE. contig = IS_CONTIGUOUS(b%x) 指定給假設形狀陣列的範例 3:CONTIGUOUS屬性 INTEGER, POINTER :: p(:) INTE...
If a is an array dummy argument, it may be declared as an assumed-shape array Sign in to download full-size image where the actual array bounds are transmitted at run time. An array that is local to a procedure may be specified as an automatic array whose bounds depend on another ...
In this case, the interface statement refers to a Fortran 90 style assumed shape array. The actual subroutine refers to a Fortran 77 explicit shape array. The lesson here is: Interfaces to Fortran 77 style routines must only use Fortran 77 style constructs. In this example, it is permitted ...
PRODUCT(array[,dim][,mask]) 返回在指定维上满足mask条件的元素的乘积RESHAPE(source,shape[,pad][,order]) 使用顺序order和补充pad数组元素来改变数组形状SHAPE(source) 返回数组的形状SIZE(array[,dim]) 返回数组在指定维上的长度SPREAD(source,dim,ncopies) 通过增加一维来复制数组SUM(array[,dim][,mask]) ...
Example 3.1:1D assumed shape array as a parameter. subroutineassumed_shape1(Y)real,intent(inout),dimension(:)::Y Y=Y+1returnend Multi-version code for the array stride is generated: Version 1: Vector code assuming Y is unit stride. ...
assumed-shape array/assume:contiguous_assumed_shape-assume contiguous_assumed_shape pointer/assume:contiguous_pointer-assume contiguous_pointer NOTE: Results are indeterminate and could result in incorrect code and segmentation faults if the user assertion is wrong and the data is not contiguous at runti...
is exactly the subject in question - assumed shape arrays automatically get their shape information passed, whereas assumed size arrays basically get nothing but a starting address passed. 运行python遇到这个错误 error: Unable to find vcvarsall.bat 可以这么解决: ...