Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 415

problem with "deallocate"

$
0
0

This simple dummy program I have done to show the problem will compile with both ( gfortran 4.9.2.10 and ifort 17.0.0 20160315 ).

With gfortran it works smoothly while with ifort it generates a SEGFAULT in the deallocation phase.

I can't understand if this is a problem of the program or a problem of the compiler.

>>=====================================================================================

MODULE container
IMPLICIT NONE
TYPE :: container_t
  PRIVATE
  INTEGER, DIMENSION(:), POINTER :: A=>NULL()
CONTAINS
  PROCEDURE, PASS, PUBLIC :: BIND=>container_bind
  PROCEDURE, PASS, PUBLIC :: FREE=>container_free
END TYPE
CONTAINS
SUBROUTINE container_bind( hobj, dat )
  CLASS(container_t),             INTENT(INOUT) :: hobj
  CLASS(*), DIMENSION(:), TARGET, INTENT(IN)    :: dat
  SELECT TYPE  ( A => dat )
  TYPE IS (INTEGER)
    hobj%A => A
  END SELECT
END SUBROUTINE container_bind
SUBROUTINE container_free( hobj )
  CLASS(container_t),     INTENT(INOUT) :: hobj
  IF ( ASSOCIATED(hobj%A) ) DEALLOCATE(hobj%A)
END SUBROUTINE container_free
END MODULE container

PROGRAM test
  USE :: container
IMPLICIT NONE
  TYPE(container_t) :: T
  INTEGER, DIMENSION(:), POINTER :: A=>NULL()
  ALLOCATE(A(10))
  WRITE(*,*) 'Allocated...'
  CALL T%BIND( A )
  WRITE(*,*) 'Bounded...'
  CALL T%FREE()
  WRITE(*,*) 'Finished...'
END PROGRAM test

>>=====================================================================================

 

 


Viewing all articles
Browse latest Browse all 415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>