Just a general coding question regarding data type pointer variables.
My question is for pointer data types that contain allocatable arrays such as the following example:
C DATA TYPE DECLARATION IN A MODULE TYPE TARRAY INTEGER::POS LOGICAL::USEVAL DOUBLE PRECISION::VAL DOUBLE PRECISION,DIMENSION(:),ALLOCATABLE::TIM,DAT END TYPE ! TYPE TTYPE INTEGER::NT CHARACTER(20), DIMENSION(:),ALLOCATABLE::NAM TYPE(TARRAY),DIMENSION(:),ALLOCATABLE::T END TYPE ! TYPE, EXTENDS (TTYPE):: TTYPEAUX REAL, DIMENSION(:),ALLOCATABLE:: FAC INTEGER, DIMENSION(:),ALLOCATABLE:: IDX LOGICAL :: PRNT END TYPE
That are then declaired as a pointer as follows:
TYPE(TTYPEAUX), POINTER:: DATA ALLOCATE(DATA)
After the pointer has been allocated the various allocatable parts in the data type are allocated.
My question is will there be any memory leaks or problems if at the end of the code or when I no longer need the pointer I just use the following:
DEALLOCATE(DATA)
Which would then DEALLOCATE the data type and all the allocatable arrays within it.
For that matter if DATA was only a regular pointer array would it deallocate the entire array or do I have to do something like:
DATA=>NULL() C or NULLIFY(DATA)
To remove it from memory or would those only disassociate the pointer leaving the array sitting in memory. (There maybe other features pointing to the pointer array.)
I personally hate pointers, but for this particle program that I am working on I have to use them.
Thanks for your help as always!