Question about FAST 8 source code

Dear All

I am trying to modify a little part of the FAST 8 source code. I checked the source code and found that they are all subroutines and modules. I can not find the main Program which means that I do not know where does the code begin to be executed. I am wondering how does this source code begin to be executed? Besides, I found that there is a comment that “FAST_Prog.f90, FAST_IO.f90, FAST_Types.f90, and FAST_Mods.f90 make up the FAST glue code in the FAST Modularization Framework”. But I can not find FAST_Prog.f90 in the source code archive.

Best

XING WEI

Dear Xing,

The main FAST PROGRAM for the FAST executable is included in the source file named FAST_Prog.f90, available in the Source directory of the FAST v8 archive.

Best regards,

Dear Jason

Thank you for your advice. I have been working on modifying the code these days. I would like to add two inputs from Simulink to S-function. These two variables will be added to the dynamics of TMD as external forces. I have changed the relative subroutines and compiled successfully. But when I generate a new S-function and use it in the Simulink.There is an error when I try to change the number of input of S-function. The error is shown below. I am wondering if it is because I did not modify FAST_SFun.c.

Capture.JPG

I have studied FAST_SFun.c but did not found the variable relative to the inputs from Simulink to S-function. I found that the variable “NumFixedInputs” in FAST_Library.f90 represents the number of inputs from Simulink to S-function so I changed this variable. Could you please tell me what part of FAST_SFun.c needs to be changed to add two inputs from Simulink to S-function if it is necessary?

Best

XING WEI

Dear Xing,

The S-Function for FAST v8 was set up with the variable NumAdditionalInputs that can be used to add new inputs to the S-Function without recompiling (although a recompile of the FAST dynamic library is still required to make use of the new inputs).

Regardless, your error appears to be related to a memory allocation in HydroDyn. Can you run this model with the standard FAST libraries supplied by FAST? It may be that your model is too big i.e. requires too much RAM to be run in a 32-bit application (in this case you can use the 64-bit application).

Best regards,

Dear Jason

I do not know why my reply was placed before yours so I submit it again and it is now the last post shown in the list.

Best

XING WEI


Dear Jason

Thank you for your reply! I found that I can successfully change the third parameter of S-function parameters in the beginning without running the simulation. After I run the simulation, I found that the same error will occur when I try to change the third parameters of S-function. Is this normal?

Besides, I am wondering what variable do I need to modify in source code because “NumAddInputs” did not appear in the source code? “NumAddInputs” only appears in FAST_SFun.c.

The code I am using has actually been changed by others with 6 extra inputs to S-function from Simulink. The bad thing is that I can not contact her at the moment. I found that she changed the variable “NumFixedInputs” in FAST_Library.f90. and nothing changed in FAST_SFun.c. I did the same thing to change “NumFixedInputs” and follow what she did in subroutines and compiled the FAST dynamic library successfully. Then I changed the third parameter of S-function parameters but got the following error when running the simulation.

The error shows that it comes from Subroutine “FAST_Updates”. I checked “FAST_Updates” but I found that the error would occur for Subroutine “FAST_Start” first because there are same codes in both subroutines. I attached the codes. Therefore, I think the error should occur for “FAST_Start” first because “FAST_Start” is called earlier than “FAST_Update” but it didn’t. Do you have any idea on this error?

Thank you for your patience! This problem is killing me.

Best

XING WEI

Dear Xing Wei

Based on the new forum topic you started (http://forums.nrel.gov/t/question-about-running-fast-8-in-simulink/1783/1), can I assume that you managed to solve the problem you describe above? Can you clarify how you solved it?

Best regards,

Dear Jason

I solved this by specifying the S-function I used. It was a very stupid error because I found that I did not call the S-function which is linked to the dynamic library I modified. Actually, because I have two folders and both of them have S-function file, I called the other S-function in another folder whose dynamic library was not changed. I am wondering how to direct the S-function because we can only input the name of mex file in S-function parameters in Simulink. If I have two folders in Matlab path, which S-function will it choose?

I am currently adding or removing the Matlab path to ensure that only the right folder is included in the Matlab path.

Best

XING WEI

Dear Xing Wei,

You can use the MATLAB intrinsic “which” function to see which S-Function will be used if there are multiple S-Functions of the same name in the search paths.

Best regards,