71), ensures that the double and quad types are actually twice and four times the precision of a single: integer, parameter :: & sp = kind ( 1.0 ), & dp = selected_real_kind ( 2 * precision ( 1.0_sp )), & qp = selected_real_kind ( 2 * precision ( 1.0_dp ))įinally, precision of 32-, 64-, and 128-bit reals can usually be obtained with the following constants: integer, parameter :: sp = selected_real_kind ( 6, 37 ) integer, parameter :: dp = selected_real_kind ( 15, 307 ) integer, parameter :: qp = selected_real_kind ( 33, 4931 ) One can also guarantee precision up to that of the machine-compiler-specific double precision real by using the kind function to get the kind of 1.d0: integer, parameter :: dp = kind ( 1.d0 )Īnother possibility, suggested by Metcalf, et. 20-22): integer, parameter :: dp = selected_real_kind ( 15, 307 ) real ( kind = dp ) :: a real ( dp ) :: b The following example declares two real variables a and b which are guaranteed to have at least 15 significant digits of precision and an exponent range of at least 307 (Lemmon and Schafer, 2005, p. double precision is also no longer needed and can be thought of as a kind of real. real*8 and counterparts should no longer be used (Chin, Worth, and Greenough, 2006, p. In Fortran 90 and later, intrinsic types such as real and integer have a kind attribute which guarantees a specific precision and/or range.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |