Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a version of gridpp.xml with its tool.
[simgrid.git] / buildtools / Cmake / transform_optorsim_platform.pl
1 #!/usr/bin/perl -w
2 use strict;
3
4 if($#ARGV!=0) {
5     die "Usage: perl transfrom_optorsim_platform.pl <file.conf>\n";
6 }
7
8 my($conf_file)=$ARGV[0];
9
10 open FILE, $conf_file or die "Unable to open $conf_file";
11
12 print "<?xml version='1.0'?>\n";
13 print "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n";
14 print "<platform version=\"3\">\n";
15 print "<AS  id=\"AS0\"  routing=\"Floyd\">\n";
16
17 my $line;
18 my @tokens;
19 my $token;
20 my $dst = 0;
21 my $src = 0;
22 my @list_of_name;
23 my $num_link = 0;
24
25 my @links = ();
26 my @routers = ();
27 my @hosts = ();
28 my @routes = ();
29 my $power;
30 while(defined($line=<FILE>))
31 {
32         
33         if($line =~ /^#(.*)\)(.*)$/)
34         {
35                 print "<!--$1 $2-->\n";
36                 push @list_of_name, $2;
37         }
38         elsif($line =~ /^([0-9]*) ([0-9]*) ([0-9]*) (.*)$/)
39         {
40                 if($1.$2.$3 == "000"){
41                         push @routers, "\t<router id=\"$list_of_name[$src]\"/>\n";
42                 }
43                 else{
44                         $power = $1 * $3;
45                         if($power == 0){
46                                 $power=1;
47                         }
48                         push @hosts, "\t<host id=\"$list_of_name[$src]\" power=\"$power\"/>\n";
49                 }               
50                 my $table = $4;
51                 @tokens = split(/ /,$table);
52                 foreach $token (@tokens) {
53                         if($token != "0"){
54 #                               print "from \"$list_of_name[$src]\" to \"$list_of_name[$dst]\" bdw=\"$token\"\n";
55                                 if($src <= $dst){
56                                         
57                                         push @links, "\t<link id=\"link$num_link\" bandwidth=\"$token\"/>\n";
58                                         
59                                         push @routes, "\t<route src=\"$list_of_name[$src]\" dst=\"$list_of_name[$dst]\">\n";
60                                         push @routes, "\t\t<link_ctn id=\"link$num_link\"/>\n";
61                                         push @routes, "\t</route>\n";
62                                         $num_link++;
63                                 }
64                         }
65                         $dst++;
66                 }
67                 $src++;
68                 $dst = 0;
69     }
70     else
71     {
72         die;
73     }
74         
75         
76 }
77 close(FILE);
78         
79 print @hosts;
80 print "\n";
81 print @routers;
82 print "\n";
83 print @links;
84 print "\n";
85 print @routes;
86
87 print "</AS>\n";
88 print "</platform>";
89
90 print " \n";