public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* RANDOM_INIT() and coarray Fortran
@ 2021-04-03 17:28 Steve Kargl
  2021-04-04  3:30 ` Damian Rouson
  0 siblings, 1 reply; 22+ messages in thread
From: Steve Kargl @ 2021-04-03 17:28 UTC (permalink / raw)
  To: fortran

What to do about RANDOM_INIT() and coarray Fortran?

The main issue is that if one compiles with -fcoarray=lib
(or the WIP -fcoarray=shared), then RANDOM_INIT() may
require communication between images.  Thus, RANDOM_INIT()
cannot live in libgfortran for at least -fcoarray=lib.

Consider the simple code:

subroutine foo
   call random_init(.true., .false.)
end subroutine foo

I have updated the patch for
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98301
to use a stub routine for -fcoarray=lib and -fcoarray=shared.
Anyone, who knows how to use git, is encouraged to commit the patch.

For -fcoarray=none (default option) and -fcoarray=single, the
patch will cause gfortran to generate

__attribute__((fn spec (". ")))
void foo ()
{
  _gfortran_random_init (1, 0, 0);
}

_gfortran_random_init() live in libgfortran and it has been updated
to meet the intended requires of the Fortran standard.

With -fcoarray=lib and -fcoarray=shared, gfortran will now generate

__attribute__((fn spec (". ")))
void foo ()
{
  _gfortran_random_init_foobar (1, 0);
}

where _gfortran_random_init_foobar() lives in libgfortran.  It prints
an error message that RANDOM_INIT() is not yet supported for coarray
Fortran and exits.  Someone, who cares about coarray Fortran, can fix
-fcoarray=lib and -fcoarray=shared by updating trans-decl.c (see the
FIXME for random_init()) to emit 

__attribute__((fn spec (". ")))
void foo ()
{
  _gfortran_caf_random_init (1, 0);
}

or

__attribute__((fn spec (". ")))
void foo ()
{
  _gfortran_cas_random_init (1, 0);
}

-- 
Steve

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-06-06 10:15 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-03 17:28 RANDOM_INIT() and coarray Fortran Steve Kargl
2021-04-04  3:30 ` Damian Rouson
2021-04-04  5:33   ` Steve Kargl
2021-04-23 16:43     ` [Patch, Fortran] PR98301 " Andre Vehreschild
2021-04-23 17:18       ` Steve Kargl
2021-04-24 10:49         ` [Patch, Fortran, Update] " Andre Vehreschild
2021-04-24 15:44           ` Steve Kargl
2021-04-24 15:56             ` Dr. Andre Vehreschild
2021-04-25 20:03           ` Steve Kargl
2021-04-26 10:36             ` [Patch, Fortran, Update 2] " Andre Vehreschild
2021-05-03  9:21               ` [Ping, Patch, " Andre Vehreschild
2021-05-03 15:20                 ` Steve Kargl
2021-05-21  8:09                   ` [Ping^2, Patch, Fortran] " Andre Vehreschild
2021-05-21 15:08                     ` Steve Kargl
2021-05-22  2:38                       ` Jerry D
2021-05-22 11:39                         ` Andre Vehreschild
2021-05-22 17:58                           ` Martin Liška
2021-05-23 11:59                             ` Andre Vehreschild
2021-05-23 12:17                               ` Martin Liška
2021-06-05 14:04                           ` [Patch, Fortran, backport 2 gcc-11] " Andre Vehreschild
2021-06-05 16:27                             ` Steve Kargl
2021-06-06 10:14                               ` [COMITTED, Patch, " Andre Vehreschild

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).