-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable kind #17
Variable kind #17
Conversation
… the defintion of 'rk' in 'src/rk.f'
I should mention that so far the only testing I have done is running I'll do some numerical tests tomorrow on a few examples. Are there any more specific tests that @zoziha or @certik would like? |
I think what you done is the best way ( module fftpack_kind
use iso_fortran_env, only: sp => real32, dp => real64, qp => real128
#if defined(sp)
integer, parameter :: rk = sp
#elif defined(qp)
integer, parameter :: rk = qp
#else
integer, parameter :: rk = dp
#endif
end module fftpack_kind
Yes, because of the error reported by I tried to implement multi-dimensional fft early on, such as fft2(see add_fft2), so fftpack changed (*) and (1) to (:) is appropriate and reasonable.
Regarding numerical testing, I don't have any ideas. I don't actually have enough numerical experience. |
Note that lines like this: DATA TSQRT2 /2.82842712474619009760D0/ are not going to be correct for quad precision. They need to be replaced with something like this: real(rk),parameter :: tsqrt2 = 2.0_rk * sqrt(2.0_rk) But... I would recommend converting all these |
Also the calls to |
Good points. I fixed the FLOAT calls, but maybe we need to close this PR and think this through more carefully. Your point about the DATA statements and quad precision is well taken, and there are still lots of double precision literals scattered throughout the code (e.g. 2.0D0). There are also calls to "DCMPLX" which I don't even think is standard Fortran. |
how about this: #18 |
Closing in favor of #18. |
This PR allows the user to change the real/complex kind at compile time by changing the definition of
RK
in rk.fMy original plan (the plan I discussed with @certik) was to change
IMPLICIT DOUBLE PRECISION
toIMPLICIT REAL(RK)
and to include a file directly about that line, which definedINTEGER, PARAMETER :: RK = KIND(1.0d0)
, but this didn't work because in that solution I ended up with a variable declaration before anIMPLICIT
statement, which is illegal. So instead, I opted to create a module calledfftpack_kind
, which definesRK
, andUSE
that module in each of the old F77 subroutines. Basically the same solution, but I use a module rather than including a loose file. I hope that's okay.Most of these changes were done via
perl -pi -e
, rather than doing them manually.