- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to create an array of linked lists and can not seem to get the proper syntax. I am trying to do the following,
do i = 1,N
call linkedlist(i,..., ptr)
tree(i) => ptr
end do
I can create a linked list, ptr, which is a derived type but want to associate it with each element of an array (pointer i assume?) so I get the following,
tree(1) => linked list from the loop when i = 1
tree(2) => linked list from the loop when i = 2
...
Could someone plase show me the syntax on how to do this? I have tried many different combinations and can not seem to get it to work!
Thank you very mcuh for your help.
Sincerely,
David
I am trying to create an array of linked lists and can not seem to get the proper syntax. I am trying to do the following,
do i = 1,N
call linkedlist(i,..., ptr)
tree(i) => ptr
end do
I can create a linked list, ptr, which is a derived type but want to associate it with each element of an array (pointer i assume?) so I get the following,
tree(1) => linked list from the loop when i = 1
tree(2) => linked list from the loop when i = 2
...
Could someone plase show me the syntax on how to do this? I have tried many different combinations and can not seem to get it to work!
Thank you very mcuh for your help.
Sincerely,
David
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess you are looking for something along these lines:
type linked_list_ptr
type(linked_list_type), pointer :: ptr
end type linked_list_ptr
type(linked_list_ptr), dimension(:), allocatable :: list
list(1)%ptr => ptr_a
list(2)%ptr => ptr_b
...
Fortran does not allow an array of pointers, you must have a derived
type that intervenes.
Regards,
Arjen
type linked_list_ptr
type(linked_list_type), pointer :: ptr
end type linked_list_ptr
type(linked_list_ptr), dimension(:), allocatable :: list
list(1)%ptr => ptr_a
list(2)%ptr => ptr_b
...
Fortran does not allow an array of pointers, you must have a derived
type that intervenes.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Arjen!
That was it! Thank you very much for the help!
Sincerely,
David
That was it! Thank you very much for the help!
Sincerely,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're welcome.
Regards,
Arjen
Regards,
Arjen

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