- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We want to create a structure holding strings that vary greatly in length that can be modified during program execution. So we are using deferred length pointers. However, we are running into a problem deallocating them later. Below is a greatly simplified program that demonstrates the issue. The deallocate in the main program works. The one in subroutine a crashes.
character(:), pointer :: ptr1
character(:), pointer :: ptr2
integer ierr
allocate(character(12) :: ptr1, stat = ierr)
ptr1 = "ABCDEFGHIJKLM"
ptr2 => ptr1
deallocate(ptr2)
allocate(character(12) :: ptr1, stat = ierr)
ptr1 = "MLKJIHGFEDCBA"
call a(ptr1)
contains
subroutine a(ptr)
character(:), pointer :: ptr
ptr2 => ptr
deallocate(ptr2)
end subroutine a
end
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Forgot to mention, running IVF 15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It appears this should work when using ptr2. It also fails with the 16.0 compiler. Deallocation is successful inside the contained routine when using the dummy argument itself. I submitted this to Development.
(Internal tracking id: DPD200377888)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page