代码是:
Type , public :: TS_VAR
Complex , allocatable :: An_array (:)
End type TS_VAR
Type ( TS_VAR ) , allocatable :: TS_PU (:)
Allocate ( TS_PU ( 24 ) , Stat = ALLOC_ERR )
If ( ALLOC_ERR .ne. 0 ) Stop ( !!! Memory allocation problem !!! )
Do j = 1 , 24
Allocate ( TS_PU(j)%An_array ( 1 : 13 ) , Stat = ALLOC_ERR )
If ( ALLOC_ERR .ne. 0 ) Stop ( !!! Memory allocation problem !!! )
End do
!!! Calculation
Do j = 1 , 24
Do i = 1 , 13
TS_PU(j)%An_array ( i ) = cmplx ( ! Some calculation )
End do
End do
Logical , dimension ( 1 : 13 , 24 ) :: DM_mask = .false.
Forall( 1 : 5 , j = 1 : 24 ) DM_mask(i,j) = .true.
Write(*,*) maxloc ( abs ( TS_PU(:)%An_array ( : ) ) , mask = DM_mask )
编译过程完成后我得到了这条消息:
Component to the right of a part reference with nonzero rank must not have the ALLOCATABLE attribute
这个例子有什么问题? 在阵列的特定扇区中是否存在最大值搜索的内在函数?