Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
030f7cdfd2f1a9e93d1d0fad5a128185ec9ffa64
[simgrid.git] / tools / graphicator / graphicator.c
1 /* Copyright (c) 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _XBT_WIN32
8 #include <unistd.h>
9 #endif
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <time.h>
14 #include <string.h>
15 #include <math.h>
16
17
18 #include "simdag/simdag.h"
19 #include "xbt/log.h"
20 #include "xbt/dict.h"
21 #include "xbt/ex.h"
22 #include "xbt/graph.h"
23 #include "surf/surf.h"
24 #include "surf/surf_private.h"
25
26 XBT_LOG_NEW_DEFAULT_CATEGORY(graphicator,
27                              "Graphicator Logging System");
28
29 int main(int argc, char **argv)
30 {
31   char *platformFile = NULL;
32   char *graphvizFile = NULL;
33
34   xbt_ex_t e;
35
36   MSG_global_init(&argc, argv);
37
38   if (argc < 3){
39     XBT_INFO("Usage: %s <platform_file.xml> <graphviz_file.dot>", argv[0]);
40     return 1;
41   }
42   platformFile = argv[1];
43   graphvizFile = argv[2];
44
45   TRY {
46     MSG_create_environment(platformFile);
47   } CATCH(e) {
48     xbt_die("Error while loading %s: %s",platformFile,e.msg);
49   }
50
51   //creating the graph structure
52   xbt_graph_t graph = TRACE_platform_graph();
53   if (graph == NULL){
54     XBT_INFO ("%s expects --cfg=tracing:1", argv[0]);
55   }else{
56     xbt_graph_export_graphviz(graph, graphvizFile, &TRACE_node_name, NULL);
57     XBT_INFO ("Output is in file %s", graphvizFile);
58   }
59   MSG_clean();
60   return 0;
61 }