Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pointer to pointer in fortran 2

Status
Not open for further replies.

harphool

Programmer
Jul 16, 2015
2
IN
type :: row1
real*8, dimension:)), pointer :: A
end type row1
type :: row2
type(row1), dimension:)), pointer :: B
end type row2
type(row2), dimension:)), pointer :: C

Do I need to fee this memory?
is nullify(C) enough?
 
Is this F90 or a later version? As of F95, arrays deallocate themselves when they go out of scope.
 
Fortran deallocates automatically only allocatable objects, not pointers. So, if C has been allocated, then nullify(C) is not enough. You must first deallocate each sub-pointer (if allocated) and then deallocate C at the end of the process to free the memory.

@harphool it is usually better to allocate only allocatable objects even if pointer objects may be allocated too. I prefer to use pointers only to point to a memory already allocated.

François Jacq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top