필터 지우기
필터 지우기

MEX fortran help with dummy arguments

조회 수: 3 (최근 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