Hi consultants: The following small test code stops on lightning with the following runtime error (after compiling with pgf90): ln0126en% a.out deallocating gethist%lev.. 0: DEALLOCATE: memory at bfffed18 not allocated ln0126en% !---------------------------------------------------------------------- module hist implicit none type history integer :: nlev real,pointer :: lev(:) end type history end module hist !---------------------------------------------------------------------- module get_hist use hist,only: history implicit none contains ! type(history) function gethist(nlev) integer,intent(in) :: nlev integer :: ier gethist%nlev = nlev if (associated(gethist%lev)) then write(6,"('deallocating gethist%lev..')") deallocate(gethist%lev) endif write(6,"('allocating gethist%lev: gethist%nlev=',i3)") | gethist%nlev allocate(gethist%lev(gethist%nlev),stat=ier) write(6,"('after allocate gethist%lev: gethist%nlev=',i3, | ' ier=',i3)") gethist%nlev,ier end function gethist end module get_hist !---------------------------------------------------------------------- program testalloc use hist,only: history use get_hist,only: gethist implicit none type(history) :: h integer :: nlev ! nlev = 100 h = gethist(nlev) end program testalloc !---------------------------------------------------------------------- So the associated() intrinsic function is returning true (even tho the pointer has not yet been associated), but then the deallocate statement fails saying the memory wasnt allocated after all. Now if I replace function gethist with a subroutine, and pass h as an argument, it works. But this is a distillation of a much larger code (a serial post-processor), and it would take quite a bit of work to change it, and I don't see why it should fail as is anyway. It runs fine on xlf90 bs and bv, and f90 on tempest. It also fails on our local HAO linux boxes, using a slightly different version of pgf90. Do you see any other way around this beside replacing the function with a subroutine? And do you think this warrants a bug report to the Portland Group? Thanks, --Ben