SCALE(3) - [MODEL_COMPONENTS] Scale a real value by a whole power of the radix
result = scale(x, i)
elemental real(kind=KIND) function scale(x, i)real(kind=KIND),intent(in) :: x integer(kind=**),intent(in) :: i
o X is type real of any kind o I is type an integer of any kind o the result is real of the same kind as X
SCALE(3) returns x * RADIX(X)**I.
It is almost certain the radix(base) of the platform is two, therefore SCALE(3) is generally the same as X*2**I
o X : the value to multiply by RADIX(X)**I. Its type and kind is used to determine the radix for values with its characteristics and determines the characteristics of the result, so care must be taken the returned value is within the range of the characteristics of X. o I : The power to raise the radix of the machine to
The return value is X * RADIX(X)**I, assuming that value can be represented by a value of the type and kind of X.
Sample program:
program demo_scale implicit none real :: x = 178.1387e-4 integer :: i = 5 print *, scale(x,i), x*radix(x)**i end program demo_scaleResults:
0.570043862 0.570043862
Fortran 95
DIGITS(3), EPSILON(3), EXPONENT(3), FRACTION(3), HUGE(3), MAXEXPONENT(3), MINEXPONENT(3), NEAREST(3), PRECISION(3), RADIX(3), RANGE(3), RRSPACING(3), SET_EXPONENT(3), SPACING(3), TINY(3)
fortran-lang intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | scale (3) | July 22, 2023 |