Re: Nested dummy procedures



Stanislaus wrote:
| Hello,
|
| Does any body know how make code below more smart? Do not look whta
| functions do -- it's example.
<snip code>
| It seems that when I declare dummy function as real(8) Func(K) compiler
| thinks that it can be only array, but not a function which returns
| array of length K! But real(8) Func -- can be function wich returns
| scalar. So I had to use interfaces => module or triple declaration of K
| and L. May be there is a way of writing more smart code in this case.
| I'll be glad any help.

Sorry, I don't follow you 100%, so I apologize in advance if I'm
answering the wrong question...

I don't see anything particularly bad with the code you posted
(apart from the fact that M and X are never initialized, and wrong
rank of M is copied into X, but that's probably due to simplification).

I'm not a fan of functions returning arrays, because I foresee
potential efficiency problems -- compilers tend to generate
lots of temporary array copies in this way; I'd prefer subroutines
instead (but that could lead to even longer code). Also, you might
use assumed-shape (:) instead of explicit-size arrays (K).

However, in both cases, you CAN'T avoid explicit interface
blocks for dummy procedures. Both functions returning arrays and
subroutines with assumed-shape arguments require explicit interface,
and interface block is the only way to achieve it if the procedure
is a dummy argument.

You can make the code more elegant and slightly less error-prone
if you move the interface body to an include file and INCLUDE it
in necessary places, but that's more or less it.

--
Jugoslav
___________
www.xeffort.com

Please reply to the newsgroup.
You can find my real e-mail on my home page above.
.



Relevant Pages

  • Re: Storage & Passing of "Typed" data
    ... >> requires an explicit interface, but you could have an explicit ... > Assumed shape requires a discontiguous dummy in cases where you ... > in that for this kind of array one can pass a single element on down ... could also be determined by using the (nonstandard, but common) ...
    (comp.lang.fortran)
  • Re: Operations on derived type arrays
    ... Yeah, I was thinking about how I would have to declare the dummy argument, and it didn't occur to me that assumed shape should fit the bill. ... the first version of the test program didn't properly have an explicit interface for the called subroutine. ... Strangely, the compiler generated a warning - "an explicit-shaped array is being passed to a routine that expects a pointer or assumed-shape array" - because all source was in one file, but on execution a warning was generated that an array temporary was being created, whereupon there was the expected access violation. ...
    (comp.lang.fortran)
  • Re: calling a subroutine with optional arguments
    ... I have a question about calling a subroutine with optional arguments. ... present when invoking a procedure with an explicit interface. ... the dummy argument, that's simply not true. ...
    (comp.lang.fortran)
  • Re: Storage & Passing of "Typed" data
    ... > requires an explicit interface, but you could have an explicit ... Assumed shape requires a discontiguous dummy in cases where you ... in that for this kind of array one can pass a single element on down ...
    (comp.lang.fortran)
  • Re: allocating arrays in external subprograms and fileIO
    ... >> array, optional arguments etc.), you have to have explicit interface, ... function (not a subroutine) ...
    (comp.lang.fortran)