testing/icgen/random_verschillende_resoluties_N-GenIC/gadget3_64/pm_periodic.c
void pm_init_periodic(void)
{
  int i;
  int slab_to_task_local[PMGRID];

  All.Asmth[0] = ASMTH * All.BoxSize / PMGRID;
  All.Rcut[0] = RCUT * All.Asmth[0];

  /* Set up the FFTW plan files. */

  fft_forward_plan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD, PMGRID, PMGRID, PMGRID,
					     FFTW_REAL_TO_COMPLEX, FFTW_ESTIMATE | FFTW_IN_PLACE);
  fft_inverse_plan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD, PMGRID, PMGRID, PMGRID,
					     FFTW_COMPLEX_TO_REAL, FFTW_ESTIMATE | FFTW_IN_PLACE);

  /* Workspace out the ranges on each processor. */

  rfftwnd_mpi_local_sizes(fft_forward_plan, &nslab_x, &slabstart_x, &nslab_y, &slabstart_y, &fftsize);

  for(i = 0; i < PMGRID; i++)
    slab_to_task_local[i] = 0;

  for(i = 0; i < nslab_x; i++)
    slab_to_task_local[slabstart_x + i] = ThisTask;

  MPI_Allreduce(slab_to_task_local, slab_to_task, PMGRID, MPI_INT, MPI_SUM, MPI_COMM_WORLD);

  MPI_Allreduce(&nslab_x, &smallest_slab, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);

  slabs_per_task = (int *) mymalloc(NTask * sizeof(int));
  MPI_Allgather(&nslab_x, 1, MPI_INT, slabs_per_task, 1, MPI_INT, MPI_COMM_WORLD);

  first_slab_of_task = (int *) mymalloc(NTask * sizeof(int));
  MPI_Allgather(&slabstart_x, 1, MPI_INT, first_slab_of_task, 1, MPI_INT, MPI_COMM_WORLD);

  to_slab_fac = PMGRID / All.BoxSize;

  MPI_Allreduce(&fftsize, &maxfftsize, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
}
/*! This routines generates the FFTW-plans to carry out the parallel FFTs
 *  later on. Some auxiliary variables are also initialized.
 */
This routines generates the FFTW-plans to carry out the parallel FFTs
later on. Some auxiliary variables are also initialized.
This routines generates the FFTW - plans to carry out the parallel FFTs later on . Some auxiliary variables are also initialized .
void pm_init_periodic(void)
{
  int i;
  int slab_to_task_local[PMGRID];
  All.Asmth[0] = ASMTH * All.BoxSize / PMGRID;
  All.Rcut[0] = RCUT * All.Asmth[0];
  fft_forward_plan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD, PMGRID, PMGRID, PMGRID,
					     FFTW_REAL_TO_COMPLEX, FFTW_ESTIMATE | FFTW_IN_PLACE);
  fft_inverse_plan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD, PMGRID, PMGRID, PMGRID,
					     FFTW_COMPLEX_TO_REAL, FFTW_ESTIMATE | FFTW_IN_PLACE);
  rfftwnd_mpi_local_sizes(fft_forward_plan, &nslab_x, &slabstart_x, &nslab_y, &slabstart_y, &fftsize);
  for(i = 0; i < PMGRID; i++)
    slab_to_task_local[i] = 0;
  for(i = 0; i < nslab_x; i++)
    slab_to_task_local[slabstart_x + i] = ThisTask;
  MPI_Allreduce(slab_to_task_local, slab_to_task, PMGRID, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
  MPI_Allreduce(&nslab_x, &smallest_slab, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);
  slabs_per_task = (int *) mymalloc(NTask * sizeof(int));
  MPI_Allgather(&nslab_x, 1, MPI_INT, slabs_per_task, 1, MPI_INT, MPI_COMM_WORLD);
  first_slab_of_task = (int *) mymalloc(NTask * sizeof(int));
  MPI_Allgather(&slabstart_x, 1, MPI_INT, first_slab_of_task, 1, MPI_INT, MPI_COMM_WORLD);
  to_slab_fac = PMGRID / All.BoxSize;
  MPI_Allreduce(&fftsize, &maxfftsize, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
}
void pm_init_periodic ( void ) { int i ; int slab_to_task_local [ PMGRID ] ; All . Asmth [ 0 ] = ASMTH * All . BoxSize / PMGRID ; All . Rcut [ 0 ] = RCUT * All . Asmth [ 0 ] ; fft_forward_plan = rfftw3d_mpi_create_plan ( MPI_COMM_WORLD , PMGRID , PMGRID , PMGRID , FFTW_REAL_TO_COMPLEX , FFTW_ESTIMATE | FFTW_IN_PLACE ) ; fft_inverse_plan = rfftw3d_mpi_create_plan ( MPI_COMM_WORLD , PMGRID , PMGRID , PMGRID , FFTW_COMPLEX_TO_REAL , FFTW_ESTIMATE | FFTW_IN_PLACE ) ; rfftwnd_mpi_local_sizes ( fft_forward_plan , & nslab_x , & slabstart_x , & nslab_y , & slabstart_y , & fftsize ) ; for ( i = 0 ; i < PMGRID ; i ++ ) slab_to_task_local [ i ] = 0 ; for ( i = 0 ; i < nslab_x ; i ++ ) slab_to_task_local [ slabstart_x + i ] = ThisTask ; MPI_Allreduce ( slab_to_task_local , slab_to_task , PMGRID , MPI_INT , MPI_SUM , MPI_COMM_WORLD ) ; MPI_Allreduce ( & nslab_x , & smallest_slab , 1 , MPI_INT , MPI_MIN , MPI_COMM_WORLD ) ; slabs_per_task = ( int * ) mymalloc ( NTask * sizeof ( int ) ) ; MPI_Allgather ( & nslab_x , 1 , MPI_INT , slabs_per_task , 1 , MPI_INT , MPI_COMM_WORLD ) ; first_slab_of_task = ( int * ) mymalloc ( NTask * sizeof ( int ) ) ; MPI_Allgather ( & slabstart_x , 1 , MPI_INT , first_slab_of_task , 1 , MPI_INT , MPI_COMM_WORLD ) ; to_slab_fac = PMGRID / All . BoxSize ; MPI_Allreduce ( & fftsize , & maxfftsize , 1 , MPI_INT , MPI_MAX , MPI_COMM_WORLD ) ; }
This routines generates the FFTW-plans to carry out the parallel FFTs
  later on.
This routines generates the FFTW - plans to carry out the parallel FFTs later on .
/* Set up the FFTW plan files. */ /* Workspace out the ranges on each processor. */