(j3.2006) C-Interop question about establishing the bounds
Fri Feb 6 15:44:40 EST 2015
On Feb 6, 2015, at 2:36 PM, Daniel C Chen <cdchen at ca.ibm.com> wrote:
> Please consider the following code:
> Program main
> 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
> 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?
> I found the following statement [99:5-9, 220.127.116.11p2].
> "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.
> How does it apply to the BLOCK statement?
> XL Fortran Development - IBM Toronto Software Lab
> Phone: 905-413-3056
> Tie: 969-3056
> Email: cdchen at ca.ibm.com
> J3 mailing list
> J3 at mailman.j3-fortran.org
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
More information about the J3