This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,4 @@
FUNCTION MULTIPLY(X,Y)
REAL MULTIPLY, X, Y
MULTIPLY = X * Y
END

View file

@ -0,0 +1,8 @@
module elemFunc
contains
elemental function multiply(x, y)
real, intent(in) :: x, y
real :: multiply
multiply = x * y
end function multiply
end module elemFunc

View file

@ -0,0 +1,10 @@
program funcDemo
use elemFunc
real :: a = 20.0, b = 30.0, c
real, dimension(5) :: x = (/ 1.0, 2.0, 3.0, 4.0, 5.0 /), y = (/ 32.0, 16.0, 8.0, 4.0, 2.0 /), z
c = multiply(a,b) ! works with either function definition above
z = multiply(x,y) ! element-wise invocation only works with elemental function
end program funcDemo

View file

@ -0,0 +1,2 @@
c = multiply(y=b, x=a) ! the same as multiply(a, b)
z = multiply(y=x, x=y) ! the same as multiply(y, x)

View file

@ -0,0 +1,8 @@
module elemFunc
contains
elemental function multiply(x, y) result(z)
real, intent(in) :: x, y
real :: z
z = x * y
end function multiply
end module elemFunc