I'm coming to Fortran from Python.
In Python / NumPy I can do the following:
import numpy as np
a = np.arange(5)
b = a*10
print b[a == 3]
# Outputs: array([30])
In Fortran I have:
program test
implicit none
integer :: a(5)
integer :: b(5)
integer :: i
a = (/(i, i = 0, 4)/)
b = a*10
! I want to do this, but it doesn't work
!print *, b(a==3)
! So instead I do this...
do i=1,5
if(a(i)==3) print*, b(i)
enddo
end
Is there a more elegant way of doing this (for example, with intrinsic functions)?