TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Catch_SIGINIT.cpp
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Catch_SIGINIT.h>
17
20
22{
23 if (NB_CAUGHT_SIGNALS_ < 2)
24 {
26 {
27 std::cerr << " " << std::endl;
28 std::cerr << "=======================================================" << std::endl;
29 std::cerr << " " << std::endl;
30 std::cerr << "Caught signal " << signum << std::endl;
31 std::cerr << "We are trying to finish the simulation correctly ... " << std::endl;
32 std::cerr << " " << std::endl;
33 std::cerr << "=======================================================" << std::endl;
34 std::cerr << " " << std::endl;
35 }
36 }
37 else // force an exit
38 {
40 {
41 std::cerr << " " << std::endl;
42 std::cerr << "=======================================================" << std::endl;
43 std::cerr << " " << std::endl;
44 std::cerr << "Multiple signals " << signum <<" are caught !" << std::endl;
45 std::cerr << "We are forcing the exit of the processors ... " << std::endl;
46 std::cerr << " " << std::endl;
47 std::cerr << "=======================================================" << std::endl;
48 std::cerr << " " << std::endl;
49 }
51 }
52
53 // Terminate TRUST correctly => print 1 in stop file
54 Nom command = "echo '1' > ";
55 command += NOM_DU_CAS_;
56 command += ".stop";
57
58 NB_CAUGHT_SIGNALS_++; // force an exit when nb_caught_signals = 2 (3 tries)
59
60 int err = system(command);
61 if (err)
62 {
64 std::cerr << "We can not finish the simulation correctly because the stop file " << NOM_DU_CAS_<<".stop is not in the directory !" << std::endl;
66 }
67}
static Nom NOM_DU_CAS_
static int NB_CAUGHT_SIGNALS_
static void signal_callback_handler(int signum)
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Definition Process.cpp:86