MKL_ALLOC in Fortran... how to return a double array?

MKL_ALLOC in Fortran... how to return a double array?

I am trying to do two-dimensional DFTs using the Intel MKL (Math Kernal Library). I can't figure out how to use mkl_alloc to allocate a two-dimensional matrix (a rank two array) in Fortran. The form of mkl_alloc is

a_ptr = mkl_malloc( alloc_size, alignment )

where, alloc_size is an integer, and a_ptr is a Fortran pointer.  Because alloc_size is a single integer, the output a_ptr must be a pointer to an array (a rank one array).  I would like to associate the output of mkl_malloc with a rank two array, darray(N1,N2).  I cannot (as far as I can tell) equate two pointers that correspond to arrays of different rank.  This is really frustrating because I have a lot of code using the form darray(i,j) rather than the form array(i+N1*j).

I have considered using the newarray = RESHAPE(oldarray,newdim) function to convert the array dimensions, but I am not aware of any guarantee regarding the alignment of the result.

I've been banging my head against this for a couple days.  Any help would be greatly appreciated.

3 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

I figured this out on my own. The problem was that I didn't realize that the output from MKL_MALLOC is *not* a standard Fortran pointer, as many versions of the documentation had led me to believe. Therefore, none of the pointer manipulations I had been trying were working or even giving sensible results. The output of MKL_MALLOC is a non-standard Fortran Cray pointer. I wish this had been made more clear. The following code correctly allocates an aligned, rank two array.

real*8 array
pointer(ptr_to_array,array(n1,n2))
ptr_to_array = MKL_MALLOC(8*n1*n2,64)

and if I don't know the size of array in advance only during execution...

is it possible to use alignment in fortran in this case ?

Accedere per lasciare un commento.