In Fortran, if I have a selectable array of derived types, each of which consists of a pointer and a selectable array,
type group real, pointer :: object real, allocatable :: objectData(:,:) end type group type(group), allocatable :: myGroup(:)
I could free all the memory contained in this type just by making one call
deallocate(myGroup)
or I need to free arrays in each type first before freeing the derived type:
do i = 1, size(myGroup) nullify(myGroup(i)%object) deallocate(myGroup(i)%objectData) end do deallocate(myGroup)
I lean towards option 2 and collapse all the memory until the derived type is freed, if not only so that there is no memory leak, but if option 1 is equivalent, it would be useful for future reference and save me a few lines of code.
source share