This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] assumed-rank some bound intrinsics support, fix failures and improve diagnostcs


On 26/07/2012 16:53, Mikael Morin wrote:
> On 21/07/2012 13:08, Tobias Burnus wrote:
>> Only failing are:
>>   lbound(x) / ubound(x) / shape(x)
>>
> Here is a draft for those.
> Lightly tested with print *, ...
> 
Better with the tests.


$ ./test1
           1           1
           3           8
           3           8

$ ./test2
          11         101
          13         108
           3           8


program test

  integer :: a(1:3,-2:5)

  call foo(a)

contains
  subroutine foo(arg)
    integer :: arg(..)

    print *, lbound(arg)
    print *, ubound(arg)
    print *, shape(arg)
  end subroutine foo
end program test


program test

  integer :: a(1:3,-2:5)
  integer, allocatable :: b(:,:)

  b = foo(a)
  print *,b(:,1)
  print *,b(:,2)
  print *,b(:,3)

contains
  function foo(arg) result(res)
    integer :: arg(..)
    integer, allocatable :: res(:,:)

    allocate(res(rank(arg), 3))
    
    res(:,1) = lbound(arg) + (/ 10, 100 /)
    res(:,2) = (/ 10, 100 /) + ubound(arg) 
    res(:,3) = shape(arg)
    
  end function foo
end program test


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]