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 > Allocatable arr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 19 Topic 8191 of 8471
Post > Topic >>

Allocatable arrays in derived types

by Gib Bogle <bogle@[EMAIL PROTECTED] > Apr 29, 2008 at 07:57 PM

Consider a derived type used thus:

type mytype
     integer :: a,b,c
     real :: x,y,z
     real, allocatable :: mydata(:)
end type

type(mytype), allocatable :: cell(:)
type(mytype) :: acell

allocate(cell(1000))
do i = 1,1000
     if (i <= 500) then
         allocate(cell(i)%mydata(10))
     else
         allocate(cell(i)%mydata(100))
     endif
enddo

acell = cell(100)
....
acell = cell(600)

Something like this seems to work fine, so I guess it's OK.  I'm 
uncertain about how/where mydata is stored.  Perhaps I shouldn't even be 
thinking about this, but old habits die hard.  When cell is allocated 
how much space is reserved for mydata?  I suppose this is 
compiler-dependent, but what would be a typical number?  When mydata is 
allocated, where is it stored?  Finally, when acell is equated to an 
element of the cell array, where is its mydata?

Thanks in advance for a free Fortran lesson :-)
 




 19 Posts in Topic:
Allocatable arrays in derived types
Gib Bogle <bogle@[EMAI  2008-04-29 19:57:51 
Re: Allocatable arrays in derived types
Arjen Markus <arjen.ma  2008-04-29 01:23:58 
Re: Allocatable arrays in derived types
relaxmike <michael.bau  2008-04-29 02:03:17 
Re: Allocatable arrays in derived types
nospam@[EMAIL PROTECTED]   2008-04-29 02:26:48 
Re: Allocatable arrays in derived types
"Jugoslav Dujic"  2008-04-29 12:24:18 
Re: Allocatable arrays in derived types
relaxmike <michael.bau  2008-04-29 04:14:21 
Re: Allocatable arrays in derived types
"Jugoslav Dujic"  2008-04-29 14:08:55 
Re: Allocatable arrays in derived types
"James Van Buskirk&q  2008-04-29 14:30:21 
Re: Allocatable arrays in derived types
relaxmike <michael.bau  2008-04-29 06:08:04 
Re: Allocatable arrays in derived types
nospam@[EMAIL PROTECTED]   2008-04-29 09:06:51 
Re: Allocatable arrays in derived types
glen herrmannsfeldt <g  2008-04-29 08:41:18 
Re: Allocatable arrays in derived types
nospam@[EMAIL PROTECTED]   2008-04-29 14:14:44 
Re: Allocatable arrays in derived types
paul.richard.thomas@[EMAI  2008-04-29 22:25:33 
Re: Allocatable arrays in derived types
"James Van Buskirk&q  2008-04-30 00:20:44 
Re: Allocatable arrays in derived types
paul.richard.thomas@[EMAI  2008-04-30 10:19:07 
Re: Allocatable arrays in derived types
Gib Bogle <bogle@[EMAI  2008-05-02 08:57:21 
Re: Allocatable arrays in derived types
paul.richard.thomas@[EMAI  2008-04-29 05:58:51 
Re: Allocatable arrays in derived types
Damian <damian@[EMAIL   2008-04-30 00:59:43 
Re: Allocatable arrays in derived types
paul.richard.thomas@[EMAI  2008-05-01 02:40:21 

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 Jul 9 6:06:39 CDT 2008.