Beginner to Simulink and FAST V7

Hi, David.

Since NREL didn’t create the Read_Fast_Input_TMD file, I’m not sure any of us can help with the error you are getting. Perhaps Bill La Cava or Semyung Park can help. I’d probably take a look at Read_Fast_Input_TMD and see which line is causing it to stop reading your input file correctly.

Dear all,

I am an MSc student and I am a beginner to Simulink and FAST V7.
I post a reply beacause I have the same problem as the beginning of this conversation.
I have an issue when I run a simulation with FAST V7. Everything works when I use FAST v8 but since I need the linearization model from FAST v7, I changed the version.

I have windows and Matlab 64-bits so I have downloaded FAST_SFunc.mexw64 from the link … 2.00d-bjj/ and put it to the file \Simulink where FAST_SFunc.mexw32 was. But for each run, Matlab is closed without any message in the Matlab Command Window.
I have tried to do like Yanhua: to use a 32-bit Matlab in my 64-bit windows system and use the FAST_SFunc.mexw32 but the problem persists.
It is an important problem for me because I cannot run any simulation or linearization calculs.
Have you an idea to solve this problem?

Thank you in advance.

Best regards,

Hello Bonnie,

I found the mistake in the Read_FAST_Input_TMD and now I can import all the parameters I need! Thank you very much for your help! Nevertheless the simulink model provided by Dr. Lackner still doesnt run because of an error. In the process of eliminating the errors in the model I noticed the following: In the FAST-SC Overview.pdf it is mentioned that the “NREL5MW_Baseline_06b_TMD.mdl” is based on a model, which Dr. Namik from the University of Auckland has developed earlier! I already tried to contact him, but so far he has not replied to my message! I am wondering if you maybe know how I can get access to this simulink model from Dr. Namik? It would help me a lot to understand the changes Prof. Lackner undertook developing his TMD model!

If you dont have access to Dr. Namiks model you can maybe help me with the occuring error. I think the error the error is not directly associated with the TMD module: As soon as I run the model (after reading in the parameters) I get the following status line:
Warning: Invalid arguments passed to ‘dpoly’ drawing command in block ‘NREL5MW_Baseline_06b_TMD/speedfilter’. Polynomial arguments cannot be empty

Error evaluating ‘InitFcn’ callback of block_diagram ‘NREL5MW_Baseline_06b_TMD’. Caused by: Undefined function or variable ‘Model_Inputs’.[/b]

