MEX fortran help with dummy arguments

13 views (last 30 days)
Chris
Chris on 18 Feb 2013
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 Comment
Chris
Chris on 18 Feb 2013
the NB is declared as follows:
INTEGER(4), INTENT(IN) :: NB
Forgot to include the INTENT(IN)

Sign in to comment.

Answers (1)

James Tursa
James Tursa on 18 Feb 2013
Edited: James Tursa on 18 Feb 2013
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 Comments
James Tursa
James Tursa on 25 Feb 2013
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 on 15 May 2013
TFOutput = PitchCntrol( BlPitch, ElecPwr, HSS_Spd, GBRatio, TwrAccel, NB, ZTime, DT, DirRoot)
Can NB be passed or is a work around needed?

Sign in to comment.

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!