Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28597 Discussions

Problem with MOLD keywork in ALLOCATE

MR
Beginner
382 Views
Hi,
when I try to compile the attached code I see the following error:

ifort test-ifort.f90 -o test-ifort
/tmp/ifort9y3yNI.o:(.rodata+0x50): undefined reference to `i_rhs_'

however up to my understanding the code is correct (and it compiles
with gfortran).

ifort -V
Intel Fortran Intel 64 Compiler XE for applications running on
Intel 64, Version 12.0.4.191 Build 20110427

Is this a compiler problem?

Thank you,
Marco

[fortran]module mod_ti

 implicit none
 public :: c_ode, i_rhs
 private

 type, abstract :: c_ode
 contains
  procedure(i_rhs), deferred, pass(uuu) :: rhs
 end type c_ode

 abstract interface
  pure subroutine i_rhs(tnd,uuu)
   import :: c_ode
   implicit none
   class(c_ode), intent(in)  :: uuu
   class(c_ode), intent(out) :: tnd
  end subroutine i_rhs
 end interface

end module mod_ti

!--------------------------------------------------------------------

module mod_ee

 use mod_ti, only: c_ode, i_rhs

 implicit none
 public :: ee

contains

 pure subroutine ee(ynew,ynow)
  class(c_ode), intent(in)  :: ynow
  class(c_ode), intent(out) :: ynew

  class(c_ode), allocatable :: tnd

   ! if the following two lines are eliminated the code compiles
   allocate(tnd,mold=ynow)
   deallocate(tnd)
   call ynow%rhs(ynew)
 end subroutine ee

end module mod_ee

!--------------------------------------------------------------------

module mod_pb

 use mod_ti, only: c_ode, i_rhs

 implicit none
 public :: t_ode, pb_rhs

 type, extends(c_ode) :: t_ode
  real :: y(3)
 contains
  procedure, pass(uuu) :: rhs => pb_rhs
 end type t_ode

contains

 pure subroutine pb_rhs(tnd,uuu)
  class(t_ode), intent(in)  :: uuu
  class(c_ode), intent(out) :: tnd

   select type(tnd)
    type is(t_ode)
     tnd%y = -3.0*uuu%y
   end select
 end subroutine pb_rhs

end module mod_pb

!--------------------------------------------------------------------

program ode_test

 use mod_pb, only: t_ode
 use mod_ee, only: ee

 implicit none
 type(t_ode) :: a, b

 a%y = (/ 1.0 , 2.0 , 3.0 /)
 call ee(b,a)

end program ode_test
[/fortran]
0 Kudos
2 Replies
Steven_L_Intel1
Employee
382 Views
Yes, it is a compiler problem that is fixed in a future update (probably September). The bug involves an abstract type with a deferred type-bound procedure. In some cases, the compiler erroneously generates an external reference to the deferred procedure name. The issue ID for this is DPD200169377 in case you want to watch for it in the list of fixed bugs.
0 Kudos
MR
Beginner
382 Views
OK, thank you.
Marco
0 Kudos
Reply