Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: How to build a wrapper for RTW TLC Fortran function
Date: Wed, 17 Apr 2013 20:50:08 +0000 (UTC)
Organization: Embraer
Lines: 39
Message-ID: <kkn1u0$gj5$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1366231808 16997 172.30.248.35 (17 Apr 2013 20:50:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 17 Apr 2013 20:50:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 4168151
Xref: news.mathworks.com comp.soft-sys.matlab:793771

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