Fortran data offloading and chained lists

Hi all,
my request here is about your experience with fortran/nvfortran pointers offloading and OpenMP. I’ve many difficulties in porting a Fortran code on GPU with openMP offloading and if you could clarify the following concept/strategy or provide me some example or pointer to documentation to read…
My code is based on user defined types managed in chained lists. Most of the types looks like this simplified one:
type mytype
integer :: dim
integer, pointer :: tab(:)
type(mytype), pointer :: next
end type mytype
but types can also contain embeded chained lists.

My openmp strategy was to offload only the allocated tab arribute and I need to access these tab attributes using a pointer in loops.
integer, pointer :: ptr(:)
ptr=> current%tab

I offload data with a
!$omp enter data map(to:ptr)
to put them on the GPU and run kernels in loop (each kernel works on only one tab attribute, list is never managed on GPU)

But this raise frequent memory errors on the GPU so I think this is a wrong approach and I do not understand how to do this properly with OpenMP.

While I’m not 100% sure, I think this will only put the ptr itself on the device, not the data it points to. Try something like:

!$omp enter data map(to:ptr(:))

Hi Mat,
Yes I’m not very sure of the syntax too, and I try so many approach… My major missunderstanding is when using a pointer to go through the list. Example:

I have an array ARR(:) of these types (simpler to explain) and I use a local pointer to access the attribute tab of each element in ARR:

Do i=1 nelements
ptr=>ARR(i)%tab ! select the datas we need
!$omp target teams distribute parallel do
do j=1, ARR(i)%n
ptr(i) = 1
end do
end do

My local ptr descriptor (may be a local variable in a function) is not on the GPU, only the array ARR(i)%tab( : ) has been offloaded previously. And I do not understand what will occure in such a situation. I have some occurences where it works and others where it does not and I do not understand why.