21#include <Perf_counters.h>
30static const char directory_separator =
'\\';
32static const char directory_separator =
'/';
34#include <DeviceMemory.h>
35#include <TRUSTTravPool.h>
36#include <Schema_Comm_Vecteurs.h>
37#include <MD_Vector_tools.h>
39extern void desalloue_pwd();
43 Cerr <<
"TRUST_EXECUTABLE [CASE[.data]] [options]\n";
44 Cerr <<
" CASE is the basename of the trust data file (must have .data extension)\n";
45 Cerr <<
" If no CASE given, the current directory name is used\n";
46 Cerr <<
" -help_trust => print options\n";
47 Cerr <<
" -mpi => run in parallel with MPI (must run with mpirun)\n";
48 Cerr <<
" -check_enabled=0|1 => enables or disables runtime checking of parallel messages\n";
49 Cerr <<
" -debugscript=SCRIPT => execute \"SCRIPT n\" after parallel initialisation, n=processor rank\n";
50 Cerr <<
" -petsc=0 => disable call to PetscInitialize\n";
51 Cerr <<
" -journal=0..9 => select journal level (0=disable, 9=maximum verbosity)\n";
52 Cerr <<
" -journal_master => only master processor writes a journal \n";
53 Cerr <<
" -log_directory=DIR => Writes the .log files into directory DIR\n";
54 Cerr <<
" -disable_ieee => Disable the detection of NaNs. The detection can also be de-activated with env variable TRUST_DISABLE_FP_EXCEPT set to non zero.\n";
55 Cerr <<
" -no_verify => Disable the call to verifie function (from Type_Verifie) to catch outdated keywords while reading data file.\n";
56 Cerr <<
" -disable_stop => Disable the writing of the .stop file.\n";
57 Cerr <<
" -unit => Only perform TRUST initialisation without trying to execute any data file. Used for unit testing.\n";
63#define DEFAULT_CHECK_ENABLED 0
65#define DEFAULT_CHECK_ENABLED 1
68int main_TRUST(
int argc,
char** argv,
mon_main*& main_process,
bool with_mpi,
bool ieee)
81 int check_enabled = DEFAULT_CHECK_ENABLED;
82 bool with_petsc =
true;
84 int verbose_level = -1;
85 bool journal_master =
false;
87 Nom log_directory =
"";
88 bool helptrust =
false;
91#if defined(_COMPILE_AVEC_CLANG) || defined (_COMPILE_AVEC_FCC) || defined(__NVCOMPILER) || defined(__NVCC__)
94 bool apply_verification =
true;
95 bool disable_stop =
false;
96 bool unit_test =
false;
102 arguments_info =
"Executable: ";
103 arguments_info += argv[0];
104 arguments_info +=
"\n";
105 for (
int i = 1; i < argc; i++)
109 if (strcmp(argv[i],
"-help_trust") == 0)
113 else if (strcmp(argv[i],
"-disable_ieee") == 0)
116 arguments_info +=
"-disable_ieee => disable of feenableexcept\n";
118 else if (strcmp(argv[i],
"-mpi") == 0)
121 arguments_info +=
"-mpi => parallel computation with mpi\n";
123 else if (strcmp(argv[i],
"-no_verify") == 0)
125 apply_verification =
false;
126 arguments_info +=
"-no_verify => Disable the call to verifie function (from Type_Verifie) to catch outdated keywords while reading data file.\n";
128 else if (strcmp(argv[i],
"-check_enabled=1") == 0)
130 check_enabled =
true;
131 arguments_info +=
"-check_enabled=1 => force enable parallel message checking\n";
133 else if (strcmp(argv[i],
"-check_enabled=0") == 0)
135 check_enabled =
false;
136 arguments_info +=
"-check_enabled=0 => force disable parallel message checking\n";
138 else if (strncmp(argv[i],
"-debugscript=", 13) == 0)
140 exec_script = argv[i]+13;
141 arguments_info +=
"-debugscript => execute script ";
142 arguments_info += exec_script;
143 arguments_info +=
"\n";
145 else if (strcmp(argv[i],
"-petsc=0") == 0)
148 arguments_info +=
"-petsc=0 => disable call to PetscInitialize\n";
150 else if (strncmp(argv[i],
"-journal=", 9) == 0)
152 int level = atoi(argv[i]+9);
153 if (level < 0 || level > 9)
155 Cerr <<
"Bad journal level : " << argv[i] << finl;
160 verbose_level = level;
161 arguments_info +=
"-journal=";
162 arguments_info +=
Nom(level);
163 arguments_info +=
"\n";
166 else if (strcmp(argv[i],
"-journal_master") == 0)
168 journal_master =
true;
169 arguments_info +=
"-journal_master => Only the master processor will write a journal";
170 arguments_info +=
"\n";
172 else if (strncmp(argv[i],
"-log_directory=", 15) == 0)
174 log_directory = argv[i]+15;
175 log_directory += directory_separator;
176 arguments_info +=
"-log_directory => Writes the .log files into directory ";
177 arguments_info += log_directory;
178 arguments_info +=
"\n";
180 else if (strcmp(argv[i],
"-disable_stop") == 0)
183 arguments_info +=
"-disable_stop => Disable the writing of the .stop file.\n";
185 else if (strcmp(argv[i],
"-unit") == 0)
193 arguments_info +=
"Data file name = ";
194 arguments_info += data_file;
195 arguments_info +=
"\n";
200 int nprocs = (int) strtol(argv[2], (
char **)
nullptr, 10);
201 if (!errno && nprocs)
207 arguments_info +=
"Running in parallel with ";
208 arguments_info +=
Nom(nproc);
209 arguments_info +=
" processors\n";
213 arguments_info +=
"Sequential calculation\n";
217 Cerr <<
"Bad number of processors in old syntax TRUST case N" << finl;
264 statistics().begin_count(STD_COUNTERS::total_execution_time);
265 main_process=
new mon_main(verbose_level, journal_master, log_directory, apply_verification, disable_stop);
266 main_process->
init_parallel(argc, argv, with_mpi, check_enabled, with_petsc);
270 fedisableexcept(FE_ALL_EXCEPT);
274 char* theValue = getenv(
"TRUST_DISABLE_FP_EXCEPT");
275 if (theValue ==
nullptr || atoi(theValue) == 0)
277 arguments_info +=
"feenableexcept enabled.\n";
281 feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
297 if(exec_script !=
"")
301 Cerr <<
"[" <<
Process::me() <<
"] Debug mode => execute command : " << exec_script << finl;
302 std::cerr << system(exec_script) << std::endl;
307 if (helptrust) usage();
311 Cerr << arguments_info;
315 Cerr <<
"Error: nproc on command line does not match mpirun parameter.\n"
316 <<
" Use same number or -mpi parameter instead." << finl;
321 cerr.setf(ios::scientific);
323 cout.setf(ios::scientific);
335 Cerr <<
"No command line argument. Data file name from directory name:\n "
337 const int l = pwd.longueur() - 1;
339 while(i > 0 && pwd[i] != directory_separator)
347 Cerr <<
"Error : pwd() ends with directory separator " << (int)directory_separator << finl;
355 Cerr <<
"Data file : " << data_file << finl;
362 Cerr <<
" (removing .data extension)" << finl;
364 data_file.
prefix(
".data");
369 Cerr<<
"Localisation etude: " << ::pwd() << finl;
370 Cerr<<
"Nom du cas " << data_file << finl;
371 Cerr<<
" code : "<< argv[0] << finl;
372 Cerr<<
" version : " << TRUST_VERSION <<
" " << finl;
375 main_process->
dowork(data_file);
381 Cerr <<
"Arret des processes." << finl;
384 Cerr <<
"DEBUG: Statistics for Trav arrays (int): " << finl;
387 Cerr <<
"DEBUG: Statistics for Trav arrays (double): " << finl;
390 Cerr <<
"DEBUG: Statistics for Trav arrays (float): " << finl;
408 if(statistics().is_running(STD_COUNTERS::total_execution_time))
409 statistics().end_count(STD_COUNTERS::total_execution_time);
class Nom Une chaine de caractere pour nommer les objets de TRUST
virtual int finit_par(const char *const n) const
Nom substr_old(const int, const int) const
Retourne un nom selon la commande usuelle substr ATTENTION : deb = 1 => premier caractere de la chain...
Nom & prefix(const char *const)
static int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
static int me()
renvoie mon rang dans le groupe de communication courant.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
static void CleanMyStaticViews()
Classe creee et executee par main() et lors d'une execution TRUST a travers Python.
void dowork(const Nom &nom_du_cas)
void init_parallel(const int argc, char **argv, bool with_mpi, bool check_enabled=false, bool with_petsc=true)