class declaration problem

Rouson, Damian rouson@sandia.gov
Mon Feb 27 19:32:00 GMT 2012


Gfortran developers,

When I switch a dummy argument from being declared with "type" to being
declared with "class," several tests in the ForTrilinos test suite fail,
but I get no compile-time or runtime errors.  Because ForTrilinos builds
atop a deep stack of C++ code and the Fortran derived types only contain
ID tags for the underlying C++ objects, it will be challenging diagnose
this and produce a small example.  Fortunately, the workaround is simple
and inconsequential for the time being, but I'm wondering if anyone has
any idea what could be wrong or has any suggestions on how to diagnose
this further.  I can provide access to a ForTrilinos build or advice on
how to build it if anyone is so inclined.  It's part of the open-source
Trilinos library at http://trilinos.sandia.gov.

The top level of the involved source code is below.  The third procedure
calls the second one, which calls the first one, which calls a wrapper for
C++ code.  The commented line in the second procedure is the problem.

Damian


subroutine from_struct_(this,id)
  type(Epetra_MpiComm) ,intent(out) :: this
  type(FT_Epetra_MpiComm_ID_t) ,intent(in) :: id
  this%MpiComm_id = id
  ! Call a wrapper for C++ code:
  call this%set_EpetraComm_ID(this%alias_EpetraComm_ID(this%generalize()))
call this%register_self
  end subroutine

subroutine from_scratch_(this,comm)
  type(Epetra_MpiComm) ,intent(out) :: this
 !"Class" declaration causes test failures with gfortran 4.7.0

 !class(Epetra_MpiComm) ,intent(out) :: this
  integer(c_int) ,intent(in) :: comm
  call from_struct_(this,Epetra_MpiComm_Fortran_Create(comm))
  end subroutine

  type(Epetra_MpiComm) function from_scratch(comm)
  integer(c_int) ,intent(in) :: comm
  call from_scratch_(from_scratch,comm)
end function




More information about the Fortran mailing list