- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
we just installed the noncomercial version of the intel f90 on out Debian Linux system and I ran into trouble compiling my f90 code on it. The problem operator overloading for derived types.
In the attached sample program I have two modules, one defining a three_vector type and a method to add them.
The other defines a four_vector type and also a method to add them.
in both modules I define an interface to overload these methord with the (+) operator.
In the four_vector module I need to "use" the three_vector module for other operations not shown in the example.
This call:
use three_vector_class
is the origin of my problems.
while the addition of three_vector objects compiles and works in the main program, that of four_vector objects fails.
Obviously the overloading of the four_vector addition did not register.
Output from compiler(v 7.1) a the end.
From what I understand, this should work in f90, and BOTH the lahey f90 compiler as well as the DEC Unix compiler compile this correctly.
Does anybody have any suggestions? Did I do something non-kosher here?
Thanks
Volker
-----------------------------------------------------
#> ifc test2.f90
module THREE_VECTOR_CLASS
module function T_ADD
module FOUR_VECTOR_CLASS
module function F_ADD
program TEST
f = f1+f2 ! fails to compile
^
Error 145 at (63:test2.f90) : Non-numeric left operand of +, -, *, /, or ** operator
^
Error 145 at (63:test2.f90) : Non-numeric right operand of +, -, *, /, or ** operator
we just installed the noncomercial version of the intel f90 on out Debian Linux system and I ran into trouble compiling my f90 code on it. The problem operator overloading for derived types.
In the attached sample program I have two modules, one defining a three_vector type and a method to add them.
The other defines a four_vector type and also a method to add them.
in both modules I define an interface to overload these methord with the (+) operator.
In the four_vector module I need to "use" the three_vector module for other operations not shown in the example.
This call:
use three_vector_class
is the origin of my problems.
while the addition of three_vector objects compiles and works in the main program, that of four_vector objects fails.
Obviously the overloading of the four_vector addition did not register.
Output from compiler(v 7.1) a the end.
From what I understand, this should work in f90, and BOTH the lahey f90 compiler as well as the DEC Unix compiler compile this correctly.
Does anybody have any suggestions? Did I do something non-kosher here?
Thanks
Volker
-----------------------------------------------------
#> ifc test2.f90
module THREE_VECTOR_CLASS
module function T_ADD
module FOUR_VECTOR_CLASS
module function F_ADD
program TEST
f = f1+f2 ! fails to compile
^
Error 145 at (63:test2.f90) : Non-numeric left operand of +, -, *, /, or ** operator
^
Error 145 at (63:test2.f90) : Non-numeric right operand of +, -, *, /, or ** operator
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I am new to this forum and teh attchemnt of my program failed
here it is:
here it is:
module three_vector_class implicit none private :: t_add type three_vector real, dimension(1:3) ::vector end type three_vector interface operator (+) module procedure t_add end interface contains function t_add (v1,v2 ) result(v0) type(three_vector), intent(in) :: v1,v2 type(three_vector) :: v0 v0%vector = v1%vector + v2%vector end function t_add end module three_vector_class !++++++++++++++++++++++++++++++++++++++++++++++ module four_vector_class use three_vector_class ! removing would fix the problem; but three_vector ! objects are needed in the rest of the module implicit none private:: f_add type four_vector real, dimension(0:3) :: vector end type four_vector interface operator (+) module procedure f_add end interface contains function f_add (v1,v2 ) result(v0) type(four_vector), intent(in) :: v1,v2 type(four_vector) :: v0 v0%vector = v1%vector + v2%vector end function f_add ! plus other routines involving three_vector objects end module four_vector_class !+++++++++++++++++++++++++++++++++++++++++++++++++++++ program test use three_vector_class !can be removed: same result use four_vector_class implicit none type (four_vector) :: f,f1,f2 type (three_vector) :: t,t1,t2 t = t1+t2 ! <- works f = f1+f2 ! fails to compile end program test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Same problem here. When 2 modules overload the same operator, the overloading does not register. Solution in v7 was to have different modules for the TYPE definitions and for the OPERATORs (overloading, functions etc.)
In v8 (20031016Z) this does not work anymore and no solution has been found.
MODULE A
TYPE A
...
MODULE B
TYPE B
...
MODULE AOps
USE A
OPERATOR (*) ! does A*A etc.
....
MODULE BOps
USE A
USE B
OPERATOR (*) ! does B*B _and_ A*B
...
A*B does not "get through", even for operations that are inside module BOps (ie a function that uses the A*B)
Gives "An arithmetic or LOGICAL type is required in this context" plus "This binary operation is invalid", plus "No matching user defined OPERATOR with this given type and rank has been defined" (although _everything_ is in order with other compilers), or gives a segmentation fault, depending on the moon phase from what I can tell
In v8 (20031016Z) this does not work anymore and no solution has been found.
MODULE A
TYPE A
...
MODULE B
TYPE B
...
MODULE AOps
USE A
OPERATOR (*) ! does A*A etc.
....
MODULE BOps
USE A
USE B
OPERATOR (*) ! does B*B _and_ A*B
...
A*B does not "get through", even for operations that are inside module BOps (ie a function that uses the A*B)
Gives "An arithmetic or LOGICAL type is required in this context" plus "This binary operation is invalid", plus "No matching user defined OPERATOR with this given type and rank has been defined" (although _everything_ is in order with other compilers), or gives a segmentation fault, depending on the moon phase from what I can tell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
vkock, your program works in recent versions of the Intel 8.0 compiler.
tgaragou, you are using an old version of the compiler. Please update to a current one and see if the problem persists. If it does, please submit an example to Intel Premier Support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ifort -V gives
package ID: l_fc_p_8.0.034
on
http://www.intel.com/software/products/compilers/downloads/forlin.htm
I see the file
I_fc_p_8.0.034.tar.gz
Where is the new version?
package ID: l_fc_p_8.0.034
on
http://www.intel.com/software/products/compilers/downloads/forlin.htm
I see the file
I_fc_p_8.0.034.tar.gz
Where is the new version?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You download the current version from Premier SupportYou have to register your serial number first. Depending on the license you have, you may be limited as to how recent a version you can download. If you have an evaluation or non-commercial license, you can get the version current at the time you got your license.
Starting with the next version, we will be "refreshing" the "web store" copy (what you're looking at) several times a year. You'll still be able to use your Premier Support account to get a current version.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page