Пример #1
0
t_commrec *init_par(int *argc,char ***argv_ptr)
{
  t_commrec *cr;
  char      **argv;
  int       i;
  
  snew(cr,1);

  argv = *argv_ptr;
  
#ifdef GMX_MPI
#ifdef GMX_THREAD_MPI
  if (tMPI_Get_N(argc, argv_ptr)>1)
    gmx_parallel_env=1;
  else
    gmx_parallel_env=0;
#else
  gmx_parallel_env = 1;
#endif
#ifdef GMX_CHECK_MPI_ENV
  /* Do not use MPI calls when env.var. GMX_CHECK_MPI_ENV is not set */
  if (getenv(GMX_CHECK_MPI_ENV) == NULL)
    gmx_parallel_env = 0;
#endif
  if (gmx_parallel_env) {
    cr->sim_nodeid = gmx_setup(argc,argv,&cr->nnodes);
  } else {
    cr->nnodes     = 1;
    cr->sim_nodeid = 0;
  }
#else
  gmx_parallel_env = 0; 
  cr->sim_nodeid   = 0;
  cr->nnodes       = 1;
#endif

  if (!PAR(cr) && (cr->sim_nodeid != 0))
    gmx_comm("(!PAR(cr) && (cr->sim_nodeid != 0))");
  
  if (gmx_parallel_env) {
#ifdef GMX_MPI
    cr->mpi_comm_mysim = MPI_COMM_WORLD;
    cr->mpi_comm_mygroup = cr->mpi_comm_mysim;
#endif
  }
  cr->nodeid = cr->sim_nodeid;

  cr->duty = (DUTY_PP | DUTY_PME);

  /* Communicate arguments if parallel */
  if (PAR(cr))
    comm_args(cr,argc,argv_ptr);

  return cr;
}
Пример #2
0
int tMPI_Init(int *argc, char ***argv, int (*start_function)(int, char**))
{
#ifdef TMPI_TRACE
    tMPI_Trace_print("tMPI_Init(%p, %p, %p)", argc, argv, start_function);
#endif


    if (TMPI_COMM_WORLD==0) /* we're the main process */
    {
        int N=0;
        tMPI_Get_N(argc, argv, "-nt", &N);
        tMPI_Start_threads(FALSE, N, argc, argv, NULL, NULL, start_function);
    }
    else
    {
        /* if we're a sub-thread we need don't need to do anyhing, because 
           everything has already been set up by either the main thread, 
           or the thread runner function.*/
    }
    return TMPI_SUCCESS;
}