- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody,
I have a generic function ite which stands for "if ... then ... else". It is similar to C++ conditionals like "(Stat) ? a : b".
I would like to set the content of a variable dependant on the existance of an optional parameter. The code snippet looks like this:
a_iRngMin = ite(present(a_iIntMin), a_iIntMin, 0)
Where a_iIntMin is an optional integer variable in a subroutine. My question is now: Is it safe to pass a non existing optional parameter to a function if I can guarantee not to use it within that function?
I'd like to know how the intel compiler handles such stuff.
I have a generic function ite which stands for "if ... then ... else". It is similar to C++ conditionals like "(Stat) ? a : b".
I would like to set the content of a variable dependant on the existance of an optional parameter. The code snippet looks like this:
a_iRngMin = ite(present(a_iIntMin), a_iIntMin, 0)
Where a_iIntMin is an optional integer variable in a subroutine. My question is now: Is it safe to pass a non existing optional parameter to a function if I can guarantee not to use it within that function?
I'd like to know how the intel compiler handles such stuff.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it is supposed to be safe to do that. There needs to be an explicit interface for the routine you are calling that indicates the argument is OPTIONAL. The compiler is supposed to do its own "PRESENT" test and pass an "omitted" argument through. We have had bugs in this area, though primarily when calling intrinsics, so I can't guarantee it will work. It should, though.
In your example, you don't even need the present() in the call, as the ite function can do its own test. Amazing stuff, eh?
In your example, you don't even need the present() in the call, as the ite function can do its own test. Amazing stuff, eh?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I should be able to write a function like:
set_if_present(a_iParam, iVal)
This is something I originally wanted to do but did'nt expect to be possible. I will try it, would be nice if it works.
Ingo
set_if_present(a_iParam, iVal)
This is something I originally wanted to do but did'nt expect to be possible. I will try it, would be nice if it works.
Ingo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you should be able to do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Message for Ingo Berg from
Trevor Henn. Contact him at:
Message Information from:
___________________________
----------------------------------------------------
Forum: Namibia Travel
Thread Number: 89
Reply Number: 5 (0 = original message)
Thread Subject: Looking for Ingo Berg
Posted by Trevor Henn
Posted on 19:45:40, 01/15/2005
----------------------------------------------------
Posted Message:
----------------------------------------------------
HiI hope someone can assist me.
I am looking for my long lost surfer buddy Ingo Berg.We worked together in RSA on the Port Wdward coast.He then left for Swakopmund to start a bussiness.I am visiting Swakop later on this year and would love to meet up with him again.If anyone has info please send me a mail.
Thank you
Trevor Henn.
Forum: Namibia Travel
Thread Number: 89
Reply Number: 5 (0 = original message)
Thread Subject: Looking for Ingo Berg
Posted by Trevor Henn
Posted on 19:45:40, 01/15/2005
----------------------------------------------------
Posted Message:
----------------------------------------------------
HiI hope someone can assist me.
I am looking for my long lost surfer buddy Ingo Berg.We worked together in RSA on the Port Wdward coast.He then left for Swakopmund to start a bussiness.I am visiting Swakop later on this year and would love to meet up with him again.If anyone has info please send me a mail.
Thank you
Trevor Henn.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page