You mean when passed as argument to a procedure ?
Maybe use the optional
attribute:
program main
implicit none
integer, target :: ints(4) = [1, 2, 3, 4]
integer, allocatable, target :: iall(:)
integer, pointer :: iptr(:) => null()
call checkAlloc(1)
call checkAlloc(ints)
iptr => iall
call checkAlloc(iall)
call checkAlloc(iptr)
allocate(iall(2))
call checkAlloc(iall)
call checkAlloc(iptr)
contains
subroutine checkAlloc(var)
integer, optional :: var(..)
if (present(var)) then
print *, ' Var is "allocated"'
return
endif
print *, ' Var is NOT "allocated"'
end subroutine
end program main