From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by sourceware.org (Postfix) with ESMTPS id 094313858004 for ; Sat, 3 Apr 2021 17:28:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 094313858004 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.16.1/8.16.1) with ESMTPS id 133HSkMg014172 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Sat, 3 Apr 2021 10:28:46 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.16.1/8.16.1/Submit) id 133HSkuP014171 for fortran@gcc.gnu.org; Sat, 3 Apr 2021 10:28:46 -0700 (PDT) (envelope-from sgk) Date: Sat, 3 Apr 2021 10:28:46 -0700 From: Steve Kargl To: fortran@gcc.gnu.org Subject: RANDOM_INIT() and coarray Fortran Message-ID: <20210403172846.GA14134@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Apr 2021 17:28:49 -0000 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