     generate_phase_factors_gpu_kernel<<<grid_b, grid_t>>>
     (
         num_gvec_loc__, 
+        num_atoms__,
         atom_pos__, 
         gvec__, 
         phase_factors__

    int ia = blockIdx.y;
    int igloc = blockIdx.x * blockDim.x + threadIdx.x;

    if (igloc < num_gvec_loc)
    {
        int gvx = gvec[array2D_offset(0, igloc, 3)];
        int gvy = gvec[array2D_offset(1, igloc, 3)];
        int gvz = gvec[array2D_offset(2, igloc, 3)];
    
        double ax = atom_pos[array2D_offset(0, ia, 3)];
        double ay = atom_pos[array2D_offset(1, ia, 3)];
        double az = atom_pos[array2D_offset(2, ia, 3)];

        double p = twopi * (ax * gvx + ay * gvy + az * gvz);


__global__ void generate_phase_factors_gpu_kernel
(
    int num_gvec_loc, 
    int num_atoms,
    double const* atom_pos, 
    int const* gvec, 
    cuDoubleComplex* phase_factors
