|
From: Steven Correll on 6 May 2008 10:08 On May 5, 11:41 pm, "James Van Buskirk" <not_va...(a)comcast.net> wrote: > WARNING: you said earlier that you were ifort 10.1. This compiler > does not behave in a standard way when assignments to whole > allocatable arrays are carried out, unless you use some switch > at compile time. Check the ifort documentation carefully for > the exact nature of its behavior. It's not standard without > the switch. In fairness to Intel, the compiler conforms to the Fortran standard as of 1998; the switch "-assume realloc_lhs" makes it conform to the standard (in this particular matter) as of 2003. Agreed, it's odd that the 1998 TR15581 document created a situation in which allocatable array assignment behaved differently depending on whether the array was a component or a variable, but prior to 2003 it was the responsibility of the programmer to allocate the target explicitly if it wasn't a component.
From: Kurt Kallblad on 7 May 2008 01:56 "Gib Bogle" <g.bogle(a)auckland.no.spam.ac.nz> wrote in message news:481ff61f$1(a)news.auckland.ac.nz... <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? I thought it's enough to deallocate cell1 and cell2. Kurt
From: Richard Maine on 7 May 2008 03:15 Kurt Kallblad <kurt.kallblad(a)tele2.se> wrote: > "Gib Bogle" <g.bogle(a)auckland.no.spam.ac.nz> wrote in message > news:481ff61f$1(a)news.auckland.ac.nz... > <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
From: Damian on 7 May 2008 15:03 On May 7, 12:15 am, nos...(a)see.signature (Richard Maine) wrote: > Kurt Kallblad <kurt.kallb...(a)tele2.se> wrote: > > "Gib Bogle" <g.bo...(a)auckland.no.spam.ac.nz> wrote in message > >news:481ff61f$1(a)news.auckland.ac.nz... > > <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 Just make sure you 1. Couple the above assumptions with empirical testing, 2. Read the compiler manual carefully to determine if you need to pass a flag to force the automatic deallocations, and 3. Update to the latest version of your compiler if your testing uncovers problems. Portland Group had leaks up until its latest release (7.2?). Intel still has some in its current release (10.1). IBM XL Fortran does the deallocations for you only if you pass it a certain flag when you invoke the compiler. So even if you make the right assumptions based on the language standard, don't automatically assume the compiler has implemented the standard correctly. Damian
From: Steve Lionel on 7 May 2008 15:33 On Wed, 7 May 2008 12:03:34 -0700 (PDT), Damian <damian(a)rouson.net> wrote: >3. Update to the latest version of your compiler if your testing >uncovers problems. Portland Group had leaks up until its latest >release (7.2?). Intel still has some in its current release (10.1). I am not aware of allocatable component leaks in Intel Fortran 10.1. If you have a support issue number for such, please send it to me in email so that I can look it up. -- Steve Lionel Developer Products Division Intel Corporation Nashua, NH For email address, replace "invalid" with "com" User communities for Intel Software Development Products http://softwareforums.intel.com/ Intel Fortran Support http://support.intel.com/support/performancetools/fortran My Fortran blog http://www.intel.com/software/drfortran
First
|
Prev
|
Pages: 1 2 Prev: weird g77 and gfortran Next: Graphical representation of f90/f95 programs |