Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
1
Task/Function-definition/Fortran/function-definition-1.f
Normal file
1
Task/Function-definition/Fortran/function-definition-1.f
Normal file
|
|
@ -0,0 +1 @@
|
|||
XMULTF(X,Y)=X*Y
|
||||
1
Task/Function-definition/Fortran/function-definition-2.f
Normal file
1
Task/Function-definition/Fortran/function-definition-2.f
Normal file
|
|
@ -0,0 +1 @@
|
|||
MULTF(I,J)=I*J
|
||||
4
Task/Function-definition/Fortran/function-definition-3.f
Normal file
4
Task/Function-definition/Fortran/function-definition-3.f
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
FUNCTION MULTIPLY(X,Y)
|
||||
REAL MULTIPLY, X, Y
|
||||
MULTIPLY = X * Y
|
||||
END
|
||||
4
Task/Function-definition/Fortran/function-definition-4.f
Normal file
4
Task/Function-definition/Fortran/function-definition-4.f
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
FUNCTION MULTINT(X,Y)
|
||||
INTEGER MULTINT, X, Y
|
||||
MULTINT = X * Y
|
||||
END
|
||||
8
Task/Function-definition/Fortran/function-definition-5.f
Normal file
8
Task/Function-definition/Fortran/function-definition-5.f
Normal 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
|
||||
10
Task/Function-definition/Fortran/function-definition-6.f
Normal file
10
Task/Function-definition/Fortran/function-definition-6.f
Normal 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
|
||||
2
Task/Function-definition/Fortran/function-definition-7.f
Normal file
2
Task/Function-definition/Fortran/function-definition-7.f
Normal 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)
|
||||
8
Task/Function-definition/Fortran/function-definition-8.f
Normal file
8
Task/Function-definition/Fortran/function-definition-8.f
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue