Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: Derived typ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 16 of 26 Topic 8212 of 8908
Post > Topic >>

Re: Derived types and allocatable

by nospam@[EMAIL PROTECTED] (Richard Maine) May 7, 2008 at 12:15 AM

Kurt Kallblad <kurt.kallblad@[EMAIL PROTECTED]
> wrote:

> "Gib Bogle" <g.bogle@[EMAIL PROTECTED]
> wrote in message 
> news:481ff61f$1@[EMAIL PROTECTED]
> <snip>
> > do i = 1,2
> >     if (allocated(cell1(i)%cdata)) then
> >         deallocate(cell1(i)%cdata)
> >     endif
> > enddo
> > if (allocated(cell1)) then
> >     deallocate(cell1)
> > endif
> > do i = 1,2
> >     if (allocated(cell2(i)%cdata)) then
> >         write(*,*) 'deallocate cell2(i)%cdata: ',i
> >         deallocate(cell2(i)%cdata)
> >     endif
> > enddo
> > if (allocated(cell2)) then
> >     deallocate(cell2)
> > endif
> >
> > end
> 
> A different questions:
>  Is it necessery to deallocate the components?

No. Some might prefer it as a style, but it is not necessary.

>  I thought it's enough to deallocate cell1 and cell2.

As a general rule, you can assume that (barring compiler bugs),
allocatables cannot leak memory. You can pretty much deduce the details
from that. If the components weren't automatically deallocated for you,
then forgetting to deallocate them would leak memory. Therefore, you can
deduce that the components will be dealocated for you. The deduction
would be correct.

-- 
Richard Maine                    | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle           |  -- Mark Twain
 




 26 Posts in Topic:
Derived types and allocatable
Gib Bogle <g.bogle@[EM  2008-05-06 16:01:28 
Re: Derived types and allocatable
Gib Bogle <g.bogle@[EM  2008-05-06 18:09:36 
Re: Derived types and allocatable
"James Van Buskirk&q  2008-05-06 00:41:26 
Re: Derived types and allocatable
Steven Correll <steven  2008-05-06 07:08:11 
Re: Derived types and allocatable
"James Giles" &  2008-05-11 00:26:34 
Re: Derived types and allocatable
=?ISO-8859-15?Q?Jan_Vorbr  2008-05-14 12:07:46 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 19:30:39 
Re: Derived types and allocatable
glen herrmannsfeldt <g  2008-05-14 12:39:38 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 20:49:59 
Re: Derived types and allocatable
glen herrmannsfeldt <g  2008-05-14 13:27:46 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 21:40:48 
Re: Derived types and allocatable
=?ISO-8859-15?Q?Jan_Vorbr  2008-05-15 11:14:13 
Re: Derived types and allocatable
"James Van Buskirk&q  2008-05-14 11:03:21 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 19:37:02 
Re: Derived types and allocatable
"Kurt Kallblad"  2008-05-07 07:56:49 
Re: Derived types and allocatable
nospam@[EMAIL PROTECTED]   2008-05-07 00:15:43 
Re: Derived types and allocatable
Gib Bogle <bogle@[EMAI  2008-05-08 08:35:27 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-07 12:03:34 
Re: Derived types and allocatable
Steve Lionel <Steve.Li  2008-05-07 15:33:13 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-08 09:05:09 
Re: Derived types and allocatable
Steve Lionel <Steve.Li  2008-05-08 12:52:00 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-08 19:56:55 
Re: Derived types and allocatable
Steve Lionel <Steve.Li  2008-05-09 14:11:34 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-09 12:15:07 
Re: Derived types and allocatable
"James Van Buskirk&q  2008-05-06 00:11:29 
Re: Derived types and allocatable
Gib Bogle <g.bogle@[EM  2008-05-06 18:39:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Nov 19 7:47:32 CST 2008.