- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Forgive me for the convoluted title; all will hopefully become clear...
I have a derived type which contains a set of allocatable arrays:
[bash] type :: Bin real(kind(1d0)), allocatable, dimension(:) :: abscissas, ordinates end type Bin[/bash]
I now proceed to create an allocatable array of these:
[bash]type(Bin), allocatable, dimension(:) :: lottabins integer :: alloc_err allocate(lottabins(1000), stat=alloc_err) [/bash]
No problems so far; now I proceed to allocate the elements of each bin
[bash]do i=1,1000 allocate (lottabins(i)%abscissas(100), lottabins(i)%ordinates(100), stat=alloc_err) if (alloc_err.ne.0) exit end do [/bash]
This fails while i=1 with an error "severe (151): Allocatable array is already allocated". It's as if the compiler thinks I'm trying to reallocate 'lottabins' itself when in fact what I'm trying to do is to allocate, for the first time,the arrays which are elements of lottabins(i).
Is there in fact a way of doing this, or I am trying to do something which isn't supported?
Stephen.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please show us a complete, buildable and runnable program that demonstrates the problem. I often find that when users show excerpts of their code, the problem is in code not shown.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From my recollection a rather old version of IVF had this problem. ca 8.n or 9.n.
What is your compiler version?
Jim Dempsey
What is your compiler version?
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, the shame! Yes, you were quite right, when I took the code excerpts I had given you and put them into a short console program, they worked well. When I broke down my (much more complex) real program and looked at it closely, I found a duplicate variable name that accounted for the error.
This is what you get for working late on a Labor Day weekend. I'm sorry to have troubled you and hope you enjoy the rest of yours.
Stephen.
This is what you get for working late on a Labor Day weekend. I'm sorry to have troubled you and hope you enjoy the rest of yours.
Stephen.

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