Re: Allocatable attribute on derived type components




gaurav schreef:

Hi,

The F003 standard introduced allocatable attribute on derived type
components. The component with allocatable attribute has to be
allocated seperately using allocatable statment.

However, I could not understand the memory layout of the object of such
derived type object.

For example, consider the following

type drv
integer :: x(10)
real , allocatable :: y(:, :)
end type drv

and then an object obj is defined.

type (drv) :: obj

Can any one help me to understand the memory layout of "obj"? What
would be the size of obj?

Also, what would be the memory layout in case if the derived type is
sequenced?


The feature you describe is available in many Fortran 95 compilers too,
as there is a technical report on it.

But layout should not matter at all - and if it does, it will depend
entirely on the
hardware and the Fortran compiler in question.

My guess is that this is/will be implemented in a very similar way
as for pointer components, that is, "somewhere" a block of memory
will be allocated. It's position is unrelated to the position of "obj".

As to the size, the following code fragment might give a clue:

character(len=1), dimension(1) :: byte

write(*,*) size( transfer(obj,byte) )

Can you explain why you want to know?

Regards,

Arjen

.