<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr"><div>Hi,</div><div>What should I do? i have the folowing error (error C4703: variable de pointeur locale potentiellement non initialisée 'sendbuf' utilisée and error C4703: variable de pointeur locale potentiellement non initialisée 'tab_indice' utilisée ) when I execute this program:<br></div><div>#include <stdio.h></div><div>#include <stdlib.h></div><div>#include <mpi.h></div><div><br></div><div>#define DIMENSION 10</div><div><br></div><div>int main(int argc, char** argv)</div><div>{</div><div><span class="" style="white-space:pre"> </span>int myrank, i, n_procs;</div><div><span class="" style="white-space:pre"> </span>int * sendbuf; //buffer à disperser</div><div><span class="" style="white-space:pre"> </span>int * tab_indice; //indice de début de chaque subdivision</div><div><span class="" style="white-space:pre"> </span>int * tab_taille; //nombre d'éléments à envoyer</div><div><span class="" style="white-space:pre"> </span>// pour chaque processus</div><div><span class="" style="white-space:pre"> </span>int * rbuf; //buffer de reception</div><div><span class="" style="white-space:pre"> </span>int taille; //taille de la partie reçue</div><div><br></div><div><span class="" style="white-space:pre"> </span>//Initialisation de MPI</div><div><span class="" style="white-space:pre"> </span>MPI_Init(&argc, &argv);</div><div><span class="" style="white-space:pre"> </span>MPI_Comm_size(MPI_COMM_WORLD, &n_procs);</div><div><span class="" style="white-space:pre"> </span>MPI_Comm_rank(MPI_COMM_WORLD, &myrank);</div><div><br></div><div><span class="" style="white-space:pre"> </span>if (myrank == 0)</div><div><span class="" style="white-space:pre"> </span>{</div><div><span class="" style="white-space:pre"> </span>//allocation mémoire</div><div><span class="" style="white-space:pre"> </span>sendbuf = (int *)malloc(n_procs*DIMENSION*sizeof(int));</div><div><span class="" style="white-space:pre"> </span>tab_indice = (int *)malloc(n_procs*sizeof(int));</div><div><span class="" style="white-space:pre"> </span>tab_taille = (int *)malloc(n_procs*sizeof(int));</div><div><span class="" style="white-space:pre"> </span>//remplissage du buffer à disperser</div><div><span class="" style="white-space:pre"> </span>printf("la taille de la boucle %d \n", n_procs*DIMENSION);</div><div><span class="" style="white-space:pre"> </span>for (i = 0; i<n_procs*DIMENSION; i++) sendbuf[i] = i;</div><div><span class="" style="white-space:pre"> </span>//initialisation des subdivisions</div><div><span class="" style="white-space:pre"> </span>for (i = 0; i<n_procs; i++)</div><div><span class="" style="white-space:pre"> </span>{</div><div><span class="" style="white-space:pre"> </span>//nombre d'éléments à envoyer</div><div><span class="" style="white-space:pre"> </span>tab_taille[i] = DIMENSION - i;</div><div><span class="" style="white-space:pre"> </span>printf("tab_taille[%d]=%d \n", i, tab_taille[i]);</div><div><span class="" style="white-space:pre"> </span>//indice de début du processus i </div><div><span class="" style="white-space:pre"> </span>// = celui de i-1 + nombre d'éléments</div><div><span class="" style="white-space:pre"> </span>// envoyés par i-1</div><div><span class="" style="white-space:pre"> </span>if (i != 0) tab_indice[i] = tab_indice[i - 1] + tab_taille[i - 1];</div><div><span class="" style="white-space:pre"> </span>else tab_indice[i] = 0;</div><div><span class="" style="white-space:pre"> </span>printf("tab_indice[%d]=%d \n", i, tab_indice[i]);</div><div><span class="" style="white-space:pre"> </span>}</div><div><span class="" style="white-space:pre"> </span>}</div><div><span class="" style="white-space:pre"> </span>//communication de la taille de la partie reçue à chaque processus</div><div><span class="" style="white-space:pre"> </span>MPI_Scatter(tab_taille, 1, MPI_INT, &taille, 1, MPI_INT, 0, MPI_COMM_WORLD);</div><div><span class="" style="white-space:pre"> </span>//allocation du buffer de reception</div><div><span class="" style="white-space:pre"> </span>rbuf = (int *)malloc(taille*sizeof(int));</div><div><span class="" style="white-space:pre"> </span>//dispersion</div><div><span class="" style="white-space:pre"> </span>MPI_Scatterv(sendbuf, tab_taille, tab_indice, MPI_INT, rbuf,DIMENSION, MPI_INT, 0, MPI_COMM_WORLD);</div><div><span class="" style="white-space:pre"> </span>//affichage</div><div><span class="" style="white-space:pre"> </span>printf("processus %d : [ ", myrank);</div><div><span class="" style="white-space:pre"> </span>for (i = 0; i<taille; i++) printf("%d ", rbuf[i]);</div><div><span class="" style="white-space:pre"> </span>printf("]\n");</div><div><br></div><div><span class="" style="white-space:pre"> </span>//desallocation mémoire</div><div><span class="" style="white-space:pre"> </span>free(rbuf);</div><div><span class="" style="white-space:pre"> </span>if (myrank == 0) {</div><div><span class="" style="white-space:pre"> </span>free(sendbuf);</div><div><span class="" style="white-space:pre"> </span>free(tab_indice);</div><div><span class="" style="white-space:pre"> </span>free(tab_taille);</div><div><span class="" style="white-space:pre"> </span>}</div><div><span class="" style="white-space:pre"> </span></div><div><span class="" style="white-space:pre"> </span>MPI_Finalize();</div><div><span class="" style="white-space:pre"> </span>exit(EXIT_SUCCESS);</div><div>}</div></div>