(j3.2006) Standard question regarding passing a scalar string to an array
Bill Long
longb
Sun Feb 13 09:48:03 EST 2011
On 2/13/11 4:07 AM, Tobias Burnus wrote:
> Hello all,
>
> F2008, "12.5.2.4 Ordinary dummy variables":
>
> "If the actual argument is a noncoindexed scalar, the corresponding
> dummy argument shall be scalar unless the actual argument is default
> character, of type character with the C character kind (15.2.2), or is
> an element or substring of an element of an array that is not an
> assumed-shape, pointer, or polymorphic array."
>
This sentence is a companion to "12.5.2.11 Sequence association".
It provides 3 independent exceptions following the "unless":
1) actual argument is default character [which is allowed to correspond
to a character array]
2) actual argument is of type character with the C character kind
(15.2.2) [in almost all implementations redundant with (1)]
3) actual argument is an element or substring of an element of an array
that is not an assume-shape, pointer, or polymorphic array
Option (3) covers the legacy association of element sequences, as in
real x(100)
call sub (x(2))
...
subroutine sub(y)
real y(*)
>
> Is the following program valid or invalid? Namely, shall I read only
Looks valid to me.
Cheers,
Bill
> until "unless the actual argument is default character" - regarding the
> rest as belong to "or". Or does the "element of an array that is not
> a... pointer ... array" also apply? Would it be different if I had
> substring?
>
> subroutine t(x)
> character, pointer :: x(:)
> call f(x(1))
> contains
> subroutine f(a)
> character :: a(*)
> end subroutine f
> end subroutine
>
>
> I assume a character actual argument which is a (scalar) pointer is
> always valid - substring or not, isn't it?
>
> Tobias
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
--
Bill Long longb at cray.com
Fortran Technical Support & 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
mailing list