public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
To: Mikael Morin <mikael.morin@sfr.fr>
Cc: gfortran <fortran@gcc.gnu.org>
Subject: Re: [Fortran] Help with intrinsic function returning array
Date: Tue, 17 May 2016 03:30:00 -0000	[thread overview]
Message-ID: <CAHqFgjWiEGuh6ma4m4PJFmy-FPPMXeDVtAN2_4Jxj=x2-cQDdQ@mail.gmail.com> (raw)
In-Reply-To: <573A283B.6060306@sfr.fr>

Hi,

actually I've already tried that way but the size of the array
returned by the function cannot be computed by the compiler. The
number of failed images is an information contained in OpenCoarrays
(which is an external library).

Here is an example:

program fail
integer, allocatable :: failed(:)

failed = failed_images()

end program

In this case I expect to see the assignment translated into something like:

failed.data = _gfortran_caf_failed_images(&size,0B,0B);
failed.offset = -1;
failed.dim[0].lbound = 1;
failed.dim[0].ubound = size;



2016-05-16 14:06 GMT-06:00 Mikael Morin <mikael.morin@sfr.fr>:
> 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
>

  reply	other threads:[~2016-05-17  3:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 21:36 Alessandro Fanfarillo
2016-05-16 20:07 ` Mikael Morin
2016-05-17  3:30   ` Alessandro Fanfarillo [this message]
2016-05-17 19:47     ` Mikael Morin
2016-05-17 20:21       ` Alessandro Fanfarillo
2016-05-18 20:11         ` Mikael Morin
2016-05-19 17:57           ` Alessandro Fanfarillo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHqFgjWiEGuh6ma4m4PJFmy-FPPMXeDVtAN2_4Jxj=x2-cQDdQ@mail.gmail.com' \
    --to=fanfarillo.gcc@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=mikael.morin@sfr.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).