|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Anonymous Guest
|
Posted: Sun Jun 18, 2006 9:08 pm Post subject: How to pass a function (or subroutine) name as an argument? |
|
|
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: 8036 Location: Salford, UK
|
Posted: Mon Jun 19, 2006 1:13 am Post subject: How to pass a function (or subroutine) name as an argument? |
|
|
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 |
|
|
|
|
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
|