Beispiel #1
0
int main(int argc, char **argv)
{
    int i;
    simulation_data sim;
    simulation_data_ctor(&sim);

    /* Initialize environment variables. */
    SimulationArguments(argc, argv);
    VisItSetupEnvironment();

    for(i = 1; i < argc; ++i)
    {
        if(strcmp(argv[i], "-echo") == 0)
            sim.echo = 1;
    }

    /* Write out .sim file that VisIt uses to connect. */
    VisItInitializeSocketAndDumpSimFile("curve",
        "Demonstrates curve data access function",
        "/path/to/where/sim/was/started",
        NULL, NULL, SimulationFilename());

    /* Read input problem setup, geometry, data.*/
    read_input_deck();

    /* Call the main loop. */
    mainloop(&sim);

    simulation_data_dtor(&sim);

    return 0;
}
Beispiel #2
0
int main(int argc, char **argv)
{
    simulation_data sim;
    simulation_data_ctor(&sim);

    /* Initialize environment variables. */
    SimulationArguments(argc, argv);
    VisItSetupEnvironment();

    /* Write out .sim2 file that VisIt uses to connect. */
    VisItInitializeSocketAndDumpSimFile("material",
        "Demonstrates material data access function",
        "/path/to/where/sim/was/started",
        NULL, NULL, SimulationFilename());

    /* Read input problem setup, geometry, data. */
    read_input_deck();

    /* Call the main loop. */
    mainloop(&sim);

    /* Cleanup */
    simulation_data_dtor(&sim);

    return 0;
}
Beispiel #3
0
int main(int argc, char **argv)
{
    simulation_data sim;
    simulation_data_ctor(&sim);
    SimulationArguments(argc, argv);

    /* Initialize environment variables. */
    VisItSetupEnvironment();

#ifdef PARALLEL
    /* Initialize MPI */
    MPI_Init(&argc, &argv);
    MPI_Comm_rank (MPI_COMM_WORLD, &sim.par_rank);
    MPI_Comm_size (MPI_COMM_WORLD, &sim.par_size);

    /* Install callback functions for global communication. */
    VisItSetBroadcastIntFunction(visit_broadcast_int_callback);
    VisItSetBroadcastStringFunction(visit_broadcast_string_callback);
    /* Tell VSIL whether the simulation is parallel. */
    VisItSetParallel(sim.par_size > 1);
    VisItSetParallelRank(sim.par_rank);
#endif

    /* Write out .sim2 file that VisIt uses to connect. Only do it
     * on processor 0.
     */
    if(sim.par_rank == 0)
    {
        VisItInitializeSocketAndDumpSimFile("sim4p",
        "Parallel C prototype simulation connects to VisIt",
        "/path/to/where/sim/was/started", NULL, NULL, NULL);
    }

    /* Read input problem setup, geometry, data. */
    read_input_deck(&sim);

    /* Call the main loop. */
    mainloop(&sim);

    simulation_data_dtor(&sim);

#ifdef PARALLEL
    MPI_Finalize();
#endif

    return 0;
}
Beispiel #4
0
int main(int argc, char **argv)
{
    /* Initialize environment variables. */
    SimulationArguments(argc, argv);
    VisItSetupEnvironment();

    /* Write out .sim2 file that VisIt uses to connect. */
    VisItInitializeSocketAndDumpSimFile("amr",
        "Demonstrates domain nesting data access function",
        "/no/useful/path",
        NULL, NULL, SimulationFilename());

    /* Read input problem setup, geometry, data. */
    read_input_deck();

    /* Call the main loop. */
    mainloop();

    return 0;
}
Beispiel #5
0
int main(int argc, char **argv)
{
    /* Initialize environment variables. */
    SimulationArguments(argc, argv);
    VisItSetupEnvironment();

    /* Write out .sim2 file that VisIt uses to connect. */
    VisItInitializeSocketAndDumpSimFile("unstructured",
        "Demonstrates creating an unstructured mesh",
        "/path/to/where/sim/was/started",
        NULL, NULL, NULL);

    /* Read input problem setup, geometry, data. */
    read_input_deck();

    /* Call the main loop. */
    mainloop();

    return 0;
}
Beispiel #6
0
int main(int argc, char **argv)
{
    simulation_data sim;
    simulation_data_ctor(&sim);
    SimulationArguments(argc, argv);
   
    /* Initialize envuronment variables. */
    VisItSetupEnvironment();
    /* Write out .sim2 file that VisIt uses to connect. */
    VisItInitializeSocketAndDumpSimFile("sim6",
        "Demonstrates setting simulation state in metadata",
        "/path/to/where/sim/was/started",
        NULL, NULL, NULL);

    /* Read input problem setup, geometry, data. */
    read_input_deck(&sim);

    /* Call the main loop. */
    mainloop(&sim);

    simulation_data_dtor(&sim);
    return 0;
}
Beispiel #7
0
int main(int argc, char **argv)
{
    char *env = NULL;
    int i = 0;
    simulation_data sim;
    simulation_data_ctor(&sim);

#ifdef PARALLEL
    /* Initialize MPI */
    MPI_Init(&argc, &argv);

    /* Create a new communicator. */
    if (MPI_Comm_dup(MPI_COMM_WORLD, &sim.par_comm) != MPI_SUCCESS)
        sim.par_comm = MPI_COMM_WORLD;

    MPI_Comm_rank (sim.par_comm, &sim.par_rank);
    MPI_Comm_size (sim.par_comm, &sim.par_size);
#endif

    /* Initialize environment variables. */
    SimulationArguments(argc, argv);

#ifdef PARALLEL
    /* Install callback functions for global communication. */
    VisItSetBroadcastIntFunction2(visit_broadcast_int_callback, (void*)&sim);
    VisItSetBroadcastStringFunction2(visit_broadcast_string_callback, (void*)&sim);

    /* Tell libsim whether the simulation is parallel. */
    VisItSetParallel(sim.par_size > 1);
    VisItSetParallelRank(sim.par_rank);

    /* Tell libsim which communicator to use. You must pass the address of
     * an MPI_Comm object.
     */
    VisItSetMPICommunicator((void *)&sim.par_comm);
#endif

    /* Only read the environment on rank 0. This could happen before MPI_Init if
     * we are using an MPI that does not like to let us spawn processes but we
     * would not know our processor rank.
     */
    if(sim.par_rank == 0)
        env = VisItGetEnvironment();

    /* Pass the environment to all other processors collectively. */
    VisItSetupEnvironment2(env);
    if(env != NULL)
        free(env);

    for(i = 1; i < argc; ++i)
    {
        if(strcmp(argv[i], "-echo") == 0)
            sim.echo = 1;
    }

    /* Write out .sim file that VisIt uses to connect. Only do it
     * on processor 0.
     */
    /* CHANGE 3 */
    if(sim.par_rank == 0)
    {
        /* Write out .sim file that VisIt uses to connect. */
        VisItInitializeSocketAndDumpSimFile(
#ifdef PARALLEL
            "ucdcurve_par",
#else
            "ucdcurve",
#endif
            "Demonstrates 1D unstructured mesh",
            "/path/to/where/sim/was/started",
            NULL, NULL, SimulationFilename());
    }

    /* Read input problem setup, geometry, data.*/
    read_input_deck();

    /* Call the main loop. */
    mainloop(&sim);

    simulation_data_dtor(&sim);
#ifdef PARALLEL
    MPI_Finalize();
#endif

    return 0;
}
Beispiel #8
0
int main(int argc, char **argv)
{
    int i,nx = 50, ny = 50,nz = 50, batch = 0, echo = 0;
    char *env = NULL;
    simulation_data sim;

#ifdef PARALLEL
    /* Initialize MPI */
    MPI_Init(&argc, &argv);
#endif

    /* Check for command line arguments. */
    for(i = 1; i < argc; ++i)
    {
        if((i+1) < argc)
        {
            if(strcmp(argv[i], "-nx") == 0)
            {
                sscanf(argv[i+1], "%d", &nx);
                i++;
            }
            else if(strcmp(argv[i], "-ny") == 0)
            {
                sscanf(argv[i+1], "%d", &ny);
                i++;
            }
            else if(strcmp(argv[i], "-nz") == 0)
            {
                sscanf(argv[i+1], "%d", &nz);
                i++;
            }
            else if(strcmp(argv[i], "-dir") == 0)
            {
                /* Specify the path to VisIt installation. */
                VisItSetDirectory(argv[i+1]);
                i++;
            }
        }
        else if(strcmp(argv[i], "-batch") == 0)
        {
            batch = 1;
        }
        else if(strcmp(argv[i], "-echo") == 0)
        {
            echo = 1;
        }
    }

    /* Initialize environment variables. */
    SimulationArguments(argc, argv);

    simulation_data_ctor(&sim, nx, ny, nz);
    sim.echo = echo;

#ifdef PARALLEL
    /* Create a new communicator. */
    if (MPI_Comm_dup(MPI_COMM_WORLD, &sim.par_comm) != MPI_SUCCESS)
        sim.par_comm = MPI_COMM_WORLD;
    MPI_Comm_rank (sim.par_comm, &sim.par_rank);
    MPI_Comm_size (sim.par_comm, &sim.par_size);

    /* Install callback functions for global communication. */
    VisItSetBroadcastIntFunction2(SimBroadcastInt, (void*)&sim);
    VisItSetBroadcastStringFunction2(SimBroadcastString, (void*)&sim);

    /* Tell libsim whether the simulation is parallel. */
    VisItSetParallel(sim.par_size > 1);
    VisItSetParallelRank(sim.par_rank);

    /* Tell libsim which communicator to use. You must pass the address of
     * an MPI_Comm object.
     */
    VisItSetMPICommunicator((void *)&sim.par_comm);
#endif

    /* Only read the environment on rank 0. This could happen before MPI_Init if
     * we are using an MPI that does not like to let us spawn processes but we
     * would not know our processor rank.
     */
    if(sim.par_rank == 0)
        env = VisItGetEnvironment();

    /* Pass the environment to all other processors collectively. */
    VisItSetupEnvironment2(env);
    if(env != NULL)
        free(env);

    /* Call the main loop. */
    if(batch)
        mainloop_batch(&sim);
    else
    {
        if(sim.par_rank == 0)
        {
            /* Write out .sim file that VisIt uses to connect. */
            VisItInitializeSocketAndDumpSimFile(
#ifdef PARALLEL
            "zerocopy_par",
#else
            "zerocopy",
#endif
            "Demonstrates VariableData setArrayData functions for zero copy",
            "/path/to/where/sim/was/started",
            NULL, NULL, SimulationFilename());
        }

        mainloop_interactive(&sim);
    }

    if(VisItIsConnected())
        VisItDisconnect();

    simulation_data_dtor(&sim);
#ifdef PARALLEL
    MPI_Finalize();
#endif

    return 0;
}
Beispiel #9
0
int main(int argc, char **argv)
{
  char *env = NULL;
  simulation_data sim;
  simulation_data_ctor(&sim);
  sim.runMode = SIM_STOPPED;
  int r, c, ndims=2, dims[2]={8,8}, periods[2]={0,0};
  int xdivs=2, ydivs=2, zdivs=1;
  double before, after, *mem;
  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &sim.par_rank);
  MPI_Comm_size(MPI_COMM_WORLD, &sim.par_size);
  if(!sim.par_rank)
    get_procmem(&before);

