[J3] Changing address of an allocatable on assignment when shapes match

Anton Shterenlikht ashterenli at cray.com
Tue Aug 27 03:15:59 EDT 2019



> On 23 Aug 2019, at 23:41, Bill Long via J3 <j3 at mailman.j3-fortran.org> wrote:
> None of the 4 implementations ...

I haven't encountered LOC() before.
Seems it's a popular extension to the standard,
implemented in at least 4 processors - maybe more?

1. For extensions like LOC - how does one know that LOC
is doing the same thing in all those 4 processors?

2. If LOC is so popular (and useful?) why not standardise it in F202X?

Anton


> 
> 
> 
>> 
>> Steve
>> 
>> program test
>> implicit none
>> real, dimension(:), allocatable :: S
>> integer :: i, idx(7) = [1,3,5,7,2,4,6]
>> 
>> allocate(S(size(idx)))
>> do i=1,size(S)
>>  S(i) = i*i
>> end do
>> 
>> write(6,*) S
>> write(6,*) loc(S)
>> 
>> S = S(idx)
>> 
>> write(6,*) S
>> write(6,*) loc(S)
>> 
>> S(:) = S(idx)
>> 
>> write(6,*) S
>> write(6,*) loc(S)
>> 
>> deallocate(S)
>> 
>> end program
>> 
>> $ sunf90 -V
>> f90: Studio 12.6 Fortran 95 8.8 Linux_i386 2017/05/30
>> 
>> $ sunf90 test.f90 ; ./a.out
>> 1.0 4.0 9.0 16.0 25.0 36.0 49.0
>> 37518752
>> 1.0 9.0 25.0 49.0 4.0 16.0 36.0
>> 37519840
>> 1.0 25.0 4.0 36.0 9.0 49.0 16.0
>> 37519840
>> 
> 
> Bill Long                                                                       longb at cray.com
> Principal Engineer, Fortran Technical Support &   voice:  651-605-9024
> Bioinformatics Software Development                      fax:  651-605-9143
> Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425
> 
> 



More information about the J3 mailing list