[J3] DIM arguments
Bill Long
longb at cray.com
Wed Mar 6 19:22:41 EST 2019
I agree that’s what the standard says. However, the challenge comes with this version:
subroutine boo(a,i)
logical,intent(in) :: a(10,10)
integer,optional :: i
print *, any(a,i)
end
I you call this with
CALL BOO (A, 1)
then the code is valid. If called with
CALL BOO(A)
it is invalid now that the DIM argument to ANY is no longer optional. So the intention is that the compiler always generates the two-argument version, and if the user (thinking the I argument to BOO is optional) calls BOO with only one argument, the program just gets a segfault at runtime? We can do that, but I thought this was the issue F08/0038 was trying to address.
Cheers,
Bill
> On Mar 6, 2019, at 6:04 PM, Malcolm Cohen via J3 <j3 at mailman.j3-fortran.org> wrote:
>
> In F2018, the DIM argument of ANY is not an optional dummy argument. There are two forms of ANY: one with no DIM argument, one with a non-OPTIONAL DIM argument.
>
> Thus this follows the usual rules. Viz, in 15.5.2.12 Argument presence and restrictions on arguments not present, it says “An optional dummy argument that is not present is subject to the following restrictions… It shall not be supplied as an actual argument corresponding to a nonoptional dummy argument…”
>
> Thus the code is valid, and the reference is to the second form of ANY, not the first. I repeat: the DIM argument of ANY is not OPTIONAL, it is just like a generic overload.
>
> Cheers,
> --
> ..............Malcolm Cohen, NAG Oxford/Tokyo.
>
> From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Bill Long via J3
> Sent: Thursday, March 7, 2019 8:21 AM
> To: General J3 interest list <j3 at mailman.j3-fortran.org>
> Cc: Bill Long <longb at cray.com>
> Subject: [J3] DIM arguments
>
> For this example:
>
> subroutine boo(a,i)
> logical,intent(in) :: a(10,10)
> integer,optional :: i
> if (present(i)) then
> print *, any(a,i)
> else
> print *, any(a)
> end if
> end
>
> F08 gave an error because there was a specific requirement in the (then) optional DIM argument:
>
> ""The corresponding actual argument shall not be an optional dummy argument.”
>
> In F2018 we changed the DIM argument to be not optional. But we also deleted the restriction sentence. Was that intentional? It seems that (according to the logic in interp F08/0038) that we did not want to allow optional arguments to correspond to the DIM argument of the ANY function. But the restrictions on the use of optional arguments alone (absent the specific prohibition for the DIM argument of ANY) appear to make the above code conforming. Or maybe the prohibition is stated elsewhere for these DIM arguments, and I’m not seeing it.
>
> Cheers,
> Bill
>
>
> Bill Long longb at cray.com
> Principal Engineer, Fortran Technical Support & voice: 651-605-9024
> Bioinformatics Software Development fax: 651-605-9143
> Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
>
>
> Disclaimer
> The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. Please see our Privacy Notice for information on how we process personal data and for details of how to stop or limit communications from us.
>
> This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.
Bill Long longb at cray.com
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
More information about the J3
mailing list