Re: better way to name optional argument



Mike wrote:

Hi

I'd like to ask how you name the variable of optional argument?
For an existent subroutine, I'd like to add an optional argument to do
some test:
1a/ integer :: iTEST
if(present(iTEST))then
print *,iTEST,'do some test!'
else
print *,iTEST,'no need to do some test!'
end if
1b/ or
if(iTEST==1)then
print *,iTEST,'do some test!'
else
print *,iTEST,'no need to do some test!'
end if

2a/ logical :: lTEST
if(present(lTEST))then
print *,lTEST,'do some test!'
else
print *,lTEST,'no need to do some test!'
end if
2b/ or
if((lTEST))then
print *,lTEST,'do some test!'
else
print *,lTEST,'no need to do some test!'
end if

I don't know which one is a meaningful one.

It goes much complicated when there are also optional arguments to be
set when optional argument TEST is a must. I'd like to set two
parameters: ipar1,ipar2.
I am also confused how is the best way to set the if ... else ....end
if.

Any suggested example would be very much appreciated.

Mike
Sometimes, the use of optional arguments isn't the best design. A more positive approach might be (depending on what you're really trying to do) to include a "processing type" (or "function code") argument. Optional arguments are more often useful for items which have a default value that works in most cases, but you might want to change it on rare occasion, like an API call to initiate an MDI window that defaults to cover its entire child area but you might optionally want it to be minimized.

--

Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows it can't be done.

-- Henry Ford
.



Relevant Pages

  • charity beneath chief deputy
    ... She may whereby come prior to Mike when the ancient drums position ... in support of the proud compound. ...
    (rec.music.classical.recordings)
  • Re: And yet more shiao jiao clips
    ... evidence that said credentials either don't exist or are forged. ... Mike looks disinclined to do so. ... Mike want an "explanation" of aiki in Judo. ... Mike is using to support his position. ...
    (rec.martial-arts)
  • Re: The linf project
    ... language and to be honest with you, ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: OT but damn they love to bomb
    ... Mike Corbett wrote: ... >disagreed that we don't have a clear exit strategy. ... >>>one provide the kind of support, in action word and thought to the ... >>the president's actions and demanding that the troops be brought home, ...
    (rec.arts.dance)
  • Re: Terminal Server and %WINDIR%
    ... "Mike U." wrote in message ... > Hello Jason and Herb, ... >> variable to the user Windows folder. ... >> Microsoft Online Partner Support ...
    (microsoft.public.windows.server.migration)