TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
System.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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 <System.h>
17#include <Nom.h>
18
19Implemente_instanciable(System,"System",Interprete);
20// XD system interprete system INHERITS_BRACE To run Unix commands from the data file. Example: System \'echo The End |
21// XD_CONT mail trust@cea.fr\'
22// XD attr cmd chaine cmd REQ command to execute.
23
24
26{
27 return s << que_suis_je() << finl;
28}
29
31{
32 return is;
33}
34
36{
37 Nom instruction,suite;
38 is >> instruction;
39 if (instruction[0]!='"')
40 {
41 Cerr<<"In System, instruction should begin by \""<<finl;
42 Cerr<<"instruction beginning "<<instruction;
43 exit();
44 }
45 instruction.suffix("\"");
46 while(instruction[instruction.longueur()-2]!='"')
47 {
48 is >> suite;
49 assert(is.good());
50 instruction+=" ";
51 instruction+=suite;
52 }
53 instruction.prefix("\"");
54
55
56 if (je_suis_maitre())
57 {
58 Cerr<<"Shell command executed: " << instruction<<finl;
59 int error = system(instruction);
60 if (error)
61 {
62 Cerr << "The shell command returns an error: " << error << finl;
63 Cerr << "Check your data file." << finl;
64 exit();
65 }
66 }
67 barrier();
68 return is;
69}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual int good()
Definition Entree.cpp:270
Classe de base des objets "interprete".
Definition Interprete.h:38
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
int longueur() const
Renvoie le nombre de caracteres de la chaine du Nom y compris le caractere zero de fin de chaine.
Definition Nom.cpp:191
Nom & prefix(const char *const)
Definition Nom.cpp:329
Nom & suffix(const char *const)
Extraction de suffixe : Nom x("azerty");.
Definition Nom.cpp:271
friend class Entree
Definition Objet_U.h:76
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void barrier()
Synchronise tous les processeurs du groupe courant (attend que tous les processeurs soient arrives a ...
Definition Process.cpp:136
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
Classe de base des flux de sortie.
Definition Sortie.h:52
Entree & interpreter(Entree &) override
Definition System.cpp:35