Jing Guo writes:
> Richard Maine wrote:
> >
> > Mark Borges writes:
> >
> > > In SUNWspro-f77, there is a command line switch, `-r8',...
> >
> > > SUNWspor-f90-1.2 would help, but it does not have an `-r8' switch. Is
> > > there any simple way to globally change the typemap of all variables
> > > and arrays within f90, outside the compiler, equivalent to what `-r8'
> > > does for f77?
> >
> > For new f90 code, I'd recommend using the selected_real_kind
> > intrinsic. I do. This is the kind of thing it is for. It allows
> > your code to be 100% standard-conforming and still be able to move
> > between, for example, 32-bit and 64-bit environments with no source
> > code change and without depending on vendor-dependent extensions like
> > the -r8 switch.
>
> If I understand it correctly, switching between 32/64 bit environments
> is different from switching between 32/64 bits under the same
> environment. The latter is what `-r8' is for. So selected_real_kind()
> might not do the trick by itself.
In my experience, -r8 is for making code written for a 64-bit
environment work on a machine that normally uses a 32-bit environment.
That's what I used to use it for (before I switched to f90). We had a
bunch of CDC code (actually 60-bit environment, but anyway well more
than 32). The equivalent of -r8 made it easier to get much of this
code working on 32-bit machines. And that sounds roughly like what
Mark was looking for.
In any case, selected_real_kind will *ALWAYS* give you at least the
requested precision, regardless of what f90 environment it is used on.
(well, assuming the requested precision is available).
Now if you change your mind about what precision you need, that's a
different matter. Selected-real_kind is conveniently compatable with
putting your precision requirements in a single module and having them
automatically propogate to the whole code, so even if you do change
your mind on the precision requirements, things are somewhat easier
than before. Of course there are extra issues of interacting with
libraries outside of your own code.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|