#ifdef VISIT_INSITU
    SimulationArguments(argc, argv);
#endif
#define OPTS 1
#ifdef OPTS
  if(!sim.par_rank)
    {
    while(1)
      {
       static struct option long_options[] =
             {
               {"xdivs",  required_argument, 0, 'x'},
               {"ydivs",  required_argument, 0, 'y'},
               {"blocksize",  required_argument, 0, 'b'},
               {"timesteps",  required_argument, 0, 't'},
               {"file",    required_argument, 0, 'f'},
               {0, 0, 0, 0}
             };
           /* getopt_long stores the option index here. */
           int option_index = 0;
     
           c = getopt_long (argc, argv, "x:y:b:t:f:",
                            long_options, &option_index);
     
           /* Detect the end of the options. */
           if (c == -1)
             break;
     
           switch (c)
             {
             case 0:
               /* If this option set a flag, do nothing else now. */
               if (long_options[option_index].flag != 0)
                 break;
               printf ("option %s", long_options[option_index].name);
               if (optarg)
                 printf (" with arg %s", optarg);
               printf ("\n");
               break;
     
             case 'x':
               //printf ("option -x with value `%s'\n", optarg);
               dims[0] = atoi(optarg);
               break;
     
             case 'y':
               //printf ("option -y with value `%s'\n", optarg);
               dims[1] = atoi(optarg);
               break;

             case 'b':
               //printf ("option -b with value `%s'\n", optarg);
               BlockSize = atoi(optarg);
               break;

             case 't':
               //printf ("option -t with value `%s'\n", optarg);
               NUMBER_OF_ITERATIONS = atoi(optarg);
               break;
     
             case 'f':
               //printf ("option -f with value `%s'\n", optarg);
               strcpy(sim.filename, optarg);
               break;
     
             case '?':
               /* getopt_long already printed an error message. */
               break;
     
             default:
               abort ();
             }
         }
    }
