TrioCFD 1.9.9_beta
TrioCFD documentation
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
Base class for "interpreter" objects.
Definition Interprete.h:38
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
int longueur() const
Returns the number of characters in the Nom string, including the null terminator.
Definition Nom.cpp:187
Nom & prefix(const char *const)
Definition Nom.cpp:324
Nom & suffix(const char *const)
Suffix extraction: Nom x("azerty");.
Definition Nom.cpp:266
friend class Entree
Definition Objet_U.h:71
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static void barrier()
Synchronizes all processors in the current group (waits until all processors have reached the barrier...
Definition Process.cpp:133
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
Base class for output streams.
Definition Sortie.h:52
Entree & interpreter(Entree &) override
Definition System.cpp:35