At 10:59 04-05-2000 +0200, you wrote:
>Dear fortran experts,
>
>the SIZE (array, [dim]) function should give the number of elements for
>array. According to the LF95 manual, if array is assumed size, dim must be
>present and "less than the rank of array".
>
>The following code does give a FATAL--DIM argument is out of range error:
> FUNCTION test(x)
> IMPLICIT NONE
> REAL, INTENT(IN) :: x(*) ! size of x is assumed
In this case an explicit interface is needed.
And I think that You must use assumed shape .
> REAL :: test
> INTEGER :: d
> d = SIZE(x,1)
> PRINT*,'d=',d
> END FUNCTION test
>
>How can the dim=1 argument be out of range?
>
>Any help is appreciated. Best regards, Peter de Haan
I append the programme as it works correctly.
Hope this helps.
program tt
real z(5)
interface
sUbrouTINe test(x)
REAL, INTENT(IN) :: x(:) ! size of x is assumed
end subroutine
end interface
call test(z)
end program tt
sUbrouTINe test(x)
IMPLICIT NONE
REAL, INTENT(IN) :: x(:) ! shape of x is assumed
! REAL :: test
INTEGER :: d
d = SIZE(x,1)
PRINT*,'d=',d
END subroutine test
---
Meilleures Salutations,
Best Greetings,
/---
Jan van Oosterwijk
Computing Centre
Delft University of Technology
Postbus 354
2600 AJ Delft
Netherlands / Pays-Bas
Phone: +31 15 278 50 17
Fax: +31 15 278 37 87
|