 
   // For pascal GPU, the cudaMallocManaged() could probably allow to run larger systems.
   // Need to look for more informations about this!!
-  checkCudaErrors(cublasCreate(&handle_cublas_real));
-  checkCudaErrors(cublasCreate(&handle_cublas_imag));
-
-  checkCudaErrors(cudaStreamCreate(&stream_mem));
-  checkCudaErrors(cudaStreamCreate(&stream_real));
-  checkCudaErrors(cudaStreamCreate(&stream_imag));
-
-  checkCudaErrors(cublasSetStream(handle_cublas_real, stream_real));
-  checkCudaErrors(cublasSetStream(handle_cublas_imag, stream_imag));
-
-  checkCudaErrors(cudaMalloc( (void **)&ksn2e_d, sizeof(float) * norbs));
-  checkCudaErrors(cudaMalloc( (void **)&ksn2f_d, sizeof(float) * norbs));
-  checkCudaErrors(cudaMalloc( (void **)&X4_d, sizeof(float) * norbs*norbs));
-  
-  checkCudaErrors(cudaMalloc( (void **)&sab_d, sizeof(float) * norbs*norbs));
-
-  checkCudaErrors(cudaMalloc( (void **)&nb2v_d, sizeof(float) * nfermi*norbs));
-  checkCudaErrors(cudaMalloc( (void **)&nm2v_re_d, sizeof(float) * nfermi*nvirt));
-  checkCudaErrors(cudaMalloc( (void **)&nm2v_im_d, sizeof(float) * nfermi*nvirt));
-
-  checkCudaErrors(cudaMemcpy( X4_d, X4, sizeof(float) * norbs*norbs, cudaMemcpyHostToDevice));
+  cublasCreate(&handle_cublas_real);
+  cublasCreate(&handle_cublas_imag);
+
+  cudaStreamCreate(&stream_mem);
+  cudaStreamCreate(&stream_real);
+  cudaStreamCreate(&stream_imag);
+
+  cublasSetStream(handle_cublas_real, stream_real);
+  cublasSetStream(handle_cublas_imag, stream_imag);
+
+  cudaMalloc( (void **)&ksn2e_d, sizeof(float) * norbs);
+  cudaMalloc( (void **)&ksn2f_d, sizeof(float) * norbs);
+  cudaMalloc( (void **)&X4_d, sizeof(float) * norbs*norbs);
+  
+  cudaMalloc( (void **)&sab_d, sizeof(float) * norbs*norbs);
+
+  cudaMalloc( (void **)&nb2v_d, sizeof(float) * nfermi*norbs);
+  cudaMalloc( (void **)&nm2v_re_d, sizeof(float) * nfermi*nvirt);
+  cudaMalloc( (void **)&nm2v_im_d, sizeof(float) * nfermi*nvirt);
+
+  cudaMemcpy( X4_d, X4, sizeof(float) * norbs*norbs, cudaMemcpyHostToDevice);
   //checkCudaErrors(cublasSetMatrix(norbs, norbs, sizeof(float), X4, norbs, X4_d, norbs));
-  checkCudaErrors(cudaMemcpy( ksn2e_d, ksn2e, sizeof(float) * norbs, cudaMemcpyHostToDevice));
-  checkCudaErrors(cudaMemcpy( ksn2f_d, ksn2f, sizeof(float) * norbs, cudaMemcpyHostToDevice));
+  cudaMemcpy( ksn2e_d, ksn2e, sizeof(float) * norbs, cudaMemcpyHostToDevice);
+  cudaMemcpy( ksn2f_d, ksn2f, sizeof(float) * norbs, cudaMemcpyHostToDevice);
 
 }
 
 extern "C" void free_device()
 {
 
-  checkCudaErrors(cudaFree(X4_d));
-  checkCudaErrors(cudaFree(ksn2e_d));
-  checkCudaErrors(cudaFree(ksn2f_d));
-
-  checkCudaErrors(cudaFree(sab_d));
-  checkCudaErrors(cudaFree(nb2v_d));
-  checkCudaErrors(cudaFree(nm2v_re_d));
-  checkCudaErrors(cudaFree(nm2v_im_d));
-
-  checkCudaErrors(cublasDestroy(handle_cublas_real));
-  checkCudaErrors(cublasDestroy(handle_cublas_imag));
-  checkCudaErrors(cudaStreamDestroy(stream_mem));
-  checkCudaErrors(cudaStreamDestroy(stream_real));
-  checkCudaErrors(cudaStreamDestroy(stream_imag));
+  cudaFree(X4_d);
+  cudaFree(ksn2e_d);
+  cudaFree(ksn2f_d);
+
+  cudaFree(sab_d);
+  cudaFree(nb2v_d);
+  cudaFree(nm2v_re_d);
+  cudaFree(nm2v_im_d);
+
+  cublasDestroy(handle_cublas_real);
+  cublasDestroy(handle_cublas_imag);
+  cudaStreamDestroy(stream_mem);
+  cudaStreamDestroy(stream_real);
+  cudaStreamDestroy(stream_imag);
   cudaProfilerStop();
 }
 

{
  float *temp;
  temp = (float*) malloc(sizeof(float)*N1*N2);
  checkCudaErrors(cudaMemcpy( temp, dev, sizeof(float) * N1*N2, cudaMemcpyDeviceToHost));
  
  float sum = sum_float_vec(temp, N1*N2);
  free(temp);

  int i, j;

  temp = (float*) malloc(sizeof(float)*N1*N2);
  cudaMemcpy( temp, dev, sizeof(float) * N1*N2, cudaMemcpyDeviceToHost);
  
  printf("mat = \n");
  for (i = 0; i< N1; i++)
