[Fortran] Help with intrinsic function returning array

Mikael Morin mikael.morin@sfr.fr
Mon May 16 20:07:00 GMT 2016


Le 11/05/2016 23:35, Alessandro Fanfarillo a écrit :
> Dear all,
>
> I'm encountering some difficulties with implementing the intrinsic
> function "failed_images" defined in the latest TS-18508
> (http://isotc.iso.org/livelink/livelink?func=ll&objId=17288706&objAction=Open).
>
> The idea is to call the external _gfortran_caf_failed_images function
> (implemented in OpenCoarrays) than returns a rank-1 integer array
> representing the list of coarray images that have been failed
> (detected by the calling images).
> Of course, the number of failed images is not known a-priori by the
> user, thus the list should be stored in an allocatable array.
>
> So far, I pass by reference the variable representing the list length
> to the _gfortran_caf_failed_images function; once returned, this value
> contains the number of elements composing the array.
> Then, I manually build a temporary array, setting the right
> bounds,type,data and offset.
>
> What I would like to do is to assign this temporary array to the
> variable on the lhs of the assignment.
>
> I noticed several routines that manage the situation of a function
> returning an array but it is not clear to me how to adapt them to my
> situation.
>
> In attachment you can find what I've done so far; the function that
> I'm referring to is gfc_conv_intrinsic_failed_images.
>
> Thanks in advance for your support.
>
> Regards,
>
> Alessandro
>
Hello,

is there something preventing you from passing the variable's array 
descriptor address directly to the function, so that it's already all 
setup and assigned upon return?
I think that would be the easiest. Namely add the GFC_ISYM_FAILED_IMAGES 
to gfc_is_intrinsic_libcall, and see whether it works automatically (no 
promise).

Mikael



More information about the Fortran mailing list