Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
5 Views

Operator overloading with parameterized derived types

I am trying to use this feature but it doesn't seem to work. As far as I can see the attached code should compile but it doesn't. I've been staring at this code for so long I wouldn't spot an error anyway so I'd appreciate a second opinion. This is the comment at the top of the file:

! Created by  on 22/02/2020.
!
! ifort (IFORT) 19.1.0.166 20191121
!
! Build:
!   ifort -debug -check bounds -warn all -traceback AGd.f90 -o AGd
!
! Result:
!
! AGd.f90(109): error #6549: An arithmetic or LOGICAL type is required in this context.
!    v = 3*s + 1
!---------^
!AGd.f90(109): error #6355: This binary operation is invalid for this data type.
!    v = 3*s + 1
!---------^

 

0 Kudos
7 Replies
Highlighted
Valued Contributor III
5 Views

Looks like a compiler bug to

Looks like a compiler bug to me, I suggest submitting a support request for Intel OSC so their support/Fortran team to review the 2 errors raised by the compiler vis-a-vis your code and to give you feedback on them.

0 Kudos
Highlighted
Beginner
5 Views

Thank you. Support was the

Thank you. Support was the first place I tried but the only reply was that my licence didn't include support and the request was closed. I thought they might be interested anyway but I've not heard anything. So my only hope now is that someone from Intel monitors this forum and is interested in a potential compiler bug or that someone with support picks it up. I'll do my best to side-step the issue for now and hope that it will be fixed sometime in the future.

0 Kudos
Highlighted
Valued Contributor II
5 Views

Quote:geard, simon wrote:

geard, simon wrote:

Thank you. Support was the first place I tried but the only reply was that my licence didn't include support and the request was closed. I thought they might be interested anyway but I've not heard anything. So my only hope now is that someone from Intel monitors this forum and is interested in a potential compiler bug or that someone with support picks it up. I'll do my best to side-step the issue for now and hope that it will be fixed sometime in the future.

 

Intel is a large company. Large companies move at the same speed as glaciers. You need to find a work around !

0 Kudos
Highlighted
Beginner
5 Views

I have found a sort of work

I have found a sort of work round - one that enables me to build. The solution is to add user-defined operators like so:

    interface operator(.mult.)
        module procedure i_times_gav, gav_times_i, r_times_gav, gav_times_r, gav_times_gav
    end interface

    interface operator(.plus.)
        module procedure i_plus_gav, gav_plus_i, r_plus_gav, gav_plus_r, gav_plus_gav
    end interface

    interface operator(.minus.)
        module procedure i_minus_gav, gav_minus_i, r_minus_gav, gav_minus_r, gav_minus_gav
    end interface

Then the usage becomes

r3 = (1 .plus. s3) .mult. (1 .minus. (3.mult.s3)) .mult. (1 .plus. (3.mult.s3))

Of course this is only useful for completing the implementation but that at least is something.

 

0 Kudos
Highlighted
Valued Contributor III
5 Views

Quote:geard, simon wrote:

geard, simon wrote:

I have found a sort of work round - one that enables me to build. The solution is to add user-defined operators like so ..

If you're ok with moving away from generic operators with type-bound procedures but open to using newer features, you can try the Fortran 2018 with generic operators and see if they work for you:

generic :: operator(*) => i_times_gav, gav_times_i, r_times_gav, gav_times_r, gav_times_gav

generic :: operator(+) => i_plus_gav, gav_plus_i, r_plus_gav, gav_plus_r, gav_plus_gav

generic :: operator(-) => i_minus_gav, gav_minus_i, r_minus_gav, gav_minus_r, gav_minus_gav

You can then have your usage closer to black-board abstraction:

0 Kudos
Highlighted
Moderator
5 Views

I filed a bug report on this.

I filed a bug report on this. I'll keep you posted on its progress to a fix.

 

0 Kudos
Highlighted
New Contributor I
5 Views

Intel is a large company.

Intel is a large company. Large companies move at the same speed as glaciers. You need to find a work around !

Actually I find that Intel watch this forum fairly well.  

They do not always solve the problems but you get good feedback 

I suspect some of these old people never sleep 

JMN

0 Kudos