Bug 98915 - OpenACC 'routine with a name' directive does not compile
Summary: OpenACC 'routine with a name' directive does not compile
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 10.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: openacc
Depends on:
Blocks:
 
Reported: 2021-02-01 11:49 UTC by Kiril Dichev
Modified: 2021-02-01 14:37 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Module file to reproduce issue (351 bytes, text/plain)
2021-02-01 11:49 UTC, Kiril Dichev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kiril Dichev 2021-02-01 11:49:18 UTC
Created attachment 50106 [details]
Module file to reproduce issue

The OpenACC standard states that "The routine directive with a name may appear in the specification part of a subroutine, function or module, and applies to the named subroutine or function."

However, the following does not compile with Gfortran:

        function modifier(x) result(y)
            implicit none
            !$acc routine seq
            real(kind =8) :: x,y
            y = 2 * x
        end function modifier

        subroutine do_work
            implicit none
            !$acc routine(modifier) seq
            integer(kind = 4) :: i
            !$acc parallel loop collapse(3) independent private(i)
            do i = 1,q
            x(i,j,k) = 23.
            x(i,j,k) = modifier(x(i))
            end do
        end subroutine do_work

 gfortran -fopenacc -Wall -Wextra -c mymodule.f90
mymodule.f90:26:35:

   26 |             !$acc routine(modifier) seq
      |                                   1
Error: Invalid NAME ‘modifier’ in !$ACC ROUTINE ( NAME ) at (1)
Comment 1 Kiril Dichev 2021-02-01 11:58:36 UTC
See attached file for reference, snippet in description is not quite correct as I was trying to be brief
Comment 2 Tobias Burnus 2021-02-01 14:19:11 UTC
(Now: OpenACC spec issue #345)

I am not sure that a use as in attachment 50106 [details] is really intended, namely: placing the "acc routine" into a sibling procedure.

However, gfortran seems to reject too much – at least with the current wording.

The problem is that the diagnostic already happens at call time (gfc_match_oacc_routine) which requires that the symbol has been encountered before (during parsing) and the usage is such that it has to be in the current scope and cannot be in the parent scope.