Skip to content
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

Kind parameters #17

Open
raullaasner opened this issue Jan 12, 2018 · 8 comments
Open

Kind parameters #17

raullaasner opened this issue Jan 12, 2018 · 8 comments

Comments

@raullaasner
Copy link
Collaborator

What would be the best way of specifying the kind parameter? Should we always use the selected_*_kind function,
integer, parameter :: dp = selected_real_kind(15, 307)
real(dp) :: x
or are there better alternatives? According to this blog post the ISO_FORTRAN_ENV constants for kinds do not always work as intended. Also, is it a good habit to always specify the kind parameter for integers?

@szaghi
Copy link
Member

szaghi commented Jan 12, 2018

Hi @raullaasner ,

I tend to agree with Dr. Fortran (S. Lionel). I generally use my own kind precision module. I use the intrinsic ISO_FORTRAN_ENV only for rapid tests when PENF is far...

My best regards.

@tclune
Copy link
Collaborator

tclune commented Jan 12, 2018 via email

@LadaF
Copy link
Collaborator

LadaF commented Jan 12, 2018 via email

@nncarlson
Copy link
Collaborator

FWIW, I'm with @tclune on this one, and my thinking has evolved along the same lines over the years.

@tclune
Copy link
Collaborator

tclune commented Jan 12, 2018 via email

@LadaF
Copy link
Collaborator

LadaF commented Jan 12, 2018 via email

@raullaasner
Copy link
Collaborator Author

(And I assume REAL128 == C_LONG_DOUBLE, but have never checked.)

These are the kind of corner cases I had in mind, actually. REAL128 has a different effect with GNU and Intel compilers, whereas using SELECTED_REAL_KIND should always be unambiguous. REAL64 should be safe for now and it refers to double precision in all major Fortran compilers, but interestingly nothing in the standard requires it to be double precision.

@tclune
Copy link
Collaborator

tclune commented Jan 12, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants