FORTRAN 95 does not allow user-defined types to contain allocatable components, and the workaround is to allow allocation via pointer instead. I have happily been allocating and deallocating derived type components for a while now, but only this morning did I get around to writing code that tested the allocated status of one of them.
The following code provokes (from FTN95 v5.40) warning 1179: - WORKAROUND is not ALLOCATABLE yet is used in an ALLOCATED test.
I think this is wrong, since it is not workaround that is being used in the test, but its allocatable component. Note that the corresponding allocate statement is not flagged as erroneous.
I appreciate its only a warning, and thus non-fatal, but I'd be decidedly happier in ignoring it if other folks who have been doing this new-fangled FTN95 stuff longer than me were in agreement that this warning should not be issued in the first place.
Comments?
<edited immediately post-posting> I hadn't actually tried to run the compiled code when I posted. When I do, I get an access violation on the if (allocated) ... statement.
So clearly there's more to this than meets the eye - mine, anyway. I was wondering whether I have to nullify the pointer before I can test its allocated status? But it can't be that simple - if the component is already allocated, say elsewhere in a module like in my real code, there is no reason why I should not be able to test its allocated status.
Thoughts?
Andy
program hello_kate
type contains_pointer_for_allocation_purposes
integer, pointer :: pseudo_allocatable (:)
end type contains_pointer_for_allocation_purposes
type (contains_pointer_for_allocation_purposes) workaround
if (allocated (workaround% pseudo_allocatable)) deallocate (workaround% pseudo_allocatable)
allocate (workaround% pseudo_allocatable (10))
stop
end program hello_kate