testing/icgen/random_verschillende_resoluties_N-GenIC/gadget3_64/pm_nonperiodic.c
void pm_init_nonperiodic(void)
{
  int i, slab_to_task_local[GRID];
  double bytes_tot = 0;
  size_t bytes;

  /* Set up the FFTW plan files. */

  fft_forward_plan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD, GRID, GRID, GRID,
					     FFTW_REAL_TO_COMPLEX, FFTW_ESTIMATE | FFTW_IN_PLACE);
  fft_inverse_plan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD, GRID, GRID, GRID,
					     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 < GRID; 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, GRID, MPI_INT, MPI_SUM, 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);

  MPI_Allreduce(&fftsize, &maxfftsize, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);

  /* now allocate memory to hold the FFT fields */

#if !defined(PERIODIC)
  if(!(kernel[0] = (fftw_real *) mymalloc(bytes = fftsize * sizeof(fftw_real))))
    {
      printf("failed to allocate memory for `FFT-kernel[0]' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  fft_of_kernel[0] = (fftw_complex *) kernel[0];
#ifdef SCALARFIELD
  if(!(kernel_scalarfield[0] = (fftw_real *) mymalloc(bytes = fftsize * sizeof(fftw_real))))
    {
      printf("failed to allocate memory for `FFT-kernel_scalarfield[0]' (%g MB).\n",
	     bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  fft_of_kernel_scalarfield[0] = (fftw_complex *) kernel_scalarfield[0];
#endif
#endif

#if defined(PLACEHIGHRESREGION)
  if(!(kernel[1] = (fftw_real *) mymalloc(bytes = fftsize * sizeof(fftw_real))))
    {
      printf("failed to allocate memory for `FFT-kernel[1]' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  fft_of_kernel[1] = (fftw_complex *) kernel[1];
#ifdef SCALARFIELD
  if(!(kernel_scalarfield[1] = (fftw_real *) mymalloc(bytes = fftsize * sizeof(fftw_real))))
    {
      printf("failed to allocate memory for `FFT-kernel_scalarfield[1]' (%g MB).\n",
	     bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  fft_of_kernel_scalarfield[1] = (fftw_complex *) kernel_scalarfield[1];
#endif
#endif

  if(ThisTask == 0)
    printf("\nAllocated %g MByte for FFT kernel(s).\n\n", bytes_tot / (1024.0 * 1024.0));

}
/*! Initialization of the non-periodic PM routines. The plan-files for FFTW
 *  are created. Finally, the routine to set-up the non-periodic Greens
 *  function is called.
 */
Initialization of the non-periodic PM routines. The plan-files for FFTW
are created. Finally, the routine to set-up the non-periodic Greens
function is called.
Initialization of the non - periodic PM routines . The plan - files for FFTW are created . Finally the routine to set - up the non - periodic Greens function is called .
void pm_init_nonperiodic(void)
{
  int i, slab_to_task_local[GRID];
  double bytes_tot = 0;
  size_t bytes;
  fft_forward_plan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD, GRID, GRID, GRID,
					     FFTW_REAL_TO_COMPLEX, FFTW_ESTIMATE | FFTW_IN_PLACE);
  fft_inverse_plan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD, GRID, GRID, GRID,
					     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 < GRID; 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, GRID, MPI_INT, MPI_SUM, 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);
  MPI_Allreduce(&fftsize, &maxfftsize, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
#if !defined(PERIODIC)
  if(!(kernel[0] = (fftw_real *) mymalloc(bytes = fftsize * sizeof(fftw_real))))
    {
      printf("failed to allocate memory for `FFT-kernel[0]' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  fft_of_kernel[0] = (fftw_complex *) kernel[0];
#ifdef SCALARFIELD
  if(!(kernel_scalarfield[0] = (fftw_real *) mymalloc(bytes = fftsize * sizeof(fftw_real))))
    {
      printf("failed to allocate memory for `FFT-kernel_scalarfield[0]' (%g MB).\n",
	     bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  fft_of_kernel_scalarfield[0] = (fftw_complex *) kernel_scalarfield[0];
#endif
#endif
#if defined(PLACEHIGHRESREGION)
  if(!(kernel[1] = (fftw_real *) mymalloc(bytes = fftsize * sizeof(fftw_real))))
    {
      printf("failed to allocate memory for `FFT-kernel[1]' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  fft_of_kernel[1] = (fftw_complex *) kernel[1];
#ifdef SCALARFIELD
  if(!(kernel_scalarfield[1] = (fftw_real *) mymalloc(bytes = fftsize * sizeof(fftw_real))))
    {
      printf("failed to allocate memory for `FFT-kernel_scalarfield[1]' (%g MB).\n",
	     bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  fft_of_kernel_scalarfield[1] = (fftw_complex *) kernel_scalarfield[1];
#endif
#endif
  if(ThisTask == 0)
    printf("\nAllocated %g MByte for FFT kernel(s).\n\n", bytes_tot / (1024.0 * 1024.0));
}
void pm_init_nonperiodic ( void ) { int i , slab_to_task_local [ GRID ] ; double bytes_tot = 0 ; size_t bytes ; fft_forward_plan = rfftw3d_mpi_create_plan ( MPI_COMM_WORLD , GRID , GRID , GRID , FFTW_REAL_TO_COMPLEX , FFTW_ESTIMATE | FFTW_IN_PLACE ) ; fft_inverse_plan = rfftw3d_mpi_create_plan ( MPI_COMM_WORLD , GRID , GRID , GRID , 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 < GRID ; 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 , GRID , MPI_INT , MPI_SUM , 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 ) ; MPI_Allreduce ( & fftsize , & maxfftsize , 1 , MPI_INT , MPI_MAX , MPI_COMM_WORLD ) ; #if ! defined ( PERIODIC ) if ( ! ( kernel [ 0 ] = ( fftw_real * ) mymalloc ( bytes = fftsize * sizeof ( fftw_real ) ) ) ) { printf ( " \n " , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 1 ) ; } bytes_tot += bytes ; fft_of_kernel [ 0 ] = ( fftw_complex * ) kernel [ 0 ] ; #ifdef SCALARFIELD if ( ! ( kernel_scalarfield [ 0 ] = ( fftw_real * ) mymalloc ( bytes = fftsize * sizeof ( fftw_real ) ) ) ) { printf ( " \n " , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 1 ) ; } bytes_tot += bytes ; fft_of_kernel_scalarfield [ 0 ] = ( fftw_complex * ) kernel_scalarfield [ 0 ] ; #endif #endif #if defined ( PLACEHIGHRESREGION ) if ( ! ( kernel [ 1 ] = ( fftw_real * ) mymalloc ( bytes = fftsize * sizeof ( fftw_real ) ) ) ) { printf ( " \n " , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 1 ) ; } bytes_tot += bytes ; fft_of_kernel [ 1 ] = ( fftw_complex * ) kernel [ 1 ] ; #ifdef SCALARFIELD if ( ! ( kernel_scalarfield [ 1 ] = ( fftw_real * ) mymalloc ( bytes = fftsize * sizeof ( fftw_real ) ) ) ) { printf ( " \n " , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 1 ) ; } bytes_tot += bytes ; fft_of_kernel_scalarfield [ 1 ] = ( fftw_complex * ) kernel_scalarfield [ 1 ] ; #endif #endif if ( ThisTask == 0 ) printf ( " \n \n \n " , bytes_tot / ( 1024.0 * 1024.0 ) ) ; }
Initialization of the non-periodic PM routines.
Initialization of the non - periodic PM routines .
/* Set up the FFTW plan files. */ /* Workspace out the ranges on each processor. */ /* now allocate memory to hold the FFT fields */