From 4ea36cb5e365f7c8da51927a1efcd45b22f26711 Mon Sep 17 00:00:00 2001 From: Bonnie Jonkman Date: Thu, 13 Mar 2025 12:14:28 -0600 Subject: [PATCH] Avoid ending program when called as a shared library When running from Simulink, Matlab would end (instead of the DLL). This PR fixes the problem. --- modules/openfast-library/src/FAST_Subs.f90 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/openfast-library/src/FAST_Subs.f90 b/modules/openfast-library/src/FAST_Subs.f90 index f8d11cb72a..1b0050734c 100644 --- a/modules/openfast-library/src/FAST_Subs.f90 +++ b/modules/openfast-library/src/FAST_Subs.f90 @@ -9615,12 +9615,16 @@ SUBROUTINE ExitThisProgram( p_FAST, y_FAST, m_FAST, ED, SED, BD, SrvD, AD, ADsk, SimMsg = TRIM(FAST_Ver%Name)//' encountered an error '//TRIM(SimMsg)//'.'//NewLine//' Simulation error level: '//TRIM(GetErrStr(ErrorLevel)) +#if (defined COMPILE_SIMULINK || defined COMPILE_LABVIEW) + ! When built as a shared library/dll, don't end the program. + CALL WrScr(trim(SimMsg)) +#else if (StopTheProgram) then CALL ProgAbort( trim(SimMsg), TrapErrors=.FALSE., TimeWait=3._ReKi ) ! wait 3 seconds (in case they double-clicked and got an error) else CALL WrScr(trim(SimMsg)) end if - +#endif END IF !............................................................................................................................