From: Levinthal, D. A <dav...@in...> - 2004-10-05 21:20:00
|
I can't figure out how to get the gnuplot process to terminate at the end of my application..The x window remains open and the process hangs at the end.. the fprintf's to stderr seem to imply all is well..but the xwindow is persistant and the application cannot exit Note: that I need to have the plots stay there during execution, without having to put the application in a sleep state..(The display is of a numerical solution converging..) ?? d Gnuplot is being invoked with: if((gplot =3D=3D 1) && (current_processor =3D=3D 0)){ // Gnuplot initialization fgnuplot =3D popen("/usr/bin/gnuplot -persist", "w"); if (fgnuplot =3D=3D NULL) { fprintf(stderr, "popen call failed!, unable to start gnuplot"); } else {=20 // initial settings fprintf(fgnuplot, "set data style lines\n"); fprintf(fgnuplot, "set hidden3d\n"); fprintf(fgnuplot, "set contour base\n"); fprintf(fgnuplot, "set zrange[-20:20]\n"); fflush(fgnuplot); =20 } } =20 And then all sorts of attempts at killing it off seem to fail??? if ((gplot =3D=3D 1) && fgnuplot) { // Gather results for(iproc=3D0; iproc < number_of_processors; iproc++) for ( i =3D 0 ; i < plrows ; i++ ) for ( j =3D 0 ; j < PLOTDIM ; j++ ) plot[i + iproc*plrows][j] =3D result[i*iplstride+iplstart[0]+nrows*iproc][j*jplstride + jplstart]; fprintf(stderr,"gathered plot\n"); save2DArray(plot, PLOTDIM,PLOTDIM, 1, 1, "fout.dat"); fprintf(fgnuplot, "set title \"Converged in %d iterations\"\n", k); fprintf(fgnuplot, "splot 'fout.dat' matrix\n"); fflush(fgnuplot); // wait for gnuplot to exit fclose(fgnuplot); =20 // wait(&rc); printf("root node: finished\n"); } =20 Or if ((gplot =3D=3D 1) && fgnuplot) { printf(" in plotting section on root node\n"); // Gather results for(iproc=3D0; iproc < number_of_processors; iproc++) for ( i =3D 0 ; i < plrows ; i++ ) for ( j =3D 0 ; j < PLOTDIM ; j++ ) plot[i + iproc*plrows][j] =3D result[i*iplstride+iplstart[0]+nrows*iproc][j*jplstride + jplstart]; fprintf(stderr,"gathered plot\n"); save2DArray(plot, PLOTDIM,PLOTDIM, 1, 1, "fout.dat"); fprintf(fgnuplot, "set title \"Converged in %d iterations\"\n", k); fprintf(fgnuplot, "splot 'fout.dat' matrix\n"); fprintf(stderr, "finished final fprintf(fgnuplot \n"); fflush(fgnuplot); fprintf(stderr, "finished final fflush\n"); fprintf(fgnuplot, " quit\n"); fprintf(fgnuplot, " exit\n"); // wait for gnuplot to exit wait(&rc); fprintf(stderr, "finished wait =3D %i\n", rc); pstatus =3D pclose(fgnuplot); fprintf(stderr, "finished plcose =3D %i\n", pstatus); =20 =20 printf("root node: finished\n"); } |