Kenneth_Smith
Joined: 18 May 2012 Posts: 753 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Thu Jan 02, 2025 3:39 pm Post subject: shiftr and shiftl |
|
|
Please consider adding shiftr and shiftl to the wish list.
I had to resort to adding a ftn95 specific module in order to compile and run a much larger program with ftn95
Thanks
Ken
Code: | winapp
module shift_ftn95_mod
implicit none
contains
integer function shiftr(i,n)
integer, intent(in) :: i, n
shiftr = ishft(i,-n)
end function shiftr
integer function shiftl(i,n)
integer, intent(in) :: i, n
shiftl = ishft(i,n)
end function shiftl
end module shift_ftn95_mod
program int_div_mult_by_2
use iso_fortran_env
use shift_ftn95_mod ! Required with FTN95
implicit none
integer i, j
write(*,'(a,/)') compiler_version()
i = 3 ! i = 3, j = 2
j = 2
print*, i/j ! i/j = 1
print*, ishft(i,-1) ! i / 2 = 1
print*, shiftr(i,1) ! i / 2 = 1
print*, i*j ! i x j = 6
print*, shiftl(i,1) ! i x 2 = 6
i = 4
print* ! i = 4, j = 2
print*, i/j ! i/j = 2
print*, ishft(i,-1) ! i / 2 = 2
print*, shiftr(i,1) ! i / 2 = 2
print*, i*j ! i x j = 8
print*, shiftl(i,1) ! i x 2 = 8
end program int_div_mult_by_2
|
Code: | FTN95 v9.04.0
1
1
1
6
6
2
2
2
8
8
|
|
|