I have encountered this problem before, and the solution that worked for me was to to declare the component as POINTER
instead of ALLOCATABLE, TARGET
. I am not sure whether the Fortran standard does not support it, or this feature is just not implemented by the compilers. I was using ifort v12.0.2.137
.
Would this be an acceptable solution for you? You would then be able to use it as pointer target.
TYPE , PUBLIC :: InputType
TYPE(InputType_C) :: C_obj
REAL(KIND=C_DOUBLE),DIMENSION(:),POINTER :: In_X => NULL()
REAL , DIMENSION(:) , ALLOCATABLE :: X
REAL , DIMENSION(:) , ALLOCATABLE :: Y
REAL , DIMENSION(:) , ALLOCATABLE :: Z
INTEGER , DIMENSION(:) , ALLOCATABLE :: index
INTEGER :: Xlen
INTEGER :: Ylen
INTEGER :: Zlen
INTEGER :: indexlen
END TYPE InputType
Then, you can associate the In_X
pointer with target data:
In_X(1:Input%C_obj%Xlen) => Input%X(1:Input%C_obj%Xlen)
Note that Input%X
will need to have a TARGET
attribute as well.