Borrar filtros
Borrar filtros

MEX fortran help with dummy arguments

4 visualizaciones (últimos 30 días)
Chris
Chris el 18 de Feb. de 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 comentario
Chris
Chris el 18 de Feb. de 2013
the NB is declared as follows:
INTEGER(4), INTENT(IN) :: NB
Forgot to include the INTENT(IN)

Iniciar sesión para comentar.

Respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by