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 

How to pass a function (or subroutine) name as an argument?

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





PostPosted: Sun Jun 18, 2006 9:08 pm    Post subject: How to pass a function (or subroutine) name as an argument? Reply with quote

Greetings. A quick query on passing the name of
a function as an argument. My particular application
is a subroutine that finds the root(s) of whatever
mathematical function is given it:

subroutine solver (func,x)
etc...
end subroutine solver

where "func" refers to any function in the calling statement,
viz.

call solver (func1,x)
call solver (func2,x)

My FTN95 book discusses interfaces (= function prototypes),
but I am not sure eactly where I should put the interface
block and how to use it.

Is there a quick answer?

With many thanks,
Ludwig


Ludwig
Back to top
PaulLaidler
Site Admin


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

PostPosted: Mon Jun 19, 2006 1:13 am    Post subject: How to pass a function (or subroutine) name as an argument? Reply with quote

Ludwig

You only need to use an INTERACE (for external subprograms) when using Fortran 90 features such as optional and keyword arguments and when passing "assumed shape" arrays. Otherwise, all you need to do is to declare the return type of a function. Is it also a standard practise to declare external functions and subroutines as EXTERNAL.

Standard texts usually have examples that show you how to do this.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General 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