Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to build a wrapper for RTW TLC Fortran function

Subject: How to build a wrapper for RTW TLC Fortran function

From: Cesar Lopes

Date: 17 Apr, 2013 20:50:08

Message: 1 of 1

I have a legacy code in Fortran I want to incorporate it to a Simulink model, to be compiled using the RTW.

I developed a wrapper function in C (S-Function level 2), which invokes the function fortran compiled (. Obj). Everything works perfectly in Simulink (MEX S-Function). However, errors occur when attempting to compile using RTW.

I created a file for TLC s-function with the following content:

---------------------------------------------------------------------
% implements "MyWrapperSFunction" "C"

BlockTypeSetup% function (block, system) void
   openfile% buffer
extern void FUNC_FORTRAN (real_T INPUT, OUTPUT real_T);

   closefile% buffer
   % <LibCacheFunctionPrototype(buffer)>
   % <LibAddToModelSources("FUNC_FORTRAN")>
% endfunction%% BlockTypeSetup

% function Outputs (block, system) Output
   / *% <Type> Block:% <Name> * /
   % assign input LibBlockInputSignal = (0, "", "", 0)
   % assign LibBlockOutputSignal output = (0, "", "", 0)
     FUNC_FORTRAN (% <input>, <output>%);


% endfunction%% Outputs

----------------------------------------------------------------


I get error messages saying that it can not find the file FUNC_FORTRAN.obj. However, it is in the same directory as the .tlc file.

When I manually put the obj file in the folder created during compilation (containing the files .mk .bat, etc.), I get other error messages saying it could not find Fortran libs.

Someone already made a wrapper function for Fortran and compiled it with RTW?

Thanks for the help.

César

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us