使用maxval或minval函数

时间:2019-06-24 16:43:14

标签: fortran gfortran

将minval和maxval函数与可分配向量结合使用的问题。

该示例仅用于显示错误消息。 Refl_Type上的分量H的最小维数为3(对于h,k和l索引)。

有什么简单的解决方法吗?

程序检查       隐性无

  !> Type definitions
  Type :: Refl_Type
     integer,dimension(:), allocatable :: H            ! H
     integer                           :: Mult  =0     ! Mutiplicity
  End Type Refl_Type

  Type, extends(Refl_Type) :: SRefl_Type
     real :: Fo    =0.0  ! Observed Structure Factor
     real :: Fc    =0.0  ! Calculated Structure Factor
  End Type SRefl_Type

  Type :: RefList_Type
     integer                                     :: Nref
     class(refl_Type), dimension(:), allocatable :: Reflections
  end Type RefList_Type

  Type(RefList_Type) :: List

  Contains

  Subroutine Sub(List)
     !---- Argument ----!
     type (RefList_Type), intent(in out) :: List

     !---- Local Variables ----!
     integer            :: n
     integer            :: hmax,kmax,lmax
     integer            :: hmin,kmin,lmin

     n=List%Nref

     hmax=maxval(list%reflections(1:n)%h(1))
     kmax=maxval(list%reflections(1:n)%h(2))
     lmax=maxval(list%reflections(1:n)%h(3))


   End Subroutine Sub

End Program Check

我有下一个错误编译 ...

 hmax=maxval(list%reflections(1:n)%h(1))
                  1

Error: Component to the right of a part reference with nonzero rank must not have the ALLOCATABLE attribute at (1)

0 个答案:

没有答案
相关问题