I wanna create an allocatable array in custom type as follows:
- type cell
- integer(4) :: fn
- integer(4), dimension(:), allocatable :: nd
- end type cell
- type(cell), dimension(:), allocatable :: elem
- allocate(elem(10000))
There is memory occupier ten times more than 10000*4 Bytes before allocating array nd, why?
I thought a custom type might not contains any uncertain array, and modified the code as follows:
- type cell
- integer(4) :: fn
- integer(4), pointer :: nd(:)
- end type cell
- type(cell), dimension(:), allocatable :: elem
- allocate(elem(10000))
- do i=1,10000
- elem(i)%nd=>cnode(j:j+7)
- end do
where cnode is a target array. The same situation happens, i.g. the memory occupier is ten times
more than (10000*4+10000*8*4), and why? What should I do to change this?