MEX fortran help with dummy arguments

4 次查看(过去 30 天)
Chris
Chris 2013-2-18
I receive the following errors when try to compile my mex file:
pitchmex.f90(54): error #6451: A dummy argument name is required in this context. [NB]
INTEGER(4), INTENT(IN) :: NB ! Number of blades.
-------------------------------^
pitchmex.f90(54): error #6279: A specification expression object must be a dummy argument, a COMMON block object, or an object accessible through host or use association [NB]
INTEGER(4), INTENT(IN) :: NB ! Number of blades.
-------------------------------^
compilation aborted for pitchmex.f90 (code 1)
C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of 'pitchmex.f90' failed.
*************************************************************
Does mex allow for dummy arguments to be passed? I have my variables declared as follows:
INTEGER(4) :: NB ! Number of blades.
REAL(ReKi) :: BlPitch (NB) ! Current values of the blade pitch angles (rad)
(-)
REAL(ReKi) :: HSS_Spd ! HSS speed (rad/s)
REAL(ReKi) :: TFOutput(NB) ! Desired pitch angles returned by this subroutine (rad)
etc...
Is there a problem with making an array with NB size? Is there a way to fix this so I don't have to "hardwire" in a value for NB in the mex routine?
Chris
  1 个评论
Chris
Chris 2013-2-18
the NB is declared as follows:
INTEGER(4), INTENT(IN) :: NB
Forgot to include the INTENT(IN)

请先登录,再进行评论。

回答(1 个)

James Tursa
James Tursa 2013-2-18
编辑:James Tursa 2013-2-18
The compiler is telling you that NB needs to come from an argument list (i.e., a dummy variable). I.e., it is expecting that this statement is inside a subroutine or function and that NB is listed as an argument. Can you post the code above this for the subroutine or function statement? Are BlPitch and TFOutput arguments? Or are they local variables? If local, keep in mind that they will be allocated off of the stack, not the heap, so if NB is very large you will risk a seg fault by blowing your stack size.
  5 个评论
James Tursa
James Tursa 2013-2-25
Last question and then I can post your mex interface code. What do you want the syntax for calling the mex function to be? E.g., would it be this:
function TFOutput = PitchCntrl(BlPitch,DT,ElecPwr,GBRatio,HSS_Spd,TwrAccel,Ztime)
which assumes that NB will be calculated inside mexFunction based on the size of the BlPitch that is passed in from MATLAB.
Chris
Chris 2013-5-15
TFOutput = PitchCntrol( BlPitch, ElecPwr, HSS_Spd, GBRatio, TwrAccel, NB, ZTime, DT, DirRoot)
Can NB be passed or is a work around needed?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by