Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29271 ディスカッション

Doubt w.r.t. to Fortran2003 standard

Alberto_F__M_
ビギナー
1,124件の閲覧回数

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 件の賞賛
7 返答(返信)
Steven_L_Intel1
従業員
1,124件の閲覧回数

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.

FortranFan
名誉コントリビューター III
1,124件の閲覧回数

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!

Patrice_l_
ビギナー
1,124件の閲覧回数

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.

 

Steven_L_Intel1
従業員
1,124件の閲覧回数

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

FortranFan
名誉コントリビューター III
1,124件の閲覧回数

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,

Steven_L_Intel1
従業員
1,124件の閲覧回数

You are correct.

Steven_L_Intel1
従業員
1,124件の閲覧回数

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

返信