Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

optional arguments: bug or feature?

16 views
Skip to first unread message

Phillip Helbig---undress to reply

unread,
Apr 9, 2012, 9:23:58 AM4/9/12
to
I now have this:

IF <different input arguments than last call> THEN
CALL CALCULATE
ELSE
<issue warning>
ENDIF

!set output arguments, using newly calculated or SAVEd values

K_O = K ! output arguments have _O appended to the corresponding
! saved internal variable

However, I have to do this

IF (PRESENT(K_O)) THEN K_O = K

Is there a reason for this? Of course, in some cases one might not want
to calculated any value for the variable if it is not present, so
PRESENT is of course useful in such cases. However, I was hoping that I
could give K_O a value even if it isn't present in the argument list.
Of course, in that case the calling routine would know nothing about it,
but that is neither here nor there.

dpb

unread,
Apr 9, 2012, 10:43:30 AM4/9/12
to
It's that there's no actual argument associated w/ the dummy argument if
not present (so there may not be anything to assign to in lazy-speak).

It's Standard, not a bug; it's illegal to refer to a nonPRESENT dummy
argument.

--

Richard Maine

unread,
Apr 9, 2012, 11:03:13 AM4/9/12
to
Phillip Helbig---undress to reply <hel...@astro.multiCLOTHESvax.de>
wrote:

> However, I have to do this
>
> IF (PRESENT(K_O)) THEN K_O = K
>
> Is there a reason for this? Of course, in some cases one might not want
> to calculated any value for the variable if it is not present, so
> PRESENT is of course useful in such cases. However, I was hoping that I
> could give K_O a value even if it isn't present in the argument list.
> Of course, in that case the calling routine would know nothing about it,
> but that is neither here nor there.

I have long advocated for an option that allows you to specify that an
optional dummy with a non-present actual argument just acts like a local
variable. But I've had no sucess with pushing that. (Yes, there would
need to be additional complications in the specification of handling
things like assumed shape dummies).

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain

Phillip Helbig---undress to reply

unread,
Apr 9, 2012, 11:37:21 AM4/9/12
to
In article <1ki9y9j.u8dk7t1vpoou2N%nos...@see.signature>,
nos...@see.signature (Richard Maine) writes:

> > However, I have to do this
> >
> > IF (PRESENT(K_O)) THEN K_O = K

> I have long advocated for an option that allows you to specify that an
> optional dummy with a non-present actual argument just acts like a local
> variable. But I've had no sucess with pushing that. (Yes, there would
> need to be additional complications in the specification of handling
> things like assumed shape dummies).

Glad we agree. :-)

As I mentioned, in the current case the optional arguments are, at least
for this routine in the module, to allow the user to get just those he
needs, not to save calculation time if they are not present (since (a)
calculation is quick and (b) I need them internally in other routines
anyway). Thus, such a feature would come in handy.

0 new messages