Thank you Stephan, it is working now. I forgot to add the correct files to the makefile, for I put the module in a seperate file (grid.F). The correct makefile rule for the main program (main.F) is: <br><br><span style="font-family: courier new,monospace;">main: grid.o main.o chkopts</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> -${FLINKER} -o main grid.o main.o ${PETSC_KSP_LIB}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ${RM} main.o grid.o</span><br style="font-family: courier new,monospace;">
<br>Thanks again. <br><br>Leo<br><br><br><div class="gmail_quote">2010/10/1 Stephan Kramer <span dir="ltr"><<a href="mailto:s.kramer@imperial.ac.uk">s.kramer@imperial.ac.uk</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On 30/09/10 23:09, Leo van Kampenhout wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Declaring it external in the program/subroutine that is using the module<br>
results in<br>
<br>
main.F:65.43:<br>
external gridtest<br>
Error: Cannot change attributes of USE-associated symbol at (1)<br>
<br>
Thanks, Leo<br>
</blockquote>
<br></div>
Yes, as I said before :) - module subroutines should *not* be declared external. You do<br>
not need that line.<br>
<br>
Cheers<br>
Stephan<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
<br>
<br>
2010/9/30 Stephan Kramer <<a href="mailto:s.kramer@imperial.ac.uk" target="_blank">s.kramer@imperial.ac.uk</a><br></div>
<mailto:<a href="mailto:s.kramer@imperial.ac.uk" target="_blank">s.kramer@imperial.ac.uk</a>>><div><div></div><div class="h5"><br>
<br>
On 30/09/10 15:31, Leo van Kampenhout wrote:<br>
<br>
Hi all,<br>
<br>
since it is mandatory to declare all subroutines as "external" in<br>
Fortran, is it possible for Modules to have subroutines? I'm<br>
unable to<br>
declare the subroutine external inside the module itself, nor in the<br>
program which is using it. Not declaring it external at all<br>
results in<br>
the following compilation error:<br>
<br>
/net/users/csg/csg4035/master/workdir/src/main.F:97: undefined<br>
reference<br>
to `__grid_MOD_readgrid'<br>
<br>
(the module is here is named "grid", the subroutine "readgrid" )<br>
<br>
Thanks,<br>
Leo<br>
<br>
<br>
If you put your subroutine in a module, it should not be declared<br>
external. You can directly call it from within the module itself. When<br>
calling it inside any other module/program you need to add "use<br>
grid" before<br>
the "implicit none".<br>
<br>
Putting subroutines inside a module is highly recommended as it<br>
automatically<br>
provides an explicit interface so that the compiler can check the<br>
arguments in<br>
your subroutine call.<br>
<br>
Cheers<br>
Stephan<br>
<br>
<br>
</div></div></blockquote>
<br>
</blockquote></div><br>