Unfortunately the board attachment quota has been reached, so that I cannot upload any screenshots! But if you have a look into the modell you`ll see that it tries to extract the HSS speed from the green wind turbine block with “u(strmatch(‘GenSpeed’,OutList))” - I added “GenSpeed” to the Outlist before running the model. Next in line is a transfer fcn with numerator w_cut, denominator [1 w_cut] and initial conditions 1173.7*1/w_cut. At the location of this transfer fcn I get the question marks and thats where the warning message points to! Do you have an idea what I may need to change in the primary Input file?

Thanks a lot,


Hi, Audrey.

Depending on the version of Matlab you are using, you may need to recompile the FAST_SFunc mex function. I think the mex file was created with Matlab R2012a so it may not be compatible with your version of Matlab.

Hi, David.

I do not have the files from Dr. Namik. The first error indicates that one or more arguments to dpoly are empty. It looks like the w_cut variable is undefined. The other error refers something called Model_Inputs that is undefined. So, I would guess that you are missing a MATLAB script that defines some variables (including w_cut and Model_Inputs) that are needed for the Simulink model you are running.

Hi Bonnie.

“It looks like the w_cut variable is undefined. The other error refers something called Model_Inputs that is undefined. So, I would guess that you are missing a MATLAB script that defines some variables (including w_cut and Model_Inputs) that are needed for the Simulink model you are running.”

That was my assumption as well! I also thought that the “Model_Inputs error” only occurs because the w_cut variable is missing, but I dont know that for sure. Or could it also be that there is some kind of error in the extraction of “Genspeed” fromthe Output list? When you say “missing a MATLAB script that defines some variables that are needed for the Simulink model”, what exactly do you mean? I am confused because I couldnt find the variable w_cut in any of the UserGuides! Guessing only by the name of the variable, it sounds like it is some kind of cut-off/filter variable! But where exactly do I define those variables (w_cut and Model_Inputs)? Do I need an additional Matlab script for it or would I make additions to one of the existing ones (like source codes, Simsetup, Read_FAST_input)?

Just to see if there are any additional errors in the model I deleted the “speed filter” block from the simulink model and the “Model_Inputs” variable from InitFcn (in the Model Properties window). Then I get the following error:

Input array cannot hold the number of inputs.
Aborting program.
Error while obtaining sizes from MEX S-function ‘FAST_SFunc’ in ‘NREL5MW_Baseline_06b_TMD/FAST Nonlinear Wind Turbine/S-Function’.
Caused by:
Closing program.

I compiled the Fast_Sfunc exactly how it is described in the the make_FAST_Sfunc, that´s why I dont understand why Simulink has a porblem obtaining the sizes! Where exactly do I define the number of inputs/the input array? And how do I know the number of Inputs I need to define?

Thank you very much in advance,


Hi Bonnie,

Thank you for your answer. I am trying to compile FAST_Sfun using Make_FAST_SFun.m file and matlab 32 bits.
I followed the instructions in the matlab script. But I have the following error:

→ Options file specified on command line

→ Options file = intelf12msvs2010shellopts.bat
MATLAB = C:\Program Files (x86)\MATLAB\R2014a32
→ COMPILER = ifort
→ Compiler flags:
COMPFLAGS = /assume:byterecl /traceback /real_size:64 /Qzero /Qsave
arguments =
Name switch = /Fo
→ Pre-linking commands =
→ LINKER = link
→ Link directives:
LINKFLAGS = /dll /export:MEXFUNCTION /LIBPATH:“C:\Program Files (x86)\MATLAB\R2014a32\extern\lib\win32\microsoft” libmx.lib libmex.lib libmat.lib /implib:“C:\Users\AUDREY~1\AppData\Local\Temp\mex_Ha1Z6v\templib.x” /MAP:“” /NOLOGO /manifest /INCREMENTAL:NO
LINKDEBUGFLAGS = /debug /PDB:“FAST_SFunc.mexw32.pdb”
Name directive = /out:“FAST_SFunc.mexw32”
File link directive =
Lib. link directive =
Rsp file indicator = @
→ Resource Compiler = rc /fo “mexversion.res”
→ Resource Linker =

→ ifort /assume:byterecl /traceback /real_size:64 /Qzero /Qsave /FoC:\Users\AUDREY~1\AppData\Local\Temp\mex_Ha1Z6v\DoubPrec.obj /O2 /DNDEBUG -DMX_COMPAT_32 “C:\Users\Audrey Viala\Desktop\Fast v7\Source\NWTC_LIB\Source\DoubPrec.f90”

Intel(R) Visual Fortran Compiler for applications running on IA-32, Version 16.0 Build 20160415
Copyright (C) 1985-2016 Intel Corporation. All rights reserved.

ifort: error #10037: could not find ‘link’

C:\PROGRA~2\MATLAB\R2014A32\BIN\MEX.PL: Error: Compile of ‘C:\Users\Audrey Viala\Desktop\Fast v7\Source\NWTC_LIB\Source\DoubPrec.f90’ failed.

Unable to complete successfully…

I suppose there is a problem with my paths but I am lost between compiler paths, FAST paths and matlab paths…
I have intel fortran compiler with visual studio 2015.I am using MATLAB R2014a 32 bits.
I am not sure about “LINKER=link”
Could you clarify this point for me please?

Thank you very much in advance.

Best regards,

Hi, Audrey.

If the script can’t find the link command, that means the path/include/lib variables in your options .bat file are not set properly. I have found the easiest way to fix this is to copy the variables that the Intel Command Prompt window sets for you.

Open the Intel command prompt (see FAST v7 compiling instructions for descriptions of where you can find this on your computer). In that command window that opens, change to a directory where you have write permissions, then type this:

echo SET TmpPath=%PATH%; >> opts.out echo SET TmpIncl=%INCLUDE%; >> opts.out echo SET TmpLib=%LIB%; >> opts.out This will append three lines to a file called opts.out (you can name it whatever you want, just make sure you don’t overwrite anything important).
Open the opts.out file, copy those three lines, and then paste them into your FortranOptionsFile (the batch script specified in make_FAST_SFunc.m) before the three lines that start with SET PATH= SET INCLUDE= SET LIB=

Now, take a close look at the PATH, INCLUDE, and LIB variables specified in the FortranOptionsFile. Each entry in those lines is separated by a semicolon; Remove each entry in those three lines that doesn’t contain the word “MATLAB”. In my case, that leaves me with:SET PATH=%MATLAB_BIN%; SET INCLUDE= SET LIB=%MATLAB%\extern\lib\win32;

Then, I add the paths that the Intel Command Window gave me, so my final section of code will look something like this:

SET TmpPath=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Progra…
SET TmpIncl=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 1…
SET TmpLib=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB;C:\Program Files (x86)\Microsoft Visual Studio 12.0\V…

SET LIB=%MATLAB%\extern\lib\win32;%TmpLib%;
[/code]Note that I didn’t copy the full TmpPath, TmpIncl, and TmpLib variables here because they are very long. You should obviously copy the full set of paths.


You are using a model that was not developed at NREL, and our User’s Guides will not cover details that are specific to other people’s models. I have never seen the TMD model or the FAST-SC documentation, so I can only guess.

I have seen some models where the Simsetup.m file calls other Matlab scripts to set variables specific to the Simulink model being run. You probably could add these parameters to Simsetup.m, but it’s also possible the missing Matlab script does other things, too.

The “Input array cannot hold the number of inputs” is generated in FASTGateway.f90 (FAST v7). The (NREL) FAST_SFunc assumes there are 2 Generator + 2 Yaw + NumBl blade pitch + 2*NDOF (q, qdot) inputs. If the number of inputs to the FAST_SFunc block in Simulink does not match those values, it aborts. Perhaps the version you are using is different, but that is what is in the code NREL distributes.

Hi Bonnie!

Thank you so much for your help! I have succeded in compiling FAST_SFun mex file.
Now, I will try to use it in simulation to see if the problem with Matlab persists.

Best regards.

Hi Bonnie,

I have looked further the simulation with Simulink and FAST v7 and I have a small question.
Why the parameter “initialized” decrease from 1 to 0 after a simulation?

I have realized that after setting this parameter to 1 and run again a simulation, there is no problem whereas if I let this parameter with the 0 value Matlab is closed.
In the file "Read_FAST_Input.m we can read:

Initialized = 1;                                    % Tells S-function if this script ran prior to simulation.  0 = no.

Is it the FAST_SFun which changes this parameter? And why? It seems causing some problems to run a second simulation without setting to 1 after the first one.

I don’t know if I am very clear but I think it can be the origin of my issue with FAST v7 and Simulink simulation.


The FAST v7 S-Function does change the initialized variable to 0 after initialization. It also checks that it is 1 before it will run. The idea is to make sure you have called Read_FAST_Input.m in Matlab each time you start a model, which makes sure the variables in the Matlab workspace are consistent with the internal variables of the S-Function. If you are running the same model again (using the same, unchanged, FAST input file), it should be okay to reset the initialized variable to 1 without running Read_FAST_Input. The way it was developed, though, it assumes you use Simsetup.m each time you start a model.

Hi Bonnie,

Thank you for your explanation.
With all your instructions I have compiled FAST_SFunc for both 32 and 64 bits.
However, when I try to use them, MATLAB is crashed.

I am trying to run a simulation with the NRELOffshrBsline5MW_OC3Hywind but it does not worked. I don’t really understand what you said in another post: "FAST v7 as distributed does not run the 5MW models. The primary reason is that the Bladed-style DLL controller requires a separate compilation. If you want to run the 5MW model in Simulink, you’ll have to recompile FAST_SFunc using the appropriate source files for the Bladed Interface. " from

  1. How can I use the appropriate DLL file during the compilation?

I have tried to use the one available in the OC3 file: FAST_v7.02.00d-bjj_AeroDyn_v13.00.02a-bjj_BladedDLLInterface_OC3Hywind by remplacing the FAST bladed DLL but the FAST_SFUNC mex after compilation is the same.
2) How can I use the three following files included in the OC3 folder?

  • FAST_v7.02.00d-bjj_AeroDyn_v13.00.02a-bjj_BladedDLLInterface_OC3Hywind
  • DISCON.f90

I feel desperate because I am not able to run a linearization of the OC3 model…
Thank you very much for your help.

Dear Bonnie,

I have encountered the same problem as Audrey. I am using Matlab 2016b 64 bits. I have read the FAST v8 Interface to Simulink from README_FAST8 pdf and did as follows:

  • created the FAST_SFunc.mexw64 using create_FAST_SFunc.m
  • add %FAST_v8\bin to MATLAB path

then I tried running the two samples from %Simulink\Samples.

In both cases matlab crashes (with system error). The OpenLoop file gives the following error message:

Error using Run_OpenLoop (line 30)
Error while obtaining sizes from MEX S-function ‘FAST_SFunc’ in ‘OpenLoop/FAST Nonlinear Wind Turbine/S-Function’.
Caused by:
Error using Run_OpenLoop (line 30)

Hello Everyone,

I am posting on this thread because I have a similar query and I am a beginner with Fast v7.
I am following a documentation from NREL “Simulation for Wind Turbines Generator - With Fast and Matlab-Simulink Module”

During the time I was following the above documentation in the section 4.1.2 I took all the steps necessary to do interface the induction generator in to the Test01_Sig model, and also make the constant as it is in the documentation.

But when I am trying to run my simulation I get these errors. I don`t know what mistake I am doing.
Below is the error when I am trying to run the simulation

