Dear All,
Can I ask a stupid queation? How can I define complex variables by such
kind of method below?
Many thanks,
Zhongfu
Richard Maine wrote:
>Blackwell, Bennie F writes:
> > I have seen (and used) the following two ways of setting machine precision.
> > What is recommended way and why?
> >
> > method A
> > INTEGER, PARAMETER :: REAL_8 = SELECTED_REAL_KIND(15,30)
> > REAL(KIND=REAL_8), PARAMETER :: PI = 3.141592653589793238462643383_REAL_8
> >
> > method B
> > INTEGER, PARAMETER :: SP = KIND(1.0) ! single precision
> > INTEGER, PARAMETER :: DP = KIND(1.0D0) ! double precision
> > REAL (DP), PARAMETER :: PI = 3.141592653589793238462643383_DP
>
>Others have commented on what these two approaches mean. I don't
>have much to add to that. I would like to add one very strong
>recommendation, though. Above all, I recommend using a named
>parameter, preferably in a module, to specify precision. Both of
>your samples above do follow this recommendation. As long as you
>have done that, it is a 1-line change to specify the parameter
>value differently if you need to for any reason.
>
>With that in mind, I typically use a more generic name for the
>parameter. Most of the code shouldn't care whether it is
>single precision, double precision, real*8, or whatever. So I
>don't embed those in my choice of names. I happen to use r_kind
>to indicate my normal working real kind. Some people use something
>like wp for working precision, but I find that just a little too
>short (and thus prone to name conflicts). Of course, the name is
>very much a side question.
>
>So my main message is that you are in good shape with either of the
>approaches you suggest, so long as you put the parameter definition in
>a module that is used by the whole application so that changing it is
>simple. (Ok, an include file would do, though I personally prefer a
>module).
>
>--
>Richard Maine | Good judgment comes from experience;
>[log in to unmask] | experience comes from bad judgment.
> | -- Mark Twain
>
>
>
|