Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
12 Views

deallocate type variable only one field

Dear all,

I have the following type variable:

  TYPE::tMACROCELLNODE
   INTEGER                                        :: nElem
   INTEGER                                        :: AA
   INTEGER                                        :: IDnode
   INTEGER                                        :: IDmCell
   REAL(KIND=8),ALLOCATABLE,DIMENSION(:)          :: WFX
   REAL(KIND=8),ALLOCATABLE,DIMENSION(:)          :: WFY
   !
   REAL(KIND=8),ALLOCATABLE,DIMENSION(:)          :: WFtime
   REAL(KIND=8),ALLOCATABLE,DIMENSION(:)          :: WFpdf
   !
   REAL                                           :: qs
  ENDTYPE

During my program, I allocate it as:

first of all:

ALLOCATE(MACROCELLNODE(npairs))

and then

DO i.....

       ALLOCATE(MACROCELLNODE(i)%WFX(n))
...
...

My question is:

Is it possible deallocate only one field of it?

for example:

i=10
DEALLOCATE(MACRCELLNODE(i)%WFX(:))

Thank to all of you

Diego

0 Kudos
3 Replies
Highlighted
12 Views

Yes, you can do that. You can also deallocate the entire array and each of the components will be deallocated as necessary.

You have the syntax a bit wrong in the DEALLOCATE, though - no (:) at the end.

0 Kudos
Highlighted
Beginner
12 Views

Dear all, Dear Steve,

Thanks a lot, but what is the difference between

VECTOR(:) or VECTOR?

Just to better understand

Thanks again

0 Kudos
Highlighted
Black Belt
12 Views

When you allocate an array, you have to specify the extent of the array. When you deallocate, however, you do not specify a range of indices. You may deallocate only the entire array, and not chosen portions of it. Therefore, writing (:) in the deallocation statement would be superfluous, and the language rules do not let you write that qualifier.

0 Kudos