# Instructions for Compiling FAST

**URL:** <https://forums.nlr.gov/t/instructions-for-compiling-fast/514>\
**Category:** Computer-Aided Engineering Software Tools\
**Created:** [May 25, 2012, 7:15pm UTC](https://forums.nlr.gov/t/instructions-for-compiling-fast/514 "2012-05-25T19:15:27Z")\
**Posts on this page:** 1\
**Showing post:** 121

<div class="post-metadata">

**Author:** ![Keshan.He](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@Keshan.He](https://forums.nlr.gov/u/Keshan.He)\
**Post date:** [May 8, 2015, 4:42pm UTC](https://forums.nlr.gov/t/instructions-for-compiling-fast/514/121 "2015-05-08T16:42:02Z")

</div>

Hi, Bonnie,  
Thank you very much for your answers.  
I found FAST V8.10 can “ add an additional FAST\_SFunc input from Simulink, just change the third S-Function parameter in the S-Function block in Simulink and then modify FAST\_Library.f90 to handle the new input value” , I think this could help me to add an flap control signal input from simulink.But I met another problem.I modify some FAST source code list as below:  
(1) FAST\_Library.f90  
subroutine FAST\_SetExternalInputs(NumInputs\_c, InputAry, m\_FAST)  
……  
! add some variable  
REAL(ReKi) , DIMENSION(1:3) :: FlapCom\_STU ! Flap commands from Simulink/Labview [rad/s]  
REAL :: COM1\_STU,COM2\_STU,COM3\_STU ! Deliver the flap commands parameter to AeroSubs.f90 file.  
COMMON COM1\_STU,COM2\_STU,COM3\_STU  
……  
IF ( NumInputs\_c \> NumFixedInputs ) THEN ! NumFixedInputs is the fixed number of inputs  
IF ( NumInputs\_c == NumFixedInputs + 3 ) &  
m\_FAST%ExternInput%FlapCom\_STU = InputAry(9:11) ! use the input port InputAry(9:11) to pass the flap commands  
!m\_FAST%ExternInput%LidarFocus = InputAry(9:11)  
END IF  
COM1\_STU = FlapCom\_STU(1)  
COM2\_STU = FlapCom\_STU(2)  
COM3\_STU = FlapCom\_STU(3)  
end subroutine FAST\_SetExternalInputs  
（2）AeroSubs.f90  
SUBROUTINE AD\_GetInput(InitInp, P, x, xd, z, O, y, ErrStat, ErrMess )  
……  
! add some variable  
CHARACTER (1024) :: FlapNm(100)  
INTEGER :: L  
INTEGER :: FlapCom  
REAL :: COM11\_STU,COM12\_STU,COM13\_STU  
COMMON COM11\_STU,COM12\_STU,COM13\_STU  
……  
!read the flap airfoil file name(s)  
CALL ReadAryLines( UnIn, InitInp%ADFileName, FlapNm, 10, AryName=‘FlapNm’, AryDescr=‘Flap file names’, ErrStat=ErrStat, ErrMsg=ErrMess )  
IF (ErrStat \>= AbortErrLev) THEN  
CLOSE(UnIn)  
RETURN  
END IF  
! flap airfoil data file name(s) pass to FlapNm(L)  
DO L=1,10  
IF ( PathIsRelative( FlapNm(L) ) ) FlapNm(L) = TRIM(FilePath)//TRIM( FlapNm(L) )  
END DO  
FlapCom = INT( COM11\_STU ) !Use the COM11\_STU as an flap command single  
! use the new flap airfoil data file to replace the old airfoil data file according to the flap command single  
SELECT CASE (FlapCom)  
CASE(1)  
P%AirFoil%FoilNm(10)=FlapNm(1)  
CASE(2)  
P%AirFoil%FoilNm(10)=FlapNm(2)  
CASE(3)  
P%AirFoil%FoilNm(10)=FlapNm(3)  
CASE(4)  
P%AirFoil%FoilNm(10)=FlapNm(4)  
CASE(5)  
P%AirFoil%FoilNm(10)=FlapNm(5)  
CASE(6)  
P%AirFoil%FoilNm(10)=FlapNm(6)  
CASE(7)  
P%AirFoil%FoilNm(10)=FlapNm(7)  
CASE(8)  
P%AirFoil%FoilNm(10)=FlapNm(8)  
CASE(9)  
P%AirFoil%FoilNm(10)=FlapNm(9)  
CASE(10)  
P%AirFoil%FoilNm(10)=FlapNm(10)  
CASE DEFAULT  
WRITE(_,_)“ERROR”  
STOP  
END SELECT  
……  
Then run the …\Simulink\VisualStudio\FAST\_Library.vfproj, It could create the FAST\_Library\_debug\_Win32.dll. And then use the new FAST\_Library\_debug\_Win32.dll replace the old FAST\_Library \_Win32.dll, and run the Run\_OpenLoop.m file, An error occur , the prompt message are as below:

* * *

```
This segmentation violation occurred while executing the 
S-function 'FAST_SFunc' in block 'O'.
A common cause of this segmentation violation is an incorrect
input port direct feedthrough setting. Each input port of the
S-function that is read (accessed) in mdlOutputs and/or
mdlGetTimeOfNextVarHit must specify that it needs its input
signal in these routines by setting direct feedthrough for
these input ports.
1) To debug your C-MEX S-function, you can enable diagnostics
   by compiling the S-function source with the -g flag, e.g.,
      mex -g sfunction_name.c
2) You can ask Simulink to try assuming your S-function has
   direct feedthrough using:
      set_param('modelname','TryForcingSFcnDF','on')
   If Simulink can find a valid sorting mode that does not
   result in algebraic loops involving your S-function, your
   model will execute (assuming that the cause of this
   segmentation violation is an incorrect direct feedthrough
   setting on an input port).
See matlabroot/simulink/src/sfuntmpl_directfeed.txt
-------------------------------------------------------------

```

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)  
FatalException

```
  There are something wrong happen in the interface of the FAST_SFunc and Matlab\Simulink, I don’t know how to solve it. Can anybody help me?  

```

Best regards,  
keshan

---

_[View the full topic](https://forums.nlr.gov/t/instructions-for-compiling-fast/514)._
