(j3.2006) Standard question regarding passing a scalar string to an array

Bill Long longb
Sun Feb 13 11:51:16 EST 2011

On 2/13/11 8:48 AM, Bill Long wrote:
> On 2/13/11 4:07 AM, Tobias Burnus wrote:
>> Hello all,
>> F2008, " 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 " 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.

Perhaps more explanation would help here.  The code is legal based on 
(1) [for the scalar x(1)] , but the size of the array a(*) in subroutine 
f is only 1.    x(2) in subroutine t does not necessarily correspond to 
a(2) in subroutine f since the array x fails to meet the requirements in 
(3) [i.e. x(1) does not represent the first element of a contiguous 

The real issue is that x, as a pointer, is not known to be contiguous, 
which is what is effectively required for sequence association to work 
here. Now that we have the concept of "contiguous" in the standard, the 
current "is not an assumed-shape, pointer, or polymorphic array" seems 
equivalent to "is simply contiguous and not polymorphic". Probably "is 
simply contiguous" would be sufficient, since that's the operational 


> 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