14#include "arcane/impl/InternalInfosDumper.h"
16#include "arcane/utils/String.h"
17#include "arcane/utils/PlatformUtils.h"
18#include "arcane/utils/FatalErrorException.h"
19#include "arcane/utils/ITraceMng.h"
20#include "arcane/utils/ScopedPtr.h"
21#include "arcane/utils/ApplicationInfo.h"
22#include "arcane/utils/JSONWriter.h"
23#include "arcane/utils/FileContent.h"
25#include "arcane/Parallel.h"
26#include "arcane/IParallelMng.h"
27#include "arcane/Directory.h"
28#include "arcane/ServiceFinder2.h"
29#include "arcane/IApplication.h"
30#include "arcane/ICodeService.h"
31#include "arcane/SubDomainBuildInfo.h"
32#include "arcane/IServiceLoader.h"
33#include "arcane/IParallelSuperMng.h"
34#include "arcane/IMainFactory.h"
35#include "arcane/ISession.h"
36#include "arcane/ISubDomain.h"
37#include "arcane/ITimeLoopMng.h"
38#include "arcane/IVariableMng.h"
39#include "arcane/IXmlDocumentHolder.h"
40#include "arcane/XmlNodeList.h"
41#include "arcane/IModuleMng.h"
42#include "arcane/IModule.h"
43#include "arcane/VariableRef.h"
44#include "arcane/VariableCollection.h"
45#include "arcane/IIOMng.h"
46#include "arcane/ITimeLoop.h"
47#include "arcane/ICaseMng.h"
48#include "arcane/ICaseOptions.h"
49#include "arcane/IRessourceMng.h"
51#include "arcane/impl/TimeLoopReader.h"
62extern "C++" ARCANE_IMPL_EXPORT Ref<ICodeService>
63createArcaneCodeService(IApplication* app);
69InternalInfosDumper(IApplication* application)
70: m_application(application)
77Ref<ICodeService> InternalInfosDumper::
80 String code_name = platform::getEnvironmentVariable(
"STDENV_CODE_NAME");
82 ARCANE_FATAL(
"environment variable 'STDENV_CODE_NAME' is not defined");
84 IApplication* app = m_application;
85 ServiceFinder2T<ICodeService,IApplication> code_services_utils(app,app);
86 String full_code_name = code_name +
"Code";
87 Ref<ICodeService> code = code_services_utils.createReference(full_code_name);
92 if (code_name==
"Arcane")
93 code = createArcaneCodeService(app);
96 ARCANE_FATAL(
"No code service named '{0}' found",full_code_name);
103void InternalInfosDumper::
106 ITraceMng* tr = m_application->traceMng();
107 IMainFactory* main_factory = m_application->mainFactory();
108 tr->info() <<
"Sortie des infos internes à Arcane";
109 Ref<ICodeService> code_service = _getDefaultService();
110 ISession* session(code_service->createSession());
111 IParallelSuperMng* psm = m_application->parallelSuperMng();
112 Ref<IParallelMng> world_pm = psm->internalCreateWorldParallelMng(0);
113 SubDomainBuildInfo sdbi(world_pm,0);
114 sdbi.setCaseFileName(String());
116 ISubDomain* sub_domain(session->createSubDomain(sdbi));
117 ScopedPtrT<IServiceLoader> service_loader(main_factory->createServiceLoader());
120 TimeLoopReader stl(m_application);
122 stl.registerTimeLoops(sub_domain);
125 service_loader->loadModules(sub_domain,
true);
128 UniqueArray<IServiceInfo*> service_infos;
130 std::set<IServiceInfo*> done_set;
131 for( ServiceFactory2Collection::Enumerator j(m_application->serviceFactories2()); ++j; ){
132 Internal::IServiceFactory2* sf2 = *j;
133 IServiceInfo* s = sf2->serviceInfo();
134 if (done_set.find(s)==done_set.end()){
135 service_infos.add(s);
141 IModuleMng* module_mng = sub_domain->moduleMng();
142 IVariableMng* variable_mng = sub_domain->variableMng();
146 String us_name(
"name");
147 String us_ref(
"ref");
148 String us_datatype(
"datatype");
149 String us_dimension(
"dimension");
150 String us_kind(
"kind");
151 String us_root(
"root");
152 String us_modules(
"modules");
153 String us_module(
"module");
154 String us_services(
"services");
155 String us_service(
"service");
157 ScopedPtrT<IXmlDocumentHolder> doc_holder(m_application->ressourceMng()->createXmlDocument());
158 XmlNode doc_element = doc_holder->documentNode();
159 XmlNode root_element = doc_element.createAndAppendElement(us_root);
161 XmlNode modules = root_element.createAndAppendElement(us_modules);
163 for( ModuleCollection::Enumerator i(module_mng->modules()); ++i; ){
164 XmlNode module_element = modules.createAndAppendElement(us_module);
165 module_element.setAttrValue(us_name,String((*i)->name()));
166 var_ref_list.clear();
167 variable_mng->variables(var_ref_list,*i);
168 for( VariableRefList::Enumerator j(var_ref_list); ++j; ){
169 XmlNode variable_element = module_element.createAndAppendElement(
"variable-ref");
170 variable_element.setAttrValue(us_ref,String((*j)->name()));
174 XmlNode variables = root_element.createAndAppendElement(
"variables");
176 VariableCollection var_prv_list(variable_mng->variables());
177 for( VariableCollection::Enumerator j(var_prv_list); ++j; ){
179 String dim(String::fromNumber(var->dimension()));
180 XmlNode variable_element = variables.createAndAppendElement(
"variable");
181 variable_element.setAttrValue(us_name,var->name());
182 variable_element.setAttrValue(us_datatype,
dataTypeName(var->dataType()));
183 variable_element.setAttrValue(us_dimension,dim);
184 variable_element.setAttrValue(us_kind,
itemKindName(var->itemKind()));
188 ITimeLoopMng* tm = sub_domain->timeLoopMng();
190 tm->timeLoopsName(timeloop_name_list);
192 XmlNode timeloops = root_element.createAndAppendElement(
"timeloops");
193 for( StringCollection::Enumerator i(timeloop_name_list); ++i; ){
194 XmlNode timeloop_elem = timeloops.createAndAppendElement(
"timeloop");
195 timeloop_elem.setAttrValue(us_name,*i);
201 std::map<String,List<IServiceInfo*> > interfaces_to_service;
202 XmlNode services_elem = root_element.createAndAppendElement(us_services);
204 for(
int i=0, n=service_infos.size(); i<n; ++i ){
205 IServiceInfo* service_info = service_infos[i];
206 XmlNode service_elem = services_elem.createAndAppendElement(us_service);
207 service_elem.setAttrValue(us_name,service_info->localName());
209 auto xml_file_base_name = service_info->caseOptionsFileName();
210 if (!xml_file_base_name.null()){
211 service_elem.setAttrValue(
"file-base-name",xml_file_base_name);
214 for( StringCollection::Enumerator j(service_info->implementedInterfaces()); ++j; ){
215 XmlNode interface_elem = service_elem.createAndAppendElement(
"implement-class");
216 interface_elem.setAttrValue(us_name,*j);
217 interfaces_to_service[*j].add(service_info);
222 XmlNode classes_elem = services_elem.createAndAppendElement(
"services-class");
223 std::map<String,List<IServiceInfo*> >::const_iterator begin = interfaces_to_service.begin();
224 std::map<String,List<IServiceInfo*> >::const_iterator end = interfaces_to_service.end();
225 for( ; begin!=end; ++begin ){
226 XmlNode class_elem = classes_elem.createAndAppendElement(
"class");
227 class_elem.setAttrValue(us_name,begin->first);
228 for( List<IServiceInfo*>::Enumerator i(begin->second); ++i; ){
229 IServiceInfo* service_info = *i;
230 XmlNode service_elem = class_elem.createAndAppendElement(us_service);
231 service_elem.setAttrValue(us_name,service_info->localName());
233 auto xml_file_base_name = service_info->caseOptionsFileName();
234 if (!xml_file_base_name.null()){
235 service_elem.setAttrValue(
"file-base-name",xml_file_base_name);
243 Directory shared_dir(m_application->applicationInfo().dataDir());
244 String filename = shared_dir.file(
"arcane_internal.xml");
245 cerr <<
"** FILE IS " << filename <<
'\n';
246 sub_domain->ioMng()->writeXmlFile(doc_holder.get(),filename);
252void InternalInfosDumper::
253dumpInternalAllInfos()
255 m_application->traceMng()->info() <<
"Sortie des infos sur les boucles en temps";
286 elem2.createAndAppendElement(
"codefullversion",
String(m_application->mainVersionStr()));
287 elem2.createAndAppendElement(
"codeversion",
String(m_application->majorAndMinorVersionStr()));
309 loop_mng->registerTimeLoop(timeloop);
325 cerr <<
"** FILE IS " << filename <<
'\n';
326 m_application->ioMng()->writeXmlFile(
doc_holder.get(),filename);
332void InternalInfosDumper::
349 String ustr_module(
"module");
350 String ustr_name(
"name");
351 String ustr_activated(
"activated");
352 String ustr_variable(
"variable");
353 String ustr_variable_ref(
"variable-ref");
354 String ustr_ref(
"ref");
355 String ustr_datatype(
"datatype");
356 String ustr_dimension(
"dimension");
357 String ustr_kind(
"kind");
358 String ustr_caseblock(
"caseblock");
359 String ustr_tagname(
"tagname");
365 JSONWriter::Array ja_modules(json_writer,
"modules");
366 for( IModule* module : sd->moduleMng()->modules() ){
367 JSONWriter::Object jo_module(json_writer);
368 json_writer.write(ustr_name,module->name());
369 json_writer.write(ustr_activated,module->used());
372 var_mng->variables(var_ref_list,module);
373 JSONWriter::Array ja_variables(json_writer,
"variables");
374 for( VariableRef* vr : var_ref_list )
375 json_writer.writeValue(vr->variable()->fullName());
381 VariableCollection var_prv_list = var_mng->variables();
382 JSONWriter::Array jo_variables(json_writer,
"variables");
383 for( VariableCollection::Enumerator j(var_prv_list); ++j; ){
385 JSONWriter::Object jo_variable(json_writer);
386 json_writer.write(ustr_name,var->fullName());
387 json_writer.write(ustr_datatype,
dataTypeName(var->dataType()));
388 json_writer.write(ustr_dimension,(
Int64)var->dimension());
389 json_writer.write(ustr_kind,
itemKindName(var->itemKind()));
398 JSONWriter::Array ja_blocks(json_writer,
"caseblocks");
399 for( ICaseOptions* block : blocks ){
400 JSONWriter::Object jo_block(json_writer);
401 json_writer.write(ustr_tagname,block->rootTagName());
403 IModule* block_module = block->caseModule();
405 json_writer.write(ustr_module,block_module->name());
415void InternalInfosDumper::
421 tr->
info() <<
"Generating Arcane Database";
450 for( ServiceFactory2Collection::Enumerator
j(m_application->serviceFactories2()); ++
j; ){
522 json_writer.writeIfNotNull(
"file-base-name",service_info->caseOptionsFileName());
529 Int64 block_size = 80;
536 auto z = content.subSpan(index,block_size);
563 json_writer.writeIfNotNull(
"file-base-name",service_info->caseOptionsFileName());
575 json_writer.write(
"codefullversion",m_application->mainVersionStr());
576 json_writer.write(
"codeversion",m_application->majorAndMinorVersionStr());
599 loop_mng->registerTimeLoop(timeloop);
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Informations sur une application.
Classe gérant un répertoire.
Interface de l'application.
Manufacture des classes d'Arcane.
Interface du gestionnaire de modules.
Classe abstraite du superviseur de parallélisme.
Interface des informations d'un service ou d'un module.
Interface de chargement des services.
Interface d'une session d'exécution d'un cas.
virtual ISubDomain * createSubDomain(const SubDomainBuildInfo &sdbi)=0
Créé un sous-domaine avec les paramètres contenus dans sdbi.
Interface du gestionnaire d'un sous-domaine.
virtual IVariableMng * variableMng()=0
Retourne le gestionnaire de variables.
virtual ICaseMng * caseMng()=0
Retourne le gestionnaire du jeu de données.
Interface du gestionnaire de la boucle en temps.
Interface d'une boucle en temps.
virtual String name() const =0
Nom de la boucle en temps.
Interface du gestionnaire de variables.
Interface d'une variable.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Paramètres nécessaires à la construction d'un sous-domaine.
Functor de chargement d'une boucle en temps.
Vue constante d'un tableau de type T.
Interface du gestionnaire de traces.
virtual TraceMessage info()=0
Flot pour un message d'information.
Chaîne de caractères unicode.
void writeBytes(std::ostream &o) const
Écrit la chaîne au format UTF-8 sur le flot o.
ITraceMng * traceMng() const
Gestionnaire de trace.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Span< const std::byte > ByteConstSpan
Vue en lecture seule d'un tableau à une dimension de caractères.
Collection< ICaseOptions * > CaseOptionsCollection
Collection d'options du jeu de données.
ConstArrayView< Byte > ByteConstArrayView
Equivalent C d'un tableau à une dimension de caractères.
List< String > StringList
Tableau de chaînes de caractères unicode.
const char * itemKindName(eItemKind kind)
Nom du genre d'entité.
List< VariableRef * > VariableRefList
Tableau de références de variables.
const char * dataTypeName(eDataType type)
Nom du type de donnée.