! Find the maximum element location in array
function maxindex_z(v)
use work

complex v(n)

maxindex_z =1

v_max =maxval(abs(v))

do i=1,n
if(abs(v(i)) ==v_max) then
maxindex_z =i
exit
endif
enddo

END
