About portable programming in fortran

yuanliu1_at_gmail.com
Date: 03/29/05


Date: 28 Mar 2005 16:05:13 -0800

I have a fortran code, I want it to work both under single precision
and double precision mode. I made it partly work.
first I define the kind parameter,
integer, parameter :: myprec = selected_real_kind(*) //* can be 6 for
single precision and 15 for double precision.

then everything is declared in this way.
real (myprec) a, b, c

if I want my code to work under double precision, I just set * to 15,
and so on.

but still, this is not perfect. Since for double precision variables, I
have dabs, dsqrt, zsqrt, zexp, dexp. For single precision, I have abs,
sqrt, csqrt, exp...
how to make the intrinsic function portable?? I suppose one way is to
conditionally compile. Am I right?



Relevant Pages

  • Re: BLAS: dgemm
    ... to a procedure requiring double precision data, ... be 'single precision correct' instead of 'double precision correct'. ... Where is the compiler supposed to get ...
    (comp.lang.fortran)
  • Re: increasing width
    ... which I get every time I want to declare real. ... used to declare single or double precision variables. ... easily support more than one "kind" of single precision variable. ... have at least 13 digits of precision, ...
    (comp.lang.fortran)
  • Re: increasing width
    ... Some fellow over in sci.math.num-analysis tells me I can get at least 6 more sig figs, if instead of declaring as type real, I declare as real. ... used to declare single or double precision variables. ... easily support more than one "kind" of single precision variable. ... have at least 13 digits of precision, ...
    (comp.lang.fortran)
  • Re: Singles to Doubles
    ... of the original code difference between direct promotion as opposed to ... Double you would have gotten full precision to start with... ... You have successfully read the existing single precision data directly ...
    (microsoft.public.vb.general.discussion)
  • Re: Using a GPU for supercomputing?
    ... GPU, because the floating point is single-precision only, and HPC ... Exploiting Single Precision Math in HPC ...
    (comp.sys.ibm.pc.hardware.chips)