GerritGroot
Technical User
Hi,
Imagine that I've got a derived type as follows:
And then an array of this type, say:
Then if I first allocate MY
for example and then allocate locally, i.e. something like:
Would it be enough to just deallocate the variable MY before closing the program?
Or do I have to deallocate all the sub-%parts separately?
It seems to work till now, though when repeating the program I get some strange behaviour and, though I guess not, I wonder whether it has something to do with this.
Thanks,
Gerrit
Imagine that I've got a derived type as follows:
Code:
TYPE MY_Type
INTEGER :: intone,inttwo
INTEGER, DIMENSION(:), ALLOCATABLE :: myintarr
CHARACTER(LEN=80) :: myname
REAL, DIMENSION(:), ALLOCATABLE :: reallistone,reallisttwo
REAL, DIMENSION(:,:), ALLOCATABLE :: matone,mattwo
REAL, DIMENSION(:,:,:), ALLOCATABLE :: cubeone,cubetwo
END TYPE MY_Type
Code:
TYPE (MY_Type), DIMENSION(:), ALLOCATABLE :: MY
Code:
ALLOCATE(MY(10))
Code:
ALLOCATE(MY(3)%reallistone(7))
Would it be enough to just deallocate the variable MY before closing the program?
Code:
DEALLOCATE(MY)
Or do I have to deallocate all the sub-%parts separately?
It seems to work till now, though when repeating the program I get some strange behaviour and, though I guess not, I wonder whether it has something to do with this.
Thanks,
Gerrit