Moved all source (that I've found) into src/.
[parallel_computing.git] / content / MPE / src / fun / fun.c
diff --git a/content/MPE/src/fun/fun.c b/content/MPE/src/fun/fun.c
deleted file mode 100644 (file)
index c47ebc2..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-
-
-           /* MPE Graphics Demonstration  */
-
-                                    /* Michel Vallieres */
-
-#include <stdio.h>
-#include <math.h>
-#include <sys/time.h>
-#include <stdlib.h>
-#include "mpi.h"
-#include "mpe.h"
-#include "mpe_graphics.h"
-
-#define WINDOW_SIZE_X     600
-#define WINDOW_SIZE_Y     500
-
-int draw_something( MPE_XGraph graph, int myid )
-{
-                                              /* draw line & graph update */
-
-    int iy, iy_coordinate, ix_coordinate_1, ix_coordinate_2;
-
-    for ( iy=1 ; iy <  5 ; iy++ )
-      {
-        iy_coordinate = iy*WINDOW_SIZE_Y/7 + 10*myid;
-        ix_coordinate_1 = 100 + 10*myid;
-        ix_coordinate_2 = ix_coordinate_1 + iy*50;
-        MPE_Draw_line( graph, ix_coordinate_1, iy_coordinate, 
-                             ix_coordinate_2, iy_coordinate,
-                                           MPE_BLACK );
-      }
-                                              /* update graph */
-    MPE_Update( graph );
-}
-
-int try_colors ( MPE_XGraph graph, int myid, MPE_Color colors[], int nc )
-{
-                                              /* -- draw -- the palette        */
-                                              /* i.e., lines of various colors */
-    int ic;
-    for ( ic=1 ; ic<=nc ; ic++ )
-      {
-        MPE_Draw_line( graph, 20+ic, WINDOW_SIZE_Y-20, 
-                             20+ic, WINDOW_SIZE_Y-50,
-                                           colors[ic] );
-      }
-                                              /* update graph */
-    MPE_Update( graph );
-}
-
-int draw_various_shapes(  MPE_XGraph graph, int myid, int numprocs,
-                          MPE_Color colors[], int nc )
-{
-                                              /* examples of different shapes */
-    int xc, yc, radius, is, ns, listpe[100];
-    MPE_Point points[500];
-    int ip, shift, N_points;
-
-    ns = 3;                                   /* list of processes      */
-    listpe[0] = 0;                            /* each process will draw */
-    for ( is=1; is<ns ; is++ )                /* different objects      */
-      {
-        listpe[is] = listpe[is-1] + 1;
-        if ( listpe[is] > numprocs-1 ) listpe[is] = 0;
-      }
-                                              /* filled circle */
-    if ( myid == listpe[0] ) 
-      {
-        xc = 0.8*WINDOW_SIZE_X;
-        yc = 0.2*WINDOW_SIZE_Y;
-        radius = 0.01*(WINDOW_SIZE_X + WINDOW_SIZE_Y);
-        MPE_Fill_circle( graph, xc, yc, radius, colors[120]);
-      }
-                                              /* -- empty --  circle */
-    if ( myid == listpe[1] ) 
-      {
-        xc = 0.8*WINDOW_SIZE_X;
-        yc = 0.3*WINDOW_SIZE_Y;
-        radius = 0.01*(WINDOW_SIZE_X + WINDOW_SIZE_Y);
-        MPE_Draw_circle( graph, xc, yc, radius, colors[120]);
-      }
-                                              /* colored X */
-                                              /* draw a bunch of points */
-                                              /* at once -- efficient */
-    if ( myid == listpe[2] ) 
-      {
-        xc = 0.8*WINDOW_SIZE_X;
-        yc = 0.4*WINDOW_SIZE_Y;
-        N_points = nc;
-        shift = N_points/4;
-        for ( ip=0 ; ip<N_points ; ip++ )
-         {
-             points[ip].x = xc + ip - shift;
-             points[ip].y = yc + ip/2;
-             points[ip].c = colors[ip];
-             if ( ip > N_points/2 ) 
-              {
-                    points[ip].x = xc + ip - N_points/2 - shift;
-                    points[ip].y = yc + (- ip + N_points)/2; 
-              }
-         }
-        MPE_Draw_points( graph, points, N_points);
-      }
-                                              /* update graph */
-      MPE_Update( graph );
-}
-
-
-int quit_by_touch( MPE_XGraph graph )
-{
-                                              /* interacting with graphic */
-     int x, y, button, xc, yc, w, h, xs, ys;
-     
-     xc = 0.95*WINDOW_SIZE_X;                 /* draw filled rectangle */
-     yc = 0.95*WINDOW_SIZE_Y;                 /* lower bottom corner   */
-     w = WINDOW_SIZE_X - xc;                  /* of graphic window     */
-     h = WINDOW_SIZE_Y - yc;
-     MPE_Fill_rectangle( graph, xc, yc, w, h, MPE_BLACK );
-     xs = xc+0.4*w;
-     ys = yc + 0.8*h;
-     MPE_Draw_string( graph, xs, ys, MPE_WHITE, "Q" );
-                                               /* infinite loop            */
-                                               /* wait for different touch */
-     for ( ; ; )
-       {
-                                              /* wait for mouse to touch graph */
-                                               /* can only be done by master */
-          MPE_Get_mouse_press( graph, &x, &y, &button );
-                                                 /* result is touch point */
-          fprintf( stderr, "\n Graph coordinates of the touch: %d %d %d \n", x, y, button );
-          if ( x > xc && y > yc )  
-           {
-               fprintf( stderr, "\n Last touch was in the -- quit -- rectangle \n\n" );
-               return;
-           }  
-       }
-}
-
-int main( int argc, char * argv[] )
-{
-    int numprocs, myid;
-    MPE_XGraph graph;
-    int nc, ic;
-    MPE_Color colors[500];
-                                               /* subscribe to MPI virtual machine */
-    MPI_Init(&argc,&argv);
-    MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
-    MPI_Comm_rank(MPI_COMM_WORLD,&myid);
-                                               /* start MPE graphics */
-    MPE_Open_graphics( &graph, MPI_COMM_WORLD, 0, -1, -1, WINDOW_SIZE_X,
-                      WINDOW_SIZE_Y, 0 );
-                                               /* -- write -- on graph */
-    if ( myid == 0 ) 
-           MPE_Draw_string( graph, 0.3*WINDOW_SIZE_X, 0.1*WINDOW_SIZE_Y, 
-                 MPE_BLUE, "MPE Simple Graphics Demo" );
-                                               /* draw a shape from a function */
-    draw_something( graph, myid );
-                                               /* default color palette */
-    MPE_Num_colors ( graph, &nc );
-    fprintf( stderr, "\n Process: %d -- Numbers of colors:  %d \n", myid, nc );
-                                               /* make a new color palette */
-    nc = 128;
-    MPE_Make_color_array( graph, nc, colors );
-    fprintf( stderr, " Process: %d -- Made %d colors \n", myid, nc );
-                                               /* draw shapes using different colors */
-    draw_various_shapes( graph, myid, numprocs, colors, nc );
-                                               /* display color palette */
-    if ( myid == 0 )
-              try_colors ( graph, myid, colors, nc );
-                                               /* interaction with graph */
-    if ( myid == 0 ) 
-              quit_by_touch( graph );
-                                               /* synchronize processes */
-    MPI_Barrier( MPI_COMM_WORLD );
-                                               /* end graphics */
-    MPE_Close_graphics( &graph );
-                                               /* end MPI */
-    MPI_Finalize();
-}
-
-
-
-
-
-
-
-
-
-
-
-