[patch, fortran] Implement FINDLOC
Thomas Koenig
tkoenig@netcologne.de
Tue Oct 23 21:02:00 GMT 2018
Am 23.10.18 um 18:16 schrieb Dominique d'Humières:
>
>> Anyway, the attached patch fixes this,
>
> It now gives the error
>
> 4 | integer, parameter :: I_FINDLOC_BACK(1) = findloc([1,1],1, &
> | 1
> Error: transformational intrinsic 'findloc' at (1) is not permitted in an initialization expression
That error message was misleading, the new one now has
Error: Parameter 'x' at (1) has not been declared or is a variable,
which does not reduce to a constant expression
> The following test
>
> program logtest3
> implicit none
> ! ********************************************************!
> ! ******* Everything depends on this parameter ***********!
>
> integer, parameter :: A1 = 2
> logical :: L
> L = transfer(A1,L)
> call sub(L)
> end program logtest3
>
> subroutine sub(x)
> implicit none
> logical x
> integer a(1)
> character(*), parameter :: strings(2) = ['.TRUE. ','.FALSE.']
>
> a = findloc([1,1],1,mask=[x,.TRUE.])
> write(*,'(a)') 'Value by FINDLOC(MASK): '// &
> trim(strings(a(1)))
> a = findloc([1,1],1,back=x)
> write(*,'(a)') 'Value by FINDLOC(BACK): '// &
> trim(strings(3-a(1)))
>
> end subroutine sub
>
> does not link:
>
> 8 | L = transfer(A1,L)
> | 1
> Warning: Assigning value other than 0 or 1 to LOGICAL has undefined result at (1)
> Undefined symbols for architecture x86_64:
> "__gfortran_findloc0_i4", referenced from:
> _sub_ in ccnoLKfH.o
> "__gfortran_mfindloc0_i4", referenced from:
> _sub_ in ccnoLKfH.o
> ld: symbol(s) not found for architecture x86_64
> collect2: error: ld returned 1 exit status
Ah, I didn't include the newly generated files in the previous patch.
Now included.
> Finally the line before the end of findloc_6.f90 should be
>
> if (findloc(ch,"CC ",dim=1,mask=false) /= 0) stop 23
Changed, also the whitespace fixes that Bernhard mentioned.
So, I think this should be clear for trunk now. I will supply
the documentation later.
Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: findloc_1.f90
Type: text/x-fortran
Size: 615 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20181023/a0626e8c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: findloc_2.f90
Type: text/x-fortran
Size: 1059 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20181023/a0626e8c/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: findloc_3.f90
Type: text/x-fortran
Size: 2731 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20181023/a0626e8c/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: findloc_4.f90
Type: text/x-fortran
Size: 912 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20181023/a0626e8c/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: findloc_5.f90
Type: text/x-fortran
Size: 2188 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20181023/a0626e8c/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: findloc_6.f90
Type: text/x-fortran
Size: 1791 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20181023/a0626e8c/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: findloc_7.f90
Type: text/x-fortran
Size: 335 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20181023/a0626e8c/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p15b.diff.gz
Type: application/gzip
Size: 31672 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20181023/a0626e8c/attachment.gz>
More information about the Fortran
mailing list