Re: Strange behavior using a module which uses another module



In article
<ba7b849c-3c46-4bc8-98e4-9f48fed9c4ba@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
deltaquattro <deltaquattro@xxxxxxxxx> wrote:

1) I was surprised that main was able to access gamma, lgamma and
factorial, defined in md_Global_funcs, since main only uses md_Jacobi
and not md_Global_funcs. However, I looked at MRC and found that since
md_Jacobi uses md_Global_funcs, then main has access to it also. Is it
possible to let a program unit A use a module B, without having access
to any module used by B unless explicitly used by A?

Yes, access to module and local variables in a module are controlled
with PUBLIC, PRIVATE, and ONLY. If necessary, you can also define
local aliases in order to avoid conflicts with two or more functions
that have the same name.

2) compiling with EFC, I get the following error:
[...]
due to the "write" instruction in lgamma. Why is the compiler
complaining about a recursive I/O? How can I use print/write
statements to debug my libraries without incurring in this error?

Don't do recursive I/O. For example

y = lgamma(real(i))
write(*,*) ..., y

After you debug the function and remove the I/O within it, it is
then alright to access the function within an I/O statement as you
did in your original code. Or, unless you really want a function
interface, change your function into a subroutine and then you never
have to worry about this again.

$.02 -Ron Shepard
.