Re: Nested dummy procedures
- From: "Jugoslav Dujic" <jdujic@xxxxxxxxx>
- Date: Mon, 30 Jan 2006 09:06:52 +0100
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.
.
- References:
- Nested dummy procedures
- From: Stanislaus
- Nested dummy procedures
- Prev by Date: Re: MATMUL slower than expected
- Next by Date: Re: save attribute for module variables
- Previous by thread: Nested dummy procedures
- Next by thread: warning #266: function declared implicitly
- Index(es):
Relevant Pages
|
|