From 5ca2b9073a3d2bbbb9322cddf9fc123de977bbfd Mon Sep 17 00:00:00 2001 From: Bonnie Jonkman Date: Wed, 13 Jul 2022 11:13:37 -0600 Subject: [PATCH 1/4] S-Function build The Simulink S-Function in OpenFAST v3.2.0 does not build. These are the changes I made to get it to build. Here are the error message from the build: .\..\..\modules\openfast-library\src\FAST_Library.h(29): error C2143: syntax error: missing ')' before '=' ..\..\..\modules\openfast-library\src\FAST_Library.h(29): error C2072: 'FAST_Sizes': initialization of a function ..\..\..\modules\openfast-library\src\FAST_Library.h(29): error C2059: syntax error: 'type' C:\\openfast\glue-codes\simulink\src\FAST_SFunc.c(206): error C2198: 'FAST_Sizes': too few arguments for call --- glue-codes/simulink/src/FAST_SFunc.c | 2 +- modules/openfast-library/src/FAST_Library.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/glue-codes/simulink/src/FAST_SFunc.c b/glue-codes/simulink/src/FAST_SFunc.c index 1faef333a..06a9f9de5 100644 --- a/glue-codes/simulink/src/FAST_SFunc.c +++ b/glue-codes/simulink/src/FAST_SFunc.c @@ -203,7 +203,7 @@ static void mdlInitializeSizes(SimStruct *S) FAST_AllocateTurbines(&nTurbines, &ErrStat, ErrMsg); if (checkError(S)) return; - FAST_Sizes(&iTurb, InputFileName, &AbortErrLev, &NumOutputs, &dt, &ErrStat, ErrMsg, ChannelNames, &TMax, InitInputAry); + FAST_Sizes(&iTurb, InputFileName, &AbortErrLev, &NumOutputs, &TMax, &dt, &ErrStat, ErrMsg, ChannelNames, &TMax, InitInputAry); n_t_global = -1; if (checkError(S)) return; diff --git a/modules/openfast-library/src/FAST_Library.h b/modules/openfast-library/src/FAST_Library.h index 61b3db54a..869169f2b 100644 --- a/modules/openfast-library/src/FAST_Library.h +++ b/modules/openfast-library/src/FAST_Library.h @@ -26,7 +26,7 @@ EXTERNAL_ROUTINE void FAST_OpFM_Step(int * iTurb, int *ErrStat, char *ErrMsg); EXTERNAL_ROUTINE void FAST_HubPosition(int * iTurb, float * absolute_position, float * rotation_veocity, double * orientation_dcm, int *ErrStat, char *ErrMsg); EXTERNAL_ROUTINE void FAST_Restart(int * iTurb, const char *CheckpointRootName, int *AbortErrLev, int * NumOuts, double * dt, int * n_t_global, int *ErrStat, char *ErrMsg); -EXTERNAL_ROUTINE void FAST_Sizes(int * iTurb, const char *InputFileName, int *AbortErrLev, int * NumOuts, double * dt, double * tmax, int *ErrStat, char *ErrMsg, char *ChannelNames, double *TMax = NULL, double *InitInputAry = NULL); +EXTERNAL_ROUTINE void FAST_Sizes(int * iTurb, const char *InputFileName, int *AbortErrLev, int * NumOuts, double * dt, double * tmax, int *ErrStat, char *ErrMsg, char *ChannelNames, double *TMax, double *InitInputAry); EXTERNAL_ROUTINE void FAST_Start(int * iTurb, int *NumInputs_c, int *NumOutputs_c, double *InputAry, double *OutputAry, int *ErrStat, char *ErrMsg); EXTERNAL_ROUTINE void FAST_Update(int * iTurb, int *NumInputs_c, int *NumOutputs_c, double *InputAry, double *OutputAry, bool *EndSimulationEarly, int *ErrStat, char *ErrMsg); EXTERNAL_ROUTINE void FAST_End(int * iTurb, bool * stopThisProgram); From 5c65c7a8138558cdb274be8627e886bdfa987ba1 Mon Sep 17 00:00:00 2001 From: Bonnie Jonkman Date: Wed, 13 Jul 2022 11:34:55 -0600 Subject: [PATCH 2/4] Add conditional compile for C++ vs C definition Maybe there is a better way to code this??? --- modules/openfast-library/src/FAST_Library.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/openfast-library/src/FAST_Library.h b/modules/openfast-library/src/FAST_Library.h index 869169f2b..3c5f4cd65 100644 --- a/modules/openfast-library/src/FAST_Library.h +++ b/modules/openfast-library/src/FAST_Library.h @@ -26,7 +26,11 @@ EXTERNAL_ROUTINE void FAST_OpFM_Step(int * iTurb, int *ErrStat, char *ErrMsg); EXTERNAL_ROUTINE void FAST_HubPosition(int * iTurb, float * absolute_position, float * rotation_veocity, double * orientation_dcm, int *ErrStat, char *ErrMsg); EXTERNAL_ROUTINE void FAST_Restart(int * iTurb, const char *CheckpointRootName, int *AbortErrLev, int * NumOuts, double * dt, int * n_t_global, int *ErrStat, char *ErrMsg); +#ifdef __cplusplus +EXTERNAL_ROUTINE void FAST_Sizes(int * iTurb, const char *InputFileName, int *AbortErrLev, int * NumOuts, double * dt, double * tmax, int *ErrStat, char *ErrMsg, char *ChannelNames, double *TMax = NULL, double *InitInputAry = NULL); +#else EXTERNAL_ROUTINE void FAST_Sizes(int * iTurb, const char *InputFileName, int *AbortErrLev, int * NumOuts, double * dt, double * tmax, int *ErrStat, char *ErrMsg, char *ChannelNames, double *TMax, double *InitInputAry); +#endif EXTERNAL_ROUTINE void FAST_Start(int * iTurb, int *NumInputs_c, int *NumOutputs_c, double *InputAry, double *OutputAry, int *ErrStat, char *ErrMsg); EXTERNAL_ROUTINE void FAST_Update(int * iTurb, int *NumInputs_c, int *NumOutputs_c, double *InputAry, double *OutputAry, bool *EndSimulationEarly, int *ErrStat, char *ErrMsg); EXTERNAL_ROUTINE void FAST_End(int * iTurb, bool * stopThisProgram); From d37e809039e38d6571ae054c2efadedcabed4692 Mon Sep 17 00:00:00 2001 From: Bonnie Jonkman Date: Thu, 14 Jul 2022 10:52:16 -0600 Subject: [PATCH 3/4] Simulink S-function: Fix argument order --- glue-codes/simulink/src/FAST_SFunc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/glue-codes/simulink/src/FAST_SFunc.c b/glue-codes/simulink/src/FAST_SFunc.c index 06a9f9de5..12dc67160 100644 --- a/glue-codes/simulink/src/FAST_SFunc.c +++ b/glue-codes/simulink/src/FAST_SFunc.c @@ -204,6 +204,7 @@ static void mdlInitializeSizes(SimStruct *S) if (checkError(S)) return; FAST_Sizes(&iTurb, InputFileName, &AbortErrLev, &NumOutputs, &TMax, &dt, &ErrStat, ErrMsg, ChannelNames, &TMax, InitInputAry); + FAST_Sizes(&iTurb, InputFileName, &AbortErrLev, &NumOutputs, &dt, &TMax, &ErrStat, ErrMsg, ChannelNames, &TMax, InitInputAry); n_t_global = -1; if (checkError(S)) return; From 03baffb21b14a32175d5e837235f0162073c83b5 Mon Sep 17 00:00:00 2001 From: Bonnie Jonkman Date: Thu, 14 Jul 2022 11:00:05 -0600 Subject: [PATCH 4/4] remove extra line from previous commit --- glue-codes/simulink/src/FAST_SFunc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/glue-codes/simulink/src/FAST_SFunc.c b/glue-codes/simulink/src/FAST_SFunc.c index 12dc67160..b03d689a9 100644 --- a/glue-codes/simulink/src/FAST_SFunc.c +++ b/glue-codes/simulink/src/FAST_SFunc.c @@ -203,7 +203,6 @@ static void mdlInitializeSizes(SimStruct *S) FAST_AllocateTurbines(&nTurbines, &ErrStat, ErrMsg); if (checkError(S)) return; - FAST_Sizes(&iTurb, InputFileName, &AbortErrLev, &NumOutputs, &TMax, &dt, &ErrStat, ErrMsg, ChannelNames, &TMax, InitInputAry); FAST_Sizes(&iTurb, InputFileName, &AbortErrLev, &NumOutputs, &dt, &TMax, &ErrStat, ErrMsg, ChannelNames, &TMax, InitInputAry); n_t_global = -1; if (checkError(S)) return;