Re: Acceptable Pack args
- From: "David Frank" <dave_frank@xxxxxxxxxxx>
- Date: Wed, 24 Aug 2005 14:03:40 GMT
"Rich Townsend" <rhdt@xxxxxxxxxxxxxxxxxxx> wrote in message
news:dehtsr$6kg$1@xxxxxxxxxxxxxxxxxxxxxxx
> David Frank wrote:
>> Because the discussion how PACK operates in Reduce_Blanks shows no sign
>> of ending due to the continued blather of 2 posters there, I submit
>> following proof that its NOT the mask arg array sizes that drives the
>> PACK,
>> its the array being packed.
>>
>> My assertion is:
>> as long as "b,c" arrays are at least the size of "a" there wont be a
>> bounds fault in CVF,
>> does this assertion hold for your compiler?
>>
>> ! ------------
>> program test
>> character :: a(5)
>> character,allocatable :: b(:), c(:)
>>
>> allocate (b(20), c(1000) )
>> a = 'a' ; b = ' ' ; b = ' '
>>
>> write (*,*) pack(a, b==' '.or.c==' ') ! outputs aaaaa
>> end program
>
> c is not defined anywhere in the program, and the code is therefore
> non-standard. Assuming that you meant to write
>
> a = 'a' ; b = ' ' ; c = ' '
>
> ...then the code is *STILL* non-standard. As already pointed out in the
> error message pointed out by Joost, the problem is that the b and c arrays
> are not conformable. The .OR. operator requires that its operators be
> conformable -- either a scalar an array, or two arrays of exactly the same
> shape.
>
> PACK has nothing to do with this problem. The problem persists if the
> PACK() call is removed completely, so that the write statement reads:
>
> write (*,*) b==' '.or.c==' '
>
I agree you have a problem with code above, but thats not related to PACK.
> It appears that your confusion with pack stems from your lack of
> understanding of the PACK() intrinsic. The logical expression used for the
> MASK argument is evaluated in its entirety *before* it is passed to PACK.
> It is not evaluated on a per-element basis within PACK.
>
As best as I can determine from looking at the assy code, it is evaluated on
a per-element basis within PACK,
e.g. PACK( a, mask)
What I think I see is:
char a(i) is fetched and the corresponding mask is evaluated (trivial in
this case its just mask(i) ) and chr is either packed or discarded
depending on the mask evaluation and the loop continues..
and similiarly for PACK (a, b==' ')
Does my code run on your computer?
.
- Follow-Ups:
- Re: Acceptable Pack args
- From: Rich Townsend
- Re: Acceptable Pack args
- References:
- Acceptable Pack args
- From: David Frank
- Re: Acceptable Pack args
- From: Rich Townsend
- Acceptable Pack args
- Prev by Date: Re: Acceptable Pack args
- Next by Date: Re: forrtl warning (402)
- Previous by thread: Re: Acceptable Pack args
- Next by thread: Re: Acceptable Pack args
- Index(es):
Relevant Pages
|
|