[J3] [EXTERNAL] Re: Custom Memory Allocator

Reuben D. Budiardja reubendb at ornl.gov
Fri Nov 15 19:19:29 EST 2019

Hi Vipul,

On 11/15/2019 03:47 PM, Vipul Parekh via J3 wrote:
> Reuben,
> Fortran standard states the object "shall have been allocated using
> the same mechanism as the Fortran ALLOCATE statement" for use with
> enhanced interoperability features introduced in Fortran 2018 i.e., in
> order to work with CFI_* functions and C descriptors.
> But with custom allocator, you can never know if you have the same
> mechanism as Fortran ALLOCATE statement.  Thus the C descriptor based
> approach is effectively not an option.

Yes, as I noted there doesn't seem to be a way to do this in a standard 
conformance way.

> So you're then back to the "opaque pointer" option introduced starting
> Fortran 2003.  Now, would there be a reason for you not to consider
> this which then made you send this inquiry?

Yes, we can do this with Fortran pointer: allocate a C pointer with the 
custom allocator and dereference it to a Fortran pointer with 
C_F_POINTER(), but for those reasons that allocatable are more 
advantageous over pointer, I'd like to be able to use allocatable array 


More information about the J3 mailing list