Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal handling - SIGTERM will stop calculation and force file saving #2110

Merged
merged 23 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
63270c4
first commit, proof of concept
bigfooted Aug 15, 2023
56411f7
Merge branch 'develop' into feature_signal_handling
bigfooted Aug 15, 2023
7be05ed
move signal handler to coutput
bigfooted Aug 16, 2023
bdfb8fb
Merge branch 'feature_signal_handling' of https://github.com/su2code/…
bigfooted Aug 16, 2023
4d5673d
Merge branch 'develop' into feature_signal_handling
bigfooted Aug 17, 2023
5a7d62d
Merge branch 'develop' into feature_signal_handling
bigfooted Aug 21, 2023
84beef6
Merge branch 'develop' into feature_signal_handling
bigfooted Aug 22, 2023
a3ef34d
Merge branch 'develop' into feature_signal_handling
bigfooted Aug 26, 2023
38f3162
Merge branch 'develop' into feature_signal_handling
bigfooted Sep 4, 2023
16bf9cd
Merge branch 'develop' into feature_signal_handling
bigfooted Sep 15, 2023
8932eed
Merge branch 'develop' into feature_signal_handling
bigfooted Oct 26, 2023
4f4c3ae
Merge branch 'develop' into feature_signal_handling
bigfooted Nov 12, 2023
49324e9
Merge branch 'develop' into feature_signal_handling
bigfooted Nov 17, 2023
2ffc16f
Merge branch 'develop' into feature_signal_handling
bigfooted Feb 7, 2024
f42e22a
Merge branch 'develop' into feature_signal_handling
bigfooted Feb 15, 2024
005dc9b
Merge branch 'develop' into feature_signal_handling
bigfooted Feb 27, 2024
6291179
Merge branch 'develop' into feature_signal_handling
bigfooted Mar 5, 2024
d77d475
Merge branch 'develop' into feature_signal_handling
bigfooted Apr 4, 2024
28b9769
Merge branch 'develop' into feature_signal_handling
bigfooted Apr 24, 2024
ef316f2
Merge branch 'develop' into feature_signal_handling
bigfooted Jun 4, 2024
5da85c6
Merge branch 'develop' into feature_signal_handling
bigfooted Jul 10, 2024
213a947
cleanup
pcarruscag Sep 15, 2024
cd80746
Merge remote-tracking branch 'upstream/develop' into feature_signal_h…
pcarruscag Sep 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions SU2_CFD/src/drivers/CSinglezoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "../../include/output/COutput.hpp"
#include "../../include/iteration/CIteration.hpp"



CSinglezoneDriver::CSinglezoneDriver(char* confFile,
unsigned short val_nZone,
SU2_Comm MPICommunicator) : CDriver(confFile,
Expand All @@ -45,6 +47,7 @@ CSinglezoneDriver::~CSinglezoneDriver() = default;

void CSinglezoneDriver::StartSolver() {


StartTime = SU2_MPI::Wtime();

config_container[ZONE_0]->Set_StartTime(StartTime);
Expand All @@ -66,8 +69,8 @@ void CSinglezoneDriver::StartSolver() {
TimeIter = config_container[ZONE_0]->GetRestart_Iter();

/*--- Run the problem until the number of time iterations required is reached. ---*/
while ( TimeIter < config_container[ZONE_0]->GetnTime_Iter() ) {

/*--- or until a SIGTERM signal stops the loop. We catch SIGTERM and exit gracefully ---*/
while ( TimeIter < config_container[ZONE_0]->GetnTime_Iter()) {
/*--- Perform some preprocessing before starting the time-step simulation. ---*/

Preprocess(TimeIter);
Expand Down
16 changes: 16 additions & 0 deletions SU2_CFD/src/iteration/CFluidIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,21 @@
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
*/

#include <iostream>
#include <csignal>

#include "../../include/iteration/CFluidIteration.hpp"
#include "../../include/output/COutput.hpp"

volatile sig_atomic_t stop;

void signalHandler( int signum ) {
cout << "NIJSO: Interrupt signal (" << signum << ") received.\n";
// cleanup and close up stuff here
stop = 1;
// terminate program
//exit(signum);
}
void CFluidIteration::Preprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry,
CSolver***** solver, CNumerics****** numerics, CConfig** config,
CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement,
Expand Down Expand Up @@ -254,6 +266,7 @@ void CFluidIteration::Solve(COutput* output, CIntegration**** integration, CGeom
unsigned long Inner_Iter, nInner_Iter = config[val_iZone]->GetnInner_Iter();
bool StopCalc = false;

signal(SIGTERM, signalHandler);
/*--- Synchronization point before a single solver iteration.
Compute the wall clock time required. ---*/

Expand Down Expand Up @@ -283,6 +296,9 @@ void CFluidIteration::Solve(COutput* output, CIntegration**** integration, CGeom
Output(output, geometry, solver, config, Inner_Iter, StopCalc, val_iZone, val_iInst);
}

/*--- If signal was sent, we set stopcalc to force writing the files ---*/
if (stop == 1) StopCalc = true;

/*--- If the iteration has converged, break the loop ---*/
if (StopCalc) break;
}
Expand Down
Loading