diff --git a/src/KOKKOS/memory_kokkos.h b/src/KOKKOS/memory_kokkos.h index 5097936ba29ee409f84772d66befede90c86d2a8..034fbca239cd3dd81e2986614183c774ca6a8bc1 100644 --- a/src/KOKKOS/memory_kokkos.h +++ b/src/KOKKOS/memory_kokkos.h @@ -173,7 +173,10 @@ TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, bigint n = 0; for (int i = 0; i < n1; i++) { - array[i] = &data.h_view(i,0); + if(n2==0) + array[i] = NULL; + else + array[i] = &data.h_view(i,0); n += n2; } return data; @@ -195,7 +198,10 @@ template <typename TYPE, typename HTYPE> bigint n = 0; for (int i = 0; i < n1; i++) { - array[i] = &h_data(i,0); + if(n2==0) + array[i] = NULL; + else + array[i] = &h_data(i,0); n += n2; } return data; @@ -216,7 +222,10 @@ TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type**) srealloc(array,nbytes,name); for (int i = 0; i < n1; i++) - array[i] = &data.h_view(i,0); + if(n2==0) + array[i] = NULL; + else + array[i] = &data.h_view(i,0); return data; } @@ -230,7 +239,10 @@ TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type **) smalloc(nbytes,name); for (int i = 0; i < n1; i++) - array[i] = &data.h_view(i,0); + if(data.h_view.dimension_1()==0) + array[i] = NULL; + else + array[i] = &data.h_view(i,0); return data; } @@ -247,7 +259,10 @@ TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type **) smalloc(nbytes,name); for (int i = 0; i < n1; i++) - array[i] = &data.h_view(i,0); + if(data.h_view.dimension_1()==0) + array[i] = NULL; + else + array[i] = &data.h_view(i,0); return data; }