Most compilers I’ve tried (intel, gnu, pathscale, cray) will return an error when attempting to allocate an array that was already allocated. For example:
program test2
integer, allocatable, dimension(:) :: foo
integer ierr
allocate(foo(100), STAT=ierr)
write(*,*) 'status = ', ierr
allocate(foo(100), STAT=ierr)
write(*,*) 'status = ', ierr
end program test2
But PGI seems to handle this fine (even when a different size is used).
Is it safe to do this?