Defining a variable that must be declared constant, but changes in a loop

前端 未结 3 2015
灰色年华
灰色年华 2021-01-21 22:36

I\'m testing out ranges of values (-1:34 just for kicks) for the function selected_real_kind to determine the kind parameter it returns and the actual

3条回答
  •  时光说笑
    2021-01-21 23:03

    Fortran provides a number of intrinsic functions for enquiring into the characteristics of the numbers it processes. Consult your documentation for functions such as digits, precision and radix. All of these (including the ones I haven't mentioned but which your documentation will list) are generic (enough) to work on inputs of all the numeric kinds supported by your compiler.

    You'll make headway faster using these functions than trying to roll your own. As you are discovering it's not a simple matter to write your own generic routines as Fortran wants kind selectors known (or knowable) at compile time. You'll also extend your knowledge of Fortran.

    You may also find functions of interest in the intrinsic module IEEE_ARITHMETIC.

提交回复
热议问题