- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to define an array of pointers into Type.
type names real :: p type (list), dimension(:), pointer :: pLend type names
type list
integer :: a
end type list
type(list), dimension(:), pointer :: pB
Then I have allocatedpB by:
nullify( pB )
allocate( pB(100) )
I need now to give dimension to pL and point it to some values of pB. How can I do this.
Thanks in advance.
Qing
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>> I would like to define an array of pointers into Type
I find it helps to declare your types inside out.
i.e. from inner most level
! define your type
type YourType
! Insert your type fields here
integer :: ID! sample field for illustration
...
end type YourType
! define a pointer to your type
type ptrYourType
type(YourType), pointer :: pT
end type ptrYourType
! declare a list of pointers to your type
type(ptrYourType), pointer :: list(:)
! allocate the list of pointers to your type
allocate(list(ListCount))
! allocate each of the types pointed to the list of your type
do i=1,size(list)
allocate(list(i).pT
end do
...
! fill in fields of your type
list(iSomeEntry).pT.ID = 12345
Jim Dempsey

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page