Exemple #1
0
void latex()
{
  /* TODO: Separate logic and markup */
  puts("\\documentclass{article}");
  puts("\\usepackage{fullpage}");
  puts("\\usepackage[thinlines]{easytable}");
  puts("\\thispagestyle{empty}");
  puts("\\begin{document}");
  puts("\\noindent");
  puts("\\large");

  srand((unsigned)time(NULL)); /* TODO: Add pre-seed o&ption */
  cell* first_cell = generate_cell_list();
  tex_loop(first_cell);
  delete_cell_list(first_cell);
  
  puts("\\end{document}");

}
Exemple #2
0
void cell_spin(int rank, int ncell, MPI_Comm comm)
{
    cell_list cells;
    int i;
    int msg;
    cells = make_cell_list();
    /* Build the list of cells */
    for ( i = 0; i < ncell; i++ ) {
        if ( rank == get_cell_rank(i) ) {
            push(make_cell(i), &(cells->cells));
        }
    }
    i = 0;
    /* Loop, updating the list of cells.  Every time through the loop,
     * we look to see if we have a control message (from the master)
     * and if so, act accordingly (reset cells for end of year, or
     * finish simulation).  Note the the control message could arrive
     * while in the update_cell_list function, so that also probes for
     * interrupts and returns early if it gets one. */
    do {
        MPI_Status status;
        int flag;
        msg = -1;
        update_cell_list(cells, comm);
        MPI_Iprobe(0, CONTROL_TAG, comm, &flag, &status);
        if ( flag ) {
            MPI_Recv(&msg, 1, MPI_INT, status.MPI_SOURCE,
                     status.MPI_TAG, comm, &status);
        }
        if ( msg == YEAR_END ) {
            list it;
            for ( it = cells->cells; it; it = it->next ) {
                print_cell((cell)(it->data));
            }
            reset_cell_list(cells);
        }
    } while ( msg != SIMULATION_END )
        ;

    delete_cell_list(cells);
}