Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Error 5082 - mex file

cptfisher
Beginner
1,769 Views
Good Day,

I keep receiving the following error when trying to compile my fortran mex file and I don't understant why.

>> mex aerotest.f90 aerodyntest.obj
aerotest.f90(94): error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( % [ . = =>
Two(A,B,C,D,TurbineComponents)
-------------------------------------^
compilation aborted for aerotest.f90 (code 1)


I removed the compiler option from the mexops file that only reads .f files and have compiled other .f90 files without a problem. Any idea why its not reading the parentheses for the function Two?
0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,769 Views
It's not that "it's not reading the parentheses", but rather that this is not valid syntax for a Fortran statement. See this thread for an earlier discussion of the same issue. If this is in a sample coming with Matlab, you really should report the error to Mathworks.
0 Kudos
cptfisher
Beginner
1,769 Views
Thanks Steve. Its not a Mathworks sample, just something I'm working on for a project.

Now I remember the previous post, so I would put the function in a module like below, with the function Two declared as type AeroConfig?:
*********************
module structmod

implicit none

contains

function Two(TurbineComponents)

Type Marker
Real(8) :: Position (3)
Real(8) :: Orientation (3,3)
Real(8) :: RotationVel (3)
Real(8) :: TranslationVel (3)
End Type Marker

Type AeroConfig
Real(8) :: Hub
End Type AeroConfig

Type(AeroConfig), Intent(In) :: TurbineComponents
Type(AeroConfig) :: Two

Two = TurbineComponents * 2

end function Two

end module structmod
**************************

Then interface using
interface operator(*)
module procedure Two
end interface
0 Kudos
Steven_L_Intel1
Employee
1,769 Views
I should have noticed you had asked the same question earlier. As I said earlier, you can't multiply a derived component, but for your purposes, all you want is Two to multiply each of the components by 2, which could be done something like this:

[plain]function Two(TurbineComponents) Type Marker Real(8) :: Position (3) Real(8) :: Orientation (3,3) Real(8) :: RotationVel (3) Real(8) :: TranslationVel (3) End Type Marker Type AeroConfig Real(8) :: Hub End Type AeroConfig Type(AeroConfig), Intent(In) :: TurbineComponents Type(AeroConfig) :: Two Two = TurbineComponents Two%Position = Two%Position * 2 Two%Orientation = Two%Orientation * 2 Two%RotationVel = Two%RotationVel * 2 Two%TranslationVel = Two%TranslationVel * 2 end function Two[/plain] However, I don't know how MATLAB is expecting to receive the function result. Fortran would expect a hidden argument to be passed with the function result. As written, MATLAB would need to call it TWO as Fortran upcases by default (on Windows.) Also, I don't see that you used Hub at all here.
0 Kudos
cptfisher
Beginner
1,769 Views
Thanks Steve. Hub is used as follows, my code had an error:
TypeAeroConfig
Type(Marker) ::Hub
EndTypeAeroConfig

so I think it would then change to
Two%Hub%Position = Two%Hub%Position * 2

I was able to compile the module and but I still receive the same 5082 error when compiling the mex file.

Would I still need to do the interface if the USE module statement is used in the mex file?

Is below correct?
interface operator(*)
module procedure Two
end interface


I would like for the argument to be passed to matlab as TurbineComponents_Hub_Position to match up with the code in matlab.


0 Kudos
Steven_L_Intel1
Employee
1,769 Views
Yes - the Hub component needs to be in all the references. You would not use a module here - just the function. You have not showed the statement that gets the error. I also don't know how Matlab calls a function that returns a structure.
0 Kudos
cptfisher
Beginner
1,769 Views
Hi Steve,

Its the following errors

structgate.f90(10): error #5082: Syntax error, found '(' when expecting one of: , ;
module procedure Two(TurbineComponents)
-------------------------^
structgate.f90(70): error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( % [ . = =>
Two(TurbineComponents)
-----------------------^


0 Kudos
Steven_L_Intel1
Employee
1,769 Views
The first one is because in a MODULE PROCEDURE declaration, you just give the name of the procedure (which follows in the moduke).

The second is similar to the one we discussed before - that isn't valid Fortran. If you want to call the function, you would typically use it in an assignment statement.

As I wrote earlier, you don't need a module for this purpose.
0 Kudos
Reply