14#include "arcane/VerifierService.h"
16#include "arcane/utils/List.h"
17#include "arcane/utils/ITraceMng.h"
18#include "arcane/utils/OStringStream.h"
20#include "arcane/ServiceBuildInfo.h"
21#include "arcane/ISubDomain.h"
22#include "arcane/IVariable.h"
23#include "arcane/IParallelMng.h"
24#include "arcane/IVariableMng.h"
25#include "arcane/ArcaneException.h"
26#include "arcane/CommonVariables.h"
27#include "arcane/SerializeBuffer.h"
28#include "arcane/VariableCollection.h"
29#include "arcane/IMesh.h"
43VerifierService(
const ServiceBuildInfo& sbi)
45, m_sub_domain(sbi.subDomain())
46, m_service_info(sbi.serviceInfo())
82 if (variable->
property() & IVariable::PSubDomainDepend)
98 if (variable->
property() & IVariable::PExecutionDepend)
100 variables.add(variable);
107template<
typename ReaderType>
void VerifierService::
132 catch(
const ReaderWriterException& rw)
136 trace->
pinfo() <<
"Impossible to compare the variable '" << var_name <<
"'\n"
137 <<
"(Exception: " << ostr.str() <<
")";
138 not_compared_str() <<
' ' << var_name;
141 diff_infos.insert(MapDiffInfosValues(var_name,DiffInfo(var_name,nb_diff)));
144 if (nb_not_compared!=0){
145 trace->
warning() <<
"Impossible to compare " << nb_not_compared <<
" variable(s): "
146 << not_compared_str.str();
149 trace->
pfatal() <<
"No variable has been compared";
153 bool is_master = sid==0;
157 for( Integer i=0; i<nb_sub_domain; ++i ){
160 SerializeBuffer sbuf;
161 pm->recvSerializer(&sbuf,i);
162 sbuf.setMode(ISerializer::ModeGet);
165 Int64 n = sbuf.getInt64();
167 for( Integer z=0; z<n; ++z ){
168 Int64 nb_var_diff = sbuf.getInt64();
170 String uvar_name(var_name);
171 trace->
debug() <<
"RECEIVE: "
172 <<
" varname=" << var_name
173 <<
" nbdiff=" << nb_var_diff;
174 MapDiffInfos::iterator i_map = diff_infos.find(uvar_name);
175 if (i_map==diff_infos.end()){
176 diff_infos.insert(MapDiffInfosValues(uvar_name,DiffInfo(uvar_name,nb_var_diff)));
179 i_map->second.m_nb_diff += nb_var_diff;
185 SerializeBuffer sbuf;
186 Int64 nb_diff = diff_infos.size();
187 sbuf.setMode(ISerializer::ModeReserve);
188 sbuf.reserve(DT_Int64,1);
189 for( MapDiffInfos::const_iterator i_map = diff_infos.begin(); i_map!=diff_infos.end(); ++i_map ){
190 const DiffInfo& diff_info = i_map->second;
191 sbuf.reserve(DT_Int64,1);
192 sbuf.reserve(diff_info.m_variable_name);
194 sbuf.allocateBuffer();
195 sbuf.setMode(ISerializer::ModePut);
196 sbuf.putInt64(nb_diff);
197 for( MapDiffInfos::const_iterator i_map = diff_infos.begin(); i_map!=diff_infos.end(); ++i_map ){
198 const DiffInfo& diff_info = i_map->second;
199 Int64 n = diff_info.m_nb_diff;
201 sbuf.put(diff_info.m_variable_name);
203 pm->sendSerializer(&sbuf,0);
209 Int64 total_nb_diff = 0;
210 for( MapDiffInfos::const_iterator i_map = diff_infos.begin(); i_map!=diff_infos.end(); ++i_map )
211 total_nb_diff += i_map->second.m_nb_diff;
213 if (!m_result_file_name.empty()){
214 const CommonVariables& vc = subDomain()->commonVariables();
215 std::ofstream result_file(m_result_file_name.localstr());
216 result_file <<
"<?xml version='1.0'?>\n";
217 result_file <<
"<compare-results"
219 <<
" total-nb-diff='" << total_nb_diff <<
"'"
220 <<
" global-iteration='" << vc.globalIteration() <<
"'"
221 <<
" global-time='" << vc.globalTime() <<
"'"
223 for( MapDiffInfos::const_iterator i_map = diff_infos.begin(); i_map!=diff_infos.end(); ++i_map ){
224 const DiffInfo& diff_info = i_map->second;
225 result_file <<
" <variable>\n"
226 <<
" <name>" << diff_info.m_variable_name <<
"</name>\n"
227 <<
" <nb-diff>" << diff_info.m_nb_diff <<
"</nb-diff>\n"
230 result_file <<
"</compare-results>\n";
232 if (total_nb_diff!=0){
233 trace->
error() <<
"Some differences exist (N=" << total_nb_diff <<
") with the reference file";
236 trace->
info() <<
"No difference with the reference !";
245void VerifierService::
246_doVerif(IDataReader* reader,
const VariableList& variables,
bool compare_ghost)
248 _doVerif2(reader,variables,compare_ghost);
Interface de la classe de base des objets principaux arcane.
virtual IParallelMng * parallelMng()=0
Gestionnaire de parallèlisme.
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual Int32 commRank() const =0
Rang de cette instance dans le communicateur.
virtual Int32 commSize() const =0
Nombre d'instance dans le communicateur.
virtual void barrier()=0
Effectue une barière.
Interface du gestionnaire d'un sous-domaine.
Interface du gestionnaire de variables.
Interface d'une variable.
virtual int property() const =0
Retourne les propriétés de la variable.
virtual eItemKind itemKind() const =0
Type des entités du maillage sur lequel repose la variable.
virtual Integer checkIfSame(IDataReader *reader, Integer max_print, bool compare_ghost)=0
Vérifie que la variable est identique à une valeur de référence.
virtual MeshHandle meshHandle() const =0
Maillage auquel est associé la variable.
virtual String name() const =0
Nom de la variable.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Flot de sortie lié à une String.
Interface du gestionnaire de traces.
virtual TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium)=0
Flot pour un message de debug.
virtual TraceMessage warning()=0
Flot pour un message d'avertissement.
virtual TraceMessage pinfo()=0
Flot pour un message d'information parallèle.
virtual TraceMessage info()=0
Flot pour un message d'information.
virtual TraceMessage pfatal()=0
Flot pour un message d'erreur fatale parallèle.
virtual TraceMessage error()=0
Flot pour un message d'erreur.
Chaîne de caractères unicode.
ITraceMng * traceMng() const
Gestionnaire de trace.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
@ IK_Unknown
Entité de maillage de genre inconnu ou non initialisé