Re: module problems
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Sun, 14 May 2006 12:50:10 -0700
<pieterprovoost@xxxxxxxxx> wrote:
I'm trying to put a collection of subroutines and functions in a
module, but this results in a number of "undefined reference".
This is a fairly common problem. When you have a procedure in a module,
all the necessary information about the procedure is comminicated by the
USE statement for the module (or, in this case, other procedures in the
same module have the information by virtue of being in the same module).
You can *NOT* redeclare the information. In paticular, you can not
redeclare the type of functions from the module. Your code has such
redeclarations.
When you do something like
double precision function co2hta (h, ta, t, s)
...
double precision :: kbdoe,...
co2hta = (ta - ((kbdoe(t, s) *...
The double precision declaration for kbdoe here tells the compiler to
*NOT* use the module function kdboe, but instead to use an external
function of that name. There is no such external function; thus the
error.
For external functions, you need to declare the type like this. For
module functions, you cannot do that. You declare the type of a module
function in one place only - in the fuction itself - not in places that
invoke the function. This is one of the gotchas about moving external
procedures into modules; you have to also find and remove all the type
declarations for the procedures. (I do still recommend moving procedures
into modules in many cases; this is just an extra step that is needed
when doing so, though).
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: module problems
- From: pieterprovoost
- Re: module problems
- From: pieterprovoost
- Re: module problems
- References:
- module problems
- From: pieterprovoost
- module problems
- Prev by Date: module problems
- Next by Date: Re: module problems
- Previous by thread: module problems
- Next by thread: Re: module problems
- Index(es):
Relevant Pages
|