MASKL(3) - [BIT:SET] Generates a left justified mask
result = maskl( i [,kind] )
elemental integer(kind=KIND) function maskl(i,KIND)integer(kind=**),intent(in) :: i integer(kind=**),intent(in),optional :: KIND
o a kind designated as ** may be any supported kind for the type o I is an integer o KIND Shall be a scalar constant expression of type integer whose value is a supported integer kind. o The result is an integer of the same kind as I unless KIND is present, which is then used to specify the kind of the result.
MASKL(3) has its leftmost I bits set to 1, and the remaining bits set to
0.
o I : the number of left-most bits to set in the integer result. It must be from 0 to the number of bits for the kind of the result. The default kind of the result is the same as I unless the result size is specified by KIND. That is, these Fortran statements must be [char46]true. : i >= 0 .and. i < bitsize(i) ! if KIND is not specified i >= 0 .and. i < bitsize(0_KIND) ! if KIND is specified
o KIND : designates the kind of the integer result.
The leftmost I bits of the output integer are set to 1 and the other bits are set to 0.
Sample program:
program demo_maskl implicit none integer :: i ! basics i=3 write(*,(i0,1x,b0)) i, maskl(i)Results:! elemental write(*,(*(i11,1x,b0.32,1x,/))) maskl([(i,i,i=0,bit_size(0),4)]) end program demo_maskl
> 3 11100000000000000000000000000000 > 0 00000000000000000000000000000000 > -268435456 11110000000000000000000000000000 > -16777216 11111111000000000000000000000000 > -1048576 11111111111100000000000000000000 > -65536 11111111111111110000000000000000 > -4096 11111111111111111111000000000000 > -256 11111111111111111111111100000000 > -16 11111111111111111111111111110000 > -1 11111111111111111111111111111111
Fortran 2008
MASKR(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | maskl (3fortran) | November 02, 2024 |