- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I receive the following erros when trying to compile a fortran mex file and wanted to see if anyone could help me solve the problem:
aerocalc.f90(96): error #6355: This binary operation is invalid for this data type. [TURBINECOMPONENTS]
y_output = (TurbineComponents) * 2
------------^
aerocalc.f90(96): error #6549: An arithmetic or LOGICAL type is required in this context.
y_output = (TurbineComponents) * 2
-------------------------------^
compilation aborted for aerocalc.f90 (code 1)
I just want to be able to pass the components to a simple fortran function.
TurbineComponents is type aeroconfig/marker which are the following:
TYPE :: Marker
REAL(8) :: Position(3)
REAL(8) :: Orientation(3,3) ! Direction Cosine Matrix (DCM)
REAL(8) :: TranslationVel(3)
REAL(8) :: RotationVel(3)
END TYPE Marker
TYPE :: AeroConfig
TYPE(Marker), ALLOCATABLE :: Blade(:)
REAL(8) :: BladeLength
TYPE(Marker) :: Hub
TYPE(Marker) :: RotorFurl
TYPE(Marker) :: Nacelle
TYPE(Marker) :: TailFin
TYPE(Marker) :: Tower
TYPE(Marker) :: Substructure
TYPE(Marker) :: Foundation
END TYPE AeroConfig
I receive the following erros when trying to compile a fortran mex file and wanted to see if anyone could help me solve the problem:
aerocalc.f90(96): error #6355: This binary operation is invalid for this data type. [TURBINECOMPONENTS]
y_output = (TurbineComponents) * 2
------------^
aerocalc.f90(96): error #6549: An arithmetic or LOGICAL type is required in this context.
y_output = (TurbineComponents) * 2
-------------------------------^
compilation aborted for aerocalc.f90 (code 1)
I just want to be able to pass the components to a simple fortran function.
TurbineComponents is type aeroconfig/marker which are the following:
TYPE :: Marker
REAL(8) :: Position(3)
REAL(8) :: Orientation(3,3) ! Direction Cosine Matrix (DCM)
REAL(8) :: TranslationVel(3)
REAL(8) :: RotationVel(3)
END TYPE Marker
TYPE :: AeroConfig
TYPE(Marker), ALLOCATABLE :: Blade(:)
REAL(8) :: BladeLength
TYPE(Marker) :: Hub
TYPE(Marker) :: RotorFurl
TYPE(Marker) :: Nacelle
TYPE(Marker) :: TailFin
TYPE(Marker) :: Tower
TYPE(Marker) :: Substructure
TYPE(Marker) :: Foundation
END TYPE AeroConfig
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You will have to write a function that accepts an argument of type AeroConfig, an argument of integer, and "multiplies" them, whatever that means. It might mean multiplying each of the REAL subcomponents of each component of type AeroConfig. This function would return a value of type AeroConfig that has the result. Then you'd declare an interface something like this:
interface operator(*)
module procedure my_multiply ! Or whatever you want to call it
end interface
This assumes you put this in a module - if not, you would include the specification of the function in the interface block.
Or you can just write your MEX-callable procedure to do the multiply directly rather than trying to express it as a multiply of a derived type by a constant.
interface operator(*)
module procedure my_multiply ! Or whatever you want to call it
end interface
This assumes you put this in a module - if not, you would include the specification of the function in the interface block.
Or you can just write your MEX-callable procedure to do the multiply directly rather than trying to express it as a multiply of a derived type by a constant.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
need more information.
how you set it
and how you pass it/use it
and how it is defined in the called routine
from the error message you don't have it properly defined for the way you are using it!
how you set it
and how you pass it/use it
and how it is defined in the called routine
from the error message you don't have it properly defined for the way you are using it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I understand what you have written, TurbineComponents is a variable of derived type. There is no built-in definition of what it means to multiply a derived type variable, though you can define one. I don't see any function here, so I don't know what you are trying to accomplish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for the confusion. Yes, TurbineComponents is a variable of derived type. I want to be able to input the TurbineComponents by Matlab and then use the fortran mex file for the calculation:
Type(aeroconfig) :: TurbineComponents, y_output
and use the below subroutine in the mex file:
subroutine doublevector(y_output, TurbineComponents)
TYPE :: Marker
REAL(8) :: Position(3)
REAL(8) :: Orientation(3,3)
REAL(8) :: TranslationVel(3)
REAL(8) :: RotationVel(3)
END TYPE Marker
TYPE :: AeroConfig
TYPE(Marker), ALLOCATABLE :: Blade(:)
REAL(8) :: BladeLength
TYPE(Marker) :: Hub
TYPE(Marker) :: RotorFurl
TYPE(Marker) :: Nacelle
TYPE(Marker) :: TailFin
TYPE(Marker) :: Tower
TYPE(Marker) :: Substructure
TYPE(Marker) :: Foundation
END TYPE AeroConfig
Type(AeroConfig) :: TurbineComponents, y_output
y_output = (TurbineComponents) * 2
return
end
Type(aeroconfig) :: TurbineComponents, y_output
and use the below subroutine in the mex file:
subroutine doublevector(y_output, TurbineComponents)
TYPE :: Marker
REAL(8) :: Position(3)
REAL(8) :: Orientation(3,3)
REAL(8) :: TranslationVel(3)
REAL(8) :: RotationVel(3)
END TYPE Marker
TYPE :: AeroConfig
TYPE(Marker), ALLOCATABLE :: Blade(:)
REAL(8) :: BladeLength
TYPE(Marker) :: Hub
TYPE(Marker) :: RotorFurl
TYPE(Marker) :: Nacelle
TYPE(Marker) :: TailFin
TYPE(Marker) :: Tower
TYPE(Marker) :: Substructure
TYPE(Marker) :: Foundation
END TYPE AeroConfig
Type(AeroConfig) :: TurbineComponents, y_output
y_output = (TurbineComponents) * 2
return
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You will have to write a function that accepts an argument of type AeroConfig, an argument of integer, and "multiplies" them, whatever that means. It might mean multiplying each of the REAL subcomponents of each component of type AeroConfig. This function would return a value of type AeroConfig that has the result. Then you'd declare an interface something like this:
interface operator(*)
module procedure my_multiply ! Or whatever you want to call it
end interface
This assumes you put this in a module - if not, you would include the specification of the function in the interface block.
Or you can just write your MEX-callable procedure to do the multiply directly rather than trying to express it as a multiply of a derived type by a constant.
interface operator(*)
module procedure my_multiply ! Or whatever you want to call it
end interface
This assumes you put this in a module - if not, you would include the specification of the function in the interface block.
Or you can just write your MEX-callable procedure to do the multiply directly rather than trying to express it as a multiply of a derived type by a constant.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help Steve

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