I am pretty confused about how to transfer some initial data, and allocate arrays, to the MIC at the beginning of my code. For instance, one of my sources of confusion is my position array r. Here, my r is an array of structure
double precision :: x,y,z
integer :: type
end type posit
type(posit), allocatable :: r(:)
r is allocated at run time when the number of particles is read in. The values of the array will change during every iteration of the code, as the particles move around. However the size of the array doesn't change, so I would like to allocate the memory on the MIC at run time. When I use the MIC, I would like the elements of r to be copied to the preallocated memory locations. However, my understanding of
!dir$ offload target(mic:0) in(r) alloc_if(0)
is that r will not be read back from the MIC to the host, which is good for me, but the alloc_if(0) will not allocate memory and will cause the MIC to use the data from the previous runs. If this is true, is there a way for me to have the MIC allocate memory at run time, read in the values of the r whenever the mic is called, and then not deallocate. Also as my final question, what would I have to do if r was a matrix as opposed to array and also what if r was just a scalar double.