On Thu, 2 Dec 1999, Andrew Reynolds wrote:
> The code I have been developing was originally written in F77, hence all
> the nasty real*8 and complex*16. At present the code works, even with
[snip]
> I realise that I should convert the code to the more acceptable real ::
> complex :: declarations, but what should I set the kind= to if I want
> double precision ?
I sympathise with your problems, and hope that others in this list with
more expertise than me will respond, as you pose a general question that
deserves a good answer. Some may say that your old code was never genuine
Fortran, because REAL*8 and the like are outside all Standards. But in
practice, as we all know, a huge amount of code has been written that way,
and F90/F95 provide no simple upgrade path.
For new code which you want to be _portable_ the best approach seems to be
to have a tiny module which defines a couple of kind parameters, say "sp"
and "dp" with suitable values. Then each declaration either uses
REAL(sp) :: list_of_reals
REAL(dp) :: list_of_doubles
In principle you could use a text editor to convert REAL*8 to REAL(dp) and
REAL*4 to REAL(sp). But doing this in old-style code risks missing some
vital declarations, e.g. of function names. And you have to insert a
whole lot of USE statements. And all your double precision constants need
to be specified with D exponent or _dp as suffix. Does anyone know of
programs to do all the required conversions automatically?
In practice, if time is short, and you are only using one platform, you
may be better off doing the minimum modifications that get your code
running.
--
Clive Page,
Dept of Physics & Astronomy,
University of Leicester.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|