From: dpb on
monir wrote:
> On Aug 2, 12:07 pm, Steven Correll <steven.corr...(a)gmail.com> wrote:
>> On Aug 1, 7:48 pm, monir <mon...(a)rogers.com> wrote:
>>> On Jul 31, 3:58 pm, Steven Correll <steven.corr...(a)gmail.com> wrote:
>
> Hi Steven;
>
> 1) In your example, putting:" ... an "e" in front of every "mysub*"
> identifier related to an external
> procedure and an "m" in front of every "mysub*" identifier related to
> a module procedure..."
> makes the example much clearer, and it works fine.
>
> 2) Your advice: " ... when writing new code, the easiest approach is
> to use
> module procedures always and external procedures never."
> is well taken. In other words, leave the external procedure to the
> experts.
>
> 3) Here's the Module procedure only, which works fine:
>
> MODULE mymodule
> implicit none
> Interface mmysub
> module procedure mysubi, mysubr
> End Interface mmysub
> Contains
> Subroutine mysubi(arg)
> integer :: arg(:)
> print *, 'I am a module procedure', size(arg)
> End Subroutine mysubi
> Subroutine mysubr(arg)
> real :: arg(:)
> print *, 'I am a module procedure too', size(arg)
> End Subroutine mysubr
> END module mymodule
>
> Program myprog
> implicit none
> integer :: myint(7)
> real :: myreal(8)
> call call_module_procedures()
> Contains
> Subroutine call_module_procedures()
> USE mymodule
> call mmysub(myint)
> call mmysub(myreal)
> End Subroutine call_module_procedures
> END Program myprog
>
> 3) I hope you don't mind a couple of basic questions:
> ....a) Why did you "USE mymodule" in the "Contains" section of the
> main program instead of simply "USE mymodule" at the top of main ??

Cuz that's where the need is for the contents of mymodule; namely the
interface information for the routines.

> ....b) What happens if subroutine mysubr(arg) is Function myfunr(arg)
> with myfunr and arg in DP ??

I'd suggest try it and see. The quick answer is "boom!" and one would
hope you would understand why.

> Keep in mind that dealing with External functions in F90 has been the
> root cause of (my) confusion!

Again, you don't have any external functions in sight as Richard M has
pointed out multiple times.

> 4) Once I know the answer (and understand it!), I'll try to use your
> example as a template and modify my OP sample code accordingly.
>
> Thanks again for your tremendous help and patience.
> Monir

--