! Elemental functions and subroutines are specified for scalar arguments ! but their beauty is that they can also be applied to arrays. However you ! need to specify INTENT of the variables. Also dummy arguments and result ! must not have the pointer attribute program main implicit none real :: x(5),y(5) ! Uses the Fortran intrinsic 'sqrt' x=(/ 25.0, 16.0, 9.0, 4.0, 1.0 /) y=sqrt(x) print*, y ! Uses a user-defined subroutine 'my_sqrt_sub' y=0.0 call my_sqrt_sub(x,y) print*, y ! Uses a user-defined function 'my_sqrt_func' y=0.0 y=my_sqrt_func(x) print*, y contains elemental subroutine my_sqrt_sub(a,b) implicit none real,intent(in) :: a real,intent(out) :: b b=(a)**(1.0/2.0) end subroutine my_sqrt_sub elemental function my_sqrt_func(a) implicit none real :: my_sqrt_func real, intent(in) :: a my_sqrt_func=(a)**(1.0/2.0) end function my_sqrt_func end program main