#endif
  MPI_Bcast(dims, 2, MPI_INT, 0, MPI_COMM_WORLD);
  MPI_Bcast(&BlockSize, 1, MPI_INT, 0, MPI_COMM_WORLD);
  MPI_Bcast(&NUMBER_OF_ITERATIONS, 1, MPI_INT, 0, MPI_COMM_WORLD);
  // broadcast name, even if it was not set
  MPI_Bcast(sim.filename, 256, MPI_CHAR, 0, MPI_COMM_WORLD);

  if(sim.par_size != dims[0]*dims[1])
    {
    if(sim.par_rank == 0)
      fprintf(stderr,"The cartesian topology requested (%d nodes) does not allow to map all tasks. Resubmit\n", sim.par_size);
    MPI_Finalize();
    exit(1);
    }

  MPI_Cart_create(MPI_COMM_WORLD, ndims, dims, periods, 1, &sim.comm_cart);
  MPI_Cart_coords(sim.comm_cart, sim.par_rank, 2, sim.coords);
  //sim.comm_cart = MPI_COMM_WORLD;
  sim.cart_dims[0] = dims[0];
  sim.cart_dims[1] = dims[1];

 /* Adjust the partitioning */
  sim.grid.Ncolumns = BlockSize; //LONGITUDE_SIZE; /* assume they divide evenly */
  sim.global_dims[0] = BlockSize * dims[0];

  sim.grid.Nrows = BlockSize; //LATITUDE_SIZE; /* assume they divide evenly */
  sim.global_dims[1] = BlockSize * dims[1];

  sim.global_dims[2] = BlockSize; //LEVELS_SIZE;
  sim.grid.Nlevels = BlockSize;

  //fprintf(stderr,"p=[%d], coords[%dx%d], array[%d*%d*%d] global[%d*%d*%d]\n", sim.par_rank, sim.coords[0], sim.coords[1], sim.grid.Ncolumns, sim.grid.Nrows, sim.grid.Nlevels, sim.global_dims[0], sim.global_dims[1], sim.global_dims[2]);

