Fortran90 からずっと 6.3.3.1 Deallocation of allocatable arrays で述べてる
return または end で手続きの実行が終了したとき、その手続きの局所変数は deallocate されると

allocate 時の問題じゃないことは当然確認したね?コードうp