(j3.2006) C-Interop question about establishing the bounds

Daniel C Chen cdchen
Sat Feb 7 12:22:52 EST 2015


Thanks Bill.

I should have researched some more. It is clear now.

Daniel

XL Fortran Development - IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran



From:	Bill Long <longb at cray.com>
To:	fortran standards email list for J3 <j3 at mailman.j3-fortran.org>
Date:	02/06/2015 15:45
Subject:	Re: (j3.2006) C-Interop question about establishing the bounds
Sent by:	j3-bounces at mailman.j3-fortran.org




On Feb 6, 2015, at 2:36 PM, Daniel C Chen <cdchen at ca.ibm.com> wrote:

> Hello,
>
> Please consider the following code:
>
>       Program main
>         interface
>           subroutine sub(c_arg) bind(c)
>             integer n                   !! Local auto var
>             character(*) :: c_arg(n,5)
>           end subroutine
>         end interface
>         character(3) :: ccc(10)
>         call sub(ccc)
>       end program
>
> Question:
> 1. Is the program standard conforming?
> 2. If it is legal, what would be the rank of the effective argument that
is passed to sub?
> 3. If it is legal, what would be the ubound of the effecive argument?
>
> Discussion:
> I found the following statement [99:5-9, 5.3.8.2p2].
>
> "An explicit-shape array that is a named local variable of
> a subprogram or BLOCK construct may have bounds that are not
> constant expressions. The bounds, and hence shape, are
> determined on entry to a procedure defined by the subprogram,
> or on execution of the BLOCK statement, by evaluating
> the bounds? expressions."
>
> Does it mean in order to determine the bounds of c_arg on entry to sub,
> 'n' must be a dummy argument itself since 'n' may not be defined at the
> Entry to sub if it is automatic variable?

A variable used as part of a dimension in this case has to be a dummy
argument, accessible from a module, or part of a visible COMMON block.  The
value has to be known on entry to the routine.   See the full set of
restrictions (including those for BLOCK) in 7.1.11 Specification
expressions.

Cheers,
Bill




>
> How does it apply to the BLOCK statement?
>
> Thanks,
>
> Daniel
>
> XL Fortran Development - IBM Toronto Software Lab
> Phone: 905-413-3056
> Tie: 969-3056
> Email: cdchen at ca.ibm.com
> http://www.ibm.com/software/awdtools/fortran/xlfortran
>
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long
longb at cray.com
Fortran Technical Suport  &                                  voice:
651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101


_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20150207/dc67ec5c/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.j3-fortran.org/pipermail/j3/attachments/20150207/dc67ec5c/attachment.gif 



More information about the J3 mailing list