- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
I would like to find out a size of memory which is assigned by a huge allocatable array. Every ellements of my array has a derived type like the following:
type :: my_type
double precision, dimension(:,:), allocatable :: z
end typemy_type
...
In the code I allocate
allocate( array(1:Nmax) )
do i = 1, Nmax
allocate( array(i)%z(1:arrayMax, 1:3) )
end do
Nmax and arrayMax are approx. equal to 17000 and 10000 respectivly. And so I warry about work station. How much Mb will I use performing this?Is there any intrinsict function estimating it?
Oleg.
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Each "z" element will have 30000 elements of 8-byte reals, or 240,000 bytes. In addition, there is the array descriptor for each z which will be something like 48 bytes. So, 17000 * 240,048 = about 4GB. You will need a 64-bit OS to allocate this much data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May I attach the "z" elements from 1 up to Nmax during the calculation? resizing//increasing the allocatable array in order to save the memory.
I am performing my calculation in 64-bit OS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure I understand the question. You don't have to allocate all the z elements at once. However, there is no real support for "resizing" an allocatable array. You can do it with a three-step process:
1. Allocate a new array to the desired size
2. Copy the elements from old to new
3. Use MOVE_ALLOC to "transfer" the allocation of the new array back to the old.
Note that for a while you will have twice the memory allocated.
1. Allocate a new array to the desired size
2. Copy the elements from old to new
3. Use MOVE_ALLOC to "transfer" the allocation of the new array back to the old.
Note that for a while you will have twice the memory allocated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you! I thought this way, too.
You note is important. Finaly, I will use more than 4 Gb (from 4 to 8 Gb after the half point of a calculation).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In case of using selected_real_kind will the size of element change from 8-byte?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That depends on the parameters you supply to selected_real_kind. If precision and exponent range are small enough for a IEEE 754 single precision real, you will only need 4 bytes per real.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Be aware of the distinction between virtual and physical memory. When a chunk of memory is newly allocated that does not mean that it is instantlymapped to physical memory. That will only happen when you start writing toit.
So if your array is sparse, e.g. with large unused and uninitialized sections, then it will use less physical memory than you expect. With other words: It is legal to allocate more thanthe physical memory knowing that not all of it will be used. In that case you just have to avoid initializing the whole thing. In that case your workstation will freeze.
So if your array is sparse, e.g. with large unused and uninitialized sections, then it will use less physical memory than you expect. With other words: It is legal to allocate more thanthe physical memory knowing that not all of it will be used. In that case you just have to avoid initializing the whole thing. In that case your workstation will freeze.
![](/skins/images/B7BA37F9CE4B52FF7CAE1FB0388839C8/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page