forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

unclear on an interface

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
brucebowler
Guest





PostPosted: Mon Mar 13, 2006 2:40 pm    Post subject: unclear on an interface Reply with quote

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 (Smile :: 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(Smile :: 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

PostPosted: Mon Mar 13, 2006 6:18 pm    Post subject: unclear on an interface Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Tue Mar 14, 2006 1:00 am    Post subject: unclear on an interface Reply with quote

Bruce

You need to include

real, dimension(9) :: func

in your interface.
Back to top
View user's profile Send private message AIM Address
brucebowler
Guest





PostPosted: Tue Mar 14, 2006 6:12 am    Post subject: unclear on an interface Reply with quote

Paul,

Thanks once again for your excellent assistance. That was exactly what I needed Smile

Bruce
Back to top
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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