Re: module problems



<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
.



Relevant Pages

  • Re: increasing width
    ... which I get every time I want to declare real. ... used to declare single or double precision variables. ... easily support more than one "kind" of single precision variable. ... have at least 13 digits of precision, ...
    (comp.lang.fortran)
  • Re: increasing width
    ... Some fellow over in sci.math.num-analysis tells me I can get at least 6 more sig figs, if instead of declaring as type real, I declare as real. ... used to declare single or double precision variables. ... easily support more than one "kind" of single precision variable. ... have at least 13 digits of precision, ...
    (comp.lang.fortran)
  • Re: WIN API example in C++
    ... A very short introduction to the Visual Basic Declare statement: ... - "Declare" introduces the respective external function to the VB project ... The only thing that you need to now about this to use OSRegOpenKey() in C++ ... - that the function RegOpenKeyA() is provided by the library ADVAPi32.DLL". ...
    (microsoft.public.vb.winapi)
  • Re: double confusion
    ... Modules that came in in Fortran 90, where you can just declare things "once at ... precision, but not for integer or real ... ... This reflects the implicit Typing of the languages - in C functions return ... Thus you must declare all double precision variables. ...
    (comp.lang.fortran)
  • lang effort: type conversions
    ... the lang will be dynamically typed with a prototype ... long, either a fixnum or an on-heap object, with undefined precision (for ... will declare a mutable one. ...
    (comp.lang.misc)