Hello everyone,
I am using Petsc in parallel and I am trying to color my nodes into different colors according to their location in different processes. So I created a code in C:
char colr[16][30]= {
"pink1",
"yellow1",
"red",
"turquoise",
"sienna",
"white",
"green",
"purple",
"blue",
"grey",
"black",
"brown",
"darkgoldenrod3",
"tan",
"plum4",
"peachpuff1"
};
FILE * fpdot;
char filenamea[100];
sprintf(filenamea,"/home/edaoktay/Desktop/matrices/dots/mat_n_%d_size_%d_lap_%d_cut_%d_tol_%g.dot",nev,siz,lap,cutt,toleps);
fpdot = fopen (filenamea,"w");
fprintf (fpdot, "digraph PL_of_n_%d_size_%d_lap_%d_cut_%d_tol_%g{\n node [shape=point]\n ",nev,siz,lap,cutt,toleps);
for (j=0;j<nev;j++){
if (rank == j){
for (i=0;i<vend-vstart;i++){
printf("%d color %s for rank = %d\n",vecar[i],colr[j],rank);
fprintf (fpdot, "%d [fillcolor = %s];\n",vecar[i],colr[j] );
}
}
}
fprintf (fpdot, "}\n\n\n");
fclose (fpdot);
where nev is the number of processes, vecar is the string holding node number in the process, and its size is vend-vstart.
After running the code, the dot file was written for only for one process. In other words, for instance, normally, the nodes should be arranged like that (like I got from printf() function):
1 color pink1 for rank = 0
4 color pink1 for rank = 0
0 color yellow1 for rank = 1
2 color yellow1 for rank = 1
3 color yellow1 for rank = 1
5 color yellow1 for rank = 1
6 color yellow1 for rank = 1
7 color yellow1 for rank = 1
8 color yellow1 for rank = 1
however, in dot file:
0 [fillcolor = yellow1];
2 [fillcolor = yellow1];
3 [fillcolor = yellow1];
5 [fillcolor = yellow1];
6 [fillcolor = yellow1];
7 [fillcolor = yellow1];
8 [fillcolor = yellow1];
i.e. only in process number 1 was considered in the loop.
I couldn’t understand how printf function prints the whole nodes in the whole processes but fprintf prints only nodes in one process.
I was wondering where and what am I doing wrong? Since this is the first time I am writing a dot file, I couldn’t understand where the problem is.
Thanks!