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 on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

use only and operator overload functions

jimdempseyatthecove
Honored Contributor III
1,250 Views

I do not know if this is a bug or a (overlooked) feature.

 

I have a module with a user defined type and operator overload function. For example:

interface operator (+)
module procedure nmin_add
end interface

 

The procedure nmin_add adds two of the type and returns the type result.

Performing A = B + C where the operands and result are the same type.

No issue when a procedure contains:

 

 use foo_module   ! A, B and C, and nmin_add contained in the module

 

The issue comes in when I have:

 

use foo_module, only: A, B C

error #6549: An arithmetic or LOGICAL type is required in this context. [...]

as well as

use foo_module, only: A, B C, nmin_add

error #6580: Name in only-list does not exist or is not accessible. [NMIN_ADD]

 

The problem I believe is the operator(+) isn't imported, nor is the function. It looks like there is no syntax on the use only to pull in the operators.

Sorry, for not providing a reproducer.

Jim Dempsey

 

0 Kudos
1 Solution
andrew_4619
Honored Contributor III
1,224 Views
What if you add the type to use

View solution in original post

2 Replies
andrew_4619
Honored Contributor III
1,225 Views
What if you add the type to use
jimdempseyatthecove
Honored Contributor III
1,193 Views

Ahh, hadn't tried that.

That works.

 

Thanks

Helps resolve name collisions.

 

Jim

0 Kudos
Reply