A tale of three compilers

Paul Thomas paulthomas2@wanadoo.fr
Sat Dec 4 18:12:00 GMT 2004


In trying to develop a sparse matrix interface with automatic garbage 
collection, I have run into a rather quirky part of fortran95.  gfortran, 
g95 and Digital Fortran 6.0 all give different results for the code below.

gfortran gives:
 base%this%this=>base? F
 base%this%this=>? F
 base%this=>? T

g95 gives:
 base%this%this=>base? T
 base%this%this=>? F
 base%this=>? T

and Digital Fortran:
 base%this%this=>base? T
 base%this%this=>? T
 base%this=>? T                    !!

I have perused the ISO standard to see what should happen but cannot find 
any specification of the clean up must be effected on going out of scope. 
gfortran is by far the cleanest and most compatible with what I am trying to 
do.  However, this clean up presumably carries a time penalty?  It is also 
manifestly untransportable.

Why, oh why is there only a default destructor in fortran9x?

Paul Thomas

module global
  type                                ::  mytype
     type(mytype),pointer   ::  this
  end type mytype
  type(mytype),target        :: base
end module global
program test_equi
  use global
  call check()
  print *, "base%this%this=>base?"  ,  associated(base%this%this,base)
  print *, "base%this%this=>?" ,          associated(base%this%this)
  print *, "base%this=>?" ,                   associated(base%this)
contains
  subroutine check()
  type(mytype),target        :: j
  base%this => j                      !have the variables point
  j%this => base                      !to one another
  end subroutine check             !take j out of scope
end program test_equi







More information about the Fortran mailing list