|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
brucebowler Guest
|
Posted: Mon Mar 13, 2006 2:40 pm Post subject: unclear on an interface |
|
|
I have the following source, with the main program in 1 file and the function in a separate file.
program test
implicit none
real a(100,9)
real b(100)
real x(9)
real t
integer i
interface
function func(t,i,b,a)
real,intent(in) :: t
integer,intent(in) :: i
real, intent(in),dimension ( :: b
real, intent(in),dimension(:,9) :: a
end function func
end interface
real :: func
i = 1
t = 1.0
x = func(t,i,b,a)
stop
end
function func (t,i,b,a)
implicit none
real, intent(in) :: t
integer, intent(in) :: i
real, intent(in), dimension( :: b
real, intent(in), dimension(:,9) :: a
real, dimension(9) :: func
do i = 1,9
func(i) = 1.0
enddo
return
end
two questions...
1) Is that the "proper" way to define an array valued function (if not, that might be the root of the other problem).
2) When I debug the program, in func, array a is (9,9), not (100,9) as I would have expected.
Thanks!
Bruce
|
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Mon Mar 13, 2006 6:18 pm Post subject: unclear on an interface |
|
|
To define an array as the result of a function, I think you should use the RESULT attribite in the finction definition.
I must admit my thinking does not go to an array being returned and I would use a subroutine form for coding the problem.
For the functionality of an array function, with an array being returned, the array dimension must be consistent with the x(9), so I wonder why you have chosen the "100" as the implied dimension in the function definition, rather than the "9".
I hope these comments assist ? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Tue Mar 14, 2006 1:00 am Post subject: unclear on an interface |
|
|
Bruce
You need to include
real, dimension(9) :: func
in your interface. |
|
Back to top |
|
|
brucebowler Guest
|
Posted: Tue Mar 14, 2006 6:12 am Post subject: unclear on an interface |
|
|
Paul,
Thanks once again for your excellent assistance. That was exactly what I needed
Bruce |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|