Re: Acceptable Pack args




"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?






.



Relevant Pages

  • Re: Acceptable Pack args
    ... its the array being packed. ... PACK has nothing to do with this problem. ... The logical expression used for the MASK argument is evaluated in its entirety *before* it is passed to PACK. ... char ais fetched and the corresponding mask is evaluated ) and chr is either packed or discarded depending on the mask evaluation and the loop continues.. ...
    (comp.lang.fortran)
  • Re: packing floats?
    ... > array is unique. ... I'm trying to take the values and pack ... > into a hash then I can easily tell if I have a unique entity. ... in maintaining the actual float representation" implies a lossy ...
    (comp.lang.perl.misc)
  • Re: [PATCH 03/10] AXFS: axfs.h
    ... Is the reasonn for the bytetable just to pack numbers efficiently, ... Take an array of u64 like this: ... rootfs I can fit many of the data structures in an u8 array, ...
    (Linux-Kernel)
  • Re: Selecting the optimimum combination
    ... The idea is to fill this array completely, element by element in turn, ... That gives the cost, and a pack size to order. ... so we want element J to deal with the best purchase of ...
    (alt.comp.lang.borland-delphi)
  • Re: pack an array
    ... of this script to pack the array @array. ... Use the 'grep' function: ...
    (perl.beginners)