Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

Doubt w.r.t. to Fortran2003 standard

Alberto_F__M_
Beginner
1,166 Views

Dear Intel Fortran Compiler users,

I would like to know whether the following code snippet

module overwrite
  type madre
   contains
     procedure :: sum => sum_madres
     generic   :: operator(+) => sum
  end type madre

  type, extends(madre) ::  hijo
  contains
     procedure :: sum => sum_hijos_compliant
  end type hijo

contains

function sum_madres(op1,op2) result(res)
 implicit none
 class(madre), intent(in) :: op1, op2
 class(madre), pointer    :: res
 write(*,*) 'sum_madres'
end function sum_madres

function sum_hijos_compliant(op1,op2) result(res)
   implicit none
   class(hijo) , intent(in) :: op1
   class(madre), intent(in) :: op2
   class(madre), pointer    :: res
   write(*,*) 'sum_hijos'
end function

end module overwrite

program drive_ovw
  use overwrite
  implicit none

  type(madre) :: m1, m2
  type(hijo)  :: h1, h2
  class(madre), pointer :: hres

  hres => h1 + m2

end program drive_ovw

should output 'sum_hijos' or 'sum_madres'. With the Intel and GFORTRAN compilers I get 'sum_madres', while with the IBM XLF compiler I get 'sum_hijos'.

I have already reported this same query in the following forum:

https://groups.google.com/forum/#!topic/comp.lang.fortran/aFNK3FXqTUA

and one very related here:

https://gcc.gnu.org/ml/fortran/2014-10/msg00124.html

with no clear answer yet.

Thanks in advance.
Best regards,
 Alberto.

0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,166 Views

Related discussion in https://software.intel.com/en-us/forums/topic/534779

I will also look at this one, though my original impulse is to say that 'sum_hijos' would be correct.

0 Kudos
FortranFan
Honored Contributor III
1,166 Views

Thank you, Alberto, for posting your query here.

As mentioned by Steve and as I posted at the comp.lang.fortran thread, "sum_hijos" appears to be the correct response.  I look forward to the discussion!

0 Kudos
Patrice_l_
Beginner
1,166 Views

Maybe you should take a look at my post here : https://software.intel.com/en-us/forums/topic/534286 where i report  the same problem along with addition binding to the operator. 

As I stated in my post, and is the situation for you , if you replace the operator + by a call to the function sum, you get the right_answer sum_hijos.

 

0 Kudos
Steven_L_Intel1
Employee
1,166 Views

This is a problem we're already working on - our issue ID is DPD200362489. I will update this thread about any progress.

0 Kudos
FortranFan
Honored Contributor III
1,166 Views

Steve Lionel (Intel) wrote:

This is a problem we're already working on - our issue ID is DPD200362489. I will update this thread about any progress.

Steve,

I read this is as "confirmation" from you and Intel the code in the original post is consistent with the Fortran 2003 standard and that "sum_hijos" is indeed the right response.  Please correct me if I'm mistaken.

Thanks,

0 Kudos
Steven_L_Intel1
Employee
1,166 Views

You are correct.

0 Kudos
Steven_L_Intel1
Employee
1,166 Views

This problem is fixed in the 16.0 compiler, available now.

0 Kudos
Reply