Below is the Simulink file related to it and also the m file


Dear Sami,

Your error is regarding a Tmech, which is part of the induction generator model, not provided by NREL. I suggest that you contact the source of this induction generator model for help.

Best regards,

Dear Jason,

thanks for your quick reply the problem is solved. By completely deleting the tmech and put a constant of 0 instead of it.

Thanks anyways

Dear All,

I am an MSc student and I am trying to simulate the NREL 5.0 MW Baseline Wind Turbine, including torque and pitch control using Simulink. I have troubles in this procedure, since it is not so clear to me. As I understand, all the information about the controllers is in the DISCON.dll file that is also included in the .zip file found in Please correct me if I am wrong.

In order to use these controllers I run Simsetup.m and then OpenLoop.mdl. I added in the same folder the files: FAST_SFunc.mexw64, FAST_Library_x64.dll and MAP_x64.dll from FAST v8. I initially used FAST_SFunc.mexw64 from v7.02, but OpenLoop.mdl gave me errors. Finally, after running OpenLoop.mdl, I derive the following error:

My questions are the following:

  1. How can I solve this error?
  2. Is any other way to use the information of the DISCON.dll apart from using Simulink?
  3. Is it correct to use the files I mentioned before from FAST v8?
  4. Since I am simply running the OpenLoop.mdl, should I change anything in it?

Thank you very much for your time!

Best regards,


Dear Georgios,

You shouldn’t need to change anything to run the OpenLoop.mdl. Are you running the OpenLoop.mdl distributed with FAST v8 or FAST v7? When you open the FAST_SFunc block in Simulink, do you see three S-Function parameters (FAST_InputFileName, TMax, 0), as shown in Figure 9 of the FAST v8 ReadMe file: (it should look just like Figure 9 if you are using the OpenLoop.mdl provided with FAST v8)?

Regardless, you don’t need to use the Simulink interface at all if you want to use a controller implemented as a DISCON.dll. The Simulink interface is meant to be used for implementing the controller within Simulink. If you want to use a controller implemented as a DISCON.dll, I would suggest running the FAST executable instead.

Best regards,

Dear Jason,

My apologies for my late response. Thank you very much for your help. I downloaded and used the already compiled executable file “FAST_v7.02.00d-bjj_AeroDyn_v13.00.02a-bjj_BladedDLLInterface.exe” from the directory I also included the “DFORRT.DLL” file in the working directory. It seems that the controller works.

Thank you very much again!

Best regards