       temp_potential = buffer_potential;
     }
     // allocate an array on the CPU to hold max_dti returned from each thread block
-    host_dti_array = (Real *) malloc(ngrid*sizeof(Real));
+    CudaSafeCall( cudaHostAlloc(&host_dti_array, ngrid*sizeof(Real), cudaHostAllocDefault) );
     #ifdef COOLING_GPU
-    host_dt_array = (Real *) malloc(ngrid*sizeof(Real));
+    CudaSafeCall( cudaHostAlloc(&host_dt_array, ngrid*sizeof(Real), cudaHostAllocDefault) );
     #endif  
 
     // allocate memory on the GPU

void Free_Memory_Simple_3D(){
  
  // free CPU memory
  if (block_tot > 1) free(buffer);
  free(host_dti_array);  
  #ifdef COOLING_GPU
  free(host_dt_array);  
  #endif  
  
  // free the GPU memory


    // allocate buffer to copy conserved variable blocks to/from
    if (block_tot > 1) {
      if ( cudaSuccess != cudaHostAlloc(&buffer, n_fields*BLOCK_VOL*sizeof(Real), cudaHostAllocDefault) ) {
        printf("Failed to allocate CPU buffer.\n");
      }
      tmp1 = buffer;
