Dear all,
I have a question regarding the following code snippet:
MODULE TestModule !{ TYPE X0Type REAL(KIND=8), DIMENSION(:),ALLOCATABLE :: X ENDTYPE TYPE SL_DataStrucType REAL(KIND=8), DIMENSION(:), POINTER :: X TYPE(X0Type), DIMENSION(:), POINTER :: StoredX0 => null() ENDTYPE SL_DataStrucType TYPE(SL_DataStrucType), POINTER :: DB_MMxSL_Data => null() TYPE(X0Type), DIMENSION(:), POINTER :: StoredX0 => null() CONTAINS SUBROUTINE Test() ALLOCATE(DB_MMxSL_Data%StoredX0(1)) ALLOCATE(DB_MMxSL_Data%X, SOURCE=StoredX0(1)%X) ALLOCATE(DB_MMxSL_Data%X, SOURCE=DB_MMxSL_Data%StoredX0(1)%X) END SUBROUTINE ENDMODULE TestModule !}
There seems not to be any problem with the upper allocate statement, but when the allocate option Source= is encompassed in a structure, I get the following compiler diagnostic:
error #8152: Neither the ERRMSG= variable nor any part of the source expression in SOURCE= or MOLD= specifiers may be allocated in the ALLOCATE statement in which it appears. [DB_MMXSL_DATA]
Can anyone explain the fundamental difference between the two allocate statements, that is causing in this error.
Dirk