#ifdef VISIT_INSITU
    FILE *fp;
    if(sim.par_rank == 0){
        env = VisItGetEnvironment();
    //fp = fopen("/scratch/rosa/jfavre/foo.txt", "w");
    //fprintf(fp, "%s\n", env);
    }
      

    /* Pass the environment to all other processors collectively. */
    VisItSetupEnvironment2(env);
    if(env != NULL)
        free(env);

    /* Install callback functions for global communication. */
    VisItSetBroadcastIntFunction2(visit_broadcast_int_callback, (void*)&sim);
    VisItSetBroadcastStringFunction2(visit_broadcast_string_callback, (void*)&sim);
    /* Tell whether the simulation is parallel. */
    VisItSetParallel(sim.par_size > 1);
    VisItSetParallelRank(sim.par_rank);
    if(sim.par_rank == 0)
      {
      //fprintf(fp, "\n--reached before callbacks\n", env);
      //fclose(fp);
      }


    if(sim.par_rank == 0)
    {
        VisItInitializeSocketAndDumpSimFile("Cosmo",
            "Code YYY coupled with VisIt's libsim",
            "/path/to/where/sim/was/started",
            NULL, NULL, "/users/jfavre/.visit/simulations/rosa.sim2");
    }
#endif

  grid_data_allocate(&sim);

  mpi_elapsed = MPI_Wtime();
  mainloop(&sim);
  mpi_elapsed = MPI_Wtime() - mpi_elapsed;

  grid_data_dtor(&sim.grid);

  if(!sim.par_rank){
    get_procmem(&after);
    fprintf(stderr, "Testing get_procmem... %f %f %f\n",
          before, after, after-before);
    }

  MPI_Barrier(sim.comm_cart);
 
  if(sim.par_rank == 0)
    {
    printf("written grids of %d,%d,%d\n",  BlockSize, BlockSize, BlockSize);
    printf("written %d iterations\n", NUMBER_OF_ITERATIONS);
    printf("MPI Elapsed time: %f sec\n", mpi_elapsed);
    printf("average  %f Gbytes/sec\n", (BlockSize*BlockSize*BlockSize*4.0*sim.par_size*NUMBER_OF_ITERATIONS) / (1024*1024*1024*mpi_elapsed));
    }

  MPI_Finalize();

  return 0;
}