topic I figured this out on my own. in IntelĀ® oneAPI Math Kernel Library
https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-ALLOC-in-Fortran-how-to-return-a-double-array/m-p/994956#M18252
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)Sat, 29 Sep 2012 00:40:46 GMTAndrew_M_32012-09-29T00:40:46ZMKL_ALLOC in Fortran... how to return a double array?
https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-ALLOC-in-Fortran-how-to-return-a-double-array/m-p/994955#M18251
<P></P>
<P>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</P>
<P><SPAN class="var">a_ptr</SPAN><SPAN class="delim"> = </SPAN><SPAN class="kwd">mkl_malloc</SPAN><SPAN class="delim">( </SPAN><SPAN class="var">alloc_size</SPAN><SPAN class="sep">, </SPAN><SPAN class="var">alignment</SPAN><SPAN class="delim"> )</SPAN></P>
<P><SPAN class="delim">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).</SPAN></P>
<P>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.</P>
<P>I've been banging my head against this for a couple days. Any help would be greatly appreciated.</P>Fri, 28 Sep 2012 02:17:10 GMThttps://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-ALLOC-in-Fortran-how-to-return-a-double-array/m-p/994955#M18251Andrew_M_32012-09-28T02:17:10ZI figured this out on my own.
https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-ALLOC-in-Fortran-how-to-return-a-double-array/m-p/994956#M18252
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)Sat, 29 Sep 2012 00:40:46 GMThttps://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-ALLOC-in-Fortran-how-to-return-a-double-array/m-p/994956#M18252Andrew_M_32012-09-29T00:40:46Zand if I don't know the size
https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-ALLOC-in-Fortran-how-to-return-a-double-array/m-p/994957#M18253
<P>and if I don't know the size of array in advance only during execution...</P>
<P>is it possible to use alignment in fortran in this case ?</P>Mon, 21 Oct 2013 15:37:44 GMThttps://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-ALLOC-in-Fortran-how-to-return-a-double-array/m-p/994957#M18253Vitaliy_F_2013-10-21T15:37:44Z