testing/icgen/random_verschillende_resoluties_N-GenIC/gadget3_64/pm_periodic.c
void pm_init_periodic_allocate(void)
{
  double bytes_tot = 0;
  size_t bytes;

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

  if(!(rhogrid = (fftw_real *) mymalloc(bytes = maxfftsize * sizeof(d_fftw_real))))
    {
      printf("failed to allocate memory for `FFT-rhogrid' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;

  if(!(forcegrid = (fftw_real *) mymalloc(bytes = maxfftsize * sizeof(d_fftw_real))))
    {
      printf("failed to allocate memory for `FFT-forcegrid' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;

  if(!(part = (struct part_slab_data *) mymalloc(bytes = 8 * NumPart * sizeof(struct part_slab_data))))
    {
      printf("failed to allocate memory for `part' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;

  if(!(part_sortindex = (int *) mymalloc(bytes = 8 * NumPart * sizeof(int))))
    {
      printf("failed to allocate memory for `part_sortindex' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;

  if(ThisTask == 0)
    printf("Using %g MByte for periodic FFT computation. (presently allocated=%g MB)\n",
	   bytes_tot / (1024.0 * 1024.0), AllocatedBytes / (1024.0 * 1024.0));

  workspace = forcegrid;

  fft_of_rhogrid = (fftw_complex *) & rhogrid[0];

  d_rhogrid = (d_fftw_real *) rhogrid;
  d_forcegrid = (d_fftw_real *) forcegrid;
  d_workspace = (d_fftw_real *) workspace;
}
/*! This function allocates the memory neeed to compute the long-range PM
 *  force. Three fields are used, one to hold the density (and its FFT, and
 *  then the real-space potential), one to hold the force field obtained by
 *  finite differencing, and finally a workspace field, which is used both as
 *  workspace for the parallel FFT, and as buffer for the communication
 *  algorithm used in the force computation.
 */
This function allocates the memory neeed to compute the long-range PM
force. Three fields are used, one to hold the density (and its FFT, and
then the real-space potential), one to hold the force field obtained by
finite differencing, and finally a workspace field, which is used both as
workspace for the parallel FFT, and as buffer for the communication
algorithm used in the force computation.
This function allocates the memory neeed to compute the long - range PM force . Three fields are used one to hold the density ( and its FFT and then the real - space potential ) one to hold the force field obtained by finite differencing and finally a workspace field which is used both as workspace for the parallel FFT and as buffer for the communication algorithm used in the force computation .
void pm_init_periodic_allocate(void)
{
  double bytes_tot = 0;
  size_t bytes;
  if(!(rhogrid = (fftw_real *) mymalloc(bytes = maxfftsize * sizeof(d_fftw_real))))
    {
      printf("failed to allocate memory for `FFT-rhogrid' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  if(!(forcegrid = (fftw_real *) mymalloc(bytes = maxfftsize * sizeof(d_fftw_real))))
    {
      printf("failed to allocate memory for `FFT-forcegrid' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  if(!(part = (struct part_slab_data *) mymalloc(bytes = 8 * NumPart * sizeof(struct part_slab_data))))
    {
      printf("failed to allocate memory for `part' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  if(!(part_sortindex = (int *) mymalloc(bytes = 8 * NumPart * sizeof(int))))
    {
      printf("failed to allocate memory for `part_sortindex' (%g MB).\n", bytes / (1024.0 * 1024.0));
      endrun(1);
    }
  bytes_tot += bytes;
  if(ThisTask == 0)
    printf("Using %g MByte for periodic FFT computation. (presently allocated=%g MB)\n",
	   bytes_tot / (1024.0 * 1024.0), AllocatedBytes / (1024.0 * 1024.0));
  workspace = forcegrid;
  fft_of_rhogrid = (fftw_complex *) & rhogrid[0];
  d_rhogrid = (d_fftw_real *) rhogrid;
  d_forcegrid = (d_fftw_real *) forcegrid;
  d_workspace = (d_fftw_real *) workspace;
}
void pm_init_periodic_allocate ( void ) { double bytes_tot = 0 ; size_t bytes ; if ( ! ( rhogrid = ( fftw_real * ) mymalloc ( bytes = maxfftsize * sizeof ( d_fftw_real ) ) ) ) { printf ( " \n " , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 1 ) ; } bytes_tot += bytes ; if ( ! ( forcegrid = ( fftw_real * ) mymalloc ( bytes = maxfftsize * sizeof ( d_fftw_real ) ) ) ) { printf ( " \n " , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 1 ) ; } bytes_tot += bytes ; if ( ! ( part = ( struct part_slab_data * ) mymalloc ( bytes = 8 * NumPart * sizeof ( struct part_slab_data ) ) ) ) { printf ( " \n " , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 1 ) ; } bytes_tot += bytes ; if ( ! ( part_sortindex = ( int * ) mymalloc ( bytes = 8 * NumPart * sizeof ( int ) ) ) ) { printf ( " \n " , bytes / ( 1024.0 * 1024.0 ) ) ; endrun ( 1 ) ; } bytes_tot += bytes ; if ( ThisTask == 0 ) printf ( " \n " , bytes_tot / ( 1024.0 * 1024.0 ) , AllocatedBytes / ( 1024.0 * 1024.0 ) ) ; workspace = forcegrid ; fft_of_rhogrid = ( fftw_complex * ) & rhogrid [ 0 ] ; d_rhogrid = ( d_fftw_real * ) rhogrid ; d_forcegrid = ( d_fftw_real * ) forcegrid ; d_workspace = ( d_fftw_real * ) workspace ; }
This function allocates the memory neeed to compute the long-range PM
  force.
This function allocates the memory neeed to compute the long - range PM force .
/* allocate the memory to hold the FFT fields */